f6825d0f8b68fc487969372e65acb50b408e5969
[ldk-java] / src / main / jni / bindings.c
1 #define LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ LDKCVec_TransactionOutputsZ
2 #define CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free CVec_TransactionOutputsZ_free
3 #include "org_ldk_impl_bindings.h"
4 #include <lightning.h>
5 #include <string.h>
6 #include <stdatomic.h>
7 #include <stdlib.h>
8
9 #define DEBUG_PRINT(...) fprintf(stderr, __VA_ARGS__)
10 #define MALLOC(a, _) malloc(a)
11 #define FREE(p) if ((uint64_t)(p) > 1024) { free(p); }
12 #define DO_ASSERT(a) (void)(a)
13 #define CHECK(a)
14
15 static jmethodID ordinal_meth = NULL;
16 static jmethodID slicedef_meth = NULL;
17 static jclass slicedef_cls = NULL;
18 JNIEXPORT void Java_org_ldk_impl_bindings_init(JNIEnv * env, jclass _b, jclass enum_class, jclass slicedef_class) {
19         ordinal_meth = (*env)->GetMethodID(env, enum_class, "ordinal", "()I");
20         CHECK(ordinal_meth != NULL);
21         slicedef_meth = (*env)->GetMethodID(env, slicedef_class, "<init>", "(JJJ)V");
22         CHECK(slicedef_meth != NULL);
23         slicedef_cls = (*env)->NewGlobalRef(env, slicedef_class);
24         CHECK(slicedef_cls != NULL);
25 }
26
27 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_deref_1bool (JNIEnv * env, jclass _a, jlong ptr) {
28         return *((bool*)ptr);
29 }
30 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_deref_1long (JNIEnv * env, jclass _a, jlong ptr) {
31         return *((long*)ptr);
32 }
33 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_free_1heap_1ptr (JNIEnv * env, jclass _a, jlong ptr) {
34         FREE((void*)ptr);
35 }
36 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_read_1bytes (JNIEnv * env, jclass _b, jlong ptr, jlong len) {
37         jbyteArray ret_arr = (*env)->NewByteArray(env, len);
38         (*env)->SetByteArrayRegion(env, ret_arr, 0, len, (unsigned char*)ptr);
39         return ret_arr;
40 }
41 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_get_1u8_1slice_1bytes (JNIEnv * env, jclass _b, jlong slice_ptr) {
42         LDKu8slice *slice = (LDKu8slice*)slice_ptr;
43         jbyteArray ret_arr = (*env)->NewByteArray(env, slice->datalen);
44         (*env)->SetByteArrayRegion(env, ret_arr, 0, slice->datalen, slice->data);
45         return ret_arr;
46 }
47 JNIEXPORT int64_t impl_bindings_bytes_1to_1u8_1vec (JNIEnv * env, jclass _b, jbyteArray bytes) {
48         LDKCVec_u8Z *vec = (LDKCVec_u8Z*)MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8");
49         vec->datalen = (*env)->GetArrayLength(env, bytes);
50         vec->data = (uint8_t*)MALLOC(vec->datalen, "LDKCVec_u8Z Bytes");
51         (*env)->GetByteArrayRegion (env, bytes, 0, vec->datalen, vec->data);
52         return (uint64_t)vec;
53 }
54 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_txpointer_1get_1buffer (JNIEnv * env, jclass _b, jlong ptr) {
55         LDKTransaction *txdata = (LDKTransaction*)ptr;
56         LDKu8slice slice;
57         slice.data = txdata->data;
58         slice.datalen = txdata->datalen;
59         return Java_org_ldk_impl_bindings_get_1u8_1slice_1bytes(env, _b, (uint64_t)&slice);
60 }
61 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_new_1txpointer_1copy_1data (JNIEnv * env, jclass _b, jbyteArray bytes) {
62         LDKTransaction *txdata = (LDKTransaction*)MALLOC(sizeof(LDKTransaction), "LDKTransaction");
63         txdata->datalen = (*env)->GetArrayLength(env, bytes);
64         txdata->data = (uint8_t*)MALLOC(txdata->datalen, "Tx Data Bytes");
65         txdata->data_is_owned = false;
66         (*env)->GetByteArrayRegion (env, bytes, 0, txdata->datalen, txdata->data);
67         return (uint64_t)txdata;
68 }
69 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_txpointer_1free (JNIEnv * env, jclass _b, jlong ptr) {
70         LDKTransaction *tx = (LDKTransaction*)ptr;
71         tx->data_is_owned = true;
72         Transaction_free(*tx);
73         FREE((void*)ptr);
74 }
75 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_vec_1slice_1len (JNIEnv * env, jclass _a, jlong ptr) {
76         // Check offsets of a few Vec types are all consistent as we're meant to be generic across types
77         _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_SignatureZ, datalen), "Vec<*> needs to be mapped identically");
78         _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_MessageSendEventZ, datalen), "Vec<*> needs to be mapped identically");
79         _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_EventZ, datalen), "Vec<*> needs to be mapped identically");
80         _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_C2Tuple_usizeTransactionZZ, datalen), "Vec<*> needs to be mapped identically");
81         LDKCVec_u8Z *vec = (LDKCVec_u8Z*)ptr;
82         return (uint64_t)vec->datalen;
83 }
84 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_new_1empty_1slice_1vec (JNIEnv * env, jclass _b) {
85         // Check sizes of a few Vec types are all consistent as we're meant to be generic across types
86         _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_SignatureZ), "Vec<*> needs to be mapped identically");
87         _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_MessageSendEventZ), "Vec<*> needs to be mapped identically");
88         _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_EventZ), "Vec<*> needs to be mapped identically");
89         _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_C2Tuple_usizeTransactionZZ), "Vec<*> needs to be mapped identically");
90         LDKCVec_u8Z *vec = (LDKCVec_u8Z*)MALLOC(sizeof(LDKCVec_u8Z), "Empty LDKCVec");
91         vec->data = NULL;
92         vec->datalen = 0;
93         return (uint64_t)vec;
94 }
95
96 // We assume that CVec_u8Z and u8slice are the same size and layout (and thus pointers to the two can be mixed)
97 _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKu8slice), "Vec<u8> and [u8] need to have been mapped identically");
98 _Static_assert(offsetof(LDKCVec_u8Z, data) == offsetof(LDKu8slice, data), "Vec<u8> and [u8] need to have been mapped identically");
99 _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKu8slice, datalen), "Vec<u8> and [u8] need to have been mapped identically");
100
101 _Static_assert(sizeof(jlong) == sizeof(int64_t), "We assume that j-types are the same as C types");
102 _Static_assert(sizeof(jbyte) == sizeof(char), "We assume that j-types are the same as C types");
103 _Static_assert(sizeof(void*) <= 8, "Pointers must fit into 64 bits");
104
105 typedef jlongArray int64_tArray;
106 typedef jbyteArray int8_tArray;
107
108 static inline jstring str_ref_to_java(JNIEnv *env, const char* chars, size_t len) {
109         // Sadly we need to create a temporary because Java can't accept a char* without a 0-terminator
110         char* conv_buf = MALLOC(len + 1, "str conv buf");
111         memcpy(conv_buf, chars, len);
112         conv_buf[len] = 0;
113         jstring ret = (*env)->NewStringUTF(env, conv_buf);
114         FREE(conv_buf);
115         return ret;
116 }
117 static inline LDKStr java_to_owned_str(JNIEnv *env, jstring str) {
118         uint64_t str_len = (*env)->GetStringUTFLength(env, str);
119         char* newchars = MALLOC(str_len + 1, "String chars");
120         const char* jchars = (*env)->GetStringUTFChars(env, str, NULL);
121         memcpy(newchars, jchars, str_len);
122         newchars[str_len] = 0;
123         (*env)->ReleaseStringUTFChars(env, str, jchars);
124         LDKStr res = {
125                 .chars = newchars,
126                 .len = str_len,
127                 .chars_is_owned = true
128         };
129         return res;
130 }
131
132 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_get_1lib_1version_1string(JNIEnv *env, jclass _c) {
133         return str_ref_to_java(env, "v0.0.13-26-gfb06c6a", strlen("v0.0.13-26-gfb06c6a"));
134 }
135 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_get_1ldk_1c_1bindings_1version(JNIEnv *env, jclass _c) {
136         return str_ref_to_java(env, check_get_ldk_bindings_version(), strlen(check_get_ldk_bindings_version()));
137 }
138 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_get_1ldk_1version(JNIEnv *env, jclass _c) {
139         return str_ref_to_java(env, check_get_ldk_version(), strlen(check_get_ldk_version()));
140 }
141 static jclass arr_of_B_clz = NULL;
142 static jclass arr_of_J_clz = NULL;
143 JNIEXPORT void Java_org_ldk_impl_bindings_init_1class_1cache(JNIEnv * env, jclass clz) {
144         arr_of_B_clz = (*env)->FindClass(env, "[B");
145         CHECK(arr_of_B_clz != NULL);
146         arr_of_B_clz = (*env)->NewGlobalRef(env, arr_of_B_clz);
147         arr_of_J_clz = (*env)->FindClass(env, "[J");
148         CHECK(arr_of_J_clz != NULL);
149         arr_of_J_clz = (*env)->NewGlobalRef(env, arr_of_J_clz);
150 }
151 static inline struct LDKThirtyTwoBytes ThirtyTwoBytes_clone(const struct LDKThirtyTwoBytes *orig) { struct LDKThirtyTwoBytes ret; memcpy(ret.data, orig->data, 32); return ret; }
152 static inline LDKAccessError LDKAccessError_from_java(JNIEnv *env, jclass clz) {
153         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
154                 case 0: return LDKAccessError_UnknownChain;
155                 case 1: return LDKAccessError_UnknownTx;
156         }
157         abort();
158 }
159 static jclass AccessError_class = NULL;
160 static jfieldID AccessError_LDKAccessError_UnknownChain = NULL;
161 static jfieldID AccessError_LDKAccessError_UnknownTx = NULL;
162 JNIEXPORT void JNICALL Java_org_ldk_enums_AccessError_init (JNIEnv *env, jclass clz) {
163         AccessError_class = (*env)->NewGlobalRef(env, clz);
164         CHECK(AccessError_class != NULL);
165         AccessError_LDKAccessError_UnknownChain = (*env)->GetStaticFieldID(env, AccessError_class, "LDKAccessError_UnknownChain", "Lorg/ldk/enums/AccessError;");
166         CHECK(AccessError_LDKAccessError_UnknownChain != NULL);
167         AccessError_LDKAccessError_UnknownTx = (*env)->GetStaticFieldID(env, AccessError_class, "LDKAccessError_UnknownTx", "Lorg/ldk/enums/AccessError;");
168         CHECK(AccessError_LDKAccessError_UnknownTx != NULL);
169 }
170 static inline jclass LDKAccessError_to_java(JNIEnv *env, LDKAccessError val) {
171         switch (val) {
172                 case LDKAccessError_UnknownChain:
173                         return (*env)->GetStaticObjectField(env, AccessError_class, AccessError_LDKAccessError_UnknownChain);
174                 case LDKAccessError_UnknownTx:
175                         return (*env)->GetStaticObjectField(env, AccessError_class, AccessError_LDKAccessError_UnknownTx);
176                 default: abort();
177         }
178 }
179
180 static inline LDKChannelMonitorUpdateErr LDKChannelMonitorUpdateErr_from_java(JNIEnv *env, jclass clz) {
181         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
182                 case 0: return LDKChannelMonitorUpdateErr_TemporaryFailure;
183                 case 1: return LDKChannelMonitorUpdateErr_PermanentFailure;
184         }
185         abort();
186 }
187 static jclass ChannelMonitorUpdateErr_class = NULL;
188 static jfieldID ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_TemporaryFailure = NULL;
189 static jfieldID ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_PermanentFailure = NULL;
190 JNIEXPORT void JNICALL Java_org_ldk_enums_ChannelMonitorUpdateErr_init (JNIEnv *env, jclass clz) {
191         ChannelMonitorUpdateErr_class = (*env)->NewGlobalRef(env, clz);
192         CHECK(ChannelMonitorUpdateErr_class != NULL);
193         ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_TemporaryFailure = (*env)->GetStaticFieldID(env, ChannelMonitorUpdateErr_class, "LDKChannelMonitorUpdateErr_TemporaryFailure", "Lorg/ldk/enums/ChannelMonitorUpdateErr;");
194         CHECK(ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_TemporaryFailure != NULL);
195         ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_PermanentFailure = (*env)->GetStaticFieldID(env, ChannelMonitorUpdateErr_class, "LDKChannelMonitorUpdateErr_PermanentFailure", "Lorg/ldk/enums/ChannelMonitorUpdateErr;");
196         CHECK(ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_PermanentFailure != NULL);
197 }
198 static inline jclass LDKChannelMonitorUpdateErr_to_java(JNIEnv *env, LDKChannelMonitorUpdateErr val) {
199         switch (val) {
200                 case LDKChannelMonitorUpdateErr_TemporaryFailure:
201                         return (*env)->GetStaticObjectField(env, ChannelMonitorUpdateErr_class, ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_TemporaryFailure);
202                 case LDKChannelMonitorUpdateErr_PermanentFailure:
203                         return (*env)->GetStaticObjectField(env, ChannelMonitorUpdateErr_class, ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_PermanentFailure);
204                 default: abort();
205         }
206 }
207
208 static inline LDKConfirmationTarget LDKConfirmationTarget_from_java(JNIEnv *env, jclass clz) {
209         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
210                 case 0: return LDKConfirmationTarget_Background;
211                 case 1: return LDKConfirmationTarget_Normal;
212                 case 2: return LDKConfirmationTarget_HighPriority;
213         }
214         abort();
215 }
216 static jclass ConfirmationTarget_class = NULL;
217 static jfieldID ConfirmationTarget_LDKConfirmationTarget_Background = NULL;
218 static jfieldID ConfirmationTarget_LDKConfirmationTarget_Normal = NULL;
219 static jfieldID ConfirmationTarget_LDKConfirmationTarget_HighPriority = NULL;
220 JNIEXPORT void JNICALL Java_org_ldk_enums_ConfirmationTarget_init (JNIEnv *env, jclass clz) {
221         ConfirmationTarget_class = (*env)->NewGlobalRef(env, clz);
222         CHECK(ConfirmationTarget_class != NULL);
223         ConfirmationTarget_LDKConfirmationTarget_Background = (*env)->GetStaticFieldID(env, ConfirmationTarget_class, "LDKConfirmationTarget_Background", "Lorg/ldk/enums/ConfirmationTarget;");
224         CHECK(ConfirmationTarget_LDKConfirmationTarget_Background != NULL);
225         ConfirmationTarget_LDKConfirmationTarget_Normal = (*env)->GetStaticFieldID(env, ConfirmationTarget_class, "LDKConfirmationTarget_Normal", "Lorg/ldk/enums/ConfirmationTarget;");
226         CHECK(ConfirmationTarget_LDKConfirmationTarget_Normal != NULL);
227         ConfirmationTarget_LDKConfirmationTarget_HighPriority = (*env)->GetStaticFieldID(env, ConfirmationTarget_class, "LDKConfirmationTarget_HighPriority", "Lorg/ldk/enums/ConfirmationTarget;");
228         CHECK(ConfirmationTarget_LDKConfirmationTarget_HighPriority != NULL);
229 }
230 static inline jclass LDKConfirmationTarget_to_java(JNIEnv *env, LDKConfirmationTarget val) {
231         switch (val) {
232                 case LDKConfirmationTarget_Background:
233                         return (*env)->GetStaticObjectField(env, ConfirmationTarget_class, ConfirmationTarget_LDKConfirmationTarget_Background);
234                 case LDKConfirmationTarget_Normal:
235                         return (*env)->GetStaticObjectField(env, ConfirmationTarget_class, ConfirmationTarget_LDKConfirmationTarget_Normal);
236                 case LDKConfirmationTarget_HighPriority:
237                         return (*env)->GetStaticObjectField(env, ConfirmationTarget_class, ConfirmationTarget_LDKConfirmationTarget_HighPriority);
238                 default: abort();
239         }
240 }
241
242 static inline LDKCreationError LDKCreationError_from_java(JNIEnv *env, jclass clz) {
243         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
244                 case 0: return LDKCreationError_DescriptionTooLong;
245                 case 1: return LDKCreationError_RouteTooLong;
246                 case 2: return LDKCreationError_TimestampOutOfBounds;
247                 case 3: return LDKCreationError_ExpiryTimeOutOfBounds;
248         }
249         abort();
250 }
251 static jclass CreationError_class = NULL;
252 static jfieldID CreationError_LDKCreationError_DescriptionTooLong = NULL;
253 static jfieldID CreationError_LDKCreationError_RouteTooLong = NULL;
254 static jfieldID CreationError_LDKCreationError_TimestampOutOfBounds = NULL;
255 static jfieldID CreationError_LDKCreationError_ExpiryTimeOutOfBounds = NULL;
256 JNIEXPORT void JNICALL Java_org_ldk_enums_CreationError_init (JNIEnv *env, jclass clz) {
257         CreationError_class = (*env)->NewGlobalRef(env, clz);
258         CHECK(CreationError_class != NULL);
259         CreationError_LDKCreationError_DescriptionTooLong = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_DescriptionTooLong", "Lorg/ldk/enums/CreationError;");
260         CHECK(CreationError_LDKCreationError_DescriptionTooLong != NULL);
261         CreationError_LDKCreationError_RouteTooLong = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_RouteTooLong", "Lorg/ldk/enums/CreationError;");
262         CHECK(CreationError_LDKCreationError_RouteTooLong != NULL);
263         CreationError_LDKCreationError_TimestampOutOfBounds = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_TimestampOutOfBounds", "Lorg/ldk/enums/CreationError;");
264         CHECK(CreationError_LDKCreationError_TimestampOutOfBounds != NULL);
265         CreationError_LDKCreationError_ExpiryTimeOutOfBounds = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_ExpiryTimeOutOfBounds", "Lorg/ldk/enums/CreationError;");
266         CHECK(CreationError_LDKCreationError_ExpiryTimeOutOfBounds != NULL);
267 }
268 static inline jclass LDKCreationError_to_java(JNIEnv *env, LDKCreationError val) {
269         switch (val) {
270                 case LDKCreationError_DescriptionTooLong:
271                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_DescriptionTooLong);
272                 case LDKCreationError_RouteTooLong:
273                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_RouteTooLong);
274                 case LDKCreationError_TimestampOutOfBounds:
275                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_TimestampOutOfBounds);
276                 case LDKCreationError_ExpiryTimeOutOfBounds:
277                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_ExpiryTimeOutOfBounds);
278                 default: abort();
279         }
280 }
281
282 static inline LDKCurrency LDKCurrency_from_java(JNIEnv *env, jclass clz) {
283         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
284                 case 0: return LDKCurrency_Bitcoin;
285                 case 1: return LDKCurrency_BitcoinTestnet;
286                 case 2: return LDKCurrency_Regtest;
287                 case 3: return LDKCurrency_Simnet;
288                 case 4: return LDKCurrency_Signet;
289         }
290         abort();
291 }
292 static jclass Currency_class = NULL;
293 static jfieldID Currency_LDKCurrency_Bitcoin = NULL;
294 static jfieldID Currency_LDKCurrency_BitcoinTestnet = NULL;
295 static jfieldID Currency_LDKCurrency_Regtest = NULL;
296 static jfieldID Currency_LDKCurrency_Simnet = NULL;
297 static jfieldID Currency_LDKCurrency_Signet = NULL;
298 JNIEXPORT void JNICALL Java_org_ldk_enums_Currency_init (JNIEnv *env, jclass clz) {
299         Currency_class = (*env)->NewGlobalRef(env, clz);
300         CHECK(Currency_class != NULL);
301         Currency_LDKCurrency_Bitcoin = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_Bitcoin", "Lorg/ldk/enums/Currency;");
302         CHECK(Currency_LDKCurrency_Bitcoin != NULL);
303         Currency_LDKCurrency_BitcoinTestnet = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_BitcoinTestnet", "Lorg/ldk/enums/Currency;");
304         CHECK(Currency_LDKCurrency_BitcoinTestnet != NULL);
305         Currency_LDKCurrency_Regtest = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_Regtest", "Lorg/ldk/enums/Currency;");
306         CHECK(Currency_LDKCurrency_Regtest != NULL);
307         Currency_LDKCurrency_Simnet = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_Simnet", "Lorg/ldk/enums/Currency;");
308         CHECK(Currency_LDKCurrency_Simnet != NULL);
309         Currency_LDKCurrency_Signet = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_Signet", "Lorg/ldk/enums/Currency;");
310         CHECK(Currency_LDKCurrency_Signet != NULL);
311 }
312 static inline jclass LDKCurrency_to_java(JNIEnv *env, LDKCurrency val) {
313         switch (val) {
314                 case LDKCurrency_Bitcoin:
315                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_Bitcoin);
316                 case LDKCurrency_BitcoinTestnet:
317                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_BitcoinTestnet);
318                 case LDKCurrency_Regtest:
319                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_Regtest);
320                 case LDKCurrency_Simnet:
321                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_Simnet);
322                 case LDKCurrency_Signet:
323                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_Signet);
324                 default: abort();
325         }
326 }
327
328 static inline LDKIOError LDKIOError_from_java(JNIEnv *env, jclass clz) {
329         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
330                 case 0: return LDKIOError_NotFound;
331                 case 1: return LDKIOError_PermissionDenied;
332                 case 2: return LDKIOError_ConnectionRefused;
333                 case 3: return LDKIOError_ConnectionReset;
334                 case 4: return LDKIOError_ConnectionAborted;
335                 case 5: return LDKIOError_NotConnected;
336                 case 6: return LDKIOError_AddrInUse;
337                 case 7: return LDKIOError_AddrNotAvailable;
338                 case 8: return LDKIOError_BrokenPipe;
339                 case 9: return LDKIOError_AlreadyExists;
340                 case 10: return LDKIOError_WouldBlock;
341                 case 11: return LDKIOError_InvalidInput;
342                 case 12: return LDKIOError_InvalidData;
343                 case 13: return LDKIOError_TimedOut;
344                 case 14: return LDKIOError_WriteZero;
345                 case 15: return LDKIOError_Interrupted;
346                 case 16: return LDKIOError_Other;
347                 case 17: return LDKIOError_UnexpectedEof;
348         }
349         abort();
350 }
351 static jclass IOError_class = NULL;
352 static jfieldID IOError_LDKIOError_NotFound = NULL;
353 static jfieldID IOError_LDKIOError_PermissionDenied = NULL;
354 static jfieldID IOError_LDKIOError_ConnectionRefused = NULL;
355 static jfieldID IOError_LDKIOError_ConnectionReset = NULL;
356 static jfieldID IOError_LDKIOError_ConnectionAborted = NULL;
357 static jfieldID IOError_LDKIOError_NotConnected = NULL;
358 static jfieldID IOError_LDKIOError_AddrInUse = NULL;
359 static jfieldID IOError_LDKIOError_AddrNotAvailable = NULL;
360 static jfieldID IOError_LDKIOError_BrokenPipe = NULL;
361 static jfieldID IOError_LDKIOError_AlreadyExists = NULL;
362 static jfieldID IOError_LDKIOError_WouldBlock = NULL;
363 static jfieldID IOError_LDKIOError_InvalidInput = NULL;
364 static jfieldID IOError_LDKIOError_InvalidData = NULL;
365 static jfieldID IOError_LDKIOError_TimedOut = NULL;
366 static jfieldID IOError_LDKIOError_WriteZero = NULL;
367 static jfieldID IOError_LDKIOError_Interrupted = NULL;
368 static jfieldID IOError_LDKIOError_Other = NULL;
369 static jfieldID IOError_LDKIOError_UnexpectedEof = NULL;
370 JNIEXPORT void JNICALL Java_org_ldk_enums_IOError_init (JNIEnv *env, jclass clz) {
371         IOError_class = (*env)->NewGlobalRef(env, clz);
372         CHECK(IOError_class != NULL);
373         IOError_LDKIOError_NotFound = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_NotFound", "Lorg/ldk/enums/IOError;");
374         CHECK(IOError_LDKIOError_NotFound != NULL);
375         IOError_LDKIOError_PermissionDenied = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_PermissionDenied", "Lorg/ldk/enums/IOError;");
376         CHECK(IOError_LDKIOError_PermissionDenied != NULL);
377         IOError_LDKIOError_ConnectionRefused = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_ConnectionRefused", "Lorg/ldk/enums/IOError;");
378         CHECK(IOError_LDKIOError_ConnectionRefused != NULL);
379         IOError_LDKIOError_ConnectionReset = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_ConnectionReset", "Lorg/ldk/enums/IOError;");
380         CHECK(IOError_LDKIOError_ConnectionReset != NULL);
381         IOError_LDKIOError_ConnectionAborted = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_ConnectionAborted", "Lorg/ldk/enums/IOError;");
382         CHECK(IOError_LDKIOError_ConnectionAborted != NULL);
383         IOError_LDKIOError_NotConnected = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_NotConnected", "Lorg/ldk/enums/IOError;");
384         CHECK(IOError_LDKIOError_NotConnected != NULL);
385         IOError_LDKIOError_AddrInUse = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_AddrInUse", "Lorg/ldk/enums/IOError;");
386         CHECK(IOError_LDKIOError_AddrInUse != NULL);
387         IOError_LDKIOError_AddrNotAvailable = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_AddrNotAvailable", "Lorg/ldk/enums/IOError;");
388         CHECK(IOError_LDKIOError_AddrNotAvailable != NULL);
389         IOError_LDKIOError_BrokenPipe = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_BrokenPipe", "Lorg/ldk/enums/IOError;");
390         CHECK(IOError_LDKIOError_BrokenPipe != NULL);
391         IOError_LDKIOError_AlreadyExists = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_AlreadyExists", "Lorg/ldk/enums/IOError;");
392         CHECK(IOError_LDKIOError_AlreadyExists != NULL);
393         IOError_LDKIOError_WouldBlock = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_WouldBlock", "Lorg/ldk/enums/IOError;");
394         CHECK(IOError_LDKIOError_WouldBlock != NULL);
395         IOError_LDKIOError_InvalidInput = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_InvalidInput", "Lorg/ldk/enums/IOError;");
396         CHECK(IOError_LDKIOError_InvalidInput != NULL);
397         IOError_LDKIOError_InvalidData = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_InvalidData", "Lorg/ldk/enums/IOError;");
398         CHECK(IOError_LDKIOError_InvalidData != NULL);
399         IOError_LDKIOError_TimedOut = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_TimedOut", "Lorg/ldk/enums/IOError;");
400         CHECK(IOError_LDKIOError_TimedOut != NULL);
401         IOError_LDKIOError_WriteZero = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_WriteZero", "Lorg/ldk/enums/IOError;");
402         CHECK(IOError_LDKIOError_WriteZero != NULL);
403         IOError_LDKIOError_Interrupted = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_Interrupted", "Lorg/ldk/enums/IOError;");
404         CHECK(IOError_LDKIOError_Interrupted != NULL);
405         IOError_LDKIOError_Other = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_Other", "Lorg/ldk/enums/IOError;");
406         CHECK(IOError_LDKIOError_Other != NULL);
407         IOError_LDKIOError_UnexpectedEof = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_UnexpectedEof", "Lorg/ldk/enums/IOError;");
408         CHECK(IOError_LDKIOError_UnexpectedEof != NULL);
409 }
410 static inline jclass LDKIOError_to_java(JNIEnv *env, LDKIOError val) {
411         switch (val) {
412                 case LDKIOError_NotFound:
413                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_NotFound);
414                 case LDKIOError_PermissionDenied:
415                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_PermissionDenied);
416                 case LDKIOError_ConnectionRefused:
417                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_ConnectionRefused);
418                 case LDKIOError_ConnectionReset:
419                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_ConnectionReset);
420                 case LDKIOError_ConnectionAborted:
421                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_ConnectionAborted);
422                 case LDKIOError_NotConnected:
423                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_NotConnected);
424                 case LDKIOError_AddrInUse:
425                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_AddrInUse);
426                 case LDKIOError_AddrNotAvailable:
427                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_AddrNotAvailable);
428                 case LDKIOError_BrokenPipe:
429                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_BrokenPipe);
430                 case LDKIOError_AlreadyExists:
431                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_AlreadyExists);
432                 case LDKIOError_WouldBlock:
433                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_WouldBlock);
434                 case LDKIOError_InvalidInput:
435                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_InvalidInput);
436                 case LDKIOError_InvalidData:
437                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_InvalidData);
438                 case LDKIOError_TimedOut:
439                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_TimedOut);
440                 case LDKIOError_WriteZero:
441                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_WriteZero);
442                 case LDKIOError_Interrupted:
443                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_Interrupted);
444                 case LDKIOError_Other:
445                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_Other);
446                 case LDKIOError_UnexpectedEof:
447                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_UnexpectedEof);
448                 default: abort();
449         }
450 }
451
452 static inline LDKLevel LDKLevel_from_java(JNIEnv *env, jclass clz) {
453         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
454                 case 0: return LDKLevel_Off;
455                 case 1: return LDKLevel_Error;
456                 case 2: return LDKLevel_Warn;
457                 case 3: return LDKLevel_Info;
458                 case 4: return LDKLevel_Debug;
459                 case 5: return LDKLevel_Trace;
460         }
461         abort();
462 }
463 static jclass Level_class = NULL;
464 static jfieldID Level_LDKLevel_Off = NULL;
465 static jfieldID Level_LDKLevel_Error = NULL;
466 static jfieldID Level_LDKLevel_Warn = NULL;
467 static jfieldID Level_LDKLevel_Info = NULL;
468 static jfieldID Level_LDKLevel_Debug = NULL;
469 static jfieldID Level_LDKLevel_Trace = NULL;
470 JNIEXPORT void JNICALL Java_org_ldk_enums_Level_init (JNIEnv *env, jclass clz) {
471         Level_class = (*env)->NewGlobalRef(env, clz);
472         CHECK(Level_class != NULL);
473         Level_LDKLevel_Off = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Off", "Lorg/ldk/enums/Level;");
474         CHECK(Level_LDKLevel_Off != NULL);
475         Level_LDKLevel_Error = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Error", "Lorg/ldk/enums/Level;");
476         CHECK(Level_LDKLevel_Error != NULL);
477         Level_LDKLevel_Warn = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Warn", "Lorg/ldk/enums/Level;");
478         CHECK(Level_LDKLevel_Warn != NULL);
479         Level_LDKLevel_Info = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Info", "Lorg/ldk/enums/Level;");
480         CHECK(Level_LDKLevel_Info != NULL);
481         Level_LDKLevel_Debug = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Debug", "Lorg/ldk/enums/Level;");
482         CHECK(Level_LDKLevel_Debug != NULL);
483         Level_LDKLevel_Trace = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Trace", "Lorg/ldk/enums/Level;");
484         CHECK(Level_LDKLevel_Trace != NULL);
485 }
486 static inline jclass LDKLevel_to_java(JNIEnv *env, LDKLevel val) {
487         switch (val) {
488                 case LDKLevel_Off:
489                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Off);
490                 case LDKLevel_Error:
491                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Error);
492                 case LDKLevel_Warn:
493                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Warn);
494                 case LDKLevel_Info:
495                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Info);
496                 case LDKLevel_Debug:
497                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Debug);
498                 case LDKLevel_Trace:
499                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Trace);
500                 default: abort();
501         }
502 }
503
504 static inline LDKNetwork LDKNetwork_from_java(JNIEnv *env, jclass clz) {
505         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
506                 case 0: return LDKNetwork_Bitcoin;
507                 case 1: return LDKNetwork_Testnet;
508                 case 2: return LDKNetwork_Regtest;
509                 case 3: return LDKNetwork_Signet;
510         }
511         abort();
512 }
513 static jclass Network_class = NULL;
514 static jfieldID Network_LDKNetwork_Bitcoin = NULL;
515 static jfieldID Network_LDKNetwork_Testnet = NULL;
516 static jfieldID Network_LDKNetwork_Regtest = NULL;
517 static jfieldID Network_LDKNetwork_Signet = NULL;
518 JNIEXPORT void JNICALL Java_org_ldk_enums_Network_init (JNIEnv *env, jclass clz) {
519         Network_class = (*env)->NewGlobalRef(env, clz);
520         CHECK(Network_class != NULL);
521         Network_LDKNetwork_Bitcoin = (*env)->GetStaticFieldID(env, Network_class, "LDKNetwork_Bitcoin", "Lorg/ldk/enums/Network;");
522         CHECK(Network_LDKNetwork_Bitcoin != NULL);
523         Network_LDKNetwork_Testnet = (*env)->GetStaticFieldID(env, Network_class, "LDKNetwork_Testnet", "Lorg/ldk/enums/Network;");
524         CHECK(Network_LDKNetwork_Testnet != NULL);
525         Network_LDKNetwork_Regtest = (*env)->GetStaticFieldID(env, Network_class, "LDKNetwork_Regtest", "Lorg/ldk/enums/Network;");
526         CHECK(Network_LDKNetwork_Regtest != NULL);
527         Network_LDKNetwork_Signet = (*env)->GetStaticFieldID(env, Network_class, "LDKNetwork_Signet", "Lorg/ldk/enums/Network;");
528         CHECK(Network_LDKNetwork_Signet != NULL);
529 }
530 static inline jclass LDKNetwork_to_java(JNIEnv *env, LDKNetwork val) {
531         switch (val) {
532                 case LDKNetwork_Bitcoin:
533                         return (*env)->GetStaticObjectField(env, Network_class, Network_LDKNetwork_Bitcoin);
534                 case LDKNetwork_Testnet:
535                         return (*env)->GetStaticObjectField(env, Network_class, Network_LDKNetwork_Testnet);
536                 case LDKNetwork_Regtest:
537                         return (*env)->GetStaticObjectField(env, Network_class, Network_LDKNetwork_Regtest);
538                 case LDKNetwork_Signet:
539                         return (*env)->GetStaticObjectField(env, Network_class, Network_LDKNetwork_Signet);
540                 default: abort();
541         }
542 }
543
544 static inline LDKSecp256k1Error LDKSecp256k1Error_from_java(JNIEnv *env, jclass clz) {
545         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
546                 case 0: return LDKSecp256k1Error_IncorrectSignature;
547                 case 1: return LDKSecp256k1Error_InvalidMessage;
548                 case 2: return LDKSecp256k1Error_InvalidPublicKey;
549                 case 3: return LDKSecp256k1Error_InvalidSignature;
550                 case 4: return LDKSecp256k1Error_InvalidSecretKey;
551                 case 5: return LDKSecp256k1Error_InvalidRecoveryId;
552                 case 6: return LDKSecp256k1Error_InvalidTweak;
553                 case 7: return LDKSecp256k1Error_TweakCheckFailed;
554                 case 8: return LDKSecp256k1Error_NotEnoughMemory;
555         }
556         abort();
557 }
558 static jclass Secp256k1Error_class = NULL;
559 static jfieldID Secp256k1Error_LDKSecp256k1Error_IncorrectSignature = NULL;
560 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidMessage = NULL;
561 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey = NULL;
562 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidSignature = NULL;
563 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey = NULL;
564 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId = NULL;
565 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidTweak = NULL;
566 static jfieldID Secp256k1Error_LDKSecp256k1Error_TweakCheckFailed = NULL;
567 static jfieldID Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory = NULL;
568 JNIEXPORT void JNICALL Java_org_ldk_enums_Secp256k1Error_init (JNIEnv *env, jclass clz) {
569         Secp256k1Error_class = (*env)->NewGlobalRef(env, clz);
570         CHECK(Secp256k1Error_class != NULL);
571         Secp256k1Error_LDKSecp256k1Error_IncorrectSignature = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_IncorrectSignature", "Lorg/ldk/enums/Secp256k1Error;");
572         CHECK(Secp256k1Error_LDKSecp256k1Error_IncorrectSignature != NULL);
573         Secp256k1Error_LDKSecp256k1Error_InvalidMessage = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidMessage", "Lorg/ldk/enums/Secp256k1Error;");
574         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidMessage != NULL);
575         Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidPublicKey", "Lorg/ldk/enums/Secp256k1Error;");
576         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey != NULL);
577         Secp256k1Error_LDKSecp256k1Error_InvalidSignature = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidSignature", "Lorg/ldk/enums/Secp256k1Error;");
578         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidSignature != NULL);
579         Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidSecretKey", "Lorg/ldk/enums/Secp256k1Error;");
580         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey != NULL);
581         Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidRecoveryId", "Lorg/ldk/enums/Secp256k1Error;");
582         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId != NULL);
583         Secp256k1Error_LDKSecp256k1Error_InvalidTweak = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidTweak", "Lorg/ldk/enums/Secp256k1Error;");
584         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidTweak != NULL);
585         Secp256k1Error_LDKSecp256k1Error_TweakCheckFailed = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_TweakCheckFailed", "Lorg/ldk/enums/Secp256k1Error;");
586         CHECK(Secp256k1Error_LDKSecp256k1Error_TweakCheckFailed != NULL);
587         Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_NotEnoughMemory", "Lorg/ldk/enums/Secp256k1Error;");
588         CHECK(Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory != NULL);
589 }
590 static inline jclass LDKSecp256k1Error_to_java(JNIEnv *env, LDKSecp256k1Error val) {
591         switch (val) {
592                 case LDKSecp256k1Error_IncorrectSignature:
593                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_IncorrectSignature);
594                 case LDKSecp256k1Error_InvalidMessage:
595                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidMessage);
596                 case LDKSecp256k1Error_InvalidPublicKey:
597                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey);
598                 case LDKSecp256k1Error_InvalidSignature:
599                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidSignature);
600                 case LDKSecp256k1Error_InvalidSecretKey:
601                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey);
602                 case LDKSecp256k1Error_InvalidRecoveryId:
603                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId);
604                 case LDKSecp256k1Error_InvalidTweak:
605                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidTweak);
606                 case LDKSecp256k1Error_TweakCheckFailed:
607                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_TweakCheckFailed);
608                 case LDKSecp256k1Error_NotEnoughMemory:
609                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory);
610                 default: abort();
611         }
612 }
613
614 static inline LDKSemanticError LDKSemanticError_from_java(JNIEnv *env, jclass clz) {
615         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
616                 case 0: return LDKSemanticError_NoPaymentHash;
617                 case 1: return LDKSemanticError_MultiplePaymentHashes;
618                 case 2: return LDKSemanticError_NoDescription;
619                 case 3: return LDKSemanticError_MultipleDescriptions;
620                 case 4: return LDKSemanticError_MultiplePaymentSecrets;
621                 case 5: return LDKSemanticError_InvalidFeatures;
622                 case 6: return LDKSemanticError_InvalidRecoveryId;
623                 case 7: return LDKSemanticError_InvalidSignature;
624         }
625         abort();
626 }
627 static jclass SemanticError_class = NULL;
628 static jfieldID SemanticError_LDKSemanticError_NoPaymentHash = NULL;
629 static jfieldID SemanticError_LDKSemanticError_MultiplePaymentHashes = NULL;
630 static jfieldID SemanticError_LDKSemanticError_NoDescription = NULL;
631 static jfieldID SemanticError_LDKSemanticError_MultipleDescriptions = NULL;
632 static jfieldID SemanticError_LDKSemanticError_MultiplePaymentSecrets = NULL;
633 static jfieldID SemanticError_LDKSemanticError_InvalidFeatures = NULL;
634 static jfieldID SemanticError_LDKSemanticError_InvalidRecoveryId = NULL;
635 static jfieldID SemanticError_LDKSemanticError_InvalidSignature = NULL;
636 JNIEXPORT void JNICALL Java_org_ldk_enums_SemanticError_init (JNIEnv *env, jclass clz) {
637         SemanticError_class = (*env)->NewGlobalRef(env, clz);
638         CHECK(SemanticError_class != NULL);
639         SemanticError_LDKSemanticError_NoPaymentHash = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_NoPaymentHash", "Lorg/ldk/enums/SemanticError;");
640         CHECK(SemanticError_LDKSemanticError_NoPaymentHash != NULL);
641         SemanticError_LDKSemanticError_MultiplePaymentHashes = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_MultiplePaymentHashes", "Lorg/ldk/enums/SemanticError;");
642         CHECK(SemanticError_LDKSemanticError_MultiplePaymentHashes != NULL);
643         SemanticError_LDKSemanticError_NoDescription = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_NoDescription", "Lorg/ldk/enums/SemanticError;");
644         CHECK(SemanticError_LDKSemanticError_NoDescription != NULL);
645         SemanticError_LDKSemanticError_MultipleDescriptions = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_MultipleDescriptions", "Lorg/ldk/enums/SemanticError;");
646         CHECK(SemanticError_LDKSemanticError_MultipleDescriptions != NULL);
647         SemanticError_LDKSemanticError_MultiplePaymentSecrets = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_MultiplePaymentSecrets", "Lorg/ldk/enums/SemanticError;");
648         CHECK(SemanticError_LDKSemanticError_MultiplePaymentSecrets != NULL);
649         SemanticError_LDKSemanticError_InvalidFeatures = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_InvalidFeatures", "Lorg/ldk/enums/SemanticError;");
650         CHECK(SemanticError_LDKSemanticError_InvalidFeatures != NULL);
651         SemanticError_LDKSemanticError_InvalidRecoveryId = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_InvalidRecoveryId", "Lorg/ldk/enums/SemanticError;");
652         CHECK(SemanticError_LDKSemanticError_InvalidRecoveryId != NULL);
653         SemanticError_LDKSemanticError_InvalidSignature = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_InvalidSignature", "Lorg/ldk/enums/SemanticError;");
654         CHECK(SemanticError_LDKSemanticError_InvalidSignature != NULL);
655 }
656 static inline jclass LDKSemanticError_to_java(JNIEnv *env, LDKSemanticError val) {
657         switch (val) {
658                 case LDKSemanticError_NoPaymentHash:
659                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_NoPaymentHash);
660                 case LDKSemanticError_MultiplePaymentHashes:
661                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_MultiplePaymentHashes);
662                 case LDKSemanticError_NoDescription:
663                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_NoDescription);
664                 case LDKSemanticError_MultipleDescriptions:
665                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_MultipleDescriptions);
666                 case LDKSemanticError_MultiplePaymentSecrets:
667                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_MultiplePaymentSecrets);
668                 case LDKSemanticError_InvalidFeatures:
669                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_InvalidFeatures);
670                 case LDKSemanticError_InvalidRecoveryId:
671                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_InvalidRecoveryId);
672                 case LDKSemanticError_InvalidSignature:
673                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_InvalidSignature);
674                 default: abort();
675         }
676 }
677
678 static inline LDKSiPrefix LDKSiPrefix_from_java(JNIEnv *env, jclass clz) {
679         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
680                 case 0: return LDKSiPrefix_Milli;
681                 case 1: return LDKSiPrefix_Micro;
682                 case 2: return LDKSiPrefix_Nano;
683                 case 3: return LDKSiPrefix_Pico;
684         }
685         abort();
686 }
687 static jclass SiPrefix_class = NULL;
688 static jfieldID SiPrefix_LDKSiPrefix_Milli = NULL;
689 static jfieldID SiPrefix_LDKSiPrefix_Micro = NULL;
690 static jfieldID SiPrefix_LDKSiPrefix_Nano = NULL;
691 static jfieldID SiPrefix_LDKSiPrefix_Pico = NULL;
692 JNIEXPORT void JNICALL Java_org_ldk_enums_SiPrefix_init (JNIEnv *env, jclass clz) {
693         SiPrefix_class = (*env)->NewGlobalRef(env, clz);
694         CHECK(SiPrefix_class != NULL);
695         SiPrefix_LDKSiPrefix_Milli = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Milli", "Lorg/ldk/enums/SiPrefix;");
696         CHECK(SiPrefix_LDKSiPrefix_Milli != NULL);
697         SiPrefix_LDKSiPrefix_Micro = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Micro", "Lorg/ldk/enums/SiPrefix;");
698         CHECK(SiPrefix_LDKSiPrefix_Micro != NULL);
699         SiPrefix_LDKSiPrefix_Nano = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Nano", "Lorg/ldk/enums/SiPrefix;");
700         CHECK(SiPrefix_LDKSiPrefix_Nano != NULL);
701         SiPrefix_LDKSiPrefix_Pico = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Pico", "Lorg/ldk/enums/SiPrefix;");
702         CHECK(SiPrefix_LDKSiPrefix_Pico != NULL);
703 }
704 static inline jclass LDKSiPrefix_to_java(JNIEnv *env, LDKSiPrefix val) {
705         switch (val) {
706                 case LDKSiPrefix_Milli:
707                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Milli);
708                 case LDKSiPrefix_Micro:
709                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Micro);
710                 case LDKSiPrefix_Nano:
711                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Nano);
712                 case LDKSiPrefix_Pico:
713                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Pico);
714                 default: abort();
715         }
716 }
717
718 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1u8Z_1new(JNIEnv *env, jclass clz, int8_tArray elems) {
719         LDKCVec_u8Z *ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
720         ret->datalen = (*env)->GetArrayLength(env, elems);
721         if (ret->datalen == 0) {
722                 ret->data = NULL;
723         } else {
724                 ret->data = MALLOC(sizeof(uint8_t) * ret->datalen, "LDKCVec_u8Z Data");
725                 int8_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
726                 for (size_t i = 0; i < ret->datalen; i++) {
727                         ret->data[i] = java_elems[i];
728                 }
729                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
730         }
731         return (uint64_t)ret;
732 }
733 static inline LDKCVec_u8Z CVec_u8Z_clone(const LDKCVec_u8Z *orig) {
734         LDKCVec_u8Z ret = { .data = MALLOC(sizeof(int8_t) * orig->datalen, "LDKCVec_u8Z clone bytes"), .datalen = orig->datalen };
735         memcpy(ret.data, orig->data, sizeof(int8_t) * ret.datalen);
736         return ret;
737 }
738 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SecretKeyErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
739         return ((LDKCResult_SecretKeyErrorZ*)arg)->result_ok;
740 }
741 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SecretKeyErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
742         LDKCResult_SecretKeyErrorZ *val = (LDKCResult_SecretKeyErrorZ*)(arg & ~1);
743         CHECK(val->result_ok);
744         int8_tArray res_arr = (*env)->NewByteArray(env, 32);
745         (*env)->SetByteArrayRegion(env, res_arr, 0, 32, (*val->contents.result).bytes);
746         return res_arr;
747 }
748 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SecretKeyErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
749         LDKCResult_SecretKeyErrorZ *val = (LDKCResult_SecretKeyErrorZ*)(arg & ~1);
750         CHECK(!val->result_ok);
751         jclass err_conv = LDKSecp256k1Error_to_java(env, (*val->contents.err));
752         return err_conv;
753 }
754 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PublicKeyErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
755         return ((LDKCResult_PublicKeyErrorZ*)arg)->result_ok;
756 }
757 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PublicKeyErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
758         LDKCResult_PublicKeyErrorZ *val = (LDKCResult_PublicKeyErrorZ*)(arg & ~1);
759         CHECK(val->result_ok);
760         int8_tArray res_arr = (*env)->NewByteArray(env, 33);
761         (*env)->SetByteArrayRegion(env, res_arr, 0, 33, (*val->contents.result).compressed_form);
762         return res_arr;
763 }
764 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PublicKeyErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
765         LDKCResult_PublicKeyErrorZ *val = (LDKCResult_PublicKeyErrorZ*)(arg & ~1);
766         CHECK(!val->result_ok);
767         jclass err_conv = LDKSecp256k1Error_to_java(env, (*val->contents.err));
768         return err_conv;
769 }
770 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
771         return ((LDKCResult_TxCreationKeysDecodeErrorZ*)arg)->result_ok;
772 }
773 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
774         LDKCResult_TxCreationKeysDecodeErrorZ *val = (LDKCResult_TxCreationKeysDecodeErrorZ*)(arg & ~1);
775         CHECK(val->result_ok);
776         LDKTxCreationKeys res_var = (*val->contents.result);
777         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
778         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
779         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
780         return res_ref;
781 }
782 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
783         LDKCResult_TxCreationKeysDecodeErrorZ *val = (LDKCResult_TxCreationKeysDecodeErrorZ*)(arg & ~1);
784         CHECK(!val->result_ok);
785         LDKDecodeError err_var = (*val->contents.err);
786         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
787         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
788         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
789         return err_ref;
790 }
791 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelPublicKeysDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
792         return ((LDKCResult_ChannelPublicKeysDecodeErrorZ*)arg)->result_ok;
793 }
794 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelPublicKeysDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
795         LDKCResult_ChannelPublicKeysDecodeErrorZ *val = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(arg & ~1);
796         CHECK(val->result_ok);
797         LDKChannelPublicKeys res_var = (*val->contents.result);
798         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
799         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
800         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
801         return res_ref;
802 }
803 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelPublicKeysDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
804         LDKCResult_ChannelPublicKeysDecodeErrorZ *val = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(arg & ~1);
805         CHECK(!val->result_ok);
806         LDKDecodeError err_var = (*val->contents.err);
807         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
808         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
809         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
810         return err_ref;
811 }
812 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
813         return ((LDKCResult_TxCreationKeysErrorZ*)arg)->result_ok;
814 }
815 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
816         LDKCResult_TxCreationKeysErrorZ *val = (LDKCResult_TxCreationKeysErrorZ*)(arg & ~1);
817         CHECK(val->result_ok);
818         LDKTxCreationKeys res_var = (*val->contents.result);
819         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
820         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
821         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
822         return res_ref;
823 }
824 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
825         LDKCResult_TxCreationKeysErrorZ *val = (LDKCResult_TxCreationKeysErrorZ*)(arg & ~1);
826         CHECK(!val->result_ok);
827         jclass err_conv = LDKSecp256k1Error_to_java(env, (*val->contents.err));
828         return err_conv;
829 }
830 static jclass LDKCOption_u32Z_Some_class = NULL;
831 static jmethodID LDKCOption_u32Z_Some_meth = NULL;
832 static jclass LDKCOption_u32Z_None_class = NULL;
833 static jmethodID LDKCOption_u32Z_None_meth = NULL;
834 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u32Z_init (JNIEnv *env, jclass clz) {
835         LDKCOption_u32Z_Some_class =
836                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_u32Z$Some;"));
837         CHECK(LDKCOption_u32Z_Some_class != NULL);
838         LDKCOption_u32Z_Some_meth = (*env)->GetMethodID(env, LDKCOption_u32Z_Some_class, "<init>", "(I)V");
839         CHECK(LDKCOption_u32Z_Some_meth != NULL);
840         LDKCOption_u32Z_None_class =
841                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_u32Z$None;"));
842         CHECK(LDKCOption_u32Z_None_class != NULL);
843         LDKCOption_u32Z_None_meth = (*env)->GetMethodID(env, LDKCOption_u32Z_None_class, "<init>", "()V");
844         CHECK(LDKCOption_u32Z_None_meth != NULL);
845 }
846 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u32Z_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
847         LDKCOption_u32Z *obj = (LDKCOption_u32Z*)(ptr & ~1);
848         switch(obj->tag) {
849                 case LDKCOption_u32Z_Some: {
850                         return (*env)->NewObject(env, LDKCOption_u32Z_Some_class, LDKCOption_u32Z_Some_meth, obj->some);
851                 }
852                 case LDKCOption_u32Z_None: {
853                         return (*env)->NewObject(env, LDKCOption_u32Z_None_class, LDKCOption_u32Z_None_meth);
854                 }
855                 default: abort();
856         }
857 }
858 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCOutputInCommitmentDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
859         return ((LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)arg)->result_ok;
860 }
861 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCOutputInCommitmentDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
862         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *val = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(arg & ~1);
863         CHECK(val->result_ok);
864         LDKHTLCOutputInCommitment res_var = (*val->contents.result);
865         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
866         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
867         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
868         return res_ref;
869 }
870 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCOutputInCommitmentDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
871         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *val = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(arg & ~1);
872         CHECK(!val->result_ok);
873         LDKDecodeError err_var = (*val->contents.err);
874         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
875         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
876         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
877         return err_ref;
878 }
879 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
880         return ((LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)arg)->result_ok;
881 }
882 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
883         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
884         CHECK(val->result_ok);
885         LDKCounterpartyChannelTransactionParameters res_var = (*val->contents.result);
886         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
887         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
888         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
889         return res_ref;
890 }
891 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
892         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
893         CHECK(!val->result_ok);
894         LDKDecodeError err_var = (*val->contents.err);
895         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
896         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
897         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
898         return err_ref;
899 }
900 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelTransactionParametersDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
901         return ((LDKCResult_ChannelTransactionParametersDecodeErrorZ*)arg)->result_ok;
902 }
903 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelTransactionParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
904         LDKCResult_ChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
905         CHECK(val->result_ok);
906         LDKChannelTransactionParameters res_var = (*val->contents.result);
907         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
908         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
909         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
910         return res_ref;
911 }
912 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelTransactionParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
913         LDKCResult_ChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
914         CHECK(!val->result_ok);
915         LDKDecodeError err_var = (*val->contents.err);
916         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
917         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
918         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
919         return err_ref;
920 }
921 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HolderCommitmentTransactionDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
922         return ((LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)arg)->result_ok;
923 }
924 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HolderCommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
925         LDKCResult_HolderCommitmentTransactionDecodeErrorZ *val = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(arg & ~1);
926         CHECK(val->result_ok);
927         LDKHolderCommitmentTransaction res_var = (*val->contents.result);
928         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
929         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
930         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
931         return res_ref;
932 }
933 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HolderCommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
934         LDKCResult_HolderCommitmentTransactionDecodeErrorZ *val = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(arg & ~1);
935         CHECK(!val->result_ok);
936         LDKDecodeError err_var = (*val->contents.err);
937         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
938         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
939         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
940         return err_ref;
941 }
942 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1BuiltCommitmentTransactionDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
943         return ((LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)arg)->result_ok;
944 }
945 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1BuiltCommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
946         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *val = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(arg & ~1);
947         CHECK(val->result_ok);
948         LDKBuiltCommitmentTransaction res_var = (*val->contents.result);
949         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
950         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
951         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
952         return res_ref;
953 }
954 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1BuiltCommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
955         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *val = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(arg & ~1);
956         CHECK(!val->result_ok);
957         LDKDecodeError err_var = (*val->contents.err);
958         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
959         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
960         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
961         return err_ref;
962 }
963 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentTransactionDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
964         return ((LDKCResult_CommitmentTransactionDecodeErrorZ*)arg)->result_ok;
965 }
966 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
967         LDKCResult_CommitmentTransactionDecodeErrorZ *val = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(arg & ~1);
968         CHECK(val->result_ok);
969         LDKCommitmentTransaction res_var = (*val->contents.result);
970         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
971         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
972         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
973         return res_ref;
974 }
975 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
976         LDKCResult_CommitmentTransactionDecodeErrorZ *val = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(arg & ~1);
977         CHECK(!val->result_ok);
978         LDKDecodeError err_var = (*val->contents.err);
979         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
980         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
981         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
982         return err_ref;
983 }
984 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TrustedCommitmentTransactionNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
985         return ((LDKCResult_TrustedCommitmentTransactionNoneZ*)arg)->result_ok;
986 }
987 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TrustedCommitmentTransactionNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
988         LDKCResult_TrustedCommitmentTransactionNoneZ *val = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(arg & ~1);
989         CHECK(val->result_ok);
990         LDKTrustedCommitmentTransaction res_var = (*val->contents.result);
991         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
992         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
993         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
994         return res_ref;
995 }
996 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TrustedCommitmentTransactionNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
997         LDKCResult_TrustedCommitmentTransactionNoneZ *val = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(arg & ~1);
998         CHECK(!val->result_ok);
999         return *val->contents.err;
1000 }
1001 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1SignatureZNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1002         return ((LDKCResult_CVec_SignatureZNoneZ*)arg)->result_ok;
1003 }
1004 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1SignatureZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1005         LDKCResult_CVec_SignatureZNoneZ *val = (LDKCResult_CVec_SignatureZNoneZ*)(arg & ~1);
1006         CHECK(val->result_ok);
1007         LDKCVec_SignatureZ res_var = (*val->contents.result);
1008         jobjectArray res_arr = (*env)->NewObjectArray(env, res_var.datalen, arr_of_B_clz, NULL);
1009         ;
1010         for (size_t i = 0; i < res_var.datalen; i++) {
1011                 int8_tArray res_conv_8_arr = (*env)->NewByteArray(env, 64);
1012                 (*env)->SetByteArrayRegion(env, res_conv_8_arr, 0, 64, res_var.data[i].compact_form);
1013                 (*env)->SetObjectArrayElement(env, res_arr, i, res_conv_8_arr);
1014         }
1015         return res_arr;
1016 }
1017 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1SignatureZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1018         LDKCResult_CVec_SignatureZNoneZ *val = (LDKCResult_CVec_SignatureZNoneZ*)(arg & ~1);
1019         CHECK(!val->result_ok);
1020         return *val->contents.err;
1021 }
1022 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1023         return ((LDKCResult_NoneErrorZ*)arg)->result_ok;
1024 }
1025 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1026         LDKCResult_NoneErrorZ *val = (LDKCResult_NoneErrorZ*)(arg & ~1);
1027         CHECK(val->result_ok);
1028         return *val->contents.result;
1029 }
1030 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1031         LDKCResult_NoneErrorZ *val = (LDKCResult_NoneErrorZ*)(arg & ~1);
1032         CHECK(!val->result_ok);
1033         jclass err_conv = LDKIOError_to_java(env, (*val->contents.err));
1034         return err_conv;
1035 }
1036 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteHopDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1037         return ((LDKCResult_RouteHopDecodeErrorZ*)arg)->result_ok;
1038 }
1039 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteHopDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1040         LDKCResult_RouteHopDecodeErrorZ *val = (LDKCResult_RouteHopDecodeErrorZ*)(arg & ~1);
1041         CHECK(val->result_ok);
1042         LDKRouteHop res_var = (*val->contents.result);
1043         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1044         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1045         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1046         return res_ref;
1047 }
1048 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteHopDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1049         LDKCResult_RouteHopDecodeErrorZ *val = (LDKCResult_RouteHopDecodeErrorZ*)(arg & ~1);
1050         CHECK(!val->result_ok);
1051         LDKDecodeError err_var = (*val->contents.err);
1052         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1053         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1054         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1055         return err_ref;
1056 }
1057 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1RouteHopZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1058         LDKCVec_RouteHopZ *ret = MALLOC(sizeof(LDKCVec_RouteHopZ), "LDKCVec_RouteHopZ");
1059         ret->datalen = (*env)->GetArrayLength(env, elems);
1060         if (ret->datalen == 0) {
1061                 ret->data = NULL;
1062         } else {
1063                 ret->data = MALLOC(sizeof(LDKRouteHop) * ret->datalen, "LDKCVec_RouteHopZ Data");
1064                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1065                 for (size_t i = 0; i < ret->datalen; i++) {
1066                         int64_t arr_elem = java_elems[i];
1067                         LDKRouteHop arr_elem_conv;
1068                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
1069                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
1070                         arr_elem_conv = RouteHop_clone(&arr_elem_conv);
1071                         ret->data[i] = arr_elem_conv;
1072                 }
1073                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1074         }
1075         return (uint64_t)ret;
1076 }
1077 static inline LDKCVec_RouteHopZ CVec_RouteHopZ_clone(const LDKCVec_RouteHopZ *orig) {
1078         LDKCVec_RouteHopZ ret = { .data = MALLOC(sizeof(LDKRouteHop) * orig->datalen, "LDKCVec_RouteHopZ clone bytes"), .datalen = orig->datalen };
1079         for (size_t i = 0; i < ret.datalen; i++) {
1080                 ret.data[i] = RouteHop_clone(&orig->data[i]);
1081         }
1082         return ret;
1083 }
1084 static inline LDKCVec_CVec_RouteHopZZ CVec_CVec_RouteHopZZ_clone(const LDKCVec_CVec_RouteHopZZ *orig) {
1085         LDKCVec_CVec_RouteHopZZ ret = { .data = MALLOC(sizeof(LDKCVec_RouteHopZ) * orig->datalen, "LDKCVec_CVec_RouteHopZZ clone bytes"), .datalen = orig->datalen };
1086         for (size_t i = 0; i < ret.datalen; i++) {
1087                 ret.data[i] = CVec_RouteHopZ_clone(&orig->data[i]);
1088         }
1089         return ret;
1090 }
1091 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1092         return ((LDKCResult_RouteDecodeErrorZ*)arg)->result_ok;
1093 }
1094 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1095         LDKCResult_RouteDecodeErrorZ *val = (LDKCResult_RouteDecodeErrorZ*)(arg & ~1);
1096         CHECK(val->result_ok);
1097         LDKRoute res_var = (*val->contents.result);
1098         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1099         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1100         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1101         return res_ref;
1102 }
1103 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1104         LDKCResult_RouteDecodeErrorZ *val = (LDKCResult_RouteDecodeErrorZ*)(arg & ~1);
1105         CHECK(!val->result_ok);
1106         LDKDecodeError err_var = (*val->contents.err);
1107         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1108         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1109         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1110         return err_ref;
1111 }
1112 static jclass LDKCOption_u64Z_Some_class = NULL;
1113 static jmethodID LDKCOption_u64Z_Some_meth = NULL;
1114 static jclass LDKCOption_u64Z_None_class = NULL;
1115 static jmethodID LDKCOption_u64Z_None_meth = NULL;
1116 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u64Z_init (JNIEnv *env, jclass clz) {
1117         LDKCOption_u64Z_Some_class =
1118                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_u64Z$Some;"));
1119         CHECK(LDKCOption_u64Z_Some_class != NULL);
1120         LDKCOption_u64Z_Some_meth = (*env)->GetMethodID(env, LDKCOption_u64Z_Some_class, "<init>", "(J)V");
1121         CHECK(LDKCOption_u64Z_Some_meth != NULL);
1122         LDKCOption_u64Z_None_class =
1123                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_u64Z$None;"));
1124         CHECK(LDKCOption_u64Z_None_class != NULL);
1125         LDKCOption_u64Z_None_meth = (*env)->GetMethodID(env, LDKCOption_u64Z_None_class, "<init>", "()V");
1126         CHECK(LDKCOption_u64Z_None_meth != NULL);
1127 }
1128 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u64Z_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1129         LDKCOption_u64Z *obj = (LDKCOption_u64Z*)(ptr & ~1);
1130         switch(obj->tag) {
1131                 case LDKCOption_u64Z_Some: {
1132                         return (*env)->NewObject(env, LDKCOption_u64Z_Some_class, LDKCOption_u64Z_Some_meth, obj->some);
1133                 }
1134                 case LDKCOption_u64Z_None: {
1135                         return (*env)->NewObject(env, LDKCOption_u64Z_None_class, LDKCOption_u64Z_None_meth);
1136                 }
1137                 default: abort();
1138         }
1139 }
1140 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1ChannelDetailsZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1141         LDKCVec_ChannelDetailsZ *ret = MALLOC(sizeof(LDKCVec_ChannelDetailsZ), "LDKCVec_ChannelDetailsZ");
1142         ret->datalen = (*env)->GetArrayLength(env, elems);
1143         if (ret->datalen == 0) {
1144                 ret->data = NULL;
1145         } else {
1146                 ret->data = MALLOC(sizeof(LDKChannelDetails) * ret->datalen, "LDKCVec_ChannelDetailsZ Data");
1147                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1148                 for (size_t i = 0; i < ret->datalen; i++) {
1149                         int64_t arr_elem = java_elems[i];
1150                         LDKChannelDetails arr_elem_conv;
1151                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
1152                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
1153                         arr_elem_conv = ChannelDetails_clone(&arr_elem_conv);
1154                         ret->data[i] = arr_elem_conv;
1155                 }
1156                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1157         }
1158         return (uint64_t)ret;
1159 }
1160 static inline LDKCVec_ChannelDetailsZ CVec_ChannelDetailsZ_clone(const LDKCVec_ChannelDetailsZ *orig) {
1161         LDKCVec_ChannelDetailsZ ret = { .data = MALLOC(sizeof(LDKChannelDetails) * orig->datalen, "LDKCVec_ChannelDetailsZ clone bytes"), .datalen = orig->datalen };
1162         for (size_t i = 0; i < ret.datalen; i++) {
1163                 ret.data[i] = ChannelDetails_clone(&orig->data[i]);
1164         }
1165         return ret;
1166 }
1167 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1RouteHintZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1168         LDKCVec_RouteHintZ *ret = MALLOC(sizeof(LDKCVec_RouteHintZ), "LDKCVec_RouteHintZ");
1169         ret->datalen = (*env)->GetArrayLength(env, elems);
1170         if (ret->datalen == 0) {
1171                 ret->data = NULL;
1172         } else {
1173                 ret->data = MALLOC(sizeof(LDKRouteHint) * ret->datalen, "LDKCVec_RouteHintZ Data");
1174                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1175                 for (size_t i = 0; i < ret->datalen; i++) {
1176                         int64_t arr_elem = java_elems[i];
1177                         LDKRouteHint arr_elem_conv;
1178                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
1179                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
1180                         arr_elem_conv = RouteHint_clone(&arr_elem_conv);
1181                         ret->data[i] = arr_elem_conv;
1182                 }
1183                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1184         }
1185         return (uint64_t)ret;
1186 }
1187 static inline LDKCVec_RouteHintZ CVec_RouteHintZ_clone(const LDKCVec_RouteHintZ *orig) {
1188         LDKCVec_RouteHintZ ret = { .data = MALLOC(sizeof(LDKRouteHint) * orig->datalen, "LDKCVec_RouteHintZ clone bytes"), .datalen = orig->datalen };
1189         for (size_t i = 0; i < ret.datalen; i++) {
1190                 ret.data[i] = RouteHint_clone(&orig->data[i]);
1191         }
1192         return ret;
1193 }
1194 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteLightningErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1195         return ((LDKCResult_RouteLightningErrorZ*)arg)->result_ok;
1196 }
1197 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1198         LDKCResult_RouteLightningErrorZ *val = (LDKCResult_RouteLightningErrorZ*)(arg & ~1);
1199         CHECK(val->result_ok);
1200         LDKRoute res_var = (*val->contents.result);
1201         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1202         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1203         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1204         return res_ref;
1205 }
1206 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1207         LDKCResult_RouteLightningErrorZ *val = (LDKCResult_RouteLightningErrorZ*)(arg & ~1);
1208         CHECK(!val->result_ok);
1209         LDKLightningError err_var = (*val->contents.err);
1210         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1211         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1212         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1213         return err_ref;
1214 }
1215 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxOutAccessErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1216         return ((LDKCResult_TxOutAccessErrorZ*)arg)->result_ok;
1217 }
1218 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxOutAccessErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1219         LDKCResult_TxOutAccessErrorZ *val = (LDKCResult_TxOutAccessErrorZ*)(arg & ~1);
1220         CHECK(val->result_ok);
1221         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
1222         return (uint64_t)res_ref;
1223 }
1224 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxOutAccessErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1225         LDKCResult_TxOutAccessErrorZ *val = (LDKCResult_TxOutAccessErrorZ*)(arg & ~1);
1226         CHECK(!val->result_ok);
1227         jclass err_conv = LDKAccessError_to_java(env, (*val->contents.err));
1228         return err_conv;
1229 }
1230 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1usizeTransactionZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
1231         LDKC2Tuple_usizeTransactionZ* ret = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
1232         ret->a = a;
1233         LDKTransaction b_ref;
1234         b_ref.datalen = (*env)->GetArrayLength(env, b);
1235         b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
1236         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
1237         b_ref.data_is_owned = false;
1238         ret->b = b_ref;
1239         return (uint64_t)ret;
1240 }
1241 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1usizeTransactionZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
1242         LDKC2Tuple_usizeTransactionZ *tuple = (LDKC2Tuple_usizeTransactionZ*)(ptr & ~1);
1243         return tuple->a;
1244 }
1245 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1usizeTransactionZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
1246         LDKC2Tuple_usizeTransactionZ *tuple = (LDKC2Tuple_usizeTransactionZ*)(ptr & ~1);
1247         LDKTransaction b_var = tuple->b;
1248         int8_tArray b_arr = (*env)->NewByteArray(env, b_var.datalen);
1249         (*env)->SetByteArrayRegion(env, b_arr, 0, b_var.datalen, b_var.data);
1250         return b_arr;
1251 }
1252 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1usizeTransactionZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1253         LDKCVec_C2Tuple_usizeTransactionZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_usizeTransactionZZ), "LDKCVec_C2Tuple_usizeTransactionZZ");
1254         ret->datalen = (*env)->GetArrayLength(env, elems);
1255         if (ret->datalen == 0) {
1256                 ret->data = NULL;
1257         } else {
1258                 ret->data = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ) * ret->datalen, "LDKCVec_C2Tuple_usizeTransactionZZ Data");
1259                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1260                 for (size_t i = 0; i < ret->datalen; i++) {
1261                         int64_t arr_elem = java_elems[i];
1262                         LDKC2Tuple_usizeTransactionZ arr_elem_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)arr_elem) & ~1);
1263                         arr_elem_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)arr_elem) & ~1));
1264                         ret->data[i] = arr_elem_conv;
1265                 }
1266                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1267         }
1268         return (uint64_t)ret;
1269 }
1270 static inline LDKCVec_C2Tuple_usizeTransactionZZ CVec_C2Tuple_usizeTransactionZZ_clone(const LDKCVec_C2Tuple_usizeTransactionZZ *orig) {
1271         LDKCVec_C2Tuple_usizeTransactionZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ) * orig->datalen, "LDKCVec_C2Tuple_usizeTransactionZZ clone bytes"), .datalen = orig->datalen };
1272         for (size_t i = 0; i < ret.datalen; i++) {
1273                 ret.data[i] = C2Tuple_usizeTransactionZ_clone(&orig->data[i]);
1274         }
1275         return ret;
1276 }
1277 static inline LDKCVec_TxidZ CVec_ThirtyTwoBytesZ_clone(const LDKCVec_TxidZ *orig) {
1278         LDKCVec_TxidZ ret = { .data = MALLOC(sizeof(LDKThirtyTwoBytes) * orig->datalen, "LDKCVec_TxidZ clone bytes"), .datalen = orig->datalen };
1279         for (size_t i = 0; i < ret.datalen; i++) {
1280                 ret.data[i] = ThirtyTwoBytes_clone(&orig->data[i]);
1281         }
1282         return ret;
1283 }
1284 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneChannelMonitorUpdateErrZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1285         return ((LDKCResult_NoneChannelMonitorUpdateErrZ*)arg)->result_ok;
1286 }
1287 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneChannelMonitorUpdateErrZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1288         LDKCResult_NoneChannelMonitorUpdateErrZ *val = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(arg & ~1);
1289         CHECK(val->result_ok);
1290         return *val->contents.result;
1291 }
1292 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneChannelMonitorUpdateErrZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1293         LDKCResult_NoneChannelMonitorUpdateErrZ *val = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(arg & ~1);
1294         CHECK(!val->result_ok);
1295         jclass err_conv = LDKChannelMonitorUpdateErr_to_java(env, (*val->contents.err));
1296         return err_conv;
1297 }
1298 static jclass LDKMonitorEvent_HTLCEvent_class = NULL;
1299 static jmethodID LDKMonitorEvent_HTLCEvent_meth = NULL;
1300 static jclass LDKMonitorEvent_CommitmentTxBroadcasted_class = NULL;
1301 static jmethodID LDKMonitorEvent_CommitmentTxBroadcasted_meth = NULL;
1302 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKMonitorEvent_init (JNIEnv *env, jclass clz) {
1303         LDKMonitorEvent_HTLCEvent_class =
1304                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMonitorEvent$HTLCEvent;"));
1305         CHECK(LDKMonitorEvent_HTLCEvent_class != NULL);
1306         LDKMonitorEvent_HTLCEvent_meth = (*env)->GetMethodID(env, LDKMonitorEvent_HTLCEvent_class, "<init>", "(J)V");
1307         CHECK(LDKMonitorEvent_HTLCEvent_meth != NULL);
1308         LDKMonitorEvent_CommitmentTxBroadcasted_class =
1309                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMonitorEvent$CommitmentTxBroadcasted;"));
1310         CHECK(LDKMonitorEvent_CommitmentTxBroadcasted_class != NULL);
1311         LDKMonitorEvent_CommitmentTxBroadcasted_meth = (*env)->GetMethodID(env, LDKMonitorEvent_CommitmentTxBroadcasted_class, "<init>", "(J)V");
1312         CHECK(LDKMonitorEvent_CommitmentTxBroadcasted_meth != NULL);
1313 }
1314 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKMonitorEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1315         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
1316         switch(obj->tag) {
1317                 case LDKMonitorEvent_HTLCEvent: {
1318                         LDKHTLCUpdate htlc_event_var = obj->htlc_event;
1319                         CHECK((((uint64_t)htlc_event_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1320                         CHECK((((uint64_t)&htlc_event_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1321                         uint64_t htlc_event_ref = (uint64_t)htlc_event_var.inner & ~1;
1322                         return (*env)->NewObject(env, LDKMonitorEvent_HTLCEvent_class, LDKMonitorEvent_HTLCEvent_meth, htlc_event_ref);
1323                 }
1324                 case LDKMonitorEvent_CommitmentTxBroadcasted: {
1325                         LDKOutPoint commitment_tx_broadcasted_var = obj->commitment_tx_broadcasted;
1326                         CHECK((((uint64_t)commitment_tx_broadcasted_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1327                         CHECK((((uint64_t)&commitment_tx_broadcasted_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1328                         uint64_t commitment_tx_broadcasted_ref = (uint64_t)commitment_tx_broadcasted_var.inner & ~1;
1329                         return (*env)->NewObject(env, LDKMonitorEvent_CommitmentTxBroadcasted_class, LDKMonitorEvent_CommitmentTxBroadcasted_meth, commitment_tx_broadcasted_ref);
1330                 }
1331                 default: abort();
1332         }
1333 }
1334 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1MonitorEventZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1335         LDKCVec_MonitorEventZ *ret = MALLOC(sizeof(LDKCVec_MonitorEventZ), "LDKCVec_MonitorEventZ");
1336         ret->datalen = (*env)->GetArrayLength(env, elems);
1337         if (ret->datalen == 0) {
1338                 ret->data = NULL;
1339         } else {
1340                 ret->data = MALLOC(sizeof(LDKMonitorEvent) * ret->datalen, "LDKCVec_MonitorEventZ Data");
1341                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1342                 for (size_t i = 0; i < ret->datalen; i++) {
1343                         int64_t arr_elem = java_elems[i];
1344                         LDKMonitorEvent arr_elem_conv = *(LDKMonitorEvent*)(((uint64_t)arr_elem) & ~1);
1345                         arr_elem_conv = MonitorEvent_clone((LDKMonitorEvent*)(((uint64_t)arr_elem) & ~1));
1346                         ret->data[i] = arr_elem_conv;
1347                 }
1348                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1349         }
1350         return (uint64_t)ret;
1351 }
1352 static inline LDKCVec_MonitorEventZ CVec_MonitorEventZ_clone(const LDKCVec_MonitorEventZ *orig) {
1353         LDKCVec_MonitorEventZ ret = { .data = MALLOC(sizeof(LDKMonitorEvent) * orig->datalen, "LDKCVec_MonitorEventZ clone bytes"), .datalen = orig->datalen };
1354         for (size_t i = 0; i < ret.datalen; i++) {
1355                 ret.data[i] = MonitorEvent_clone(&orig->data[i]);
1356         }
1357         return ret;
1358 }
1359 static jclass LDKCOption_C2Tuple_usizeTransactionZZ_Some_class = NULL;
1360 static jmethodID LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth = NULL;
1361 static jclass LDKCOption_C2Tuple_usizeTransactionZZ_None_class = NULL;
1362 static jmethodID LDKCOption_C2Tuple_usizeTransactionZZ_None_meth = NULL;
1363 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1C2Tuple_1usizeTransactionZZ_init (JNIEnv *env, jclass clz) {
1364         LDKCOption_C2Tuple_usizeTransactionZZ_Some_class =
1365                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_C2Tuple_usizeTransactionZZ$Some;"));
1366         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_Some_class != NULL);
1367         LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_C2Tuple_usizeTransactionZZ_Some_class, "<init>", "(J)V");
1368         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth != NULL);
1369         LDKCOption_C2Tuple_usizeTransactionZZ_None_class =
1370                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_C2Tuple_usizeTransactionZZ$None;"));
1371         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_None_class != NULL);
1372         LDKCOption_C2Tuple_usizeTransactionZZ_None_meth = (*env)->GetMethodID(env, LDKCOption_C2Tuple_usizeTransactionZZ_None_class, "<init>", "()V");
1373         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_None_meth != NULL);
1374 }
1375 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1C2Tuple_1usizeTransactionZZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1376         LDKCOption_C2Tuple_usizeTransactionZZ *obj = (LDKCOption_C2Tuple_usizeTransactionZZ*)(ptr & ~1);
1377         switch(obj->tag) {
1378                 case LDKCOption_C2Tuple_usizeTransactionZZ_Some: {
1379                         uint64_t some_ref = (uint64_t)(&obj->some) | 1;
1380                         return (*env)->NewObject(env, LDKCOption_C2Tuple_usizeTransactionZZ_Some_class, LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth, some_ref);
1381                 }
1382                 case LDKCOption_C2Tuple_usizeTransactionZZ_None: {
1383                         return (*env)->NewObject(env, LDKCOption_C2Tuple_usizeTransactionZZ_None_class, LDKCOption_C2Tuple_usizeTransactionZZ_None_meth);
1384                 }
1385                 default: abort();
1386         }
1387 }
1388 static jclass LDKSpendableOutputDescriptor_StaticOutput_class = NULL;
1389 static jmethodID LDKSpendableOutputDescriptor_StaticOutput_meth = NULL;
1390 static jclass LDKSpendableOutputDescriptor_DelayedPaymentOutput_class = NULL;
1391 static jmethodID LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth = NULL;
1392 static jclass LDKSpendableOutputDescriptor_StaticPaymentOutput_class = NULL;
1393 static jmethodID LDKSpendableOutputDescriptor_StaticPaymentOutput_meth = NULL;
1394 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKSpendableOutputDescriptor_init (JNIEnv *env, jclass clz) {
1395         LDKSpendableOutputDescriptor_StaticOutput_class =
1396                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKSpendableOutputDescriptor$StaticOutput;"));
1397         CHECK(LDKSpendableOutputDescriptor_StaticOutput_class != NULL);
1398         LDKSpendableOutputDescriptor_StaticOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_StaticOutput_class, "<init>", "(JJ)V");
1399         CHECK(LDKSpendableOutputDescriptor_StaticOutput_meth != NULL);
1400         LDKSpendableOutputDescriptor_DelayedPaymentOutput_class =
1401                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKSpendableOutputDescriptor$DelayedPaymentOutput;"));
1402         CHECK(LDKSpendableOutputDescriptor_DelayedPaymentOutput_class != NULL);
1403         LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_DelayedPaymentOutput_class, "<init>", "(J)V");
1404         CHECK(LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth != NULL);
1405         LDKSpendableOutputDescriptor_StaticPaymentOutput_class =
1406                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKSpendableOutputDescriptor$StaticPaymentOutput;"));
1407         CHECK(LDKSpendableOutputDescriptor_StaticPaymentOutput_class != NULL);
1408         LDKSpendableOutputDescriptor_StaticPaymentOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_StaticPaymentOutput_class, "<init>", "(J)V");
1409         CHECK(LDKSpendableOutputDescriptor_StaticPaymentOutput_meth != NULL);
1410 }
1411 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKSpendableOutputDescriptor_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1412         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)(ptr & ~1);
1413         switch(obj->tag) {
1414                 case LDKSpendableOutputDescriptor_StaticOutput: {
1415                         LDKOutPoint outpoint_var = obj->static_output.outpoint;
1416                         CHECK((((uint64_t)outpoint_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1417                         CHECK((((uint64_t)&outpoint_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1418                         uint64_t outpoint_ref = (uint64_t)outpoint_var.inner & ~1;
1419                         uint64_t output_ref = ((uint64_t)&obj->static_output.output) | 1;
1420                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_StaticOutput_class, LDKSpendableOutputDescriptor_StaticOutput_meth, outpoint_ref, (uint64_t)output_ref);
1421                 }
1422                 case LDKSpendableOutputDescriptor_DelayedPaymentOutput: {
1423                         LDKDelayedPaymentOutputDescriptor delayed_payment_output_var = obj->delayed_payment_output;
1424                         CHECK((((uint64_t)delayed_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1425                         CHECK((((uint64_t)&delayed_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1426                         uint64_t delayed_payment_output_ref = (uint64_t)delayed_payment_output_var.inner & ~1;
1427                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_DelayedPaymentOutput_class, LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth, delayed_payment_output_ref);
1428                 }
1429                 case LDKSpendableOutputDescriptor_StaticPaymentOutput: {
1430                         LDKStaticPaymentOutputDescriptor static_payment_output_var = obj->static_payment_output;
1431                         CHECK((((uint64_t)static_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1432                         CHECK((((uint64_t)&static_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1433                         uint64_t static_payment_output_ref = (uint64_t)static_payment_output_var.inner & ~1;
1434                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_StaticPaymentOutput_class, LDKSpendableOutputDescriptor_StaticPaymentOutput_meth, static_payment_output_ref);
1435                 }
1436                 default: abort();
1437         }
1438 }
1439 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1SpendableOutputDescriptorZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1440         LDKCVec_SpendableOutputDescriptorZ *ret = MALLOC(sizeof(LDKCVec_SpendableOutputDescriptorZ), "LDKCVec_SpendableOutputDescriptorZ");
1441         ret->datalen = (*env)->GetArrayLength(env, elems);
1442         if (ret->datalen == 0) {
1443                 ret->data = NULL;
1444         } else {
1445                 ret->data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * ret->datalen, "LDKCVec_SpendableOutputDescriptorZ Data");
1446                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1447                 for (size_t i = 0; i < ret->datalen; i++) {
1448                         int64_t arr_elem = java_elems[i];
1449                         LDKSpendableOutputDescriptor arr_elem_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)arr_elem) & ~1);
1450                         arr_elem_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uint64_t)arr_elem) & ~1));
1451                         ret->data[i] = arr_elem_conv;
1452                 }
1453                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1454         }
1455         return (uint64_t)ret;
1456 }
1457 static inline LDKCVec_SpendableOutputDescriptorZ CVec_SpendableOutputDescriptorZ_clone(const LDKCVec_SpendableOutputDescriptorZ *orig) {
1458         LDKCVec_SpendableOutputDescriptorZ ret = { .data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * orig->datalen, "LDKCVec_SpendableOutputDescriptorZ clone bytes"), .datalen = orig->datalen };
1459         for (size_t i = 0; i < ret.datalen; i++) {
1460                 ret.data[i] = SpendableOutputDescriptor_clone(&orig->data[i]);
1461         }
1462         return ret;
1463 }
1464 static jclass LDKErrorAction_DisconnectPeer_class = NULL;
1465 static jmethodID LDKErrorAction_DisconnectPeer_meth = NULL;
1466 static jclass LDKErrorAction_IgnoreError_class = NULL;
1467 static jmethodID LDKErrorAction_IgnoreError_meth = NULL;
1468 static jclass LDKErrorAction_SendErrorMessage_class = NULL;
1469 static jmethodID LDKErrorAction_SendErrorMessage_meth = NULL;
1470 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKErrorAction_init (JNIEnv *env, jclass clz) {
1471         LDKErrorAction_DisconnectPeer_class =
1472                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKErrorAction$DisconnectPeer;"));
1473         CHECK(LDKErrorAction_DisconnectPeer_class != NULL);
1474         LDKErrorAction_DisconnectPeer_meth = (*env)->GetMethodID(env, LDKErrorAction_DisconnectPeer_class, "<init>", "(J)V");
1475         CHECK(LDKErrorAction_DisconnectPeer_meth != NULL);
1476         LDKErrorAction_IgnoreError_class =
1477                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKErrorAction$IgnoreError;"));
1478         CHECK(LDKErrorAction_IgnoreError_class != NULL);
1479         LDKErrorAction_IgnoreError_meth = (*env)->GetMethodID(env, LDKErrorAction_IgnoreError_class, "<init>", "()V");
1480         CHECK(LDKErrorAction_IgnoreError_meth != NULL);
1481         LDKErrorAction_SendErrorMessage_class =
1482                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKErrorAction$SendErrorMessage;"));
1483         CHECK(LDKErrorAction_SendErrorMessage_class != NULL);
1484         LDKErrorAction_SendErrorMessage_meth = (*env)->GetMethodID(env, LDKErrorAction_SendErrorMessage_class, "<init>", "(J)V");
1485         CHECK(LDKErrorAction_SendErrorMessage_meth != NULL);
1486 }
1487 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKErrorAction_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1488         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
1489         switch(obj->tag) {
1490                 case LDKErrorAction_DisconnectPeer: {
1491                         LDKErrorMessage msg_var = obj->disconnect_peer.msg;
1492                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1493                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1494                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1495                         return (*env)->NewObject(env, LDKErrorAction_DisconnectPeer_class, LDKErrorAction_DisconnectPeer_meth, msg_ref);
1496                 }
1497                 case LDKErrorAction_IgnoreError: {
1498                         return (*env)->NewObject(env, LDKErrorAction_IgnoreError_class, LDKErrorAction_IgnoreError_meth);
1499                 }
1500                 case LDKErrorAction_SendErrorMessage: {
1501                         LDKErrorMessage msg_var = obj->send_error_message.msg;
1502                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1503                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1504                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1505                         return (*env)->NewObject(env, LDKErrorAction_SendErrorMessage_class, LDKErrorAction_SendErrorMessage_meth, msg_ref);
1506                 }
1507                 default: abort();
1508         }
1509 }
1510 static jclass LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class = NULL;
1511 static jmethodID LDKHTLCFailChannelUpdate_ChannelUpdateMessage_meth = NULL;
1512 static jclass LDKHTLCFailChannelUpdate_ChannelClosed_class = NULL;
1513 static jmethodID LDKHTLCFailChannelUpdate_ChannelClosed_meth = NULL;
1514 static jclass LDKHTLCFailChannelUpdate_NodeFailure_class = NULL;
1515 static jmethodID LDKHTLCFailChannelUpdate_NodeFailure_meth = NULL;
1516 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKHTLCFailChannelUpdate_init (JNIEnv *env, jclass clz) {
1517         LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class =
1518                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKHTLCFailChannelUpdate$ChannelUpdateMessage;"));
1519         CHECK(LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class != NULL);
1520         LDKHTLCFailChannelUpdate_ChannelUpdateMessage_meth = (*env)->GetMethodID(env, LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class, "<init>", "(J)V");
1521         CHECK(LDKHTLCFailChannelUpdate_ChannelUpdateMessage_meth != NULL);
1522         LDKHTLCFailChannelUpdate_ChannelClosed_class =
1523                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKHTLCFailChannelUpdate$ChannelClosed;"));
1524         CHECK(LDKHTLCFailChannelUpdate_ChannelClosed_class != NULL);
1525         LDKHTLCFailChannelUpdate_ChannelClosed_meth = (*env)->GetMethodID(env, LDKHTLCFailChannelUpdate_ChannelClosed_class, "<init>", "(JZ)V");
1526         CHECK(LDKHTLCFailChannelUpdate_ChannelClosed_meth != NULL);
1527         LDKHTLCFailChannelUpdate_NodeFailure_class =
1528                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKHTLCFailChannelUpdate$NodeFailure;"));
1529         CHECK(LDKHTLCFailChannelUpdate_NodeFailure_class != NULL);
1530         LDKHTLCFailChannelUpdate_NodeFailure_meth = (*env)->GetMethodID(env, LDKHTLCFailChannelUpdate_NodeFailure_class, "<init>", "([BZ)V");
1531         CHECK(LDKHTLCFailChannelUpdate_NodeFailure_meth != NULL);
1532 }
1533 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKHTLCFailChannelUpdate_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1534         LDKHTLCFailChannelUpdate *obj = (LDKHTLCFailChannelUpdate*)(ptr & ~1);
1535         switch(obj->tag) {
1536                 case LDKHTLCFailChannelUpdate_ChannelUpdateMessage: {
1537                         LDKChannelUpdate msg_var = obj->channel_update_message.msg;
1538                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1539                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1540                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1541                         return (*env)->NewObject(env, LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class, LDKHTLCFailChannelUpdate_ChannelUpdateMessage_meth, msg_ref);
1542                 }
1543                 case LDKHTLCFailChannelUpdate_ChannelClosed: {
1544                         return (*env)->NewObject(env, LDKHTLCFailChannelUpdate_ChannelClosed_class, LDKHTLCFailChannelUpdate_ChannelClosed_meth, obj->channel_closed.short_channel_id, obj->channel_closed.is_permanent);
1545                 }
1546                 case LDKHTLCFailChannelUpdate_NodeFailure: {
1547                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1548                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->node_failure.node_id.compressed_form);
1549                         return (*env)->NewObject(env, LDKHTLCFailChannelUpdate_NodeFailure_class, LDKHTLCFailChannelUpdate_NodeFailure_meth, node_id_arr, obj->node_failure.is_permanent);
1550                 }
1551                 default: abort();
1552         }
1553 }
1554 static jclass LDKMessageSendEvent_SendAcceptChannel_class = NULL;
1555 static jmethodID LDKMessageSendEvent_SendAcceptChannel_meth = NULL;
1556 static jclass LDKMessageSendEvent_SendOpenChannel_class = NULL;
1557 static jmethodID LDKMessageSendEvent_SendOpenChannel_meth = NULL;
1558 static jclass LDKMessageSendEvent_SendFundingCreated_class = NULL;
1559 static jmethodID LDKMessageSendEvent_SendFundingCreated_meth = NULL;
1560 static jclass LDKMessageSendEvent_SendFundingSigned_class = NULL;
1561 static jmethodID LDKMessageSendEvent_SendFundingSigned_meth = NULL;
1562 static jclass LDKMessageSendEvent_SendFundingLocked_class = NULL;
1563 static jmethodID LDKMessageSendEvent_SendFundingLocked_meth = NULL;
1564 static jclass LDKMessageSendEvent_SendAnnouncementSignatures_class = NULL;
1565 static jmethodID LDKMessageSendEvent_SendAnnouncementSignatures_meth = NULL;
1566 static jclass LDKMessageSendEvent_UpdateHTLCs_class = NULL;
1567 static jmethodID LDKMessageSendEvent_UpdateHTLCs_meth = NULL;
1568 static jclass LDKMessageSendEvent_SendRevokeAndACK_class = NULL;
1569 static jmethodID LDKMessageSendEvent_SendRevokeAndACK_meth = NULL;
1570 static jclass LDKMessageSendEvent_SendClosingSigned_class = NULL;
1571 static jmethodID LDKMessageSendEvent_SendClosingSigned_meth = NULL;
1572 static jclass LDKMessageSendEvent_SendShutdown_class = NULL;
1573 static jmethodID LDKMessageSendEvent_SendShutdown_meth = NULL;
1574 static jclass LDKMessageSendEvent_SendChannelReestablish_class = NULL;
1575 static jmethodID LDKMessageSendEvent_SendChannelReestablish_meth = NULL;
1576 static jclass LDKMessageSendEvent_BroadcastChannelAnnouncement_class = NULL;
1577 static jmethodID LDKMessageSendEvent_BroadcastChannelAnnouncement_meth = NULL;
1578 static jclass LDKMessageSendEvent_BroadcastNodeAnnouncement_class = NULL;
1579 static jmethodID LDKMessageSendEvent_BroadcastNodeAnnouncement_meth = NULL;
1580 static jclass LDKMessageSendEvent_BroadcastChannelUpdate_class = NULL;
1581 static jmethodID LDKMessageSendEvent_BroadcastChannelUpdate_meth = NULL;
1582 static jclass LDKMessageSendEvent_HandleError_class = NULL;
1583 static jmethodID LDKMessageSendEvent_HandleError_meth = NULL;
1584 static jclass LDKMessageSendEvent_PaymentFailureNetworkUpdate_class = NULL;
1585 static jmethodID LDKMessageSendEvent_PaymentFailureNetworkUpdate_meth = NULL;
1586 static jclass LDKMessageSendEvent_SendChannelRangeQuery_class = NULL;
1587 static jmethodID LDKMessageSendEvent_SendChannelRangeQuery_meth = NULL;
1588 static jclass LDKMessageSendEvent_SendShortIdsQuery_class = NULL;
1589 static jmethodID LDKMessageSendEvent_SendShortIdsQuery_meth = NULL;
1590 static jclass LDKMessageSendEvent_SendReplyChannelRange_class = NULL;
1591 static jmethodID LDKMessageSendEvent_SendReplyChannelRange_meth = NULL;
1592 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKMessageSendEvent_init (JNIEnv *env, jclass clz) {
1593         LDKMessageSendEvent_SendAcceptChannel_class =
1594                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendAcceptChannel;"));
1595         CHECK(LDKMessageSendEvent_SendAcceptChannel_class != NULL);
1596         LDKMessageSendEvent_SendAcceptChannel_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendAcceptChannel_class, "<init>", "([BJ)V");
1597         CHECK(LDKMessageSendEvent_SendAcceptChannel_meth != NULL);
1598         LDKMessageSendEvent_SendOpenChannel_class =
1599                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendOpenChannel;"));
1600         CHECK(LDKMessageSendEvent_SendOpenChannel_class != NULL);
1601         LDKMessageSendEvent_SendOpenChannel_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendOpenChannel_class, "<init>", "([BJ)V");
1602         CHECK(LDKMessageSendEvent_SendOpenChannel_meth != NULL);
1603         LDKMessageSendEvent_SendFundingCreated_class =
1604                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendFundingCreated;"));
1605         CHECK(LDKMessageSendEvent_SendFundingCreated_class != NULL);
1606         LDKMessageSendEvent_SendFundingCreated_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingCreated_class, "<init>", "([BJ)V");
1607         CHECK(LDKMessageSendEvent_SendFundingCreated_meth != NULL);
1608         LDKMessageSendEvent_SendFundingSigned_class =
1609                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendFundingSigned;"));
1610         CHECK(LDKMessageSendEvent_SendFundingSigned_class != NULL);
1611         LDKMessageSendEvent_SendFundingSigned_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingSigned_class, "<init>", "([BJ)V");
1612         CHECK(LDKMessageSendEvent_SendFundingSigned_meth != NULL);
1613         LDKMessageSendEvent_SendFundingLocked_class =
1614                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendFundingLocked;"));
1615         CHECK(LDKMessageSendEvent_SendFundingLocked_class != NULL);
1616         LDKMessageSendEvent_SendFundingLocked_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingLocked_class, "<init>", "([BJ)V");
1617         CHECK(LDKMessageSendEvent_SendFundingLocked_meth != NULL);
1618         LDKMessageSendEvent_SendAnnouncementSignatures_class =
1619                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendAnnouncementSignatures;"));
1620         CHECK(LDKMessageSendEvent_SendAnnouncementSignatures_class != NULL);
1621         LDKMessageSendEvent_SendAnnouncementSignatures_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendAnnouncementSignatures_class, "<init>", "([BJ)V");
1622         CHECK(LDKMessageSendEvent_SendAnnouncementSignatures_meth != NULL);
1623         LDKMessageSendEvent_UpdateHTLCs_class =
1624                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$UpdateHTLCs;"));
1625         CHECK(LDKMessageSendEvent_UpdateHTLCs_class != NULL);
1626         LDKMessageSendEvent_UpdateHTLCs_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_UpdateHTLCs_class, "<init>", "([BJ)V");
1627         CHECK(LDKMessageSendEvent_UpdateHTLCs_meth != NULL);
1628         LDKMessageSendEvent_SendRevokeAndACK_class =
1629                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendRevokeAndACK;"));
1630         CHECK(LDKMessageSendEvent_SendRevokeAndACK_class != NULL);
1631         LDKMessageSendEvent_SendRevokeAndACK_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendRevokeAndACK_class, "<init>", "([BJ)V");
1632         CHECK(LDKMessageSendEvent_SendRevokeAndACK_meth != NULL);
1633         LDKMessageSendEvent_SendClosingSigned_class =
1634                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendClosingSigned;"));
1635         CHECK(LDKMessageSendEvent_SendClosingSigned_class != NULL);
1636         LDKMessageSendEvent_SendClosingSigned_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendClosingSigned_class, "<init>", "([BJ)V");
1637         CHECK(LDKMessageSendEvent_SendClosingSigned_meth != NULL);
1638         LDKMessageSendEvent_SendShutdown_class =
1639                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendShutdown;"));
1640         CHECK(LDKMessageSendEvent_SendShutdown_class != NULL);
1641         LDKMessageSendEvent_SendShutdown_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendShutdown_class, "<init>", "([BJ)V");
1642         CHECK(LDKMessageSendEvent_SendShutdown_meth != NULL);
1643         LDKMessageSendEvent_SendChannelReestablish_class =
1644                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendChannelReestablish;"));
1645         CHECK(LDKMessageSendEvent_SendChannelReestablish_class != NULL);
1646         LDKMessageSendEvent_SendChannelReestablish_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelReestablish_class, "<init>", "([BJ)V");
1647         CHECK(LDKMessageSendEvent_SendChannelReestablish_meth != NULL);
1648         LDKMessageSendEvent_BroadcastChannelAnnouncement_class =
1649                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$BroadcastChannelAnnouncement;"));
1650         CHECK(LDKMessageSendEvent_BroadcastChannelAnnouncement_class != NULL);
1651         LDKMessageSendEvent_BroadcastChannelAnnouncement_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastChannelAnnouncement_class, "<init>", "(JJ)V");
1652         CHECK(LDKMessageSendEvent_BroadcastChannelAnnouncement_meth != NULL);
1653         LDKMessageSendEvent_BroadcastNodeAnnouncement_class =
1654                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$BroadcastNodeAnnouncement;"));
1655         CHECK(LDKMessageSendEvent_BroadcastNodeAnnouncement_class != NULL);
1656         LDKMessageSendEvent_BroadcastNodeAnnouncement_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastNodeAnnouncement_class, "<init>", "(J)V");
1657         CHECK(LDKMessageSendEvent_BroadcastNodeAnnouncement_meth != NULL);
1658         LDKMessageSendEvent_BroadcastChannelUpdate_class =
1659                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$BroadcastChannelUpdate;"));
1660         CHECK(LDKMessageSendEvent_BroadcastChannelUpdate_class != NULL);
1661         LDKMessageSendEvent_BroadcastChannelUpdate_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastChannelUpdate_class, "<init>", "(J)V");
1662         CHECK(LDKMessageSendEvent_BroadcastChannelUpdate_meth != NULL);
1663         LDKMessageSendEvent_HandleError_class =
1664                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$HandleError;"));
1665         CHECK(LDKMessageSendEvent_HandleError_class != NULL);
1666         LDKMessageSendEvent_HandleError_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_HandleError_class, "<init>", "([BJ)V");
1667         CHECK(LDKMessageSendEvent_HandleError_meth != NULL);
1668         LDKMessageSendEvent_PaymentFailureNetworkUpdate_class =
1669                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$PaymentFailureNetworkUpdate;"));
1670         CHECK(LDKMessageSendEvent_PaymentFailureNetworkUpdate_class != NULL);
1671         LDKMessageSendEvent_PaymentFailureNetworkUpdate_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_PaymentFailureNetworkUpdate_class, "<init>", "(J)V");
1672         CHECK(LDKMessageSendEvent_PaymentFailureNetworkUpdate_meth != NULL);
1673         LDKMessageSendEvent_SendChannelRangeQuery_class =
1674                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendChannelRangeQuery;"));
1675         CHECK(LDKMessageSendEvent_SendChannelRangeQuery_class != NULL);
1676         LDKMessageSendEvent_SendChannelRangeQuery_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelRangeQuery_class, "<init>", "([BJ)V");
1677         CHECK(LDKMessageSendEvent_SendChannelRangeQuery_meth != NULL);
1678         LDKMessageSendEvent_SendShortIdsQuery_class =
1679                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendShortIdsQuery;"));
1680         CHECK(LDKMessageSendEvent_SendShortIdsQuery_class != NULL);
1681         LDKMessageSendEvent_SendShortIdsQuery_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendShortIdsQuery_class, "<init>", "([BJ)V");
1682         CHECK(LDKMessageSendEvent_SendShortIdsQuery_meth != NULL);
1683         LDKMessageSendEvent_SendReplyChannelRange_class =
1684                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendReplyChannelRange;"));
1685         CHECK(LDKMessageSendEvent_SendReplyChannelRange_class != NULL);
1686         LDKMessageSendEvent_SendReplyChannelRange_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendReplyChannelRange_class, "<init>", "([BJ)V");
1687         CHECK(LDKMessageSendEvent_SendReplyChannelRange_meth != NULL);
1688 }
1689 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1690         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
1691         switch(obj->tag) {
1692                 case LDKMessageSendEvent_SendAcceptChannel: {
1693                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1694                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_accept_channel.node_id.compressed_form);
1695                         LDKAcceptChannel msg_var = obj->send_accept_channel.msg;
1696                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1697                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1698                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1699                         return (*env)->NewObject(env, LDKMessageSendEvent_SendAcceptChannel_class, LDKMessageSendEvent_SendAcceptChannel_meth, node_id_arr, msg_ref);
1700                 }
1701                 case LDKMessageSendEvent_SendOpenChannel: {
1702                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1703                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_open_channel.node_id.compressed_form);
1704                         LDKOpenChannel msg_var = obj->send_open_channel.msg;
1705                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1706                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1707                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1708                         return (*env)->NewObject(env, LDKMessageSendEvent_SendOpenChannel_class, LDKMessageSendEvent_SendOpenChannel_meth, node_id_arr, msg_ref);
1709                 }
1710                 case LDKMessageSendEvent_SendFundingCreated: {
1711                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1712                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_created.node_id.compressed_form);
1713                         LDKFundingCreated msg_var = obj->send_funding_created.msg;
1714                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1715                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1716                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1717                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingCreated_class, LDKMessageSendEvent_SendFundingCreated_meth, node_id_arr, msg_ref);
1718                 }
1719                 case LDKMessageSendEvent_SendFundingSigned: {
1720                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1721                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_signed.node_id.compressed_form);
1722                         LDKFundingSigned msg_var = obj->send_funding_signed.msg;
1723                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1724                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1725                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1726                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingSigned_class, LDKMessageSendEvent_SendFundingSigned_meth, node_id_arr, msg_ref);
1727                 }
1728                 case LDKMessageSendEvent_SendFundingLocked: {
1729                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1730                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_locked.node_id.compressed_form);
1731                         LDKFundingLocked msg_var = obj->send_funding_locked.msg;
1732                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1733                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1734                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1735                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingLocked_class, LDKMessageSendEvent_SendFundingLocked_meth, node_id_arr, msg_ref);
1736                 }
1737                 case LDKMessageSendEvent_SendAnnouncementSignatures: {
1738                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1739                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_announcement_signatures.node_id.compressed_form);
1740                         LDKAnnouncementSignatures msg_var = obj->send_announcement_signatures.msg;
1741                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1742                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1743                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1744                         return (*env)->NewObject(env, LDKMessageSendEvent_SendAnnouncementSignatures_class, LDKMessageSendEvent_SendAnnouncementSignatures_meth, node_id_arr, msg_ref);
1745                 }
1746                 case LDKMessageSendEvent_UpdateHTLCs: {
1747                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1748                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->update_htl_cs.node_id.compressed_form);
1749                         LDKCommitmentUpdate updates_var = obj->update_htl_cs.updates;
1750                         CHECK((((uint64_t)updates_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1751                         CHECK((((uint64_t)&updates_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1752                         uint64_t updates_ref = (uint64_t)updates_var.inner & ~1;
1753                         return (*env)->NewObject(env, LDKMessageSendEvent_UpdateHTLCs_class, LDKMessageSendEvent_UpdateHTLCs_meth, node_id_arr, updates_ref);
1754                 }
1755                 case LDKMessageSendEvent_SendRevokeAndACK: {
1756                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1757                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_revoke_and_ack.node_id.compressed_form);
1758                         LDKRevokeAndACK msg_var = obj->send_revoke_and_ack.msg;
1759                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1760                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1761                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1762                         return (*env)->NewObject(env, LDKMessageSendEvent_SendRevokeAndACK_class, LDKMessageSendEvent_SendRevokeAndACK_meth, node_id_arr, msg_ref);
1763                 }
1764                 case LDKMessageSendEvent_SendClosingSigned: {
1765                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1766                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_closing_signed.node_id.compressed_form);
1767                         LDKClosingSigned msg_var = obj->send_closing_signed.msg;
1768                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1769                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1770                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1771                         return (*env)->NewObject(env, LDKMessageSendEvent_SendClosingSigned_class, LDKMessageSendEvent_SendClosingSigned_meth, node_id_arr, msg_ref);
1772                 }
1773                 case LDKMessageSendEvent_SendShutdown: {
1774                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1775                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_shutdown.node_id.compressed_form);
1776                         LDKShutdown msg_var = obj->send_shutdown.msg;
1777                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1778                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1779                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1780                         return (*env)->NewObject(env, LDKMessageSendEvent_SendShutdown_class, LDKMessageSendEvent_SendShutdown_meth, node_id_arr, msg_ref);
1781                 }
1782                 case LDKMessageSendEvent_SendChannelReestablish: {
1783                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1784                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_reestablish.node_id.compressed_form);
1785                         LDKChannelReestablish msg_var = obj->send_channel_reestablish.msg;
1786                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1787                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1788                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1789                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelReestablish_class, LDKMessageSendEvent_SendChannelReestablish_meth, node_id_arr, msg_ref);
1790                 }
1791                 case LDKMessageSendEvent_BroadcastChannelAnnouncement: {
1792                         LDKChannelAnnouncement msg_var = obj->broadcast_channel_announcement.msg;
1793                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1794                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1795                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1796                         LDKChannelUpdate update_msg_var = obj->broadcast_channel_announcement.update_msg;
1797                         CHECK((((uint64_t)update_msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1798                         CHECK((((uint64_t)&update_msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1799                         uint64_t update_msg_ref = (uint64_t)update_msg_var.inner & ~1;
1800                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastChannelAnnouncement_class, LDKMessageSendEvent_BroadcastChannelAnnouncement_meth, msg_ref, update_msg_ref);
1801                 }
1802                 case LDKMessageSendEvent_BroadcastNodeAnnouncement: {
1803                         LDKNodeAnnouncement msg_var = obj->broadcast_node_announcement.msg;
1804                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1805                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1806                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1807                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastNodeAnnouncement_class, LDKMessageSendEvent_BroadcastNodeAnnouncement_meth, msg_ref);
1808                 }
1809                 case LDKMessageSendEvent_BroadcastChannelUpdate: {
1810                         LDKChannelUpdate msg_var = obj->broadcast_channel_update.msg;
1811                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1812                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1813                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1814                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastChannelUpdate_class, LDKMessageSendEvent_BroadcastChannelUpdate_meth, msg_ref);
1815                 }
1816                 case LDKMessageSendEvent_HandleError: {
1817                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1818                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->handle_error.node_id.compressed_form);
1819                         uint64_t action_ref = ((uint64_t)&obj->handle_error.action) | 1;
1820                         return (*env)->NewObject(env, LDKMessageSendEvent_HandleError_class, LDKMessageSendEvent_HandleError_meth, node_id_arr, action_ref);
1821                 }
1822                 case LDKMessageSendEvent_PaymentFailureNetworkUpdate: {
1823                         uint64_t update_ref = ((uint64_t)&obj->payment_failure_network_update.update) | 1;
1824                         return (*env)->NewObject(env, LDKMessageSendEvent_PaymentFailureNetworkUpdate_class, LDKMessageSendEvent_PaymentFailureNetworkUpdate_meth, update_ref);
1825                 }
1826                 case LDKMessageSendEvent_SendChannelRangeQuery: {
1827                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1828                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_range_query.node_id.compressed_form);
1829                         LDKQueryChannelRange msg_var = obj->send_channel_range_query.msg;
1830                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1831                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1832                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1833                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelRangeQuery_class, LDKMessageSendEvent_SendChannelRangeQuery_meth, node_id_arr, msg_ref);
1834                 }
1835                 case LDKMessageSendEvent_SendShortIdsQuery: {
1836                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1837                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_short_ids_query.node_id.compressed_form);
1838                         LDKQueryShortChannelIds msg_var = obj->send_short_ids_query.msg;
1839                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1840                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1841                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1842                         return (*env)->NewObject(env, LDKMessageSendEvent_SendShortIdsQuery_class, LDKMessageSendEvent_SendShortIdsQuery_meth, node_id_arr, msg_ref);
1843                 }
1844                 case LDKMessageSendEvent_SendReplyChannelRange: {
1845                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1846                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_reply_channel_range.node_id.compressed_form);
1847                         LDKReplyChannelRange msg_var = obj->send_reply_channel_range.msg;
1848                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1849                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1850                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1851                         return (*env)->NewObject(env, LDKMessageSendEvent_SendReplyChannelRange_class, LDKMessageSendEvent_SendReplyChannelRange_meth, node_id_arr, msg_ref);
1852                 }
1853                 default: abort();
1854         }
1855 }
1856 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1MessageSendEventZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1857         LDKCVec_MessageSendEventZ *ret = MALLOC(sizeof(LDKCVec_MessageSendEventZ), "LDKCVec_MessageSendEventZ");
1858         ret->datalen = (*env)->GetArrayLength(env, elems);
1859         if (ret->datalen == 0) {
1860                 ret->data = NULL;
1861         } else {
1862                 ret->data = MALLOC(sizeof(LDKMessageSendEvent) * ret->datalen, "LDKCVec_MessageSendEventZ Data");
1863                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1864                 for (size_t i = 0; i < ret->datalen; i++) {
1865                         int64_t arr_elem = java_elems[i];
1866                         LDKMessageSendEvent arr_elem_conv = *(LDKMessageSendEvent*)(((uint64_t)arr_elem) & ~1);
1867                         arr_elem_conv = MessageSendEvent_clone((LDKMessageSendEvent*)(((uint64_t)arr_elem) & ~1));
1868                         ret->data[i] = arr_elem_conv;
1869                 }
1870                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1871         }
1872         return (uint64_t)ret;
1873 }
1874 static inline LDKCVec_MessageSendEventZ CVec_MessageSendEventZ_clone(const LDKCVec_MessageSendEventZ *orig) {
1875         LDKCVec_MessageSendEventZ ret = { .data = MALLOC(sizeof(LDKMessageSendEvent) * orig->datalen, "LDKCVec_MessageSendEventZ clone bytes"), .datalen = orig->datalen };
1876         for (size_t i = 0; i < ret.datalen; i++) {
1877                 ret.data[i] = MessageSendEvent_clone(&orig->data[i]);
1878         }
1879         return ret;
1880 }
1881 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitFeaturesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1882         return ((LDKCResult_InitFeaturesDecodeErrorZ*)arg)->result_ok;
1883 }
1884 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1885         LDKCResult_InitFeaturesDecodeErrorZ *val = (LDKCResult_InitFeaturesDecodeErrorZ*)(arg & ~1);
1886         CHECK(val->result_ok);
1887         LDKInitFeatures res_var = (*val->contents.result);
1888         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1889         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1890         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1891         return res_ref;
1892 }
1893 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1894         LDKCResult_InitFeaturesDecodeErrorZ *val = (LDKCResult_InitFeaturesDecodeErrorZ*)(arg & ~1);
1895         CHECK(!val->result_ok);
1896         LDKDecodeError err_var = (*val->contents.err);
1897         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1898         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1899         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1900         return err_ref;
1901 }
1902 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeFeaturesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1903         return ((LDKCResult_NodeFeaturesDecodeErrorZ*)arg)->result_ok;
1904 }
1905 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1906         LDKCResult_NodeFeaturesDecodeErrorZ *val = (LDKCResult_NodeFeaturesDecodeErrorZ*)(arg & ~1);
1907         CHECK(val->result_ok);
1908         LDKNodeFeatures res_var = (*val->contents.result);
1909         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1910         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1911         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1912         return res_ref;
1913 }
1914 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1915         LDKCResult_NodeFeaturesDecodeErrorZ *val = (LDKCResult_NodeFeaturesDecodeErrorZ*)(arg & ~1);
1916         CHECK(!val->result_ok);
1917         LDKDecodeError err_var = (*val->contents.err);
1918         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1919         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1920         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1921         return err_ref;
1922 }
1923 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelFeaturesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1924         return ((LDKCResult_ChannelFeaturesDecodeErrorZ*)arg)->result_ok;
1925 }
1926 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1927         LDKCResult_ChannelFeaturesDecodeErrorZ *val = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(arg & ~1);
1928         CHECK(val->result_ok);
1929         LDKChannelFeatures res_var = (*val->contents.result);
1930         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1931         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1932         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1933         return res_ref;
1934 }
1935 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1936         LDKCResult_ChannelFeaturesDecodeErrorZ *val = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(arg & ~1);
1937         CHECK(!val->result_ok);
1938         LDKDecodeError err_var = (*val->contents.err);
1939         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1940         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1941         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1942         return err_ref;
1943 }
1944 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceFeaturesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1945         return ((LDKCResult_InvoiceFeaturesDecodeErrorZ*)arg)->result_ok;
1946 }
1947 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1948         LDKCResult_InvoiceFeaturesDecodeErrorZ *val = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(arg & ~1);
1949         CHECK(val->result_ok);
1950         LDKInvoiceFeatures res_var = (*val->contents.result);
1951         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1952         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1953         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1954         return res_ref;
1955 }
1956 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1957         LDKCResult_InvoiceFeaturesDecodeErrorZ *val = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(arg & ~1);
1958         CHECK(!val->result_ok);
1959         LDKDecodeError err_var = (*val->contents.err);
1960         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1961         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1962         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1963         return err_ref;
1964 }
1965 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1966         return ((LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)arg)->result_ok;
1967 }
1968 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1969         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
1970         CHECK(val->result_ok);
1971         LDKDelayedPaymentOutputDescriptor res_var = (*val->contents.result);
1972         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1973         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1974         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1975         return res_ref;
1976 }
1977 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1978         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
1979         CHECK(!val->result_ok);
1980         LDKDecodeError err_var = (*val->contents.err);
1981         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1982         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1983         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1984         return err_ref;
1985 }
1986 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1987         return ((LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)arg)->result_ok;
1988 }
1989 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1990         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
1991         CHECK(val->result_ok);
1992         LDKStaticPaymentOutputDescriptor res_var = (*val->contents.result);
1993         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1994         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1995         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1996         return res_ref;
1997 }
1998 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1999         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
2000         CHECK(!val->result_ok);
2001         LDKDecodeError err_var = (*val->contents.err);
2002         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2003         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2004         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
2005         return err_ref;
2006 }
2007 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SpendableOutputDescriptorDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2008         return ((LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)arg)->result_ok;
2009 }
2010 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SpendableOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2011         LDKCResult_SpendableOutputDescriptorDecodeErrorZ *val = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(arg & ~1);
2012         CHECK(val->result_ok);
2013         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
2014         return res_ref;
2015 }
2016 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SpendableOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2017         LDKCResult_SpendableOutputDescriptorDecodeErrorZ *val = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(arg & ~1);
2018         CHECK(!val->result_ok);
2019         LDKDecodeError err_var = (*val->contents.err);
2020         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2021         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2022         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
2023         return err_ref;
2024 }
2025 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1SignatureCVec_1SignatureZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, jobjectArray b) {
2026         LDKC2Tuple_SignatureCVec_SignatureZZ* ret = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
2027         LDKSignature a_ref;
2028         CHECK((*env)->GetArrayLength(env, a) == 64);
2029         (*env)->GetByteArrayRegion(env, a, 0, 64, a_ref.compact_form);
2030         ret->a = a_ref;
2031         LDKCVec_SignatureZ b_constr;
2032         b_constr.datalen = (*env)->GetArrayLength(env, b);
2033         if (b_constr.datalen > 0)
2034                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
2035         else
2036                 b_constr.data = NULL;
2037         for (size_t i = 0; i < b_constr.datalen; i++) {
2038                 int8_tArray b_conv_8 = (*env)->GetObjectArrayElement(env, b, i);
2039                 LDKSignature b_conv_8_ref;
2040                 CHECK((*env)->GetArrayLength(env, b_conv_8) == 64);
2041                 (*env)->GetByteArrayRegion(env, b_conv_8, 0, 64, b_conv_8_ref.compact_form);
2042                 b_constr.data[i] = b_conv_8_ref;
2043         }
2044         ret->b = b_constr;
2045         return (uint64_t)ret;
2046 }
2047 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1SignatureCVec_1SignatureZZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
2048         LDKC2Tuple_SignatureCVec_SignatureZZ *tuple = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(ptr & ~1);
2049         int8_tArray a_arr = (*env)->NewByteArray(env, 64);
2050         (*env)->SetByteArrayRegion(env, a_arr, 0, 64, tuple->a.compact_form);
2051         return a_arr;
2052 }
2053 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1SignatureCVec_1SignatureZZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
2054         LDKC2Tuple_SignatureCVec_SignatureZZ *tuple = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(ptr & ~1);
2055         LDKCVec_SignatureZ b_var = tuple->b;
2056         jobjectArray b_arr = (*env)->NewObjectArray(env, b_var.datalen, arr_of_B_clz, NULL);
2057         ;
2058         for (size_t i = 0; i < b_var.datalen; i++) {
2059                 int8_tArray b_conv_8_arr = (*env)->NewByteArray(env, 64);
2060                 (*env)->SetByteArrayRegion(env, b_conv_8_arr, 0, 64, b_var.data[i].compact_form);
2061                 (*env)->SetObjectArrayElement(env, b_arr, i, b_conv_8_arr);
2062         }
2063         return b_arr;
2064 }
2065 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2066         return ((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)arg)->result_ok;
2067 }
2068 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2069         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *val = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(arg & ~1);
2070         CHECK(val->result_ok);
2071         uint64_t res_ref = (uint64_t)(&(*val->contents.result)) | 1;
2072         return res_ref;
2073 }
2074 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2075         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *val = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(arg & ~1);
2076         CHECK(!val->result_ok);
2077         return *val->contents.err;
2078 }
2079 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignatureNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2080         return ((LDKCResult_SignatureNoneZ*)arg)->result_ok;
2081 }
2082 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignatureNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2083         LDKCResult_SignatureNoneZ *val = (LDKCResult_SignatureNoneZ*)(arg & ~1);
2084         CHECK(val->result_ok);
2085         int8_tArray res_arr = (*env)->NewByteArray(env, 64);
2086         (*env)->SetByteArrayRegion(env, res_arr, 0, 64, (*val->contents.result).compact_form);
2087         return res_arr;
2088 }
2089 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignatureNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2090         LDKCResult_SignatureNoneZ *val = (LDKCResult_SignatureNoneZ*)(arg & ~1);
2091         CHECK(!val->result_ok);
2092         return *val->contents.err;
2093 }
2094 typedef struct LDKBaseSign_JCalls {
2095         atomic_size_t refcnt;
2096         JavaVM *vm;
2097         jweak o;
2098         jmethodID get_per_commitment_point_meth;
2099         jmethodID release_commitment_secret_meth;
2100         jmethodID channel_keys_id_meth;
2101         jmethodID sign_counterparty_commitment_meth;
2102         jmethodID sign_holder_commitment_and_htlcs_meth;
2103         jmethodID sign_justice_revoked_output_meth;
2104         jmethodID sign_justice_revoked_htlc_meth;
2105         jmethodID sign_counterparty_htlc_transaction_meth;
2106         jmethodID sign_closing_transaction_meth;
2107         jmethodID sign_channel_announcement_meth;
2108         jmethodID ready_channel_meth;
2109 } LDKBaseSign_JCalls;
2110 static void LDKBaseSign_JCalls_free(void* this_arg) {
2111         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2112         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2113                 JNIEnv *env;
2114                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2115                 if (get_jenv_res == JNI_EDETACHED) {
2116                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2117                 } else {
2118                         DO_ASSERT(get_jenv_res == JNI_OK);
2119                 }
2120                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
2121                 if (get_jenv_res == JNI_EDETACHED) {
2122                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2123                 }
2124                 FREE(j_calls);
2125         }
2126 }
2127 LDKPublicKey get_per_commitment_point_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
2128         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2129         JNIEnv *env;
2130         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2131         if (get_jenv_res == JNI_EDETACHED) {
2132                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2133         } else {
2134                 DO_ASSERT(get_jenv_res == JNI_OK);
2135         }
2136         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2137         CHECK(obj != NULL);
2138         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_per_commitment_point_meth, idx);
2139         LDKPublicKey ret_ref;
2140         CHECK((*env)->GetArrayLength(env, ret) == 33);
2141         (*env)->GetByteArrayRegion(env, ret, 0, 33, ret_ref.compressed_form);
2142         if (get_jenv_res == JNI_EDETACHED) {
2143                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2144         }
2145         return ret_ref;
2146 }
2147 LDKThirtyTwoBytes release_commitment_secret_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
2148         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2149         JNIEnv *env;
2150         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2151         if (get_jenv_res == JNI_EDETACHED) {
2152                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2153         } else {
2154                 DO_ASSERT(get_jenv_res == JNI_OK);
2155         }
2156         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2157         CHECK(obj != NULL);
2158         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->release_commitment_secret_meth, idx);
2159         LDKThirtyTwoBytes ret_ref;
2160         CHECK((*env)->GetArrayLength(env, ret) == 32);
2161         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
2162         if (get_jenv_res == JNI_EDETACHED) {
2163                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2164         }
2165         return ret_ref;
2166 }
2167 LDKThirtyTwoBytes channel_keys_id_LDKBaseSign_jcall(const void* this_arg) {
2168         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2169         JNIEnv *env;
2170         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2171         if (get_jenv_res == JNI_EDETACHED) {
2172                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2173         } else {
2174                 DO_ASSERT(get_jenv_res == JNI_OK);
2175         }
2176         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2177         CHECK(obj != NULL);
2178         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->channel_keys_id_meth);
2179         LDKThirtyTwoBytes ret_ref;
2180         CHECK((*env)->GetArrayLength(env, ret) == 32);
2181         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
2182         if (get_jenv_res == JNI_EDETACHED) {
2183                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2184         }
2185         return ret_ref;
2186 }
2187 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKCommitmentTransaction * commitment_tx) {
2188         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2189         JNIEnv *env;
2190         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2191         if (get_jenv_res == JNI_EDETACHED) {
2192                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2193         } else {
2194                 DO_ASSERT(get_jenv_res == JNI_OK);
2195         }
2196         LDKCommitmentTransaction commitment_tx_var = *commitment_tx;
2197         commitment_tx_var = CommitmentTransaction_clone(commitment_tx);
2198         CHECK((((uint64_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2199         CHECK((((uint64_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2200         uint64_t commitment_tx_ref = (uint64_t)commitment_tx_var.inner;
2201         if (commitment_tx_var.is_owned) {
2202                 commitment_tx_ref |= 1;
2203         }
2204         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2205         CHECK(obj != NULL);
2206         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(*env)->CallLongMethod(env, obj, j_calls->sign_counterparty_commitment_meth, commitment_tx_ref);
2207         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1);
2208         ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1));
2209         if (get_jenv_res == JNI_EDETACHED) {
2210                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2211         }
2212         return ret_conv;
2213 }
2214 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_holder_commitment_and_htlcs_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * commitment_tx) {
2215         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2216         JNIEnv *env;
2217         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2218         if (get_jenv_res == JNI_EDETACHED) {
2219                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2220         } else {
2221                 DO_ASSERT(get_jenv_res == JNI_OK);
2222         }
2223         LDKHolderCommitmentTransaction commitment_tx_var = *commitment_tx;
2224         commitment_tx_var = HolderCommitmentTransaction_clone(commitment_tx);
2225         CHECK((((uint64_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2226         CHECK((((uint64_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2227         uint64_t commitment_tx_ref = (uint64_t)commitment_tx_var.inner;
2228         if (commitment_tx_var.is_owned) {
2229                 commitment_tx_ref |= 1;
2230         }
2231         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2232         CHECK(obj != NULL);
2233         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(*env)->CallLongMethod(env, obj, j_calls->sign_holder_commitment_and_htlcs_meth, commitment_tx_ref);
2234         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1);
2235         ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1));
2236         if (get_jenv_res == JNI_EDETACHED) {
2237                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2238         }
2239         return ret_conv;
2240 }
2241 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]) {
2242         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2243         JNIEnv *env;
2244         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2245         if (get_jenv_res == JNI_EDETACHED) {
2246                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2247         } else {
2248                 DO_ASSERT(get_jenv_res == JNI_OK);
2249         }
2250         LDKTransaction justice_tx_var = justice_tx;
2251         int8_tArray justice_tx_arr = (*env)->NewByteArray(env, justice_tx_var.datalen);
2252         (*env)->SetByteArrayRegion(env, justice_tx_arr, 0, justice_tx_var.datalen, justice_tx_var.data);
2253         Transaction_free(justice_tx_var);
2254         int8_tArray per_commitment_key_arr = (*env)->NewByteArray(env, 32);
2255         (*env)->SetByteArrayRegion(env, per_commitment_key_arr, 0, 32, *per_commitment_key);
2256         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2257         CHECK(obj != NULL);
2258         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);
2259         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
2260         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
2261         if (get_jenv_res == JNI_EDETACHED) {
2262                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2263         }
2264         return ret_conv;
2265 }
2266 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) {
2267         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2268         JNIEnv *env;
2269         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2270         if (get_jenv_res == JNI_EDETACHED) {
2271                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2272         } else {
2273                 DO_ASSERT(get_jenv_res == JNI_OK);
2274         }
2275         LDKTransaction justice_tx_var = justice_tx;
2276         int8_tArray justice_tx_arr = (*env)->NewByteArray(env, justice_tx_var.datalen);
2277         (*env)->SetByteArrayRegion(env, justice_tx_arr, 0, justice_tx_var.datalen, justice_tx_var.data);
2278         Transaction_free(justice_tx_var);
2279         int8_tArray per_commitment_key_arr = (*env)->NewByteArray(env, 32);
2280         (*env)->SetByteArrayRegion(env, per_commitment_key_arr, 0, 32, *per_commitment_key);
2281         LDKHTLCOutputInCommitment htlc_var = *htlc;
2282         htlc_var = HTLCOutputInCommitment_clone(htlc);
2283         CHECK((((uint64_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2284         CHECK((((uint64_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2285         uint64_t htlc_ref = (uint64_t)htlc_var.inner;
2286         if (htlc_var.is_owned) {
2287                 htlc_ref |= 1;
2288         }
2289         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2290         CHECK(obj != NULL);
2291         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);
2292         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
2293         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
2294         if (get_jenv_res == JNI_EDETACHED) {
2295                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2296         }
2297         return ret_conv;
2298 }
2299 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) {
2300         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2301         JNIEnv *env;
2302         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2303         if (get_jenv_res == JNI_EDETACHED) {
2304                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2305         } else {
2306                 DO_ASSERT(get_jenv_res == JNI_OK);
2307         }
2308         LDKTransaction htlc_tx_var = htlc_tx;
2309         int8_tArray htlc_tx_arr = (*env)->NewByteArray(env, htlc_tx_var.datalen);
2310         (*env)->SetByteArrayRegion(env, htlc_tx_arr, 0, htlc_tx_var.datalen, htlc_tx_var.data);
2311         Transaction_free(htlc_tx_var);
2312         int8_tArray per_commitment_point_arr = (*env)->NewByteArray(env, 33);
2313         (*env)->SetByteArrayRegion(env, per_commitment_point_arr, 0, 33, per_commitment_point.compressed_form);
2314         LDKHTLCOutputInCommitment htlc_var = *htlc;
2315         htlc_var = HTLCOutputInCommitment_clone(htlc);
2316         CHECK((((uint64_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2317         CHECK((((uint64_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2318         uint64_t htlc_ref = (uint64_t)htlc_var.inner;
2319         if (htlc_var.is_owned) {
2320                 htlc_ref |= 1;
2321         }
2322         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2323         CHECK(obj != NULL);
2324         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);
2325         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
2326         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
2327         if (get_jenv_res == JNI_EDETACHED) {
2328                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2329         }
2330         return ret_conv;
2331 }
2332 LDKCResult_SignatureNoneZ sign_closing_transaction_LDKBaseSign_jcall(const void* this_arg, LDKTransaction closing_tx) {
2333         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2334         JNIEnv *env;
2335         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2336         if (get_jenv_res == JNI_EDETACHED) {
2337                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2338         } else {
2339                 DO_ASSERT(get_jenv_res == JNI_OK);
2340         }
2341         LDKTransaction closing_tx_var = closing_tx;
2342         int8_tArray closing_tx_arr = (*env)->NewByteArray(env, closing_tx_var.datalen);
2343         (*env)->SetByteArrayRegion(env, closing_tx_arr, 0, closing_tx_var.datalen, closing_tx_var.data);
2344         Transaction_free(closing_tx_var);
2345         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2346         CHECK(obj != NULL);
2347         LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)(*env)->CallLongMethod(env, obj, j_calls->sign_closing_transaction_meth, closing_tx_arr);
2348         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
2349         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
2350         if (get_jenv_res == JNI_EDETACHED) {
2351                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2352         }
2353         return ret_conv;
2354 }
2355 LDKCResult_SignatureNoneZ sign_channel_announcement_LDKBaseSign_jcall(const void* this_arg, const LDKUnsignedChannelAnnouncement * msg) {
2356         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2357         JNIEnv *env;
2358         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2359         if (get_jenv_res == JNI_EDETACHED) {
2360                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2361         } else {
2362                 DO_ASSERT(get_jenv_res == JNI_OK);
2363         }
2364         LDKUnsignedChannelAnnouncement msg_var = *msg;
2365         msg_var = UnsignedChannelAnnouncement_clone(msg);
2366         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2367         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2368         uint64_t msg_ref = (uint64_t)msg_var.inner;
2369         if (msg_var.is_owned) {
2370                 msg_ref |= 1;
2371         }
2372         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2373         CHECK(obj != NULL);
2374         LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)(*env)->CallLongMethod(env, obj, j_calls->sign_channel_announcement_meth, msg_ref);
2375         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
2376         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
2377         if (get_jenv_res == JNI_EDETACHED) {
2378                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2379         }
2380         return ret_conv;
2381 }
2382 void ready_channel_LDKBaseSign_jcall(void* this_arg, const LDKChannelTransactionParameters * channel_parameters) {
2383         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2384         JNIEnv *env;
2385         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2386         if (get_jenv_res == JNI_EDETACHED) {
2387                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2388         } else {
2389                 DO_ASSERT(get_jenv_res == JNI_OK);
2390         }
2391         LDKChannelTransactionParameters channel_parameters_var = *channel_parameters;
2392         channel_parameters_var = ChannelTransactionParameters_clone(channel_parameters);
2393         CHECK((((uint64_t)channel_parameters_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2394         CHECK((((uint64_t)&channel_parameters_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2395         uint64_t channel_parameters_ref = (uint64_t)channel_parameters_var.inner;
2396         if (channel_parameters_var.is_owned) {
2397                 channel_parameters_ref |= 1;
2398         }
2399         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2400         CHECK(obj != NULL);
2401         (*env)->CallVoidMethod(env, obj, j_calls->ready_channel_meth, channel_parameters_ref);
2402         if (get_jenv_res == JNI_EDETACHED) {
2403                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2404         }
2405 }
2406 static void* LDKBaseSign_JCalls_clone(const void* this_arg) {
2407         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2408         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2409         return (void*) this_arg;
2410 }
2411 static inline LDKBaseSign LDKBaseSign_init (JNIEnv *env, jclass clz, jobject o, int64_t pubkeys) {
2412         jclass c = (*env)->GetObjectClass(env, o);
2413         CHECK(c != NULL);
2414         LDKBaseSign_JCalls *calls = MALLOC(sizeof(LDKBaseSign_JCalls), "LDKBaseSign_JCalls");
2415         atomic_init(&calls->refcnt, 1);
2416         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
2417         calls->o = (*env)->NewWeakGlobalRef(env, o);
2418         calls->get_per_commitment_point_meth = (*env)->GetMethodID(env, c, "get_per_commitment_point", "(J)[B");
2419         CHECK(calls->get_per_commitment_point_meth != NULL);
2420         calls->release_commitment_secret_meth = (*env)->GetMethodID(env, c, "release_commitment_secret", "(J)[B");
2421         CHECK(calls->release_commitment_secret_meth != NULL);
2422         calls->channel_keys_id_meth = (*env)->GetMethodID(env, c, "channel_keys_id", "()[B");
2423         CHECK(calls->channel_keys_id_meth != NULL);
2424         calls->sign_counterparty_commitment_meth = (*env)->GetMethodID(env, c, "sign_counterparty_commitment", "(J)J");
2425         CHECK(calls->sign_counterparty_commitment_meth != NULL);
2426         calls->sign_holder_commitment_and_htlcs_meth = (*env)->GetMethodID(env, c, "sign_holder_commitment_and_htlcs", "(J)J");
2427         CHECK(calls->sign_holder_commitment_and_htlcs_meth != NULL);
2428         calls->sign_justice_revoked_output_meth = (*env)->GetMethodID(env, c, "sign_justice_revoked_output", "([BJJ[B)J");
2429         CHECK(calls->sign_justice_revoked_output_meth != NULL);
2430         calls->sign_justice_revoked_htlc_meth = (*env)->GetMethodID(env, c, "sign_justice_revoked_htlc", "([BJJ[BJ)J");
2431         CHECK(calls->sign_justice_revoked_htlc_meth != NULL);
2432         calls->sign_counterparty_htlc_transaction_meth = (*env)->GetMethodID(env, c, "sign_counterparty_htlc_transaction", "([BJJ[BJ)J");
2433         CHECK(calls->sign_counterparty_htlc_transaction_meth != NULL);
2434         calls->sign_closing_transaction_meth = (*env)->GetMethodID(env, c, "sign_closing_transaction", "([B)J");
2435         CHECK(calls->sign_closing_transaction_meth != NULL);
2436         calls->sign_channel_announcement_meth = (*env)->GetMethodID(env, c, "sign_channel_announcement", "(J)J");
2437         CHECK(calls->sign_channel_announcement_meth != NULL);
2438         calls->ready_channel_meth = (*env)->GetMethodID(env, c, "ready_channel", "(J)V");
2439         CHECK(calls->ready_channel_meth != NULL);
2440
2441         LDKChannelPublicKeys pubkeys_conv;
2442         pubkeys_conv.inner = (void*)(pubkeys & (~1));
2443         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
2444         pubkeys_conv = ChannelPublicKeys_clone(&pubkeys_conv);
2445
2446         LDKBaseSign ret = {
2447                 .this_arg = (void*) calls,
2448                 .get_per_commitment_point = get_per_commitment_point_LDKBaseSign_jcall,
2449                 .release_commitment_secret = release_commitment_secret_LDKBaseSign_jcall,
2450                 .channel_keys_id = channel_keys_id_LDKBaseSign_jcall,
2451                 .sign_counterparty_commitment = sign_counterparty_commitment_LDKBaseSign_jcall,
2452                 .sign_holder_commitment_and_htlcs = sign_holder_commitment_and_htlcs_LDKBaseSign_jcall,
2453                 .sign_justice_revoked_output = sign_justice_revoked_output_LDKBaseSign_jcall,
2454                 .sign_justice_revoked_htlc = sign_justice_revoked_htlc_LDKBaseSign_jcall,
2455                 .sign_counterparty_htlc_transaction = sign_counterparty_htlc_transaction_LDKBaseSign_jcall,
2456                 .sign_closing_transaction = sign_closing_transaction_LDKBaseSign_jcall,
2457                 .sign_channel_announcement = sign_channel_announcement_LDKBaseSign_jcall,
2458                 .ready_channel = ready_channel_LDKBaseSign_jcall,
2459                 .free = LDKBaseSign_JCalls_free,
2460                 .pubkeys = pubkeys_conv,
2461                 .set_pubkeys = NULL,
2462         };
2463         return ret;
2464 }
2465 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKBaseSign_1new(JNIEnv *env, jclass clz, jobject o, int64_t pubkeys) {
2466         LDKBaseSign *res_ptr = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
2467         *res_ptr = LDKBaseSign_init(env, clz, o, pubkeys);
2468         return (uint64_t)res_ptr;
2469 }
2470 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) {
2471         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2472         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
2473         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, (this_arg_conv->get_per_commitment_point)(this_arg_conv->this_arg, idx).compressed_form);
2474         return ret_arr;
2475 }
2476
2477 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BaseSign_1release_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_arg, int64_t idx) {
2478         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2479         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
2480         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->release_commitment_secret)(this_arg_conv->this_arg, idx).data);
2481         return ret_arr;
2482 }
2483
2484 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BaseSign_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
2485         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2486         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
2487         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->channel_keys_id)(this_arg_conv->this_arg).data);
2488         return ret_arr;
2489 }
2490
2491 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) {
2492         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2493         LDKCommitmentTransaction commitment_tx_conv;
2494         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
2495         commitment_tx_conv.is_owned = false;
2496         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
2497         *ret_conv = (this_arg_conv->sign_counterparty_commitment)(this_arg_conv->this_arg, &commitment_tx_conv);
2498         return (uint64_t)ret_conv;
2499 }
2500
2501 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) {
2502         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2503         LDKHolderCommitmentTransaction commitment_tx_conv;
2504         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
2505         commitment_tx_conv.is_owned = false;
2506         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
2507         *ret_conv = (this_arg_conv->sign_holder_commitment_and_htlcs)(this_arg_conv->this_arg, &commitment_tx_conv);
2508         return (uint64_t)ret_conv;
2509 }
2510
2511 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) {
2512         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2513         LDKTransaction justice_tx_ref;
2514         justice_tx_ref.datalen = (*env)->GetArrayLength(env, justice_tx);
2515         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
2516         (*env)->GetByteArrayRegion(env, justice_tx, 0, justice_tx_ref.datalen, justice_tx_ref.data);
2517         justice_tx_ref.data_is_owned = true;
2518         unsigned char per_commitment_key_arr[32];
2519         CHECK((*env)->GetArrayLength(env, per_commitment_key) == 32);
2520         (*env)->GetByteArrayRegion(env, per_commitment_key, 0, 32, per_commitment_key_arr);
2521         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
2522         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2523         *ret_conv = (this_arg_conv->sign_justice_revoked_output)(this_arg_conv->this_arg, justice_tx_ref, input, amount, per_commitment_key_ref);
2524         return (uint64_t)ret_conv;
2525 }
2526
2527 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) {
2528         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2529         LDKTransaction justice_tx_ref;
2530         justice_tx_ref.datalen = (*env)->GetArrayLength(env, justice_tx);
2531         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
2532         (*env)->GetByteArrayRegion(env, justice_tx, 0, justice_tx_ref.datalen, justice_tx_ref.data);
2533         justice_tx_ref.data_is_owned = true;
2534         unsigned char per_commitment_key_arr[32];
2535         CHECK((*env)->GetArrayLength(env, per_commitment_key) == 32);
2536         (*env)->GetByteArrayRegion(env, per_commitment_key, 0, 32, per_commitment_key_arr);
2537         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
2538         LDKHTLCOutputInCommitment htlc_conv;
2539         htlc_conv.inner = (void*)(htlc & (~1));
2540         htlc_conv.is_owned = false;
2541         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2542         *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);
2543         return (uint64_t)ret_conv;
2544 }
2545
2546 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) {
2547         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2548         LDKTransaction htlc_tx_ref;
2549         htlc_tx_ref.datalen = (*env)->GetArrayLength(env, htlc_tx);
2550         htlc_tx_ref.data = MALLOC(htlc_tx_ref.datalen, "LDKTransaction Bytes");
2551         (*env)->GetByteArrayRegion(env, htlc_tx, 0, htlc_tx_ref.datalen, htlc_tx_ref.data);
2552         htlc_tx_ref.data_is_owned = true;
2553         LDKPublicKey per_commitment_point_ref;
2554         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
2555         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
2556         LDKHTLCOutputInCommitment htlc_conv;
2557         htlc_conv.inner = (void*)(htlc & (~1));
2558         htlc_conv.is_owned = false;
2559         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2560         *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);
2561         return (uint64_t)ret_conv;
2562 }
2563
2564 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) {
2565         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2566         LDKTransaction closing_tx_ref;
2567         closing_tx_ref.datalen = (*env)->GetArrayLength(env, closing_tx);
2568         closing_tx_ref.data = MALLOC(closing_tx_ref.datalen, "LDKTransaction Bytes");
2569         (*env)->GetByteArrayRegion(env, closing_tx, 0, closing_tx_ref.datalen, closing_tx_ref.data);
2570         closing_tx_ref.data_is_owned = true;
2571         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2572         *ret_conv = (this_arg_conv->sign_closing_transaction)(this_arg_conv->this_arg, closing_tx_ref);
2573         return (uint64_t)ret_conv;
2574 }
2575
2576 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1sign_1channel_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
2577         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2578         LDKUnsignedChannelAnnouncement msg_conv;
2579         msg_conv.inner = (void*)(msg & (~1));
2580         msg_conv.is_owned = false;
2581         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2582         *ret_conv = (this_arg_conv->sign_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
2583         return (uint64_t)ret_conv;
2584 }
2585
2586 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BaseSign_1ready_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t channel_parameters) {
2587         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2588         LDKChannelTransactionParameters channel_parameters_conv;
2589         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
2590         channel_parameters_conv.is_owned = false;
2591         (this_arg_conv->ready_channel)(this_arg_conv->this_arg, &channel_parameters_conv);
2592 }
2593
2594 LDKChannelPublicKeys LDKBaseSign_set_get_pubkeys(LDKBaseSign* this_arg) {
2595         if (this_arg->set_pubkeys != NULL)
2596                 this_arg->set_pubkeys(this_arg);
2597         return this_arg->pubkeys;
2598 }
2599 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1get_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
2600         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2601         LDKChannelPublicKeys ret_var = LDKBaseSign_set_get_pubkeys(this_arg_conv);
2602         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2603         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2604         uint64_t ret_ref = (uint64_t)ret_var.inner;
2605         if (ret_var.is_owned) {
2606                 ret_ref |= 1;
2607         }
2608         return ret_ref;
2609 }
2610
2611 typedef struct LDKSign_JCalls {
2612         atomic_size_t refcnt;
2613         JavaVM *vm;
2614         jweak o;
2615         LDKBaseSign_JCalls* BaseSign;
2616         jmethodID write_meth;
2617 } LDKSign_JCalls;
2618 static void LDKSign_JCalls_free(void* this_arg) {
2619         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
2620         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2621                 JNIEnv *env;
2622                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2623                 if (get_jenv_res == JNI_EDETACHED) {
2624                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2625                 } else {
2626                         DO_ASSERT(get_jenv_res == JNI_OK);
2627                 }
2628                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
2629                 if (get_jenv_res == JNI_EDETACHED) {
2630                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2631                 }
2632                 FREE(j_calls);
2633         }
2634 }
2635 LDKCVec_u8Z write_LDKSign_jcall(const void* this_arg) {
2636         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
2637         JNIEnv *env;
2638         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2639         if (get_jenv_res == JNI_EDETACHED) {
2640                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2641         } else {
2642                 DO_ASSERT(get_jenv_res == JNI_OK);
2643         }
2644         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2645         CHECK(obj != NULL);
2646         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->write_meth);
2647         LDKCVec_u8Z ret_ref;
2648         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
2649         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
2650         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
2651         if (get_jenv_res == JNI_EDETACHED) {
2652                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2653         }
2654         return ret_ref;
2655 }
2656 static void* LDKSign_JCalls_clone(const void* this_arg) {
2657         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
2658         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2659         atomic_fetch_add_explicit(&j_calls->BaseSign->refcnt, 1, memory_order_release);
2660         return (void*) this_arg;
2661 }
2662 static inline LDKSign LDKSign_init (JNIEnv *env, jclass clz, jobject o, jobject BaseSign, int64_t pubkeys) {
2663         jclass c = (*env)->GetObjectClass(env, o);
2664         CHECK(c != NULL);
2665         LDKSign_JCalls *calls = MALLOC(sizeof(LDKSign_JCalls), "LDKSign_JCalls");
2666         atomic_init(&calls->refcnt, 1);
2667         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
2668         calls->o = (*env)->NewWeakGlobalRef(env, o);
2669         calls->write_meth = (*env)->GetMethodID(env, c, "write", "()[B");
2670         CHECK(calls->write_meth != NULL);
2671
2672         LDKChannelPublicKeys pubkeys_conv;
2673         pubkeys_conv.inner = (void*)(pubkeys & (~1));
2674         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
2675         pubkeys_conv = ChannelPublicKeys_clone(&pubkeys_conv);
2676
2677         LDKSign ret = {
2678                 .this_arg = (void*) calls,
2679                 .write = write_LDKSign_jcall,
2680                 .clone = LDKSign_JCalls_clone,
2681                 .free = LDKSign_JCalls_free,
2682                 .BaseSign = LDKBaseSign_init(env, clz, BaseSign, pubkeys),
2683         };
2684         calls->BaseSign = ret.BaseSign.this_arg;
2685         return ret;
2686 }
2687 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSign_1new(JNIEnv *env, jclass clz, jobject o, jobject BaseSign, int64_t pubkeys) {
2688         LDKSign *res_ptr = MALLOC(sizeof(LDKSign), "LDKSign");
2689         *res_ptr = LDKSign_init(env, clz, o, BaseSign, pubkeys);
2690         return (uint64_t)res_ptr;
2691 }
2692 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Sign_1write(JNIEnv *env, jclass clz, int64_t this_arg) {
2693         LDKSign* this_arg_conv = (LDKSign*)(((uint64_t)this_arg) & ~1);
2694         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
2695         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
2696         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
2697         CVec_u8Z_free(ret_var);
2698         return ret_arr;
2699 }
2700
2701 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2702         return ((LDKCResult_SignDecodeErrorZ*)arg)->result_ok;
2703 }
2704 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2705         LDKCResult_SignDecodeErrorZ *val = (LDKCResult_SignDecodeErrorZ*)(arg & ~1);
2706         CHECK(val->result_ok);
2707         LDKSign* ret = MALLOC(sizeof(LDKSign), "LDKSign");
2708         *ret = Sign_clone(&(*val->contents.result));
2709         return (uint64_t)ret;
2710 }
2711 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2712         LDKCResult_SignDecodeErrorZ *val = (LDKCResult_SignDecodeErrorZ*)(arg & ~1);
2713         CHECK(!val->result_ok);
2714         LDKDecodeError err_var = (*val->contents.err);
2715         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2716         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2717         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
2718         return err_ref;
2719 }
2720 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RecoverableSignatureNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2721         return ((LDKCResult_RecoverableSignatureNoneZ*)arg)->result_ok;
2722 }
2723 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RecoverableSignatureNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2724         LDKCResult_RecoverableSignatureNoneZ *val = (LDKCResult_RecoverableSignatureNoneZ*)(arg & ~1);
2725         CHECK(val->result_ok);
2726         int8_tArray es_arr = (*env)->NewByteArray(env, 68);
2727         (*env)->SetByteArrayRegion(env, es_arr, 0, 68, (*val->contents.result).serialized_form);
2728         return es_arr;
2729 }
2730 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RecoverableSignatureNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2731         LDKCResult_RecoverableSignatureNoneZ *val = (LDKCResult_RecoverableSignatureNoneZ*)(arg & ~1);
2732         CHECK(!val->result_ok);
2733         return *val->contents.err;
2734 }
2735 static inline LDKCVec_CVec_u8ZZ CVec_CVec_u8ZZ_clone(const LDKCVec_CVec_u8ZZ *orig) {
2736         LDKCVec_CVec_u8ZZ ret = { .data = MALLOC(sizeof(LDKCVec_u8Z) * orig->datalen, "LDKCVec_CVec_u8ZZ clone bytes"), .datalen = orig->datalen };
2737         for (size_t i = 0; i < ret.datalen; i++) {
2738                 ret.data[i] = CVec_u8Z_clone(&orig->data[i]);
2739         }
2740         return ret;
2741 }
2742 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1CVec_1u8ZZNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2743         return ((LDKCResult_CVec_CVec_u8ZZNoneZ*)arg)->result_ok;
2744 }
2745 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1CVec_1u8ZZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2746         LDKCResult_CVec_CVec_u8ZZNoneZ *val = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(arg & ~1);
2747         CHECK(val->result_ok);
2748         LDKCVec_CVec_u8ZZ res_var = (*val->contents.result);
2749         jobjectArray res_arr = (*env)->NewObjectArray(env, res_var.datalen, arr_of_B_clz, NULL);
2750         ;
2751         for (size_t i = 0; i < res_var.datalen; i++) {
2752                 LDKCVec_u8Z res_conv_8_var = res_var.data[i];
2753                 int8_tArray res_conv_8_arr = (*env)->NewByteArray(env, res_conv_8_var.datalen);
2754                 (*env)->SetByteArrayRegion(env, res_conv_8_arr, 0, res_conv_8_var.datalen, res_conv_8_var.data);
2755                 (*env)->SetObjectArrayElement(env, res_arr, i, res_conv_8_arr);
2756         }
2757         return res_arr;
2758 }
2759 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1CVec_1u8ZZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2760         LDKCResult_CVec_CVec_u8ZZNoneZ *val = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(arg & ~1);
2761         CHECK(!val->result_ok);
2762         return *val->contents.err;
2763 }
2764 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InMemorySignerDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2765         return ((LDKCResult_InMemorySignerDecodeErrorZ*)arg)->result_ok;
2766 }
2767 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InMemorySignerDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2768         LDKCResult_InMemorySignerDecodeErrorZ *val = (LDKCResult_InMemorySignerDecodeErrorZ*)(arg & ~1);
2769         CHECK(val->result_ok);
2770         LDKInMemorySigner res_var = (*val->contents.result);
2771         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2772         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2773         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
2774         return res_ref;
2775 }
2776 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InMemorySignerDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2777         LDKCResult_InMemorySignerDecodeErrorZ *val = (LDKCResult_InMemorySignerDecodeErrorZ*)(arg & ~1);
2778         CHECK(!val->result_ok);
2779         LDKDecodeError err_var = (*val->contents.err);
2780         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2781         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2782         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
2783         return err_ref;
2784 }
2785 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1TxOutZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
2786         LDKCVec_TxOutZ *ret = MALLOC(sizeof(LDKCVec_TxOutZ), "LDKCVec_TxOutZ");
2787         ret->datalen = (*env)->GetArrayLength(env, elems);
2788         if (ret->datalen == 0) {
2789                 ret->data = NULL;
2790         } else {
2791                 ret->data = MALLOC(sizeof(LDKTxOut) * ret->datalen, "LDKCVec_TxOutZ Data");
2792                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
2793                 for (size_t i = 0; i < ret->datalen; i++) {
2794                         int64_t arr_elem = java_elems[i];
2795                         LDKTxOut arr_elem_conv = *(LDKTxOut*)(((uint64_t)arr_elem) & ~1);
2796                         arr_elem_conv = TxOut_clone((LDKTxOut*)(((uint64_t)arr_elem) & ~1));
2797                         ret->data[i] = arr_elem_conv;
2798                 }
2799                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
2800         }
2801         return (uint64_t)ret;
2802 }
2803 static inline LDKCVec_TxOutZ CVec_TxOutZ_clone(const LDKCVec_TxOutZ *orig) {
2804         LDKCVec_TxOutZ ret = { .data = MALLOC(sizeof(LDKTxOut) * orig->datalen, "LDKCVec_TxOutZ clone bytes"), .datalen = orig->datalen };
2805         for (size_t i = 0; i < ret.datalen; i++) {
2806                 ret.data[i] = TxOut_clone(&orig->data[i]);
2807         }
2808         return ret;
2809 }
2810 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TransactionNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2811         return ((LDKCResult_TransactionNoneZ*)arg)->result_ok;
2812 }
2813 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TransactionNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2814         LDKCResult_TransactionNoneZ *val = (LDKCResult_TransactionNoneZ*)(arg & ~1);
2815         CHECK(val->result_ok);
2816         LDKTransaction res_var = (*val->contents.result);
2817         int8_tArray res_arr = (*env)->NewByteArray(env, res_var.datalen);
2818         (*env)->SetByteArrayRegion(env, res_arr, 0, res_var.datalen, res_var.data);
2819         return res_arr;
2820 }
2821 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TransactionNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2822         LDKCResult_TransactionNoneZ *val = (LDKCResult_TransactionNoneZ*)(arg & ~1);
2823         CHECK(!val->result_ok);
2824         return *val->contents.err;
2825 }
2826 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1BlockHashChannelMonitorZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
2827         LDKC2Tuple_BlockHashChannelMonitorZ* ret = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
2828         LDKThirtyTwoBytes a_ref;
2829         CHECK((*env)->GetArrayLength(env, a) == 32);
2830         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
2831         ret->a = a_ref;
2832         LDKChannelMonitor b_conv;
2833         b_conv.inner = (void*)(b & (~1));
2834         b_conv.is_owned = (b & 1) || (b == 0);
2835         b_conv = ChannelMonitor_clone(&b_conv);
2836         ret->b = b_conv;
2837         return (uint64_t)ret;
2838 }
2839 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1BlockHashChannelMonitorZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
2840         LDKC2Tuple_BlockHashChannelMonitorZ *tuple = (LDKC2Tuple_BlockHashChannelMonitorZ*)(ptr & ~1);
2841         int8_tArray a_arr = (*env)->NewByteArray(env, 32);
2842         (*env)->SetByteArrayRegion(env, a_arr, 0, 32, tuple->a.data);
2843         return a_arr;
2844 }
2845 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1BlockHashChannelMonitorZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
2846         LDKC2Tuple_BlockHashChannelMonitorZ *tuple = (LDKC2Tuple_BlockHashChannelMonitorZ*)(ptr & ~1);
2847         LDKChannelMonitor b_var = tuple->b;
2848         CHECK((((uint64_t)b_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2849         CHECK((((uint64_t)&b_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2850         uint64_t b_ref = (uint64_t)b_var.inner & ~1;
2851         return b_ref;
2852 }
2853 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1BlockHashChannelMonitorZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
2854         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_BlockHashChannelMonitorZZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ");
2855         ret->datalen = (*env)->GetArrayLength(env, elems);
2856         if (ret->datalen == 0) {
2857                 ret->data = NULL;
2858         } else {
2859                 ret->data = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ) * ret->datalen, "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Data");
2860                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
2861                 for (size_t i = 0; i < ret->datalen; i++) {
2862                         int64_t arr_elem = java_elems[i];
2863                         LDKC2Tuple_BlockHashChannelMonitorZ arr_elem_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)arr_elem) & ~1);
2864                         // Warning: we may need a move here but no clone is available for LDKC2Tuple_BlockHashChannelMonitorZ
2865                         ret->data[i] = arr_elem_conv;
2866                 }
2867                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
2868         }
2869         return (uint64_t)ret;
2870 }
2871 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2872         return ((LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)arg)->result_ok;
2873 }
2874 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2875         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *val = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(arg & ~1);
2876         CHECK(val->result_ok);
2877         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ res_var = (*val->contents.result);
2878         int64_tArray res_arr = (*env)->NewLongArray(env, res_var.datalen);
2879         int64_t *res_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, res_arr, NULL);
2880         for (size_t i = 0; i < res_var.datalen; i++) {
2881                 uint64_t res_conv_34_ref = (uint64_t)(&res_var.data[i]) | 1;
2882                 res_arr_ptr[i] = res_conv_34_ref;
2883         }
2884         (*env)->ReleasePrimitiveArrayCritical(env, res_arr, res_arr_ptr, 0);
2885         return res_arr;
2886 }
2887 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2888         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *val = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(arg & ~1);
2889         CHECK(!val->result_ok);
2890         jclass err_conv = LDKIOError_to_java(env, (*val->contents.err));
2891         return err_conv;
2892 }
2893 static jclass LDKAPIError_APIMisuseError_class = NULL;
2894 static jmethodID LDKAPIError_APIMisuseError_meth = NULL;
2895 static jclass LDKAPIError_FeeRateTooHigh_class = NULL;
2896 static jmethodID LDKAPIError_FeeRateTooHigh_meth = NULL;
2897 static jclass LDKAPIError_RouteError_class = NULL;
2898 static jmethodID LDKAPIError_RouteError_meth = NULL;
2899 static jclass LDKAPIError_ChannelUnavailable_class = NULL;
2900 static jmethodID LDKAPIError_ChannelUnavailable_meth = NULL;
2901 static jclass LDKAPIError_MonitorUpdateFailed_class = NULL;
2902 static jmethodID LDKAPIError_MonitorUpdateFailed_meth = NULL;
2903 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKAPIError_init (JNIEnv *env, jclass clz) {
2904         LDKAPIError_APIMisuseError_class =
2905                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$APIMisuseError;"));
2906         CHECK(LDKAPIError_APIMisuseError_class != NULL);
2907         LDKAPIError_APIMisuseError_meth = (*env)->GetMethodID(env, LDKAPIError_APIMisuseError_class, "<init>", "(Ljava/lang/String;)V");
2908         CHECK(LDKAPIError_APIMisuseError_meth != NULL);
2909         LDKAPIError_FeeRateTooHigh_class =
2910                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$FeeRateTooHigh;"));
2911         CHECK(LDKAPIError_FeeRateTooHigh_class != NULL);
2912         LDKAPIError_FeeRateTooHigh_meth = (*env)->GetMethodID(env, LDKAPIError_FeeRateTooHigh_class, "<init>", "(Ljava/lang/String;I)V");
2913         CHECK(LDKAPIError_FeeRateTooHigh_meth != NULL);
2914         LDKAPIError_RouteError_class =
2915                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$RouteError;"));
2916         CHECK(LDKAPIError_RouteError_class != NULL);
2917         LDKAPIError_RouteError_meth = (*env)->GetMethodID(env, LDKAPIError_RouteError_class, "<init>", "(Ljava/lang/String;)V");
2918         CHECK(LDKAPIError_RouteError_meth != NULL);
2919         LDKAPIError_ChannelUnavailable_class =
2920                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$ChannelUnavailable;"));
2921         CHECK(LDKAPIError_ChannelUnavailable_class != NULL);
2922         LDKAPIError_ChannelUnavailable_meth = (*env)->GetMethodID(env, LDKAPIError_ChannelUnavailable_class, "<init>", "(Ljava/lang/String;)V");
2923         CHECK(LDKAPIError_ChannelUnavailable_meth != NULL);
2924         LDKAPIError_MonitorUpdateFailed_class =
2925                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$MonitorUpdateFailed;"));
2926         CHECK(LDKAPIError_MonitorUpdateFailed_class != NULL);
2927         LDKAPIError_MonitorUpdateFailed_meth = (*env)->GetMethodID(env, LDKAPIError_MonitorUpdateFailed_class, "<init>", "()V");
2928         CHECK(LDKAPIError_MonitorUpdateFailed_meth != NULL);
2929 }
2930 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKAPIError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2931         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
2932         switch(obj->tag) {
2933                 case LDKAPIError_APIMisuseError: {
2934                         LDKStr err_str = obj->api_misuse_error.err;
2935                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
2936                         return (*env)->NewObject(env, LDKAPIError_APIMisuseError_class, LDKAPIError_APIMisuseError_meth, err_conv);
2937                 }
2938                 case LDKAPIError_FeeRateTooHigh: {
2939                         LDKStr err_str = obj->fee_rate_too_high.err;
2940                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
2941                         return (*env)->NewObject(env, LDKAPIError_FeeRateTooHigh_class, LDKAPIError_FeeRateTooHigh_meth, err_conv, obj->fee_rate_too_high.feerate);
2942                 }
2943                 case LDKAPIError_RouteError: {
2944                         LDKStr err_str = obj->route_error.err;
2945                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
2946                         return (*env)->NewObject(env, LDKAPIError_RouteError_class, LDKAPIError_RouteError_meth, err_conv);
2947                 }
2948                 case LDKAPIError_ChannelUnavailable: {
2949                         LDKStr err_str = obj->channel_unavailable.err;
2950                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
2951                         return (*env)->NewObject(env, LDKAPIError_ChannelUnavailable_class, LDKAPIError_ChannelUnavailable_meth, err_conv);
2952                 }
2953                 case LDKAPIError_MonitorUpdateFailed: {
2954                         return (*env)->NewObject(env, LDKAPIError_MonitorUpdateFailed_class, LDKAPIError_MonitorUpdateFailed_meth);
2955                 }
2956                 default: abort();
2957         }
2958 }
2959 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneAPIErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2960         return ((LDKCResult_NoneAPIErrorZ*)arg)->result_ok;
2961 }
2962 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2963         LDKCResult_NoneAPIErrorZ *val = (LDKCResult_NoneAPIErrorZ*)(arg & ~1);
2964         CHECK(val->result_ok);
2965         return *val->contents.result;
2966 }
2967 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2968         LDKCResult_NoneAPIErrorZ *val = (LDKCResult_NoneAPIErrorZ*)(arg & ~1);
2969         CHECK(!val->result_ok);
2970         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
2971         return err_ref;
2972 }
2973 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1CResult_1NoneAPIErrorZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
2974         LDKCVec_CResult_NoneAPIErrorZZ *ret = MALLOC(sizeof(LDKCVec_CResult_NoneAPIErrorZZ), "LDKCVec_CResult_NoneAPIErrorZZ");
2975         ret->datalen = (*env)->GetArrayLength(env, elems);
2976         if (ret->datalen == 0) {
2977                 ret->data = NULL;
2978         } else {
2979                 ret->data = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ) * ret->datalen, "LDKCVec_CResult_NoneAPIErrorZZ Data");
2980                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
2981                 for (size_t i = 0; i < ret->datalen; i++) {
2982                         int64_t arr_elem = java_elems[i];
2983                         LDKCResult_NoneAPIErrorZ arr_elem_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)arr_elem) & ~1);
2984                         arr_elem_conv = CResult_NoneAPIErrorZ_clone((LDKCResult_NoneAPIErrorZ*)(((uint64_t)arr_elem) & ~1));
2985                         ret->data[i] = arr_elem_conv;
2986                 }
2987                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
2988         }
2989         return (uint64_t)ret;
2990 }
2991 static inline LDKCVec_CResult_NoneAPIErrorZZ CVec_CResult_NoneAPIErrorZZ_clone(const LDKCVec_CResult_NoneAPIErrorZZ *orig) {
2992         LDKCVec_CResult_NoneAPIErrorZZ ret = { .data = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ) * orig->datalen, "LDKCVec_CResult_NoneAPIErrorZZ clone bytes"), .datalen = orig->datalen };
2993         for (size_t i = 0; i < ret.datalen; i++) {
2994                 ret.data[i] = CResult_NoneAPIErrorZ_clone(&orig->data[i]);
2995         }
2996         return ret;
2997 }
2998 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1APIErrorZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
2999         LDKCVec_APIErrorZ *ret = MALLOC(sizeof(LDKCVec_APIErrorZ), "LDKCVec_APIErrorZ");
3000         ret->datalen = (*env)->GetArrayLength(env, elems);
3001         if (ret->datalen == 0) {
3002                 ret->data = NULL;
3003         } else {
3004                 ret->data = MALLOC(sizeof(LDKAPIError) * ret->datalen, "LDKCVec_APIErrorZ Data");
3005                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3006                 for (size_t i = 0; i < ret->datalen; i++) {
3007                         int64_t arr_elem = java_elems[i];
3008                         LDKAPIError arr_elem_conv = *(LDKAPIError*)(((uint64_t)arr_elem) & ~1);
3009                         arr_elem_conv = APIError_clone((LDKAPIError*)(((uint64_t)arr_elem) & ~1));
3010                         ret->data[i] = arr_elem_conv;
3011                 }
3012                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3013         }
3014         return (uint64_t)ret;
3015 }
3016 static inline LDKCVec_APIErrorZ CVec_APIErrorZ_clone(const LDKCVec_APIErrorZ *orig) {
3017         LDKCVec_APIErrorZ ret = { .data = MALLOC(sizeof(LDKAPIError) * orig->datalen, "LDKCVec_APIErrorZ clone bytes"), .datalen = orig->datalen };
3018         for (size_t i = 0; i < ret.datalen; i++) {
3019                 ret.data[i] = APIError_clone(&orig->data[i]);
3020         }
3021         return ret;
3022 }
3023 static jclass LDKPaymentSendFailure_ParameterError_class = NULL;
3024 static jmethodID LDKPaymentSendFailure_ParameterError_meth = NULL;
3025 static jclass LDKPaymentSendFailure_PathParameterError_class = NULL;
3026 static jmethodID LDKPaymentSendFailure_PathParameterError_meth = NULL;
3027 static jclass LDKPaymentSendFailure_AllFailedRetrySafe_class = NULL;
3028 static jmethodID LDKPaymentSendFailure_AllFailedRetrySafe_meth = NULL;
3029 static jclass LDKPaymentSendFailure_PartialFailure_class = NULL;
3030 static jmethodID LDKPaymentSendFailure_PartialFailure_meth = NULL;
3031 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKPaymentSendFailure_init (JNIEnv *env, jclass clz) {
3032         LDKPaymentSendFailure_ParameterError_class =
3033                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentSendFailure$ParameterError;"));
3034         CHECK(LDKPaymentSendFailure_ParameterError_class != NULL);
3035         LDKPaymentSendFailure_ParameterError_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_ParameterError_class, "<init>", "(J)V");
3036         CHECK(LDKPaymentSendFailure_ParameterError_meth != NULL);
3037         LDKPaymentSendFailure_PathParameterError_class =
3038                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentSendFailure$PathParameterError;"));
3039         CHECK(LDKPaymentSendFailure_PathParameterError_class != NULL);
3040         LDKPaymentSendFailure_PathParameterError_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_PathParameterError_class, "<init>", "([J)V");
3041         CHECK(LDKPaymentSendFailure_PathParameterError_meth != NULL);
3042         LDKPaymentSendFailure_AllFailedRetrySafe_class =
3043                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentSendFailure$AllFailedRetrySafe;"));
3044         CHECK(LDKPaymentSendFailure_AllFailedRetrySafe_class != NULL);
3045         LDKPaymentSendFailure_AllFailedRetrySafe_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_AllFailedRetrySafe_class, "<init>", "([J)V");
3046         CHECK(LDKPaymentSendFailure_AllFailedRetrySafe_meth != NULL);
3047         LDKPaymentSendFailure_PartialFailure_class =
3048                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentSendFailure$PartialFailure;"));
3049         CHECK(LDKPaymentSendFailure_PartialFailure_class != NULL);
3050         LDKPaymentSendFailure_PartialFailure_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_PartialFailure_class, "<init>", "([J)V");
3051         CHECK(LDKPaymentSendFailure_PartialFailure_meth != NULL);
3052 }
3053 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPaymentSendFailure_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3054         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
3055         switch(obj->tag) {
3056                 case LDKPaymentSendFailure_ParameterError: {
3057                         uint64_t parameter_error_ref = ((uint64_t)&obj->parameter_error) | 1;
3058                         return (*env)->NewObject(env, LDKPaymentSendFailure_ParameterError_class, LDKPaymentSendFailure_ParameterError_meth, parameter_error_ref);
3059                 }
3060                 case LDKPaymentSendFailure_PathParameterError: {
3061                         LDKCVec_CResult_NoneAPIErrorZZ path_parameter_error_var = obj->path_parameter_error;
3062                         int64_tArray path_parameter_error_arr = (*env)->NewLongArray(env, path_parameter_error_var.datalen);
3063                         int64_t *path_parameter_error_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_parameter_error_arr, NULL);
3064                         for (size_t w = 0; w < path_parameter_error_var.datalen; w++) {
3065                                 LDKCResult_NoneAPIErrorZ* path_parameter_error_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
3066                                 *path_parameter_error_conv_22_conv = path_parameter_error_var.data[w];
3067                                 *path_parameter_error_conv_22_conv = CResult_NoneAPIErrorZ_clone(path_parameter_error_conv_22_conv);
3068                                 path_parameter_error_arr_ptr[w] = (uint64_t)path_parameter_error_conv_22_conv;
3069                         }
3070                         (*env)->ReleasePrimitiveArrayCritical(env, path_parameter_error_arr, path_parameter_error_arr_ptr, 0);
3071                         return (*env)->NewObject(env, LDKPaymentSendFailure_PathParameterError_class, LDKPaymentSendFailure_PathParameterError_meth, path_parameter_error_arr);
3072                 }
3073                 case LDKPaymentSendFailure_AllFailedRetrySafe: {
3074                         LDKCVec_APIErrorZ all_failed_retry_safe_var = obj->all_failed_retry_safe;
3075                         int64_tArray all_failed_retry_safe_arr = (*env)->NewLongArray(env, all_failed_retry_safe_var.datalen);
3076                         int64_t *all_failed_retry_safe_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, all_failed_retry_safe_arr, NULL);
3077                         for (size_t k = 0; k < all_failed_retry_safe_var.datalen; k++) {
3078                                 uint64_t all_failed_retry_safe_conv_10_ref = ((uint64_t)&all_failed_retry_safe_var.data[k]) | 1;
3079                                 all_failed_retry_safe_arr_ptr[k] = all_failed_retry_safe_conv_10_ref;
3080                         }
3081                         (*env)->ReleasePrimitiveArrayCritical(env, all_failed_retry_safe_arr, all_failed_retry_safe_arr_ptr, 0);
3082                         return (*env)->NewObject(env, LDKPaymentSendFailure_AllFailedRetrySafe_class, LDKPaymentSendFailure_AllFailedRetrySafe_meth, all_failed_retry_safe_arr);
3083                 }
3084                 case LDKPaymentSendFailure_PartialFailure: {
3085                         LDKCVec_CResult_NoneAPIErrorZZ partial_failure_var = obj->partial_failure;
3086                         int64_tArray partial_failure_arr = (*env)->NewLongArray(env, partial_failure_var.datalen);
3087                         int64_t *partial_failure_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, partial_failure_arr, NULL);
3088                         for (size_t w = 0; w < partial_failure_var.datalen; w++) {
3089                                 LDKCResult_NoneAPIErrorZ* partial_failure_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
3090                                 *partial_failure_conv_22_conv = partial_failure_var.data[w];
3091                                 *partial_failure_conv_22_conv = CResult_NoneAPIErrorZ_clone(partial_failure_conv_22_conv);
3092                                 partial_failure_arr_ptr[w] = (uint64_t)partial_failure_conv_22_conv;
3093                         }
3094                         (*env)->ReleasePrimitiveArrayCritical(env, partial_failure_arr, partial_failure_arr_ptr, 0);
3095                         return (*env)->NewObject(env, LDKPaymentSendFailure_PartialFailure_class, LDKPaymentSendFailure_PartialFailure_meth, partial_failure_arr);
3096                 }
3097                 default: abort();
3098         }
3099 }
3100 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePaymentSendFailureZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3101         return ((LDKCResult_NonePaymentSendFailureZ*)arg)->result_ok;
3102 }
3103 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePaymentSendFailureZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3104         LDKCResult_NonePaymentSendFailureZ *val = (LDKCResult_NonePaymentSendFailureZ*)(arg & ~1);
3105         CHECK(val->result_ok);
3106         return *val->contents.result;
3107 }
3108 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePaymentSendFailureZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3109         LDKCResult_NonePaymentSendFailureZ *val = (LDKCResult_NonePaymentSendFailureZ*)(arg & ~1);
3110         CHECK(!val->result_ok);
3111         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
3112         return err_ref;
3113 }
3114 static jclass LDKNetAddress_IPv4_class = NULL;
3115 static jmethodID LDKNetAddress_IPv4_meth = NULL;
3116 static jclass LDKNetAddress_IPv6_class = NULL;
3117 static jmethodID LDKNetAddress_IPv6_meth = NULL;
3118 static jclass LDKNetAddress_OnionV2_class = NULL;
3119 static jmethodID LDKNetAddress_OnionV2_meth = NULL;
3120 static jclass LDKNetAddress_OnionV3_class = NULL;
3121 static jmethodID LDKNetAddress_OnionV3_meth = NULL;
3122 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKNetAddress_init (JNIEnv *env, jclass clz) {
3123         LDKNetAddress_IPv4_class =
3124                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$IPv4;"));
3125         CHECK(LDKNetAddress_IPv4_class != NULL);
3126         LDKNetAddress_IPv4_meth = (*env)->GetMethodID(env, LDKNetAddress_IPv4_class, "<init>", "([BS)V");
3127         CHECK(LDKNetAddress_IPv4_meth != NULL);
3128         LDKNetAddress_IPv6_class =
3129                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$IPv6;"));
3130         CHECK(LDKNetAddress_IPv6_class != NULL);
3131         LDKNetAddress_IPv6_meth = (*env)->GetMethodID(env, LDKNetAddress_IPv6_class, "<init>", "([BS)V");
3132         CHECK(LDKNetAddress_IPv6_meth != NULL);
3133         LDKNetAddress_OnionV2_class =
3134                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$OnionV2;"));
3135         CHECK(LDKNetAddress_OnionV2_class != NULL);
3136         LDKNetAddress_OnionV2_meth = (*env)->GetMethodID(env, LDKNetAddress_OnionV2_class, "<init>", "([BS)V");
3137         CHECK(LDKNetAddress_OnionV2_meth != NULL);
3138         LDKNetAddress_OnionV3_class =
3139                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$OnionV3;"));
3140         CHECK(LDKNetAddress_OnionV3_class != NULL);
3141         LDKNetAddress_OnionV3_meth = (*env)->GetMethodID(env, LDKNetAddress_OnionV3_class, "<init>", "([BSBS)V");
3142         CHECK(LDKNetAddress_OnionV3_meth != NULL);
3143 }
3144 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKNetAddress_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3145         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3146         switch(obj->tag) {
3147                 case LDKNetAddress_IPv4: {
3148                         int8_tArray addr_arr = (*env)->NewByteArray(env, 4);
3149                         (*env)->SetByteArrayRegion(env, addr_arr, 0, 4, obj->i_pv4.addr.data);
3150                         return (*env)->NewObject(env, LDKNetAddress_IPv4_class, LDKNetAddress_IPv4_meth, addr_arr, obj->i_pv4.port);
3151                 }
3152                 case LDKNetAddress_IPv6: {
3153                         int8_tArray addr_arr = (*env)->NewByteArray(env, 16);
3154                         (*env)->SetByteArrayRegion(env, addr_arr, 0, 16, obj->i_pv6.addr.data);
3155                         return (*env)->NewObject(env, LDKNetAddress_IPv6_class, LDKNetAddress_IPv6_meth, addr_arr, obj->i_pv6.port);
3156                 }
3157                 case LDKNetAddress_OnionV2: {
3158                         int8_tArray addr_arr = (*env)->NewByteArray(env, 10);
3159                         (*env)->SetByteArrayRegion(env, addr_arr, 0, 10, obj->onion_v2.addr.data);
3160                         return (*env)->NewObject(env, LDKNetAddress_OnionV2_class, LDKNetAddress_OnionV2_meth, addr_arr, obj->onion_v2.port);
3161                 }
3162                 case LDKNetAddress_OnionV3: {
3163                         int8_tArray ed25519_pubkey_arr = (*env)->NewByteArray(env, 32);
3164                         (*env)->SetByteArrayRegion(env, ed25519_pubkey_arr, 0, 32, obj->onion_v3.ed25519_pubkey.data);
3165                         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);
3166                 }
3167                 default: abort();
3168         }
3169 }
3170 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1NetAddressZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
3171         LDKCVec_NetAddressZ *ret = MALLOC(sizeof(LDKCVec_NetAddressZ), "LDKCVec_NetAddressZ");
3172         ret->datalen = (*env)->GetArrayLength(env, elems);
3173         if (ret->datalen == 0) {
3174                 ret->data = NULL;
3175         } else {
3176                 ret->data = MALLOC(sizeof(LDKNetAddress) * ret->datalen, "LDKCVec_NetAddressZ Data");
3177                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3178                 for (size_t i = 0; i < ret->datalen; i++) {
3179                         int64_t arr_elem = java_elems[i];
3180                         LDKNetAddress arr_elem_conv = *(LDKNetAddress*)(((uint64_t)arr_elem) & ~1);
3181                         arr_elem_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)arr_elem) & ~1));
3182                         ret->data[i] = arr_elem_conv;
3183                 }
3184                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3185         }
3186         return (uint64_t)ret;
3187 }
3188 static inline LDKCVec_NetAddressZ CVec_NetAddressZ_clone(const LDKCVec_NetAddressZ *orig) {
3189         LDKCVec_NetAddressZ ret = { .data = MALLOC(sizeof(LDKNetAddress) * orig->datalen, "LDKCVec_NetAddressZ clone bytes"), .datalen = orig->datalen };
3190         for (size_t i = 0; i < ret.datalen; i++) {
3191                 ret.data[i] = NetAddress_clone(&orig->data[i]);
3192         }
3193         return ret;
3194 }
3195 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1PaymentHashPaymentSecretZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int8_tArray b) {
3196         LDKC2Tuple_PaymentHashPaymentSecretZ* ret = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
3197         LDKThirtyTwoBytes a_ref;
3198         CHECK((*env)->GetArrayLength(env, a) == 32);
3199         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
3200         ret->a = a_ref;
3201         LDKThirtyTwoBytes b_ref;
3202         CHECK((*env)->GetArrayLength(env, b) == 32);
3203         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
3204         ret->b = b_ref;
3205         return (uint64_t)ret;
3206 }
3207 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1PaymentHashPaymentSecretZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
3208         LDKC2Tuple_PaymentHashPaymentSecretZ *tuple = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(ptr & ~1);
3209         int8_tArray a_arr = (*env)->NewByteArray(env, 32);
3210         (*env)->SetByteArrayRegion(env, a_arr, 0, 32, tuple->a.data);
3211         return a_arr;
3212 }
3213 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1PaymentHashPaymentSecretZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
3214         LDKC2Tuple_PaymentHashPaymentSecretZ *tuple = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(ptr & ~1);
3215         int8_tArray b_arr = (*env)->NewByteArray(env, 32);
3216         (*env)->SetByteArrayRegion(env, b_arr, 0, 32, tuple->b.data);
3217         return b_arr;
3218 }
3219 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentSecretAPIErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3220         return ((LDKCResult_PaymentSecretAPIErrorZ*)arg)->result_ok;
3221 }
3222 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentSecretAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3223         LDKCResult_PaymentSecretAPIErrorZ *val = (LDKCResult_PaymentSecretAPIErrorZ*)(arg & ~1);
3224         CHECK(val->result_ok);
3225         int8_tArray res_arr = (*env)->NewByteArray(env, 32);
3226         (*env)->SetByteArrayRegion(env, res_arr, 0, 32, (*val->contents.result).data);
3227         return res_arr;
3228 }
3229 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentSecretAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3230         LDKCResult_PaymentSecretAPIErrorZ *val = (LDKCResult_PaymentSecretAPIErrorZ*)(arg & ~1);
3231         CHECK(!val->result_ok);
3232         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
3233         return err_ref;
3234 }
3235 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1ChannelMonitorZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
3236         LDKCVec_ChannelMonitorZ *ret = MALLOC(sizeof(LDKCVec_ChannelMonitorZ), "LDKCVec_ChannelMonitorZ");
3237         ret->datalen = (*env)->GetArrayLength(env, elems);
3238         if (ret->datalen == 0) {
3239                 ret->data = NULL;
3240         } else {
3241                 ret->data = MALLOC(sizeof(LDKChannelMonitor) * ret->datalen, "LDKCVec_ChannelMonitorZ Data");
3242                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3243                 for (size_t i = 0; i < ret->datalen; i++) {
3244                         int64_t arr_elem = java_elems[i];
3245                         LDKChannelMonitor arr_elem_conv;
3246                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3247                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3248                         arr_elem_conv = ChannelMonitor_clone(&arr_elem_conv);
3249                         ret->data[i] = arr_elem_conv;
3250                 }
3251                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3252         }
3253         return (uint64_t)ret;
3254 }
3255 static inline LDKCVec_ChannelMonitorZ CVec_ChannelMonitorZ_clone(const LDKCVec_ChannelMonitorZ *orig) {
3256         LDKCVec_ChannelMonitorZ ret = { .data = MALLOC(sizeof(LDKChannelMonitor) * orig->datalen, "LDKCVec_ChannelMonitorZ clone bytes"), .datalen = orig->datalen };
3257         for (size_t i = 0; i < ret.datalen; i++) {
3258                 ret.data[i] = ChannelMonitor_clone(&orig->data[i]);
3259         }
3260         return ret;
3261 }
3262 typedef struct LDKWatch_JCalls {
3263         atomic_size_t refcnt;
3264         JavaVM *vm;
3265         jweak o;
3266         jmethodID watch_channel_meth;
3267         jmethodID update_channel_meth;
3268         jmethodID release_pending_monitor_events_meth;
3269 } LDKWatch_JCalls;
3270 static void LDKWatch_JCalls_free(void* this_arg) {
3271         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
3272         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3273                 JNIEnv *env;
3274                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3275                 if (get_jenv_res == JNI_EDETACHED) {
3276                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3277                 } else {
3278                         DO_ASSERT(get_jenv_res == JNI_OK);
3279                 }
3280                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
3281                 if (get_jenv_res == JNI_EDETACHED) {
3282                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3283                 }
3284                 FREE(j_calls);
3285         }
3286 }
3287 LDKCResult_NoneChannelMonitorUpdateErrZ watch_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitor monitor) {
3288         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
3289         JNIEnv *env;
3290         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3291         if (get_jenv_res == JNI_EDETACHED) {
3292                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3293         } else {
3294                 DO_ASSERT(get_jenv_res == JNI_OK);
3295         }
3296         LDKOutPoint funding_txo_var = funding_txo;
3297         CHECK((((uint64_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3298         CHECK((((uint64_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3299         uint64_t funding_txo_ref = (uint64_t)funding_txo_var.inner;
3300         if (funding_txo_var.is_owned) {
3301                 funding_txo_ref |= 1;
3302         }
3303         LDKChannelMonitor monitor_var = monitor;
3304         CHECK((((uint64_t)monitor_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3305         CHECK((((uint64_t)&monitor_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3306         uint64_t monitor_ref = (uint64_t)monitor_var.inner;
3307         if (monitor_var.is_owned) {
3308                 monitor_ref |= 1;
3309         }
3310         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3311         CHECK(obj != NULL);
3312         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(*env)->CallLongMethod(env, obj, j_calls->watch_channel_meth, funding_txo_ref, monitor_ref);
3313         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
3314         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
3315         if (get_jenv_res == JNI_EDETACHED) {
3316                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3317         }
3318         return ret_conv;
3319 }
3320 LDKCResult_NoneChannelMonitorUpdateErrZ update_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitorUpdate update) {
3321         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
3322         JNIEnv *env;
3323         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3324         if (get_jenv_res == JNI_EDETACHED) {
3325                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3326         } else {
3327                 DO_ASSERT(get_jenv_res == JNI_OK);
3328         }
3329         LDKOutPoint funding_txo_var = funding_txo;
3330         CHECK((((uint64_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3331         CHECK((((uint64_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3332         uint64_t funding_txo_ref = (uint64_t)funding_txo_var.inner;
3333         if (funding_txo_var.is_owned) {
3334                 funding_txo_ref |= 1;
3335         }
3336         LDKChannelMonitorUpdate update_var = update;
3337         CHECK((((uint64_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3338         CHECK((((uint64_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3339         uint64_t update_ref = (uint64_t)update_var.inner;
3340         if (update_var.is_owned) {
3341                 update_ref |= 1;
3342         }
3343         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3344         CHECK(obj != NULL);
3345         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(*env)->CallLongMethod(env, obj, j_calls->update_channel_meth, funding_txo_ref, update_ref);
3346         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
3347         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
3348         if (get_jenv_res == JNI_EDETACHED) {
3349                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3350         }
3351         return ret_conv;
3352 }
3353 LDKCVec_MonitorEventZ release_pending_monitor_events_LDKWatch_jcall(const void* this_arg) {
3354         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
3355         JNIEnv *env;
3356         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3357         if (get_jenv_res == JNI_EDETACHED) {
3358                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3359         } else {
3360                 DO_ASSERT(get_jenv_res == JNI_OK);
3361         }
3362         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3363         CHECK(obj != NULL);
3364         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->release_pending_monitor_events_meth);
3365         LDKCVec_MonitorEventZ ret_constr;
3366         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
3367         if (ret_constr.datalen > 0)
3368                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
3369         else
3370                 ret_constr.data = NULL;
3371         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
3372         for (size_t o = 0; o < ret_constr.datalen; o++) {
3373                 int64_t ret_conv_14 = ret_vals[o];
3374                 LDKMonitorEvent ret_conv_14_conv = *(LDKMonitorEvent*)(((uint64_t)ret_conv_14) & ~1);
3375                 ret_conv_14_conv = MonitorEvent_clone((LDKMonitorEvent*)(((uint64_t)ret_conv_14) & ~1));
3376                 ret_constr.data[o] = ret_conv_14_conv;
3377         }
3378         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
3379         if (get_jenv_res == JNI_EDETACHED) {
3380                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3381         }
3382         return ret_constr;
3383 }
3384 static void* LDKWatch_JCalls_clone(const void* this_arg) {
3385         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
3386         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3387         return (void*) this_arg;
3388 }
3389 static inline LDKWatch LDKWatch_init (JNIEnv *env, jclass clz, jobject o) {
3390         jclass c = (*env)->GetObjectClass(env, o);
3391         CHECK(c != NULL);
3392         LDKWatch_JCalls *calls = MALLOC(sizeof(LDKWatch_JCalls), "LDKWatch_JCalls");
3393         atomic_init(&calls->refcnt, 1);
3394         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
3395         calls->o = (*env)->NewWeakGlobalRef(env, o);
3396         calls->watch_channel_meth = (*env)->GetMethodID(env, c, "watch_channel", "(JJ)J");
3397         CHECK(calls->watch_channel_meth != NULL);
3398         calls->update_channel_meth = (*env)->GetMethodID(env, c, "update_channel", "(JJ)J");
3399         CHECK(calls->update_channel_meth != NULL);
3400         calls->release_pending_monitor_events_meth = (*env)->GetMethodID(env, c, "release_pending_monitor_events", "()[J");
3401         CHECK(calls->release_pending_monitor_events_meth != NULL);
3402
3403         LDKWatch ret = {
3404                 .this_arg = (void*) calls,
3405                 .watch_channel = watch_channel_LDKWatch_jcall,
3406                 .update_channel = update_channel_LDKWatch_jcall,
3407                 .release_pending_monitor_events = release_pending_monitor_events_LDKWatch_jcall,
3408                 .free = LDKWatch_JCalls_free,
3409         };
3410         return ret;
3411 }
3412 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKWatch_1new(JNIEnv *env, jclass clz, jobject o) {
3413         LDKWatch *res_ptr = MALLOC(sizeof(LDKWatch), "LDKWatch");
3414         *res_ptr = LDKWatch_init(env, clz, o);
3415         return (uint64_t)res_ptr;
3416 }
3417 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) {
3418         LDKWatch* this_arg_conv = (LDKWatch*)(((uint64_t)this_arg) & ~1);
3419         LDKOutPoint funding_txo_conv;
3420         funding_txo_conv.inner = (void*)(funding_txo & (~1));
3421         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
3422         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
3423         LDKChannelMonitor monitor_conv;
3424         monitor_conv.inner = (void*)(monitor & (~1));
3425         monitor_conv.is_owned = (monitor & 1) || (monitor == 0);
3426         monitor_conv = ChannelMonitor_clone(&monitor_conv);
3427         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
3428         *ret_conv = (this_arg_conv->watch_channel)(this_arg_conv->this_arg, funding_txo_conv, monitor_conv);
3429         return (uint64_t)ret_conv;
3430 }
3431
3432 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) {
3433         LDKWatch* this_arg_conv = (LDKWatch*)(((uint64_t)this_arg) & ~1);
3434         LDKOutPoint funding_txo_conv;
3435         funding_txo_conv.inner = (void*)(funding_txo & (~1));
3436         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
3437         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
3438         LDKChannelMonitorUpdate update_conv;
3439         update_conv.inner = (void*)(update & (~1));
3440         update_conv.is_owned = (update & 1) || (update == 0);
3441         update_conv = ChannelMonitorUpdate_clone(&update_conv);
3442         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
3443         *ret_conv = (this_arg_conv->update_channel)(this_arg_conv->this_arg, funding_txo_conv, update_conv);
3444         return (uint64_t)ret_conv;
3445 }
3446
3447 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Watch_1release_1pending_1monitor_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
3448         LDKWatch* this_arg_conv = (LDKWatch*)(((uint64_t)this_arg) & ~1);
3449         LDKCVec_MonitorEventZ ret_var = (this_arg_conv->release_pending_monitor_events)(this_arg_conv->this_arg);
3450         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
3451         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
3452         for (size_t o = 0; o < ret_var.datalen; o++) {
3453                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
3454                 *ret_conv_14_copy = MonitorEvent_clone(&ret_var.data[o]);
3455                 uint64_t ret_conv_14_ref = (uint64_t)ret_conv_14_copy;
3456                 ret_arr_ptr[o] = ret_conv_14_ref;
3457         }
3458         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
3459         FREE(ret_var.data);
3460         return ret_arr;
3461 }
3462
3463 typedef struct LDKBroadcasterInterface_JCalls {
3464         atomic_size_t refcnt;
3465         JavaVM *vm;
3466         jweak o;
3467         jmethodID broadcast_transaction_meth;
3468 } LDKBroadcasterInterface_JCalls;
3469 static void LDKBroadcasterInterface_JCalls_free(void* this_arg) {
3470         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
3471         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3472                 JNIEnv *env;
3473                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3474                 if (get_jenv_res == JNI_EDETACHED) {
3475                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3476                 } else {
3477                         DO_ASSERT(get_jenv_res == JNI_OK);
3478                 }
3479                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
3480                 if (get_jenv_res == JNI_EDETACHED) {
3481                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3482                 }
3483                 FREE(j_calls);
3484         }
3485 }
3486 void broadcast_transaction_LDKBroadcasterInterface_jcall(const void* this_arg, LDKTransaction tx) {
3487         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
3488         JNIEnv *env;
3489         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3490         if (get_jenv_res == JNI_EDETACHED) {
3491                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3492         } else {
3493                 DO_ASSERT(get_jenv_res == JNI_OK);
3494         }
3495         LDKTransaction tx_var = tx;
3496         int8_tArray tx_arr = (*env)->NewByteArray(env, tx_var.datalen);
3497         (*env)->SetByteArrayRegion(env, tx_arr, 0, tx_var.datalen, tx_var.data);
3498         Transaction_free(tx_var);
3499         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3500         CHECK(obj != NULL);
3501         (*env)->CallVoidMethod(env, obj, j_calls->broadcast_transaction_meth, tx_arr);
3502         if (get_jenv_res == JNI_EDETACHED) {
3503                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3504         }
3505 }
3506 static void* LDKBroadcasterInterface_JCalls_clone(const void* this_arg) {
3507         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
3508         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3509         return (void*) this_arg;
3510 }
3511 static inline LDKBroadcasterInterface LDKBroadcasterInterface_init (JNIEnv *env, jclass clz, jobject o) {
3512         jclass c = (*env)->GetObjectClass(env, o);
3513         CHECK(c != NULL);
3514         LDKBroadcasterInterface_JCalls *calls = MALLOC(sizeof(LDKBroadcasterInterface_JCalls), "LDKBroadcasterInterface_JCalls");
3515         atomic_init(&calls->refcnt, 1);
3516         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
3517         calls->o = (*env)->NewWeakGlobalRef(env, o);
3518         calls->broadcast_transaction_meth = (*env)->GetMethodID(env, c, "broadcast_transaction", "([B)V");
3519         CHECK(calls->broadcast_transaction_meth != NULL);
3520
3521         LDKBroadcasterInterface ret = {
3522                 .this_arg = (void*) calls,
3523                 .broadcast_transaction = broadcast_transaction_LDKBroadcasterInterface_jcall,
3524                 .free = LDKBroadcasterInterface_JCalls_free,
3525         };
3526         return ret;
3527 }
3528 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKBroadcasterInterface_1new(JNIEnv *env, jclass clz, jobject o) {
3529         LDKBroadcasterInterface *res_ptr = MALLOC(sizeof(LDKBroadcasterInterface), "LDKBroadcasterInterface");
3530         *res_ptr = LDKBroadcasterInterface_init(env, clz, o);
3531         return (uint64_t)res_ptr;
3532 }
3533 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BroadcasterInterface_1broadcast_1transaction(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray tx) {
3534         LDKBroadcasterInterface* this_arg_conv = (LDKBroadcasterInterface*)(((uint64_t)this_arg) & ~1);
3535         LDKTransaction tx_ref;
3536         tx_ref.datalen = (*env)->GetArrayLength(env, tx);
3537         tx_ref.data = MALLOC(tx_ref.datalen, "LDKTransaction Bytes");
3538         (*env)->GetByteArrayRegion(env, tx, 0, tx_ref.datalen, tx_ref.data);
3539         tx_ref.data_is_owned = true;
3540         (this_arg_conv->broadcast_transaction)(this_arg_conv->this_arg, tx_ref);
3541 }
3542
3543 typedef struct LDKKeysInterface_JCalls {
3544         atomic_size_t refcnt;
3545         JavaVM *vm;
3546         jweak o;
3547         jmethodID get_node_secret_meth;
3548         jmethodID get_destination_script_meth;
3549         jmethodID get_shutdown_pubkey_meth;
3550         jmethodID get_channel_signer_meth;
3551         jmethodID get_secure_random_bytes_meth;
3552         jmethodID read_chan_signer_meth;
3553         jmethodID sign_invoice_meth;
3554 } LDKKeysInterface_JCalls;
3555 static void LDKKeysInterface_JCalls_free(void* this_arg) {
3556         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3557         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3558                 JNIEnv *env;
3559                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3560                 if (get_jenv_res == JNI_EDETACHED) {
3561                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3562                 } else {
3563                         DO_ASSERT(get_jenv_res == JNI_OK);
3564                 }
3565                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
3566                 if (get_jenv_res == JNI_EDETACHED) {
3567                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3568                 }
3569                 FREE(j_calls);
3570         }
3571 }
3572 LDKSecretKey get_node_secret_LDKKeysInterface_jcall(const void* this_arg) {
3573         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3574         JNIEnv *env;
3575         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3576         if (get_jenv_res == JNI_EDETACHED) {
3577                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3578         } else {
3579                 DO_ASSERT(get_jenv_res == JNI_OK);
3580         }
3581         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3582         CHECK(obj != NULL);
3583         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_node_secret_meth);
3584         LDKSecretKey ret_ref;
3585         CHECK((*env)->GetArrayLength(env, ret) == 32);
3586         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.bytes);
3587         if (get_jenv_res == JNI_EDETACHED) {
3588                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3589         }
3590         return ret_ref;
3591 }
3592 LDKCVec_u8Z get_destination_script_LDKKeysInterface_jcall(const void* this_arg) {
3593         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3594         JNIEnv *env;
3595         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3596         if (get_jenv_res == JNI_EDETACHED) {
3597                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3598         } else {
3599                 DO_ASSERT(get_jenv_res == JNI_OK);
3600         }
3601         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3602         CHECK(obj != NULL);
3603         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_destination_script_meth);
3604         LDKCVec_u8Z ret_ref;
3605         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
3606         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
3607         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
3608         if (get_jenv_res == JNI_EDETACHED) {
3609                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3610         }
3611         return ret_ref;
3612 }
3613 LDKPublicKey get_shutdown_pubkey_LDKKeysInterface_jcall(const void* this_arg) {
3614         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3615         JNIEnv *env;
3616         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3617         if (get_jenv_res == JNI_EDETACHED) {
3618                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3619         } else {
3620                 DO_ASSERT(get_jenv_res == JNI_OK);
3621         }
3622         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3623         CHECK(obj != NULL);
3624         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_shutdown_pubkey_meth);
3625         LDKPublicKey ret_ref;
3626         CHECK((*env)->GetArrayLength(env, ret) == 33);
3627         (*env)->GetByteArrayRegion(env, ret, 0, 33, ret_ref.compressed_form);
3628         if (get_jenv_res == JNI_EDETACHED) {
3629                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3630         }
3631         return ret_ref;
3632 }
3633 LDKSign get_channel_signer_LDKKeysInterface_jcall(const void* this_arg, bool inbound, uint64_t channel_value_satoshis) {
3634         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3635         JNIEnv *env;
3636         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3637         if (get_jenv_res == JNI_EDETACHED) {
3638                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3639         } else {
3640                 DO_ASSERT(get_jenv_res == JNI_OK);
3641         }
3642         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3643         CHECK(obj != NULL);
3644         LDKSign* ret = (LDKSign*)(*env)->CallLongMethod(env, obj, j_calls->get_channel_signer_meth, inbound, channel_value_satoshis);
3645         LDKSign ret_conv = *(LDKSign*)(((uint64_t)ret) & ~1);
3646         ret_conv = Sign_clone(ret);
3647         if (get_jenv_res == JNI_EDETACHED) {
3648                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3649         }
3650         return ret_conv;
3651 }
3652 LDKThirtyTwoBytes get_secure_random_bytes_LDKKeysInterface_jcall(const void* this_arg) {
3653         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3654         JNIEnv *env;
3655         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3656         if (get_jenv_res == JNI_EDETACHED) {
3657                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3658         } else {
3659                 DO_ASSERT(get_jenv_res == JNI_OK);
3660         }
3661         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3662         CHECK(obj != NULL);
3663         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_secure_random_bytes_meth);
3664         LDKThirtyTwoBytes ret_ref;
3665         CHECK((*env)->GetArrayLength(env, ret) == 32);
3666         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
3667         if (get_jenv_res == JNI_EDETACHED) {
3668                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3669         }
3670         return ret_ref;
3671 }
3672 LDKCResult_SignDecodeErrorZ read_chan_signer_LDKKeysInterface_jcall(const void* this_arg, LDKu8slice reader) {
3673         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3674         JNIEnv *env;
3675         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3676         if (get_jenv_res == JNI_EDETACHED) {
3677                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3678         } else {
3679                 DO_ASSERT(get_jenv_res == JNI_OK);
3680         }
3681         LDKu8slice reader_var = reader;
3682         int8_tArray reader_arr = (*env)->NewByteArray(env, reader_var.datalen);
3683         (*env)->SetByteArrayRegion(env, reader_arr, 0, reader_var.datalen, reader_var.data);
3684         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3685         CHECK(obj != NULL);
3686         LDKCResult_SignDecodeErrorZ* ret = (LDKCResult_SignDecodeErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->read_chan_signer_meth, reader_arr);
3687         LDKCResult_SignDecodeErrorZ ret_conv = *(LDKCResult_SignDecodeErrorZ*)(((uint64_t)ret) & ~1);
3688         ret_conv = CResult_SignDecodeErrorZ_clone((LDKCResult_SignDecodeErrorZ*)(((uint64_t)ret) & ~1));
3689         if (get_jenv_res == JNI_EDETACHED) {
3690                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3691         }
3692         return ret_conv;
3693 }
3694 LDKCResult_RecoverableSignatureNoneZ sign_invoice_LDKKeysInterface_jcall(const void* this_arg, LDKCVec_u8Z invoice_preimage) {
3695         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3696         JNIEnv *env;
3697         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3698         if (get_jenv_res == JNI_EDETACHED) {
3699                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3700         } else {
3701                 DO_ASSERT(get_jenv_res == JNI_OK);
3702         }
3703         LDKCVec_u8Z invoice_preimage_var = invoice_preimage;
3704         int8_tArray invoice_preimage_arr = (*env)->NewByteArray(env, invoice_preimage_var.datalen);
3705         (*env)->SetByteArrayRegion(env, invoice_preimage_arr, 0, invoice_preimage_var.datalen, invoice_preimage_var.data);
3706         CVec_u8Z_free(invoice_preimage_var);
3707         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3708         CHECK(obj != NULL);
3709         LDKCResult_RecoverableSignatureNoneZ* ret = (LDKCResult_RecoverableSignatureNoneZ*)(*env)->CallLongMethod(env, obj, j_calls->sign_invoice_meth, invoice_preimage_arr);
3710         LDKCResult_RecoverableSignatureNoneZ ret_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(((uint64_t)ret) & ~1);
3711         ret_conv = CResult_RecoverableSignatureNoneZ_clone((LDKCResult_RecoverableSignatureNoneZ*)(((uint64_t)ret) & ~1));
3712         if (get_jenv_res == JNI_EDETACHED) {
3713                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3714         }
3715         return ret_conv;
3716 }
3717 static void* LDKKeysInterface_JCalls_clone(const void* this_arg) {
3718         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3719         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3720         return (void*) this_arg;
3721 }
3722 static inline LDKKeysInterface LDKKeysInterface_init (JNIEnv *env, jclass clz, jobject o) {
3723         jclass c = (*env)->GetObjectClass(env, o);
3724         CHECK(c != NULL);
3725         LDKKeysInterface_JCalls *calls = MALLOC(sizeof(LDKKeysInterface_JCalls), "LDKKeysInterface_JCalls");
3726         atomic_init(&calls->refcnt, 1);
3727         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
3728         calls->o = (*env)->NewWeakGlobalRef(env, o);
3729         calls->get_node_secret_meth = (*env)->GetMethodID(env, c, "get_node_secret", "()[B");
3730         CHECK(calls->get_node_secret_meth != NULL);
3731         calls->get_destination_script_meth = (*env)->GetMethodID(env, c, "get_destination_script", "()[B");
3732         CHECK(calls->get_destination_script_meth != NULL);
3733         calls->get_shutdown_pubkey_meth = (*env)->GetMethodID(env, c, "get_shutdown_pubkey", "()[B");
3734         CHECK(calls->get_shutdown_pubkey_meth != NULL);
3735         calls->get_channel_signer_meth = (*env)->GetMethodID(env, c, "get_channel_signer", "(ZJ)J");
3736         CHECK(calls->get_channel_signer_meth != NULL);
3737         calls->get_secure_random_bytes_meth = (*env)->GetMethodID(env, c, "get_secure_random_bytes", "()[B");
3738         CHECK(calls->get_secure_random_bytes_meth != NULL);
3739         calls->read_chan_signer_meth = (*env)->GetMethodID(env, c, "read_chan_signer", "([B)J");
3740         CHECK(calls->read_chan_signer_meth != NULL);
3741         calls->sign_invoice_meth = (*env)->GetMethodID(env, c, "sign_invoice", "([B)J");
3742         CHECK(calls->sign_invoice_meth != NULL);
3743
3744         LDKKeysInterface ret = {
3745                 .this_arg = (void*) calls,
3746                 .get_node_secret = get_node_secret_LDKKeysInterface_jcall,
3747                 .get_destination_script = get_destination_script_LDKKeysInterface_jcall,
3748                 .get_shutdown_pubkey = get_shutdown_pubkey_LDKKeysInterface_jcall,
3749                 .get_channel_signer = get_channel_signer_LDKKeysInterface_jcall,
3750                 .get_secure_random_bytes = get_secure_random_bytes_LDKKeysInterface_jcall,
3751                 .read_chan_signer = read_chan_signer_LDKKeysInterface_jcall,
3752                 .sign_invoice = sign_invoice_LDKKeysInterface_jcall,
3753                 .free = LDKKeysInterface_JCalls_free,
3754         };
3755         return ret;
3756 }
3757 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKKeysInterface_1new(JNIEnv *env, jclass clz, jobject o) {
3758         LDKKeysInterface *res_ptr = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
3759         *res_ptr = LDKKeysInterface_init(env, clz, o);
3760         return (uint64_t)res_ptr;
3761 }
3762 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1node_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
3763         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
3764         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
3765         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->get_node_secret)(this_arg_conv->this_arg).bytes);
3766         return ret_arr;
3767 }
3768
3769 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1destination_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
3770         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
3771         LDKCVec_u8Z ret_var = (this_arg_conv->get_destination_script)(this_arg_conv->this_arg);
3772         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
3773         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
3774         CVec_u8Z_free(ret_var);
3775         return ret_arr;
3776 }
3777
3778 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1shutdown_1pubkey(JNIEnv *env, jclass clz, int64_t this_arg) {
3779         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
3780         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
3781         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, (this_arg_conv->get_shutdown_pubkey)(this_arg_conv->this_arg).compressed_form);
3782         return ret_arr;
3783 }
3784
3785 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) {
3786         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
3787         LDKSign* ret = MALLOC(sizeof(LDKSign), "LDKSign");
3788         *ret = (this_arg_conv->get_channel_signer)(this_arg_conv->this_arg, inbound, channel_value_satoshis);
3789         return (uint64_t)ret;
3790 }
3791
3792 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1secure_1random_1bytes(JNIEnv *env, jclass clz, int64_t this_arg) {
3793         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
3794         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
3795         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->get_secure_random_bytes)(this_arg_conv->this_arg).data);
3796         return ret_arr;
3797 }
3798
3799 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1read_1chan_1signer(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray reader) {
3800         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
3801         LDKu8slice reader_ref;
3802         reader_ref.datalen = (*env)->GetArrayLength(env, reader);
3803         reader_ref.data = (*env)->GetByteArrayElements (env, reader, NULL);
3804         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
3805         *ret_conv = (this_arg_conv->read_chan_signer)(this_arg_conv->this_arg, reader_ref);
3806         (*env)->ReleaseByteArrayElements(env, reader, (int8_t*)reader_ref.data, 0);
3807         return (uint64_t)ret_conv;
3808 }
3809
3810 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1sign_1invoice(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray invoice_preimage) {
3811         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
3812         LDKCVec_u8Z invoice_preimage_ref;
3813         invoice_preimage_ref.datalen = (*env)->GetArrayLength(env, invoice_preimage);
3814         invoice_preimage_ref.data = MALLOC(invoice_preimage_ref.datalen, "LDKCVec_u8Z Bytes");
3815         (*env)->GetByteArrayRegion(env, invoice_preimage, 0, invoice_preimage_ref.datalen, invoice_preimage_ref.data);
3816         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
3817         *ret_conv = (this_arg_conv->sign_invoice)(this_arg_conv->this_arg, invoice_preimage_ref);
3818         return (uint64_t)ret_conv;
3819 }
3820
3821 typedef struct LDKFeeEstimator_JCalls {
3822         atomic_size_t refcnt;
3823         JavaVM *vm;
3824         jweak o;
3825         jmethodID get_est_sat_per_1000_weight_meth;
3826 } LDKFeeEstimator_JCalls;
3827 static void LDKFeeEstimator_JCalls_free(void* this_arg) {
3828         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
3829         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3830                 JNIEnv *env;
3831                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3832                 if (get_jenv_res == JNI_EDETACHED) {
3833                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3834                 } else {
3835                         DO_ASSERT(get_jenv_res == JNI_OK);
3836                 }
3837                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
3838                 if (get_jenv_res == JNI_EDETACHED) {
3839                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3840                 }
3841                 FREE(j_calls);
3842         }
3843 }
3844 uint32_t get_est_sat_per_1000_weight_LDKFeeEstimator_jcall(const void* this_arg, LDKConfirmationTarget confirmation_target) {
3845         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
3846         JNIEnv *env;
3847         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3848         if (get_jenv_res == JNI_EDETACHED) {
3849                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3850         } else {
3851                 DO_ASSERT(get_jenv_res == JNI_OK);
3852         }
3853         jclass confirmation_target_conv = LDKConfirmationTarget_to_java(env, confirmation_target);
3854         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3855         CHECK(obj != NULL);
3856         int32_t ret = (*env)->CallIntMethod(env, obj, j_calls->get_est_sat_per_1000_weight_meth, confirmation_target_conv);
3857         if (get_jenv_res == JNI_EDETACHED) {
3858                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3859         }
3860         return ret;
3861 }
3862 static void* LDKFeeEstimator_JCalls_clone(const void* this_arg) {
3863         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
3864         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3865         return (void*) this_arg;
3866 }
3867 static inline LDKFeeEstimator LDKFeeEstimator_init (JNIEnv *env, jclass clz, jobject o) {
3868         jclass c = (*env)->GetObjectClass(env, o);
3869         CHECK(c != NULL);
3870         LDKFeeEstimator_JCalls *calls = MALLOC(sizeof(LDKFeeEstimator_JCalls), "LDKFeeEstimator_JCalls");
3871         atomic_init(&calls->refcnt, 1);
3872         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
3873         calls->o = (*env)->NewWeakGlobalRef(env, o);
3874         calls->get_est_sat_per_1000_weight_meth = (*env)->GetMethodID(env, c, "get_est_sat_per_1000_weight", "(Lorg/ldk/enums/ConfirmationTarget;)I");
3875         CHECK(calls->get_est_sat_per_1000_weight_meth != NULL);
3876
3877         LDKFeeEstimator ret = {
3878                 .this_arg = (void*) calls,
3879                 .get_est_sat_per_1000_weight = get_est_sat_per_1000_weight_LDKFeeEstimator_jcall,
3880                 .free = LDKFeeEstimator_JCalls_free,
3881         };
3882         return ret;
3883 }
3884 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKFeeEstimator_1new(JNIEnv *env, jclass clz, jobject o) {
3885         LDKFeeEstimator *res_ptr = MALLOC(sizeof(LDKFeeEstimator), "LDKFeeEstimator");
3886         *res_ptr = LDKFeeEstimator_init(env, clz, o);
3887         return (uint64_t)res_ptr;
3888 }
3889 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) {
3890         LDKFeeEstimator* this_arg_conv = (LDKFeeEstimator*)(((uint64_t)this_arg) & ~1);
3891         LDKConfirmationTarget confirmation_target_conv = LDKConfirmationTarget_from_java(env, confirmation_target);
3892         int32_t ret_val = (this_arg_conv->get_est_sat_per_1000_weight)(this_arg_conv->this_arg, confirmation_target_conv);
3893         return ret_val;
3894 }
3895
3896 typedef struct LDKLogger_JCalls {
3897         atomic_size_t refcnt;
3898         JavaVM *vm;
3899         jweak o;
3900         jmethodID log_meth;
3901 } LDKLogger_JCalls;
3902 static void LDKLogger_JCalls_free(void* this_arg) {
3903         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
3904         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3905                 JNIEnv *env;
3906                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3907                 if (get_jenv_res == JNI_EDETACHED) {
3908                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3909                 } else {
3910                         DO_ASSERT(get_jenv_res == JNI_OK);
3911                 }
3912                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
3913                 if (get_jenv_res == JNI_EDETACHED) {
3914                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3915                 }
3916                 FREE(j_calls);
3917         }
3918 }
3919 void log_LDKLogger_jcall(const void* this_arg, const char* record) {
3920         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
3921         JNIEnv *env;
3922         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3923         if (get_jenv_res == JNI_EDETACHED) {
3924                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3925         } else {
3926                 DO_ASSERT(get_jenv_res == JNI_OK);
3927         }
3928         const char* record_str = record;
3929         jstring record_conv = str_ref_to_java(env, record_str, strlen(record_str));
3930         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3931         CHECK(obj != NULL);
3932         (*env)->CallVoidMethod(env, obj, j_calls->log_meth, record_conv);
3933         if (get_jenv_res == JNI_EDETACHED) {
3934                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3935         }
3936 }
3937 static void* LDKLogger_JCalls_clone(const void* this_arg) {
3938         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
3939         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3940         return (void*) this_arg;
3941 }
3942 static inline LDKLogger LDKLogger_init (JNIEnv *env, jclass clz, jobject o) {
3943         jclass c = (*env)->GetObjectClass(env, o);
3944         CHECK(c != NULL);
3945         LDKLogger_JCalls *calls = MALLOC(sizeof(LDKLogger_JCalls), "LDKLogger_JCalls");
3946         atomic_init(&calls->refcnt, 1);
3947         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
3948         calls->o = (*env)->NewWeakGlobalRef(env, o);
3949         calls->log_meth = (*env)->GetMethodID(env, c, "log", "(Ljava/lang/String;)V");
3950         CHECK(calls->log_meth != NULL);
3951
3952         LDKLogger ret = {
3953                 .this_arg = (void*) calls,
3954                 .log = log_LDKLogger_jcall,
3955                 .free = LDKLogger_JCalls_free,
3956         };
3957         return ret;
3958 }
3959 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKLogger_1new(JNIEnv *env, jclass clz, jobject o) {
3960         LDKLogger *res_ptr = MALLOC(sizeof(LDKLogger), "LDKLogger");
3961         *res_ptr = LDKLogger_init(env, clz, o);
3962         return (uint64_t)res_ptr;
3963 }
3964 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1BlockHashChannelManagerZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
3965         LDKC2Tuple_BlockHashChannelManagerZ* ret = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
3966         LDKThirtyTwoBytes a_ref;
3967         CHECK((*env)->GetArrayLength(env, a) == 32);
3968         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
3969         ret->a = a_ref;
3970         LDKChannelManager b_conv;
3971         b_conv.inner = (void*)(b & (~1));
3972         b_conv.is_owned = (b & 1) || (b == 0);
3973         // Warning: we need a move here but no clone is available for LDKChannelManager
3974         ret->b = b_conv;
3975         return (uint64_t)ret;
3976 }
3977 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1BlockHashChannelManagerZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
3978         LDKC2Tuple_BlockHashChannelManagerZ *tuple = (LDKC2Tuple_BlockHashChannelManagerZ*)(ptr & ~1);
3979         int8_tArray a_arr = (*env)->NewByteArray(env, 32);
3980         (*env)->SetByteArrayRegion(env, a_arr, 0, 32, tuple->a.data);
3981         return a_arr;
3982 }
3983 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1BlockHashChannelManagerZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
3984         LDKC2Tuple_BlockHashChannelManagerZ *tuple = (LDKC2Tuple_BlockHashChannelManagerZ*)(ptr & ~1);
3985         LDKChannelManager b_var = tuple->b;
3986         CHECK((((uint64_t)b_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3987         CHECK((((uint64_t)&b_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3988         uint64_t b_ref = (uint64_t)b_var.inner & ~1;
3989         return b_ref;
3990 }
3991 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3992         return ((LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)arg)->result_ok;
3993 }
3994 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3995         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(arg & ~1);
3996         CHECK(val->result_ok);
3997         uint64_t res_ref = (uint64_t)(&(*val->contents.result)) | 1;
3998         return res_ref;
3999 }
4000 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4001         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(arg & ~1);
4002         CHECK(!val->result_ok);
4003         LDKDecodeError err_var = (*val->contents.err);
4004         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4005         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4006         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4007         return err_ref;
4008 }
4009 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelConfigDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4010         return ((LDKCResult_ChannelConfigDecodeErrorZ*)arg)->result_ok;
4011 }
4012 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelConfigDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4013         LDKCResult_ChannelConfigDecodeErrorZ *val = (LDKCResult_ChannelConfigDecodeErrorZ*)(arg & ~1);
4014         CHECK(val->result_ok);
4015         LDKChannelConfig res_var = (*val->contents.result);
4016         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4017         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4018         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4019         return res_ref;
4020 }
4021 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelConfigDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4022         LDKCResult_ChannelConfigDecodeErrorZ *val = (LDKCResult_ChannelConfigDecodeErrorZ*)(arg & ~1);
4023         CHECK(!val->result_ok);
4024         LDKDecodeError err_var = (*val->contents.err);
4025         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4026         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4027         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4028         return err_ref;
4029 }
4030 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OutPointDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4031         return ((LDKCResult_OutPointDecodeErrorZ*)arg)->result_ok;
4032 }
4033 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OutPointDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4034         LDKCResult_OutPointDecodeErrorZ *val = (LDKCResult_OutPointDecodeErrorZ*)(arg & ~1);
4035         CHECK(val->result_ok);
4036         LDKOutPoint res_var = (*val->contents.result);
4037         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4038         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4039         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4040         return res_ref;
4041 }
4042 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OutPointDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4043         LDKCResult_OutPointDecodeErrorZ *val = (LDKCResult_OutPointDecodeErrorZ*)(arg & ~1);
4044         CHECK(!val->result_ok);
4045         LDKDecodeError err_var = (*val->contents.err);
4046         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4047         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4048         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4049         return err_ref;
4050 }
4051 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SiPrefixNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4052         return ((LDKCResult_SiPrefixNoneZ*)arg)->result_ok;
4053 }
4054 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SiPrefixNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4055         LDKCResult_SiPrefixNoneZ *val = (LDKCResult_SiPrefixNoneZ*)(arg & ~1);
4056         CHECK(val->result_ok);
4057         jclass res_conv = LDKSiPrefix_to_java(env, (*val->contents.result));
4058         return res_conv;
4059 }
4060 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SiPrefixNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4061         LDKCResult_SiPrefixNoneZ *val = (LDKCResult_SiPrefixNoneZ*)(arg & ~1);
4062         CHECK(!val->result_ok);
4063         return *val->contents.err;
4064 }
4065 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4066         return ((LDKCResult_InvoiceNoneZ*)arg)->result_ok;
4067 }
4068 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4069         LDKCResult_InvoiceNoneZ *val = (LDKCResult_InvoiceNoneZ*)(arg & ~1);
4070         CHECK(val->result_ok);
4071         LDKInvoice res_var = (*val->contents.result);
4072         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4073         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4074         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4075         return res_ref;
4076 }
4077 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4078         LDKCResult_InvoiceNoneZ *val = (LDKCResult_InvoiceNoneZ*)(arg & ~1);
4079         CHECK(!val->result_ok);
4080         return *val->contents.err;
4081 }
4082 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignedRawInvoiceNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4083         return ((LDKCResult_SignedRawInvoiceNoneZ*)arg)->result_ok;
4084 }
4085 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignedRawInvoiceNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4086         LDKCResult_SignedRawInvoiceNoneZ *val = (LDKCResult_SignedRawInvoiceNoneZ*)(arg & ~1);
4087         CHECK(val->result_ok);
4088         LDKSignedRawInvoice res_var = (*val->contents.result);
4089         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4090         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4091         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4092         return res_ref;
4093 }
4094 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignedRawInvoiceNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4095         LDKCResult_SignedRawInvoiceNoneZ *val = (LDKCResult_SignedRawInvoiceNoneZ*)(arg & ~1);
4096         CHECK(!val->result_ok);
4097         return *val->contents.err;
4098 }
4099 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) {
4100         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
4101         LDKRawInvoice a_conv;
4102         a_conv.inner = (void*)(a & (~1));
4103         a_conv.is_owned = (a & 1) || (a == 0);
4104         a_conv = RawInvoice_clone(&a_conv);
4105         ret->a = a_conv;
4106         LDKThirtyTwoBytes b_ref;
4107         CHECK((*env)->GetArrayLength(env, b) == 32);
4108         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
4109         ret->b = b_ref;
4110         LDKInvoiceSignature c_conv;
4111         c_conv.inner = (void*)(c & (~1));
4112         c_conv.is_owned = (c & 1) || (c == 0);
4113         c_conv = InvoiceSignature_clone(&c_conv);
4114         ret->c = c_conv;
4115         return (uint64_t)ret;
4116 }
4117 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
4118         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *tuple = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(ptr & ~1);
4119         LDKRawInvoice a_var = tuple->a;
4120         CHECK((((uint64_t)a_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4121         CHECK((((uint64_t)&a_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4122         uint64_t a_ref = (uint64_t)a_var.inner & ~1;
4123         return a_ref;
4124 }
4125 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
4126         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *tuple = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(ptr & ~1);
4127         int8_tArray b_arr = (*env)->NewByteArray(env, 32);
4128         (*env)->SetByteArrayRegion(env, b_arr, 0, 32, tuple->b.data);
4129         return b_arr;
4130 }
4131 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1c(JNIEnv *env, jclass clz, int64_t ptr) {
4132         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *tuple = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(ptr & ~1);
4133         LDKInvoiceSignature c_var = tuple->c;
4134         CHECK((((uint64_t)c_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4135         CHECK((((uint64_t)&c_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4136         uint64_t c_ref = (uint64_t)c_var.inner & ~1;
4137         return c_ref;
4138 }
4139 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PayeePubKeyErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4140         return ((LDKCResult_PayeePubKeyErrorZ*)arg)->result_ok;
4141 }
4142 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PayeePubKeyErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4143         LDKCResult_PayeePubKeyErrorZ *val = (LDKCResult_PayeePubKeyErrorZ*)(arg & ~1);
4144         CHECK(val->result_ok);
4145         LDKPayeePubKey res_var = (*val->contents.result);
4146         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4147         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4148         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4149         return res_ref;
4150 }
4151 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PayeePubKeyErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4152         LDKCResult_PayeePubKeyErrorZ *val = (LDKCResult_PayeePubKeyErrorZ*)(arg & ~1);
4153         CHECK(!val->result_ok);
4154         jclass err_conv = LDKSecp256k1Error_to_java(env, (*val->contents.err));
4155         return err_conv;
4156 }
4157 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1PrivateRouteZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
4158         LDKCVec_PrivateRouteZ *ret = MALLOC(sizeof(LDKCVec_PrivateRouteZ), "LDKCVec_PrivateRouteZ");
4159         ret->datalen = (*env)->GetArrayLength(env, elems);
4160         if (ret->datalen == 0) {
4161                 ret->data = NULL;
4162         } else {
4163                 ret->data = MALLOC(sizeof(LDKPrivateRoute) * ret->datalen, "LDKCVec_PrivateRouteZ Data");
4164                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
4165                 for (size_t i = 0; i < ret->datalen; i++) {
4166                         int64_t arr_elem = java_elems[i];
4167                         LDKPrivateRoute arr_elem_conv;
4168                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
4169                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
4170                         arr_elem_conv = PrivateRoute_clone(&arr_elem_conv);
4171                         ret->data[i] = arr_elem_conv;
4172                 }
4173                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
4174         }
4175         return (uint64_t)ret;
4176 }
4177 static inline LDKCVec_PrivateRouteZ CVec_PrivateRouteZ_clone(const LDKCVec_PrivateRouteZ *orig) {
4178         LDKCVec_PrivateRouteZ ret = { .data = MALLOC(sizeof(LDKPrivateRoute) * orig->datalen, "LDKCVec_PrivateRouteZ clone bytes"), .datalen = orig->datalen };
4179         for (size_t i = 0; i < ret.datalen; i++) {
4180                 ret.data[i] = PrivateRoute_clone(&orig->data[i]);
4181         }
4182         return ret;
4183 }
4184 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PositiveTimestampCreationErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4185         return ((LDKCResult_PositiveTimestampCreationErrorZ*)arg)->result_ok;
4186 }
4187 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PositiveTimestampCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4188         LDKCResult_PositiveTimestampCreationErrorZ *val = (LDKCResult_PositiveTimestampCreationErrorZ*)(arg & ~1);
4189         CHECK(val->result_ok);
4190         LDKPositiveTimestamp res_var = (*val->contents.result);
4191         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4192         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4193         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4194         return res_ref;
4195 }
4196 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PositiveTimestampCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4197         LDKCResult_PositiveTimestampCreationErrorZ *val = (LDKCResult_PositiveTimestampCreationErrorZ*)(arg & ~1);
4198         CHECK(!val->result_ok);
4199         jclass err_conv = LDKCreationError_to_java(env, (*val->contents.err));
4200         return err_conv;
4201 }
4202 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneSemanticErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4203         return ((LDKCResult_NoneSemanticErrorZ*)arg)->result_ok;
4204 }
4205 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneSemanticErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4206         LDKCResult_NoneSemanticErrorZ *val = (LDKCResult_NoneSemanticErrorZ*)(arg & ~1);
4207         CHECK(val->result_ok);
4208         return *val->contents.result;
4209 }
4210 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneSemanticErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4211         LDKCResult_NoneSemanticErrorZ *val = (LDKCResult_NoneSemanticErrorZ*)(arg & ~1);
4212         CHECK(!val->result_ok);
4213         jclass err_conv = LDKSemanticError_to_java(env, (*val->contents.err));
4214         return err_conv;
4215 }
4216 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceSemanticErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4217         return ((LDKCResult_InvoiceSemanticErrorZ*)arg)->result_ok;
4218 }
4219 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceSemanticErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4220         LDKCResult_InvoiceSemanticErrorZ *val = (LDKCResult_InvoiceSemanticErrorZ*)(arg & ~1);
4221         CHECK(val->result_ok);
4222         LDKInvoice res_var = (*val->contents.result);
4223         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4224         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4225         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4226         return res_ref;
4227 }
4228 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceSemanticErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4229         LDKCResult_InvoiceSemanticErrorZ *val = (LDKCResult_InvoiceSemanticErrorZ*)(arg & ~1);
4230         CHECK(!val->result_ok);
4231         jclass err_conv = LDKSemanticError_to_java(env, (*val->contents.err));
4232         return err_conv;
4233 }
4234 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DescriptionCreationErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4235         return ((LDKCResult_DescriptionCreationErrorZ*)arg)->result_ok;
4236 }
4237 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DescriptionCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4238         LDKCResult_DescriptionCreationErrorZ *val = (LDKCResult_DescriptionCreationErrorZ*)(arg & ~1);
4239         CHECK(val->result_ok);
4240         LDKDescription res_var = (*val->contents.result);
4241         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4242         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4243         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4244         return res_ref;
4245 }
4246 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DescriptionCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4247         LDKCResult_DescriptionCreationErrorZ *val = (LDKCResult_DescriptionCreationErrorZ*)(arg & ~1);
4248         CHECK(!val->result_ok);
4249         jclass err_conv = LDKCreationError_to_java(env, (*val->contents.err));
4250         return err_conv;
4251 }
4252 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ExpiryTimeCreationErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4253         return ((LDKCResult_ExpiryTimeCreationErrorZ*)arg)->result_ok;
4254 }
4255 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ExpiryTimeCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4256         LDKCResult_ExpiryTimeCreationErrorZ *val = (LDKCResult_ExpiryTimeCreationErrorZ*)(arg & ~1);
4257         CHECK(val->result_ok);
4258         LDKExpiryTime res_var = (*val->contents.result);
4259         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4260         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4261         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4262         return res_ref;
4263 }
4264 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ExpiryTimeCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4265         LDKCResult_ExpiryTimeCreationErrorZ *val = (LDKCResult_ExpiryTimeCreationErrorZ*)(arg & ~1);
4266         CHECK(!val->result_ok);
4267         jclass err_conv = LDKCreationError_to_java(env, (*val->contents.err));
4268         return err_conv;
4269 }
4270 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PrivateRouteCreationErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4271         return ((LDKCResult_PrivateRouteCreationErrorZ*)arg)->result_ok;
4272 }
4273 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PrivateRouteCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4274         LDKCResult_PrivateRouteCreationErrorZ *val = (LDKCResult_PrivateRouteCreationErrorZ*)(arg & ~1);
4275         CHECK(val->result_ok);
4276         LDKPrivateRoute res_var = (*val->contents.result);
4277         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4278         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4279         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4280         return res_ref;
4281 }
4282 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PrivateRouteCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4283         LDKCResult_PrivateRouteCreationErrorZ *val = (LDKCResult_PrivateRouteCreationErrorZ*)(arg & ~1);
4284         CHECK(!val->result_ok);
4285         jclass err_conv = LDKCreationError_to_java(env, (*val->contents.err));
4286         return err_conv;
4287 }
4288 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1StringErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4289         return ((LDKCResult_StringErrorZ*)arg)->result_ok;
4290 }
4291 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_LDKCResult_1StringErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4292         LDKCResult_StringErrorZ *val = (LDKCResult_StringErrorZ*)(arg & ~1);
4293         CHECK(val->result_ok);
4294         LDKStr res_str = (*val->contents.result);
4295         jstring res_conv = str_ref_to_java(env, res_str.chars, res_str.len);
4296         return res_conv;
4297 }
4298 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1StringErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4299         LDKCResult_StringErrorZ *val = (LDKCResult_StringErrorZ*)(arg & ~1);
4300         CHECK(!val->result_ok);
4301         jclass err_conv = LDKSecp256k1Error_to_java(env, (*val->contents.err));
4302         return err_conv;
4303 }
4304 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelMonitorUpdateDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4305         return ((LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)arg)->result_ok;
4306 }
4307 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelMonitorUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4308         LDKCResult_ChannelMonitorUpdateDecodeErrorZ *val = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(arg & ~1);
4309         CHECK(val->result_ok);
4310         LDKChannelMonitorUpdate res_var = (*val->contents.result);
4311         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4312         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4313         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4314         return res_ref;
4315 }
4316 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelMonitorUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4317         LDKCResult_ChannelMonitorUpdateDecodeErrorZ *val = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(arg & ~1);
4318         CHECK(!val->result_ok);
4319         LDKDecodeError err_var = (*val->contents.err);
4320         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4321         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4322         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4323         return err_ref;
4324 }
4325 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCUpdateDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4326         return ((LDKCResult_HTLCUpdateDecodeErrorZ*)arg)->result_ok;
4327 }
4328 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4329         LDKCResult_HTLCUpdateDecodeErrorZ *val = (LDKCResult_HTLCUpdateDecodeErrorZ*)(arg & ~1);
4330         CHECK(val->result_ok);
4331         LDKHTLCUpdate res_var = (*val->contents.result);
4332         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4333         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4334         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4335         return res_ref;
4336 }
4337 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4338         LDKCResult_HTLCUpdateDecodeErrorZ *val = (LDKCResult_HTLCUpdateDecodeErrorZ*)(arg & ~1);
4339         CHECK(!val->result_ok);
4340         LDKDecodeError err_var = (*val->contents.err);
4341         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4342         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4343         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4344         return err_ref;
4345 }
4346 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneMonitorUpdateErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4347         return ((LDKCResult_NoneMonitorUpdateErrorZ*)arg)->result_ok;
4348 }
4349 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneMonitorUpdateErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4350         LDKCResult_NoneMonitorUpdateErrorZ *val = (LDKCResult_NoneMonitorUpdateErrorZ*)(arg & ~1);
4351         CHECK(val->result_ok);
4352         return *val->contents.result;
4353 }
4354 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneMonitorUpdateErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4355         LDKCResult_NoneMonitorUpdateErrorZ *val = (LDKCResult_NoneMonitorUpdateErrorZ*)(arg & ~1);
4356         CHECK(!val->result_ok);
4357         LDKMonitorUpdateError err_var = (*val->contents.err);
4358         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4359         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4360         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4361         return err_ref;
4362 }
4363 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1OutPointScriptZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
4364         LDKC2Tuple_OutPointScriptZ* ret = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
4365         LDKOutPoint a_conv;
4366         a_conv.inner = (void*)(a & (~1));
4367         a_conv.is_owned = (a & 1) || (a == 0);
4368         a_conv = OutPoint_clone(&a_conv);
4369         ret->a = a_conv;
4370         LDKCVec_u8Z b_ref;
4371         b_ref.datalen = (*env)->GetArrayLength(env, b);
4372         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
4373         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
4374         ret->b = b_ref;
4375         return (uint64_t)ret;
4376 }
4377 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1OutPointScriptZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
4378         LDKC2Tuple_OutPointScriptZ *tuple = (LDKC2Tuple_OutPointScriptZ*)(ptr & ~1);
4379         LDKOutPoint a_var = tuple->a;
4380         CHECK((((uint64_t)a_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4381         CHECK((((uint64_t)&a_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4382         uint64_t a_ref = (uint64_t)a_var.inner & ~1;
4383         return a_ref;
4384 }
4385 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1OutPointScriptZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
4386         LDKC2Tuple_OutPointScriptZ *tuple = (LDKC2Tuple_OutPointScriptZ*)(ptr & ~1);
4387         LDKCVec_u8Z b_var = tuple->b;
4388         int8_tArray b_arr = (*env)->NewByteArray(env, b_var.datalen);
4389         (*env)->SetByteArrayRegion(env, b_arr, 0, b_var.datalen, b_var.data);
4390         return b_arr;
4391 }
4392 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1u32ScriptZ_1new(JNIEnv *env, jclass clz, int32_t a, int8_tArray b) {
4393         LDKC2Tuple_u32ScriptZ* ret = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
4394         ret->a = a;
4395         LDKCVec_u8Z b_ref;
4396         b_ref.datalen = (*env)->GetArrayLength(env, b);
4397         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
4398         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
4399         ret->b = b_ref;
4400         return (uint64_t)ret;
4401 }
4402 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1u32ScriptZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
4403         LDKC2Tuple_u32ScriptZ *tuple = (LDKC2Tuple_u32ScriptZ*)(ptr & ~1);
4404         return tuple->a;
4405 }
4406 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1u32ScriptZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
4407         LDKC2Tuple_u32ScriptZ *tuple = (LDKC2Tuple_u32ScriptZ*)(ptr & ~1);
4408         LDKCVec_u8Z b_var = tuple->b;
4409         int8_tArray b_arr = (*env)->NewByteArray(env, b_var.datalen);
4410         (*env)->SetByteArrayRegion(env, b_arr, 0, b_var.datalen, b_var.data);
4411         return b_arr;
4412 }
4413 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1u32ScriptZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
4414         LDKCVec_C2Tuple_u32ScriptZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_u32ScriptZZ), "LDKCVec_C2Tuple_u32ScriptZZ");
4415         ret->datalen = (*env)->GetArrayLength(env, elems);
4416         if (ret->datalen == 0) {
4417                 ret->data = NULL;
4418         } else {
4419                 ret->data = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ) * ret->datalen, "LDKCVec_C2Tuple_u32ScriptZZ Data");
4420                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
4421                 for (size_t i = 0; i < ret->datalen; i++) {
4422                         int64_t arr_elem = java_elems[i];
4423                         LDKC2Tuple_u32ScriptZ arr_elem_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)arr_elem) & ~1);
4424                         arr_elem_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)(((uint64_t)arr_elem) & ~1));
4425                         ret->data[i] = arr_elem_conv;
4426                 }
4427                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
4428         }
4429         return (uint64_t)ret;
4430 }
4431 static inline LDKCVec_C2Tuple_u32ScriptZZ CVec_C2Tuple_u32ScriptZZ_clone(const LDKCVec_C2Tuple_u32ScriptZZ *orig) {
4432         LDKCVec_C2Tuple_u32ScriptZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ) * orig->datalen, "LDKCVec_C2Tuple_u32ScriptZZ clone bytes"), .datalen = orig->datalen };
4433         for (size_t i = 0; i < ret.datalen; i++) {
4434                 ret.data[i] = C2Tuple_u32ScriptZ_clone(&orig->data[i]);
4435         }
4436         return ret;
4437 }
4438 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
4439         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
4440         LDKThirtyTwoBytes a_ref;
4441         CHECK((*env)->GetArrayLength(env, a) == 32);
4442         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
4443         ret->a = a_ref;
4444         LDKCVec_C2Tuple_u32ScriptZZ b_constr;
4445         b_constr.datalen = (*env)->GetArrayLength(env, b);
4446         if (b_constr.datalen > 0)
4447                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
4448         else
4449                 b_constr.data = NULL;
4450         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
4451         for (size_t b = 0; b < b_constr.datalen; b++) {
4452                 int64_t b_conv_27 = b_vals[b];
4453                 LDKC2Tuple_u32ScriptZ b_conv_27_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_27) & ~1);
4454                 b_conv_27_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_27) & ~1));
4455                 b_constr.data[b] = b_conv_27_conv;
4456         }
4457         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
4458         ret->b = b_constr;
4459         return (uint64_t)ret;
4460 }
4461 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
4462         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *tuple = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(ptr & ~1);
4463         int8_tArray a_arr = (*env)->NewByteArray(env, 32);
4464         (*env)->SetByteArrayRegion(env, a_arr, 0, 32, tuple->a.data);
4465         return a_arr;
4466 }
4467 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
4468         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *tuple = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(ptr & ~1);
4469         LDKCVec_C2Tuple_u32ScriptZZ b_var = tuple->b;
4470         int64_tArray b_arr = (*env)->NewLongArray(env, b_var.datalen);
4471         int64_t *b_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, b_arr, NULL);
4472         for (size_t b = 0; b < b_var.datalen; b++) {
4473                 uint64_t b_conv_27_ref = (uint64_t)(&b_var.data[b]) | 1;
4474                 b_arr_ptr[b] = b_conv_27_ref;
4475         }
4476         (*env)->ReleasePrimitiveArrayCritical(env, b_arr, b_arr_ptr, 0);
4477         return b_arr;
4478 }
4479 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
4480         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ");
4481         ret->datalen = (*env)->GetArrayLength(env, elems);
4482         if (ret->datalen == 0) {
4483                 ret->data = NULL;
4484         } else {
4485                 ret->data = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ) * ret->datalen, "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ Data");
4486                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
4487                 for (size_t i = 0; i < ret->datalen; i++) {
4488                         int64_t arr_elem = java_elems[i];
4489                         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ arr_elem_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)arr_elem) & ~1);
4490                         arr_elem_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone((LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)arr_elem) & ~1));
4491                         ret->data[i] = arr_elem_conv;
4492                 }
4493                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
4494         }
4495         return (uint64_t)ret;
4496 }
4497 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ *orig) {
4498         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 };
4499         for (size_t i = 0; i < ret.datalen; i++) {
4500                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(&orig->data[i]);
4501         }
4502         return ret;
4503 }
4504 static jclass LDKEvent_FundingGenerationReady_class = NULL;
4505 static jmethodID LDKEvent_FundingGenerationReady_meth = NULL;
4506 static jclass LDKEvent_PaymentReceived_class = NULL;
4507 static jmethodID LDKEvent_PaymentReceived_meth = NULL;
4508 static jclass LDKEvent_PaymentSent_class = NULL;
4509 static jmethodID LDKEvent_PaymentSent_meth = NULL;
4510 static jclass LDKEvent_PaymentFailed_class = NULL;
4511 static jmethodID LDKEvent_PaymentFailed_meth = NULL;
4512 static jclass LDKEvent_PendingHTLCsForwardable_class = NULL;
4513 static jmethodID LDKEvent_PendingHTLCsForwardable_meth = NULL;
4514 static jclass LDKEvent_SpendableOutputs_class = NULL;
4515 static jmethodID LDKEvent_SpendableOutputs_meth = NULL;
4516 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKEvent_init (JNIEnv *env, jclass clz) {
4517         LDKEvent_FundingGenerationReady_class =
4518                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$FundingGenerationReady;"));
4519         CHECK(LDKEvent_FundingGenerationReady_class != NULL);
4520         LDKEvent_FundingGenerationReady_meth = (*env)->GetMethodID(env, LDKEvent_FundingGenerationReady_class, "<init>", "([BJ[BJ)V");
4521         CHECK(LDKEvent_FundingGenerationReady_meth != NULL);
4522         LDKEvent_PaymentReceived_class =
4523                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PaymentReceived;"));
4524         CHECK(LDKEvent_PaymentReceived_class != NULL);
4525         LDKEvent_PaymentReceived_meth = (*env)->GetMethodID(env, LDKEvent_PaymentReceived_class, "<init>", "([B[B[BJJ)V");
4526         CHECK(LDKEvent_PaymentReceived_meth != NULL);
4527         LDKEvent_PaymentSent_class =
4528                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PaymentSent;"));
4529         CHECK(LDKEvent_PaymentSent_class != NULL);
4530         LDKEvent_PaymentSent_meth = (*env)->GetMethodID(env, LDKEvent_PaymentSent_class, "<init>", "([B)V");
4531         CHECK(LDKEvent_PaymentSent_meth != NULL);
4532         LDKEvent_PaymentFailed_class =
4533                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PaymentFailed;"));
4534         CHECK(LDKEvent_PaymentFailed_class != NULL);
4535         LDKEvent_PaymentFailed_meth = (*env)->GetMethodID(env, LDKEvent_PaymentFailed_class, "<init>", "([BZ)V");
4536         CHECK(LDKEvent_PaymentFailed_meth != NULL);
4537         LDKEvent_PendingHTLCsForwardable_class =
4538                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PendingHTLCsForwardable;"));
4539         CHECK(LDKEvent_PendingHTLCsForwardable_class != NULL);
4540         LDKEvent_PendingHTLCsForwardable_meth = (*env)->GetMethodID(env, LDKEvent_PendingHTLCsForwardable_class, "<init>", "(J)V");
4541         CHECK(LDKEvent_PendingHTLCsForwardable_meth != NULL);
4542         LDKEvent_SpendableOutputs_class =
4543                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$SpendableOutputs;"));
4544         CHECK(LDKEvent_SpendableOutputs_class != NULL);
4545         LDKEvent_SpendableOutputs_meth = (*env)->GetMethodID(env, LDKEvent_SpendableOutputs_class, "<init>", "([J)V");
4546         CHECK(LDKEvent_SpendableOutputs_meth != NULL);
4547 }
4548 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
4549         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
4550         switch(obj->tag) {
4551                 case LDKEvent_FundingGenerationReady: {
4552                         int8_tArray temporary_channel_id_arr = (*env)->NewByteArray(env, 32);
4553                         (*env)->SetByteArrayRegion(env, temporary_channel_id_arr, 0, 32, obj->funding_generation_ready.temporary_channel_id.data);
4554                         LDKCVec_u8Z output_script_var = obj->funding_generation_ready.output_script;
4555                         int8_tArray output_script_arr = (*env)->NewByteArray(env, output_script_var.datalen);
4556                         (*env)->SetByteArrayRegion(env, output_script_arr, 0, output_script_var.datalen, output_script_var.data);
4557                         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);
4558                 }
4559                 case LDKEvent_PaymentReceived: {
4560                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
4561                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_received.payment_hash.data);
4562                         int8_tArray payment_preimage_arr = (*env)->NewByteArray(env, 32);
4563                         (*env)->SetByteArrayRegion(env, payment_preimage_arr, 0, 32, obj->payment_received.payment_preimage.data);
4564                         int8_tArray payment_secret_arr = (*env)->NewByteArray(env, 32);
4565                         (*env)->SetByteArrayRegion(env, payment_secret_arr, 0, 32, obj->payment_received.payment_secret.data);
4566                         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);
4567                 }
4568                 case LDKEvent_PaymentSent: {
4569                         int8_tArray payment_preimage_arr = (*env)->NewByteArray(env, 32);
4570                         (*env)->SetByteArrayRegion(env, payment_preimage_arr, 0, 32, obj->payment_sent.payment_preimage.data);
4571                         return (*env)->NewObject(env, LDKEvent_PaymentSent_class, LDKEvent_PaymentSent_meth, payment_preimage_arr);
4572                 }
4573                 case LDKEvent_PaymentFailed: {
4574                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
4575                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_failed.payment_hash.data);
4576                         return (*env)->NewObject(env, LDKEvent_PaymentFailed_class, LDKEvent_PaymentFailed_meth, payment_hash_arr, obj->payment_failed.rejected_by_dest);
4577                 }
4578                 case LDKEvent_PendingHTLCsForwardable: {
4579                         return (*env)->NewObject(env, LDKEvent_PendingHTLCsForwardable_class, LDKEvent_PendingHTLCsForwardable_meth, obj->pending_htl_cs_forwardable.time_forwardable);
4580                 }
4581                 case LDKEvent_SpendableOutputs: {
4582                         LDKCVec_SpendableOutputDescriptorZ outputs_var = obj->spendable_outputs.outputs;
4583                         int64_tArray outputs_arr = (*env)->NewLongArray(env, outputs_var.datalen);
4584                         int64_t *outputs_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, outputs_arr, NULL);
4585                         for (size_t b = 0; b < outputs_var.datalen; b++) {
4586                                 uint64_t outputs_conv_27_ref = ((uint64_t)&outputs_var.data[b]) | 1;
4587                                 outputs_arr_ptr[b] = outputs_conv_27_ref;
4588                         }
4589                         (*env)->ReleasePrimitiveArrayCritical(env, outputs_arr, outputs_arr_ptr, 0);
4590                         return (*env)->NewObject(env, LDKEvent_SpendableOutputs_class, LDKEvent_SpendableOutputs_meth, outputs_arr);
4591                 }
4592                 default: abort();
4593         }
4594 }
4595 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1EventZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
4596         LDKCVec_EventZ *ret = MALLOC(sizeof(LDKCVec_EventZ), "LDKCVec_EventZ");
4597         ret->datalen = (*env)->GetArrayLength(env, elems);
4598         if (ret->datalen == 0) {
4599                 ret->data = NULL;
4600         } else {
4601                 ret->data = MALLOC(sizeof(LDKEvent) * ret->datalen, "LDKCVec_EventZ Data");
4602                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
4603                 for (size_t i = 0; i < ret->datalen; i++) {
4604                         int64_t arr_elem = java_elems[i];
4605                         LDKEvent arr_elem_conv = *(LDKEvent*)(((uint64_t)arr_elem) & ~1);
4606                         arr_elem_conv = Event_clone((LDKEvent*)(((uint64_t)arr_elem) & ~1));
4607                         ret->data[i] = arr_elem_conv;
4608                 }
4609                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
4610         }
4611         return (uint64_t)ret;
4612 }
4613 static inline LDKCVec_EventZ CVec_EventZ_clone(const LDKCVec_EventZ *orig) {
4614         LDKCVec_EventZ ret = { .data = MALLOC(sizeof(LDKEvent) * orig->datalen, "LDKCVec_EventZ clone bytes"), .datalen = orig->datalen };
4615         for (size_t i = 0; i < ret.datalen; i++) {
4616                 ret.data[i] = Event_clone(&orig->data[i]);
4617         }
4618         return ret;
4619 }
4620 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1u32TxOutZ_1new(JNIEnv *env, jclass clz, int32_t a, int64_t b) {
4621         LDKC2Tuple_u32TxOutZ* ret = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
4622         ret->a = a;
4623         LDKTxOut b_conv = *(LDKTxOut*)(((uint64_t)b) & ~1);
4624         b_conv = TxOut_clone((LDKTxOut*)(((uint64_t)b) & ~1));
4625         ret->b = b_conv;
4626         return (uint64_t)ret;
4627 }
4628 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1u32TxOutZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
4629         LDKC2Tuple_u32TxOutZ *tuple = (LDKC2Tuple_u32TxOutZ*)(ptr & ~1);
4630         return tuple->a;
4631 }
4632 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1u32TxOutZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
4633         LDKC2Tuple_u32TxOutZ *tuple = (LDKC2Tuple_u32TxOutZ*)(ptr & ~1);
4634         uint64_t b_ref = ((uint64_t)&tuple->b) | 1;
4635         return (uint64_t)b_ref;
4636 }
4637 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1u32TxOutZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
4638         LDKCVec_C2Tuple_u32TxOutZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_u32TxOutZZ), "LDKCVec_C2Tuple_u32TxOutZZ");
4639         ret->datalen = (*env)->GetArrayLength(env, elems);
4640         if (ret->datalen == 0) {
4641                 ret->data = NULL;
4642         } else {
4643                 ret->data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * ret->datalen, "LDKCVec_C2Tuple_u32TxOutZZ Data");
4644                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
4645                 for (size_t i = 0; i < ret->datalen; i++) {
4646                         int64_t arr_elem = java_elems[i];
4647                         LDKC2Tuple_u32TxOutZ arr_elem_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)arr_elem) & ~1);
4648                         arr_elem_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uint64_t)arr_elem) & ~1));
4649                         ret->data[i] = arr_elem_conv;
4650                 }
4651                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
4652         }
4653         return (uint64_t)ret;
4654 }
4655 static inline LDKCVec_C2Tuple_u32TxOutZZ CVec_C2Tuple_u32TxOutZZ_clone(const LDKCVec_C2Tuple_u32TxOutZZ *orig) {
4656         LDKCVec_C2Tuple_u32TxOutZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * orig->datalen, "LDKCVec_C2Tuple_u32TxOutZZ clone bytes"), .datalen = orig->datalen };
4657         for (size_t i = 0; i < ret.datalen; i++) {
4658                 ret.data[i] = C2Tuple_u32TxOutZ_clone(&orig->data[i]);
4659         }
4660         return ret;
4661 }
4662 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
4663         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
4664         LDKThirtyTwoBytes a_ref;
4665         CHECK((*env)->GetArrayLength(env, a) == 32);
4666         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
4667         ret->a = a_ref;
4668         LDKCVec_C2Tuple_u32TxOutZZ b_constr;
4669         b_constr.datalen = (*env)->GetArrayLength(env, b);
4670         if (b_constr.datalen > 0)
4671                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
4672         else
4673                 b_constr.data = NULL;
4674         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
4675         for (size_t a = 0; a < b_constr.datalen; a++) {
4676                 int64_t b_conv_26 = b_vals[a];
4677                 LDKC2Tuple_u32TxOutZ b_conv_26_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_26) & ~1);
4678                 b_conv_26_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_26) & ~1));
4679                 b_constr.data[a] = b_conv_26_conv;
4680         }
4681         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
4682         ret->b = b_constr;
4683         return (uint64_t)ret;
4684 }
4685 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
4686         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *tuple = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(ptr & ~1);
4687         int8_tArray a_arr = (*env)->NewByteArray(env, 32);
4688         (*env)->SetByteArrayRegion(env, a_arr, 0, 32, tuple->a.data);
4689         return a_arr;
4690 }
4691 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
4692         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *tuple = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(ptr & ~1);
4693         LDKCVec_C2Tuple_u32TxOutZZ b_var = tuple->b;
4694         int64_tArray b_arr = (*env)->NewLongArray(env, b_var.datalen);
4695         int64_t *b_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, b_arr, NULL);
4696         for (size_t a = 0; a < b_var.datalen; a++) {
4697                 uint64_t b_conv_26_ref = (uint64_t)(&b_var.data[a]) | 1;
4698                 b_arr_ptr[a] = b_conv_26_ref;
4699         }
4700         (*env)->ReleasePrimitiveArrayCritical(env, b_arr, b_arr_ptr, 0);
4701         return b_arr;
4702 }
4703 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
4704         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ");
4705         ret->datalen = (*env)->GetArrayLength(env, elems);
4706         if (ret->datalen == 0) {
4707                 ret->data = NULL;
4708         } else {
4709                 ret->data = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ) * ret->datalen, "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Data");
4710                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
4711                 for (size_t i = 0; i < ret->datalen; i++) {
4712                         int64_t arr_elem = java_elems[i];
4713                         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ arr_elem_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)arr_elem) & ~1);
4714                         arr_elem_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone((LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)arr_elem) & ~1));
4715                         ret->data[i] = arr_elem_conv;
4716                 }
4717                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
4718         }
4719         return (uint64_t)ret;
4720 }
4721 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ *orig) {
4722         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 };
4723         for (size_t i = 0; i < ret.datalen; i++) {
4724                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(&orig->data[i]);
4725         }
4726         return ret;
4727 }
4728 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4729         return ((LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)arg)->result_ok;
4730 }
4731 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4732         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1);
4733         CHECK(val->result_ok);
4734         uint64_t res_ref = (uint64_t)(&(*val->contents.result)) | 1;
4735         return res_ref;
4736 }
4737 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4738         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1);
4739         CHECK(!val->result_ok);
4740         LDKDecodeError err_var = (*val->contents.err);
4741         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4742         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4743         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4744         return err_ref;
4745 }
4746 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolLightningErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4747         return ((LDKCResult_boolLightningErrorZ*)arg)->result_ok;
4748 }
4749 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4750         LDKCResult_boolLightningErrorZ *val = (LDKCResult_boolLightningErrorZ*)(arg & ~1);
4751         CHECK(val->result_ok);
4752         return *val->contents.result;
4753 }
4754 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4755         LDKCResult_boolLightningErrorZ *val = (LDKCResult_boolLightningErrorZ*)(arg & ~1);
4756         CHECK(!val->result_ok);
4757         LDKLightningError err_var = (*val->contents.err);
4758         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4759         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4760         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4761         return err_ref;
4762 }
4763 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) {
4764         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
4765         LDKChannelAnnouncement a_conv;
4766         a_conv.inner = (void*)(a & (~1));
4767         a_conv.is_owned = (a & 1) || (a == 0);
4768         a_conv = ChannelAnnouncement_clone(&a_conv);
4769         ret->a = a_conv;
4770         LDKChannelUpdate b_conv;
4771         b_conv.inner = (void*)(b & (~1));
4772         b_conv.is_owned = (b & 1) || (b == 0);
4773         b_conv = ChannelUpdate_clone(&b_conv);
4774         ret->b = b_conv;
4775         LDKChannelUpdate c_conv;
4776         c_conv.inner = (void*)(c & (~1));
4777         c_conv.is_owned = (c & 1) || (c == 0);
4778         c_conv = ChannelUpdate_clone(&c_conv);
4779         ret->c = c_conv;
4780         return (uint64_t)ret;
4781 }
4782 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
4783         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *tuple = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ptr & ~1);
4784         LDKChannelAnnouncement a_var = tuple->a;
4785         CHECK((((uint64_t)a_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4786         CHECK((((uint64_t)&a_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4787         uint64_t a_ref = (uint64_t)a_var.inner & ~1;
4788         return a_ref;
4789 }
4790 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
4791         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *tuple = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ptr & ~1);
4792         LDKChannelUpdate b_var = tuple->b;
4793         CHECK((((uint64_t)b_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4794         CHECK((((uint64_t)&b_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4795         uint64_t b_ref = (uint64_t)b_var.inner & ~1;
4796         return b_ref;
4797 }
4798 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1c(JNIEnv *env, jclass clz, int64_t ptr) {
4799         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *tuple = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ptr & ~1);
4800         LDKChannelUpdate c_var = tuple->c;
4801         CHECK((((uint64_t)c_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4802         CHECK((((uint64_t)&c_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4803         uint64_t c_ref = (uint64_t)c_var.inner & ~1;
4804         return c_ref;
4805 }
4806 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
4807         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *ret = MALLOC(sizeof(LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ");
4808         ret->datalen = (*env)->GetArrayLength(env, elems);
4809         if (ret->datalen == 0) {
4810                 ret->data = NULL;
4811         } else {
4812                 ret->data = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) * ret->datalen, "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Data");
4813                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
4814                 for (size_t i = 0; i < ret->datalen; i++) {
4815                         int64_t arr_elem = java_elems[i];
4816                         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ arr_elem_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)arr_elem) & ~1);
4817                         arr_elem_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone((LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)arr_elem) & ~1));
4818                         ret->data[i] = arr_elem_conv;
4819                 }
4820                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
4821         }
4822         return (uint64_t)ret;
4823 }
4824 static inline LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone(const LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *orig) {
4825         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret = { .data = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) * orig->datalen, "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ clone bytes"), .datalen = orig->datalen };
4826         for (size_t i = 0; i < ret.datalen; i++) {
4827                 ret.data[i] = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(&orig->data[i]);
4828         }
4829         return ret;
4830 }
4831 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1NodeAnnouncementZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
4832         LDKCVec_NodeAnnouncementZ *ret = MALLOC(sizeof(LDKCVec_NodeAnnouncementZ), "LDKCVec_NodeAnnouncementZ");
4833         ret->datalen = (*env)->GetArrayLength(env, elems);
4834         if (ret->datalen == 0) {
4835                 ret->data = NULL;
4836         } else {
4837                 ret->data = MALLOC(sizeof(LDKNodeAnnouncement) * ret->datalen, "LDKCVec_NodeAnnouncementZ Data");
4838                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
4839                 for (size_t i = 0; i < ret->datalen; i++) {
4840                         int64_t arr_elem = java_elems[i];
4841                         LDKNodeAnnouncement arr_elem_conv;
4842                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
4843                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
4844                         arr_elem_conv = NodeAnnouncement_clone(&arr_elem_conv);
4845                         ret->data[i] = arr_elem_conv;
4846                 }
4847                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
4848         }
4849         return (uint64_t)ret;
4850 }
4851 static inline LDKCVec_NodeAnnouncementZ CVec_NodeAnnouncementZ_clone(const LDKCVec_NodeAnnouncementZ *orig) {
4852         LDKCVec_NodeAnnouncementZ ret = { .data = MALLOC(sizeof(LDKNodeAnnouncement) * orig->datalen, "LDKCVec_NodeAnnouncementZ clone bytes"), .datalen = orig->datalen };
4853         for (size_t i = 0; i < ret.datalen; i++) {
4854                 ret.data[i] = NodeAnnouncement_clone(&orig->data[i]);
4855         }
4856         return ret;
4857 }
4858 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneLightningErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4859         return ((LDKCResult_NoneLightningErrorZ*)arg)->result_ok;
4860 }
4861 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4862         LDKCResult_NoneLightningErrorZ *val = (LDKCResult_NoneLightningErrorZ*)(arg & ~1);
4863         CHECK(val->result_ok);
4864         return *val->contents.result;
4865 }
4866 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4867         LDKCResult_NoneLightningErrorZ *val = (LDKCResult_NoneLightningErrorZ*)(arg & ~1);
4868         CHECK(!val->result_ok);
4869         LDKLightningError err_var = (*val->contents.err);
4870         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4871         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4872         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4873         return err_ref;
4874 }
4875 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1u8ZPeerHandleErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4876         return ((LDKCResult_CVec_u8ZPeerHandleErrorZ*)arg)->result_ok;
4877 }
4878 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1u8ZPeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4879         LDKCResult_CVec_u8ZPeerHandleErrorZ *val = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(arg & ~1);
4880         CHECK(val->result_ok);
4881         LDKCVec_u8Z res_var = (*val->contents.result);
4882         int8_tArray res_arr = (*env)->NewByteArray(env, res_var.datalen);
4883         (*env)->SetByteArrayRegion(env, res_arr, 0, res_var.datalen, res_var.data);
4884         return res_arr;
4885 }
4886 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1u8ZPeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4887         LDKCResult_CVec_u8ZPeerHandleErrorZ *val = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(arg & ~1);
4888         CHECK(!val->result_ok);
4889         LDKPeerHandleError err_var = (*val->contents.err);
4890         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4891         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4892         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4893         return err_ref;
4894 }
4895 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePeerHandleErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4896         return ((LDKCResult_NonePeerHandleErrorZ*)arg)->result_ok;
4897 }
4898 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4899         LDKCResult_NonePeerHandleErrorZ *val = (LDKCResult_NonePeerHandleErrorZ*)(arg & ~1);
4900         CHECK(val->result_ok);
4901         return *val->contents.result;
4902 }
4903 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4904         LDKCResult_NonePeerHandleErrorZ *val = (LDKCResult_NonePeerHandleErrorZ*)(arg & ~1);
4905         CHECK(!val->result_ok);
4906         LDKPeerHandleError err_var = (*val->contents.err);
4907         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4908         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4909         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4910         return err_ref;
4911 }
4912 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolPeerHandleErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4913         return ((LDKCResult_boolPeerHandleErrorZ*)arg)->result_ok;
4914 }
4915 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolPeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4916         LDKCResult_boolPeerHandleErrorZ *val = (LDKCResult_boolPeerHandleErrorZ*)(arg & ~1);
4917         CHECK(val->result_ok);
4918         return *val->contents.result;
4919 }
4920 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolPeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4921         LDKCResult_boolPeerHandleErrorZ *val = (LDKCResult_boolPeerHandleErrorZ*)(arg & ~1);
4922         CHECK(!val->result_ok);
4923         LDKPeerHandleError err_var = (*val->contents.err);
4924         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4925         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4926         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4927         return err_ref;
4928 }
4929 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DirectionalChannelInfoDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4930         return ((LDKCResult_DirectionalChannelInfoDecodeErrorZ*)arg)->result_ok;
4931 }
4932 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DirectionalChannelInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4933         LDKCResult_DirectionalChannelInfoDecodeErrorZ *val = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(arg & ~1);
4934         CHECK(val->result_ok);
4935         LDKDirectionalChannelInfo res_var = (*val->contents.result);
4936         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4937         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4938         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4939         return res_ref;
4940 }
4941 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DirectionalChannelInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4942         LDKCResult_DirectionalChannelInfoDecodeErrorZ *val = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(arg & ~1);
4943         CHECK(!val->result_ok);
4944         LDKDecodeError err_var = (*val->contents.err);
4945         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4946         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4947         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4948         return err_ref;
4949 }
4950 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelInfoDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4951         return ((LDKCResult_ChannelInfoDecodeErrorZ*)arg)->result_ok;
4952 }
4953 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4954         LDKCResult_ChannelInfoDecodeErrorZ *val = (LDKCResult_ChannelInfoDecodeErrorZ*)(arg & ~1);
4955         CHECK(val->result_ok);
4956         LDKChannelInfo res_var = (*val->contents.result);
4957         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4958         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4959         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4960         return res_ref;
4961 }
4962 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4963         LDKCResult_ChannelInfoDecodeErrorZ *val = (LDKCResult_ChannelInfoDecodeErrorZ*)(arg & ~1);
4964         CHECK(!val->result_ok);
4965         LDKDecodeError err_var = (*val->contents.err);
4966         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4967         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4968         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4969         return err_ref;
4970 }
4971 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RoutingFeesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4972         return ((LDKCResult_RoutingFeesDecodeErrorZ*)arg)->result_ok;
4973 }
4974 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RoutingFeesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4975         LDKCResult_RoutingFeesDecodeErrorZ *val = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
4976         CHECK(val->result_ok);
4977         LDKRoutingFees res_var = (*val->contents.result);
4978         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4979         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4980         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4981         return res_ref;
4982 }
4983 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RoutingFeesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4984         LDKCResult_RoutingFeesDecodeErrorZ *val = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
4985         CHECK(!val->result_ok);
4986         LDKDecodeError err_var = (*val->contents.err);
4987         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4988         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4989         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4990         return err_ref;
4991 }
4992 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementInfoDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4993         return ((LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)arg)->result_ok;
4994 }
4995 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4996         LDKCResult_NodeAnnouncementInfoDecodeErrorZ *val = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
4997         CHECK(val->result_ok);
4998         LDKNodeAnnouncementInfo res_var = (*val->contents.result);
4999         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5000         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5001         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5002         return res_ref;
5003 }
5004 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5005         LDKCResult_NodeAnnouncementInfoDecodeErrorZ *val = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
5006         CHECK(!val->result_ok);
5007         LDKDecodeError err_var = (*val->contents.err);
5008         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5009         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5010         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5011         return err_ref;
5012 }
5013 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1u64Z_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
5014         LDKCVec_u64Z *ret = MALLOC(sizeof(LDKCVec_u64Z), "LDKCVec_u64Z");
5015         ret->datalen = (*env)->GetArrayLength(env, elems);
5016         if (ret->datalen == 0) {
5017                 ret->data = NULL;
5018         } else {
5019                 ret->data = MALLOC(sizeof(uint64_t) * ret->datalen, "LDKCVec_u64Z Data");
5020                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
5021                 for (size_t i = 0; i < ret->datalen; i++) {
5022                         ret->data[i] = java_elems[i];
5023                 }
5024                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
5025         }
5026         return (uint64_t)ret;
5027 }
5028 static inline LDKCVec_u64Z CVec_u64Z_clone(const LDKCVec_u64Z *orig) {
5029         LDKCVec_u64Z ret = { .data = MALLOC(sizeof(int64_t) * orig->datalen, "LDKCVec_u64Z clone bytes"), .datalen = orig->datalen };
5030         memcpy(ret.data, orig->data, sizeof(int64_t) * ret.datalen);
5031         return ret;
5032 }
5033 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeInfoDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5034         return ((LDKCResult_NodeInfoDecodeErrorZ*)arg)->result_ok;
5035 }
5036 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5037         LDKCResult_NodeInfoDecodeErrorZ *val = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
5038         CHECK(val->result_ok);
5039         LDKNodeInfo res_var = (*val->contents.result);
5040         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5041         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5042         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5043         return res_ref;
5044 }
5045 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5046         LDKCResult_NodeInfoDecodeErrorZ *val = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
5047         CHECK(!val->result_ok);
5048         LDKDecodeError err_var = (*val->contents.err);
5049         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5050         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5051         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5052         return err_ref;
5053 }
5054 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetworkGraphDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5055         return ((LDKCResult_NetworkGraphDecodeErrorZ*)arg)->result_ok;
5056 }
5057 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetworkGraphDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5058         LDKCResult_NetworkGraphDecodeErrorZ *val = (LDKCResult_NetworkGraphDecodeErrorZ*)(arg & ~1);
5059         CHECK(val->result_ok);
5060         LDKNetworkGraph res_var = (*val->contents.result);
5061         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5062         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5063         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5064         return res_ref;
5065 }
5066 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetworkGraphDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5067         LDKCResult_NetworkGraphDecodeErrorZ *val = (LDKCResult_NetworkGraphDecodeErrorZ*)(arg & ~1);
5068         CHECK(!val->result_ok);
5069         LDKDecodeError err_var = (*val->contents.err);
5070         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5071         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5072         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5073         return err_ref;
5074 }
5075 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressu8Z_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5076         return ((LDKCResult_NetAddressu8Z*)arg)->result_ok;
5077 }
5078 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressu8Z_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5079         LDKCResult_NetAddressu8Z *val = (LDKCResult_NetAddressu8Z*)(arg & ~1);
5080         CHECK(val->result_ok);
5081         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
5082         return res_ref;
5083 }
5084 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressu8Z_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5085         LDKCResult_NetAddressu8Z *val = (LDKCResult_NetAddressu8Z*)(arg & ~1);
5086         CHECK(!val->result_ok);
5087         return *val->contents.err;
5088 }
5089 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CResult_1NetAddressu8ZDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5090         return ((LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)arg)->result_ok;
5091 }
5092 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CResult_1NetAddressu8ZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5093         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ *val = (LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(arg & ~1);
5094         CHECK(val->result_ok);
5095         LDKCResult_NetAddressu8Z* res_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
5096         *res_conv = (*val->contents.result);
5097         *res_conv = CResult_NetAddressu8Z_clone(res_conv);
5098         return (uint64_t)res_conv;
5099 }
5100 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CResult_1NetAddressu8ZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5101         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ *val = (LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(arg & ~1);
5102         CHECK(!val->result_ok);
5103         LDKDecodeError err_var = (*val->contents.err);
5104         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5105         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5106         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5107         return err_ref;
5108 }
5109 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5110         return ((LDKCResult_NetAddressDecodeErrorZ*)arg)->result_ok;
5111 }
5112 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5113         LDKCResult_NetAddressDecodeErrorZ *val = (LDKCResult_NetAddressDecodeErrorZ*)(arg & ~1);
5114         CHECK(val->result_ok);
5115         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
5116         return res_ref;
5117 }
5118 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5119         LDKCResult_NetAddressDecodeErrorZ *val = (LDKCResult_NetAddressDecodeErrorZ*)(arg & ~1);
5120         CHECK(!val->result_ok);
5121         LDKDecodeError err_var = (*val->contents.err);
5122         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5123         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5124         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5125         return err_ref;
5126 }
5127 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1UpdateAddHTLCZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
5128         LDKCVec_UpdateAddHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateAddHTLCZ), "LDKCVec_UpdateAddHTLCZ");
5129         ret->datalen = (*env)->GetArrayLength(env, elems);
5130         if (ret->datalen == 0) {
5131                 ret->data = NULL;
5132         } else {
5133                 ret->data = MALLOC(sizeof(LDKUpdateAddHTLC) * ret->datalen, "LDKCVec_UpdateAddHTLCZ Data");
5134                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
5135                 for (size_t i = 0; i < ret->datalen; i++) {
5136                         int64_t arr_elem = java_elems[i];
5137                         LDKUpdateAddHTLC arr_elem_conv;
5138                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
5139                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
5140                         arr_elem_conv = UpdateAddHTLC_clone(&arr_elem_conv);
5141                         ret->data[i] = arr_elem_conv;
5142                 }
5143                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
5144         }
5145         return (uint64_t)ret;
5146 }
5147 static inline LDKCVec_UpdateAddHTLCZ CVec_UpdateAddHTLCZ_clone(const LDKCVec_UpdateAddHTLCZ *orig) {
5148         LDKCVec_UpdateAddHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateAddHTLC) * orig->datalen, "LDKCVec_UpdateAddHTLCZ clone bytes"), .datalen = orig->datalen };
5149         for (size_t i = 0; i < ret.datalen; i++) {
5150                 ret.data[i] = UpdateAddHTLC_clone(&orig->data[i]);
5151         }
5152         return ret;
5153 }
5154 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1UpdateFulfillHTLCZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
5155         LDKCVec_UpdateFulfillHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateFulfillHTLCZ), "LDKCVec_UpdateFulfillHTLCZ");
5156         ret->datalen = (*env)->GetArrayLength(env, elems);
5157         if (ret->datalen == 0) {
5158                 ret->data = NULL;
5159         } else {
5160                 ret->data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * ret->datalen, "LDKCVec_UpdateFulfillHTLCZ Data");
5161                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
5162                 for (size_t i = 0; i < ret->datalen; i++) {
5163                         int64_t arr_elem = java_elems[i];
5164                         LDKUpdateFulfillHTLC arr_elem_conv;
5165                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
5166                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
5167                         arr_elem_conv = UpdateFulfillHTLC_clone(&arr_elem_conv);
5168                         ret->data[i] = arr_elem_conv;
5169                 }
5170                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
5171         }
5172         return (uint64_t)ret;
5173 }
5174 static inline LDKCVec_UpdateFulfillHTLCZ CVec_UpdateFulfillHTLCZ_clone(const LDKCVec_UpdateFulfillHTLCZ *orig) {
5175         LDKCVec_UpdateFulfillHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * orig->datalen, "LDKCVec_UpdateFulfillHTLCZ clone bytes"), .datalen = orig->datalen };
5176         for (size_t i = 0; i < ret.datalen; i++) {
5177                 ret.data[i] = UpdateFulfillHTLC_clone(&orig->data[i]);
5178         }
5179         return ret;
5180 }
5181 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1UpdateFailHTLCZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
5182         LDKCVec_UpdateFailHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateFailHTLCZ), "LDKCVec_UpdateFailHTLCZ");
5183         ret->datalen = (*env)->GetArrayLength(env, elems);
5184         if (ret->datalen == 0) {
5185                 ret->data = NULL;
5186         } else {
5187                 ret->data = MALLOC(sizeof(LDKUpdateFailHTLC) * ret->datalen, "LDKCVec_UpdateFailHTLCZ Data");
5188                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
5189                 for (size_t i = 0; i < ret->datalen; i++) {
5190                         int64_t arr_elem = java_elems[i];
5191                         LDKUpdateFailHTLC arr_elem_conv;
5192                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
5193                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
5194                         arr_elem_conv = UpdateFailHTLC_clone(&arr_elem_conv);
5195                         ret->data[i] = arr_elem_conv;
5196                 }
5197                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
5198         }
5199         return (uint64_t)ret;
5200 }
5201 static inline LDKCVec_UpdateFailHTLCZ CVec_UpdateFailHTLCZ_clone(const LDKCVec_UpdateFailHTLCZ *orig) {
5202         LDKCVec_UpdateFailHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailHTLC) * orig->datalen, "LDKCVec_UpdateFailHTLCZ clone bytes"), .datalen = orig->datalen };
5203         for (size_t i = 0; i < ret.datalen; i++) {
5204                 ret.data[i] = UpdateFailHTLC_clone(&orig->data[i]);
5205         }
5206         return ret;
5207 }
5208 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1UpdateFailMalformedHTLCZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
5209         LDKCVec_UpdateFailMalformedHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateFailMalformedHTLCZ), "LDKCVec_UpdateFailMalformedHTLCZ");
5210         ret->datalen = (*env)->GetArrayLength(env, elems);
5211         if (ret->datalen == 0) {
5212                 ret->data = NULL;
5213         } else {
5214                 ret->data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * ret->datalen, "LDKCVec_UpdateFailMalformedHTLCZ Data");
5215                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
5216                 for (size_t i = 0; i < ret->datalen; i++) {
5217                         int64_t arr_elem = java_elems[i];
5218                         LDKUpdateFailMalformedHTLC arr_elem_conv;
5219                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
5220                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
5221                         arr_elem_conv = UpdateFailMalformedHTLC_clone(&arr_elem_conv);
5222                         ret->data[i] = arr_elem_conv;
5223                 }
5224                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
5225         }
5226         return (uint64_t)ret;
5227 }
5228 static inline LDKCVec_UpdateFailMalformedHTLCZ CVec_UpdateFailMalformedHTLCZ_clone(const LDKCVec_UpdateFailMalformedHTLCZ *orig) {
5229         LDKCVec_UpdateFailMalformedHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * orig->datalen, "LDKCVec_UpdateFailMalformedHTLCZ clone bytes"), .datalen = orig->datalen };
5230         for (size_t i = 0; i < ret.datalen; i++) {
5231                 ret.data[i] = UpdateFailMalformedHTLC_clone(&orig->data[i]);
5232         }
5233         return ret;
5234 }
5235 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AcceptChannelDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5236         return ((LDKCResult_AcceptChannelDecodeErrorZ*)arg)->result_ok;
5237 }
5238 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AcceptChannelDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5239         LDKCResult_AcceptChannelDecodeErrorZ *val = (LDKCResult_AcceptChannelDecodeErrorZ*)(arg & ~1);
5240         CHECK(val->result_ok);
5241         LDKAcceptChannel res_var = (*val->contents.result);
5242         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5243         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5244         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5245         return res_ref;
5246 }
5247 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AcceptChannelDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5248         LDKCResult_AcceptChannelDecodeErrorZ *val = (LDKCResult_AcceptChannelDecodeErrorZ*)(arg & ~1);
5249         CHECK(!val->result_ok);
5250         LDKDecodeError err_var = (*val->contents.err);
5251         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5252         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5253         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5254         return err_ref;
5255 }
5256 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AnnouncementSignaturesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5257         return ((LDKCResult_AnnouncementSignaturesDecodeErrorZ*)arg)->result_ok;
5258 }
5259 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AnnouncementSignaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5260         LDKCResult_AnnouncementSignaturesDecodeErrorZ *val = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(arg & ~1);
5261         CHECK(val->result_ok);
5262         LDKAnnouncementSignatures res_var = (*val->contents.result);
5263         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5264         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5265         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5266         return res_ref;
5267 }
5268 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AnnouncementSignaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5269         LDKCResult_AnnouncementSignaturesDecodeErrorZ *val = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(arg & ~1);
5270         CHECK(!val->result_ok);
5271         LDKDecodeError err_var = (*val->contents.err);
5272         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5273         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5274         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5275         return err_ref;
5276 }
5277 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelReestablishDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5278         return ((LDKCResult_ChannelReestablishDecodeErrorZ*)arg)->result_ok;
5279 }
5280 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelReestablishDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5281         LDKCResult_ChannelReestablishDecodeErrorZ *val = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
5282         CHECK(val->result_ok);
5283         LDKChannelReestablish res_var = (*val->contents.result);
5284         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5285         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5286         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5287         return res_ref;
5288 }
5289 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelReestablishDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5290         LDKCResult_ChannelReestablishDecodeErrorZ *val = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
5291         CHECK(!val->result_ok);
5292         LDKDecodeError err_var = (*val->contents.err);
5293         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5294         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5295         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5296         return err_ref;
5297 }
5298 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ClosingSignedDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5299         return ((LDKCResult_ClosingSignedDecodeErrorZ*)arg)->result_ok;
5300 }
5301 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ClosingSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5302         LDKCResult_ClosingSignedDecodeErrorZ *val = (LDKCResult_ClosingSignedDecodeErrorZ*)(arg & ~1);
5303         CHECK(val->result_ok);
5304         LDKClosingSigned res_var = (*val->contents.result);
5305         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5306         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5307         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5308         return res_ref;
5309 }
5310 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ClosingSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5311         LDKCResult_ClosingSignedDecodeErrorZ *val = (LDKCResult_ClosingSignedDecodeErrorZ*)(arg & ~1);
5312         CHECK(!val->result_ok);
5313         LDKDecodeError err_var = (*val->contents.err);
5314         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5315         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5316         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5317         return err_ref;
5318 }
5319 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentSignedDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5320         return ((LDKCResult_CommitmentSignedDecodeErrorZ*)arg)->result_ok;
5321 }
5322 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5323         LDKCResult_CommitmentSignedDecodeErrorZ *val = (LDKCResult_CommitmentSignedDecodeErrorZ*)(arg & ~1);
5324         CHECK(val->result_ok);
5325         LDKCommitmentSigned res_var = (*val->contents.result);
5326         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5327         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5328         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5329         return res_ref;
5330 }
5331 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5332         LDKCResult_CommitmentSignedDecodeErrorZ *val = (LDKCResult_CommitmentSignedDecodeErrorZ*)(arg & ~1);
5333         CHECK(!val->result_ok);
5334         LDKDecodeError err_var = (*val->contents.err);
5335         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5336         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5337         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5338         return err_ref;
5339 }
5340 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingCreatedDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5341         return ((LDKCResult_FundingCreatedDecodeErrorZ*)arg)->result_ok;
5342 }
5343 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingCreatedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5344         LDKCResult_FundingCreatedDecodeErrorZ *val = (LDKCResult_FundingCreatedDecodeErrorZ*)(arg & ~1);
5345         CHECK(val->result_ok);
5346         LDKFundingCreated res_var = (*val->contents.result);
5347         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5348         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5349         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5350         return res_ref;
5351 }
5352 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingCreatedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5353         LDKCResult_FundingCreatedDecodeErrorZ *val = (LDKCResult_FundingCreatedDecodeErrorZ*)(arg & ~1);
5354         CHECK(!val->result_ok);
5355         LDKDecodeError err_var = (*val->contents.err);
5356         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5357         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5358         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5359         return err_ref;
5360 }
5361 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingSignedDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5362         return ((LDKCResult_FundingSignedDecodeErrorZ*)arg)->result_ok;
5363 }
5364 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5365         LDKCResult_FundingSignedDecodeErrorZ *val = (LDKCResult_FundingSignedDecodeErrorZ*)(arg & ~1);
5366         CHECK(val->result_ok);
5367         LDKFundingSigned res_var = (*val->contents.result);
5368         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5369         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5370         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5371         return res_ref;
5372 }
5373 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5374         LDKCResult_FundingSignedDecodeErrorZ *val = (LDKCResult_FundingSignedDecodeErrorZ*)(arg & ~1);
5375         CHECK(!val->result_ok);
5376         LDKDecodeError err_var = (*val->contents.err);
5377         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5378         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5379         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5380         return err_ref;
5381 }
5382 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingLockedDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5383         return ((LDKCResult_FundingLockedDecodeErrorZ*)arg)->result_ok;
5384 }
5385 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingLockedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5386         LDKCResult_FundingLockedDecodeErrorZ *val = (LDKCResult_FundingLockedDecodeErrorZ*)(arg & ~1);
5387         CHECK(val->result_ok);
5388         LDKFundingLocked res_var = (*val->contents.result);
5389         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5390         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5391         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5392         return res_ref;
5393 }
5394 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingLockedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5395         LDKCResult_FundingLockedDecodeErrorZ *val = (LDKCResult_FundingLockedDecodeErrorZ*)(arg & ~1);
5396         CHECK(!val->result_ok);
5397         LDKDecodeError err_var = (*val->contents.err);
5398         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5399         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5400         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5401         return err_ref;
5402 }
5403 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5404         return ((LDKCResult_InitDecodeErrorZ*)arg)->result_ok;
5405 }
5406 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5407         LDKCResult_InitDecodeErrorZ *val = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
5408         CHECK(val->result_ok);
5409         LDKInit res_var = (*val->contents.result);
5410         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5411         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5412         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5413         return res_ref;
5414 }
5415 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5416         LDKCResult_InitDecodeErrorZ *val = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
5417         CHECK(!val->result_ok);
5418         LDKDecodeError err_var = (*val->contents.err);
5419         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5420         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5421         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5422         return err_ref;
5423 }
5424 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OpenChannelDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5425         return ((LDKCResult_OpenChannelDecodeErrorZ*)arg)->result_ok;
5426 }
5427 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OpenChannelDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5428         LDKCResult_OpenChannelDecodeErrorZ *val = (LDKCResult_OpenChannelDecodeErrorZ*)(arg & ~1);
5429         CHECK(val->result_ok);
5430         LDKOpenChannel res_var = (*val->contents.result);
5431         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5432         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5433         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5434         return res_ref;
5435 }
5436 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OpenChannelDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5437         LDKCResult_OpenChannelDecodeErrorZ *val = (LDKCResult_OpenChannelDecodeErrorZ*)(arg & ~1);
5438         CHECK(!val->result_ok);
5439         LDKDecodeError err_var = (*val->contents.err);
5440         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5441         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5442         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5443         return err_ref;
5444 }
5445 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RevokeAndACKDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5446         return ((LDKCResult_RevokeAndACKDecodeErrorZ*)arg)->result_ok;
5447 }
5448 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RevokeAndACKDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5449         LDKCResult_RevokeAndACKDecodeErrorZ *val = (LDKCResult_RevokeAndACKDecodeErrorZ*)(arg & ~1);
5450         CHECK(val->result_ok);
5451         LDKRevokeAndACK res_var = (*val->contents.result);
5452         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5453         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5454         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5455         return res_ref;
5456 }
5457 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RevokeAndACKDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5458         LDKCResult_RevokeAndACKDecodeErrorZ *val = (LDKCResult_RevokeAndACKDecodeErrorZ*)(arg & ~1);
5459         CHECK(!val->result_ok);
5460         LDKDecodeError err_var = (*val->contents.err);
5461         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5462         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5463         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5464         return err_ref;
5465 }
5466 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5467         return ((LDKCResult_ShutdownDecodeErrorZ*)arg)->result_ok;
5468 }
5469 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5470         LDKCResult_ShutdownDecodeErrorZ *val = (LDKCResult_ShutdownDecodeErrorZ*)(arg & ~1);
5471         CHECK(val->result_ok);
5472         LDKShutdown res_var = (*val->contents.result);
5473         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5474         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5475         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5476         return res_ref;
5477 }
5478 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5479         LDKCResult_ShutdownDecodeErrorZ *val = (LDKCResult_ShutdownDecodeErrorZ*)(arg & ~1);
5480         CHECK(!val->result_ok);
5481         LDKDecodeError err_var = (*val->contents.err);
5482         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5483         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5484         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5485         return err_ref;
5486 }
5487 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailHTLCDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5488         return ((LDKCResult_UpdateFailHTLCDecodeErrorZ*)arg)->result_ok;
5489 }
5490 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5491         LDKCResult_UpdateFailHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(arg & ~1);
5492         CHECK(val->result_ok);
5493         LDKUpdateFailHTLC res_var = (*val->contents.result);
5494         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5495         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5496         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5497         return res_ref;
5498 }
5499 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5500         LDKCResult_UpdateFailHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(arg & ~1);
5501         CHECK(!val->result_ok);
5502         LDKDecodeError err_var = (*val->contents.err);
5503         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5504         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5505         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5506         return err_ref;
5507 }
5508 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailMalformedHTLCDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5509         return ((LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)arg)->result_ok;
5510 }
5511 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailMalformedHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5512         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(arg & ~1);
5513         CHECK(val->result_ok);
5514         LDKUpdateFailMalformedHTLC res_var = (*val->contents.result);
5515         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5516         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5517         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5518         return res_ref;
5519 }
5520 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailMalformedHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5521         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(arg & ~1);
5522         CHECK(!val->result_ok);
5523         LDKDecodeError err_var = (*val->contents.err);
5524         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5525         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5526         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5527         return err_ref;
5528 }
5529 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFeeDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5530         return ((LDKCResult_UpdateFeeDecodeErrorZ*)arg)->result_ok;
5531 }
5532 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFeeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5533         LDKCResult_UpdateFeeDecodeErrorZ *val = (LDKCResult_UpdateFeeDecodeErrorZ*)(arg & ~1);
5534         CHECK(val->result_ok);
5535         LDKUpdateFee res_var = (*val->contents.result);
5536         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5537         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5538         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5539         return res_ref;
5540 }
5541 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFeeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5542         LDKCResult_UpdateFeeDecodeErrorZ *val = (LDKCResult_UpdateFeeDecodeErrorZ*)(arg & ~1);
5543         CHECK(!val->result_ok);
5544         LDKDecodeError err_var = (*val->contents.err);
5545         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5546         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5547         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5548         return err_ref;
5549 }
5550 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFulfillHTLCDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5551         return ((LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)arg)->result_ok;
5552 }
5553 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFulfillHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5554         LDKCResult_UpdateFulfillHTLCDecodeErrorZ *val = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(arg & ~1);
5555         CHECK(val->result_ok);
5556         LDKUpdateFulfillHTLC res_var = (*val->contents.result);
5557         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5558         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5559         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5560         return res_ref;
5561 }
5562 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFulfillHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5563         LDKCResult_UpdateFulfillHTLCDecodeErrorZ *val = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(arg & ~1);
5564         CHECK(!val->result_ok);
5565         LDKDecodeError err_var = (*val->contents.err);
5566         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5567         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5568         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5569         return err_ref;
5570 }
5571 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateAddHTLCDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5572         return ((LDKCResult_UpdateAddHTLCDecodeErrorZ*)arg)->result_ok;
5573 }
5574 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateAddHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5575         LDKCResult_UpdateAddHTLCDecodeErrorZ *val = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(arg & ~1);
5576         CHECK(val->result_ok);
5577         LDKUpdateAddHTLC res_var = (*val->contents.result);
5578         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5579         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5580         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5581         return res_ref;
5582 }
5583 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateAddHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5584         LDKCResult_UpdateAddHTLCDecodeErrorZ *val = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(arg & ~1);
5585         CHECK(!val->result_ok);
5586         LDKDecodeError err_var = (*val->contents.err);
5587         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5588         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5589         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5590         return err_ref;
5591 }
5592 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PingDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5593         return ((LDKCResult_PingDecodeErrorZ*)arg)->result_ok;
5594 }
5595 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PingDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5596         LDKCResult_PingDecodeErrorZ *val = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
5597         CHECK(val->result_ok);
5598         LDKPing res_var = (*val->contents.result);
5599         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5600         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5601         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5602         return res_ref;
5603 }
5604 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PingDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5605         LDKCResult_PingDecodeErrorZ *val = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
5606         CHECK(!val->result_ok);
5607         LDKDecodeError err_var = (*val->contents.err);
5608         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5609         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5610         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5611         return err_ref;
5612 }
5613 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PongDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5614         return ((LDKCResult_PongDecodeErrorZ*)arg)->result_ok;
5615 }
5616 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PongDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5617         LDKCResult_PongDecodeErrorZ *val = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
5618         CHECK(val->result_ok);
5619         LDKPong res_var = (*val->contents.result);
5620         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5621         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5622         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5623         return res_ref;
5624 }
5625 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PongDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5626         LDKCResult_PongDecodeErrorZ *val = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
5627         CHECK(!val->result_ok);
5628         LDKDecodeError err_var = (*val->contents.err);
5629         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5630         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5631         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5632         return err_ref;
5633 }
5634 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelAnnouncementDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5635         return ((LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)arg)->result_ok;
5636 }
5637 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5638         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
5639         CHECK(val->result_ok);
5640         LDKUnsignedChannelAnnouncement res_var = (*val->contents.result);
5641         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5642         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5643         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5644         return res_ref;
5645 }
5646 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5647         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
5648         CHECK(!val->result_ok);
5649         LDKDecodeError err_var = (*val->contents.err);
5650         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5651         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5652         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5653         return err_ref;
5654 }
5655 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelAnnouncementDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5656         return ((LDKCResult_ChannelAnnouncementDecodeErrorZ*)arg)->result_ok;
5657 }
5658 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5659         LDKCResult_ChannelAnnouncementDecodeErrorZ *val = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(arg & ~1);
5660         CHECK(val->result_ok);
5661         LDKChannelAnnouncement res_var = (*val->contents.result);
5662         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5663         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5664         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5665         return res_ref;
5666 }
5667 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5668         LDKCResult_ChannelAnnouncementDecodeErrorZ *val = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(arg & ~1);
5669         CHECK(!val->result_ok);
5670         LDKDecodeError err_var = (*val->contents.err);
5671         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5672         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5673         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5674         return err_ref;
5675 }
5676 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelUpdateDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5677         return ((LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)arg)->result_ok;
5678 }
5679 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5680         LDKCResult_UnsignedChannelUpdateDecodeErrorZ *val = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
5681         CHECK(val->result_ok);
5682         LDKUnsignedChannelUpdate res_var = (*val->contents.result);
5683         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5684         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5685         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5686         return res_ref;
5687 }
5688 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5689         LDKCResult_UnsignedChannelUpdateDecodeErrorZ *val = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
5690         CHECK(!val->result_ok);
5691         LDKDecodeError err_var = (*val->contents.err);
5692         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5693         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5694         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5695         return err_ref;
5696 }
5697 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelUpdateDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5698         return ((LDKCResult_ChannelUpdateDecodeErrorZ*)arg)->result_ok;
5699 }
5700 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5701         LDKCResult_ChannelUpdateDecodeErrorZ *val = (LDKCResult_ChannelUpdateDecodeErrorZ*)(arg & ~1);
5702         CHECK(val->result_ok);
5703         LDKChannelUpdate res_var = (*val->contents.result);
5704         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5705         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5706         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5707         return res_ref;
5708 }
5709 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5710         LDKCResult_ChannelUpdateDecodeErrorZ *val = (LDKCResult_ChannelUpdateDecodeErrorZ*)(arg & ~1);
5711         CHECK(!val->result_ok);
5712         LDKDecodeError err_var = (*val->contents.err);
5713         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5714         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5715         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5716         return err_ref;
5717 }
5718 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ErrorMessageDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5719         return ((LDKCResult_ErrorMessageDecodeErrorZ*)arg)->result_ok;
5720 }
5721 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ErrorMessageDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5722         LDKCResult_ErrorMessageDecodeErrorZ *val = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
5723         CHECK(val->result_ok);
5724         LDKErrorMessage res_var = (*val->contents.result);
5725         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5726         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5727         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5728         return res_ref;
5729 }
5730 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ErrorMessageDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5731         LDKCResult_ErrorMessageDecodeErrorZ *val = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
5732         CHECK(!val->result_ok);
5733         LDKDecodeError err_var = (*val->contents.err);
5734         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5735         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5736         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5737         return err_ref;
5738 }
5739 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedNodeAnnouncementDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5740         return ((LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)arg)->result_ok;
5741 }
5742 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedNodeAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5743         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
5744         CHECK(val->result_ok);
5745         LDKUnsignedNodeAnnouncement res_var = (*val->contents.result);
5746         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5747         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5748         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5749         return res_ref;
5750 }
5751 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedNodeAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5752         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
5753         CHECK(!val->result_ok);
5754         LDKDecodeError err_var = (*val->contents.err);
5755         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5756         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5757         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5758         return err_ref;
5759 }
5760 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5761         return ((LDKCResult_NodeAnnouncementDecodeErrorZ*)arg)->result_ok;
5762 }
5763 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5764         LDKCResult_NodeAnnouncementDecodeErrorZ *val = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(arg & ~1);
5765         CHECK(val->result_ok);
5766         LDKNodeAnnouncement res_var = (*val->contents.result);
5767         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5768         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5769         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5770         return res_ref;
5771 }
5772 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5773         LDKCResult_NodeAnnouncementDecodeErrorZ *val = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(arg & ~1);
5774         CHECK(!val->result_ok);
5775         LDKDecodeError err_var = (*val->contents.err);
5776         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5777         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5778         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5779         return err_ref;
5780 }
5781 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryShortChannelIdsDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5782         return ((LDKCResult_QueryShortChannelIdsDecodeErrorZ*)arg)->result_ok;
5783 }
5784 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryShortChannelIdsDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5785         LDKCResult_QueryShortChannelIdsDecodeErrorZ *val = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
5786         CHECK(val->result_ok);
5787         LDKQueryShortChannelIds res_var = (*val->contents.result);
5788         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5789         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5790         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5791         return res_ref;
5792 }
5793 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryShortChannelIdsDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5794         LDKCResult_QueryShortChannelIdsDecodeErrorZ *val = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
5795         CHECK(!val->result_ok);
5796         LDKDecodeError err_var = (*val->contents.err);
5797         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5798         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5799         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5800         return err_ref;
5801 }
5802 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyShortChannelIdsEndDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5803         return ((LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)arg)->result_ok;
5804 }
5805 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyShortChannelIdsEndDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5806         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *val = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
5807         CHECK(val->result_ok);
5808         LDKReplyShortChannelIdsEnd res_var = (*val->contents.result);
5809         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5810         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5811         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5812         return res_ref;
5813 }
5814 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyShortChannelIdsEndDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5815         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *val = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
5816         CHECK(!val->result_ok);
5817         LDKDecodeError err_var = (*val->contents.err);
5818         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5819         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5820         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5821         return err_ref;
5822 }
5823 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryChannelRangeDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5824         return ((LDKCResult_QueryChannelRangeDecodeErrorZ*)arg)->result_ok;
5825 }
5826 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryChannelRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5827         LDKCResult_QueryChannelRangeDecodeErrorZ *val = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
5828         CHECK(val->result_ok);
5829         LDKQueryChannelRange res_var = (*val->contents.result);
5830         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5831         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5832         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5833         return res_ref;
5834 }
5835 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryChannelRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5836         LDKCResult_QueryChannelRangeDecodeErrorZ *val = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
5837         CHECK(!val->result_ok);
5838         LDKDecodeError err_var = (*val->contents.err);
5839         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5840         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5841         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5842         return err_ref;
5843 }
5844 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyChannelRangeDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5845         return ((LDKCResult_ReplyChannelRangeDecodeErrorZ*)arg)->result_ok;
5846 }
5847 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyChannelRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5848         LDKCResult_ReplyChannelRangeDecodeErrorZ *val = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
5849         CHECK(val->result_ok);
5850         LDKReplyChannelRange res_var = (*val->contents.result);
5851         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5852         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5853         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5854         return res_ref;
5855 }
5856 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyChannelRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5857         LDKCResult_ReplyChannelRangeDecodeErrorZ *val = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
5858         CHECK(!val->result_ok);
5859         LDKDecodeError err_var = (*val->contents.err);
5860         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5861         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5862         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5863         return err_ref;
5864 }
5865 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1GossipTimestampFilterDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5866         return ((LDKCResult_GossipTimestampFilterDecodeErrorZ*)arg)->result_ok;
5867 }
5868 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1GossipTimestampFilterDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5869         LDKCResult_GossipTimestampFilterDecodeErrorZ *val = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
5870         CHECK(val->result_ok);
5871         LDKGossipTimestampFilter res_var = (*val->contents.result);
5872         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5873         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5874         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5875         return res_ref;
5876 }
5877 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1GossipTimestampFilterDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5878         LDKCResult_GossipTimestampFilterDecodeErrorZ *val = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
5879         CHECK(!val->result_ok);
5880         LDKDecodeError err_var = (*val->contents.err);
5881         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5882         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5883         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5884         return err_ref;
5885 }
5886 static jclass LDKSignOrCreationError_SignError_class = NULL;
5887 static jmethodID LDKSignOrCreationError_SignError_meth = NULL;
5888 static jclass LDKSignOrCreationError_CreationError_class = NULL;
5889 static jmethodID LDKSignOrCreationError_CreationError_meth = NULL;
5890 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKSignOrCreationError_init (JNIEnv *env, jclass clz) {
5891         LDKSignOrCreationError_SignError_class =
5892                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKSignOrCreationError$SignError;"));
5893         CHECK(LDKSignOrCreationError_SignError_class != NULL);
5894         LDKSignOrCreationError_SignError_meth = (*env)->GetMethodID(env, LDKSignOrCreationError_SignError_class, "<init>", "()V");
5895         CHECK(LDKSignOrCreationError_SignError_meth != NULL);
5896         LDKSignOrCreationError_CreationError_class =
5897                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKSignOrCreationError$CreationError;"));
5898         CHECK(LDKSignOrCreationError_CreationError_class != NULL);
5899         LDKSignOrCreationError_CreationError_meth = (*env)->GetMethodID(env, LDKSignOrCreationError_CreationError_class, "<init>", "(Lorg/ldk/enums/CreationError;)V");
5900         CHECK(LDKSignOrCreationError_CreationError_meth != NULL);
5901 }
5902 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKSignOrCreationError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
5903         LDKSignOrCreationError *obj = (LDKSignOrCreationError*)(ptr & ~1);
5904         switch(obj->tag) {
5905                 case LDKSignOrCreationError_SignError: {
5906                         return (*env)->NewObject(env, LDKSignOrCreationError_SignError_class, LDKSignOrCreationError_SignError_meth);
5907                 }
5908                 case LDKSignOrCreationError_CreationError: {
5909                         jclass creation_error_conv = LDKCreationError_to_java(env, obj->creation_error);
5910                         return (*env)->NewObject(env, LDKSignOrCreationError_CreationError_class, LDKSignOrCreationError_CreationError_meth, creation_error_conv);
5911                 }
5912                 default: abort();
5913         }
5914 }
5915 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceSignOrCreationErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5916         return ((LDKCResult_InvoiceSignOrCreationErrorZ*)arg)->result_ok;
5917 }
5918 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceSignOrCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5919         LDKCResult_InvoiceSignOrCreationErrorZ *val = (LDKCResult_InvoiceSignOrCreationErrorZ*)(arg & ~1);
5920         CHECK(val->result_ok);
5921         LDKInvoice res_var = (*val->contents.result);
5922         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5923         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5924         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5925         return res_ref;
5926 }
5927 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceSignOrCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5928         LDKCResult_InvoiceSignOrCreationErrorZ *val = (LDKCResult_InvoiceSignOrCreationErrorZ*)(arg & ~1);
5929         CHECK(!val->result_ok);
5930         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
5931         return err_ref;
5932 }
5933 typedef struct LDKMessageSendEventsProvider_JCalls {
5934         atomic_size_t refcnt;
5935         JavaVM *vm;
5936         jweak o;
5937         jmethodID get_and_clear_pending_msg_events_meth;
5938 } LDKMessageSendEventsProvider_JCalls;
5939 static void LDKMessageSendEventsProvider_JCalls_free(void* this_arg) {
5940         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
5941         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5942                 JNIEnv *env;
5943                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5944                 if (get_jenv_res == JNI_EDETACHED) {
5945                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5946                 } else {
5947                         DO_ASSERT(get_jenv_res == JNI_OK);
5948                 }
5949                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
5950                 if (get_jenv_res == JNI_EDETACHED) {
5951                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5952                 }
5953                 FREE(j_calls);
5954         }
5955 }
5956 LDKCVec_MessageSendEventZ get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall(const void* this_arg) {
5957         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
5958         JNIEnv *env;
5959         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5960         if (get_jenv_res == JNI_EDETACHED) {
5961                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5962         } else {
5963                 DO_ASSERT(get_jenv_res == JNI_OK);
5964         }
5965         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5966         CHECK(obj != NULL);
5967         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_and_clear_pending_msg_events_meth);
5968         LDKCVec_MessageSendEventZ ret_constr;
5969         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
5970         if (ret_constr.datalen > 0)
5971                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
5972         else
5973                 ret_constr.data = NULL;
5974         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
5975         for (size_t s = 0; s < ret_constr.datalen; s++) {
5976                 int64_t ret_conv_18 = ret_vals[s];
5977                 LDKMessageSendEvent ret_conv_18_conv = *(LDKMessageSendEvent*)(((uint64_t)ret_conv_18) & ~1);
5978                 ret_conv_18_conv = MessageSendEvent_clone((LDKMessageSendEvent*)(((uint64_t)ret_conv_18) & ~1));
5979                 ret_constr.data[s] = ret_conv_18_conv;
5980         }
5981         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
5982         if (get_jenv_res == JNI_EDETACHED) {
5983                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5984         }
5985         return ret_constr;
5986 }
5987 static void* LDKMessageSendEventsProvider_JCalls_clone(const void* this_arg) {
5988         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
5989         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5990         return (void*) this_arg;
5991 }
5992 static inline LDKMessageSendEventsProvider LDKMessageSendEventsProvider_init (JNIEnv *env, jclass clz, jobject o) {
5993         jclass c = (*env)->GetObjectClass(env, o);
5994         CHECK(c != NULL);
5995         LDKMessageSendEventsProvider_JCalls *calls = MALLOC(sizeof(LDKMessageSendEventsProvider_JCalls), "LDKMessageSendEventsProvider_JCalls");
5996         atomic_init(&calls->refcnt, 1);
5997         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
5998         calls->o = (*env)->NewWeakGlobalRef(env, o);
5999         calls->get_and_clear_pending_msg_events_meth = (*env)->GetMethodID(env, c, "get_and_clear_pending_msg_events", "()[J");
6000         CHECK(calls->get_and_clear_pending_msg_events_meth != NULL);
6001
6002         LDKMessageSendEventsProvider ret = {
6003                 .this_arg = (void*) calls,
6004                 .get_and_clear_pending_msg_events = get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall,
6005                 .free = LDKMessageSendEventsProvider_JCalls_free,
6006         };
6007         return ret;
6008 }
6009 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEventsProvider_1new(JNIEnv *env, jclass clz, jobject o) {
6010         LDKMessageSendEventsProvider *res_ptr = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
6011         *res_ptr = LDKMessageSendEventsProvider_init(env, clz, o);
6012         return (uint64_t)res_ptr;
6013 }
6014 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_MessageSendEventsProvider_1get_1and_1clear_1pending_1msg_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
6015         LDKMessageSendEventsProvider* this_arg_conv = (LDKMessageSendEventsProvider*)(((uint64_t)this_arg) & ~1);
6016         LDKCVec_MessageSendEventZ ret_var = (this_arg_conv->get_and_clear_pending_msg_events)(this_arg_conv->this_arg);
6017         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
6018         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
6019         for (size_t s = 0; s < ret_var.datalen; s++) {
6020                 LDKMessageSendEvent *ret_conv_18_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
6021                 *ret_conv_18_copy = MessageSendEvent_clone(&ret_var.data[s]);
6022                 uint64_t ret_conv_18_ref = (uint64_t)ret_conv_18_copy;
6023                 ret_arr_ptr[s] = ret_conv_18_ref;
6024         }
6025         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
6026         FREE(ret_var.data);
6027         return ret_arr;
6028 }
6029
6030 typedef struct LDKEventHandler_JCalls {
6031         atomic_size_t refcnt;
6032         JavaVM *vm;
6033         jweak o;
6034         jmethodID handle_event_meth;
6035 } LDKEventHandler_JCalls;
6036 static void LDKEventHandler_JCalls_free(void* this_arg) {
6037         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
6038         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6039                 JNIEnv *env;
6040                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6041                 if (get_jenv_res == JNI_EDETACHED) {
6042                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6043                 } else {
6044                         DO_ASSERT(get_jenv_res == JNI_OK);
6045                 }
6046                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6047                 if (get_jenv_res == JNI_EDETACHED) {
6048                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6049                 }
6050                 FREE(j_calls);
6051         }
6052 }
6053 void handle_event_LDKEventHandler_jcall(const void* this_arg, LDKEvent event) {
6054         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
6055         JNIEnv *env;
6056         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6057         if (get_jenv_res == JNI_EDETACHED) {
6058                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6059         } else {
6060                 DO_ASSERT(get_jenv_res == JNI_OK);
6061         }
6062         LDKEvent *event_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
6063         *event_copy = event;
6064         uint64_t event_ref = (uint64_t)event_copy;
6065         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6066         CHECK(obj != NULL);
6067         (*env)->CallVoidMethod(env, obj, j_calls->handle_event_meth, event_ref);
6068         if (get_jenv_res == JNI_EDETACHED) {
6069                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6070         }
6071 }
6072 static void* LDKEventHandler_JCalls_clone(const void* this_arg) {
6073         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
6074         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6075         return (void*) this_arg;
6076 }
6077 static inline LDKEventHandler LDKEventHandler_init (JNIEnv *env, jclass clz, jobject o) {
6078         jclass c = (*env)->GetObjectClass(env, o);
6079         CHECK(c != NULL);
6080         LDKEventHandler_JCalls *calls = MALLOC(sizeof(LDKEventHandler_JCalls), "LDKEventHandler_JCalls");
6081         atomic_init(&calls->refcnt, 1);
6082         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6083         calls->o = (*env)->NewWeakGlobalRef(env, o);
6084         calls->handle_event_meth = (*env)->GetMethodID(env, c, "handle_event", "(J)V");
6085         CHECK(calls->handle_event_meth != NULL);
6086
6087         LDKEventHandler ret = {
6088                 .this_arg = (void*) calls,
6089                 .handle_event = handle_event_LDKEventHandler_jcall,
6090                 .free = LDKEventHandler_JCalls_free,
6091         };
6092         return ret;
6093 }
6094 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKEventHandler_1new(JNIEnv *env, jclass clz, jobject o) {
6095         LDKEventHandler *res_ptr = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
6096         *res_ptr = LDKEventHandler_init(env, clz, o);
6097         return (uint64_t)res_ptr;
6098 }
6099 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventHandler_1handle_1event(JNIEnv *env, jclass clz, int64_t this_arg, int64_t event) {
6100         LDKEventHandler* this_arg_conv = (LDKEventHandler*)(((uint64_t)this_arg) & ~1);
6101         LDKEvent event_conv = *(LDKEvent*)(((uint64_t)event) & ~1);
6102         (this_arg_conv->handle_event)(this_arg_conv->this_arg, event_conv);
6103 }
6104
6105 typedef struct LDKEventsProvider_JCalls {
6106         atomic_size_t refcnt;
6107         JavaVM *vm;
6108         jweak o;
6109         jmethodID process_pending_events_meth;
6110 } LDKEventsProvider_JCalls;
6111 static void LDKEventsProvider_JCalls_free(void* this_arg) {
6112         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
6113         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6114                 JNIEnv *env;
6115                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6116                 if (get_jenv_res == JNI_EDETACHED) {
6117                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6118                 } else {
6119                         DO_ASSERT(get_jenv_res == JNI_OK);
6120                 }
6121                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6122                 if (get_jenv_res == JNI_EDETACHED) {
6123                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6124                 }
6125                 FREE(j_calls);
6126         }
6127 }
6128 void process_pending_events_LDKEventsProvider_jcall(const void* this_arg, LDKEventHandler handler) {
6129         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
6130         JNIEnv *env;
6131         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6132         if (get_jenv_res == JNI_EDETACHED) {
6133                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6134         } else {
6135                 DO_ASSERT(get_jenv_res == JNI_OK);
6136         }
6137         LDKEventHandler* ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
6138         *ret = handler;
6139         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6140         CHECK(obj != NULL);
6141         (*env)->CallVoidMethod(env, obj, j_calls->process_pending_events_meth, (uint64_t)ret);
6142         if (get_jenv_res == JNI_EDETACHED) {
6143                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6144         }
6145 }
6146 static void* LDKEventsProvider_JCalls_clone(const void* this_arg) {
6147         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
6148         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6149         return (void*) this_arg;
6150 }
6151 static inline LDKEventsProvider LDKEventsProvider_init (JNIEnv *env, jclass clz, jobject o) {
6152         jclass c = (*env)->GetObjectClass(env, o);
6153         CHECK(c != NULL);
6154         LDKEventsProvider_JCalls *calls = MALLOC(sizeof(LDKEventsProvider_JCalls), "LDKEventsProvider_JCalls");
6155         atomic_init(&calls->refcnt, 1);
6156         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6157         calls->o = (*env)->NewWeakGlobalRef(env, o);
6158         calls->process_pending_events_meth = (*env)->GetMethodID(env, c, "process_pending_events", "(J)V");
6159         CHECK(calls->process_pending_events_meth != NULL);
6160
6161         LDKEventsProvider ret = {
6162                 .this_arg = (void*) calls,
6163                 .process_pending_events = process_pending_events_LDKEventsProvider_jcall,
6164                 .free = LDKEventsProvider_JCalls_free,
6165         };
6166         return ret;
6167 }
6168 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKEventsProvider_1new(JNIEnv *env, jclass clz, jobject o) {
6169         LDKEventsProvider *res_ptr = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
6170         *res_ptr = LDKEventsProvider_init(env, clz, o);
6171         return (uint64_t)res_ptr;
6172 }
6173 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventsProvider_1process_1pending_1events(JNIEnv *env, jclass clz, int64_t this_arg, int64_t handler) {
6174         LDKEventsProvider* this_arg_conv = (LDKEventsProvider*)(((uint64_t)this_arg) & ~1);
6175         LDKEventHandler handler_conv = *(LDKEventHandler*)(((uint64_t)handler) & ~1);
6176         if (handler_conv.free == LDKEventHandler_JCalls_free) {
6177                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
6178                 LDKEventHandler_JCalls_clone(handler_conv.this_arg);
6179         }
6180         (this_arg_conv->process_pending_events)(this_arg_conv->this_arg, handler_conv);
6181 }
6182
6183 typedef struct LDKAccess_JCalls {
6184         atomic_size_t refcnt;
6185         JavaVM *vm;
6186         jweak o;
6187         jmethodID get_utxo_meth;
6188 } LDKAccess_JCalls;
6189 static void LDKAccess_JCalls_free(void* this_arg) {
6190         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
6191         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6192                 JNIEnv *env;
6193                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6194                 if (get_jenv_res == JNI_EDETACHED) {
6195                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6196                 } else {
6197                         DO_ASSERT(get_jenv_res == JNI_OK);
6198                 }
6199                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6200                 if (get_jenv_res == JNI_EDETACHED) {
6201                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6202                 }
6203                 FREE(j_calls);
6204         }
6205 }
6206 LDKCResult_TxOutAccessErrorZ get_utxo_LDKAccess_jcall(const void* this_arg, const uint8_t (* genesis_hash)[32], uint64_t short_channel_id) {
6207         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
6208         JNIEnv *env;
6209         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6210         if (get_jenv_res == JNI_EDETACHED) {
6211                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6212         } else {
6213                 DO_ASSERT(get_jenv_res == JNI_OK);
6214         }
6215         int8_tArray genesis_hash_arr = (*env)->NewByteArray(env, 32);
6216         (*env)->SetByteArrayRegion(env, genesis_hash_arr, 0, 32, *genesis_hash);
6217         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6218         CHECK(obj != NULL);
6219         LDKCResult_TxOutAccessErrorZ* ret = (LDKCResult_TxOutAccessErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->get_utxo_meth, genesis_hash_arr, short_channel_id);
6220         LDKCResult_TxOutAccessErrorZ ret_conv = *(LDKCResult_TxOutAccessErrorZ*)(((uint64_t)ret) & ~1);
6221         ret_conv = CResult_TxOutAccessErrorZ_clone((LDKCResult_TxOutAccessErrorZ*)(((uint64_t)ret) & ~1));
6222         if (get_jenv_res == JNI_EDETACHED) {
6223                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6224         }
6225         return ret_conv;
6226 }
6227 static void* LDKAccess_JCalls_clone(const void* this_arg) {
6228         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
6229         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6230         return (void*) this_arg;
6231 }
6232 static inline LDKAccess LDKAccess_init (JNIEnv *env, jclass clz, jobject o) {
6233         jclass c = (*env)->GetObjectClass(env, o);
6234         CHECK(c != NULL);
6235         LDKAccess_JCalls *calls = MALLOC(sizeof(LDKAccess_JCalls), "LDKAccess_JCalls");
6236         atomic_init(&calls->refcnt, 1);
6237         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6238         calls->o = (*env)->NewWeakGlobalRef(env, o);
6239         calls->get_utxo_meth = (*env)->GetMethodID(env, c, "get_utxo", "([BJ)J");
6240         CHECK(calls->get_utxo_meth != NULL);
6241
6242         LDKAccess ret = {
6243                 .this_arg = (void*) calls,
6244                 .get_utxo = get_utxo_LDKAccess_jcall,
6245                 .free = LDKAccess_JCalls_free,
6246         };
6247         return ret;
6248 }
6249 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKAccess_1new(JNIEnv *env, jclass clz, jobject o) {
6250         LDKAccess *res_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
6251         *res_ptr = LDKAccess_init(env, clz, o);
6252         return (uint64_t)res_ptr;
6253 }
6254 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) {
6255         LDKAccess* this_arg_conv = (LDKAccess*)(((uint64_t)this_arg) & ~1);
6256         unsigned char genesis_hash_arr[32];
6257         CHECK((*env)->GetArrayLength(env, genesis_hash) == 32);
6258         (*env)->GetByteArrayRegion(env, genesis_hash, 0, 32, genesis_hash_arr);
6259         unsigned char (*genesis_hash_ref)[32] = &genesis_hash_arr;
6260         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
6261         *ret_conv = (this_arg_conv->get_utxo)(this_arg_conv->this_arg, genesis_hash_ref, short_channel_id);
6262         return (uint64_t)ret_conv;
6263 }
6264
6265 typedef struct LDKListen_JCalls {
6266         atomic_size_t refcnt;
6267         JavaVM *vm;
6268         jweak o;
6269         jmethodID block_connected_meth;
6270         jmethodID block_disconnected_meth;
6271 } LDKListen_JCalls;
6272 static void LDKListen_JCalls_free(void* this_arg) {
6273         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
6274         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6275                 JNIEnv *env;
6276                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6277                 if (get_jenv_res == JNI_EDETACHED) {
6278                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6279                 } else {
6280                         DO_ASSERT(get_jenv_res == JNI_OK);
6281                 }
6282                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6283                 if (get_jenv_res == JNI_EDETACHED) {
6284                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6285                 }
6286                 FREE(j_calls);
6287         }
6288 }
6289 void block_connected_LDKListen_jcall(const void* this_arg, LDKu8slice block, uint32_t height) {
6290         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
6291         JNIEnv *env;
6292         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6293         if (get_jenv_res == JNI_EDETACHED) {
6294                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6295         } else {
6296                 DO_ASSERT(get_jenv_res == JNI_OK);
6297         }
6298         LDKu8slice block_var = block;
6299         int8_tArray block_arr = (*env)->NewByteArray(env, block_var.datalen);
6300         (*env)->SetByteArrayRegion(env, block_arr, 0, block_var.datalen, block_var.data);
6301         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6302         CHECK(obj != NULL);
6303         (*env)->CallVoidMethod(env, obj, j_calls->block_connected_meth, block_arr, height);
6304         if (get_jenv_res == JNI_EDETACHED) {
6305                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6306         }
6307 }
6308 void block_disconnected_LDKListen_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
6309         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
6310         JNIEnv *env;
6311         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6312         if (get_jenv_res == JNI_EDETACHED) {
6313                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6314         } else {
6315                 DO_ASSERT(get_jenv_res == JNI_OK);
6316         }
6317         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
6318         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
6319         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6320         CHECK(obj != NULL);
6321         (*env)->CallVoidMethod(env, obj, j_calls->block_disconnected_meth, header_arr, height);
6322         if (get_jenv_res == JNI_EDETACHED) {
6323                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6324         }
6325 }
6326 static void* LDKListen_JCalls_clone(const void* this_arg) {
6327         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
6328         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6329         return (void*) this_arg;
6330 }
6331 static inline LDKListen LDKListen_init (JNIEnv *env, jclass clz, jobject o) {
6332         jclass c = (*env)->GetObjectClass(env, o);
6333         CHECK(c != NULL);
6334         LDKListen_JCalls *calls = MALLOC(sizeof(LDKListen_JCalls), "LDKListen_JCalls");
6335         atomic_init(&calls->refcnt, 1);
6336         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6337         calls->o = (*env)->NewWeakGlobalRef(env, o);
6338         calls->block_connected_meth = (*env)->GetMethodID(env, c, "block_connected", "([BI)V");
6339         CHECK(calls->block_connected_meth != NULL);
6340         calls->block_disconnected_meth = (*env)->GetMethodID(env, c, "block_disconnected", "([BI)V");
6341         CHECK(calls->block_disconnected_meth != NULL);
6342
6343         LDKListen ret = {
6344                 .this_arg = (void*) calls,
6345                 .block_connected = block_connected_LDKListen_jcall,
6346                 .block_disconnected = block_disconnected_LDKListen_jcall,
6347                 .free = LDKListen_JCalls_free,
6348         };
6349         return ret;
6350 }
6351 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKListen_1new(JNIEnv *env, jclass clz, jobject o) {
6352         LDKListen *res_ptr = MALLOC(sizeof(LDKListen), "LDKListen");
6353         *res_ptr = LDKListen_init(env, clz, o);
6354         return (uint64_t)res_ptr;
6355 }
6356 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) {
6357         LDKListen* this_arg_conv = (LDKListen*)(((uint64_t)this_arg) & ~1);
6358         LDKu8slice block_ref;
6359         block_ref.datalen = (*env)->GetArrayLength(env, block);
6360         block_ref.data = (*env)->GetByteArrayElements (env, block, NULL);
6361         (this_arg_conv->block_connected)(this_arg_conv->this_arg, block_ref, height);
6362         (*env)->ReleaseByteArrayElements(env, block, (int8_t*)block_ref.data, 0);
6363 }
6364
6365 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) {
6366         LDKListen* this_arg_conv = (LDKListen*)(((uint64_t)this_arg) & ~1);
6367         unsigned char header_arr[80];
6368         CHECK((*env)->GetArrayLength(env, header) == 80);
6369         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
6370         unsigned char (*header_ref)[80] = &header_arr;
6371         (this_arg_conv->block_disconnected)(this_arg_conv->this_arg, header_ref, height);
6372 }
6373
6374 typedef struct LDKConfirm_JCalls {
6375         atomic_size_t refcnt;
6376         JavaVM *vm;
6377         jweak o;
6378         jmethodID transactions_confirmed_meth;
6379         jmethodID transaction_unconfirmed_meth;
6380         jmethodID best_block_updated_meth;
6381         jmethodID get_relevant_txids_meth;
6382 } LDKConfirm_JCalls;
6383 static void LDKConfirm_JCalls_free(void* this_arg) {
6384         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
6385         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6386                 JNIEnv *env;
6387                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6388                 if (get_jenv_res == JNI_EDETACHED) {
6389                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6390                 } else {
6391                         DO_ASSERT(get_jenv_res == JNI_OK);
6392                 }
6393                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6394                 if (get_jenv_res == JNI_EDETACHED) {
6395                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6396                 }
6397                 FREE(j_calls);
6398         }
6399 }
6400 void transactions_confirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height) {
6401         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
6402         JNIEnv *env;
6403         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6404         if (get_jenv_res == JNI_EDETACHED) {
6405                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6406         } else {
6407                 DO_ASSERT(get_jenv_res == JNI_OK);
6408         }
6409         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
6410         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
6411         LDKCVec_C2Tuple_usizeTransactionZZ txdata_var = txdata;
6412         int64_tArray txdata_arr = (*env)->NewLongArray(env, txdata_var.datalen);
6413         int64_t *txdata_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, txdata_arr, NULL);
6414         for (size_t y = 0; y < txdata_var.datalen; y++) {
6415                 LDKC2Tuple_usizeTransactionZ* txdata_conv_24_ref = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
6416                 *txdata_conv_24_ref = txdata_var.data[y];
6417                 txdata_arr_ptr[y] = (uint64_t)txdata_conv_24_ref;
6418         }
6419         (*env)->ReleasePrimitiveArrayCritical(env, txdata_arr, txdata_arr_ptr, 0);
6420         FREE(txdata_var.data);
6421         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6422         CHECK(obj != NULL);
6423         (*env)->CallVoidMethod(env, obj, j_calls->transactions_confirmed_meth, header_arr, txdata_arr, height);
6424         if (get_jenv_res == JNI_EDETACHED) {
6425                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6426         }
6427 }
6428 void transaction_unconfirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* txid)[32]) {
6429         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
6430         JNIEnv *env;
6431         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6432         if (get_jenv_res == JNI_EDETACHED) {
6433                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6434         } else {
6435                 DO_ASSERT(get_jenv_res == JNI_OK);
6436         }
6437         int8_tArray txid_arr = (*env)->NewByteArray(env, 32);
6438         (*env)->SetByteArrayRegion(env, txid_arr, 0, 32, *txid);
6439         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6440         CHECK(obj != NULL);
6441         (*env)->CallVoidMethod(env, obj, j_calls->transaction_unconfirmed_meth, txid_arr);
6442         if (get_jenv_res == JNI_EDETACHED) {
6443                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6444         }
6445 }
6446 void best_block_updated_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
6447         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
6448         JNIEnv *env;
6449         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6450         if (get_jenv_res == JNI_EDETACHED) {
6451                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6452         } else {
6453                 DO_ASSERT(get_jenv_res == JNI_OK);
6454         }
6455         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
6456         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
6457         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6458         CHECK(obj != NULL);
6459         (*env)->CallVoidMethod(env, obj, j_calls->best_block_updated_meth, header_arr, height);
6460         if (get_jenv_res == JNI_EDETACHED) {
6461                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6462         }
6463 }
6464 LDKCVec_TxidZ get_relevant_txids_LDKConfirm_jcall(const void* this_arg) {
6465         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
6466         JNIEnv *env;
6467         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6468         if (get_jenv_res == JNI_EDETACHED) {
6469                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6470         } else {
6471                 DO_ASSERT(get_jenv_res == JNI_OK);
6472         }
6473         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6474         CHECK(obj != NULL);
6475         jobjectArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_relevant_txids_meth);
6476         LDKCVec_TxidZ ret_constr;
6477         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
6478         if (ret_constr.datalen > 0)
6479                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
6480         else
6481                 ret_constr.data = NULL;
6482         for (size_t i = 0; i < ret_constr.datalen; i++) {
6483                 int8_tArray ret_conv_8 = (*env)->GetObjectArrayElement(env, ret, i);
6484                 LDKThirtyTwoBytes ret_conv_8_ref;
6485                 CHECK((*env)->GetArrayLength(env, ret_conv_8) == 32);
6486                 (*env)->GetByteArrayRegion(env, ret_conv_8, 0, 32, ret_conv_8_ref.data);
6487                 ret_constr.data[i] = ret_conv_8_ref;
6488         }
6489         if (get_jenv_res == JNI_EDETACHED) {
6490                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6491         }
6492         return ret_constr;
6493 }
6494 static void* LDKConfirm_JCalls_clone(const void* this_arg) {
6495         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
6496         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6497         return (void*) this_arg;
6498 }
6499 static inline LDKConfirm LDKConfirm_init (JNIEnv *env, jclass clz, jobject o) {
6500         jclass c = (*env)->GetObjectClass(env, o);
6501         CHECK(c != NULL);
6502         LDKConfirm_JCalls *calls = MALLOC(sizeof(LDKConfirm_JCalls), "LDKConfirm_JCalls");
6503         atomic_init(&calls->refcnt, 1);
6504         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6505         calls->o = (*env)->NewWeakGlobalRef(env, o);
6506         calls->transactions_confirmed_meth = (*env)->GetMethodID(env, c, "transactions_confirmed", "([B[JI)V");
6507         CHECK(calls->transactions_confirmed_meth != NULL);
6508         calls->transaction_unconfirmed_meth = (*env)->GetMethodID(env, c, "transaction_unconfirmed", "([B)V");
6509         CHECK(calls->transaction_unconfirmed_meth != NULL);
6510         calls->best_block_updated_meth = (*env)->GetMethodID(env, c, "best_block_updated", "([BI)V");
6511         CHECK(calls->best_block_updated_meth != NULL);
6512         calls->get_relevant_txids_meth = (*env)->GetMethodID(env, c, "get_relevant_txids", "()[[B");
6513         CHECK(calls->get_relevant_txids_meth != NULL);
6514
6515         LDKConfirm ret = {
6516                 .this_arg = (void*) calls,
6517                 .transactions_confirmed = transactions_confirmed_LDKConfirm_jcall,
6518                 .transaction_unconfirmed = transaction_unconfirmed_LDKConfirm_jcall,
6519                 .best_block_updated = best_block_updated_LDKConfirm_jcall,
6520                 .get_relevant_txids = get_relevant_txids_LDKConfirm_jcall,
6521                 .free = LDKConfirm_JCalls_free,
6522         };
6523         return ret;
6524 }
6525 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKConfirm_1new(JNIEnv *env, jclass clz, jobject o) {
6526         LDKConfirm *res_ptr = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
6527         *res_ptr = LDKConfirm_init(env, clz, o);
6528         return (uint64_t)res_ptr;
6529 }
6530 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) {
6531         LDKConfirm* this_arg_conv = (LDKConfirm*)(((uint64_t)this_arg) & ~1);
6532         unsigned char header_arr[80];
6533         CHECK((*env)->GetArrayLength(env, header) == 80);
6534         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
6535         unsigned char (*header_ref)[80] = &header_arr;
6536         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
6537         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
6538         if (txdata_constr.datalen > 0)
6539                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
6540         else
6541                 txdata_constr.data = NULL;
6542         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
6543         for (size_t y = 0; y < txdata_constr.datalen; y++) {
6544                 int64_t txdata_conv_24 = txdata_vals[y];
6545                 LDKC2Tuple_usizeTransactionZ txdata_conv_24_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_24) & ~1);
6546                 txdata_conv_24_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_24) & ~1));
6547                 txdata_constr.data[y] = txdata_conv_24_conv;
6548         }
6549         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
6550         (this_arg_conv->transactions_confirmed)(this_arg_conv->this_arg, header_ref, txdata_constr, height);
6551 }
6552
6553 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Confirm_1transaction_1unconfirmed(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray txid) {
6554         LDKConfirm* this_arg_conv = (LDKConfirm*)(((uint64_t)this_arg) & ~1);
6555         unsigned char txid_arr[32];
6556         CHECK((*env)->GetArrayLength(env, txid) == 32);
6557         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
6558         unsigned char (*txid_ref)[32] = &txid_arr;
6559         (this_arg_conv->transaction_unconfirmed)(this_arg_conv->this_arg, txid_ref);
6560 }
6561
6562 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) {
6563         LDKConfirm* this_arg_conv = (LDKConfirm*)(((uint64_t)this_arg) & ~1);
6564         unsigned char header_arr[80];
6565         CHECK((*env)->GetArrayLength(env, header) == 80);
6566         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
6567         unsigned char (*header_ref)[80] = &header_arr;
6568         (this_arg_conv->best_block_updated)(this_arg_conv->this_arg, header_ref, height);
6569 }
6570
6571 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_Confirm_1get_1relevant_1txids(JNIEnv *env, jclass clz, int64_t this_arg) {
6572         LDKConfirm* this_arg_conv = (LDKConfirm*)(((uint64_t)this_arg) & ~1);
6573         LDKCVec_TxidZ ret_var = (this_arg_conv->get_relevant_txids)(this_arg_conv->this_arg);
6574         jobjectArray ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
6575         ;
6576         for (size_t i = 0; i < ret_var.datalen; i++) {
6577                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 32);
6578                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 32, ret_var.data[i].data);
6579                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
6580         }
6581         FREE(ret_var.data);
6582         return ret_arr;
6583 }
6584
6585 typedef struct LDKFilter_JCalls {
6586         atomic_size_t refcnt;
6587         JavaVM *vm;
6588         jweak o;
6589         jmethodID register_tx_meth;
6590         jmethodID register_output_meth;
6591 } LDKFilter_JCalls;
6592 static void LDKFilter_JCalls_free(void* this_arg) {
6593         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
6594         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6595                 JNIEnv *env;
6596                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6597                 if (get_jenv_res == JNI_EDETACHED) {
6598                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6599                 } else {
6600                         DO_ASSERT(get_jenv_res == JNI_OK);
6601                 }
6602                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6603                 if (get_jenv_res == JNI_EDETACHED) {
6604                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6605                 }
6606                 FREE(j_calls);
6607         }
6608 }
6609 void register_tx_LDKFilter_jcall(const void* this_arg, const uint8_t (* txid)[32], LDKu8slice script_pubkey) {
6610         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
6611         JNIEnv *env;
6612         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6613         if (get_jenv_res == JNI_EDETACHED) {
6614                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6615         } else {
6616                 DO_ASSERT(get_jenv_res == JNI_OK);
6617         }
6618         int8_tArray txid_arr = (*env)->NewByteArray(env, 32);
6619         (*env)->SetByteArrayRegion(env, txid_arr, 0, 32, *txid);
6620         LDKu8slice script_pubkey_var = script_pubkey;
6621         int8_tArray script_pubkey_arr = (*env)->NewByteArray(env, script_pubkey_var.datalen);
6622         (*env)->SetByteArrayRegion(env, script_pubkey_arr, 0, script_pubkey_var.datalen, script_pubkey_var.data);
6623         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6624         CHECK(obj != NULL);
6625         (*env)->CallVoidMethod(env, obj, j_calls->register_tx_meth, txid_arr, script_pubkey_arr);
6626         if (get_jenv_res == JNI_EDETACHED) {
6627                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6628         }
6629 }
6630 LDKCOption_C2Tuple_usizeTransactionZZ register_output_LDKFilter_jcall(const void* this_arg, LDKWatchedOutput output) {
6631         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
6632         JNIEnv *env;
6633         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6634         if (get_jenv_res == JNI_EDETACHED) {
6635                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6636         } else {
6637                 DO_ASSERT(get_jenv_res == JNI_OK);
6638         }
6639         LDKWatchedOutput output_var = output;
6640         CHECK((((uint64_t)output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6641         CHECK((((uint64_t)&output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6642         uint64_t output_ref = (uint64_t)output_var.inner;
6643         if (output_var.is_owned) {
6644                 output_ref |= 1;
6645         }
6646         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6647         CHECK(obj != NULL);
6648         LDKCOption_C2Tuple_usizeTransactionZZ* ret = (LDKCOption_C2Tuple_usizeTransactionZZ*)(*env)->CallLongMethod(env, obj, j_calls->register_output_meth, output_ref);
6649         LDKCOption_C2Tuple_usizeTransactionZZ ret_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(((uint64_t)ret) & ~1);
6650         ret_conv = COption_C2Tuple_usizeTransactionZZ_clone((LDKCOption_C2Tuple_usizeTransactionZZ*)(((uint64_t)ret) & ~1));
6651         if (get_jenv_res == JNI_EDETACHED) {
6652                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6653         }
6654         return ret_conv;
6655 }
6656 static void* LDKFilter_JCalls_clone(const void* this_arg) {
6657         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
6658         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6659         return (void*) this_arg;
6660 }
6661 static inline LDKFilter LDKFilter_init (JNIEnv *env, jclass clz, jobject o) {
6662         jclass c = (*env)->GetObjectClass(env, o);
6663         CHECK(c != NULL);
6664         LDKFilter_JCalls *calls = MALLOC(sizeof(LDKFilter_JCalls), "LDKFilter_JCalls");
6665         atomic_init(&calls->refcnt, 1);
6666         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6667         calls->o = (*env)->NewWeakGlobalRef(env, o);
6668         calls->register_tx_meth = (*env)->GetMethodID(env, c, "register_tx", "([B[B)V");
6669         CHECK(calls->register_tx_meth != NULL);
6670         calls->register_output_meth = (*env)->GetMethodID(env, c, "register_output", "(J)J");
6671         CHECK(calls->register_output_meth != NULL);
6672
6673         LDKFilter ret = {
6674                 .this_arg = (void*) calls,
6675                 .register_tx = register_tx_LDKFilter_jcall,
6676                 .register_output = register_output_LDKFilter_jcall,
6677                 .free = LDKFilter_JCalls_free,
6678         };
6679         return ret;
6680 }
6681 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKFilter_1new(JNIEnv *env, jclass clz, jobject o) {
6682         LDKFilter *res_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter");
6683         *res_ptr = LDKFilter_init(env, clz, o);
6684         return (uint64_t)res_ptr;
6685 }
6686 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) {
6687         LDKFilter* this_arg_conv = (LDKFilter*)(((uint64_t)this_arg) & ~1);
6688         unsigned char txid_arr[32];
6689         CHECK((*env)->GetArrayLength(env, txid) == 32);
6690         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
6691         unsigned char (*txid_ref)[32] = &txid_arr;
6692         LDKu8slice script_pubkey_ref;
6693         script_pubkey_ref.datalen = (*env)->GetArrayLength(env, script_pubkey);
6694         script_pubkey_ref.data = (*env)->GetByteArrayElements (env, script_pubkey, NULL);
6695         (this_arg_conv->register_tx)(this_arg_conv->this_arg, txid_ref, script_pubkey_ref);
6696         (*env)->ReleaseByteArrayElements(env, script_pubkey, (int8_t*)script_pubkey_ref.data, 0);
6697 }
6698
6699 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Filter_1register_1output(JNIEnv *env, jclass clz, int64_t this_arg, int64_t output) {
6700         LDKFilter* this_arg_conv = (LDKFilter*)(((uint64_t)this_arg) & ~1);
6701         LDKWatchedOutput output_conv;
6702         output_conv.inner = (void*)(output & (~1));
6703         output_conv.is_owned = (output & 1) || (output == 0);
6704         output_conv = WatchedOutput_clone(&output_conv);
6705         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
6706         *ret_copy = (this_arg_conv->register_output)(this_arg_conv->this_arg, output_conv);
6707         uint64_t ret_ref = (uint64_t)ret_copy;
6708         return ret_ref;
6709 }
6710
6711 typedef struct LDKPersist_JCalls {
6712         atomic_size_t refcnt;
6713         JavaVM *vm;
6714         jweak o;
6715         jmethodID persist_new_channel_meth;
6716         jmethodID update_persisted_channel_meth;
6717 } LDKPersist_JCalls;
6718 static void LDKPersist_JCalls_free(void* this_arg) {
6719         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
6720         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6721                 JNIEnv *env;
6722                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6723                 if (get_jenv_res == JNI_EDETACHED) {
6724                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6725                 } else {
6726                         DO_ASSERT(get_jenv_res == JNI_OK);
6727                 }
6728                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6729                 if (get_jenv_res == JNI_EDETACHED) {
6730                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6731                 }
6732                 FREE(j_calls);
6733         }
6734 }
6735 LDKCResult_NoneChannelMonitorUpdateErrZ persist_new_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint id, const LDKChannelMonitor * data) {
6736         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
6737         JNIEnv *env;
6738         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6739         if (get_jenv_res == JNI_EDETACHED) {
6740                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6741         } else {
6742                 DO_ASSERT(get_jenv_res == JNI_OK);
6743         }
6744         LDKOutPoint id_var = id;
6745         CHECK((((uint64_t)id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6746         CHECK((((uint64_t)&id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6747         uint64_t id_ref = (uint64_t)id_var.inner;
6748         if (id_var.is_owned) {
6749                 id_ref |= 1;
6750         }
6751         LDKChannelMonitor data_var = *data;
6752         data_var = ChannelMonitor_clone(data);
6753         CHECK((((uint64_t)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6754         CHECK((((uint64_t)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6755         uint64_t data_ref = (uint64_t)data_var.inner;
6756         if (data_var.is_owned) {
6757                 data_ref |= 1;
6758         }
6759         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6760         CHECK(obj != NULL);
6761         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(*env)->CallLongMethod(env, obj, j_calls->persist_new_channel_meth, id_ref, data_ref);
6762         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
6763         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
6764         if (get_jenv_res == JNI_EDETACHED) {
6765                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6766         }
6767         return ret_conv;
6768 }
6769 LDKCResult_NoneChannelMonitorUpdateErrZ update_persisted_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint id, const LDKChannelMonitorUpdate * update, const LDKChannelMonitor * data) {
6770         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
6771         JNIEnv *env;
6772         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6773         if (get_jenv_res == JNI_EDETACHED) {
6774                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6775         } else {
6776                 DO_ASSERT(get_jenv_res == JNI_OK);
6777         }
6778         LDKOutPoint id_var = id;
6779         CHECK((((uint64_t)id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6780         CHECK((((uint64_t)&id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6781         uint64_t id_ref = (uint64_t)id_var.inner;
6782         if (id_var.is_owned) {
6783                 id_ref |= 1;
6784         }
6785         LDKChannelMonitorUpdate update_var = *update;
6786         update_var = ChannelMonitorUpdate_clone(update);
6787         CHECK((((uint64_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6788         CHECK((((uint64_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6789         uint64_t update_ref = (uint64_t)update_var.inner;
6790         if (update_var.is_owned) {
6791                 update_ref |= 1;
6792         }
6793         LDKChannelMonitor data_var = *data;
6794         data_var = ChannelMonitor_clone(data);
6795         CHECK((((uint64_t)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6796         CHECK((((uint64_t)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6797         uint64_t data_ref = (uint64_t)data_var.inner;
6798         if (data_var.is_owned) {
6799                 data_ref |= 1;
6800         }
6801         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6802         CHECK(obj != NULL);
6803         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(*env)->CallLongMethod(env, obj, j_calls->update_persisted_channel_meth, id_ref, update_ref, data_ref);
6804         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
6805         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
6806         if (get_jenv_res == JNI_EDETACHED) {
6807                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6808         }
6809         return ret_conv;
6810 }
6811 static void* LDKPersist_JCalls_clone(const void* this_arg) {
6812         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
6813         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6814         return (void*) this_arg;
6815 }
6816 static inline LDKPersist LDKPersist_init (JNIEnv *env, jclass clz, jobject o) {
6817         jclass c = (*env)->GetObjectClass(env, o);
6818         CHECK(c != NULL);
6819         LDKPersist_JCalls *calls = MALLOC(sizeof(LDKPersist_JCalls), "LDKPersist_JCalls");
6820         atomic_init(&calls->refcnt, 1);
6821         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6822         calls->o = (*env)->NewWeakGlobalRef(env, o);
6823         calls->persist_new_channel_meth = (*env)->GetMethodID(env, c, "persist_new_channel", "(JJ)J");
6824         CHECK(calls->persist_new_channel_meth != NULL);
6825         calls->update_persisted_channel_meth = (*env)->GetMethodID(env, c, "update_persisted_channel", "(JJJ)J");
6826         CHECK(calls->update_persisted_channel_meth != NULL);
6827
6828         LDKPersist ret = {
6829                 .this_arg = (void*) calls,
6830                 .persist_new_channel = persist_new_channel_LDKPersist_jcall,
6831                 .update_persisted_channel = update_persisted_channel_LDKPersist_jcall,
6832                 .free = LDKPersist_JCalls_free,
6833         };
6834         return ret;
6835 }
6836 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKPersist_1new(JNIEnv *env, jclass clz, jobject o) {
6837         LDKPersist *res_ptr = MALLOC(sizeof(LDKPersist), "LDKPersist");
6838         *res_ptr = LDKPersist_init(env, clz, o);
6839         return (uint64_t)res_ptr;
6840 }
6841 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) {
6842         LDKPersist* this_arg_conv = (LDKPersist*)(((uint64_t)this_arg) & ~1);
6843         LDKOutPoint id_conv;
6844         id_conv.inner = (void*)(id & (~1));
6845         id_conv.is_owned = (id & 1) || (id == 0);
6846         id_conv = OutPoint_clone(&id_conv);
6847         LDKChannelMonitor data_conv;
6848         data_conv.inner = (void*)(data & (~1));
6849         data_conv.is_owned = false;
6850         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
6851         *ret_conv = (this_arg_conv->persist_new_channel)(this_arg_conv->this_arg, id_conv, &data_conv);
6852         return (uint64_t)ret_conv;
6853 }
6854
6855 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) {
6856         LDKPersist* this_arg_conv = (LDKPersist*)(((uint64_t)this_arg) & ~1);
6857         LDKOutPoint id_conv;
6858         id_conv.inner = (void*)(id & (~1));
6859         id_conv.is_owned = (id & 1) || (id == 0);
6860         id_conv = OutPoint_clone(&id_conv);
6861         LDKChannelMonitorUpdate update_conv;
6862         update_conv.inner = (void*)(update & (~1));
6863         update_conv.is_owned = false;
6864         LDKChannelMonitor data_conv;
6865         data_conv.inner = (void*)(data & (~1));
6866         data_conv.is_owned = false;
6867         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
6868         *ret_conv = (this_arg_conv->update_persisted_channel)(this_arg_conv->this_arg, id_conv, &update_conv, &data_conv);
6869         return (uint64_t)ret_conv;
6870 }
6871
6872 typedef struct LDKChannelMessageHandler_JCalls {
6873         atomic_size_t refcnt;
6874         JavaVM *vm;
6875         jweak o;
6876         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
6877         jmethodID handle_open_channel_meth;
6878         jmethodID handle_accept_channel_meth;
6879         jmethodID handle_funding_created_meth;
6880         jmethodID handle_funding_signed_meth;
6881         jmethodID handle_funding_locked_meth;
6882         jmethodID handle_shutdown_meth;
6883         jmethodID handle_closing_signed_meth;
6884         jmethodID handle_update_add_htlc_meth;
6885         jmethodID handle_update_fulfill_htlc_meth;
6886         jmethodID handle_update_fail_htlc_meth;
6887         jmethodID handle_update_fail_malformed_htlc_meth;
6888         jmethodID handle_commitment_signed_meth;
6889         jmethodID handle_revoke_and_ack_meth;
6890         jmethodID handle_update_fee_meth;
6891         jmethodID handle_announcement_signatures_meth;
6892         jmethodID peer_disconnected_meth;
6893         jmethodID peer_connected_meth;
6894         jmethodID handle_channel_reestablish_meth;
6895         jmethodID handle_channel_update_meth;
6896         jmethodID handle_error_meth;
6897 } LDKChannelMessageHandler_JCalls;
6898 static void LDKChannelMessageHandler_JCalls_free(void* this_arg) {
6899         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
6900         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6901                 JNIEnv *env;
6902                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6903                 if (get_jenv_res == JNI_EDETACHED) {
6904                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6905                 } else {
6906                         DO_ASSERT(get_jenv_res == JNI_OK);
6907                 }
6908                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6909                 if (get_jenv_res == JNI_EDETACHED) {
6910                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6911                 }
6912                 FREE(j_calls);
6913         }
6914 }
6915 void handle_open_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKOpenChannel * msg) {
6916         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
6917         JNIEnv *env;
6918         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6919         if (get_jenv_res == JNI_EDETACHED) {
6920                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6921         } else {
6922                 DO_ASSERT(get_jenv_res == JNI_OK);
6923         }
6924         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
6925         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
6926         LDKInitFeatures their_features_var = their_features;
6927         CHECK((((uint64_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6928         CHECK((((uint64_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6929         uint64_t their_features_ref = (uint64_t)their_features_var.inner;
6930         if (their_features_var.is_owned) {
6931                 their_features_ref |= 1;
6932         }
6933         LDKOpenChannel msg_var = *msg;
6934         msg_var = OpenChannel_clone(msg);
6935         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6936         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6937         uint64_t msg_ref = (uint64_t)msg_var.inner;
6938         if (msg_var.is_owned) {
6939                 msg_ref |= 1;
6940         }
6941         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6942         CHECK(obj != NULL);
6943         (*env)->CallVoidMethod(env, obj, j_calls->handle_open_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
6944         if (get_jenv_res == JNI_EDETACHED) {
6945                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6946         }
6947 }
6948 void handle_accept_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKAcceptChannel * msg) {
6949         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
6950         JNIEnv *env;
6951         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6952         if (get_jenv_res == JNI_EDETACHED) {
6953                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6954         } else {
6955                 DO_ASSERT(get_jenv_res == JNI_OK);
6956         }
6957         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
6958         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
6959         LDKInitFeatures their_features_var = their_features;
6960         CHECK((((uint64_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6961         CHECK((((uint64_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6962         uint64_t their_features_ref = (uint64_t)their_features_var.inner;
6963         if (their_features_var.is_owned) {
6964                 their_features_ref |= 1;
6965         }
6966         LDKAcceptChannel msg_var = *msg;
6967         msg_var = AcceptChannel_clone(msg);
6968         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6969         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6970         uint64_t msg_ref = (uint64_t)msg_var.inner;
6971         if (msg_var.is_owned) {
6972                 msg_ref |= 1;
6973         }
6974         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6975         CHECK(obj != NULL);
6976         (*env)->CallVoidMethod(env, obj, j_calls->handle_accept_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
6977         if (get_jenv_res == JNI_EDETACHED) {
6978                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6979         }
6980 }
6981 void handle_funding_created_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingCreated * msg) {
6982         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
6983         JNIEnv *env;
6984         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6985         if (get_jenv_res == JNI_EDETACHED) {
6986                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6987         } else {
6988                 DO_ASSERT(get_jenv_res == JNI_OK);
6989         }
6990         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
6991         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
6992         LDKFundingCreated msg_var = *msg;
6993         msg_var = FundingCreated_clone(msg);
6994         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6995         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6996         uint64_t msg_ref = (uint64_t)msg_var.inner;
6997         if (msg_var.is_owned) {
6998                 msg_ref |= 1;
6999         }
7000         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7001         CHECK(obj != NULL);
7002         (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_created_meth, their_node_id_arr, msg_ref);
7003         if (get_jenv_res == JNI_EDETACHED) {
7004                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7005         }
7006 }
7007 void handle_funding_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingSigned * msg) {
7008         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7009         JNIEnv *env;
7010         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7011         if (get_jenv_res == JNI_EDETACHED) {
7012                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7013         } else {
7014                 DO_ASSERT(get_jenv_res == JNI_OK);
7015         }
7016         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7017         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7018         LDKFundingSigned msg_var = *msg;
7019         msg_var = FundingSigned_clone(msg);
7020         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7021         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7022         uint64_t msg_ref = (uint64_t)msg_var.inner;
7023         if (msg_var.is_owned) {
7024                 msg_ref |= 1;
7025         }
7026         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7027         CHECK(obj != NULL);
7028         (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_signed_meth, their_node_id_arr, msg_ref);
7029         if (get_jenv_res == JNI_EDETACHED) {
7030                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7031         }
7032 }
7033 void handle_funding_locked_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingLocked * msg) {
7034         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7035         JNIEnv *env;
7036         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7037         if (get_jenv_res == JNI_EDETACHED) {
7038                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7039         } else {
7040                 DO_ASSERT(get_jenv_res == JNI_OK);
7041         }
7042         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7043         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7044         LDKFundingLocked msg_var = *msg;
7045         msg_var = FundingLocked_clone(msg);
7046         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7047         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7048         uint64_t msg_ref = (uint64_t)msg_var.inner;
7049         if (msg_var.is_owned) {
7050                 msg_ref |= 1;
7051         }
7052         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7053         CHECK(obj != NULL);
7054         (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_locked_meth, their_node_id_arr, msg_ref);
7055         if (get_jenv_res == JNI_EDETACHED) {
7056                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7057         }
7058 }
7059 void handle_shutdown_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInitFeatures * their_features, const LDKShutdown * msg) {
7060         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7061         JNIEnv *env;
7062         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7063         if (get_jenv_res == JNI_EDETACHED) {
7064                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7065         } else {
7066                 DO_ASSERT(get_jenv_res == JNI_OK);
7067         }
7068         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7069         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7070         LDKInitFeatures their_features_var = *their_features;
7071         their_features_var = InitFeatures_clone(their_features);
7072         CHECK((((uint64_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7073         CHECK((((uint64_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7074         uint64_t their_features_ref = (uint64_t)their_features_var.inner;
7075         if (their_features_var.is_owned) {
7076                 their_features_ref |= 1;
7077         }
7078         LDKShutdown msg_var = *msg;
7079         msg_var = Shutdown_clone(msg);
7080         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7081         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7082         uint64_t msg_ref = (uint64_t)msg_var.inner;
7083         if (msg_var.is_owned) {
7084                 msg_ref |= 1;
7085         }
7086         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7087         CHECK(obj != NULL);
7088         (*env)->CallVoidMethod(env, obj, j_calls->handle_shutdown_meth, their_node_id_arr, their_features_ref, msg_ref);
7089         if (get_jenv_res == JNI_EDETACHED) {
7090                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7091         }
7092 }
7093 void handle_closing_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKClosingSigned * msg) {
7094         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7095         JNIEnv *env;
7096         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7097         if (get_jenv_res == JNI_EDETACHED) {
7098                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7099         } else {
7100                 DO_ASSERT(get_jenv_res == JNI_OK);
7101         }
7102         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7103         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7104         LDKClosingSigned msg_var = *msg;
7105         msg_var = ClosingSigned_clone(msg);
7106         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7107         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7108         uint64_t msg_ref = (uint64_t)msg_var.inner;
7109         if (msg_var.is_owned) {
7110                 msg_ref |= 1;
7111         }
7112         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7113         CHECK(obj != NULL);
7114         (*env)->CallVoidMethod(env, obj, j_calls->handle_closing_signed_meth, their_node_id_arr, msg_ref);
7115         if (get_jenv_res == JNI_EDETACHED) {
7116                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7117         }
7118 }
7119 void handle_update_add_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateAddHTLC * msg) {
7120         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7121         JNIEnv *env;
7122         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7123         if (get_jenv_res == JNI_EDETACHED) {
7124                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7125         } else {
7126                 DO_ASSERT(get_jenv_res == JNI_OK);
7127         }
7128         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7129         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7130         LDKUpdateAddHTLC msg_var = *msg;
7131         msg_var = UpdateAddHTLC_clone(msg);
7132         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7133         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7134         uint64_t msg_ref = (uint64_t)msg_var.inner;
7135         if (msg_var.is_owned) {
7136                 msg_ref |= 1;
7137         }
7138         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7139         CHECK(obj != NULL);
7140         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_add_htlc_meth, their_node_id_arr, msg_ref);
7141         if (get_jenv_res == JNI_EDETACHED) {
7142                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7143         }
7144 }
7145 void handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFulfillHTLC * msg) {
7146         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7147         JNIEnv *env;
7148         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7149         if (get_jenv_res == JNI_EDETACHED) {
7150                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7151         } else {
7152                 DO_ASSERT(get_jenv_res == JNI_OK);
7153         }
7154         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7155         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7156         LDKUpdateFulfillHTLC msg_var = *msg;
7157         msg_var = UpdateFulfillHTLC_clone(msg);
7158         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7159         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7160         uint64_t msg_ref = (uint64_t)msg_var.inner;
7161         if (msg_var.is_owned) {
7162                 msg_ref |= 1;
7163         }
7164         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7165         CHECK(obj != NULL);
7166         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fulfill_htlc_meth, their_node_id_arr, msg_ref);
7167         if (get_jenv_res == JNI_EDETACHED) {
7168                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7169         }
7170 }
7171 void handle_update_fail_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailHTLC * msg) {
7172         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7173         JNIEnv *env;
7174         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7175         if (get_jenv_res == JNI_EDETACHED) {
7176                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7177         } else {
7178                 DO_ASSERT(get_jenv_res == JNI_OK);
7179         }
7180         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7181         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7182         LDKUpdateFailHTLC msg_var = *msg;
7183         msg_var = UpdateFailHTLC_clone(msg);
7184         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7185         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7186         uint64_t msg_ref = (uint64_t)msg_var.inner;
7187         if (msg_var.is_owned) {
7188                 msg_ref |= 1;
7189         }
7190         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7191         CHECK(obj != NULL);
7192         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fail_htlc_meth, their_node_id_arr, msg_ref);
7193         if (get_jenv_res == JNI_EDETACHED) {
7194                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7195         }
7196 }
7197 void handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailMalformedHTLC * msg) {
7198         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7199         JNIEnv *env;
7200         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7201         if (get_jenv_res == JNI_EDETACHED) {
7202                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7203         } else {
7204                 DO_ASSERT(get_jenv_res == JNI_OK);
7205         }
7206         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7207         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7208         LDKUpdateFailMalformedHTLC msg_var = *msg;
7209         msg_var = UpdateFailMalformedHTLC_clone(msg);
7210         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7211         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7212         uint64_t msg_ref = (uint64_t)msg_var.inner;
7213         if (msg_var.is_owned) {
7214                 msg_ref |= 1;
7215         }
7216         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7217         CHECK(obj != NULL);
7218         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fail_malformed_htlc_meth, their_node_id_arr, msg_ref);
7219         if (get_jenv_res == JNI_EDETACHED) {
7220                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7221         }
7222 }
7223 void handle_commitment_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKCommitmentSigned * msg) {
7224         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7225         JNIEnv *env;
7226         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7227         if (get_jenv_res == JNI_EDETACHED) {
7228                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7229         } else {
7230                 DO_ASSERT(get_jenv_res == JNI_OK);
7231         }
7232         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7233         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7234         LDKCommitmentSigned msg_var = *msg;
7235         msg_var = CommitmentSigned_clone(msg);
7236         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7237         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7238         uint64_t msg_ref = (uint64_t)msg_var.inner;
7239         if (msg_var.is_owned) {
7240                 msg_ref |= 1;
7241         }
7242         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7243         CHECK(obj != NULL);
7244         (*env)->CallVoidMethod(env, obj, j_calls->handle_commitment_signed_meth, their_node_id_arr, msg_ref);
7245         if (get_jenv_res == JNI_EDETACHED) {
7246                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7247         }
7248 }
7249 void handle_revoke_and_ack_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKRevokeAndACK * msg) {
7250         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7251         JNIEnv *env;
7252         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7253         if (get_jenv_res == JNI_EDETACHED) {
7254                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7255         } else {
7256                 DO_ASSERT(get_jenv_res == JNI_OK);
7257         }
7258         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7259         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7260         LDKRevokeAndACK msg_var = *msg;
7261         msg_var = RevokeAndACK_clone(msg);
7262         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7263         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7264         uint64_t msg_ref = (uint64_t)msg_var.inner;
7265         if (msg_var.is_owned) {
7266                 msg_ref |= 1;
7267         }
7268         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7269         CHECK(obj != NULL);
7270         (*env)->CallVoidMethod(env, obj, j_calls->handle_revoke_and_ack_meth, their_node_id_arr, msg_ref);
7271         if (get_jenv_res == JNI_EDETACHED) {
7272                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7273         }
7274 }
7275 void handle_update_fee_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFee * msg) {
7276         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7277         JNIEnv *env;
7278         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7279         if (get_jenv_res == JNI_EDETACHED) {
7280                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7281         } else {
7282                 DO_ASSERT(get_jenv_res == JNI_OK);
7283         }
7284         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7285         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7286         LDKUpdateFee msg_var = *msg;
7287         msg_var = UpdateFee_clone(msg);
7288         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7289         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7290         uint64_t msg_ref = (uint64_t)msg_var.inner;
7291         if (msg_var.is_owned) {
7292                 msg_ref |= 1;
7293         }
7294         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7295         CHECK(obj != NULL);
7296         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fee_meth, their_node_id_arr, msg_ref);
7297         if (get_jenv_res == JNI_EDETACHED) {
7298                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7299         }
7300 }
7301 void handle_announcement_signatures_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKAnnouncementSignatures * msg) {
7302         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7303         JNIEnv *env;
7304         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7305         if (get_jenv_res == JNI_EDETACHED) {
7306                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7307         } else {
7308                 DO_ASSERT(get_jenv_res == JNI_OK);
7309         }
7310         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7311         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7312         LDKAnnouncementSignatures msg_var = *msg;
7313         msg_var = AnnouncementSignatures_clone(msg);
7314         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7315         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7316         uint64_t msg_ref = (uint64_t)msg_var.inner;
7317         if (msg_var.is_owned) {
7318                 msg_ref |= 1;
7319         }
7320         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7321         CHECK(obj != NULL);
7322         (*env)->CallVoidMethod(env, obj, j_calls->handle_announcement_signatures_meth, their_node_id_arr, msg_ref);
7323         if (get_jenv_res == JNI_EDETACHED) {
7324                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7325         }
7326 }
7327 void peer_disconnected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, bool no_connection_possible) {
7328         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7329         JNIEnv *env;
7330         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7331         if (get_jenv_res == JNI_EDETACHED) {
7332                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7333         } else {
7334                 DO_ASSERT(get_jenv_res == JNI_OK);
7335         }
7336         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7337         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7338         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7339         CHECK(obj != NULL);
7340         (*env)->CallVoidMethod(env, obj, j_calls->peer_disconnected_meth, their_node_id_arr, no_connection_possible);
7341         if (get_jenv_res == JNI_EDETACHED) {
7342                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7343         }
7344 }
7345 void peer_connected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * msg) {
7346         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7347         JNIEnv *env;
7348         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7349         if (get_jenv_res == JNI_EDETACHED) {
7350                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7351         } else {
7352                 DO_ASSERT(get_jenv_res == JNI_OK);
7353         }
7354         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7355         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7356         LDKInit msg_var = *msg;
7357         msg_var = Init_clone(msg);
7358         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7359         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7360         uint64_t msg_ref = (uint64_t)msg_var.inner;
7361         if (msg_var.is_owned) {
7362                 msg_ref |= 1;
7363         }
7364         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7365         CHECK(obj != NULL);
7366         (*env)->CallVoidMethod(env, obj, j_calls->peer_connected_meth, their_node_id_arr, msg_ref);
7367         if (get_jenv_res == JNI_EDETACHED) {
7368                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7369         }
7370 }
7371 void handle_channel_reestablish_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelReestablish * msg) {
7372         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7373         JNIEnv *env;
7374         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7375         if (get_jenv_res == JNI_EDETACHED) {
7376                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7377         } else {
7378                 DO_ASSERT(get_jenv_res == JNI_OK);
7379         }
7380         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7381         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7382         LDKChannelReestablish msg_var = *msg;
7383         msg_var = ChannelReestablish_clone(msg);
7384         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7385         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7386         uint64_t msg_ref = (uint64_t)msg_var.inner;
7387         if (msg_var.is_owned) {
7388                 msg_ref |= 1;
7389         }
7390         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7391         CHECK(obj != NULL);
7392         (*env)->CallVoidMethod(env, obj, j_calls->handle_channel_reestablish_meth, their_node_id_arr, msg_ref);
7393         if (get_jenv_res == JNI_EDETACHED) {
7394                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7395         }
7396 }
7397 void handle_channel_update_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelUpdate * msg) {
7398         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7399         JNIEnv *env;
7400         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7401         if (get_jenv_res == JNI_EDETACHED) {
7402                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7403         } else {
7404                 DO_ASSERT(get_jenv_res == JNI_OK);
7405         }
7406         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7407         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7408         LDKChannelUpdate msg_var = *msg;
7409         msg_var = ChannelUpdate_clone(msg);
7410         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7411         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7412         uint64_t msg_ref = (uint64_t)msg_var.inner;
7413         if (msg_var.is_owned) {
7414                 msg_ref |= 1;
7415         }
7416         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7417         CHECK(obj != NULL);
7418         (*env)->CallVoidMethod(env, obj, j_calls->handle_channel_update_meth, their_node_id_arr, msg_ref);
7419         if (get_jenv_res == JNI_EDETACHED) {
7420                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7421         }
7422 }
7423 void handle_error_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKErrorMessage * msg) {
7424         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7425         JNIEnv *env;
7426         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7427         if (get_jenv_res == JNI_EDETACHED) {
7428                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7429         } else {
7430                 DO_ASSERT(get_jenv_res == JNI_OK);
7431         }
7432         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7433         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7434         LDKErrorMessage msg_var = *msg;
7435         msg_var = ErrorMessage_clone(msg);
7436         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7437         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7438         uint64_t msg_ref = (uint64_t)msg_var.inner;
7439         if (msg_var.is_owned) {
7440                 msg_ref |= 1;
7441         }
7442         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7443         CHECK(obj != NULL);
7444         (*env)->CallVoidMethod(env, obj, j_calls->handle_error_meth, their_node_id_arr, msg_ref);
7445         if (get_jenv_res == JNI_EDETACHED) {
7446                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7447         }
7448 }
7449 static void* LDKChannelMessageHandler_JCalls_clone(const void* this_arg) {
7450         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7451         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7452         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
7453         return (void*) this_arg;
7454 }
7455 static inline LDKChannelMessageHandler LDKChannelMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
7456         jclass c = (*env)->GetObjectClass(env, o);
7457         CHECK(c != NULL);
7458         LDKChannelMessageHandler_JCalls *calls = MALLOC(sizeof(LDKChannelMessageHandler_JCalls), "LDKChannelMessageHandler_JCalls");
7459         atomic_init(&calls->refcnt, 1);
7460         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
7461         calls->o = (*env)->NewWeakGlobalRef(env, o);
7462         calls->handle_open_channel_meth = (*env)->GetMethodID(env, c, "handle_open_channel", "([BJJ)V");
7463         CHECK(calls->handle_open_channel_meth != NULL);
7464         calls->handle_accept_channel_meth = (*env)->GetMethodID(env, c, "handle_accept_channel", "([BJJ)V");
7465         CHECK(calls->handle_accept_channel_meth != NULL);
7466         calls->handle_funding_created_meth = (*env)->GetMethodID(env, c, "handle_funding_created", "([BJ)V");
7467         CHECK(calls->handle_funding_created_meth != NULL);
7468         calls->handle_funding_signed_meth = (*env)->GetMethodID(env, c, "handle_funding_signed", "([BJ)V");
7469         CHECK(calls->handle_funding_signed_meth != NULL);
7470         calls->handle_funding_locked_meth = (*env)->GetMethodID(env, c, "handle_funding_locked", "([BJ)V");
7471         CHECK(calls->handle_funding_locked_meth != NULL);
7472         calls->handle_shutdown_meth = (*env)->GetMethodID(env, c, "handle_shutdown", "([BJJ)V");
7473         CHECK(calls->handle_shutdown_meth != NULL);
7474         calls->handle_closing_signed_meth = (*env)->GetMethodID(env, c, "handle_closing_signed", "([BJ)V");
7475         CHECK(calls->handle_closing_signed_meth != NULL);
7476         calls->handle_update_add_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_add_htlc", "([BJ)V");
7477         CHECK(calls->handle_update_add_htlc_meth != NULL);
7478         calls->handle_update_fulfill_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fulfill_htlc", "([BJ)V");
7479         CHECK(calls->handle_update_fulfill_htlc_meth != NULL);
7480         calls->handle_update_fail_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fail_htlc", "([BJ)V");
7481         CHECK(calls->handle_update_fail_htlc_meth != NULL);
7482         calls->handle_update_fail_malformed_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fail_malformed_htlc", "([BJ)V");
7483         CHECK(calls->handle_update_fail_malformed_htlc_meth != NULL);
7484         calls->handle_commitment_signed_meth = (*env)->GetMethodID(env, c, "handle_commitment_signed", "([BJ)V");
7485         CHECK(calls->handle_commitment_signed_meth != NULL);
7486         calls->handle_revoke_and_ack_meth = (*env)->GetMethodID(env, c, "handle_revoke_and_ack", "([BJ)V");
7487         CHECK(calls->handle_revoke_and_ack_meth != NULL);
7488         calls->handle_update_fee_meth = (*env)->GetMethodID(env, c, "handle_update_fee", "([BJ)V");
7489         CHECK(calls->handle_update_fee_meth != NULL);
7490         calls->handle_announcement_signatures_meth = (*env)->GetMethodID(env, c, "handle_announcement_signatures", "([BJ)V");
7491         CHECK(calls->handle_announcement_signatures_meth != NULL);
7492         calls->peer_disconnected_meth = (*env)->GetMethodID(env, c, "peer_disconnected", "([BZ)V");
7493         CHECK(calls->peer_disconnected_meth != NULL);
7494         calls->peer_connected_meth = (*env)->GetMethodID(env, c, "peer_connected", "([BJ)V");
7495         CHECK(calls->peer_connected_meth != NULL);
7496         calls->handle_channel_reestablish_meth = (*env)->GetMethodID(env, c, "handle_channel_reestablish", "([BJ)V");
7497         CHECK(calls->handle_channel_reestablish_meth != NULL);
7498         calls->handle_channel_update_meth = (*env)->GetMethodID(env, c, "handle_channel_update", "([BJ)V");
7499         CHECK(calls->handle_channel_update_meth != NULL);
7500         calls->handle_error_meth = (*env)->GetMethodID(env, c, "handle_error", "([BJ)V");
7501         CHECK(calls->handle_error_meth != NULL);
7502
7503         LDKChannelMessageHandler ret = {
7504                 .this_arg = (void*) calls,
7505                 .handle_open_channel = handle_open_channel_LDKChannelMessageHandler_jcall,
7506                 .handle_accept_channel = handle_accept_channel_LDKChannelMessageHandler_jcall,
7507                 .handle_funding_created = handle_funding_created_LDKChannelMessageHandler_jcall,
7508                 .handle_funding_signed = handle_funding_signed_LDKChannelMessageHandler_jcall,
7509                 .handle_funding_locked = handle_funding_locked_LDKChannelMessageHandler_jcall,
7510                 .handle_shutdown = handle_shutdown_LDKChannelMessageHandler_jcall,
7511                 .handle_closing_signed = handle_closing_signed_LDKChannelMessageHandler_jcall,
7512                 .handle_update_add_htlc = handle_update_add_htlc_LDKChannelMessageHandler_jcall,
7513                 .handle_update_fulfill_htlc = handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall,
7514                 .handle_update_fail_htlc = handle_update_fail_htlc_LDKChannelMessageHandler_jcall,
7515                 .handle_update_fail_malformed_htlc = handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall,
7516                 .handle_commitment_signed = handle_commitment_signed_LDKChannelMessageHandler_jcall,
7517                 .handle_revoke_and_ack = handle_revoke_and_ack_LDKChannelMessageHandler_jcall,
7518                 .handle_update_fee = handle_update_fee_LDKChannelMessageHandler_jcall,
7519                 .handle_announcement_signatures = handle_announcement_signatures_LDKChannelMessageHandler_jcall,
7520                 .peer_disconnected = peer_disconnected_LDKChannelMessageHandler_jcall,
7521                 .peer_connected = peer_connected_LDKChannelMessageHandler_jcall,
7522                 .handle_channel_reestablish = handle_channel_reestablish_LDKChannelMessageHandler_jcall,
7523                 .handle_channel_update = handle_channel_update_LDKChannelMessageHandler_jcall,
7524                 .handle_error = handle_error_LDKChannelMessageHandler_jcall,
7525                 .free = LDKChannelMessageHandler_JCalls_free,
7526                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(env, clz, MessageSendEventsProvider),
7527         };
7528         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
7529         return ret;
7530 }
7531 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
7532         LDKChannelMessageHandler *res_ptr = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
7533         *res_ptr = LDKChannelMessageHandler_init(env, clz, o, MessageSendEventsProvider);
7534         return (uint64_t)res_ptr;
7535 }
7536 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) {
7537         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7538         LDKPublicKey their_node_id_ref;
7539         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7540         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7541         LDKInitFeatures their_features_conv;
7542         their_features_conv.inner = (void*)(their_features & (~1));
7543         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
7544         their_features_conv = InitFeatures_clone(&their_features_conv);
7545         LDKOpenChannel msg_conv;
7546         msg_conv.inner = (void*)(msg & (~1));
7547         msg_conv.is_owned = false;
7548         (this_arg_conv->handle_open_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
7549 }
7550
7551 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) {
7552         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7553         LDKPublicKey their_node_id_ref;
7554         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7555         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7556         LDKInitFeatures their_features_conv;
7557         their_features_conv.inner = (void*)(their_features & (~1));
7558         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
7559         their_features_conv = InitFeatures_clone(&their_features_conv);
7560         LDKAcceptChannel msg_conv;
7561         msg_conv.inner = (void*)(msg & (~1));
7562         msg_conv.is_owned = false;
7563         (this_arg_conv->handle_accept_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
7564 }
7565
7566 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) {
7567         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7568         LDKPublicKey their_node_id_ref;
7569         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7570         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7571         LDKFundingCreated msg_conv;
7572         msg_conv.inner = (void*)(msg & (~1));
7573         msg_conv.is_owned = false;
7574         (this_arg_conv->handle_funding_created)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7575 }
7576
7577 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) {
7578         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7579         LDKPublicKey their_node_id_ref;
7580         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7581         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7582         LDKFundingSigned msg_conv;
7583         msg_conv.inner = (void*)(msg & (~1));
7584         msg_conv.is_owned = false;
7585         (this_arg_conv->handle_funding_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7586 }
7587
7588 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) {
7589         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7590         LDKPublicKey their_node_id_ref;
7591         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7592         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7593         LDKFundingLocked msg_conv;
7594         msg_conv.inner = (void*)(msg & (~1));
7595         msg_conv.is_owned = false;
7596         (this_arg_conv->handle_funding_locked)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7597 }
7598
7599 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) {
7600         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7601         LDKPublicKey their_node_id_ref;
7602         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7603         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7604         LDKInitFeatures their_features_conv;
7605         their_features_conv.inner = (void*)(their_features & (~1));
7606         their_features_conv.is_owned = false;
7607         LDKShutdown msg_conv;
7608         msg_conv.inner = (void*)(msg & (~1));
7609         msg_conv.is_owned = false;
7610         (this_arg_conv->handle_shutdown)(this_arg_conv->this_arg, their_node_id_ref, &their_features_conv, &msg_conv);
7611 }
7612
7613 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) {
7614         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7615         LDKPublicKey their_node_id_ref;
7616         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7617         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7618         LDKClosingSigned msg_conv;
7619         msg_conv.inner = (void*)(msg & (~1));
7620         msg_conv.is_owned = false;
7621         (this_arg_conv->handle_closing_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7622 }
7623
7624 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) {
7625         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7626         LDKPublicKey their_node_id_ref;
7627         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7628         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7629         LDKUpdateAddHTLC msg_conv;
7630         msg_conv.inner = (void*)(msg & (~1));
7631         msg_conv.is_owned = false;
7632         (this_arg_conv->handle_update_add_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7633 }
7634
7635 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) {
7636         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7637         LDKPublicKey their_node_id_ref;
7638         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7639         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7640         LDKUpdateFulfillHTLC msg_conv;
7641         msg_conv.inner = (void*)(msg & (~1));
7642         msg_conv.is_owned = false;
7643         (this_arg_conv->handle_update_fulfill_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7644 }
7645
7646 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) {
7647         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7648         LDKPublicKey their_node_id_ref;
7649         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7650         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7651         LDKUpdateFailHTLC msg_conv;
7652         msg_conv.inner = (void*)(msg & (~1));
7653         msg_conv.is_owned = false;
7654         (this_arg_conv->handle_update_fail_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7655 }
7656
7657 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) {
7658         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7659         LDKPublicKey their_node_id_ref;
7660         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7661         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7662         LDKUpdateFailMalformedHTLC msg_conv;
7663         msg_conv.inner = (void*)(msg & (~1));
7664         msg_conv.is_owned = false;
7665         (this_arg_conv->handle_update_fail_malformed_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7666 }
7667
7668 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) {
7669         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7670         LDKPublicKey their_node_id_ref;
7671         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7672         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7673         LDKCommitmentSigned msg_conv;
7674         msg_conv.inner = (void*)(msg & (~1));
7675         msg_conv.is_owned = false;
7676         (this_arg_conv->handle_commitment_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7677 }
7678
7679 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) {
7680         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7681         LDKPublicKey their_node_id_ref;
7682         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7683         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7684         LDKRevokeAndACK msg_conv;
7685         msg_conv.inner = (void*)(msg & (~1));
7686         msg_conv.is_owned = false;
7687         (this_arg_conv->handle_revoke_and_ack)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7688 }
7689
7690 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) {
7691         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7692         LDKPublicKey their_node_id_ref;
7693         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7694         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7695         LDKUpdateFee msg_conv;
7696         msg_conv.inner = (void*)(msg & (~1));
7697         msg_conv.is_owned = false;
7698         (this_arg_conv->handle_update_fee)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7699 }
7700
7701 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) {
7702         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7703         LDKPublicKey their_node_id_ref;
7704         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7705         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7706         LDKAnnouncementSignatures msg_conv;
7707         msg_conv.inner = (void*)(msg & (~1));
7708         msg_conv.is_owned = false;
7709         (this_arg_conv->handle_announcement_signatures)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7710 }
7711
7712 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) {
7713         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7714         LDKPublicKey their_node_id_ref;
7715         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7716         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7717         (this_arg_conv->peer_disconnected)(this_arg_conv->this_arg, their_node_id_ref, no_connection_possible);
7718 }
7719
7720 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) {
7721         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7722         LDKPublicKey their_node_id_ref;
7723         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7724         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7725         LDKInit msg_conv;
7726         msg_conv.inner = (void*)(msg & (~1));
7727         msg_conv.is_owned = false;
7728         (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7729 }
7730
7731 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) {
7732         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7733         LDKPublicKey their_node_id_ref;
7734         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7735         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7736         LDKChannelReestablish msg_conv;
7737         msg_conv.inner = (void*)(msg & (~1));
7738         msg_conv.is_owned = false;
7739         (this_arg_conv->handle_channel_reestablish)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7740 }
7741
7742 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) {
7743         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7744         LDKPublicKey their_node_id_ref;
7745         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7746         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7747         LDKChannelUpdate msg_conv;
7748         msg_conv.inner = (void*)(msg & (~1));
7749         msg_conv.is_owned = false;
7750         (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7751 }
7752
7753 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) {
7754         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7755         LDKPublicKey their_node_id_ref;
7756         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7757         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7758         LDKErrorMessage msg_conv;
7759         msg_conv.inner = (void*)(msg & (~1));
7760         msg_conv.is_owned = false;
7761         (this_arg_conv->handle_error)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7762 }
7763
7764 typedef struct LDKRoutingMessageHandler_JCalls {
7765         atomic_size_t refcnt;
7766         JavaVM *vm;
7767         jweak o;
7768         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
7769         jmethodID handle_node_announcement_meth;
7770         jmethodID handle_channel_announcement_meth;
7771         jmethodID handle_channel_update_meth;
7772         jmethodID handle_htlc_fail_channel_update_meth;
7773         jmethodID get_next_channel_announcements_meth;
7774         jmethodID get_next_node_announcements_meth;
7775         jmethodID sync_routing_table_meth;
7776         jmethodID handle_reply_channel_range_meth;
7777         jmethodID handle_reply_short_channel_ids_end_meth;
7778         jmethodID handle_query_channel_range_meth;
7779         jmethodID handle_query_short_channel_ids_meth;
7780 } LDKRoutingMessageHandler_JCalls;
7781 static void LDKRoutingMessageHandler_JCalls_free(void* this_arg) {
7782         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
7783         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7784                 JNIEnv *env;
7785                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7786                 if (get_jenv_res == JNI_EDETACHED) {
7787                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7788                 } else {
7789                         DO_ASSERT(get_jenv_res == JNI_OK);
7790                 }
7791                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
7792                 if (get_jenv_res == JNI_EDETACHED) {
7793                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7794                 }
7795                 FREE(j_calls);
7796         }
7797 }
7798 LDKCResult_boolLightningErrorZ handle_node_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKNodeAnnouncement * msg) {
7799         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
7800         JNIEnv *env;
7801         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7802         if (get_jenv_res == JNI_EDETACHED) {
7803                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7804         } else {
7805                 DO_ASSERT(get_jenv_res == JNI_OK);
7806         }
7807         LDKNodeAnnouncement msg_var = *msg;
7808         msg_var = NodeAnnouncement_clone(msg);
7809         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7810         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7811         uint64_t msg_ref = (uint64_t)msg_var.inner;
7812         if (msg_var.is_owned) {
7813                 msg_ref |= 1;
7814         }
7815         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7816         CHECK(obj != NULL);
7817         LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_node_announcement_meth, msg_ref);
7818         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1);
7819         ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1));
7820         if (get_jenv_res == JNI_EDETACHED) {
7821                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7822         }
7823         return ret_conv;
7824 }
7825 LDKCResult_boolLightningErrorZ handle_channel_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelAnnouncement * msg) {
7826         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
7827         JNIEnv *env;
7828         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7829         if (get_jenv_res == JNI_EDETACHED) {
7830                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7831         } else {
7832                 DO_ASSERT(get_jenv_res == JNI_OK);
7833         }
7834         LDKChannelAnnouncement msg_var = *msg;
7835         msg_var = ChannelAnnouncement_clone(msg);
7836         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7837         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7838         uint64_t msg_ref = (uint64_t)msg_var.inner;
7839         if (msg_var.is_owned) {
7840                 msg_ref |= 1;
7841         }
7842         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7843         CHECK(obj != NULL);
7844         LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_channel_announcement_meth, msg_ref);
7845         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1);
7846         ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1));
7847         if (get_jenv_res == JNI_EDETACHED) {
7848                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7849         }
7850         return ret_conv;
7851 }
7852 LDKCResult_boolLightningErrorZ handle_channel_update_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelUpdate * msg) {
7853         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
7854         JNIEnv *env;
7855         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7856         if (get_jenv_res == JNI_EDETACHED) {
7857                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7858         } else {
7859                 DO_ASSERT(get_jenv_res == JNI_OK);
7860         }
7861         LDKChannelUpdate msg_var = *msg;
7862         msg_var = ChannelUpdate_clone(msg);
7863         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7864         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7865         uint64_t msg_ref = (uint64_t)msg_var.inner;
7866         if (msg_var.is_owned) {
7867                 msg_ref |= 1;
7868         }
7869         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7870         CHECK(obj != NULL);
7871         LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_channel_update_meth, msg_ref);
7872         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1);
7873         ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1));
7874         if (get_jenv_res == JNI_EDETACHED) {
7875                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7876         }
7877         return ret_conv;
7878 }
7879 void handle_htlc_fail_channel_update_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKHTLCFailChannelUpdate * update) {
7880         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
7881         JNIEnv *env;
7882         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7883         if (get_jenv_res == JNI_EDETACHED) {
7884                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7885         } else {
7886                 DO_ASSERT(get_jenv_res == JNI_OK);
7887         }
7888         uint64_t ret_update = (uint64_t)update;
7889         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7890         CHECK(obj != NULL);
7891         (*env)->CallVoidMethod(env, obj, j_calls->handle_htlc_fail_channel_update_meth, ret_update);
7892         if (get_jenv_res == JNI_EDETACHED) {
7893                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7894         }
7895 }
7896 LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ get_next_channel_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, uint64_t starting_point, uint8_t batch_amount) {
7897         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
7898         JNIEnv *env;
7899         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7900         if (get_jenv_res == JNI_EDETACHED) {
7901                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7902         } else {
7903                 DO_ASSERT(get_jenv_res == JNI_OK);
7904         }
7905         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7906         CHECK(obj != NULL);
7907         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_next_channel_announcements_meth, starting_point, batch_amount);
7908         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_constr;
7909         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
7910         if (ret_constr.datalen > 0)
7911                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
7912         else
7913                 ret_constr.data = NULL;
7914         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
7915         for (size_t l = 0; l < ret_constr.datalen; l++) {
7916                 int64_t ret_conv_63 = ret_vals[l];
7917                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ ret_conv_63_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)ret_conv_63) & ~1);
7918                 ret_conv_63_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone((LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)ret_conv_63) & ~1));
7919                 ret_constr.data[l] = ret_conv_63_conv;
7920         }
7921         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
7922         if (get_jenv_res == JNI_EDETACHED) {
7923                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7924         }
7925         return ret_constr;
7926 }
7927 LDKCVec_NodeAnnouncementZ get_next_node_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey starting_point, uint8_t batch_amount) {
7928         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
7929         JNIEnv *env;
7930         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7931         if (get_jenv_res == JNI_EDETACHED) {
7932                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7933         } else {
7934                 DO_ASSERT(get_jenv_res == JNI_OK);
7935         }
7936         int8_tArray starting_point_arr = (*env)->NewByteArray(env, 33);
7937         (*env)->SetByteArrayRegion(env, starting_point_arr, 0, 33, starting_point.compressed_form);
7938         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7939         CHECK(obj != NULL);
7940         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_next_node_announcements_meth, starting_point_arr, batch_amount);
7941         LDKCVec_NodeAnnouncementZ ret_constr;
7942         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
7943         if (ret_constr.datalen > 0)
7944                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
7945         else
7946                 ret_constr.data = NULL;
7947         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
7948         for (size_t s = 0; s < ret_constr.datalen; s++) {
7949                 int64_t ret_conv_18 = ret_vals[s];
7950                 LDKNodeAnnouncement ret_conv_18_conv;
7951                 ret_conv_18_conv.inner = (void*)(ret_conv_18 & (~1));
7952                 ret_conv_18_conv.is_owned = (ret_conv_18 & 1) || (ret_conv_18 == 0);
7953                 ret_conv_18_conv = NodeAnnouncement_clone(&ret_conv_18_conv);
7954                 ret_constr.data[s] = ret_conv_18_conv;
7955         }
7956         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
7957         if (get_jenv_res == JNI_EDETACHED) {
7958                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7959         }
7960         return ret_constr;
7961 }
7962 void sync_routing_table_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * init) {
7963         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
7964         JNIEnv *env;
7965         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7966         if (get_jenv_res == JNI_EDETACHED) {
7967                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7968         } else {
7969                 DO_ASSERT(get_jenv_res == JNI_OK);
7970         }
7971         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7972         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7973         LDKInit init_var = *init;
7974         init_var = Init_clone(init);
7975         CHECK((((uint64_t)init_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7976         CHECK((((uint64_t)&init_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7977         uint64_t init_ref = (uint64_t)init_var.inner;
7978         if (init_var.is_owned) {
7979                 init_ref |= 1;
7980         }
7981         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7982         CHECK(obj != NULL);
7983         (*env)->CallVoidMethod(env, obj, j_calls->sync_routing_table_meth, their_node_id_arr, init_ref);
7984         if (get_jenv_res == JNI_EDETACHED) {
7985                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7986         }
7987 }
7988 LDKCResult_NoneLightningErrorZ handle_reply_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyChannelRange msg) {
7989         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
7990         JNIEnv *env;
7991         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7992         if (get_jenv_res == JNI_EDETACHED) {
7993                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7994         } else {
7995                 DO_ASSERT(get_jenv_res == JNI_OK);
7996         }
7997         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7998         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7999         LDKReplyChannelRange msg_var = msg;
8000         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8001         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8002         uint64_t msg_ref = (uint64_t)msg_var.inner;
8003         if (msg_var.is_owned) {
8004                 msg_ref |= 1;
8005         }
8006         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8007         CHECK(obj != NULL);
8008         LDKCResult_NoneLightningErrorZ* ret = (LDKCResult_NoneLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_reply_channel_range_meth, their_node_id_arr, msg_ref);
8009         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
8010         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
8011         if (get_jenv_res == JNI_EDETACHED) {
8012                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8013         }
8014         return ret_conv;
8015 }
8016 LDKCResult_NoneLightningErrorZ handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyShortChannelIdsEnd msg) {
8017         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8018         JNIEnv *env;
8019         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8020         if (get_jenv_res == JNI_EDETACHED) {
8021                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8022         } else {
8023                 DO_ASSERT(get_jenv_res == JNI_OK);
8024         }
8025         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8026         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8027         LDKReplyShortChannelIdsEnd msg_var = msg;
8028         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8029         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8030         uint64_t msg_ref = (uint64_t)msg_var.inner;
8031         if (msg_var.is_owned) {
8032                 msg_ref |= 1;
8033         }
8034         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8035         CHECK(obj != NULL);
8036         LDKCResult_NoneLightningErrorZ* ret = (LDKCResult_NoneLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_reply_short_channel_ids_end_meth, their_node_id_arr, msg_ref);
8037         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
8038         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
8039         if (get_jenv_res == JNI_EDETACHED) {
8040                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8041         }
8042         return ret_conv;
8043 }
8044 LDKCResult_NoneLightningErrorZ handle_query_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryChannelRange msg) {
8045         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8046         JNIEnv *env;
8047         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8048         if (get_jenv_res == JNI_EDETACHED) {
8049                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8050         } else {
8051                 DO_ASSERT(get_jenv_res == JNI_OK);
8052         }
8053         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8054         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8055         LDKQueryChannelRange msg_var = msg;
8056         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8057         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8058         uint64_t msg_ref = (uint64_t)msg_var.inner;
8059         if (msg_var.is_owned) {
8060                 msg_ref |= 1;
8061         }
8062         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8063         CHECK(obj != NULL);
8064         LDKCResult_NoneLightningErrorZ* ret = (LDKCResult_NoneLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_query_channel_range_meth, their_node_id_arr, msg_ref);
8065         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
8066         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
8067         if (get_jenv_res == JNI_EDETACHED) {
8068                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8069         }
8070         return ret_conv;
8071 }
8072 LDKCResult_NoneLightningErrorZ handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryShortChannelIds msg) {
8073         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8074         JNIEnv *env;
8075         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8076         if (get_jenv_res == JNI_EDETACHED) {
8077                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8078         } else {
8079                 DO_ASSERT(get_jenv_res == JNI_OK);
8080         }
8081         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8082         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8083         LDKQueryShortChannelIds msg_var = msg;
8084         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8085         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8086         uint64_t msg_ref = (uint64_t)msg_var.inner;
8087         if (msg_var.is_owned) {
8088                 msg_ref |= 1;
8089         }
8090         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8091         CHECK(obj != NULL);
8092         LDKCResult_NoneLightningErrorZ* ret = (LDKCResult_NoneLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_query_short_channel_ids_meth, their_node_id_arr, msg_ref);
8093         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
8094         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
8095         if (get_jenv_res == JNI_EDETACHED) {
8096                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8097         }
8098         return ret_conv;
8099 }
8100 static void* LDKRoutingMessageHandler_JCalls_clone(const void* this_arg) {
8101         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8102         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8103         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
8104         return (void*) this_arg;
8105 }
8106 static inline LDKRoutingMessageHandler LDKRoutingMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
8107         jclass c = (*env)->GetObjectClass(env, o);
8108         CHECK(c != NULL);
8109         LDKRoutingMessageHandler_JCalls *calls = MALLOC(sizeof(LDKRoutingMessageHandler_JCalls), "LDKRoutingMessageHandler_JCalls");
8110         atomic_init(&calls->refcnt, 1);
8111         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
8112         calls->o = (*env)->NewWeakGlobalRef(env, o);
8113         calls->handle_node_announcement_meth = (*env)->GetMethodID(env, c, "handle_node_announcement", "(J)J");
8114         CHECK(calls->handle_node_announcement_meth != NULL);
8115         calls->handle_channel_announcement_meth = (*env)->GetMethodID(env, c, "handle_channel_announcement", "(J)J");
8116         CHECK(calls->handle_channel_announcement_meth != NULL);
8117         calls->handle_channel_update_meth = (*env)->GetMethodID(env, c, "handle_channel_update", "(J)J");
8118         CHECK(calls->handle_channel_update_meth != NULL);
8119         calls->handle_htlc_fail_channel_update_meth = (*env)->GetMethodID(env, c, "handle_htlc_fail_channel_update", "(J)V");
8120         CHECK(calls->handle_htlc_fail_channel_update_meth != NULL);
8121         calls->get_next_channel_announcements_meth = (*env)->GetMethodID(env, c, "get_next_channel_announcements", "(JB)[J");
8122         CHECK(calls->get_next_channel_announcements_meth != NULL);
8123         calls->get_next_node_announcements_meth = (*env)->GetMethodID(env, c, "get_next_node_announcements", "([BB)[J");
8124         CHECK(calls->get_next_node_announcements_meth != NULL);
8125         calls->sync_routing_table_meth = (*env)->GetMethodID(env, c, "sync_routing_table", "([BJ)V");
8126         CHECK(calls->sync_routing_table_meth != NULL);
8127         calls->handle_reply_channel_range_meth = (*env)->GetMethodID(env, c, "handle_reply_channel_range", "([BJ)J");
8128         CHECK(calls->handle_reply_channel_range_meth != NULL);
8129         calls->handle_reply_short_channel_ids_end_meth = (*env)->GetMethodID(env, c, "handle_reply_short_channel_ids_end", "([BJ)J");
8130         CHECK(calls->handle_reply_short_channel_ids_end_meth != NULL);
8131         calls->handle_query_channel_range_meth = (*env)->GetMethodID(env, c, "handle_query_channel_range", "([BJ)J");
8132         CHECK(calls->handle_query_channel_range_meth != NULL);
8133         calls->handle_query_short_channel_ids_meth = (*env)->GetMethodID(env, c, "handle_query_short_channel_ids", "([BJ)J");
8134         CHECK(calls->handle_query_short_channel_ids_meth != NULL);
8135
8136         LDKRoutingMessageHandler ret = {
8137                 .this_arg = (void*) calls,
8138                 .handle_node_announcement = handle_node_announcement_LDKRoutingMessageHandler_jcall,
8139                 .handle_channel_announcement = handle_channel_announcement_LDKRoutingMessageHandler_jcall,
8140                 .handle_channel_update = handle_channel_update_LDKRoutingMessageHandler_jcall,
8141                 .handle_htlc_fail_channel_update = handle_htlc_fail_channel_update_LDKRoutingMessageHandler_jcall,
8142                 .get_next_channel_announcements = get_next_channel_announcements_LDKRoutingMessageHandler_jcall,
8143                 .get_next_node_announcements = get_next_node_announcements_LDKRoutingMessageHandler_jcall,
8144                 .sync_routing_table = sync_routing_table_LDKRoutingMessageHandler_jcall,
8145                 .handle_reply_channel_range = handle_reply_channel_range_LDKRoutingMessageHandler_jcall,
8146                 .handle_reply_short_channel_ids_end = handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall,
8147                 .handle_query_channel_range = handle_query_channel_range_LDKRoutingMessageHandler_jcall,
8148                 .handle_query_short_channel_ids = handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall,
8149                 .free = LDKRoutingMessageHandler_JCalls_free,
8150                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(env, clz, MessageSendEventsProvider),
8151         };
8152         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
8153         return ret;
8154 }
8155 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
8156         LDKRoutingMessageHandler *res_ptr = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
8157         *res_ptr = LDKRoutingMessageHandler_init(env, clz, o, MessageSendEventsProvider);
8158         return (uint64_t)res_ptr;
8159 }
8160 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1node_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
8161         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
8162         LDKNodeAnnouncement msg_conv;
8163         msg_conv.inner = (void*)(msg & (~1));
8164         msg_conv.is_owned = false;
8165         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
8166         *ret_conv = (this_arg_conv->handle_node_announcement)(this_arg_conv->this_arg, &msg_conv);
8167         return (uint64_t)ret_conv;
8168 }
8169
8170 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1channel_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
8171         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
8172         LDKChannelAnnouncement msg_conv;
8173         msg_conv.inner = (void*)(msg & (~1));
8174         msg_conv.is_owned = false;
8175         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
8176         *ret_conv = (this_arg_conv->handle_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
8177         return (uint64_t)ret_conv;
8178 }
8179
8180 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1channel_1update(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
8181         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
8182         LDKChannelUpdate msg_conv;
8183         msg_conv.inner = (void*)(msg & (~1));
8184         msg_conv.is_owned = false;
8185         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
8186         *ret_conv = (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, &msg_conv);
8187         return (uint64_t)ret_conv;
8188 }
8189
8190 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) {
8191         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
8192         LDKHTLCFailChannelUpdate* update_conv = (LDKHTLCFailChannelUpdate*)update;
8193         (this_arg_conv->handle_htlc_fail_channel_update)(this_arg_conv->this_arg, update_conv);
8194 }
8195
8196 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) {
8197         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
8198         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_var = (this_arg_conv->get_next_channel_announcements)(this_arg_conv->this_arg, starting_point, batch_amount);
8199         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
8200         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
8201         for (size_t l = 0; l < ret_var.datalen; l++) {
8202                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv_63_ref = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
8203                 *ret_conv_63_ref = ret_var.data[l];
8204                 ret_arr_ptr[l] = (uint64_t)ret_conv_63_ref;
8205         }
8206         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
8207         FREE(ret_var.data);
8208         return ret_arr;
8209 }
8210
8211 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) {
8212         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
8213         LDKPublicKey starting_point_ref;
8214         CHECK((*env)->GetArrayLength(env, starting_point) == 33);
8215         (*env)->GetByteArrayRegion(env, starting_point, 0, 33, starting_point_ref.compressed_form);
8216         LDKCVec_NodeAnnouncementZ ret_var = (this_arg_conv->get_next_node_announcements)(this_arg_conv->this_arg, starting_point_ref, batch_amount);
8217         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
8218         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
8219         for (size_t s = 0; s < ret_var.datalen; s++) {
8220                 LDKNodeAnnouncement ret_conv_18_var = ret_var.data[s];
8221                 CHECK((((uint64_t)ret_conv_18_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8222                 CHECK((((uint64_t)&ret_conv_18_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8223                 uint64_t ret_conv_18_ref = (uint64_t)ret_conv_18_var.inner;
8224                 if (ret_conv_18_var.is_owned) {
8225                         ret_conv_18_ref |= 1;
8226                 }
8227                 ret_arr_ptr[s] = ret_conv_18_ref;
8228         }
8229         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
8230         FREE(ret_var.data);
8231         return ret_arr;
8232 }
8233
8234 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) {
8235         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
8236         LDKPublicKey their_node_id_ref;
8237         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8238         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8239         LDKInit init_conv;
8240         init_conv.inner = (void*)(init & (~1));
8241         init_conv.is_owned = false;
8242         (this_arg_conv->sync_routing_table)(this_arg_conv->this_arg, their_node_id_ref, &init_conv);
8243 }
8244
8245 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) {
8246         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
8247         LDKPublicKey their_node_id_ref;
8248         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8249         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8250         LDKReplyChannelRange msg_conv;
8251         msg_conv.inner = (void*)(msg & (~1));
8252         msg_conv.is_owned = (msg & 1) || (msg == 0);
8253         msg_conv = ReplyChannelRange_clone(&msg_conv);
8254         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
8255         *ret_conv = (this_arg_conv->handle_reply_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
8256         return (uint64_t)ret_conv;
8257 }
8258
8259 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) {
8260         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
8261         LDKPublicKey their_node_id_ref;
8262         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8263         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8264         LDKReplyShortChannelIdsEnd msg_conv;
8265         msg_conv.inner = (void*)(msg & (~1));
8266         msg_conv.is_owned = (msg & 1) || (msg == 0);
8267         msg_conv = ReplyShortChannelIdsEnd_clone(&msg_conv);
8268         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
8269         *ret_conv = (this_arg_conv->handle_reply_short_channel_ids_end)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
8270         return (uint64_t)ret_conv;
8271 }
8272
8273 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) {
8274         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
8275         LDKPublicKey their_node_id_ref;
8276         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8277         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8278         LDKQueryChannelRange msg_conv;
8279         msg_conv.inner = (void*)(msg & (~1));
8280         msg_conv.is_owned = (msg & 1) || (msg == 0);
8281         msg_conv = QueryChannelRange_clone(&msg_conv);
8282         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
8283         *ret_conv = (this_arg_conv->handle_query_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
8284         return (uint64_t)ret_conv;
8285 }
8286
8287 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) {
8288         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
8289         LDKPublicKey their_node_id_ref;
8290         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8291         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8292         LDKQueryShortChannelIds msg_conv;
8293         msg_conv.inner = (void*)(msg & (~1));
8294         msg_conv.is_owned = (msg & 1) || (msg == 0);
8295         msg_conv = QueryShortChannelIds_clone(&msg_conv);
8296         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
8297         *ret_conv = (this_arg_conv->handle_query_short_channel_ids)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
8298         return (uint64_t)ret_conv;
8299 }
8300
8301 typedef struct LDKSocketDescriptor_JCalls {
8302         atomic_size_t refcnt;
8303         JavaVM *vm;
8304         jweak o;
8305         jmethodID send_data_meth;
8306         jmethodID disconnect_socket_meth;
8307         jmethodID eq_meth;
8308         jmethodID hash_meth;
8309 } LDKSocketDescriptor_JCalls;
8310 static void LDKSocketDescriptor_JCalls_free(void* this_arg) {
8311         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
8312         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8313                 JNIEnv *env;
8314                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8315                 if (get_jenv_res == JNI_EDETACHED) {
8316                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8317                 } else {
8318                         DO_ASSERT(get_jenv_res == JNI_OK);
8319                 }
8320                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
8321                 if (get_jenv_res == JNI_EDETACHED) {
8322                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8323                 }
8324                 FREE(j_calls);
8325         }
8326 }
8327 uintptr_t send_data_LDKSocketDescriptor_jcall(void* this_arg, LDKu8slice data, bool resume_read) {
8328         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
8329         JNIEnv *env;
8330         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8331         if (get_jenv_res == JNI_EDETACHED) {
8332                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8333         } else {
8334                 DO_ASSERT(get_jenv_res == JNI_OK);
8335         }
8336         LDKu8slice data_var = data;
8337         int8_tArray data_arr = (*env)->NewByteArray(env, data_var.datalen);
8338         (*env)->SetByteArrayRegion(env, data_arr, 0, data_var.datalen, data_var.data);
8339         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8340         CHECK(obj != NULL);
8341         int64_t ret = (*env)->CallLongMethod(env, obj, j_calls->send_data_meth, data_arr, resume_read);
8342         if (get_jenv_res == JNI_EDETACHED) {
8343                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8344         }
8345         return ret;
8346 }
8347 void disconnect_socket_LDKSocketDescriptor_jcall(void* this_arg) {
8348         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
8349         JNIEnv *env;
8350         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8351         if (get_jenv_res == JNI_EDETACHED) {
8352                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8353         } else {
8354                 DO_ASSERT(get_jenv_res == JNI_OK);
8355         }
8356         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8357         CHECK(obj != NULL);
8358         (*env)->CallVoidMethod(env, obj, j_calls->disconnect_socket_meth);
8359         if (get_jenv_res == JNI_EDETACHED) {
8360                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8361         }
8362 }
8363 bool eq_LDKSocketDescriptor_jcall(const void* this_arg, const LDKSocketDescriptor * other_arg) {
8364         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
8365         JNIEnv *env;
8366         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8367         if (get_jenv_res == JNI_EDETACHED) {
8368                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8369         } else {
8370                 DO_ASSERT(get_jenv_res == JNI_OK);
8371         }
8372         LDKSocketDescriptor *other_arg_clone = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
8373         *other_arg_clone = SocketDescriptor_clone(other_arg);
8374         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8375         CHECK(obj != NULL);
8376         jboolean ret = (*env)->CallBooleanMethod(env, obj, j_calls->eq_meth, (uint64_t)other_arg_clone);
8377         if (get_jenv_res == JNI_EDETACHED) {
8378                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8379         }
8380         return ret;
8381 }
8382 uint64_t hash_LDKSocketDescriptor_jcall(const void* this_arg) {
8383         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
8384         JNIEnv *env;
8385         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8386         if (get_jenv_res == JNI_EDETACHED) {
8387                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8388         } else {
8389                 DO_ASSERT(get_jenv_res == JNI_OK);
8390         }
8391         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8392         CHECK(obj != NULL);
8393         int64_t ret = (*env)->CallLongMethod(env, obj, j_calls->hash_meth);
8394         if (get_jenv_res == JNI_EDETACHED) {
8395                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8396         }
8397         return ret;
8398 }
8399 static void* LDKSocketDescriptor_JCalls_clone(const void* this_arg) {
8400         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
8401         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8402         return (void*) this_arg;
8403 }
8404 static inline LDKSocketDescriptor LDKSocketDescriptor_init (JNIEnv *env, jclass clz, jobject o) {
8405         jclass c = (*env)->GetObjectClass(env, o);
8406         CHECK(c != NULL);
8407         LDKSocketDescriptor_JCalls *calls = MALLOC(sizeof(LDKSocketDescriptor_JCalls), "LDKSocketDescriptor_JCalls");
8408         atomic_init(&calls->refcnt, 1);
8409         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
8410         calls->o = (*env)->NewWeakGlobalRef(env, o);
8411         calls->send_data_meth = (*env)->GetMethodID(env, c, "send_data", "([BZ)J");
8412         CHECK(calls->send_data_meth != NULL);
8413         calls->disconnect_socket_meth = (*env)->GetMethodID(env, c, "disconnect_socket", "()V");
8414         CHECK(calls->disconnect_socket_meth != NULL);
8415         calls->eq_meth = (*env)->GetMethodID(env, c, "eq", "(J)Z");
8416         CHECK(calls->eq_meth != NULL);
8417         calls->hash_meth = (*env)->GetMethodID(env, c, "hash", "()J");
8418         CHECK(calls->hash_meth != NULL);
8419
8420         LDKSocketDescriptor ret = {
8421                 .this_arg = (void*) calls,
8422                 .send_data = send_data_LDKSocketDescriptor_jcall,
8423                 .disconnect_socket = disconnect_socket_LDKSocketDescriptor_jcall,
8424                 .eq = eq_LDKSocketDescriptor_jcall,
8425                 .hash = hash_LDKSocketDescriptor_jcall,
8426                 .clone = LDKSocketDescriptor_JCalls_clone,
8427                 .free = LDKSocketDescriptor_JCalls_free,
8428         };
8429         return ret;
8430 }
8431 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSocketDescriptor_1new(JNIEnv *env, jclass clz, jobject o) {
8432         LDKSocketDescriptor *res_ptr = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
8433         *res_ptr = LDKSocketDescriptor_init(env, clz, o);
8434         return (uint64_t)res_ptr;
8435 }
8436 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) {
8437         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)(((uint64_t)this_arg) & ~1);
8438         LDKu8slice data_ref;
8439         data_ref.datalen = (*env)->GetArrayLength(env, data);
8440         data_ref.data = (*env)->GetByteArrayElements (env, data, NULL);
8441         int64_t ret_val = (this_arg_conv->send_data)(this_arg_conv->this_arg, data_ref, resume_read);
8442         (*env)->ReleaseByteArrayElements(env, data, (int8_t*)data_ref.data, 0);
8443         return ret_val;
8444 }
8445
8446 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1disconnect_1socket(JNIEnv *env, jclass clz, int64_t this_arg) {
8447         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)(((uint64_t)this_arg) & ~1);
8448         (this_arg_conv->disconnect_socket)(this_arg_conv->this_arg);
8449 }
8450
8451 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
8452         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)(((uint64_t)this_arg) & ~1);
8453         int64_t ret_val = (this_arg_conv->hash)(this_arg_conv->this_arg);
8454         return ret_val;
8455 }
8456
8457 typedef struct LDKChannelManagerPersister_JCalls {
8458         atomic_size_t refcnt;
8459         JavaVM *vm;
8460         jweak o;
8461         jmethodID persist_manager_meth;
8462 } LDKChannelManagerPersister_JCalls;
8463 static void LDKChannelManagerPersister_JCalls_free(void* this_arg) {
8464         LDKChannelManagerPersister_JCalls *j_calls = (LDKChannelManagerPersister_JCalls*) this_arg;
8465         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8466                 JNIEnv *env;
8467                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8468                 if (get_jenv_res == JNI_EDETACHED) {
8469                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8470                 } else {
8471                         DO_ASSERT(get_jenv_res == JNI_OK);
8472                 }
8473                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
8474                 if (get_jenv_res == JNI_EDETACHED) {
8475                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8476                 }
8477                 FREE(j_calls);
8478         }
8479 }
8480 LDKCResult_NoneErrorZ persist_manager_LDKChannelManagerPersister_jcall(const void* this_arg, const LDKChannelManager * channel_manager) {
8481         LDKChannelManagerPersister_JCalls *j_calls = (LDKChannelManagerPersister_JCalls*) this_arg;
8482         JNIEnv *env;
8483         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8484         if (get_jenv_res == JNI_EDETACHED) {
8485                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8486         } else {
8487                 DO_ASSERT(get_jenv_res == JNI_OK);
8488         }
8489         LDKChannelManager channel_manager_var = *channel_manager;
8490         // Warning: we may need a move here but no clone is available for LDKChannelManager
8491         CHECK((((uint64_t)channel_manager_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8492         CHECK((((uint64_t)&channel_manager_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8493         uint64_t channel_manager_ref = (uint64_t)channel_manager_var.inner;
8494         if (channel_manager_var.is_owned) {
8495                 channel_manager_ref |= 1;
8496         }
8497         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8498         CHECK(obj != NULL);
8499         LDKCResult_NoneErrorZ* ret = (LDKCResult_NoneErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->persist_manager_meth, channel_manager_ref);
8500         LDKCResult_NoneErrorZ ret_conv = *(LDKCResult_NoneErrorZ*)(((uint64_t)ret) & ~1);
8501         ret_conv = CResult_NoneErrorZ_clone((LDKCResult_NoneErrorZ*)(((uint64_t)ret) & ~1));
8502         if (get_jenv_res == JNI_EDETACHED) {
8503                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8504         }
8505         return ret_conv;
8506 }
8507 static void* LDKChannelManagerPersister_JCalls_clone(const void* this_arg) {
8508         LDKChannelManagerPersister_JCalls *j_calls = (LDKChannelManagerPersister_JCalls*) this_arg;
8509         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8510         return (void*) this_arg;
8511 }
8512 static inline LDKChannelManagerPersister LDKChannelManagerPersister_init (JNIEnv *env, jclass clz, jobject o) {
8513         jclass c = (*env)->GetObjectClass(env, o);
8514         CHECK(c != NULL);
8515         LDKChannelManagerPersister_JCalls *calls = MALLOC(sizeof(LDKChannelManagerPersister_JCalls), "LDKChannelManagerPersister_JCalls");
8516         atomic_init(&calls->refcnt, 1);
8517         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
8518         calls->o = (*env)->NewWeakGlobalRef(env, o);
8519         calls->persist_manager_meth = (*env)->GetMethodID(env, c, "persist_manager", "(J)J");
8520         CHECK(calls->persist_manager_meth != NULL);
8521
8522         LDKChannelManagerPersister ret = {
8523                 .this_arg = (void*) calls,
8524                 .persist_manager = persist_manager_LDKChannelManagerPersister_jcall,
8525                 .free = LDKChannelManagerPersister_JCalls_free,
8526         };
8527         return ret;
8528 }
8529 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKChannelManagerPersister_1new(JNIEnv *env, jclass clz, jobject o) {
8530         LDKChannelManagerPersister *res_ptr = MALLOC(sizeof(LDKChannelManagerPersister), "LDKChannelManagerPersister");
8531         *res_ptr = LDKChannelManagerPersister_init(env, clz, o);
8532         return (uint64_t)res_ptr;
8533 }
8534 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerPersister_1persist_1manager(JNIEnv *env, jclass clz, int64_t this_arg, int64_t channel_manager) {
8535         LDKChannelManagerPersister* this_arg_conv = (LDKChannelManagerPersister*)(((uint64_t)this_arg) & ~1);
8536         LDKChannelManager channel_manager_conv;
8537         channel_manager_conv.inner = (void*)(channel_manager & (~1));
8538         channel_manager_conv.is_owned = false;
8539         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
8540         *ret_conv = (this_arg_conv->persist_manager)(this_arg_conv->this_arg, &channel_manager_conv);
8541         return (uint64_t)ret_conv;
8542 }
8543
8544 static jclass LDKFallback_SegWitProgram_class = NULL;
8545 static jmethodID LDKFallback_SegWitProgram_meth = NULL;
8546 static jclass LDKFallback_PubKeyHash_class = NULL;
8547 static jmethodID LDKFallback_PubKeyHash_meth = NULL;
8548 static jclass LDKFallback_ScriptHash_class = NULL;
8549 static jmethodID LDKFallback_ScriptHash_meth = NULL;
8550 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKFallback_init (JNIEnv *env, jclass clz) {
8551         LDKFallback_SegWitProgram_class =
8552                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKFallback$SegWitProgram;"));
8553         CHECK(LDKFallback_SegWitProgram_class != NULL);
8554         LDKFallback_SegWitProgram_meth = (*env)->GetMethodID(env, LDKFallback_SegWitProgram_class, "<init>", "(B[B)V");
8555         CHECK(LDKFallback_SegWitProgram_meth != NULL);
8556         LDKFallback_PubKeyHash_class =
8557                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKFallback$PubKeyHash;"));
8558         CHECK(LDKFallback_PubKeyHash_class != NULL);
8559         LDKFallback_PubKeyHash_meth = (*env)->GetMethodID(env, LDKFallback_PubKeyHash_class, "<init>", "([B)V");
8560         CHECK(LDKFallback_PubKeyHash_meth != NULL);
8561         LDKFallback_ScriptHash_class =
8562                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKFallback$ScriptHash;"));
8563         CHECK(LDKFallback_ScriptHash_class != NULL);
8564         LDKFallback_ScriptHash_meth = (*env)->GetMethodID(env, LDKFallback_ScriptHash_class, "<init>", "([B)V");
8565         CHECK(LDKFallback_ScriptHash_meth != NULL);
8566 }
8567 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKFallback_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
8568         LDKFallback *obj = (LDKFallback*)(ptr & ~1);
8569         switch(obj->tag) {
8570                 case LDKFallback_SegWitProgram: {
8571                         uint8_t version_val = obj->seg_wit_program.version._0;
8572                         LDKCVec_u8Z program_var = obj->seg_wit_program.program;
8573                         int8_tArray program_arr = (*env)->NewByteArray(env, program_var.datalen);
8574                         (*env)->SetByteArrayRegion(env, program_arr, 0, program_var.datalen, program_var.data);
8575                         return (*env)->NewObject(env, LDKFallback_SegWitProgram_class, LDKFallback_SegWitProgram_meth, version_val, program_arr);
8576                 }
8577                 case LDKFallback_PubKeyHash: {
8578                         int8_tArray pub_key_hash_arr = (*env)->NewByteArray(env, 20);
8579                         (*env)->SetByteArrayRegion(env, pub_key_hash_arr, 0, 20, obj->pub_key_hash.data);
8580                         return (*env)->NewObject(env, LDKFallback_PubKeyHash_class, LDKFallback_PubKeyHash_meth, pub_key_hash_arr);
8581                 }
8582                 case LDKFallback_ScriptHash: {
8583                         int8_tArray script_hash_arr = (*env)->NewByteArray(env, 20);
8584                         (*env)->SetByteArrayRegion(env, script_hash_arr, 0, 20, obj->script_hash.data);
8585                         return (*env)->NewObject(env, LDKFallback_ScriptHash_class, LDKFallback_ScriptHash_meth, script_hash_arr);
8586                 }
8587                 default: abort();
8588         }
8589 }
8590 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings__1ldk_1get_1compiled_1version(JNIEnv *env, jclass clz) {
8591         LDKStr ret_str = _ldk_get_compiled_version();
8592         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
8593         return ret_conv;
8594 }
8595
8596 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings__1ldk_1c_1bindings_1get_1compiled_1version(JNIEnv *env, jclass clz) {
8597         LDKStr ret_str = _ldk_c_bindings_get_compiled_version();
8598         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
8599         return ret_conv;
8600 }
8601
8602 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Transaction_1free(JNIEnv *env, jclass clz, int8_tArray _res) {
8603         LDKTransaction _res_ref;
8604         _res_ref.datalen = (*env)->GetArrayLength(env, _res);
8605         _res_ref.data = MALLOC(_res_ref.datalen, "LDKTransaction Bytes");
8606         (*env)->GetByteArrayRegion(env, _res, 0, _res_ref.datalen, _res_ref.data);
8607         _res_ref.data_is_owned = true;
8608         Transaction_free(_res_ref);
8609 }
8610
8611 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxOut_1free(JNIEnv *env, jclass clz, int64_t _res) {
8612         if ((_res & 1) != 0) return;
8613         LDKTxOut _res_conv = *(LDKTxOut*)(((uint64_t)_res) & ~1);
8614         FREE((void*)_res);
8615         TxOut_free(_res_conv);
8616 }
8617
8618 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxOut_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8619         LDKTxOut* orig_conv = (LDKTxOut*)(orig & ~1);
8620         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
8621         *ret_ref = TxOut_clone(orig_conv);
8622         return (uint64_t)ret_ref;
8623 }
8624
8625 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Str_1free(JNIEnv *env, jclass clz, jstring _res) {
8626         LDKStr dummy = { .chars = NULL, .len = 0, .chars_is_owned = false };
8627         Str_free(dummy);
8628 }
8629
8630 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
8631         LDKSecretKey o_ref;
8632         CHECK((*env)->GetArrayLength(env, o) == 32);
8633         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.bytes);
8634         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
8635         *ret_conv = CResult_SecretKeyErrorZ_ok(o_ref);
8636         return (uint64_t)ret_conv;
8637 }
8638
8639 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
8640         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
8641         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
8642         *ret_conv = CResult_SecretKeyErrorZ_err(e_conv);
8643         return (uint64_t)ret_conv;
8644 }
8645
8646 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8647         if ((_res & 1) != 0) return;
8648         LDKCResult_SecretKeyErrorZ _res_conv = *(LDKCResult_SecretKeyErrorZ*)(((uint64_t)_res) & ~1);
8649         FREE((void*)_res);
8650         CResult_SecretKeyErrorZ_free(_res_conv);
8651 }
8652
8653 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
8654         LDKPublicKey o_ref;
8655         CHECK((*env)->GetArrayLength(env, o) == 33);
8656         (*env)->GetByteArrayRegion(env, o, 0, 33, o_ref.compressed_form);
8657         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
8658         *ret_conv = CResult_PublicKeyErrorZ_ok(o_ref);
8659         return (uint64_t)ret_conv;
8660 }
8661
8662 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
8663         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
8664         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
8665         *ret_conv = CResult_PublicKeyErrorZ_err(e_conv);
8666         return (uint64_t)ret_conv;
8667 }
8668
8669 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8670         if ((_res & 1) != 0) return;
8671         LDKCResult_PublicKeyErrorZ _res_conv = *(LDKCResult_PublicKeyErrorZ*)(((uint64_t)_res) & ~1);
8672         FREE((void*)_res);
8673         CResult_PublicKeyErrorZ_free(_res_conv);
8674 }
8675
8676 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8677         LDKCResult_PublicKeyErrorZ* orig_conv = (LDKCResult_PublicKeyErrorZ*)(orig & ~1);
8678         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
8679         *ret_conv = CResult_PublicKeyErrorZ_clone(orig_conv);
8680         return (uint64_t)ret_conv;
8681 }
8682
8683 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8684         LDKTxCreationKeys o_conv;
8685         o_conv.inner = (void*)(o & (~1));
8686         o_conv.is_owned = (o & 1) || (o == 0);
8687         o_conv = TxCreationKeys_clone(&o_conv);
8688         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
8689         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_ok(o_conv);
8690         return (uint64_t)ret_conv;
8691 }
8692
8693 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8694         LDKDecodeError e_conv;
8695         e_conv.inner = (void*)(e & (~1));
8696         e_conv.is_owned = (e & 1) || (e == 0);
8697         e_conv = DecodeError_clone(&e_conv);
8698         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
8699         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_err(e_conv);
8700         return (uint64_t)ret_conv;
8701 }
8702
8703 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8704         if ((_res & 1) != 0) return;
8705         LDKCResult_TxCreationKeysDecodeErrorZ _res_conv = *(LDKCResult_TxCreationKeysDecodeErrorZ*)(((uint64_t)_res) & ~1);
8706         FREE((void*)_res);
8707         CResult_TxCreationKeysDecodeErrorZ_free(_res_conv);
8708 }
8709
8710 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8711         LDKCResult_TxCreationKeysDecodeErrorZ* orig_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(orig & ~1);
8712         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
8713         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(orig_conv);
8714         return (uint64_t)ret_conv;
8715 }
8716
8717 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8718         LDKChannelPublicKeys o_conv;
8719         o_conv.inner = (void*)(o & (~1));
8720         o_conv.is_owned = (o & 1) || (o == 0);
8721         o_conv = ChannelPublicKeys_clone(&o_conv);
8722         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
8723         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_ok(o_conv);
8724         return (uint64_t)ret_conv;
8725 }
8726
8727 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8728         LDKDecodeError e_conv;
8729         e_conv.inner = (void*)(e & (~1));
8730         e_conv.is_owned = (e & 1) || (e == 0);
8731         e_conv = DecodeError_clone(&e_conv);
8732         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
8733         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_err(e_conv);
8734         return (uint64_t)ret_conv;
8735 }
8736
8737 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8738         if ((_res & 1) != 0) return;
8739         LDKCResult_ChannelPublicKeysDecodeErrorZ _res_conv = *(LDKCResult_ChannelPublicKeysDecodeErrorZ*)(((uint64_t)_res) & ~1);
8740         FREE((void*)_res);
8741         CResult_ChannelPublicKeysDecodeErrorZ_free(_res_conv);
8742 }
8743
8744 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8745         LDKCResult_ChannelPublicKeysDecodeErrorZ* orig_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(orig & ~1);
8746         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
8747         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(orig_conv);
8748         return (uint64_t)ret_conv;
8749 }
8750
8751 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8752         LDKTxCreationKeys o_conv;
8753         o_conv.inner = (void*)(o & (~1));
8754         o_conv.is_owned = (o & 1) || (o == 0);
8755         o_conv = TxCreationKeys_clone(&o_conv);
8756         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
8757         *ret_conv = CResult_TxCreationKeysErrorZ_ok(o_conv);
8758         return (uint64_t)ret_conv;
8759 }
8760
8761 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
8762         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
8763         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
8764         *ret_conv = CResult_TxCreationKeysErrorZ_err(e_conv);
8765         return (uint64_t)ret_conv;
8766 }
8767
8768 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8769         if ((_res & 1) != 0) return;
8770         LDKCResult_TxCreationKeysErrorZ _res_conv = *(LDKCResult_TxCreationKeysErrorZ*)(((uint64_t)_res) & ~1);
8771         FREE((void*)_res);
8772         CResult_TxCreationKeysErrorZ_free(_res_conv);
8773 }
8774
8775 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8776         LDKCResult_TxCreationKeysErrorZ* orig_conv = (LDKCResult_TxCreationKeysErrorZ*)(orig & ~1);
8777         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
8778         *ret_conv = CResult_TxCreationKeysErrorZ_clone(orig_conv);
8779         return (uint64_t)ret_conv;
8780 }
8781
8782 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1some(JNIEnv *env, jclass clz, int32_t o) {
8783         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
8784         *ret_copy = COption_u32Z_some(o);
8785         uint64_t ret_ref = (uint64_t)ret_copy;
8786         return ret_ref;
8787 }
8788
8789 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1none(JNIEnv *env, jclass clz) {
8790         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
8791         *ret_copy = COption_u32Z_none();
8792         uint64_t ret_ref = (uint64_t)ret_copy;
8793         return ret_ref;
8794 }
8795
8796 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
8797         if ((_res & 1) != 0) return;
8798         LDKCOption_u32Z _res_conv = *(LDKCOption_u32Z*)(((uint64_t)_res) & ~1);
8799         FREE((void*)_res);
8800         COption_u32Z_free(_res_conv);
8801 }
8802
8803 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8804         LDKCOption_u32Z* orig_conv = (LDKCOption_u32Z*)orig;
8805         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
8806         *ret_copy = COption_u32Z_clone(orig_conv);
8807         uint64_t ret_ref = (uint64_t)ret_copy;
8808         return ret_ref;
8809 }
8810
8811 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8812         LDKHTLCOutputInCommitment o_conv;
8813         o_conv.inner = (void*)(o & (~1));
8814         o_conv.is_owned = (o & 1) || (o == 0);
8815         o_conv = HTLCOutputInCommitment_clone(&o_conv);
8816         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
8817         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(o_conv);
8818         return (uint64_t)ret_conv;
8819 }
8820
8821 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8822         LDKDecodeError e_conv;
8823         e_conv.inner = (void*)(e & (~1));
8824         e_conv.is_owned = (e & 1) || (e == 0);
8825         e_conv = DecodeError_clone(&e_conv);
8826         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
8827         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_err(e_conv);
8828         return (uint64_t)ret_conv;
8829 }
8830
8831 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8832         if ((_res & 1) != 0) return;
8833         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ _res_conv = *(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(((uint64_t)_res) & ~1);
8834         FREE((void*)_res);
8835         CResult_HTLCOutputInCommitmentDecodeErrorZ_free(_res_conv);
8836 }
8837
8838 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8839         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* orig_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(orig & ~1);
8840         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
8841         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(orig_conv);
8842         return (uint64_t)ret_conv;
8843 }
8844
8845 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8846         LDKCounterpartyChannelTransactionParameters o_conv;
8847         o_conv.inner = (void*)(o & (~1));
8848         o_conv.is_owned = (o & 1) || (o == 0);
8849         o_conv = CounterpartyChannelTransactionParameters_clone(&o_conv);
8850         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
8851         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(o_conv);
8852         return (uint64_t)ret_conv;
8853 }
8854
8855 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8856         LDKDecodeError e_conv;
8857         e_conv.inner = (void*)(e & (~1));
8858         e_conv.is_owned = (e & 1) || (e == 0);
8859         e_conv = DecodeError_clone(&e_conv);
8860         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
8861         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(e_conv);
8862         return (uint64_t)ret_conv;
8863 }
8864
8865 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8866         if ((_res & 1) != 0) return;
8867         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(((uint64_t)_res) & ~1);
8868         FREE((void*)_res);
8869         CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(_res_conv);
8870 }
8871
8872 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8873         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
8874         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
8875         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
8876         return (uint64_t)ret_conv;
8877 }
8878
8879 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8880         LDKChannelTransactionParameters o_conv;
8881         o_conv.inner = (void*)(o & (~1));
8882         o_conv.is_owned = (o & 1) || (o == 0);
8883         o_conv = ChannelTransactionParameters_clone(&o_conv);
8884         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
8885         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_ok(o_conv);
8886         return (uint64_t)ret_conv;
8887 }
8888
8889 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8890         LDKDecodeError e_conv;
8891         e_conv.inner = (void*)(e & (~1));
8892         e_conv.is_owned = (e & 1) || (e == 0);
8893         e_conv = DecodeError_clone(&e_conv);
8894         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
8895         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_err(e_conv);
8896         return (uint64_t)ret_conv;
8897 }
8898
8899 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8900         if ((_res & 1) != 0) return;
8901         LDKCResult_ChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(((uint64_t)_res) & ~1);
8902         FREE((void*)_res);
8903         CResult_ChannelTransactionParametersDecodeErrorZ_free(_res_conv);
8904 }
8905
8906 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8907         LDKCResult_ChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
8908         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
8909         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
8910         return (uint64_t)ret_conv;
8911 }
8912
8913 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1SignatureZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
8914         LDKCVec_SignatureZ _res_constr;
8915         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
8916         if (_res_constr.datalen > 0)
8917                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
8918         else
8919                 _res_constr.data = NULL;
8920         for (size_t i = 0; i < _res_constr.datalen; i++) {
8921                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
8922                 LDKSignature _res_conv_8_ref;
8923                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 64);
8924                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 64, _res_conv_8_ref.compact_form);
8925                 _res_constr.data[i] = _res_conv_8_ref;
8926         }
8927         CVec_SignatureZ_free(_res_constr);
8928 }
8929
8930 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8931         LDKHolderCommitmentTransaction o_conv;
8932         o_conv.inner = (void*)(o & (~1));
8933         o_conv.is_owned = (o & 1) || (o == 0);
8934         o_conv = HolderCommitmentTransaction_clone(&o_conv);
8935         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
8936         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_ok(o_conv);
8937         return (uint64_t)ret_conv;
8938 }
8939
8940 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8941         LDKDecodeError e_conv;
8942         e_conv.inner = (void*)(e & (~1));
8943         e_conv.is_owned = (e & 1) || (e == 0);
8944         e_conv = DecodeError_clone(&e_conv);
8945         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
8946         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_err(e_conv);
8947         return (uint64_t)ret_conv;
8948 }
8949
8950 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8951         if ((_res & 1) != 0) return;
8952         LDKCResult_HolderCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(((uint64_t)_res) & ~1);
8953         FREE((void*)_res);
8954         CResult_HolderCommitmentTransactionDecodeErrorZ_free(_res_conv);
8955 }
8956
8957 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8958         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(orig & ~1);
8959         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
8960         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(orig_conv);
8961         return (uint64_t)ret_conv;
8962 }
8963
8964 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8965         LDKBuiltCommitmentTransaction o_conv;
8966         o_conv.inner = (void*)(o & (~1));
8967         o_conv.is_owned = (o & 1) || (o == 0);
8968         o_conv = BuiltCommitmentTransaction_clone(&o_conv);
8969         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
8970         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(o_conv);
8971         return (uint64_t)ret_conv;
8972 }
8973
8974 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8975         LDKDecodeError e_conv;
8976         e_conv.inner = (void*)(e & (~1));
8977         e_conv.is_owned = (e & 1) || (e == 0);
8978         e_conv = DecodeError_clone(&e_conv);
8979         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
8980         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_err(e_conv);
8981         return (uint64_t)ret_conv;
8982 }
8983
8984 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8985         if ((_res & 1) != 0) return;
8986         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(((uint64_t)_res) & ~1);
8987         FREE((void*)_res);
8988         CResult_BuiltCommitmentTransactionDecodeErrorZ_free(_res_conv);
8989 }
8990
8991 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8992         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(orig & ~1);
8993         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
8994         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(orig_conv);
8995         return (uint64_t)ret_conv;
8996 }
8997
8998 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8999         LDKCommitmentTransaction o_conv;
9000         o_conv.inner = (void*)(o & (~1));
9001         o_conv.is_owned = (o & 1) || (o == 0);
9002         o_conv = CommitmentTransaction_clone(&o_conv);
9003         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
9004         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_ok(o_conv);
9005         return (uint64_t)ret_conv;
9006 }
9007
9008 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9009         LDKDecodeError e_conv;
9010         e_conv.inner = (void*)(e & (~1));
9011         e_conv.is_owned = (e & 1) || (e == 0);
9012         e_conv = DecodeError_clone(&e_conv);
9013         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
9014         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_err(e_conv);
9015         return (uint64_t)ret_conv;
9016 }
9017
9018 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9019         if ((_res & 1) != 0) return;
9020         LDKCResult_CommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_CommitmentTransactionDecodeErrorZ*)(((uint64_t)_res) & ~1);
9021         FREE((void*)_res);
9022         CResult_CommitmentTransactionDecodeErrorZ_free(_res_conv);
9023 }
9024
9025 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9026         LDKCResult_CommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(orig & ~1);
9027         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
9028         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(orig_conv);
9029         return (uint64_t)ret_conv;
9030 }
9031
9032 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9033         LDKTrustedCommitmentTransaction o_conv;
9034         o_conv.inner = (void*)(o & (~1));
9035         o_conv.is_owned = (o & 1) || (o == 0);
9036         // Warning: we need a move here but no clone is available for LDKTrustedCommitmentTransaction
9037         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
9038         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_ok(o_conv);
9039         return (uint64_t)ret_conv;
9040 }
9041
9042 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1err(JNIEnv *env, jclass clz) {
9043         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
9044         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_err();
9045         return (uint64_t)ret_conv;
9046 }
9047
9048 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9049         if ((_res & 1) != 0) return;
9050         LDKCResult_TrustedCommitmentTransactionNoneZ _res_conv = *(LDKCResult_TrustedCommitmentTransactionNoneZ*)(((uint64_t)_res) & ~1);
9051         FREE((void*)_res);
9052         CResult_TrustedCommitmentTransactionNoneZ_free(_res_conv);
9053 }
9054
9055 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1ok(JNIEnv *env, jclass clz, jobjectArray o) {
9056         LDKCVec_SignatureZ o_constr;
9057         o_constr.datalen = (*env)->GetArrayLength(env, o);
9058         if (o_constr.datalen > 0)
9059                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
9060         else
9061                 o_constr.data = NULL;
9062         for (size_t i = 0; i < o_constr.datalen; i++) {
9063                 int8_tArray o_conv_8 = (*env)->GetObjectArrayElement(env, o, i);
9064                 LDKSignature o_conv_8_ref;
9065                 CHECK((*env)->GetArrayLength(env, o_conv_8) == 64);
9066                 (*env)->GetByteArrayRegion(env, o_conv_8, 0, 64, o_conv_8_ref.compact_form);
9067                 o_constr.data[i] = o_conv_8_ref;
9068         }
9069         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
9070         *ret_conv = CResult_CVec_SignatureZNoneZ_ok(o_constr);
9071         return (uint64_t)ret_conv;
9072 }
9073
9074 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1err(JNIEnv *env, jclass clz) {
9075         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
9076         *ret_conv = CResult_CVec_SignatureZNoneZ_err();
9077         return (uint64_t)ret_conv;
9078 }
9079
9080 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9081         if ((_res & 1) != 0) return;
9082         LDKCResult_CVec_SignatureZNoneZ _res_conv = *(LDKCResult_CVec_SignatureZNoneZ*)(((uint64_t)_res) & ~1);
9083         FREE((void*)_res);
9084         CResult_CVec_SignatureZNoneZ_free(_res_conv);
9085 }
9086
9087 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9088         LDKCResult_CVec_SignatureZNoneZ* orig_conv = (LDKCResult_CVec_SignatureZNoneZ*)(orig & ~1);
9089         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
9090         *ret_conv = CResult_CVec_SignatureZNoneZ_clone(orig_conv);
9091         return (uint64_t)ret_conv;
9092 }
9093
9094 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1ok(JNIEnv *env, jclass clz) {
9095         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
9096         *ret_conv = CResult_NoneErrorZ_ok();
9097         return (uint64_t)ret_conv;
9098 }
9099
9100 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
9101         LDKIOError e_conv = LDKIOError_from_java(env, e);
9102         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
9103         *ret_conv = CResult_NoneErrorZ_err(e_conv);
9104         return (uint64_t)ret_conv;
9105 }
9106
9107 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9108         if ((_res & 1) != 0) return;
9109         LDKCResult_NoneErrorZ _res_conv = *(LDKCResult_NoneErrorZ*)(((uint64_t)_res) & ~1);
9110         FREE((void*)_res);
9111         CResult_NoneErrorZ_free(_res_conv);
9112 }
9113
9114 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9115         LDKCResult_NoneErrorZ* orig_conv = (LDKCResult_NoneErrorZ*)(orig & ~1);
9116         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
9117         *ret_conv = CResult_NoneErrorZ_clone(orig_conv);
9118         return (uint64_t)ret_conv;
9119 }
9120
9121 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9122         LDKRouteHop o_conv;
9123         o_conv.inner = (void*)(o & (~1));
9124         o_conv.is_owned = (o & 1) || (o == 0);
9125         o_conv = RouteHop_clone(&o_conv);
9126         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
9127         *ret_conv = CResult_RouteHopDecodeErrorZ_ok(o_conv);
9128         return (uint64_t)ret_conv;
9129 }
9130
9131 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9132         LDKDecodeError e_conv;
9133         e_conv.inner = (void*)(e & (~1));
9134         e_conv.is_owned = (e & 1) || (e == 0);
9135         e_conv = DecodeError_clone(&e_conv);
9136         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
9137         *ret_conv = CResult_RouteHopDecodeErrorZ_err(e_conv);
9138         return (uint64_t)ret_conv;
9139 }
9140
9141 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9142         if ((_res & 1) != 0) return;
9143         LDKCResult_RouteHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHopDecodeErrorZ*)(((uint64_t)_res) & ~1);
9144         FREE((void*)_res);
9145         CResult_RouteHopDecodeErrorZ_free(_res_conv);
9146 }
9147
9148 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9149         LDKCResult_RouteHopDecodeErrorZ* orig_conv = (LDKCResult_RouteHopDecodeErrorZ*)(orig & ~1);
9150         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
9151         *ret_conv = CResult_RouteHopDecodeErrorZ_clone(orig_conv);
9152         return (uint64_t)ret_conv;
9153 }
9154
9155 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHopZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
9156         LDKCVec_RouteHopZ _res_constr;
9157         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
9158         if (_res_constr.datalen > 0)
9159                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
9160         else
9161                 _res_constr.data = NULL;
9162         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
9163         for (size_t k = 0; k < _res_constr.datalen; k++) {
9164                 int64_t _res_conv_10 = _res_vals[k];
9165                 LDKRouteHop _res_conv_10_conv;
9166                 _res_conv_10_conv.inner = (void*)(_res_conv_10 & (~1));
9167                 _res_conv_10_conv.is_owned = (_res_conv_10 & 1) || (_res_conv_10 == 0);
9168                 _res_constr.data[k] = _res_conv_10_conv;
9169         }
9170         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
9171         CVec_RouteHopZ_free(_res_constr);
9172 }
9173
9174 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CVec_1RouteHopZZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
9175         LDKCVec_CVec_RouteHopZZ _res_constr;
9176         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
9177         if (_res_constr.datalen > 0)
9178                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
9179         else
9180                 _res_constr.data = NULL;
9181         for (size_t m = 0; m < _res_constr.datalen; m++) {
9182                 int64_tArray _res_conv_12 = (*env)->GetObjectArrayElement(env, _res, m);
9183                 LDKCVec_RouteHopZ _res_conv_12_constr;
9184                 _res_conv_12_constr.datalen = (*env)->GetArrayLength(env, _res_conv_12);
9185                 if (_res_conv_12_constr.datalen > 0)
9186                         _res_conv_12_constr.data = MALLOC(_res_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
9187                 else
9188                         _res_conv_12_constr.data = NULL;
9189                 int64_t* _res_conv_12_vals = (*env)->GetLongArrayElements (env, _res_conv_12, NULL);
9190                 for (size_t k = 0; k < _res_conv_12_constr.datalen; k++) {
9191                         int64_t _res_conv_12_conv_10 = _res_conv_12_vals[k];
9192                         LDKRouteHop _res_conv_12_conv_10_conv;
9193                         _res_conv_12_conv_10_conv.inner = (void*)(_res_conv_12_conv_10 & (~1));
9194                         _res_conv_12_conv_10_conv.is_owned = (_res_conv_12_conv_10 & 1) || (_res_conv_12_conv_10 == 0);
9195                         _res_conv_12_constr.data[k] = _res_conv_12_conv_10_conv;
9196                 }
9197                 (*env)->ReleaseLongArrayElements(env, _res_conv_12, _res_conv_12_vals, 0);
9198                 _res_constr.data[m] = _res_conv_12_constr;
9199         }
9200         CVec_CVec_RouteHopZZ_free(_res_constr);
9201 }
9202
9203 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9204         LDKRoute o_conv;
9205         o_conv.inner = (void*)(o & (~1));
9206         o_conv.is_owned = (o & 1) || (o == 0);
9207         o_conv = Route_clone(&o_conv);
9208         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
9209         *ret_conv = CResult_RouteDecodeErrorZ_ok(o_conv);
9210         return (uint64_t)ret_conv;
9211 }
9212
9213 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9214         LDKDecodeError e_conv;
9215         e_conv.inner = (void*)(e & (~1));
9216         e_conv.is_owned = (e & 1) || (e == 0);
9217         e_conv = DecodeError_clone(&e_conv);
9218         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
9219         *ret_conv = CResult_RouteDecodeErrorZ_err(e_conv);
9220         return (uint64_t)ret_conv;
9221 }
9222
9223 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9224         if ((_res & 1) != 0) return;
9225         LDKCResult_RouteDecodeErrorZ _res_conv = *(LDKCResult_RouteDecodeErrorZ*)(((uint64_t)_res) & ~1);
9226         FREE((void*)_res);
9227         CResult_RouteDecodeErrorZ_free(_res_conv);
9228 }
9229
9230 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9231         LDKCResult_RouteDecodeErrorZ* orig_conv = (LDKCResult_RouteDecodeErrorZ*)(orig & ~1);
9232         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
9233         *ret_conv = CResult_RouteDecodeErrorZ_clone(orig_conv);
9234         return (uint64_t)ret_conv;
9235 }
9236
9237 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1some(JNIEnv *env, jclass clz, int64_t o) {
9238         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
9239         *ret_copy = COption_u64Z_some(o);
9240         uint64_t ret_ref = (uint64_t)ret_copy;
9241         return ret_ref;
9242 }
9243
9244 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1none(JNIEnv *env, jclass clz) {
9245         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
9246         *ret_copy = COption_u64Z_none();
9247         uint64_t ret_ref = (uint64_t)ret_copy;
9248         return ret_ref;
9249 }
9250
9251 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
9252         if ((_res & 1) != 0) return;
9253         LDKCOption_u64Z _res_conv = *(LDKCOption_u64Z*)(((uint64_t)_res) & ~1);
9254         FREE((void*)_res);
9255         COption_u64Z_free(_res_conv);
9256 }
9257
9258 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9259         LDKCOption_u64Z* orig_conv = (LDKCOption_u64Z*)orig;
9260         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
9261         *ret_copy = COption_u64Z_clone(orig_conv);
9262         uint64_t ret_ref = (uint64_t)ret_copy;
9263         return ret_ref;
9264 }
9265
9266 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ChannelDetailsZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
9267         LDKCVec_ChannelDetailsZ _res_constr;
9268         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
9269         if (_res_constr.datalen > 0)
9270                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
9271         else
9272                 _res_constr.data = NULL;
9273         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
9274         for (size_t q = 0; q < _res_constr.datalen; q++) {
9275                 int64_t _res_conv_16 = _res_vals[q];
9276                 LDKChannelDetails _res_conv_16_conv;
9277                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
9278                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
9279                 _res_constr.data[q] = _res_conv_16_conv;
9280         }
9281         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
9282         CVec_ChannelDetailsZ_free(_res_constr);
9283 }
9284
9285 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHintZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
9286         LDKCVec_RouteHintZ _res_constr;
9287         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
9288         if (_res_constr.datalen > 0)
9289                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
9290         else
9291                 _res_constr.data = NULL;
9292         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
9293         for (size_t l = 0; l < _res_constr.datalen; l++) {
9294                 int64_t _res_conv_11 = _res_vals[l];
9295                 LDKRouteHint _res_conv_11_conv;
9296                 _res_conv_11_conv.inner = (void*)(_res_conv_11 & (~1));
9297                 _res_conv_11_conv.is_owned = (_res_conv_11 & 1) || (_res_conv_11 == 0);
9298                 _res_constr.data[l] = _res_conv_11_conv;
9299         }
9300         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
9301         CVec_RouteHintZ_free(_res_constr);
9302 }
9303
9304 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9305         LDKRoute o_conv;
9306         o_conv.inner = (void*)(o & (~1));
9307         o_conv.is_owned = (o & 1) || (o == 0);
9308         o_conv = Route_clone(&o_conv);
9309         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
9310         *ret_conv = CResult_RouteLightningErrorZ_ok(o_conv);
9311         return (uint64_t)ret_conv;
9312 }
9313
9314 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9315         LDKLightningError e_conv;
9316         e_conv.inner = (void*)(e & (~1));
9317         e_conv.is_owned = (e & 1) || (e == 0);
9318         e_conv = LightningError_clone(&e_conv);
9319         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
9320         *ret_conv = CResult_RouteLightningErrorZ_err(e_conv);
9321         return (uint64_t)ret_conv;
9322 }
9323
9324 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9325         if ((_res & 1) != 0) return;
9326         LDKCResult_RouteLightningErrorZ _res_conv = *(LDKCResult_RouteLightningErrorZ*)(((uint64_t)_res) & ~1);
9327         FREE((void*)_res);
9328         CResult_RouteLightningErrorZ_free(_res_conv);
9329 }
9330
9331 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9332         LDKCResult_RouteLightningErrorZ* orig_conv = (LDKCResult_RouteLightningErrorZ*)(orig & ~1);
9333         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
9334         *ret_conv = CResult_RouteLightningErrorZ_clone(orig_conv);
9335         return (uint64_t)ret_conv;
9336 }
9337
9338 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9339         LDKTxOut o_conv = *(LDKTxOut*)(((uint64_t)o) & ~1);
9340         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
9341         *ret_conv = CResult_TxOutAccessErrorZ_ok(o_conv);
9342         return (uint64_t)ret_conv;
9343 }
9344
9345 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
9346         LDKAccessError e_conv = LDKAccessError_from_java(env, e);
9347         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
9348         *ret_conv = CResult_TxOutAccessErrorZ_err(e_conv);
9349         return (uint64_t)ret_conv;
9350 }
9351
9352 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9353         if ((_res & 1) != 0) return;
9354         LDKCResult_TxOutAccessErrorZ _res_conv = *(LDKCResult_TxOutAccessErrorZ*)(((uint64_t)_res) & ~1);
9355         FREE((void*)_res);
9356         CResult_TxOutAccessErrorZ_free(_res_conv);
9357 }
9358
9359 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9360         LDKCResult_TxOutAccessErrorZ* orig_conv = (LDKCResult_TxOutAccessErrorZ*)(orig & ~1);
9361         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
9362         *ret_conv = CResult_TxOutAccessErrorZ_clone(orig_conv);
9363         return (uint64_t)ret_conv;
9364 }
9365
9366 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9367         LDKC2Tuple_usizeTransactionZ* orig_conv = (LDKC2Tuple_usizeTransactionZ*)(orig & ~1);
9368         LDKC2Tuple_usizeTransactionZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
9369         *ret_ref = C2Tuple_usizeTransactionZ_clone(orig_conv);
9370         return (uint64_t)ret_ref;
9371 }
9372
9373 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
9374         LDKTransaction b_ref;
9375         b_ref.datalen = (*env)->GetArrayLength(env, b);
9376         b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
9377         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
9378         b_ref.data_is_owned = true;
9379         LDKC2Tuple_usizeTransactionZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
9380         *ret_ref = C2Tuple_usizeTransactionZ_new(a, b_ref);
9381         return (uint64_t)ret_ref;
9382 }
9383
9384 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9385         if ((_res & 1) != 0) return;
9386         LDKC2Tuple_usizeTransactionZ _res_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)_res) & ~1);
9387         FREE((void*)_res);
9388         C2Tuple_usizeTransactionZ_free(_res_conv);
9389 }
9390
9391 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1usizeTransactionZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
9392         LDKCVec_C2Tuple_usizeTransactionZZ _res_constr;
9393         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
9394         if (_res_constr.datalen > 0)
9395                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
9396         else
9397                 _res_constr.data = NULL;
9398         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
9399         for (size_t y = 0; y < _res_constr.datalen; y++) {
9400                 int64_t _res_conv_24 = _res_vals[y];
9401                 LDKC2Tuple_usizeTransactionZ _res_conv_24_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)_res_conv_24) & ~1);
9402                 FREE((void*)_res_conv_24);
9403                 _res_constr.data[y] = _res_conv_24_conv;
9404         }
9405         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
9406         CVec_C2Tuple_usizeTransactionZZ_free(_res_constr);
9407 }
9408
9409 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TxidZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
9410         LDKCVec_TxidZ _res_constr;
9411         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
9412         if (_res_constr.datalen > 0)
9413                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
9414         else
9415                 _res_constr.data = NULL;
9416         for (size_t i = 0; i < _res_constr.datalen; i++) {
9417                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
9418                 LDKThirtyTwoBytes _res_conv_8_ref;
9419                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 32);
9420                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 32, _res_conv_8_ref.data);
9421                 _res_constr.data[i] = _res_conv_8_ref;
9422         }
9423         CVec_TxidZ_free(_res_constr);
9424 }
9425
9426 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1ok(JNIEnv *env, jclass clz) {
9427         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
9428         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_ok();
9429         return (uint64_t)ret_conv;
9430 }
9431
9432 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1err(JNIEnv *env, jclass clz, jclass e) {
9433         LDKChannelMonitorUpdateErr e_conv = LDKChannelMonitorUpdateErr_from_java(env, e);
9434         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
9435         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_err(e_conv);
9436         return (uint64_t)ret_conv;
9437 }
9438
9439 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9440         if ((_res & 1) != 0) return;
9441         LDKCResult_NoneChannelMonitorUpdateErrZ _res_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)_res) & ~1);
9442         FREE((void*)_res);
9443         CResult_NoneChannelMonitorUpdateErrZ_free(_res_conv);
9444 }
9445
9446 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9447         LDKCResult_NoneChannelMonitorUpdateErrZ* orig_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(orig & ~1);
9448         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
9449         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone(orig_conv);
9450         return (uint64_t)ret_conv;
9451 }
9452
9453 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1MonitorEventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
9454         LDKCVec_MonitorEventZ _res_constr;
9455         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
9456         if (_res_constr.datalen > 0)
9457                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
9458         else
9459                 _res_constr.data = NULL;
9460         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
9461         for (size_t o = 0; o < _res_constr.datalen; o++) {
9462                 int64_t _res_conv_14 = _res_vals[o];
9463                 LDKMonitorEvent _res_conv_14_conv = *(LDKMonitorEvent*)(((uint64_t)_res_conv_14) & ~1);
9464                 FREE((void*)_res_conv_14);
9465                 _res_constr.data[o] = _res_conv_14_conv;
9466         }
9467         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
9468         CVec_MonitorEventZ_free(_res_constr);
9469 }
9470
9471 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1some(JNIEnv *env, jclass clz, int64_t o) {
9472         LDKC2Tuple_usizeTransactionZ o_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)o) & ~1);
9473         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
9474         *ret_copy = COption_C2Tuple_usizeTransactionZZ_some(o_conv);
9475         uint64_t ret_ref = (uint64_t)ret_copy;
9476         return ret_ref;
9477 }
9478
9479 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1none(JNIEnv *env, jclass clz) {
9480         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
9481         *ret_copy = COption_C2Tuple_usizeTransactionZZ_none();
9482         uint64_t ret_ref = (uint64_t)ret_copy;
9483         return ret_ref;
9484 }
9485
9486 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9487         if ((_res & 1) != 0) return;
9488         LDKCOption_C2Tuple_usizeTransactionZZ _res_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(((uint64_t)_res) & ~1);
9489         FREE((void*)_res);
9490         COption_C2Tuple_usizeTransactionZZ_free(_res_conv);
9491 }
9492
9493 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9494         LDKCOption_C2Tuple_usizeTransactionZZ* orig_conv = (LDKCOption_C2Tuple_usizeTransactionZZ*)orig;
9495         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
9496         *ret_copy = COption_C2Tuple_usizeTransactionZZ_clone(orig_conv);
9497         uint64_t ret_ref = (uint64_t)ret_copy;
9498         return ret_ref;
9499 }
9500
9501 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1SpendableOutputDescriptorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
9502         LDKCVec_SpendableOutputDescriptorZ _res_constr;
9503         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
9504         if (_res_constr.datalen > 0)
9505                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
9506         else
9507                 _res_constr.data = NULL;
9508         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
9509         for (size_t b = 0; b < _res_constr.datalen; b++) {
9510                 int64_t _res_conv_27 = _res_vals[b];
9511                 LDKSpendableOutputDescriptor _res_conv_27_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)_res_conv_27) & ~1);
9512                 FREE((void*)_res_conv_27);
9513                 _res_constr.data[b] = _res_conv_27_conv;
9514         }
9515         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
9516         CVec_SpendableOutputDescriptorZ_free(_res_constr);
9517 }
9518
9519 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1MessageSendEventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
9520         LDKCVec_MessageSendEventZ _res_constr;
9521         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
9522         if (_res_constr.datalen > 0)
9523                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
9524         else
9525                 _res_constr.data = NULL;
9526         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
9527         for (size_t s = 0; s < _res_constr.datalen; s++) {
9528                 int64_t _res_conv_18 = _res_vals[s];
9529                 LDKMessageSendEvent _res_conv_18_conv = *(LDKMessageSendEvent*)(((uint64_t)_res_conv_18) & ~1);
9530                 FREE((void*)_res_conv_18);
9531                 _res_constr.data[s] = _res_conv_18_conv;
9532         }
9533         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
9534         CVec_MessageSendEventZ_free(_res_constr);
9535 }
9536
9537 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9538         LDKInitFeatures o_conv;
9539         o_conv.inner = (void*)(o & (~1));
9540         o_conv.is_owned = (o & 1) || (o == 0);
9541         o_conv = InitFeatures_clone(&o_conv);
9542         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
9543         *ret_conv = CResult_InitFeaturesDecodeErrorZ_ok(o_conv);
9544         return (uint64_t)ret_conv;
9545 }
9546
9547 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9548         LDKDecodeError e_conv;
9549         e_conv.inner = (void*)(e & (~1));
9550         e_conv.is_owned = (e & 1) || (e == 0);
9551         e_conv = DecodeError_clone(&e_conv);
9552         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
9553         *ret_conv = CResult_InitFeaturesDecodeErrorZ_err(e_conv);
9554         return (uint64_t)ret_conv;
9555 }
9556
9557 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9558         if ((_res & 1) != 0) return;
9559         LDKCResult_InitFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InitFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
9560         FREE((void*)_res);
9561         CResult_InitFeaturesDecodeErrorZ_free(_res_conv);
9562 }
9563
9564 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9565         LDKNodeFeatures o_conv;
9566         o_conv.inner = (void*)(o & (~1));
9567         o_conv.is_owned = (o & 1) || (o == 0);
9568         o_conv = NodeFeatures_clone(&o_conv);
9569         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
9570         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_ok(o_conv);
9571         return (uint64_t)ret_conv;
9572 }
9573
9574 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9575         LDKDecodeError e_conv;
9576         e_conv.inner = (void*)(e & (~1));
9577         e_conv.is_owned = (e & 1) || (e == 0);
9578         e_conv = DecodeError_clone(&e_conv);
9579         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
9580         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_err(e_conv);
9581         return (uint64_t)ret_conv;
9582 }
9583
9584 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9585         if ((_res & 1) != 0) return;
9586         LDKCResult_NodeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_NodeFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
9587         FREE((void*)_res);
9588         CResult_NodeFeaturesDecodeErrorZ_free(_res_conv);
9589 }
9590
9591 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9592         LDKChannelFeatures o_conv;
9593         o_conv.inner = (void*)(o & (~1));
9594         o_conv.is_owned = (o & 1) || (o == 0);
9595         o_conv = ChannelFeatures_clone(&o_conv);
9596         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
9597         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_ok(o_conv);
9598         return (uint64_t)ret_conv;
9599 }
9600
9601 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9602         LDKDecodeError e_conv;
9603         e_conv.inner = (void*)(e & (~1));
9604         e_conv.is_owned = (e & 1) || (e == 0);
9605         e_conv = DecodeError_clone(&e_conv);
9606         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
9607         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_err(e_conv);
9608         return (uint64_t)ret_conv;
9609 }
9610
9611 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9612         if ((_res & 1) != 0) return;
9613         LDKCResult_ChannelFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
9614         FREE((void*)_res);
9615         CResult_ChannelFeaturesDecodeErrorZ_free(_res_conv);
9616 }
9617
9618 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9619         LDKInvoiceFeatures o_conv;
9620         o_conv.inner = (void*)(o & (~1));
9621         o_conv.is_owned = (o & 1) || (o == 0);
9622         o_conv = InvoiceFeatures_clone(&o_conv);
9623         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
9624         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_ok(o_conv);
9625         return (uint64_t)ret_conv;
9626 }
9627
9628 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9629         LDKDecodeError e_conv;
9630         e_conv.inner = (void*)(e & (~1));
9631         e_conv.is_owned = (e & 1) || (e == 0);
9632         e_conv = DecodeError_clone(&e_conv);
9633         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
9634         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_err(e_conv);
9635         return (uint64_t)ret_conv;
9636 }
9637
9638 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9639         if ((_res & 1) != 0) return;
9640         LDKCResult_InvoiceFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InvoiceFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
9641         FREE((void*)_res);
9642         CResult_InvoiceFeaturesDecodeErrorZ_free(_res_conv);
9643 }
9644
9645 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9646         LDKDelayedPaymentOutputDescriptor o_conv;
9647         o_conv.inner = (void*)(o & (~1));
9648         o_conv.is_owned = (o & 1) || (o == 0);
9649         o_conv = DelayedPaymentOutputDescriptor_clone(&o_conv);
9650         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
9651         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
9652         return (uint64_t)ret_conv;
9653 }
9654
9655 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9656         LDKDecodeError e_conv;
9657         e_conv.inner = (void*)(e & (~1));
9658         e_conv.is_owned = (e & 1) || (e == 0);
9659         e_conv = DecodeError_clone(&e_conv);
9660         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
9661         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
9662         return (uint64_t)ret_conv;
9663 }
9664
9665 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9666         if ((_res & 1) != 0) return;
9667         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(((uint64_t)_res) & ~1);
9668         FREE((void*)_res);
9669         CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
9670 }
9671
9672 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9673         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(orig & ~1);
9674         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
9675         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
9676         return (uint64_t)ret_conv;
9677 }
9678
9679 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9680         LDKStaticPaymentOutputDescriptor o_conv;
9681         o_conv.inner = (void*)(o & (~1));
9682         o_conv.is_owned = (o & 1) || (o == 0);
9683         o_conv = StaticPaymentOutputDescriptor_clone(&o_conv);
9684         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
9685         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
9686         return (uint64_t)ret_conv;
9687 }
9688
9689 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9690         LDKDecodeError e_conv;
9691         e_conv.inner = (void*)(e & (~1));
9692         e_conv.is_owned = (e & 1) || (e == 0);
9693         e_conv = DecodeError_clone(&e_conv);
9694         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
9695         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
9696         return (uint64_t)ret_conv;
9697 }
9698
9699 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9700         if ((_res & 1) != 0) return;
9701         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(((uint64_t)_res) & ~1);
9702         FREE((void*)_res);
9703         CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
9704 }
9705
9706 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9707         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(orig & ~1);
9708         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
9709         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
9710         return (uint64_t)ret_conv;
9711 }
9712
9713 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9714         LDKSpendableOutputDescriptor o_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)o) & ~1);
9715         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
9716         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_ok(o_conv);
9717         return (uint64_t)ret_conv;
9718 }
9719
9720 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9721         LDKDecodeError e_conv;
9722         e_conv.inner = (void*)(e & (~1));
9723         e_conv.is_owned = (e & 1) || (e == 0);
9724         e_conv = DecodeError_clone(&e_conv);
9725         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
9726         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_err(e_conv);
9727         return (uint64_t)ret_conv;
9728 }
9729
9730 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9731         if ((_res & 1) != 0) return;
9732         LDKCResult_SpendableOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(((uint64_t)_res) & ~1);
9733         FREE((void*)_res);
9734         CResult_SpendableOutputDescriptorDecodeErrorZ_free(_res_conv);
9735 }
9736
9737 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9738         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(orig & ~1);
9739         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
9740         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(orig_conv);
9741         return (uint64_t)ret_conv;
9742 }
9743
9744 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9745         LDKC2Tuple_SignatureCVec_SignatureZZ* orig_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(orig & ~1);
9746         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
9747         *ret_ref = C2Tuple_SignatureCVec_SignatureZZ_clone(orig_conv);
9748         return (uint64_t)ret_ref;
9749 }
9750
9751 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, jobjectArray b) {
9752         LDKSignature a_ref;
9753         CHECK((*env)->GetArrayLength(env, a) == 64);
9754         (*env)->GetByteArrayRegion(env, a, 0, 64, a_ref.compact_form);
9755         LDKCVec_SignatureZ b_constr;
9756         b_constr.datalen = (*env)->GetArrayLength(env, b);
9757         if (b_constr.datalen > 0)
9758                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
9759         else
9760                 b_constr.data = NULL;
9761         for (size_t i = 0; i < b_constr.datalen; i++) {
9762                 int8_tArray b_conv_8 = (*env)->GetObjectArrayElement(env, b, i);
9763                 LDKSignature b_conv_8_ref;
9764                 CHECK((*env)->GetArrayLength(env, b_conv_8) == 64);
9765                 (*env)->GetByteArrayRegion(env, b_conv_8, 0, 64, b_conv_8_ref.compact_form);
9766                 b_constr.data[i] = b_conv_8_ref;
9767         }
9768         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
9769         *ret_ref = C2Tuple_SignatureCVec_SignatureZZ_new(a_ref, b_constr);
9770         return (uint64_t)ret_ref;
9771 }
9772
9773 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9774         if ((_res & 1) != 0) return;
9775         LDKC2Tuple_SignatureCVec_SignatureZZ _res_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(((uint64_t)_res) & ~1);
9776         FREE((void*)_res);
9777         C2Tuple_SignatureCVec_SignatureZZ_free(_res_conv);
9778 }
9779
9780 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9781         LDKC2Tuple_SignatureCVec_SignatureZZ o_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(((uint64_t)o) & ~1);
9782         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
9783         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(o_conv);
9784         return (uint64_t)ret_conv;
9785 }
9786
9787 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1err(JNIEnv *env, jclass clz) {
9788         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
9789         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err();
9790         return (uint64_t)ret_conv;
9791 }
9792
9793 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9794         if ((_res & 1) != 0) return;
9795         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ _res_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)_res) & ~1);
9796         FREE((void*)_res);
9797         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(_res_conv);
9798 }
9799
9800 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9801         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* orig_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(orig & ~1);
9802         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
9803         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(orig_conv);
9804         return (uint64_t)ret_conv;
9805 }
9806
9807 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
9808         LDKSignature o_ref;
9809         CHECK((*env)->GetArrayLength(env, o) == 64);
9810         (*env)->GetByteArrayRegion(env, o, 0, 64, o_ref.compact_form);
9811         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
9812         *ret_conv = CResult_SignatureNoneZ_ok(o_ref);
9813         return (uint64_t)ret_conv;
9814 }
9815
9816 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1err(JNIEnv *env, jclass clz) {
9817         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
9818         *ret_conv = CResult_SignatureNoneZ_err();
9819         return (uint64_t)ret_conv;
9820 }
9821
9822 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9823         if ((_res & 1) != 0) return;
9824         LDKCResult_SignatureNoneZ _res_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)_res) & ~1);
9825         FREE((void*)_res);
9826         CResult_SignatureNoneZ_free(_res_conv);
9827 }
9828
9829 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9830         LDKCResult_SignatureNoneZ* orig_conv = (LDKCResult_SignatureNoneZ*)(orig & ~1);
9831         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
9832         *ret_conv = CResult_SignatureNoneZ_clone(orig_conv);
9833         return (uint64_t)ret_conv;
9834 }
9835
9836 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9837         LDKSign o_conv = *(LDKSign*)(((uint64_t)o) & ~1);
9838         if (o_conv.free == LDKSign_JCalls_free) {
9839                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
9840                 LDKSign_JCalls_clone(o_conv.this_arg);
9841         }
9842         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
9843         *ret_conv = CResult_SignDecodeErrorZ_ok(o_conv);
9844         return (uint64_t)ret_conv;
9845 }
9846
9847 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9848         LDKDecodeError e_conv;
9849         e_conv.inner = (void*)(e & (~1));
9850         e_conv.is_owned = (e & 1) || (e == 0);
9851         e_conv = DecodeError_clone(&e_conv);
9852         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
9853         *ret_conv = CResult_SignDecodeErrorZ_err(e_conv);
9854         return (uint64_t)ret_conv;
9855 }
9856
9857 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9858         if ((_res & 1) != 0) return;
9859         LDKCResult_SignDecodeErrorZ _res_conv = *(LDKCResult_SignDecodeErrorZ*)(((uint64_t)_res) & ~1);
9860         FREE((void*)_res);
9861         CResult_SignDecodeErrorZ_free(_res_conv);
9862 }
9863
9864 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9865         LDKCResult_SignDecodeErrorZ* orig_conv = (LDKCResult_SignDecodeErrorZ*)(orig & ~1);
9866         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
9867         *ret_conv = CResult_SignDecodeErrorZ_clone(orig_conv);
9868         return (uint64_t)ret_conv;
9869 }
9870
9871 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u8Z_1free(JNIEnv *env, jclass clz, int8_tArray _res) {
9872         LDKCVec_u8Z _res_ref;
9873         _res_ref.datalen = (*env)->GetArrayLength(env, _res);
9874         _res_ref.data = MALLOC(_res_ref.datalen, "LDKCVec_u8Z Bytes");
9875         (*env)->GetByteArrayRegion(env, _res, 0, _res_ref.datalen, _res_ref.data);
9876         CVec_u8Z_free(_res_ref);
9877 }
9878
9879 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray arg) {
9880         LDKRecoverableSignature arg_ref;
9881         CHECK((*env)->GetArrayLength(env, arg) == 68);
9882         (*env)->GetByteArrayRegion(env, arg, 0, 68, arg_ref.serialized_form);
9883         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
9884         *ret_conv = CResult_RecoverableSignatureNoneZ_ok(arg_ref);
9885         return (uint64_t)ret_conv;
9886 }
9887
9888 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1err(JNIEnv *env, jclass clz) {
9889         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
9890         *ret_conv = CResult_RecoverableSignatureNoneZ_err();
9891         return (uint64_t)ret_conv;
9892 }
9893
9894 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9895         if ((_res & 1) != 0) return;
9896         LDKCResult_RecoverableSignatureNoneZ _res_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(((uint64_t)_res) & ~1);
9897         FREE((void*)_res);
9898         CResult_RecoverableSignatureNoneZ_free(_res_conv);
9899 }
9900
9901 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9902         LDKCResult_RecoverableSignatureNoneZ* orig_conv = (LDKCResult_RecoverableSignatureNoneZ*)(orig & ~1);
9903         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
9904         *ret_conv = CResult_RecoverableSignatureNoneZ_clone(orig_conv);
9905         return (uint64_t)ret_conv;
9906 }
9907
9908 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CVec_1u8ZZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
9909         LDKCVec_CVec_u8ZZ _res_constr;
9910         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
9911         if (_res_constr.datalen > 0)
9912                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
9913         else
9914                 _res_constr.data = NULL;
9915         for (size_t i = 0; i < _res_constr.datalen; i++) {
9916                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
9917                 LDKCVec_u8Z _res_conv_8_ref;
9918                 _res_conv_8_ref.datalen = (*env)->GetArrayLength(env, _res_conv_8);
9919                 _res_conv_8_ref.data = MALLOC(_res_conv_8_ref.datalen, "LDKCVec_u8Z Bytes");
9920                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, _res_conv_8_ref.datalen, _res_conv_8_ref.data);
9921                 _res_constr.data[i] = _res_conv_8_ref;
9922         }
9923         CVec_CVec_u8ZZ_free(_res_constr);
9924 }
9925
9926 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1ok(JNIEnv *env, jclass clz, jobjectArray o) {
9927         LDKCVec_CVec_u8ZZ o_constr;
9928         o_constr.datalen = (*env)->GetArrayLength(env, o);
9929         if (o_constr.datalen > 0)
9930                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
9931         else
9932                 o_constr.data = NULL;
9933         for (size_t i = 0; i < o_constr.datalen; i++) {
9934                 int8_tArray o_conv_8 = (*env)->GetObjectArrayElement(env, o, i);
9935                 LDKCVec_u8Z o_conv_8_ref;
9936                 o_conv_8_ref.datalen = (*env)->GetArrayLength(env, o_conv_8);
9937                 o_conv_8_ref.data = MALLOC(o_conv_8_ref.datalen, "LDKCVec_u8Z Bytes");
9938                 (*env)->GetByteArrayRegion(env, o_conv_8, 0, o_conv_8_ref.datalen, o_conv_8_ref.data);
9939                 o_constr.data[i] = o_conv_8_ref;
9940         }
9941         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
9942         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_ok(o_constr);
9943         return (uint64_t)ret_conv;
9944 }
9945
9946 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1err(JNIEnv *env, jclass clz) {
9947         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
9948         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_err();
9949         return (uint64_t)ret_conv;
9950 }
9951
9952 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9953         if ((_res & 1) != 0) return;
9954         LDKCResult_CVec_CVec_u8ZZNoneZ _res_conv = *(LDKCResult_CVec_CVec_u8ZZNoneZ*)(((uint64_t)_res) & ~1);
9955         FREE((void*)_res);
9956         CResult_CVec_CVec_u8ZZNoneZ_free(_res_conv);
9957 }
9958
9959 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9960         LDKCResult_CVec_CVec_u8ZZNoneZ* orig_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(orig & ~1);
9961         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
9962         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(orig_conv);
9963         return (uint64_t)ret_conv;
9964 }
9965
9966 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9967         LDKInMemorySigner o_conv;
9968         o_conv.inner = (void*)(o & (~1));
9969         o_conv.is_owned = (o & 1) || (o == 0);
9970         o_conv = InMemorySigner_clone(&o_conv);
9971         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
9972         *ret_conv = CResult_InMemorySignerDecodeErrorZ_ok(o_conv);
9973         return (uint64_t)ret_conv;
9974 }
9975
9976 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9977         LDKDecodeError e_conv;
9978         e_conv.inner = (void*)(e & (~1));
9979         e_conv.is_owned = (e & 1) || (e == 0);
9980         e_conv = DecodeError_clone(&e_conv);
9981         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
9982         *ret_conv = CResult_InMemorySignerDecodeErrorZ_err(e_conv);
9983         return (uint64_t)ret_conv;
9984 }
9985
9986 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9987         if ((_res & 1) != 0) return;
9988         LDKCResult_InMemorySignerDecodeErrorZ _res_conv = *(LDKCResult_InMemorySignerDecodeErrorZ*)(((uint64_t)_res) & ~1);
9989         FREE((void*)_res);
9990         CResult_InMemorySignerDecodeErrorZ_free(_res_conv);
9991 }
9992
9993 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9994         LDKCResult_InMemorySignerDecodeErrorZ* orig_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(orig & ~1);
9995         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
9996         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(orig_conv);
9997         return (uint64_t)ret_conv;
9998 }
9999
10000 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TxOutZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
10001         LDKCVec_TxOutZ _res_constr;
10002         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
10003         if (_res_constr.datalen > 0)
10004                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
10005         else
10006                 _res_constr.data = NULL;
10007         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
10008         for (size_t h = 0; h < _res_constr.datalen; h++) {
10009                 int64_t _res_conv_7 = _res_vals[h];
10010                 LDKTxOut _res_conv_7_conv = *(LDKTxOut*)(((uint64_t)_res_conv_7) & ~1);
10011                 FREE((void*)_res_conv_7);
10012                 _res_constr.data[h] = _res_conv_7_conv;
10013         }
10014         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
10015         CVec_TxOutZ_free(_res_constr);
10016 }
10017
10018 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
10019         LDKTransaction o_ref;
10020         o_ref.datalen = (*env)->GetArrayLength(env, o);
10021         o_ref.data = MALLOC(o_ref.datalen, "LDKTransaction Bytes");
10022         (*env)->GetByteArrayRegion(env, o, 0, o_ref.datalen, o_ref.data);
10023         o_ref.data_is_owned = true;
10024         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
10025         *ret_conv = CResult_TransactionNoneZ_ok(o_ref);
10026         return (uint64_t)ret_conv;
10027 }
10028
10029 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1err(JNIEnv *env, jclass clz) {
10030         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
10031         *ret_conv = CResult_TransactionNoneZ_err();
10032         return (uint64_t)ret_conv;
10033 }
10034
10035 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10036         if ((_res & 1) != 0) return;
10037         LDKCResult_TransactionNoneZ _res_conv = *(LDKCResult_TransactionNoneZ*)(((uint64_t)_res) & ~1);
10038         FREE((void*)_res);
10039         CResult_TransactionNoneZ_free(_res_conv);
10040 }
10041
10042 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10043         LDKCResult_TransactionNoneZ* orig_conv = (LDKCResult_TransactionNoneZ*)(orig & ~1);
10044         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
10045         *ret_conv = CResult_TransactionNoneZ_clone(orig_conv);
10046         return (uint64_t)ret_conv;
10047 }
10048
10049 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
10050         LDKThirtyTwoBytes a_ref;
10051         CHECK((*env)->GetArrayLength(env, a) == 32);
10052         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
10053         LDKChannelMonitor b_conv;
10054         b_conv.inner = (void*)(b & (~1));
10055         b_conv.is_owned = (b & 1) || (b == 0);
10056         b_conv = ChannelMonitor_clone(&b_conv);
10057         LDKC2Tuple_BlockHashChannelMonitorZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
10058         *ret_ref = C2Tuple_BlockHashChannelMonitorZ_new(a_ref, b_conv);
10059         return (uint64_t)ret_ref;
10060 }
10061
10062 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10063         if ((_res & 1) != 0) return;
10064         LDKC2Tuple_BlockHashChannelMonitorZ _res_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)_res) & ~1);
10065         FREE((void*)_res);
10066         C2Tuple_BlockHashChannelMonitorZ_free(_res_conv);
10067 }
10068
10069 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1BlockHashChannelMonitorZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
10070         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ _res_constr;
10071         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
10072         if (_res_constr.datalen > 0)
10073                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Elements");
10074         else
10075                 _res_constr.data = NULL;
10076         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
10077         for (size_t i = 0; i < _res_constr.datalen; i++) {
10078                 int64_t _res_conv_34 = _res_vals[i];
10079                 LDKC2Tuple_BlockHashChannelMonitorZ _res_conv_34_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)_res_conv_34) & ~1);
10080                 FREE((void*)_res_conv_34);
10081                 _res_constr.data[i] = _res_conv_34_conv;
10082         }
10083         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
10084         CVec_C2Tuple_BlockHashChannelMonitorZZ_free(_res_constr);
10085 }
10086
10087 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1ok(JNIEnv *env, jclass clz, int64_tArray o) {
10088         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ o_constr;
10089         o_constr.datalen = (*env)->GetArrayLength(env, o);
10090         if (o_constr.datalen > 0)
10091                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Elements");
10092         else
10093                 o_constr.data = NULL;
10094         int64_t* o_vals = (*env)->GetLongArrayElements (env, o, NULL);
10095         for (size_t i = 0; i < o_constr.datalen; i++) {
10096                 int64_t o_conv_34 = o_vals[i];
10097                 LDKC2Tuple_BlockHashChannelMonitorZ o_conv_34_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)o_conv_34) & ~1);
10098                 // Warning: we may need a move here but no clone is available for LDKC2Tuple_BlockHashChannelMonitorZ
10099                 o_constr.data[i] = o_conv_34_conv;
10100         }
10101         (*env)->ReleaseLongArrayElements(env, o, o_vals, 0);
10102         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
10103         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_ok(o_constr);
10104         return (uint64_t)ret_conv;
10105 }
10106
10107 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
10108         LDKIOError e_conv = LDKIOError_from_java(env, e);
10109         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
10110         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_err(e_conv);
10111         return (uint64_t)ret_conv;
10112 }
10113
10114 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10115         if ((_res & 1) != 0) return;
10116         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ _res_conv = *(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(((uint64_t)_res) & ~1);
10117         FREE((void*)_res);
10118         CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_free(_res_conv);
10119 }
10120
10121 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1ok(JNIEnv *env, jclass clz) {
10122         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
10123         *ret_conv = CResult_NoneAPIErrorZ_ok();
10124         return (uint64_t)ret_conv;
10125 }
10126
10127 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10128         LDKAPIError e_conv = *(LDKAPIError*)(((uint64_t)e) & ~1);
10129         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
10130         *ret_conv = CResult_NoneAPIErrorZ_err(e_conv);
10131         return (uint64_t)ret_conv;
10132 }
10133
10134 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10135         if ((_res & 1) != 0) return;
10136         LDKCResult_NoneAPIErrorZ _res_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)_res) & ~1);
10137         FREE((void*)_res);
10138         CResult_NoneAPIErrorZ_free(_res_conv);
10139 }
10140
10141 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10142         LDKCResult_NoneAPIErrorZ* orig_conv = (LDKCResult_NoneAPIErrorZ*)(orig & ~1);
10143         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
10144         *ret_conv = CResult_NoneAPIErrorZ_clone(orig_conv);
10145         return (uint64_t)ret_conv;
10146 }
10147
10148 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CResult_1NoneAPIErrorZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
10149         LDKCVec_CResult_NoneAPIErrorZZ _res_constr;
10150         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
10151         if (_res_constr.datalen > 0)
10152                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
10153         else
10154                 _res_constr.data = NULL;
10155         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
10156         for (size_t w = 0; w < _res_constr.datalen; w++) {
10157                 int64_t _res_conv_22 = _res_vals[w];
10158                 LDKCResult_NoneAPIErrorZ _res_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)_res_conv_22) & ~1);
10159                 FREE((void*)_res_conv_22);
10160                 _res_constr.data[w] = _res_conv_22_conv;
10161         }
10162         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
10163         CVec_CResult_NoneAPIErrorZZ_free(_res_constr);
10164 }
10165
10166 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1APIErrorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
10167         LDKCVec_APIErrorZ _res_constr;
10168         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
10169         if (_res_constr.datalen > 0)
10170                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
10171         else
10172                 _res_constr.data = NULL;
10173         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
10174         for (size_t k = 0; k < _res_constr.datalen; k++) {
10175                 int64_t _res_conv_10 = _res_vals[k];
10176                 LDKAPIError _res_conv_10_conv = *(LDKAPIError*)(((uint64_t)_res_conv_10) & ~1);
10177                 FREE((void*)_res_conv_10);
10178                 _res_constr.data[k] = _res_conv_10_conv;
10179         }
10180         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
10181         CVec_APIErrorZ_free(_res_constr);
10182 }
10183
10184 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1ok(JNIEnv *env, jclass clz) {
10185         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
10186         *ret_conv = CResult_NonePaymentSendFailureZ_ok();
10187         return (uint64_t)ret_conv;
10188 }
10189
10190 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10191         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(((uint64_t)e) & ~1);
10192         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
10193         *ret_conv = CResult_NonePaymentSendFailureZ_err(e_conv);
10194         return (uint64_t)ret_conv;
10195 }
10196
10197 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10198         if ((_res & 1) != 0) return;
10199         LDKCResult_NonePaymentSendFailureZ _res_conv = *(LDKCResult_NonePaymentSendFailureZ*)(((uint64_t)_res) & ~1);
10200         FREE((void*)_res);
10201         CResult_NonePaymentSendFailureZ_free(_res_conv);
10202 }
10203
10204 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10205         LDKCResult_NonePaymentSendFailureZ* orig_conv = (LDKCResult_NonePaymentSendFailureZ*)(orig & ~1);
10206         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
10207         *ret_conv = CResult_NonePaymentSendFailureZ_clone(orig_conv);
10208         return (uint64_t)ret_conv;
10209 }
10210
10211 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1NetAddressZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
10212         LDKCVec_NetAddressZ _res_constr;
10213         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
10214         if (_res_constr.datalen > 0)
10215                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
10216         else
10217                 _res_constr.data = NULL;
10218         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
10219         for (size_t m = 0; m < _res_constr.datalen; m++) {
10220                 int64_t _res_conv_12 = _res_vals[m];
10221                 LDKNetAddress _res_conv_12_conv = *(LDKNetAddress*)(((uint64_t)_res_conv_12) & ~1);
10222                 FREE((void*)_res_conv_12);
10223                 _res_constr.data[m] = _res_conv_12_conv;
10224         }
10225         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
10226         CVec_NetAddressZ_free(_res_constr);
10227 }
10228
10229 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10230         LDKC2Tuple_PaymentHashPaymentSecretZ* orig_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(orig & ~1);
10231         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
10232         *ret_ref = C2Tuple_PaymentHashPaymentSecretZ_clone(orig_conv);
10233         return (uint64_t)ret_ref;
10234 }
10235
10236 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int8_tArray b) {
10237         LDKThirtyTwoBytes a_ref;
10238         CHECK((*env)->GetArrayLength(env, a) == 32);
10239         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
10240         LDKThirtyTwoBytes b_ref;
10241         CHECK((*env)->GetArrayLength(env, b) == 32);
10242         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
10243         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
10244         *ret_ref = C2Tuple_PaymentHashPaymentSecretZ_new(a_ref, b_ref);
10245         return (uint64_t)ret_ref;
10246 }
10247
10248 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10249         if ((_res & 1) != 0) return;
10250         LDKC2Tuple_PaymentHashPaymentSecretZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(((uint64_t)_res) & ~1);
10251         FREE((void*)_res);
10252         C2Tuple_PaymentHashPaymentSecretZ_free(_res_conv);
10253 }
10254
10255 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
10256         LDKThirtyTwoBytes o_ref;
10257         CHECK((*env)->GetArrayLength(env, o) == 32);
10258         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
10259         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
10260         *ret_conv = CResult_PaymentSecretAPIErrorZ_ok(o_ref);
10261         return (uint64_t)ret_conv;
10262 }
10263
10264 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10265         LDKAPIError e_conv = *(LDKAPIError*)(((uint64_t)e) & ~1);
10266         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
10267         *ret_conv = CResult_PaymentSecretAPIErrorZ_err(e_conv);
10268         return (uint64_t)ret_conv;
10269 }
10270
10271 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10272         if ((_res & 1) != 0) return;
10273         LDKCResult_PaymentSecretAPIErrorZ _res_conv = *(LDKCResult_PaymentSecretAPIErrorZ*)(((uint64_t)_res) & ~1);
10274         FREE((void*)_res);
10275         CResult_PaymentSecretAPIErrorZ_free(_res_conv);
10276 }
10277
10278 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10279         LDKCResult_PaymentSecretAPIErrorZ* orig_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(orig & ~1);
10280         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
10281         *ret_conv = CResult_PaymentSecretAPIErrorZ_clone(orig_conv);
10282         return (uint64_t)ret_conv;
10283 }
10284
10285 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ChannelMonitorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
10286         LDKCVec_ChannelMonitorZ _res_constr;
10287         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
10288         if (_res_constr.datalen > 0)
10289                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
10290         else
10291                 _res_constr.data = NULL;
10292         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
10293         for (size_t q = 0; q < _res_constr.datalen; q++) {
10294                 int64_t _res_conv_16 = _res_vals[q];
10295                 LDKChannelMonitor _res_conv_16_conv;
10296                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
10297                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
10298                 _res_constr.data[q] = _res_conv_16_conv;
10299         }
10300         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
10301         CVec_ChannelMonitorZ_free(_res_constr);
10302 }
10303
10304 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
10305         LDKThirtyTwoBytes a_ref;
10306         CHECK((*env)->GetArrayLength(env, a) == 32);
10307         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
10308         LDKChannelManager b_conv;
10309         b_conv.inner = (void*)(b & (~1));
10310         b_conv.is_owned = (b & 1) || (b == 0);
10311         // Warning: we need a move here but no clone is available for LDKChannelManager
10312         LDKC2Tuple_BlockHashChannelManagerZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
10313         *ret_ref = C2Tuple_BlockHashChannelManagerZ_new(a_ref, b_conv);
10314         return (uint64_t)ret_ref;
10315 }
10316
10317 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10318         if ((_res & 1) != 0) return;
10319         LDKC2Tuple_BlockHashChannelManagerZ _res_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(((uint64_t)_res) & ~1);
10320         FREE((void*)_res);
10321         C2Tuple_BlockHashChannelManagerZ_free(_res_conv);
10322 }
10323
10324 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10325         LDKC2Tuple_BlockHashChannelManagerZ o_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(((uint64_t)o) & ~1);
10326         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
10327         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(o_conv);
10328         return (uint64_t)ret_conv;
10329 }
10330
10331 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10332         LDKDecodeError e_conv;
10333         e_conv.inner = (void*)(e & (~1));
10334         e_conv.is_owned = (e & 1) || (e == 0);
10335         e_conv = DecodeError_clone(&e_conv);
10336         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
10337         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(e_conv);
10338         return (uint64_t)ret_conv;
10339 }
10340
10341 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10342         if ((_res & 1) != 0) return;
10343         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(((uint64_t)_res) & ~1);
10344         FREE((void*)_res);
10345         CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(_res_conv);
10346 }
10347
10348 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10349         LDKChannelConfig o_conv;
10350         o_conv.inner = (void*)(o & (~1));
10351         o_conv.is_owned = (o & 1) || (o == 0);
10352         o_conv = ChannelConfig_clone(&o_conv);
10353         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
10354         *ret_conv = CResult_ChannelConfigDecodeErrorZ_ok(o_conv);
10355         return (uint64_t)ret_conv;
10356 }
10357
10358 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10359         LDKDecodeError e_conv;
10360         e_conv.inner = (void*)(e & (~1));
10361         e_conv.is_owned = (e & 1) || (e == 0);
10362         e_conv = DecodeError_clone(&e_conv);
10363         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
10364         *ret_conv = CResult_ChannelConfigDecodeErrorZ_err(e_conv);
10365         return (uint64_t)ret_conv;
10366 }
10367
10368 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10369         if ((_res & 1) != 0) return;
10370         LDKCResult_ChannelConfigDecodeErrorZ _res_conv = *(LDKCResult_ChannelConfigDecodeErrorZ*)(((uint64_t)_res) & ~1);
10371         FREE((void*)_res);
10372         CResult_ChannelConfigDecodeErrorZ_free(_res_conv);
10373 }
10374
10375 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10376         LDKCResult_ChannelConfigDecodeErrorZ* orig_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(orig & ~1);
10377         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
10378         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(orig_conv);
10379         return (uint64_t)ret_conv;
10380 }
10381
10382 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10383         LDKOutPoint o_conv;
10384         o_conv.inner = (void*)(o & (~1));
10385         o_conv.is_owned = (o & 1) || (o == 0);
10386         o_conv = OutPoint_clone(&o_conv);
10387         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
10388         *ret_conv = CResult_OutPointDecodeErrorZ_ok(o_conv);
10389         return (uint64_t)ret_conv;
10390 }
10391
10392 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10393         LDKDecodeError e_conv;
10394         e_conv.inner = (void*)(e & (~1));
10395         e_conv.is_owned = (e & 1) || (e == 0);
10396         e_conv = DecodeError_clone(&e_conv);
10397         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
10398         *ret_conv = CResult_OutPointDecodeErrorZ_err(e_conv);
10399         return (uint64_t)ret_conv;
10400 }
10401
10402 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10403         if ((_res & 1) != 0) return;
10404         LDKCResult_OutPointDecodeErrorZ _res_conv = *(LDKCResult_OutPointDecodeErrorZ*)(((uint64_t)_res) & ~1);
10405         FREE((void*)_res);
10406         CResult_OutPointDecodeErrorZ_free(_res_conv);
10407 }
10408
10409 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10410         LDKCResult_OutPointDecodeErrorZ* orig_conv = (LDKCResult_OutPointDecodeErrorZ*)(orig & ~1);
10411         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
10412         *ret_conv = CResult_OutPointDecodeErrorZ_clone(orig_conv);
10413         return (uint64_t)ret_conv;
10414 }
10415
10416 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixNoneZ_1ok(JNIEnv *env, jclass clz, jclass o) {
10417         LDKSiPrefix o_conv = LDKSiPrefix_from_java(env, o);
10418         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
10419         *ret_conv = CResult_SiPrefixNoneZ_ok(o_conv);
10420         return (uint64_t)ret_conv;
10421 }
10422
10423 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixNoneZ_1err(JNIEnv *env, jclass clz) {
10424         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
10425         *ret_conv = CResult_SiPrefixNoneZ_err();
10426         return (uint64_t)ret_conv;
10427 }
10428
10429 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10430         if ((_res & 1) != 0) return;
10431         LDKCResult_SiPrefixNoneZ _res_conv = *(LDKCResult_SiPrefixNoneZ*)(((uint64_t)_res) & ~1);
10432         FREE((void*)_res);
10433         CResult_SiPrefixNoneZ_free(_res_conv);
10434 }
10435
10436 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10437         LDKCResult_SiPrefixNoneZ* orig_conv = (LDKCResult_SiPrefixNoneZ*)(orig & ~1);
10438         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
10439         *ret_conv = CResult_SiPrefixNoneZ_clone(orig_conv);
10440         return (uint64_t)ret_conv;
10441 }
10442
10443 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10444         LDKInvoice o_conv;
10445         o_conv.inner = (void*)(o & (~1));
10446         o_conv.is_owned = (o & 1) || (o == 0);
10447         o_conv = Invoice_clone(&o_conv);
10448         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
10449         *ret_conv = CResult_InvoiceNoneZ_ok(o_conv);
10450         return (uint64_t)ret_conv;
10451 }
10452
10453 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceNoneZ_1err(JNIEnv *env, jclass clz) {
10454         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
10455         *ret_conv = CResult_InvoiceNoneZ_err();
10456         return (uint64_t)ret_conv;
10457 }
10458
10459 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10460         if ((_res & 1) != 0) return;
10461         LDKCResult_InvoiceNoneZ _res_conv = *(LDKCResult_InvoiceNoneZ*)(((uint64_t)_res) & ~1);
10462         FREE((void*)_res);
10463         CResult_InvoiceNoneZ_free(_res_conv);
10464 }
10465
10466 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10467         LDKCResult_InvoiceNoneZ* orig_conv = (LDKCResult_InvoiceNoneZ*)(orig & ~1);
10468         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
10469         *ret_conv = CResult_InvoiceNoneZ_clone(orig_conv);
10470         return (uint64_t)ret_conv;
10471 }
10472
10473 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10474         LDKSignedRawInvoice o_conv;
10475         o_conv.inner = (void*)(o & (~1));
10476         o_conv.is_owned = (o & 1) || (o == 0);
10477         o_conv = SignedRawInvoice_clone(&o_conv);
10478         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
10479         *ret_conv = CResult_SignedRawInvoiceNoneZ_ok(o_conv);
10480         return (uint64_t)ret_conv;
10481 }
10482
10483 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceNoneZ_1err(JNIEnv *env, jclass clz) {
10484         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
10485         *ret_conv = CResult_SignedRawInvoiceNoneZ_err();
10486         return (uint64_t)ret_conv;
10487 }
10488
10489 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10490         if ((_res & 1) != 0) return;
10491         LDKCResult_SignedRawInvoiceNoneZ _res_conv = *(LDKCResult_SignedRawInvoiceNoneZ*)(((uint64_t)_res) & ~1);
10492         FREE((void*)_res);
10493         CResult_SignedRawInvoiceNoneZ_free(_res_conv);
10494 }
10495
10496 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10497         LDKCResult_SignedRawInvoiceNoneZ* orig_conv = (LDKCResult_SignedRawInvoiceNoneZ*)(orig & ~1);
10498         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
10499         *ret_conv = CResult_SignedRawInvoiceNoneZ_clone(orig_conv);
10500         return (uint64_t)ret_conv;
10501 }
10502
10503 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10504         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* orig_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(orig & ~1);
10505         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_ref = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
10506         *ret_ref = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(orig_conv);
10507         return (uint64_t)ret_ref;
10508 }
10509
10510 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) {
10511         LDKRawInvoice a_conv;
10512         a_conv.inner = (void*)(a & (~1));
10513         a_conv.is_owned = (a & 1) || (a == 0);
10514         a_conv = RawInvoice_clone(&a_conv);
10515         LDKThirtyTwoBytes b_ref;
10516         CHECK((*env)->GetArrayLength(env, b) == 32);
10517         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
10518         LDKInvoiceSignature c_conv;
10519         c_conv.inner = (void*)(c & (~1));
10520         c_conv.is_owned = (c & 1) || (c == 0);
10521         c_conv = InvoiceSignature_clone(&c_conv);
10522         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_ref = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
10523         *ret_ref = C3Tuple_RawInvoice_u832InvoiceSignatureZ_new(a_conv, b_ref, c_conv);
10524         return (uint64_t)ret_ref;
10525 }
10526
10527 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10528         if ((_res & 1) != 0) return;
10529         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ _res_conv = *(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(((uint64_t)_res) & ~1);
10530         FREE((void*)_res);
10531         C3Tuple_RawInvoice_u832InvoiceSignatureZ_free(_res_conv);
10532 }
10533
10534 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10535         LDKPayeePubKey o_conv;
10536         o_conv.inner = (void*)(o & (~1));
10537         o_conv.is_owned = (o & 1) || (o == 0);
10538         o_conv = PayeePubKey_clone(&o_conv);
10539         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
10540         *ret_conv = CResult_PayeePubKeyErrorZ_ok(o_conv);
10541         return (uint64_t)ret_conv;
10542 }
10543
10544 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
10545         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
10546         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
10547         *ret_conv = CResult_PayeePubKeyErrorZ_err(e_conv);
10548         return (uint64_t)ret_conv;
10549 }
10550
10551 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10552         if ((_res & 1) != 0) return;
10553         LDKCResult_PayeePubKeyErrorZ _res_conv = *(LDKCResult_PayeePubKeyErrorZ*)(((uint64_t)_res) & ~1);
10554         FREE((void*)_res);
10555         CResult_PayeePubKeyErrorZ_free(_res_conv);
10556 }
10557
10558 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10559         LDKCResult_PayeePubKeyErrorZ* orig_conv = (LDKCResult_PayeePubKeyErrorZ*)(orig & ~1);
10560         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
10561         *ret_conv = CResult_PayeePubKeyErrorZ_clone(orig_conv);
10562         return (uint64_t)ret_conv;
10563 }
10564
10565 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PrivateRouteZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
10566         LDKCVec_PrivateRouteZ _res_constr;
10567         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
10568         if (_res_constr.datalen > 0)
10569                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPrivateRoute), "LDKCVec_PrivateRouteZ Elements");
10570         else
10571                 _res_constr.data = NULL;
10572         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
10573         for (size_t o = 0; o < _res_constr.datalen; o++) {
10574                 int64_t _res_conv_14 = _res_vals[o];
10575                 LDKPrivateRoute _res_conv_14_conv;
10576                 _res_conv_14_conv.inner = (void*)(_res_conv_14 & (~1));
10577                 _res_conv_14_conv.is_owned = (_res_conv_14 & 1) || (_res_conv_14 == 0);
10578                 _res_constr.data[o] = _res_conv_14_conv;
10579         }
10580         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
10581         CVec_PrivateRouteZ_free(_res_constr);
10582 }
10583
10584 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10585         LDKPositiveTimestamp o_conv;
10586         o_conv.inner = (void*)(o & (~1));
10587         o_conv.is_owned = (o & 1) || (o == 0);
10588         o_conv = PositiveTimestamp_clone(&o_conv);
10589         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
10590         *ret_conv = CResult_PositiveTimestampCreationErrorZ_ok(o_conv);
10591         return (uint64_t)ret_conv;
10592 }
10593
10594 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
10595         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
10596         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
10597         *ret_conv = CResult_PositiveTimestampCreationErrorZ_err(e_conv);
10598         return (uint64_t)ret_conv;
10599 }
10600
10601 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10602         if ((_res & 1) != 0) return;
10603         LDKCResult_PositiveTimestampCreationErrorZ _res_conv = *(LDKCResult_PositiveTimestampCreationErrorZ*)(((uint64_t)_res) & ~1);
10604         FREE((void*)_res);
10605         CResult_PositiveTimestampCreationErrorZ_free(_res_conv);
10606 }
10607
10608 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10609         LDKCResult_PositiveTimestampCreationErrorZ* orig_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(orig & ~1);
10610         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
10611         *ret_conv = CResult_PositiveTimestampCreationErrorZ_clone(orig_conv);
10612         return (uint64_t)ret_conv;
10613 }
10614
10615 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1ok(JNIEnv *env, jclass clz) {
10616         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
10617         *ret_conv = CResult_NoneSemanticErrorZ_ok();
10618         return (uint64_t)ret_conv;
10619 }
10620
10621 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
10622         LDKSemanticError e_conv = LDKSemanticError_from_java(env, e);
10623         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
10624         *ret_conv = CResult_NoneSemanticErrorZ_err(e_conv);
10625         return (uint64_t)ret_conv;
10626 }
10627
10628 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10629         if ((_res & 1) != 0) return;
10630         LDKCResult_NoneSemanticErrorZ _res_conv = *(LDKCResult_NoneSemanticErrorZ*)(((uint64_t)_res) & ~1);
10631         FREE((void*)_res);
10632         CResult_NoneSemanticErrorZ_free(_res_conv);
10633 }
10634
10635 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10636         LDKCResult_NoneSemanticErrorZ* orig_conv = (LDKCResult_NoneSemanticErrorZ*)(orig & ~1);
10637         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
10638         *ret_conv = CResult_NoneSemanticErrorZ_clone(orig_conv);
10639         return (uint64_t)ret_conv;
10640 }
10641
10642 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10643         LDKInvoice o_conv;
10644         o_conv.inner = (void*)(o & (~1));
10645         o_conv.is_owned = (o & 1) || (o == 0);
10646         o_conv = Invoice_clone(&o_conv);
10647         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
10648         *ret_conv = CResult_InvoiceSemanticErrorZ_ok(o_conv);
10649         return (uint64_t)ret_conv;
10650 }
10651
10652 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
10653         LDKSemanticError e_conv = LDKSemanticError_from_java(env, e);
10654         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
10655         *ret_conv = CResult_InvoiceSemanticErrorZ_err(e_conv);
10656         return (uint64_t)ret_conv;
10657 }
10658
10659 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10660         if ((_res & 1) != 0) return;
10661         LDKCResult_InvoiceSemanticErrorZ _res_conv = *(LDKCResult_InvoiceSemanticErrorZ*)(((uint64_t)_res) & ~1);
10662         FREE((void*)_res);
10663         CResult_InvoiceSemanticErrorZ_free(_res_conv);
10664 }
10665
10666 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10667         LDKCResult_InvoiceSemanticErrorZ* orig_conv = (LDKCResult_InvoiceSemanticErrorZ*)(orig & ~1);
10668         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
10669         *ret_conv = CResult_InvoiceSemanticErrorZ_clone(orig_conv);
10670         return (uint64_t)ret_conv;
10671 }
10672
10673 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10674         LDKDescription o_conv;
10675         o_conv.inner = (void*)(o & (~1));
10676         o_conv.is_owned = (o & 1) || (o == 0);
10677         o_conv = Description_clone(&o_conv);
10678         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
10679         *ret_conv = CResult_DescriptionCreationErrorZ_ok(o_conv);
10680         return (uint64_t)ret_conv;
10681 }
10682
10683 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
10684         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
10685         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
10686         *ret_conv = CResult_DescriptionCreationErrorZ_err(e_conv);
10687         return (uint64_t)ret_conv;
10688 }
10689
10690 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10691         if ((_res & 1) != 0) return;
10692         LDKCResult_DescriptionCreationErrorZ _res_conv = *(LDKCResult_DescriptionCreationErrorZ*)(((uint64_t)_res) & ~1);
10693         FREE((void*)_res);
10694         CResult_DescriptionCreationErrorZ_free(_res_conv);
10695 }
10696
10697 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10698         LDKCResult_DescriptionCreationErrorZ* orig_conv = (LDKCResult_DescriptionCreationErrorZ*)(orig & ~1);
10699         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
10700         *ret_conv = CResult_DescriptionCreationErrorZ_clone(orig_conv);
10701         return (uint64_t)ret_conv;
10702 }
10703
10704 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ExpiryTimeCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10705         LDKExpiryTime o_conv;
10706         o_conv.inner = (void*)(o & (~1));
10707         o_conv.is_owned = (o & 1) || (o == 0);
10708         o_conv = ExpiryTime_clone(&o_conv);
10709         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
10710         *ret_conv = CResult_ExpiryTimeCreationErrorZ_ok(o_conv);
10711         return (uint64_t)ret_conv;
10712 }
10713
10714 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ExpiryTimeCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
10715         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
10716         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
10717         *ret_conv = CResult_ExpiryTimeCreationErrorZ_err(e_conv);
10718         return (uint64_t)ret_conv;
10719 }
10720
10721 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ExpiryTimeCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10722         if ((_res & 1) != 0) return;
10723         LDKCResult_ExpiryTimeCreationErrorZ _res_conv = *(LDKCResult_ExpiryTimeCreationErrorZ*)(((uint64_t)_res) & ~1);
10724         FREE((void*)_res);
10725         CResult_ExpiryTimeCreationErrorZ_free(_res_conv);
10726 }
10727
10728 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ExpiryTimeCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10729         LDKCResult_ExpiryTimeCreationErrorZ* orig_conv = (LDKCResult_ExpiryTimeCreationErrorZ*)(orig & ~1);
10730         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
10731         *ret_conv = CResult_ExpiryTimeCreationErrorZ_clone(orig_conv);
10732         return (uint64_t)ret_conv;
10733 }
10734
10735 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10736         LDKPrivateRoute o_conv;
10737         o_conv.inner = (void*)(o & (~1));
10738         o_conv.is_owned = (o & 1) || (o == 0);
10739         o_conv = PrivateRoute_clone(&o_conv);
10740         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
10741         *ret_conv = CResult_PrivateRouteCreationErrorZ_ok(o_conv);
10742         return (uint64_t)ret_conv;
10743 }
10744
10745 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
10746         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
10747         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
10748         *ret_conv = CResult_PrivateRouteCreationErrorZ_err(e_conv);
10749         return (uint64_t)ret_conv;
10750 }
10751
10752 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10753         if ((_res & 1) != 0) return;
10754         LDKCResult_PrivateRouteCreationErrorZ _res_conv = *(LDKCResult_PrivateRouteCreationErrorZ*)(((uint64_t)_res) & ~1);
10755         FREE((void*)_res);
10756         CResult_PrivateRouteCreationErrorZ_free(_res_conv);
10757 }
10758
10759 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10760         LDKCResult_PrivateRouteCreationErrorZ* orig_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(orig & ~1);
10761         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
10762         *ret_conv = CResult_PrivateRouteCreationErrorZ_clone(orig_conv);
10763         return (uint64_t)ret_conv;
10764 }
10765
10766 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1ok(JNIEnv *env, jclass clz, jstring o) {
10767         LDKStr o_conv = java_to_owned_str(env, o);
10768         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
10769         *ret_conv = CResult_StringErrorZ_ok(o_conv);
10770         return (uint64_t)ret_conv;
10771 }
10772
10773 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
10774         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
10775         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
10776         *ret_conv = CResult_StringErrorZ_err(e_conv);
10777         return (uint64_t)ret_conv;
10778 }
10779
10780 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10781         if ((_res & 1) != 0) return;
10782         LDKCResult_StringErrorZ _res_conv = *(LDKCResult_StringErrorZ*)(((uint64_t)_res) & ~1);
10783         FREE((void*)_res);
10784         CResult_StringErrorZ_free(_res_conv);
10785 }
10786
10787 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10788         LDKChannelMonitorUpdate o_conv;
10789         o_conv.inner = (void*)(o & (~1));
10790         o_conv.is_owned = (o & 1) || (o == 0);
10791         o_conv = ChannelMonitorUpdate_clone(&o_conv);
10792         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
10793         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_ok(o_conv);
10794         return (uint64_t)ret_conv;
10795 }
10796
10797 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10798         LDKDecodeError e_conv;
10799         e_conv.inner = (void*)(e & (~1));
10800         e_conv.is_owned = (e & 1) || (e == 0);
10801         e_conv = DecodeError_clone(&e_conv);
10802         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
10803         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_err(e_conv);
10804         return (uint64_t)ret_conv;
10805 }
10806
10807 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10808         if ((_res & 1) != 0) return;
10809         LDKCResult_ChannelMonitorUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
10810         FREE((void*)_res);
10811         CResult_ChannelMonitorUpdateDecodeErrorZ_free(_res_conv);
10812 }
10813
10814 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10815         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(orig & ~1);
10816         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
10817         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(orig_conv);
10818         return (uint64_t)ret_conv;
10819 }
10820
10821 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10822         LDKHTLCUpdate o_conv;
10823         o_conv.inner = (void*)(o & (~1));
10824         o_conv.is_owned = (o & 1) || (o == 0);
10825         o_conv = HTLCUpdate_clone(&o_conv);
10826         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
10827         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_ok(o_conv);
10828         return (uint64_t)ret_conv;
10829 }
10830
10831 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10832         LDKDecodeError e_conv;
10833         e_conv.inner = (void*)(e & (~1));
10834         e_conv.is_owned = (e & 1) || (e == 0);
10835         e_conv = DecodeError_clone(&e_conv);
10836         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
10837         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_err(e_conv);
10838         return (uint64_t)ret_conv;
10839 }
10840
10841 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10842         if ((_res & 1) != 0) return;
10843         LDKCResult_HTLCUpdateDecodeErrorZ _res_conv = *(LDKCResult_HTLCUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
10844         FREE((void*)_res);
10845         CResult_HTLCUpdateDecodeErrorZ_free(_res_conv);
10846 }
10847
10848 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10849         LDKCResult_HTLCUpdateDecodeErrorZ* orig_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(orig & ~1);
10850         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
10851         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(orig_conv);
10852         return (uint64_t)ret_conv;
10853 }
10854
10855 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneMonitorUpdateErrorZ_1ok(JNIEnv *env, jclass clz) {
10856         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
10857         *ret_conv = CResult_NoneMonitorUpdateErrorZ_ok();
10858         return (uint64_t)ret_conv;
10859 }
10860
10861 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneMonitorUpdateErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10862         LDKMonitorUpdateError e_conv;
10863         e_conv.inner = (void*)(e & (~1));
10864         e_conv.is_owned = (e & 1) || (e == 0);
10865         e_conv = MonitorUpdateError_clone(&e_conv);
10866         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
10867         *ret_conv = CResult_NoneMonitorUpdateErrorZ_err(e_conv);
10868         return (uint64_t)ret_conv;
10869 }
10870
10871 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneMonitorUpdateErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10872         if ((_res & 1) != 0) return;
10873         LDKCResult_NoneMonitorUpdateErrorZ _res_conv = *(LDKCResult_NoneMonitorUpdateErrorZ*)(((uint64_t)_res) & ~1);
10874         FREE((void*)_res);
10875         CResult_NoneMonitorUpdateErrorZ_free(_res_conv);
10876 }
10877
10878 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneMonitorUpdateErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10879         LDKCResult_NoneMonitorUpdateErrorZ* orig_conv = (LDKCResult_NoneMonitorUpdateErrorZ*)(orig & ~1);
10880         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
10881         *ret_conv = CResult_NoneMonitorUpdateErrorZ_clone(orig_conv);
10882         return (uint64_t)ret_conv;
10883 }
10884
10885 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10886         LDKC2Tuple_OutPointScriptZ* orig_conv = (LDKC2Tuple_OutPointScriptZ*)(orig & ~1);
10887         LDKC2Tuple_OutPointScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
10888         *ret_ref = C2Tuple_OutPointScriptZ_clone(orig_conv);
10889         return (uint64_t)ret_ref;
10890 }
10891
10892 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
10893         LDKOutPoint a_conv;
10894         a_conv.inner = (void*)(a & (~1));
10895         a_conv.is_owned = (a & 1) || (a == 0);
10896         a_conv = OutPoint_clone(&a_conv);
10897         LDKCVec_u8Z b_ref;
10898         b_ref.datalen = (*env)->GetArrayLength(env, b);
10899         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
10900         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
10901         LDKC2Tuple_OutPointScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
10902         *ret_ref = C2Tuple_OutPointScriptZ_new(a_conv, b_ref);
10903         return (uint64_t)ret_ref;
10904 }
10905
10906 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10907         if ((_res & 1) != 0) return;
10908         LDKC2Tuple_OutPointScriptZ _res_conv = *(LDKC2Tuple_OutPointScriptZ*)(((uint64_t)_res) & ~1);
10909         FREE((void*)_res);
10910         C2Tuple_OutPointScriptZ_free(_res_conv);
10911 }
10912
10913 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10914         LDKC2Tuple_u32ScriptZ* orig_conv = (LDKC2Tuple_u32ScriptZ*)(orig & ~1);
10915         LDKC2Tuple_u32ScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
10916         *ret_ref = C2Tuple_u32ScriptZ_clone(orig_conv);
10917         return (uint64_t)ret_ref;
10918 }
10919
10920 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1new(JNIEnv *env, jclass clz, int32_t a, int8_tArray b) {
10921         LDKCVec_u8Z b_ref;
10922         b_ref.datalen = (*env)->GetArrayLength(env, b);
10923         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
10924         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
10925         LDKC2Tuple_u32ScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
10926         *ret_ref = C2Tuple_u32ScriptZ_new(a, b_ref);
10927         return (uint64_t)ret_ref;
10928 }
10929
10930 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10931         if ((_res & 1) != 0) return;
10932         LDKC2Tuple_u32ScriptZ _res_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)_res) & ~1);
10933         FREE((void*)_res);
10934         C2Tuple_u32ScriptZ_free(_res_conv);
10935 }
10936
10937 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1u32ScriptZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
10938         LDKCVec_C2Tuple_u32ScriptZZ _res_constr;
10939         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
10940         if (_res_constr.datalen > 0)
10941                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
10942         else
10943                 _res_constr.data = NULL;
10944         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
10945         for (size_t b = 0; b < _res_constr.datalen; b++) {
10946                 int64_t _res_conv_27 = _res_vals[b];
10947                 LDKC2Tuple_u32ScriptZ _res_conv_27_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)_res_conv_27) & ~1);
10948                 FREE((void*)_res_conv_27);
10949                 _res_constr.data[b] = _res_conv_27_conv;
10950         }
10951         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
10952         CVec_C2Tuple_u32ScriptZZ_free(_res_constr);
10953 }
10954
10955 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10956         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(orig & ~1);
10957         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
10958         *ret_ref = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(orig_conv);
10959         return (uint64_t)ret_ref;
10960 }
10961
10962 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
10963         LDKThirtyTwoBytes a_ref;
10964         CHECK((*env)->GetArrayLength(env, a) == 32);
10965         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
10966         LDKCVec_C2Tuple_u32ScriptZZ b_constr;
10967         b_constr.datalen = (*env)->GetArrayLength(env, b);
10968         if (b_constr.datalen > 0)
10969                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
10970         else
10971                 b_constr.data = NULL;
10972         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
10973         for (size_t b = 0; b < b_constr.datalen; b++) {
10974                 int64_t b_conv_27 = b_vals[b];
10975                 LDKC2Tuple_u32ScriptZ b_conv_27_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_27) & ~1);
10976                 b_conv_27_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_27) & ~1));
10977                 b_constr.data[b] = b_conv_27_conv;
10978         }
10979         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
10980         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
10981         *ret_ref = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(a_ref, b_constr);
10982         return (uint64_t)ret_ref;
10983 }
10984
10985 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10986         if ((_res & 1) != 0) return;
10987         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)_res) & ~1);
10988         FREE((void*)_res);
10989         C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(_res_conv);
10990 }
10991
10992 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
10993         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ _res_constr;
10994         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
10995         if (_res_constr.datalen > 0)
10996                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ Elements");
10997         else
10998                 _res_constr.data = NULL;
10999         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
11000         for (size_t v = 0; v < _res_constr.datalen; v++) {
11001                 int64_t _res_conv_47 = _res_vals[v];
11002                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv_47_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)_res_conv_47) & ~1);
11003                 FREE((void*)_res_conv_47);
11004                 _res_constr.data[v] = _res_conv_47_conv;
11005         }
11006         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
11007         CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(_res_constr);
11008 }
11009
11010 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1EventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
11011         LDKCVec_EventZ _res_constr;
11012         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11013         if (_res_constr.datalen > 0)
11014                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKEvent), "LDKCVec_EventZ Elements");
11015         else
11016                 _res_constr.data = NULL;
11017         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
11018         for (size_t h = 0; h < _res_constr.datalen; h++) {
11019                 int64_t _res_conv_7 = _res_vals[h];
11020                 LDKEvent _res_conv_7_conv = *(LDKEvent*)(((uint64_t)_res_conv_7) & ~1);
11021                 FREE((void*)_res_conv_7);
11022                 _res_constr.data[h] = _res_conv_7_conv;
11023         }
11024         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
11025         CVec_EventZ_free(_res_constr);
11026 }
11027
11028 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TransactionZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
11029         LDKCVec_TransactionZ _res_constr;
11030         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11031         if (_res_constr.datalen > 0)
11032                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTransaction), "LDKCVec_TransactionZ Elements");
11033         else
11034                 _res_constr.data = NULL;
11035         for (size_t i = 0; i < _res_constr.datalen; i++) {
11036                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
11037                 LDKTransaction _res_conv_8_ref;
11038                 _res_conv_8_ref.datalen = (*env)->GetArrayLength(env, _res_conv_8);
11039                 _res_conv_8_ref.data = MALLOC(_res_conv_8_ref.datalen, "LDKTransaction Bytes");
11040                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, _res_conv_8_ref.datalen, _res_conv_8_ref.data);
11041                 _res_conv_8_ref.data_is_owned = true;
11042                 _res_constr.data[i] = _res_conv_8_ref;
11043         }
11044         CVec_TransactionZ_free(_res_constr);
11045 }
11046
11047 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11048         LDKC2Tuple_u32TxOutZ* orig_conv = (LDKC2Tuple_u32TxOutZ*)(orig & ~1);
11049         LDKC2Tuple_u32TxOutZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
11050         *ret_ref = C2Tuple_u32TxOutZ_clone(orig_conv);
11051         return (uint64_t)ret_ref;
11052 }
11053
11054 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1new(JNIEnv *env, jclass clz, int32_t a, int64_t b) {
11055         LDKTxOut b_conv = *(LDKTxOut*)(((uint64_t)b) & ~1);
11056         LDKC2Tuple_u32TxOutZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
11057         *ret_ref = C2Tuple_u32TxOutZ_new(a, b_conv);
11058         return (uint64_t)ret_ref;
11059 }
11060
11061 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11062         if ((_res & 1) != 0) return;
11063         LDKC2Tuple_u32TxOutZ _res_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)_res) & ~1);
11064         FREE((void*)_res);
11065         C2Tuple_u32TxOutZ_free(_res_conv);
11066 }
11067
11068 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1u32TxOutZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
11069         LDKCVec_C2Tuple_u32TxOutZZ _res_constr;
11070         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11071         if (_res_constr.datalen > 0)
11072                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
11073         else
11074                 _res_constr.data = NULL;
11075         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
11076         for (size_t a = 0; a < _res_constr.datalen; a++) {
11077                 int64_t _res_conv_26 = _res_vals[a];
11078                 LDKC2Tuple_u32TxOutZ _res_conv_26_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)_res_conv_26) & ~1);
11079                 FREE((void*)_res_conv_26);
11080                 _res_constr.data[a] = _res_conv_26_conv;
11081         }
11082         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
11083         CVec_C2Tuple_u32TxOutZZ_free(_res_constr);
11084 }
11085
11086 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11087         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(orig & ~1);
11088         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
11089         *ret_ref = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(orig_conv);
11090         return (uint64_t)ret_ref;
11091 }
11092
11093 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
11094         LDKThirtyTwoBytes a_ref;
11095         CHECK((*env)->GetArrayLength(env, a) == 32);
11096         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
11097         LDKCVec_C2Tuple_u32TxOutZZ b_constr;
11098         b_constr.datalen = (*env)->GetArrayLength(env, b);
11099         if (b_constr.datalen > 0)
11100                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
11101         else
11102                 b_constr.data = NULL;
11103         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
11104         for (size_t a = 0; a < b_constr.datalen; a++) {
11105                 int64_t b_conv_26 = b_vals[a];
11106                 LDKC2Tuple_u32TxOutZ b_conv_26_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_26) & ~1);
11107                 b_conv_26_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_26) & ~1));
11108                 b_constr.data[a] = b_conv_26_conv;
11109         }
11110         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
11111         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
11112         *ret_ref = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(a_ref, b_constr);
11113         return (uint64_t)ret_ref;
11114 }
11115
11116 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11117         if ((_res & 1) != 0) return;
11118         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)_res) & ~1);
11119         FREE((void*)_res);
11120         C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(_res_conv);
11121 }
11122
11123 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
11124         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ _res_constr;
11125         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11126         if (_res_constr.datalen > 0)
11127                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Elements");
11128         else
11129                 _res_constr.data = NULL;
11130         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
11131         for (size_t u = 0; u < _res_constr.datalen; u++) {
11132                 int64_t _res_conv_46 = _res_vals[u];
11133                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv_46_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)_res_conv_46) & ~1);
11134                 FREE((void*)_res_conv_46);
11135                 _res_constr.data[u] = _res_conv_46_conv;
11136         }
11137         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
11138         CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(_res_constr);
11139 }
11140
11141 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11142         LDKC2Tuple_BlockHashChannelMonitorZ o_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)o) & ~1);
11143         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
11144         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(o_conv);
11145         return (uint64_t)ret_conv;
11146 }
11147
11148 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11149         LDKDecodeError e_conv;
11150         e_conv.inner = (void*)(e & (~1));
11151         e_conv.is_owned = (e & 1) || (e == 0);
11152         e_conv = DecodeError_clone(&e_conv);
11153         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
11154         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(e_conv);
11155         return (uint64_t)ret_conv;
11156 }
11157
11158 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11159         if ((_res & 1) != 0) return;
11160         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(((uint64_t)_res) & ~1);
11161         FREE((void*)_res);
11162         CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(_res_conv);
11163 }
11164
11165 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1ok(JNIEnv *env, jclass clz, jboolean o) {
11166         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
11167         *ret_conv = CResult_boolLightningErrorZ_ok(o);
11168         return (uint64_t)ret_conv;
11169 }
11170
11171 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11172         LDKLightningError e_conv;
11173         e_conv.inner = (void*)(e & (~1));
11174         e_conv.is_owned = (e & 1) || (e == 0);
11175         e_conv = LightningError_clone(&e_conv);
11176         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
11177         *ret_conv = CResult_boolLightningErrorZ_err(e_conv);
11178         return (uint64_t)ret_conv;
11179 }
11180
11181 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11182         if ((_res & 1) != 0) return;
11183         LDKCResult_boolLightningErrorZ _res_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)_res) & ~1);
11184         FREE((void*)_res);
11185         CResult_boolLightningErrorZ_free(_res_conv);
11186 }
11187
11188 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11189         LDKCResult_boolLightningErrorZ* orig_conv = (LDKCResult_boolLightningErrorZ*)(orig & ~1);
11190         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
11191         *ret_conv = CResult_boolLightningErrorZ_clone(orig_conv);
11192         return (uint64_t)ret_conv;
11193 }
11194
11195 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11196         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* orig_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(orig & ~1);
11197         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_ref = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
11198         *ret_ref = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(orig_conv);
11199         return (uint64_t)ret_ref;
11200 }
11201
11202 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) {
11203         LDKChannelAnnouncement a_conv;
11204         a_conv.inner = (void*)(a & (~1));
11205         a_conv.is_owned = (a & 1) || (a == 0);
11206         a_conv = ChannelAnnouncement_clone(&a_conv);
11207         LDKChannelUpdate b_conv;
11208         b_conv.inner = (void*)(b & (~1));
11209         b_conv.is_owned = (b & 1) || (b == 0);
11210         b_conv = ChannelUpdate_clone(&b_conv);
11211         LDKChannelUpdate c_conv;
11212         c_conv.inner = (void*)(c & (~1));
11213         c_conv.is_owned = (c & 1) || (c == 0);
11214         c_conv = ChannelUpdate_clone(&c_conv);
11215         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_ref = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
11216         *ret_ref = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(a_conv, b_conv, c_conv);
11217         return (uint64_t)ret_ref;
11218 }
11219
11220 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11221         if ((_res & 1) != 0) return;
11222         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)_res) & ~1);
11223         FREE((void*)_res);
11224         C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(_res_conv);
11225 }
11226
11227 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
11228         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ _res_constr;
11229         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11230         if (_res_constr.datalen > 0)
11231                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
11232         else
11233                 _res_constr.data = NULL;
11234         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
11235         for (size_t l = 0; l < _res_constr.datalen; l++) {
11236                 int64_t _res_conv_63 = _res_vals[l];
11237                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv_63_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)_res_conv_63) & ~1);
11238                 FREE((void*)_res_conv_63);
11239                 _res_constr.data[l] = _res_conv_63_conv;
11240         }
11241         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
11242         CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(_res_constr);
11243 }
11244
11245 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1NodeAnnouncementZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
11246         LDKCVec_NodeAnnouncementZ _res_constr;
11247         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11248         if (_res_constr.datalen > 0)
11249                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
11250         else
11251                 _res_constr.data = NULL;
11252         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
11253         for (size_t s = 0; s < _res_constr.datalen; s++) {
11254                 int64_t _res_conv_18 = _res_vals[s];
11255                 LDKNodeAnnouncement _res_conv_18_conv;
11256                 _res_conv_18_conv.inner = (void*)(_res_conv_18 & (~1));
11257                 _res_conv_18_conv.is_owned = (_res_conv_18 & 1) || (_res_conv_18 == 0);
11258                 _res_constr.data[s] = _res_conv_18_conv;
11259         }
11260         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
11261         CVec_NodeAnnouncementZ_free(_res_constr);
11262 }
11263
11264 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1ok(JNIEnv *env, jclass clz) {
11265         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
11266         *ret_conv = CResult_NoneLightningErrorZ_ok();
11267         return (uint64_t)ret_conv;
11268 }
11269
11270 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11271         LDKLightningError e_conv;
11272         e_conv.inner = (void*)(e & (~1));
11273         e_conv.is_owned = (e & 1) || (e == 0);
11274         e_conv = LightningError_clone(&e_conv);
11275         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
11276         *ret_conv = CResult_NoneLightningErrorZ_err(e_conv);
11277         return (uint64_t)ret_conv;
11278 }
11279
11280 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11281         if ((_res & 1) != 0) return;
11282         LDKCResult_NoneLightningErrorZ _res_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)_res) & ~1);
11283         FREE((void*)_res);
11284         CResult_NoneLightningErrorZ_free(_res_conv);
11285 }
11286
11287 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11288         LDKCResult_NoneLightningErrorZ* orig_conv = (LDKCResult_NoneLightningErrorZ*)(orig & ~1);
11289         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
11290         *ret_conv = CResult_NoneLightningErrorZ_clone(orig_conv);
11291         return (uint64_t)ret_conv;
11292 }
11293
11294 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PublicKeyZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
11295         LDKCVec_PublicKeyZ _res_constr;
11296         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11297         if (_res_constr.datalen > 0)
11298                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
11299         else
11300                 _res_constr.data = NULL;
11301         for (size_t i = 0; i < _res_constr.datalen; i++) {
11302                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
11303                 LDKPublicKey _res_conv_8_ref;
11304                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 33);
11305                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 33, _res_conv_8_ref.compressed_form);
11306                 _res_constr.data[i] = _res_conv_8_ref;
11307         }
11308         CVec_PublicKeyZ_free(_res_constr);
11309 }
11310
11311 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
11312         LDKCVec_u8Z o_ref;
11313         o_ref.datalen = (*env)->GetArrayLength(env, o);
11314         o_ref.data = MALLOC(o_ref.datalen, "LDKCVec_u8Z Bytes");
11315         (*env)->GetByteArrayRegion(env, o, 0, o_ref.datalen, o_ref.data);
11316         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
11317         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_ok(o_ref);
11318         return (uint64_t)ret_conv;
11319 }
11320
11321 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11322         LDKPeerHandleError e_conv;
11323         e_conv.inner = (void*)(e & (~1));
11324         e_conv.is_owned = (e & 1) || (e == 0);
11325         e_conv = PeerHandleError_clone(&e_conv);
11326         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
11327         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_err(e_conv);
11328         return (uint64_t)ret_conv;
11329 }
11330
11331 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11332         if ((_res & 1) != 0) return;
11333         LDKCResult_CVec_u8ZPeerHandleErrorZ _res_conv = *(LDKCResult_CVec_u8ZPeerHandleErrorZ*)(((uint64_t)_res) & ~1);
11334         FREE((void*)_res);
11335         CResult_CVec_u8ZPeerHandleErrorZ_free(_res_conv);
11336 }
11337
11338 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11339         LDKCResult_CVec_u8ZPeerHandleErrorZ* orig_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(orig & ~1);
11340         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
11341         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(orig_conv);
11342         return (uint64_t)ret_conv;
11343 }
11344
11345 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1ok(JNIEnv *env, jclass clz) {
11346         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
11347         *ret_conv = CResult_NonePeerHandleErrorZ_ok();
11348         return (uint64_t)ret_conv;
11349 }
11350
11351 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11352         LDKPeerHandleError e_conv;
11353         e_conv.inner = (void*)(e & (~1));
11354         e_conv.is_owned = (e & 1) || (e == 0);
11355         e_conv = PeerHandleError_clone(&e_conv);
11356         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
11357         *ret_conv = CResult_NonePeerHandleErrorZ_err(e_conv);
11358         return (uint64_t)ret_conv;
11359 }
11360
11361 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11362         if ((_res & 1) != 0) return;
11363         LDKCResult_NonePeerHandleErrorZ _res_conv = *(LDKCResult_NonePeerHandleErrorZ*)(((uint64_t)_res) & ~1);
11364         FREE((void*)_res);
11365         CResult_NonePeerHandleErrorZ_free(_res_conv);
11366 }
11367
11368 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11369         LDKCResult_NonePeerHandleErrorZ* orig_conv = (LDKCResult_NonePeerHandleErrorZ*)(orig & ~1);
11370         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
11371         *ret_conv = CResult_NonePeerHandleErrorZ_clone(orig_conv);
11372         return (uint64_t)ret_conv;
11373 }
11374
11375 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1ok(JNIEnv *env, jclass clz, jboolean o) {
11376         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
11377         *ret_conv = CResult_boolPeerHandleErrorZ_ok(o);
11378         return (uint64_t)ret_conv;
11379 }
11380
11381 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11382         LDKPeerHandleError e_conv;
11383         e_conv.inner = (void*)(e & (~1));
11384         e_conv.is_owned = (e & 1) || (e == 0);
11385         e_conv = PeerHandleError_clone(&e_conv);
11386         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
11387         *ret_conv = CResult_boolPeerHandleErrorZ_err(e_conv);
11388         return (uint64_t)ret_conv;
11389 }
11390
11391 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11392         if ((_res & 1) != 0) return;
11393         LDKCResult_boolPeerHandleErrorZ _res_conv = *(LDKCResult_boolPeerHandleErrorZ*)(((uint64_t)_res) & ~1);
11394         FREE((void*)_res);
11395         CResult_boolPeerHandleErrorZ_free(_res_conv);
11396 }
11397
11398 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11399         LDKCResult_boolPeerHandleErrorZ* orig_conv = (LDKCResult_boolPeerHandleErrorZ*)(orig & ~1);
11400         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
11401         *ret_conv = CResult_boolPeerHandleErrorZ_clone(orig_conv);
11402         return (uint64_t)ret_conv;
11403 }
11404
11405 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DirectionalChannelInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11406         LDKDirectionalChannelInfo o_conv;
11407         o_conv.inner = (void*)(o & (~1));
11408         o_conv.is_owned = (o & 1) || (o == 0);
11409         o_conv = DirectionalChannelInfo_clone(&o_conv);
11410         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
11411         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_ok(o_conv);
11412         return (uint64_t)ret_conv;
11413 }
11414
11415 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DirectionalChannelInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11416         LDKDecodeError e_conv;
11417         e_conv.inner = (void*)(e & (~1));
11418         e_conv.is_owned = (e & 1) || (e == 0);
11419         e_conv = DecodeError_clone(&e_conv);
11420         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
11421         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_err(e_conv);
11422         return (uint64_t)ret_conv;
11423 }
11424
11425 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1DirectionalChannelInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11426         if ((_res & 1) != 0) return;
11427         LDKCResult_DirectionalChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
11428         FREE((void*)_res);
11429         CResult_DirectionalChannelInfoDecodeErrorZ_free(_res_conv);
11430 }
11431
11432 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DirectionalChannelInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11433         LDKCResult_DirectionalChannelInfoDecodeErrorZ* orig_conv = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(orig & ~1);
11434         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
11435         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_clone(orig_conv);
11436         return (uint64_t)ret_conv;
11437 }
11438
11439 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11440         LDKChannelInfo o_conv;
11441         o_conv.inner = (void*)(o & (~1));
11442         o_conv.is_owned = (o & 1) || (o == 0);
11443         o_conv = ChannelInfo_clone(&o_conv);
11444         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
11445         *ret_conv = CResult_ChannelInfoDecodeErrorZ_ok(o_conv);
11446         return (uint64_t)ret_conv;
11447 }
11448
11449 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11450         LDKDecodeError e_conv;
11451         e_conv.inner = (void*)(e & (~1));
11452         e_conv.is_owned = (e & 1) || (e == 0);
11453         e_conv = DecodeError_clone(&e_conv);
11454         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
11455         *ret_conv = CResult_ChannelInfoDecodeErrorZ_err(e_conv);
11456         return (uint64_t)ret_conv;
11457 }
11458
11459 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11460         if ((_res & 1) != 0) return;
11461         LDKCResult_ChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
11462         FREE((void*)_res);
11463         CResult_ChannelInfoDecodeErrorZ_free(_res_conv);
11464 }
11465
11466 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11467         LDKCResult_ChannelInfoDecodeErrorZ* orig_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(orig & ~1);
11468         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
11469         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(orig_conv);
11470         return (uint64_t)ret_conv;
11471 }
11472
11473 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11474         LDKRoutingFees o_conv;
11475         o_conv.inner = (void*)(o & (~1));
11476         o_conv.is_owned = (o & 1) || (o == 0);
11477         o_conv = RoutingFees_clone(&o_conv);
11478         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
11479         *ret_conv = CResult_RoutingFeesDecodeErrorZ_ok(o_conv);
11480         return (uint64_t)ret_conv;
11481 }
11482
11483 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11484         LDKDecodeError e_conv;
11485         e_conv.inner = (void*)(e & (~1));
11486         e_conv.is_owned = (e & 1) || (e == 0);
11487         e_conv = DecodeError_clone(&e_conv);
11488         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
11489         *ret_conv = CResult_RoutingFeesDecodeErrorZ_err(e_conv);
11490         return (uint64_t)ret_conv;
11491 }
11492
11493 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11494         if ((_res & 1) != 0) return;
11495         LDKCResult_RoutingFeesDecodeErrorZ _res_conv = *(LDKCResult_RoutingFeesDecodeErrorZ*)(((uint64_t)_res) & ~1);
11496         FREE((void*)_res);
11497         CResult_RoutingFeesDecodeErrorZ_free(_res_conv);
11498 }
11499
11500 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11501         LDKCResult_RoutingFeesDecodeErrorZ* orig_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(orig & ~1);
11502         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
11503         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(orig_conv);
11504         return (uint64_t)ret_conv;
11505 }
11506
11507 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11508         LDKNodeAnnouncementInfo o_conv;
11509         o_conv.inner = (void*)(o & (~1));
11510         o_conv.is_owned = (o & 1) || (o == 0);
11511         o_conv = NodeAnnouncementInfo_clone(&o_conv);
11512         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
11513         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_ok(o_conv);
11514         return (uint64_t)ret_conv;
11515 }
11516
11517 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11518         LDKDecodeError e_conv;
11519         e_conv.inner = (void*)(e & (~1));
11520         e_conv.is_owned = (e & 1) || (e == 0);
11521         e_conv = DecodeError_clone(&e_conv);
11522         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
11523         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_err(e_conv);
11524         return (uint64_t)ret_conv;
11525 }
11526
11527 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11528         if ((_res & 1) != 0) return;
11529         LDKCResult_NodeAnnouncementInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
11530         FREE((void*)_res);
11531         CResult_NodeAnnouncementInfoDecodeErrorZ_free(_res_conv);
11532 }
11533
11534 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11535         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(orig & ~1);
11536         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
11537         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(orig_conv);
11538         return (uint64_t)ret_conv;
11539 }
11540
11541 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u64Z_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
11542         LDKCVec_u64Z _res_constr;
11543         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11544         if (_res_constr.datalen > 0)
11545                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
11546         else
11547                 _res_constr.data = NULL;
11548         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
11549         for (size_t g = 0; g < _res_constr.datalen; g++) {
11550                 int64_t _res_conv_6 = _res_vals[g];
11551                 _res_constr.data[g] = _res_conv_6;
11552         }
11553         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
11554         CVec_u64Z_free(_res_constr);
11555 }
11556
11557 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11558         LDKNodeInfo o_conv;
11559         o_conv.inner = (void*)(o & (~1));
11560         o_conv.is_owned = (o & 1) || (o == 0);
11561         o_conv = NodeInfo_clone(&o_conv);
11562         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
11563         *ret_conv = CResult_NodeInfoDecodeErrorZ_ok(o_conv);
11564         return (uint64_t)ret_conv;
11565 }
11566
11567 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11568         LDKDecodeError e_conv;
11569         e_conv.inner = (void*)(e & (~1));
11570         e_conv.is_owned = (e & 1) || (e == 0);
11571         e_conv = DecodeError_clone(&e_conv);
11572         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
11573         *ret_conv = CResult_NodeInfoDecodeErrorZ_err(e_conv);
11574         return (uint64_t)ret_conv;
11575 }
11576
11577 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11578         if ((_res & 1) != 0) return;
11579         LDKCResult_NodeInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
11580         FREE((void*)_res);
11581         CResult_NodeInfoDecodeErrorZ_free(_res_conv);
11582 }
11583
11584 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11585         LDKCResult_NodeInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(orig & ~1);
11586         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
11587         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(orig_conv);
11588         return (uint64_t)ret_conv;
11589 }
11590
11591 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11592         LDKNetworkGraph o_conv;
11593         o_conv.inner = (void*)(o & (~1));
11594         o_conv.is_owned = (o & 1) || (o == 0);
11595         o_conv = NetworkGraph_clone(&o_conv);
11596         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
11597         *ret_conv = CResult_NetworkGraphDecodeErrorZ_ok(o_conv);
11598         return (uint64_t)ret_conv;
11599 }
11600
11601 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11602         LDKDecodeError e_conv;
11603         e_conv.inner = (void*)(e & (~1));
11604         e_conv.is_owned = (e & 1) || (e == 0);
11605         e_conv = DecodeError_clone(&e_conv);
11606         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
11607         *ret_conv = CResult_NetworkGraphDecodeErrorZ_err(e_conv);
11608         return (uint64_t)ret_conv;
11609 }
11610
11611 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11612         if ((_res & 1) != 0) return;
11613         LDKCResult_NetworkGraphDecodeErrorZ _res_conv = *(LDKCResult_NetworkGraphDecodeErrorZ*)(((uint64_t)_res) & ~1);
11614         FREE((void*)_res);
11615         CResult_NetworkGraphDecodeErrorZ_free(_res_conv);
11616 }
11617
11618 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11619         LDKCResult_NetworkGraphDecodeErrorZ* orig_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(orig & ~1);
11620         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
11621         *ret_conv = CResult_NetworkGraphDecodeErrorZ_clone(orig_conv);
11622         return (uint64_t)ret_conv;
11623 }
11624
11625 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressu8Z_1ok(JNIEnv *env, jclass clz, int64_t o) {
11626         LDKNetAddress o_conv = *(LDKNetAddress*)(((uint64_t)o) & ~1);
11627         LDKCResult_NetAddressu8Z* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
11628         *ret_conv = CResult_NetAddressu8Z_ok(o_conv);
11629         return (uint64_t)ret_conv;
11630 }
11631
11632 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressu8Z_1err(JNIEnv *env, jclass clz, int8_t e) {
11633         LDKCResult_NetAddressu8Z* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
11634         *ret_conv = CResult_NetAddressu8Z_err(e);
11635         return (uint64_t)ret_conv;
11636 }
11637
11638 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressu8Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
11639         if ((_res & 1) != 0) return;
11640         LDKCResult_NetAddressu8Z _res_conv = *(LDKCResult_NetAddressu8Z*)(((uint64_t)_res) & ~1);
11641         FREE((void*)_res);
11642         CResult_NetAddressu8Z_free(_res_conv);
11643 }
11644
11645 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressu8Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11646         LDKCResult_NetAddressu8Z* orig_conv = (LDKCResult_NetAddressu8Z*)(orig & ~1);
11647         LDKCResult_NetAddressu8Z* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
11648         *ret_conv = CResult_NetAddressu8Z_clone(orig_conv);
11649         return (uint64_t)ret_conv;
11650 }
11651
11652 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CResult_1NetAddressu8ZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11653         LDKCResult_NetAddressu8Z o_conv = *(LDKCResult_NetAddressu8Z*)(((uint64_t)o) & ~1);
11654         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
11655         *ret_conv = CResult_CResult_NetAddressu8ZDecodeErrorZ_ok(o_conv);
11656         return (uint64_t)ret_conv;
11657 }
11658
11659 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CResult_1NetAddressu8ZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11660         LDKDecodeError e_conv;
11661         e_conv.inner = (void*)(e & (~1));
11662         e_conv.is_owned = (e & 1) || (e == 0);
11663         e_conv = DecodeError_clone(&e_conv);
11664         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
11665         *ret_conv = CResult_CResult_NetAddressu8ZDecodeErrorZ_err(e_conv);
11666         return (uint64_t)ret_conv;
11667 }
11668
11669 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CResult_1NetAddressu8ZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11670         if ((_res & 1) != 0) return;
11671         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ _res_conv = *(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(((uint64_t)_res) & ~1);
11672         FREE((void*)_res);
11673         CResult_CResult_NetAddressu8ZDecodeErrorZ_free(_res_conv);
11674 }
11675
11676 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CResult_1NetAddressu8ZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11677         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* orig_conv = (LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(orig & ~1);
11678         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
11679         *ret_conv = CResult_CResult_NetAddressu8ZDecodeErrorZ_clone(orig_conv);
11680         return (uint64_t)ret_conv;
11681 }
11682
11683 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11684         LDKNetAddress o_conv = *(LDKNetAddress*)(((uint64_t)o) & ~1);
11685         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
11686         *ret_conv = CResult_NetAddressDecodeErrorZ_ok(o_conv);
11687         return (uint64_t)ret_conv;
11688 }
11689
11690 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11691         LDKDecodeError e_conv;
11692         e_conv.inner = (void*)(e & (~1));
11693         e_conv.is_owned = (e & 1) || (e == 0);
11694         e_conv = DecodeError_clone(&e_conv);
11695         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
11696         *ret_conv = CResult_NetAddressDecodeErrorZ_err(e_conv);
11697         return (uint64_t)ret_conv;
11698 }
11699
11700 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11701         if ((_res & 1) != 0) return;
11702         LDKCResult_NetAddressDecodeErrorZ _res_conv = *(LDKCResult_NetAddressDecodeErrorZ*)(((uint64_t)_res) & ~1);
11703         FREE((void*)_res);
11704         CResult_NetAddressDecodeErrorZ_free(_res_conv);
11705 }
11706
11707 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11708         LDKCResult_NetAddressDecodeErrorZ* orig_conv = (LDKCResult_NetAddressDecodeErrorZ*)(orig & ~1);
11709         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
11710         *ret_conv = CResult_NetAddressDecodeErrorZ_clone(orig_conv);
11711         return (uint64_t)ret_conv;
11712 }
11713
11714 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateAddHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
11715         LDKCVec_UpdateAddHTLCZ _res_constr;
11716         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11717         if (_res_constr.datalen > 0)
11718                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
11719         else
11720                 _res_constr.data = NULL;
11721         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
11722         for (size_t p = 0; p < _res_constr.datalen; p++) {
11723                 int64_t _res_conv_15 = _res_vals[p];
11724                 LDKUpdateAddHTLC _res_conv_15_conv;
11725                 _res_conv_15_conv.inner = (void*)(_res_conv_15 & (~1));
11726                 _res_conv_15_conv.is_owned = (_res_conv_15 & 1) || (_res_conv_15 == 0);
11727                 _res_constr.data[p] = _res_conv_15_conv;
11728         }
11729         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
11730         CVec_UpdateAddHTLCZ_free(_res_constr);
11731 }
11732
11733 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFulfillHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
11734         LDKCVec_UpdateFulfillHTLCZ _res_constr;
11735         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11736         if (_res_constr.datalen > 0)
11737                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
11738         else
11739                 _res_constr.data = NULL;
11740         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
11741         for (size_t t = 0; t < _res_constr.datalen; t++) {
11742                 int64_t _res_conv_19 = _res_vals[t];
11743                 LDKUpdateFulfillHTLC _res_conv_19_conv;
11744                 _res_conv_19_conv.inner = (void*)(_res_conv_19 & (~1));
11745                 _res_conv_19_conv.is_owned = (_res_conv_19 & 1) || (_res_conv_19 == 0);
11746                 _res_constr.data[t] = _res_conv_19_conv;
11747         }
11748         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
11749         CVec_UpdateFulfillHTLCZ_free(_res_constr);
11750 }
11751
11752 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFailHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
11753         LDKCVec_UpdateFailHTLCZ _res_constr;
11754         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11755         if (_res_constr.datalen > 0)
11756                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
11757         else
11758                 _res_constr.data = NULL;
11759         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
11760         for (size_t q = 0; q < _res_constr.datalen; q++) {
11761                 int64_t _res_conv_16 = _res_vals[q];
11762                 LDKUpdateFailHTLC _res_conv_16_conv;
11763                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
11764                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
11765                 _res_constr.data[q] = _res_conv_16_conv;
11766         }
11767         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
11768         CVec_UpdateFailHTLCZ_free(_res_constr);
11769 }
11770
11771 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFailMalformedHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
11772         LDKCVec_UpdateFailMalformedHTLCZ _res_constr;
11773         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11774         if (_res_constr.datalen > 0)
11775                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
11776         else
11777                 _res_constr.data = NULL;
11778         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
11779         for (size_t z = 0; z < _res_constr.datalen; z++) {
11780                 int64_t _res_conv_25 = _res_vals[z];
11781                 LDKUpdateFailMalformedHTLC _res_conv_25_conv;
11782                 _res_conv_25_conv.inner = (void*)(_res_conv_25 & (~1));
11783                 _res_conv_25_conv.is_owned = (_res_conv_25 & 1) || (_res_conv_25 == 0);
11784                 _res_constr.data[z] = _res_conv_25_conv;
11785         }
11786         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
11787         CVec_UpdateFailMalformedHTLCZ_free(_res_constr);
11788 }
11789
11790 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11791         LDKAcceptChannel o_conv;
11792         o_conv.inner = (void*)(o & (~1));
11793         o_conv.is_owned = (o & 1) || (o == 0);
11794         o_conv = AcceptChannel_clone(&o_conv);
11795         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
11796         *ret_conv = CResult_AcceptChannelDecodeErrorZ_ok(o_conv);
11797         return (uint64_t)ret_conv;
11798 }
11799
11800 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11801         LDKDecodeError e_conv;
11802         e_conv.inner = (void*)(e & (~1));
11803         e_conv.is_owned = (e & 1) || (e == 0);
11804         e_conv = DecodeError_clone(&e_conv);
11805         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
11806         *ret_conv = CResult_AcceptChannelDecodeErrorZ_err(e_conv);
11807         return (uint64_t)ret_conv;
11808 }
11809
11810 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11811         if ((_res & 1) != 0) return;
11812         LDKCResult_AcceptChannelDecodeErrorZ _res_conv = *(LDKCResult_AcceptChannelDecodeErrorZ*)(((uint64_t)_res) & ~1);
11813         FREE((void*)_res);
11814         CResult_AcceptChannelDecodeErrorZ_free(_res_conv);
11815 }
11816
11817 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11818         LDKCResult_AcceptChannelDecodeErrorZ* orig_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(orig & ~1);
11819         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
11820         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(orig_conv);
11821         return (uint64_t)ret_conv;
11822 }
11823
11824 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11825         LDKAnnouncementSignatures o_conv;
11826         o_conv.inner = (void*)(o & (~1));
11827         o_conv.is_owned = (o & 1) || (o == 0);
11828         o_conv = AnnouncementSignatures_clone(&o_conv);
11829         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
11830         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_ok(o_conv);
11831         return (uint64_t)ret_conv;
11832 }
11833
11834 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11835         LDKDecodeError e_conv;
11836         e_conv.inner = (void*)(e & (~1));
11837         e_conv.is_owned = (e & 1) || (e == 0);
11838         e_conv = DecodeError_clone(&e_conv);
11839         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
11840         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_err(e_conv);
11841         return (uint64_t)ret_conv;
11842 }
11843
11844 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11845         if ((_res & 1) != 0) return;
11846         LDKCResult_AnnouncementSignaturesDecodeErrorZ _res_conv = *(LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
11847         FREE((void*)_res);
11848         CResult_AnnouncementSignaturesDecodeErrorZ_free(_res_conv);
11849 }
11850
11851 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11852         LDKCResult_AnnouncementSignaturesDecodeErrorZ* orig_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(orig & ~1);
11853         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
11854         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(orig_conv);
11855         return (uint64_t)ret_conv;
11856 }
11857
11858 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11859         LDKChannelReestablish o_conv;
11860         o_conv.inner = (void*)(o & (~1));
11861         o_conv.is_owned = (o & 1) || (o == 0);
11862         o_conv = ChannelReestablish_clone(&o_conv);
11863         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
11864         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_ok(o_conv);
11865         return (uint64_t)ret_conv;
11866 }
11867
11868 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11869         LDKDecodeError e_conv;
11870         e_conv.inner = (void*)(e & (~1));
11871         e_conv.is_owned = (e & 1) || (e == 0);
11872         e_conv = DecodeError_clone(&e_conv);
11873         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
11874         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_err(e_conv);
11875         return (uint64_t)ret_conv;
11876 }
11877
11878 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11879         if ((_res & 1) != 0) return;
11880         LDKCResult_ChannelReestablishDecodeErrorZ _res_conv = *(LDKCResult_ChannelReestablishDecodeErrorZ*)(((uint64_t)_res) & ~1);
11881         FREE((void*)_res);
11882         CResult_ChannelReestablishDecodeErrorZ_free(_res_conv);
11883 }
11884
11885 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11886         LDKCResult_ChannelReestablishDecodeErrorZ* orig_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(orig & ~1);
11887         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
11888         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(orig_conv);
11889         return (uint64_t)ret_conv;
11890 }
11891
11892 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11893         LDKClosingSigned o_conv;
11894         o_conv.inner = (void*)(o & (~1));
11895         o_conv.is_owned = (o & 1) || (o == 0);
11896         o_conv = ClosingSigned_clone(&o_conv);
11897         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
11898         *ret_conv = CResult_ClosingSignedDecodeErrorZ_ok(o_conv);
11899         return (uint64_t)ret_conv;
11900 }
11901
11902 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11903         LDKDecodeError e_conv;
11904         e_conv.inner = (void*)(e & (~1));
11905         e_conv.is_owned = (e & 1) || (e == 0);
11906         e_conv = DecodeError_clone(&e_conv);
11907         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
11908         *ret_conv = CResult_ClosingSignedDecodeErrorZ_err(e_conv);
11909         return (uint64_t)ret_conv;
11910 }
11911
11912 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11913         if ((_res & 1) != 0) return;
11914         LDKCResult_ClosingSignedDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedDecodeErrorZ*)(((uint64_t)_res) & ~1);
11915         FREE((void*)_res);
11916         CResult_ClosingSignedDecodeErrorZ_free(_res_conv);
11917 }
11918
11919 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11920         LDKCResult_ClosingSignedDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(orig & ~1);
11921         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
11922         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(orig_conv);
11923         return (uint64_t)ret_conv;
11924 }
11925
11926 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11927         LDKCommitmentSigned o_conv;
11928         o_conv.inner = (void*)(o & (~1));
11929         o_conv.is_owned = (o & 1) || (o == 0);
11930         o_conv = CommitmentSigned_clone(&o_conv);
11931         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
11932         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_ok(o_conv);
11933         return (uint64_t)ret_conv;
11934 }
11935
11936 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11937         LDKDecodeError e_conv;
11938         e_conv.inner = (void*)(e & (~1));
11939         e_conv.is_owned = (e & 1) || (e == 0);
11940         e_conv = DecodeError_clone(&e_conv);
11941         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
11942         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_err(e_conv);
11943         return (uint64_t)ret_conv;
11944 }
11945
11946 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11947         if ((_res & 1) != 0) return;
11948         LDKCResult_CommitmentSignedDecodeErrorZ _res_conv = *(LDKCResult_CommitmentSignedDecodeErrorZ*)(((uint64_t)_res) & ~1);
11949         FREE((void*)_res);
11950         CResult_CommitmentSignedDecodeErrorZ_free(_res_conv);
11951 }
11952
11953 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11954         LDKCResult_CommitmentSignedDecodeErrorZ* orig_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(orig & ~1);
11955         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
11956         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(orig_conv);
11957         return (uint64_t)ret_conv;
11958 }
11959
11960 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11961         LDKFundingCreated o_conv;
11962         o_conv.inner = (void*)(o & (~1));
11963         o_conv.is_owned = (o & 1) || (o == 0);
11964         o_conv = FundingCreated_clone(&o_conv);
11965         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
11966         *ret_conv = CResult_FundingCreatedDecodeErrorZ_ok(o_conv);
11967         return (uint64_t)ret_conv;
11968 }
11969
11970 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11971         LDKDecodeError e_conv;
11972         e_conv.inner = (void*)(e & (~1));
11973         e_conv.is_owned = (e & 1) || (e == 0);
11974         e_conv = DecodeError_clone(&e_conv);
11975         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
11976         *ret_conv = CResult_FundingCreatedDecodeErrorZ_err(e_conv);
11977         return (uint64_t)ret_conv;
11978 }
11979
11980 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11981         if ((_res & 1) != 0) return;
11982         LDKCResult_FundingCreatedDecodeErrorZ _res_conv = *(LDKCResult_FundingCreatedDecodeErrorZ*)(((uint64_t)_res) & ~1);
11983         FREE((void*)_res);
11984         CResult_FundingCreatedDecodeErrorZ_free(_res_conv);
11985 }
11986
11987 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11988         LDKCResult_FundingCreatedDecodeErrorZ* orig_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(orig & ~1);
11989         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
11990         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(orig_conv);
11991         return (uint64_t)ret_conv;
11992 }
11993
11994 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11995         LDKFundingSigned o_conv;
11996         o_conv.inner = (void*)(o & (~1));
11997         o_conv.is_owned = (o & 1) || (o == 0);
11998         o_conv = FundingSigned_clone(&o_conv);
11999         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
12000         *ret_conv = CResult_FundingSignedDecodeErrorZ_ok(o_conv);
12001         return (uint64_t)ret_conv;
12002 }
12003
12004 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12005         LDKDecodeError e_conv;
12006         e_conv.inner = (void*)(e & (~1));
12007         e_conv.is_owned = (e & 1) || (e == 0);
12008         e_conv = DecodeError_clone(&e_conv);
12009         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
12010         *ret_conv = CResult_FundingSignedDecodeErrorZ_err(e_conv);
12011         return (uint64_t)ret_conv;
12012 }
12013
12014 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12015         if ((_res & 1) != 0) return;
12016         LDKCResult_FundingSignedDecodeErrorZ _res_conv = *(LDKCResult_FundingSignedDecodeErrorZ*)(((uint64_t)_res) & ~1);
12017         FREE((void*)_res);
12018         CResult_FundingSignedDecodeErrorZ_free(_res_conv);
12019 }
12020
12021 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12022         LDKCResult_FundingSignedDecodeErrorZ* orig_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(orig & ~1);
12023         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
12024         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(orig_conv);
12025         return (uint64_t)ret_conv;
12026 }
12027
12028 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12029         LDKFundingLocked o_conv;
12030         o_conv.inner = (void*)(o & (~1));
12031         o_conv.is_owned = (o & 1) || (o == 0);
12032         o_conv = FundingLocked_clone(&o_conv);
12033         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
12034         *ret_conv = CResult_FundingLockedDecodeErrorZ_ok(o_conv);
12035         return (uint64_t)ret_conv;
12036 }
12037
12038 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12039         LDKDecodeError e_conv;
12040         e_conv.inner = (void*)(e & (~1));
12041         e_conv.is_owned = (e & 1) || (e == 0);
12042         e_conv = DecodeError_clone(&e_conv);
12043         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
12044         *ret_conv = CResult_FundingLockedDecodeErrorZ_err(e_conv);
12045         return (uint64_t)ret_conv;
12046 }
12047
12048 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12049         if ((_res & 1) != 0) return;
12050         LDKCResult_FundingLockedDecodeErrorZ _res_conv = *(LDKCResult_FundingLockedDecodeErrorZ*)(((uint64_t)_res) & ~1);
12051         FREE((void*)_res);
12052         CResult_FundingLockedDecodeErrorZ_free(_res_conv);
12053 }
12054
12055 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12056         LDKCResult_FundingLockedDecodeErrorZ* orig_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(orig & ~1);
12057         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
12058         *ret_conv = CResult_FundingLockedDecodeErrorZ_clone(orig_conv);
12059         return (uint64_t)ret_conv;
12060 }
12061
12062 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12063         LDKInit o_conv;
12064         o_conv.inner = (void*)(o & (~1));
12065         o_conv.is_owned = (o & 1) || (o == 0);
12066         o_conv = Init_clone(&o_conv);
12067         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
12068         *ret_conv = CResult_InitDecodeErrorZ_ok(o_conv);
12069         return (uint64_t)ret_conv;
12070 }
12071
12072 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12073         LDKDecodeError e_conv;
12074         e_conv.inner = (void*)(e & (~1));
12075         e_conv.is_owned = (e & 1) || (e == 0);
12076         e_conv = DecodeError_clone(&e_conv);
12077         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
12078         *ret_conv = CResult_InitDecodeErrorZ_err(e_conv);
12079         return (uint64_t)ret_conv;
12080 }
12081
12082 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12083         if ((_res & 1) != 0) return;
12084         LDKCResult_InitDecodeErrorZ _res_conv = *(LDKCResult_InitDecodeErrorZ*)(((uint64_t)_res) & ~1);
12085         FREE((void*)_res);
12086         CResult_InitDecodeErrorZ_free(_res_conv);
12087 }
12088
12089 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12090         LDKCResult_InitDecodeErrorZ* orig_conv = (LDKCResult_InitDecodeErrorZ*)(orig & ~1);
12091         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
12092         *ret_conv = CResult_InitDecodeErrorZ_clone(orig_conv);
12093         return (uint64_t)ret_conv;
12094 }
12095
12096 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12097         LDKOpenChannel o_conv;
12098         o_conv.inner = (void*)(o & (~1));
12099         o_conv.is_owned = (o & 1) || (o == 0);
12100         o_conv = OpenChannel_clone(&o_conv);
12101         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
12102         *ret_conv = CResult_OpenChannelDecodeErrorZ_ok(o_conv);
12103         return (uint64_t)ret_conv;
12104 }
12105
12106 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12107         LDKDecodeError e_conv;
12108         e_conv.inner = (void*)(e & (~1));
12109         e_conv.is_owned = (e & 1) || (e == 0);
12110         e_conv = DecodeError_clone(&e_conv);
12111         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
12112         *ret_conv = CResult_OpenChannelDecodeErrorZ_err(e_conv);
12113         return (uint64_t)ret_conv;
12114 }
12115
12116 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12117         if ((_res & 1) != 0) return;
12118         LDKCResult_OpenChannelDecodeErrorZ _res_conv = *(LDKCResult_OpenChannelDecodeErrorZ*)(((uint64_t)_res) & ~1);
12119         FREE((void*)_res);
12120         CResult_OpenChannelDecodeErrorZ_free(_res_conv);
12121 }
12122
12123 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12124         LDKCResult_OpenChannelDecodeErrorZ* orig_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(orig & ~1);
12125         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
12126         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(orig_conv);
12127         return (uint64_t)ret_conv;
12128 }
12129
12130 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12131         LDKRevokeAndACK o_conv;
12132         o_conv.inner = (void*)(o & (~1));
12133         o_conv.is_owned = (o & 1) || (o == 0);
12134         o_conv = RevokeAndACK_clone(&o_conv);
12135         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
12136         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_ok(o_conv);
12137         return (uint64_t)ret_conv;
12138 }
12139
12140 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12141         LDKDecodeError e_conv;
12142         e_conv.inner = (void*)(e & (~1));
12143         e_conv.is_owned = (e & 1) || (e == 0);
12144         e_conv = DecodeError_clone(&e_conv);
12145         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
12146         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_err(e_conv);
12147         return (uint64_t)ret_conv;
12148 }
12149
12150 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12151         if ((_res & 1) != 0) return;
12152         LDKCResult_RevokeAndACKDecodeErrorZ _res_conv = *(LDKCResult_RevokeAndACKDecodeErrorZ*)(((uint64_t)_res) & ~1);
12153         FREE((void*)_res);
12154         CResult_RevokeAndACKDecodeErrorZ_free(_res_conv);
12155 }
12156
12157 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12158         LDKCResult_RevokeAndACKDecodeErrorZ* orig_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(orig & ~1);
12159         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
12160         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(orig_conv);
12161         return (uint64_t)ret_conv;
12162 }
12163
12164 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12165         LDKShutdown o_conv;
12166         o_conv.inner = (void*)(o & (~1));
12167         o_conv.is_owned = (o & 1) || (o == 0);
12168         o_conv = Shutdown_clone(&o_conv);
12169         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
12170         *ret_conv = CResult_ShutdownDecodeErrorZ_ok(o_conv);
12171         return (uint64_t)ret_conv;
12172 }
12173
12174 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12175         LDKDecodeError e_conv;
12176         e_conv.inner = (void*)(e & (~1));
12177         e_conv.is_owned = (e & 1) || (e == 0);
12178         e_conv = DecodeError_clone(&e_conv);
12179         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
12180         *ret_conv = CResult_ShutdownDecodeErrorZ_err(e_conv);
12181         return (uint64_t)ret_conv;
12182 }
12183
12184 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12185         if ((_res & 1) != 0) return;
12186         LDKCResult_ShutdownDecodeErrorZ _res_conv = *(LDKCResult_ShutdownDecodeErrorZ*)(((uint64_t)_res) & ~1);
12187         FREE((void*)_res);
12188         CResult_ShutdownDecodeErrorZ_free(_res_conv);
12189 }
12190
12191 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12192         LDKCResult_ShutdownDecodeErrorZ* orig_conv = (LDKCResult_ShutdownDecodeErrorZ*)(orig & ~1);
12193         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
12194         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(orig_conv);
12195         return (uint64_t)ret_conv;
12196 }
12197
12198 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12199         LDKUpdateFailHTLC o_conv;
12200         o_conv.inner = (void*)(o & (~1));
12201         o_conv.is_owned = (o & 1) || (o == 0);
12202         o_conv = UpdateFailHTLC_clone(&o_conv);
12203         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
12204         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_ok(o_conv);
12205         return (uint64_t)ret_conv;
12206 }
12207
12208 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12209         LDKDecodeError e_conv;
12210         e_conv.inner = (void*)(e & (~1));
12211         e_conv.is_owned = (e & 1) || (e == 0);
12212         e_conv = DecodeError_clone(&e_conv);
12213         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
12214         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_err(e_conv);
12215         return (uint64_t)ret_conv;
12216 }
12217
12218 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12219         if ((_res & 1) != 0) return;
12220         LDKCResult_UpdateFailHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
12221         FREE((void*)_res);
12222         CResult_UpdateFailHTLCDecodeErrorZ_free(_res_conv);
12223 }
12224
12225 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12226         LDKCResult_UpdateFailHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(orig & ~1);
12227         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
12228         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(orig_conv);
12229         return (uint64_t)ret_conv;
12230 }
12231
12232 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12233         LDKUpdateFailMalformedHTLC o_conv;
12234         o_conv.inner = (void*)(o & (~1));
12235         o_conv.is_owned = (o & 1) || (o == 0);
12236         o_conv = UpdateFailMalformedHTLC_clone(&o_conv);
12237         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
12238         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(o_conv);
12239         return (uint64_t)ret_conv;
12240 }
12241
12242 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12243         LDKDecodeError e_conv;
12244         e_conv.inner = (void*)(e & (~1));
12245         e_conv.is_owned = (e & 1) || (e == 0);
12246         e_conv = DecodeError_clone(&e_conv);
12247         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
12248         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(e_conv);
12249         return (uint64_t)ret_conv;
12250 }
12251
12252 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12253         if ((_res & 1) != 0) return;
12254         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
12255         FREE((void*)_res);
12256         CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(_res_conv);
12257 }
12258
12259 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12260         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(orig & ~1);
12261         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
12262         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(orig_conv);
12263         return (uint64_t)ret_conv;
12264 }
12265
12266 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12267         LDKUpdateFee o_conv;
12268         o_conv.inner = (void*)(o & (~1));
12269         o_conv.is_owned = (o & 1) || (o == 0);
12270         o_conv = UpdateFee_clone(&o_conv);
12271         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
12272         *ret_conv = CResult_UpdateFeeDecodeErrorZ_ok(o_conv);
12273         return (uint64_t)ret_conv;
12274 }
12275
12276 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12277         LDKDecodeError e_conv;
12278         e_conv.inner = (void*)(e & (~1));
12279         e_conv.is_owned = (e & 1) || (e == 0);
12280         e_conv = DecodeError_clone(&e_conv);
12281         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
12282         *ret_conv = CResult_UpdateFeeDecodeErrorZ_err(e_conv);
12283         return (uint64_t)ret_conv;
12284 }
12285
12286 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12287         if ((_res & 1) != 0) return;
12288         LDKCResult_UpdateFeeDecodeErrorZ _res_conv = *(LDKCResult_UpdateFeeDecodeErrorZ*)(((uint64_t)_res) & ~1);
12289         FREE((void*)_res);
12290         CResult_UpdateFeeDecodeErrorZ_free(_res_conv);
12291 }
12292
12293 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12294         LDKCResult_UpdateFeeDecodeErrorZ* orig_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(orig & ~1);
12295         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
12296         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(orig_conv);
12297         return (uint64_t)ret_conv;
12298 }
12299
12300 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12301         LDKUpdateFulfillHTLC o_conv;
12302         o_conv.inner = (void*)(o & (~1));
12303         o_conv.is_owned = (o & 1) || (o == 0);
12304         o_conv = UpdateFulfillHTLC_clone(&o_conv);
12305         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
12306         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_ok(o_conv);
12307         return (uint64_t)ret_conv;
12308 }
12309
12310 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12311         LDKDecodeError e_conv;
12312         e_conv.inner = (void*)(e & (~1));
12313         e_conv.is_owned = (e & 1) || (e == 0);
12314         e_conv = DecodeError_clone(&e_conv);
12315         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
12316         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_err(e_conv);
12317         return (uint64_t)ret_conv;
12318 }
12319
12320 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12321         if ((_res & 1) != 0) return;
12322         LDKCResult_UpdateFulfillHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
12323         FREE((void*)_res);
12324         CResult_UpdateFulfillHTLCDecodeErrorZ_free(_res_conv);
12325 }
12326
12327 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12328         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(orig & ~1);
12329         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
12330         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(orig_conv);
12331         return (uint64_t)ret_conv;
12332 }
12333
12334 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12335         LDKUpdateAddHTLC o_conv;
12336         o_conv.inner = (void*)(o & (~1));
12337         o_conv.is_owned = (o & 1) || (o == 0);
12338         o_conv = UpdateAddHTLC_clone(&o_conv);
12339         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
12340         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_ok(o_conv);
12341         return (uint64_t)ret_conv;
12342 }
12343
12344 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12345         LDKDecodeError e_conv;
12346         e_conv.inner = (void*)(e & (~1));
12347         e_conv.is_owned = (e & 1) || (e == 0);
12348         e_conv = DecodeError_clone(&e_conv);
12349         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
12350         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_err(e_conv);
12351         return (uint64_t)ret_conv;
12352 }
12353
12354 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12355         if ((_res & 1) != 0) return;
12356         LDKCResult_UpdateAddHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateAddHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
12357         FREE((void*)_res);
12358         CResult_UpdateAddHTLCDecodeErrorZ_free(_res_conv);
12359 }
12360
12361 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12362         LDKCResult_UpdateAddHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(orig & ~1);
12363         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
12364         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(orig_conv);
12365         return (uint64_t)ret_conv;
12366 }
12367
12368 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12369         LDKPing o_conv;
12370         o_conv.inner = (void*)(o & (~1));
12371         o_conv.is_owned = (o & 1) || (o == 0);
12372         o_conv = Ping_clone(&o_conv);
12373         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
12374         *ret_conv = CResult_PingDecodeErrorZ_ok(o_conv);
12375         return (uint64_t)ret_conv;
12376 }
12377
12378 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12379         LDKDecodeError e_conv;
12380         e_conv.inner = (void*)(e & (~1));
12381         e_conv.is_owned = (e & 1) || (e == 0);
12382         e_conv = DecodeError_clone(&e_conv);
12383         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
12384         *ret_conv = CResult_PingDecodeErrorZ_err(e_conv);
12385         return (uint64_t)ret_conv;
12386 }
12387
12388 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12389         if ((_res & 1) != 0) return;
12390         LDKCResult_PingDecodeErrorZ _res_conv = *(LDKCResult_PingDecodeErrorZ*)(((uint64_t)_res) & ~1);
12391         FREE((void*)_res);
12392         CResult_PingDecodeErrorZ_free(_res_conv);
12393 }
12394
12395 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12396         LDKCResult_PingDecodeErrorZ* orig_conv = (LDKCResult_PingDecodeErrorZ*)(orig & ~1);
12397         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
12398         *ret_conv = CResult_PingDecodeErrorZ_clone(orig_conv);
12399         return (uint64_t)ret_conv;
12400 }
12401
12402 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12403         LDKPong o_conv;
12404         o_conv.inner = (void*)(o & (~1));
12405         o_conv.is_owned = (o & 1) || (o == 0);
12406         o_conv = Pong_clone(&o_conv);
12407         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
12408         *ret_conv = CResult_PongDecodeErrorZ_ok(o_conv);
12409         return (uint64_t)ret_conv;
12410 }
12411
12412 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12413         LDKDecodeError e_conv;
12414         e_conv.inner = (void*)(e & (~1));
12415         e_conv.is_owned = (e & 1) || (e == 0);
12416         e_conv = DecodeError_clone(&e_conv);
12417         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
12418         *ret_conv = CResult_PongDecodeErrorZ_err(e_conv);
12419         return (uint64_t)ret_conv;
12420 }
12421
12422 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12423         if ((_res & 1) != 0) return;
12424         LDKCResult_PongDecodeErrorZ _res_conv = *(LDKCResult_PongDecodeErrorZ*)(((uint64_t)_res) & ~1);
12425         FREE((void*)_res);
12426         CResult_PongDecodeErrorZ_free(_res_conv);
12427 }
12428
12429 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12430         LDKCResult_PongDecodeErrorZ* orig_conv = (LDKCResult_PongDecodeErrorZ*)(orig & ~1);
12431         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
12432         *ret_conv = CResult_PongDecodeErrorZ_clone(orig_conv);
12433         return (uint64_t)ret_conv;
12434 }
12435
12436 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12437         LDKUnsignedChannelAnnouncement o_conv;
12438         o_conv.inner = (void*)(o & (~1));
12439         o_conv.is_owned = (o & 1) || (o == 0);
12440         o_conv = UnsignedChannelAnnouncement_clone(&o_conv);
12441         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
12442         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(o_conv);
12443         return (uint64_t)ret_conv;
12444 }
12445
12446 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12447         LDKDecodeError e_conv;
12448         e_conv.inner = (void*)(e & (~1));
12449         e_conv.is_owned = (e & 1) || (e == 0);
12450         e_conv = DecodeError_clone(&e_conv);
12451         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
12452         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(e_conv);
12453         return (uint64_t)ret_conv;
12454 }
12455
12456 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12457         if ((_res & 1) != 0) return;
12458         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
12459         FREE((void*)_res);
12460         CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(_res_conv);
12461 }
12462
12463 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12464         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(orig & ~1);
12465         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
12466         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(orig_conv);
12467         return (uint64_t)ret_conv;
12468 }
12469
12470 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12471         LDKChannelAnnouncement o_conv;
12472         o_conv.inner = (void*)(o & (~1));
12473         o_conv.is_owned = (o & 1) || (o == 0);
12474         o_conv = ChannelAnnouncement_clone(&o_conv);
12475         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
12476         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_ok(o_conv);
12477         return (uint64_t)ret_conv;
12478 }
12479
12480 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12481         LDKDecodeError e_conv;
12482         e_conv.inner = (void*)(e & (~1));
12483         e_conv.is_owned = (e & 1) || (e == 0);
12484         e_conv = DecodeError_clone(&e_conv);
12485         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
12486         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_err(e_conv);
12487         return (uint64_t)ret_conv;
12488 }
12489
12490 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12491         if ((_res & 1) != 0) return;
12492         LDKCResult_ChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_ChannelAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
12493         FREE((void*)_res);
12494         CResult_ChannelAnnouncementDecodeErrorZ_free(_res_conv);
12495 }
12496
12497 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12498         LDKCResult_ChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(orig & ~1);
12499         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
12500         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(orig_conv);
12501         return (uint64_t)ret_conv;
12502 }
12503
12504 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12505         LDKUnsignedChannelUpdate o_conv;
12506         o_conv.inner = (void*)(o & (~1));
12507         o_conv.is_owned = (o & 1) || (o == 0);
12508         o_conv = UnsignedChannelUpdate_clone(&o_conv);
12509         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
12510         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_ok(o_conv);
12511         return (uint64_t)ret_conv;
12512 }
12513
12514 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12515         LDKDecodeError e_conv;
12516         e_conv.inner = (void*)(e & (~1));
12517         e_conv.is_owned = (e & 1) || (e == 0);
12518         e_conv = DecodeError_clone(&e_conv);
12519         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
12520         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_err(e_conv);
12521         return (uint64_t)ret_conv;
12522 }
12523
12524 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12525         if ((_res & 1) != 0) return;
12526         LDKCResult_UnsignedChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
12527         FREE((void*)_res);
12528         CResult_UnsignedChannelUpdateDecodeErrorZ_free(_res_conv);
12529 }
12530
12531 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12532         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(orig & ~1);
12533         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
12534         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(orig_conv);
12535         return (uint64_t)ret_conv;
12536 }
12537
12538 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12539         LDKChannelUpdate o_conv;
12540         o_conv.inner = (void*)(o & (~1));
12541         o_conv.is_owned = (o & 1) || (o == 0);
12542         o_conv = ChannelUpdate_clone(&o_conv);
12543         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
12544         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_ok(o_conv);
12545         return (uint64_t)ret_conv;
12546 }
12547
12548 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12549         LDKDecodeError e_conv;
12550         e_conv.inner = (void*)(e & (~1));
12551         e_conv.is_owned = (e & 1) || (e == 0);
12552         e_conv = DecodeError_clone(&e_conv);
12553         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
12554         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_err(e_conv);
12555         return (uint64_t)ret_conv;
12556 }
12557
12558 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12559         if ((_res & 1) != 0) return;
12560         LDKCResult_ChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
12561         FREE((void*)_res);
12562         CResult_ChannelUpdateDecodeErrorZ_free(_res_conv);
12563 }
12564
12565 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12566         LDKCResult_ChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(orig & ~1);
12567         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
12568         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(orig_conv);
12569         return (uint64_t)ret_conv;
12570 }
12571
12572 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12573         LDKErrorMessage o_conv;
12574         o_conv.inner = (void*)(o & (~1));
12575         o_conv.is_owned = (o & 1) || (o == 0);
12576         o_conv = ErrorMessage_clone(&o_conv);
12577         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
12578         *ret_conv = CResult_ErrorMessageDecodeErrorZ_ok(o_conv);
12579         return (uint64_t)ret_conv;
12580 }
12581
12582 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12583         LDKDecodeError e_conv;
12584         e_conv.inner = (void*)(e & (~1));
12585         e_conv.is_owned = (e & 1) || (e == 0);
12586         e_conv = DecodeError_clone(&e_conv);
12587         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
12588         *ret_conv = CResult_ErrorMessageDecodeErrorZ_err(e_conv);
12589         return (uint64_t)ret_conv;
12590 }
12591
12592 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12593         if ((_res & 1) != 0) return;
12594         LDKCResult_ErrorMessageDecodeErrorZ _res_conv = *(LDKCResult_ErrorMessageDecodeErrorZ*)(((uint64_t)_res) & ~1);
12595         FREE((void*)_res);
12596         CResult_ErrorMessageDecodeErrorZ_free(_res_conv);
12597 }
12598
12599 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12600         LDKCResult_ErrorMessageDecodeErrorZ* orig_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(orig & ~1);
12601         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
12602         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(orig_conv);
12603         return (uint64_t)ret_conv;
12604 }
12605
12606 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12607         LDKUnsignedNodeAnnouncement o_conv;
12608         o_conv.inner = (void*)(o & (~1));
12609         o_conv.is_owned = (o & 1) || (o == 0);
12610         o_conv = UnsignedNodeAnnouncement_clone(&o_conv);
12611         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
12612         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(o_conv);
12613         return (uint64_t)ret_conv;
12614 }
12615
12616 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12617         LDKDecodeError e_conv;
12618         e_conv.inner = (void*)(e & (~1));
12619         e_conv.is_owned = (e & 1) || (e == 0);
12620         e_conv = DecodeError_clone(&e_conv);
12621         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
12622         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(e_conv);
12623         return (uint64_t)ret_conv;
12624 }
12625
12626 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12627         if ((_res & 1) != 0) return;
12628         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
12629         FREE((void*)_res);
12630         CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(_res_conv);
12631 }
12632
12633 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12634         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(orig & ~1);
12635         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
12636         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(orig_conv);
12637         return (uint64_t)ret_conv;
12638 }
12639
12640 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12641         LDKNodeAnnouncement o_conv;
12642         o_conv.inner = (void*)(o & (~1));
12643         o_conv.is_owned = (o & 1) || (o == 0);
12644         o_conv = NodeAnnouncement_clone(&o_conv);
12645         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
12646         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_ok(o_conv);
12647         return (uint64_t)ret_conv;
12648 }
12649
12650 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12651         LDKDecodeError e_conv;
12652         e_conv.inner = (void*)(e & (~1));
12653         e_conv.is_owned = (e & 1) || (e == 0);
12654         e_conv = DecodeError_clone(&e_conv);
12655         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
12656         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_err(e_conv);
12657         return (uint64_t)ret_conv;
12658 }
12659
12660 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12661         if ((_res & 1) != 0) return;
12662         LDKCResult_NodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
12663         FREE((void*)_res);
12664         CResult_NodeAnnouncementDecodeErrorZ_free(_res_conv);
12665 }
12666
12667 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12668         LDKCResult_NodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(orig & ~1);
12669         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
12670         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(orig_conv);
12671         return (uint64_t)ret_conv;
12672 }
12673
12674 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12675         LDKQueryShortChannelIds o_conv;
12676         o_conv.inner = (void*)(o & (~1));
12677         o_conv.is_owned = (o & 1) || (o == 0);
12678         o_conv = QueryShortChannelIds_clone(&o_conv);
12679         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
12680         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_ok(o_conv);
12681         return (uint64_t)ret_conv;
12682 }
12683
12684 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12685         LDKDecodeError e_conv;
12686         e_conv.inner = (void*)(e & (~1));
12687         e_conv.is_owned = (e & 1) || (e == 0);
12688         e_conv = DecodeError_clone(&e_conv);
12689         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
12690         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_err(e_conv);
12691         return (uint64_t)ret_conv;
12692 }
12693
12694 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12695         if ((_res & 1) != 0) return;
12696         LDKCResult_QueryShortChannelIdsDecodeErrorZ _res_conv = *(LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(((uint64_t)_res) & ~1);
12697         FREE((void*)_res);
12698         CResult_QueryShortChannelIdsDecodeErrorZ_free(_res_conv);
12699 }
12700
12701 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12702         LDKCResult_QueryShortChannelIdsDecodeErrorZ* orig_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(orig & ~1);
12703         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
12704         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(orig_conv);
12705         return (uint64_t)ret_conv;
12706 }
12707
12708 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12709         LDKReplyShortChannelIdsEnd o_conv;
12710         o_conv.inner = (void*)(o & (~1));
12711         o_conv.is_owned = (o & 1) || (o == 0);
12712         o_conv = ReplyShortChannelIdsEnd_clone(&o_conv);
12713         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
12714         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(o_conv);
12715         return (uint64_t)ret_conv;
12716 }
12717
12718 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12719         LDKDecodeError e_conv;
12720         e_conv.inner = (void*)(e & (~1));
12721         e_conv.is_owned = (e & 1) || (e == 0);
12722         e_conv = DecodeError_clone(&e_conv);
12723         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
12724         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(e_conv);
12725         return (uint64_t)ret_conv;
12726 }
12727
12728 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12729         if ((_res & 1) != 0) return;
12730         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ _res_conv = *(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(((uint64_t)_res) & ~1);
12731         FREE((void*)_res);
12732         CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(_res_conv);
12733 }
12734
12735 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12736         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* orig_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(orig & ~1);
12737         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
12738         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(orig_conv);
12739         return (uint64_t)ret_conv;
12740 }
12741
12742 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12743         LDKQueryChannelRange o_conv;
12744         o_conv.inner = (void*)(o & (~1));
12745         o_conv.is_owned = (o & 1) || (o == 0);
12746         o_conv = QueryChannelRange_clone(&o_conv);
12747         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
12748         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_ok(o_conv);
12749         return (uint64_t)ret_conv;
12750 }
12751
12752 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12753         LDKDecodeError e_conv;
12754         e_conv.inner = (void*)(e & (~1));
12755         e_conv.is_owned = (e & 1) || (e == 0);
12756         e_conv = DecodeError_clone(&e_conv);
12757         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
12758         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_err(e_conv);
12759         return (uint64_t)ret_conv;
12760 }
12761
12762 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12763         if ((_res & 1) != 0) return;
12764         LDKCResult_QueryChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_QueryChannelRangeDecodeErrorZ*)(((uint64_t)_res) & ~1);
12765         FREE((void*)_res);
12766         CResult_QueryChannelRangeDecodeErrorZ_free(_res_conv);
12767 }
12768
12769 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12770         LDKCResult_QueryChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(orig & ~1);
12771         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
12772         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(orig_conv);
12773         return (uint64_t)ret_conv;
12774 }
12775
12776 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12777         LDKReplyChannelRange o_conv;
12778         o_conv.inner = (void*)(o & (~1));
12779         o_conv.is_owned = (o & 1) || (o == 0);
12780         o_conv = ReplyChannelRange_clone(&o_conv);
12781         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
12782         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_ok(o_conv);
12783         return (uint64_t)ret_conv;
12784 }
12785
12786 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12787         LDKDecodeError e_conv;
12788         e_conv.inner = (void*)(e & (~1));
12789         e_conv.is_owned = (e & 1) || (e == 0);
12790         e_conv = DecodeError_clone(&e_conv);
12791         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
12792         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_err(e_conv);
12793         return (uint64_t)ret_conv;
12794 }
12795
12796 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12797         if ((_res & 1) != 0) return;
12798         LDKCResult_ReplyChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_ReplyChannelRangeDecodeErrorZ*)(((uint64_t)_res) & ~1);
12799         FREE((void*)_res);
12800         CResult_ReplyChannelRangeDecodeErrorZ_free(_res_conv);
12801 }
12802
12803 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12804         LDKCResult_ReplyChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(orig & ~1);
12805         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
12806         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(orig_conv);
12807         return (uint64_t)ret_conv;
12808 }
12809
12810 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12811         LDKGossipTimestampFilter o_conv;
12812         o_conv.inner = (void*)(o & (~1));
12813         o_conv.is_owned = (o & 1) || (o == 0);
12814         o_conv = GossipTimestampFilter_clone(&o_conv);
12815         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
12816         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_ok(o_conv);
12817         return (uint64_t)ret_conv;
12818 }
12819
12820 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12821         LDKDecodeError e_conv;
12822         e_conv.inner = (void*)(e & (~1));
12823         e_conv.is_owned = (e & 1) || (e == 0);
12824         e_conv = DecodeError_clone(&e_conv);
12825         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
12826         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_err(e_conv);
12827         return (uint64_t)ret_conv;
12828 }
12829
12830 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12831         if ((_res & 1) != 0) return;
12832         LDKCResult_GossipTimestampFilterDecodeErrorZ _res_conv = *(LDKCResult_GossipTimestampFilterDecodeErrorZ*)(((uint64_t)_res) & ~1);
12833         FREE((void*)_res);
12834         CResult_GossipTimestampFilterDecodeErrorZ_free(_res_conv);
12835 }
12836
12837 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12838         LDKCResult_GossipTimestampFilterDecodeErrorZ* orig_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(orig & ~1);
12839         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
12840         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(orig_conv);
12841         return (uint64_t)ret_conv;
12842 }
12843
12844 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12845         LDKInvoice o_conv;
12846         o_conv.inner = (void*)(o & (~1));
12847         o_conv.is_owned = (o & 1) || (o == 0);
12848         o_conv = Invoice_clone(&o_conv);
12849         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
12850         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_ok(o_conv);
12851         return (uint64_t)ret_conv;
12852 }
12853
12854 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12855         LDKSignOrCreationError e_conv = *(LDKSignOrCreationError*)(((uint64_t)e) & ~1);
12856         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
12857         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_err(e_conv);
12858         return (uint64_t)ret_conv;
12859 }
12860
12861 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12862         if ((_res & 1) != 0) return;
12863         LDKCResult_InvoiceSignOrCreationErrorZ _res_conv = *(LDKCResult_InvoiceSignOrCreationErrorZ*)(((uint64_t)_res) & ~1);
12864         FREE((void*)_res);
12865         CResult_InvoiceSignOrCreationErrorZ_free(_res_conv);
12866 }
12867
12868 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12869         LDKCResult_InvoiceSignOrCreationErrorZ* orig_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(orig & ~1);
12870         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
12871         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone(orig_conv);
12872         return (uint64_t)ret_conv;
12873 }
12874
12875 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Event_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
12876         if ((this_ptr & 1) != 0) return;
12877         LDKEvent this_ptr_conv = *(LDKEvent*)(((uint64_t)this_ptr) & ~1);
12878         FREE((void*)this_ptr);
12879         Event_free(this_ptr_conv);
12880 }
12881
12882 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12883         LDKEvent* orig_conv = (LDKEvent*)orig;
12884         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
12885         *ret_copy = Event_clone(orig_conv);
12886         uint64_t ret_ref = (uint64_t)ret_copy;
12887         return ret_ref;
12888 }
12889
12890 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Event_1write(JNIEnv *env, jclass clz, int64_t obj) {
12891         LDKEvent* obj_conv = (LDKEvent*)obj;
12892         LDKCVec_u8Z ret_var = Event_write(obj_conv);
12893         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
12894         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
12895         CVec_u8Z_free(ret_var);
12896         return ret_arr;
12897 }
12898
12899 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
12900         if ((this_ptr & 1) != 0) return;
12901         LDKMessageSendEvent this_ptr_conv = *(LDKMessageSendEvent*)(((uint64_t)this_ptr) & ~1);
12902         FREE((void*)this_ptr);
12903         MessageSendEvent_free(this_ptr_conv);
12904 }
12905
12906 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12907         LDKMessageSendEvent* orig_conv = (LDKMessageSendEvent*)orig;
12908         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
12909         *ret_copy = MessageSendEvent_clone(orig_conv);
12910         uint64_t ret_ref = (uint64_t)ret_copy;
12911         return ret_ref;
12912 }
12913
12914 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageSendEventsProvider_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
12915         if ((this_ptr & 1) != 0) return;
12916         LDKMessageSendEventsProvider this_ptr_conv = *(LDKMessageSendEventsProvider*)(((uint64_t)this_ptr) & ~1);
12917         FREE((void*)this_ptr);
12918         MessageSendEventsProvider_free(this_ptr_conv);
12919 }
12920
12921 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventsProvider_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
12922         if ((this_ptr & 1) != 0) return;
12923         LDKEventsProvider this_ptr_conv = *(LDKEventsProvider*)(((uint64_t)this_ptr) & ~1);
12924         FREE((void*)this_ptr);
12925         EventsProvider_free(this_ptr_conv);
12926 }
12927
12928 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
12929         if ((this_ptr & 1) != 0) return;
12930         LDKEventHandler this_ptr_conv = *(LDKEventHandler*)(((uint64_t)this_ptr) & ~1);
12931         FREE((void*)this_ptr);
12932         EventHandler_free(this_ptr_conv);
12933 }
12934
12935 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_APIError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
12936         if ((this_ptr & 1) != 0) return;
12937         LDKAPIError this_ptr_conv = *(LDKAPIError*)(((uint64_t)this_ptr) & ~1);
12938         FREE((void*)this_ptr);
12939         APIError_free(this_ptr_conv);
12940 }
12941
12942 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12943         LDKAPIError* orig_conv = (LDKAPIError*)orig;
12944         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
12945         *ret_copy = APIError_clone(orig_conv);
12946         uint64_t ret_ref = (uint64_t)ret_copy;
12947         return ret_ref;
12948 }
12949
12950 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_sign(JNIEnv *env, jclass clz, int8_tArray msg, int8_tArray sk) {
12951         LDKu8slice msg_ref;
12952         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
12953         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
12954         LDKSecretKey sk_ref;
12955         CHECK((*env)->GetArrayLength(env, sk) == 32);
12956         (*env)->GetByteArrayRegion(env, sk, 0, 32, sk_ref.bytes);
12957         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
12958         *ret_conv = sign(msg_ref, sk_ref);
12959         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
12960         return (uint64_t)ret_conv;
12961 }
12962
12963 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_recover_1pk(JNIEnv *env, jclass clz, int8_tArray msg, jstring sig) {
12964         LDKu8slice msg_ref;
12965         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
12966         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
12967         LDKStr sig_conv = java_to_owned_str(env, sig);
12968         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
12969         *ret_conv = recover_pk(msg_ref, sig_conv);
12970         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
12971         return (uint64_t)ret_conv;
12972 }
12973
12974 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_verify(JNIEnv *env, jclass clz, int8_tArray msg, jstring sig, int8_tArray pk) {
12975         LDKu8slice msg_ref;
12976         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
12977         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
12978         LDKStr sig_conv = java_to_owned_str(env, sig);
12979         LDKPublicKey pk_ref;
12980         CHECK((*env)->GetArrayLength(env, pk) == 33);
12981         (*env)->GetByteArrayRegion(env, pk, 0, 33, pk_ref.compressed_form);
12982         jboolean ret_val = verify(msg_ref, sig_conv, pk_ref);
12983         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
12984         return ret_val;
12985 }
12986
12987 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12988         LDKLevel* orig_conv = (LDKLevel*)(orig & ~1);
12989         jclass ret_conv = LDKLevel_to_java(env, Level_clone(orig_conv));
12990         return ret_conv;
12991 }
12992
12993 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Level_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
12994         LDKLevel* a_conv = (LDKLevel*)(a & ~1);
12995         LDKLevel* b_conv = (LDKLevel*)(b & ~1);
12996         jboolean ret_val = Level_eq(a_conv, b_conv);
12997         return ret_val;
12998 }
12999
13000 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Level_1hash(JNIEnv *env, jclass clz, int64_t o) {
13001         LDKLevel* o_conv = (LDKLevel*)(o & ~1);
13002         int64_t ret_val = Level_hash(o_conv);
13003         return ret_val;
13004 }
13005
13006 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1max(JNIEnv *env, jclass clz) {
13007         jclass ret_conv = LDKLevel_to_java(env, Level_max());
13008         return ret_conv;
13009 }
13010
13011 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Logger_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
13012         if ((this_ptr & 1) != 0) return;
13013         LDKLogger this_ptr_conv = *(LDKLogger*)(((uint64_t)this_ptr) & ~1);
13014         FREE((void*)this_ptr);
13015         Logger_free(this_ptr_conv);
13016 }
13017
13018 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
13019         LDKChannelHandshakeConfig this_obj_conv;
13020         this_obj_conv.inner = (void*)(this_obj & (~1));
13021         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13022         ChannelHandshakeConfig_free(this_obj_conv);
13023 }
13024
13025 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
13026         LDKChannelHandshakeConfig this_ptr_conv;
13027         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13028         this_ptr_conv.is_owned = false;
13029         int32_t ret_val = ChannelHandshakeConfig_get_minimum_depth(&this_ptr_conv);
13030         return ret_val;
13031 }
13032
13033 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
13034         LDKChannelHandshakeConfig this_ptr_conv;
13035         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13036         this_ptr_conv.is_owned = false;
13037         ChannelHandshakeConfig_set_minimum_depth(&this_ptr_conv, val);
13038 }
13039
13040 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1our_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
13041         LDKChannelHandshakeConfig this_ptr_conv;
13042         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13043         this_ptr_conv.is_owned = false;
13044         int16_t ret_val = ChannelHandshakeConfig_get_our_to_self_delay(&this_ptr_conv);
13045         return ret_val;
13046 }
13047
13048 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) {
13049         LDKChannelHandshakeConfig this_ptr_conv;
13050         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13051         this_ptr_conv.is_owned = false;
13052         ChannelHandshakeConfig_set_our_to_self_delay(&this_ptr_conv, val);
13053 }
13054
13055 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1our_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
13056         LDKChannelHandshakeConfig this_ptr_conv;
13057         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13058         this_ptr_conv.is_owned = false;
13059         int64_t ret_val = ChannelHandshakeConfig_get_our_htlc_minimum_msat(&this_ptr_conv);
13060         return ret_val;
13061 }
13062
13063 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) {
13064         LDKChannelHandshakeConfig this_ptr_conv;
13065         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13066         this_ptr_conv.is_owned = false;
13067         ChannelHandshakeConfig_set_our_htlc_minimum_msat(&this_ptr_conv, val);
13068 }
13069
13070 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) {
13071         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_new(minimum_depth_arg, our_to_self_delay_arg, our_htlc_minimum_msat_arg);
13072         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13073         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13074         uint64_t ret_ref = (uint64_t)ret_var.inner;
13075         if (ret_var.is_owned) {
13076                 ret_ref |= 1;
13077         }
13078         return ret_ref;
13079 }
13080
13081 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13082         LDKChannelHandshakeConfig orig_conv;
13083         orig_conv.inner = (void*)(orig & (~1));
13084         orig_conv.is_owned = false;
13085         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(&orig_conv);
13086         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13087         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13088         uint64_t ret_ref = (uint64_t)ret_var.inner;
13089         if (ret_var.is_owned) {
13090                 ret_ref |= 1;
13091         }
13092         return ret_ref;
13093 }
13094
13095 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1default(JNIEnv *env, jclass clz) {
13096         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_default();
13097         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13098         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13099         uint64_t ret_ref = (uint64_t)ret_var.inner;
13100         if (ret_var.is_owned) {
13101                 ret_ref |= 1;
13102         }
13103         return ret_ref;
13104 }
13105
13106 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
13107         LDKChannelHandshakeLimits this_obj_conv;
13108         this_obj_conv.inner = (void*)(this_obj & (~1));
13109         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13110         ChannelHandshakeLimits_free(this_obj_conv);
13111 }
13112
13113 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
13114         LDKChannelHandshakeLimits this_ptr_conv;
13115         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13116         this_ptr_conv.is_owned = false;
13117         int64_t ret_val = ChannelHandshakeLimits_get_min_funding_satoshis(&this_ptr_conv);
13118         return ret_val;
13119 }
13120
13121 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1min_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
13122         LDKChannelHandshakeLimits this_ptr_conv;
13123         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13124         this_ptr_conv.is_owned = false;
13125         ChannelHandshakeLimits_set_min_funding_satoshis(&this_ptr_conv, val);
13126 }
13127
13128 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
13129         LDKChannelHandshakeLimits this_ptr_conv;
13130         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13131         this_ptr_conv.is_owned = false;
13132         int64_t ret_val = ChannelHandshakeLimits_get_max_htlc_minimum_msat(&this_ptr_conv);
13133         return ret_val;
13134 }
13135
13136 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) {
13137         LDKChannelHandshakeLimits this_ptr_conv;
13138         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13139         this_ptr_conv.is_owned = false;
13140         ChannelHandshakeLimits_set_max_htlc_minimum_msat(&this_ptr_conv, val);
13141 }
13142
13143 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) {
13144         LDKChannelHandshakeLimits this_ptr_conv;
13145         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13146         this_ptr_conv.is_owned = false;
13147         int64_t ret_val = ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(&this_ptr_conv);
13148         return ret_val;
13149 }
13150
13151 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) {
13152         LDKChannelHandshakeLimits this_ptr_conv;
13153         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13154         this_ptr_conv.is_owned = false;
13155         ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
13156 }
13157
13158 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
13159         LDKChannelHandshakeLimits this_ptr_conv;
13160         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13161         this_ptr_conv.is_owned = false;
13162         int64_t ret_val = ChannelHandshakeLimits_get_max_channel_reserve_satoshis(&this_ptr_conv);
13163         return ret_val;
13164 }
13165
13166 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) {
13167         LDKChannelHandshakeLimits this_ptr_conv;
13168         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13169         this_ptr_conv.is_owned = false;
13170         ChannelHandshakeLimits_set_max_channel_reserve_satoshis(&this_ptr_conv, val);
13171 }
13172
13173 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
13174         LDKChannelHandshakeLimits this_ptr_conv;
13175         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13176         this_ptr_conv.is_owned = false;
13177         int16_t ret_val = ChannelHandshakeLimits_get_min_max_accepted_htlcs(&this_ptr_conv);
13178         return ret_val;
13179 }
13180
13181 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) {
13182         LDKChannelHandshakeLimits this_ptr_conv;
13183         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13184         this_ptr_conv.is_owned = false;
13185         ChannelHandshakeLimits_set_min_max_accepted_htlcs(&this_ptr_conv, val);
13186 }
13187
13188 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
13189         LDKChannelHandshakeLimits this_ptr_conv;
13190         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13191         this_ptr_conv.is_owned = false;
13192         int32_t ret_val = ChannelHandshakeLimits_get_max_minimum_depth(&this_ptr_conv);
13193         return ret_val;
13194 }
13195
13196 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1max_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
13197         LDKChannelHandshakeLimits this_ptr_conv;
13198         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13199         this_ptr_conv.is_owned = false;
13200         ChannelHandshakeLimits_set_max_minimum_depth(&this_ptr_conv, val);
13201 }
13202
13203 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1force_1announced_1channel_1preference(JNIEnv *env, jclass clz, int64_t this_ptr) {
13204         LDKChannelHandshakeLimits this_ptr_conv;
13205         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13206         this_ptr_conv.is_owned = false;
13207         jboolean ret_val = ChannelHandshakeLimits_get_force_announced_channel_preference(&this_ptr_conv);
13208         return ret_val;
13209 }
13210
13211 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1force_1announced_1channel_1preference(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
13212         LDKChannelHandshakeLimits this_ptr_conv;
13213         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13214         this_ptr_conv.is_owned = false;
13215         ChannelHandshakeLimits_set_force_announced_channel_preference(&this_ptr_conv, val);
13216 }
13217
13218 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1their_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
13219         LDKChannelHandshakeLimits this_ptr_conv;
13220         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13221         this_ptr_conv.is_owned = false;
13222         int16_t ret_val = ChannelHandshakeLimits_get_their_to_self_delay(&this_ptr_conv);
13223         return ret_val;
13224 }
13225
13226 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) {
13227         LDKChannelHandshakeLimits this_ptr_conv;
13228         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13229         this_ptr_conv.is_owned = false;
13230         ChannelHandshakeLimits_set_their_to_self_delay(&this_ptr_conv, val);
13231 }
13232
13233 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) {
13234         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);
13235         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13236         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13237         uint64_t ret_ref = (uint64_t)ret_var.inner;
13238         if (ret_var.is_owned) {
13239                 ret_ref |= 1;
13240         }
13241         return ret_ref;
13242 }
13243
13244 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13245         LDKChannelHandshakeLimits orig_conv;
13246         orig_conv.inner = (void*)(orig & (~1));
13247         orig_conv.is_owned = false;
13248         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(&orig_conv);
13249         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13250         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13251         uint64_t ret_ref = (uint64_t)ret_var.inner;
13252         if (ret_var.is_owned) {
13253                 ret_ref |= 1;
13254         }
13255         return ret_ref;
13256 }
13257
13258 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1default(JNIEnv *env, jclass clz) {
13259         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_default();
13260         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13261         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13262         uint64_t ret_ref = (uint64_t)ret_var.inner;
13263         if (ret_var.is_owned) {
13264                 ret_ref |= 1;
13265         }
13266         return ret_ref;
13267 }
13268
13269 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
13270         LDKChannelConfig this_obj_conv;
13271         this_obj_conv.inner = (void*)(this_obj & (~1));
13272         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13273         ChannelConfig_free(this_obj_conv);
13274 }
13275
13276 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
13277         LDKChannelConfig this_ptr_conv;
13278         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13279         this_ptr_conv.is_owned = false;
13280         int32_t ret_val = ChannelConfig_get_fee_proportional_millionths(&this_ptr_conv);
13281         return ret_val;
13282 }
13283
13284 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
13285         LDKChannelConfig this_ptr_conv;
13286         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13287         this_ptr_conv.is_owned = false;
13288         ChannelConfig_set_fee_proportional_millionths(&this_ptr_conv, val);
13289 }
13290
13291 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
13292         LDKChannelConfig this_ptr_conv;
13293         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13294         this_ptr_conv.is_owned = false;
13295         int16_t ret_val = ChannelConfig_get_cltv_expiry_delta(&this_ptr_conv);
13296         return ret_val;
13297 }
13298
13299 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
13300         LDKChannelConfig this_ptr_conv;
13301         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13302         this_ptr_conv.is_owned = false;
13303         ChannelConfig_set_cltv_expiry_delta(&this_ptr_conv, val);
13304 }
13305
13306 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1announced_1channel(JNIEnv *env, jclass clz, int64_t this_ptr) {
13307         LDKChannelConfig this_ptr_conv;
13308         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13309         this_ptr_conv.is_owned = false;
13310         jboolean ret_val = ChannelConfig_get_announced_channel(&this_ptr_conv);
13311         return ret_val;
13312 }
13313
13314 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1announced_1channel(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
13315         LDKChannelConfig this_ptr_conv;
13316         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13317         this_ptr_conv.is_owned = false;
13318         ChannelConfig_set_announced_channel(&this_ptr_conv, val);
13319 }
13320
13321 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1commit_1upfront_1shutdown_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
13322         LDKChannelConfig this_ptr_conv;
13323         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13324         this_ptr_conv.is_owned = false;
13325         jboolean ret_val = ChannelConfig_get_commit_upfront_shutdown_pubkey(&this_ptr_conv);
13326         return ret_val;
13327 }
13328
13329 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1commit_1upfront_1shutdown_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
13330         LDKChannelConfig this_ptr_conv;
13331         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13332         this_ptr_conv.is_owned = false;
13333         ChannelConfig_set_commit_upfront_shutdown_pubkey(&this_ptr_conv, val);
13334 }
13335
13336 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) {
13337         LDKChannelConfig ret_var = ChannelConfig_new(fee_proportional_millionths_arg, cltv_expiry_delta_arg, announced_channel_arg, commit_upfront_shutdown_pubkey_arg);
13338         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13339         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13340         uint64_t ret_ref = (uint64_t)ret_var.inner;
13341         if (ret_var.is_owned) {
13342                 ret_ref |= 1;
13343         }
13344         return ret_ref;
13345 }
13346
13347 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13348         LDKChannelConfig orig_conv;
13349         orig_conv.inner = (void*)(orig & (~1));
13350         orig_conv.is_owned = false;
13351         LDKChannelConfig ret_var = ChannelConfig_clone(&orig_conv);
13352         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13353         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13354         uint64_t ret_ref = (uint64_t)ret_var.inner;
13355         if (ret_var.is_owned) {
13356                 ret_ref |= 1;
13357         }
13358         return ret_ref;
13359 }
13360
13361 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1default(JNIEnv *env, jclass clz) {
13362         LDKChannelConfig ret_var = ChannelConfig_default();
13363         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13364         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13365         uint64_t ret_ref = (uint64_t)ret_var.inner;
13366         if (ret_var.is_owned) {
13367                 ret_ref |= 1;
13368         }
13369         return ret_ref;
13370 }
13371
13372 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1write(JNIEnv *env, jclass clz, int64_t obj) {
13373         LDKChannelConfig obj_conv;
13374         obj_conv.inner = (void*)(obj & (~1));
13375         obj_conv.is_owned = false;
13376         LDKCVec_u8Z ret_var = ChannelConfig_write(&obj_conv);
13377         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
13378         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
13379         CVec_u8Z_free(ret_var);
13380         return ret_arr;
13381 }
13382
13383 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
13384         LDKu8slice ser_ref;
13385         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
13386         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
13387         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
13388         *ret_conv = ChannelConfig_read(ser_ref);
13389         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
13390         return (uint64_t)ret_conv;
13391 }
13392
13393 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
13394         LDKUserConfig this_obj_conv;
13395         this_obj_conv.inner = (void*)(this_obj & (~1));
13396         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13397         UserConfig_free(this_obj_conv);
13398 }
13399
13400 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1own_1channel_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
13401         LDKUserConfig this_ptr_conv;
13402         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13403         this_ptr_conv.is_owned = false;
13404         LDKChannelHandshakeConfig ret_var = UserConfig_get_own_channel_config(&this_ptr_conv);
13405         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13406         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13407         uint64_t ret_ref = (uint64_t)ret_var.inner;
13408         if (ret_var.is_owned) {
13409                 ret_ref |= 1;
13410         }
13411         return ret_ref;
13412 }
13413
13414 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1own_1channel_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
13415         LDKUserConfig this_ptr_conv;
13416         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13417         this_ptr_conv.is_owned = false;
13418         LDKChannelHandshakeConfig val_conv;
13419         val_conv.inner = (void*)(val & (~1));
13420         val_conv.is_owned = (val & 1) || (val == 0);
13421         val_conv = ChannelHandshakeConfig_clone(&val_conv);
13422         UserConfig_set_own_channel_config(&this_ptr_conv, val_conv);
13423 }
13424
13425 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1peer_1channel_1config_1limits(JNIEnv *env, jclass clz, int64_t this_ptr) {
13426         LDKUserConfig this_ptr_conv;
13427         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13428         this_ptr_conv.is_owned = false;
13429         LDKChannelHandshakeLimits ret_var = UserConfig_get_peer_channel_config_limits(&this_ptr_conv);
13430         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13431         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13432         uint64_t ret_ref = (uint64_t)ret_var.inner;
13433         if (ret_var.is_owned) {
13434                 ret_ref |= 1;
13435         }
13436         return ret_ref;
13437 }
13438
13439 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) {
13440         LDKUserConfig this_ptr_conv;
13441         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13442         this_ptr_conv.is_owned = false;
13443         LDKChannelHandshakeLimits val_conv;
13444         val_conv.inner = (void*)(val & (~1));
13445         val_conv.is_owned = (val & 1) || (val == 0);
13446         val_conv = ChannelHandshakeLimits_clone(&val_conv);
13447         UserConfig_set_peer_channel_config_limits(&this_ptr_conv, val_conv);
13448 }
13449
13450 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1channel_1options(JNIEnv *env, jclass clz, int64_t this_ptr) {
13451         LDKUserConfig this_ptr_conv;
13452         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13453         this_ptr_conv.is_owned = false;
13454         LDKChannelConfig ret_var = UserConfig_get_channel_options(&this_ptr_conv);
13455         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13456         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13457         uint64_t ret_ref = (uint64_t)ret_var.inner;
13458         if (ret_var.is_owned) {
13459                 ret_ref |= 1;
13460         }
13461         return ret_ref;
13462 }
13463
13464 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1channel_1options(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
13465         LDKUserConfig this_ptr_conv;
13466         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13467         this_ptr_conv.is_owned = false;
13468         LDKChannelConfig val_conv;
13469         val_conv.inner = (void*)(val & (~1));
13470         val_conv.is_owned = (val & 1) || (val == 0);
13471         val_conv = ChannelConfig_clone(&val_conv);
13472         UserConfig_set_channel_options(&this_ptr_conv, val_conv);
13473 }
13474
13475 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) {
13476         LDKChannelHandshakeConfig own_channel_config_arg_conv;
13477         own_channel_config_arg_conv.inner = (void*)(own_channel_config_arg & (~1));
13478         own_channel_config_arg_conv.is_owned = (own_channel_config_arg & 1) || (own_channel_config_arg == 0);
13479         own_channel_config_arg_conv = ChannelHandshakeConfig_clone(&own_channel_config_arg_conv);
13480         LDKChannelHandshakeLimits peer_channel_config_limits_arg_conv;
13481         peer_channel_config_limits_arg_conv.inner = (void*)(peer_channel_config_limits_arg & (~1));
13482         peer_channel_config_limits_arg_conv.is_owned = (peer_channel_config_limits_arg & 1) || (peer_channel_config_limits_arg == 0);
13483         peer_channel_config_limits_arg_conv = ChannelHandshakeLimits_clone(&peer_channel_config_limits_arg_conv);
13484         LDKChannelConfig channel_options_arg_conv;
13485         channel_options_arg_conv.inner = (void*)(channel_options_arg & (~1));
13486         channel_options_arg_conv.is_owned = (channel_options_arg & 1) || (channel_options_arg == 0);
13487         channel_options_arg_conv = ChannelConfig_clone(&channel_options_arg_conv);
13488         LDKUserConfig ret_var = UserConfig_new(own_channel_config_arg_conv, peer_channel_config_limits_arg_conv, channel_options_arg_conv);
13489         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13490         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13491         uint64_t ret_ref = (uint64_t)ret_var.inner;
13492         if (ret_var.is_owned) {
13493                 ret_ref |= 1;
13494         }
13495         return ret_ref;
13496 }
13497
13498 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13499         LDKUserConfig orig_conv;
13500         orig_conv.inner = (void*)(orig & (~1));
13501         orig_conv.is_owned = false;
13502         LDKUserConfig ret_var = UserConfig_clone(&orig_conv);
13503         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13504         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13505         uint64_t ret_ref = (uint64_t)ret_var.inner;
13506         if (ret_var.is_owned) {
13507                 ret_ref |= 1;
13508         }
13509         return ret_ref;
13510 }
13511
13512 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1default(JNIEnv *env, jclass clz) {
13513         LDKUserConfig ret_var = UserConfig_default();
13514         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13515         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13516         uint64_t ret_ref = (uint64_t)ret_var.inner;
13517         if (ret_var.is_owned) {
13518                 ret_ref |= 1;
13519         }
13520         return ret_ref;
13521 }
13522
13523 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_AccessError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13524         LDKAccessError* orig_conv = (LDKAccessError*)(orig & ~1);
13525         jclass ret_conv = LDKAccessError_to_java(env, AccessError_clone(orig_conv));
13526         return ret_conv;
13527 }
13528
13529 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Access_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
13530         if ((this_ptr & 1) != 0) return;
13531         LDKAccess this_ptr_conv = *(LDKAccess*)(((uint64_t)this_ptr) & ~1);
13532         FREE((void*)this_ptr);
13533         Access_free(this_ptr_conv);
13534 }
13535
13536 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Listen_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
13537         if ((this_ptr & 1) != 0) return;
13538         LDKListen this_ptr_conv = *(LDKListen*)(((uint64_t)this_ptr) & ~1);
13539         FREE((void*)this_ptr);
13540         Listen_free(this_ptr_conv);
13541 }
13542
13543 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Confirm_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
13544         if ((this_ptr & 1) != 0) return;
13545         LDKConfirm this_ptr_conv = *(LDKConfirm*)(((uint64_t)this_ptr) & ~1);
13546         FREE((void*)this_ptr);
13547         Confirm_free(this_ptr_conv);
13548 }
13549
13550 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Watch_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
13551         if ((this_ptr & 1) != 0) return;
13552         LDKWatch this_ptr_conv = *(LDKWatch*)(((uint64_t)this_ptr) & ~1);
13553         FREE((void*)this_ptr);
13554         Watch_free(this_ptr_conv);
13555 }
13556
13557 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Filter_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
13558         if ((this_ptr & 1) != 0) return;
13559         LDKFilter this_ptr_conv = *(LDKFilter*)(((uint64_t)this_ptr) & ~1);
13560         FREE((void*)this_ptr);
13561         Filter_free(this_ptr_conv);
13562 }
13563
13564 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
13565         LDKWatchedOutput this_obj_conv;
13566         this_obj_conv.inner = (void*)(this_obj & (~1));
13567         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13568         WatchedOutput_free(this_obj_conv);
13569 }
13570
13571 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1block_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
13572         LDKWatchedOutput this_ptr_conv;
13573         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13574         this_ptr_conv.is_owned = false;
13575         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
13576         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, WatchedOutput_get_block_hash(&this_ptr_conv).data);
13577         return ret_arr;
13578 }
13579
13580 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1block_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
13581         LDKWatchedOutput this_ptr_conv;
13582         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13583         this_ptr_conv.is_owned = false;
13584         LDKThirtyTwoBytes val_ref;
13585         CHECK((*env)->GetArrayLength(env, val) == 32);
13586         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
13587         WatchedOutput_set_block_hash(&this_ptr_conv, val_ref);
13588 }
13589
13590 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
13591         LDKWatchedOutput this_ptr_conv;
13592         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13593         this_ptr_conv.is_owned = false;
13594         LDKOutPoint ret_var = WatchedOutput_get_outpoint(&this_ptr_conv);
13595         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13596         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13597         uint64_t ret_ref = (uint64_t)ret_var.inner;
13598         if (ret_var.is_owned) {
13599                 ret_ref |= 1;
13600         }
13601         return ret_ref;
13602 }
13603
13604 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
13605         LDKWatchedOutput this_ptr_conv;
13606         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13607         this_ptr_conv.is_owned = false;
13608         LDKOutPoint val_conv;
13609         val_conv.inner = (void*)(val & (~1));
13610         val_conv.is_owned = (val & 1) || (val == 0);
13611         val_conv = OutPoint_clone(&val_conv);
13612         WatchedOutput_set_outpoint(&this_ptr_conv, val_conv);
13613 }
13614
13615 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1script_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
13616         LDKWatchedOutput this_ptr_conv;
13617         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13618         this_ptr_conv.is_owned = false;
13619         LDKu8slice ret_var = WatchedOutput_get_script_pubkey(&this_ptr_conv);
13620         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
13621         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
13622         return ret_arr;
13623 }
13624
13625 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1script_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
13626         LDKWatchedOutput this_ptr_conv;
13627         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13628         this_ptr_conv.is_owned = false;
13629         LDKCVec_u8Z val_ref;
13630         val_ref.datalen = (*env)->GetArrayLength(env, val);
13631         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
13632         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
13633         WatchedOutput_set_script_pubkey(&this_ptr_conv, val_ref);
13634 }
13635
13636 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) {
13637         LDKThirtyTwoBytes block_hash_arg_ref;
13638         CHECK((*env)->GetArrayLength(env, block_hash_arg) == 32);
13639         (*env)->GetByteArrayRegion(env, block_hash_arg, 0, 32, block_hash_arg_ref.data);
13640         LDKOutPoint outpoint_arg_conv;
13641         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
13642         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
13643         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
13644         LDKCVec_u8Z script_pubkey_arg_ref;
13645         script_pubkey_arg_ref.datalen = (*env)->GetArrayLength(env, script_pubkey_arg);
13646         script_pubkey_arg_ref.data = MALLOC(script_pubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
13647         (*env)->GetByteArrayRegion(env, script_pubkey_arg, 0, script_pubkey_arg_ref.datalen, script_pubkey_arg_ref.data);
13648         LDKWatchedOutput ret_var = WatchedOutput_new(block_hash_arg_ref, outpoint_arg_conv, script_pubkey_arg_ref);
13649         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13650         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13651         uint64_t ret_ref = (uint64_t)ret_var.inner;
13652         if (ret_var.is_owned) {
13653                 ret_ref |= 1;
13654         }
13655         return ret_ref;
13656 }
13657
13658 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13659         LDKWatchedOutput orig_conv;
13660         orig_conv.inner = (void*)(orig & (~1));
13661         orig_conv.is_owned = false;
13662         LDKWatchedOutput ret_var = WatchedOutput_clone(&orig_conv);
13663         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13664         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13665         uint64_t ret_ref = (uint64_t)ret_var.inner;
13666         if (ret_var.is_owned) {
13667                 ret_ref |= 1;
13668         }
13669         return ret_ref;
13670 }
13671
13672 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1hash(JNIEnv *env, jclass clz, int64_t o) {
13673         LDKWatchedOutput o_conv;
13674         o_conv.inner = (void*)(o & (~1));
13675         o_conv.is_owned = false;
13676         int64_t ret_val = WatchedOutput_hash(&o_conv);
13677         return ret_val;
13678 }
13679
13680 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BroadcasterInterface_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
13681         if ((this_ptr & 1) != 0) return;
13682         LDKBroadcasterInterface this_ptr_conv = *(LDKBroadcasterInterface*)(((uint64_t)this_ptr) & ~1);
13683         FREE((void*)this_ptr);
13684         BroadcasterInterface_free(this_ptr_conv);
13685 }
13686
13687 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13688         LDKConfirmationTarget* orig_conv = (LDKConfirmationTarget*)(orig & ~1);
13689         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_clone(orig_conv));
13690         return ret_conv;
13691 }
13692
13693 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FeeEstimator_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
13694         if ((this_ptr & 1) != 0) return;
13695         LDKFeeEstimator this_ptr_conv = *(LDKFeeEstimator*)(((uint64_t)this_ptr) & ~1);
13696         FREE((void*)this_ptr);
13697         FeeEstimator_free(this_ptr_conv);
13698 }
13699
13700 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
13701         LDKChainMonitor this_obj_conv;
13702         this_obj_conv.inner = (void*)(this_obj & (~1));
13703         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13704         ChainMonitor_free(this_obj_conv);
13705 }
13706
13707 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) {
13708         LDKFilter *chain_source_conv_ptr = NULL;
13709         if (chain_source != 0) {
13710                 LDKFilter chain_source_conv;
13711                 chain_source_conv = *(LDKFilter*)(((uint64_t)chain_source) & ~1);
13712                 if (chain_source_conv.free == LDKFilter_JCalls_free) {
13713                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
13714                         LDKFilter_JCalls_clone(chain_source_conv.this_arg);
13715                 }
13716                 chain_source_conv_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter");
13717                 *chain_source_conv_ptr = chain_source_conv;
13718         }
13719         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
13720         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
13721                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
13722                 LDKBroadcasterInterface_JCalls_clone(broadcaster_conv.this_arg);
13723         }
13724         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
13725         if (logger_conv.free == LDKLogger_JCalls_free) {
13726                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
13727                 LDKLogger_JCalls_clone(logger_conv.this_arg);
13728         }
13729         LDKFeeEstimator feeest_conv = *(LDKFeeEstimator*)(((uint64_t)feeest) & ~1);
13730         if (feeest_conv.free == LDKFeeEstimator_JCalls_free) {
13731                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
13732                 LDKFeeEstimator_JCalls_clone(feeest_conv.this_arg);
13733         }
13734         LDKPersist persister_conv = *(LDKPersist*)(((uint64_t)persister) & ~1);
13735         if (persister_conv.free == LDKPersist_JCalls_free) {
13736                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
13737                 LDKPersist_JCalls_clone(persister_conv.this_arg);
13738         }
13739         LDKChainMonitor ret_var = ChainMonitor_new(chain_source_conv_ptr, broadcaster_conv, logger_conv, feeest_conv, persister_conv);
13740         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13741         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13742         uint64_t ret_ref = (uint64_t)ret_var.inner;
13743         if (ret_var.is_owned) {
13744                 ret_ref |= 1;
13745         }
13746         return ret_ref;
13747 }
13748
13749 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Listen(JNIEnv *env, jclass clz, int64_t this_arg) {
13750         LDKChainMonitor this_arg_conv;
13751         this_arg_conv.inner = (void*)(this_arg & (~1));
13752         this_arg_conv.is_owned = false;
13753         LDKListen* ret = MALLOC(sizeof(LDKListen), "LDKListen");
13754         *ret = ChainMonitor_as_Listen(&this_arg_conv);
13755         return (uint64_t)ret;
13756 }
13757
13758 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Confirm(JNIEnv *env, jclass clz, int64_t this_arg) {
13759         LDKChainMonitor this_arg_conv;
13760         this_arg_conv.inner = (void*)(this_arg & (~1));
13761         this_arg_conv.is_owned = false;
13762         LDKConfirm* ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
13763         *ret = ChainMonitor_as_Confirm(&this_arg_conv);
13764         return (uint64_t)ret;
13765 }
13766
13767 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Watch(JNIEnv *env, jclass clz, int64_t this_arg) {
13768         LDKChainMonitor this_arg_conv;
13769         this_arg_conv.inner = (void*)(this_arg & (~1));
13770         this_arg_conv.is_owned = false;
13771         LDKWatch* ret = MALLOC(sizeof(LDKWatch), "LDKWatch");
13772         *ret = ChainMonitor_as_Watch(&this_arg_conv);
13773         return (uint64_t)ret;
13774 }
13775
13776 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1EventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
13777         LDKChainMonitor this_arg_conv;
13778         this_arg_conv.inner = (void*)(this_arg & (~1));
13779         this_arg_conv.is_owned = false;
13780         LDKEventsProvider* ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
13781         *ret = ChainMonitor_as_EventsProvider(&this_arg_conv);
13782         return (uint64_t)ret;
13783 }
13784
13785 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
13786         LDKChannelMonitorUpdate this_obj_conv;
13787         this_obj_conv.inner = (void*)(this_obj & (~1));
13788         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13789         ChannelMonitorUpdate_free(this_obj_conv);
13790 }
13791
13792 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1get_1update_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
13793         LDKChannelMonitorUpdate this_ptr_conv;
13794         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13795         this_ptr_conv.is_owned = false;
13796         int64_t ret_val = ChannelMonitorUpdate_get_update_id(&this_ptr_conv);
13797         return ret_val;
13798 }
13799
13800 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1set_1update_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
13801         LDKChannelMonitorUpdate this_ptr_conv;
13802         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13803         this_ptr_conv.is_owned = false;
13804         ChannelMonitorUpdate_set_update_id(&this_ptr_conv, val);
13805 }
13806
13807 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13808         LDKChannelMonitorUpdate orig_conv;
13809         orig_conv.inner = (void*)(orig & (~1));
13810         orig_conv.is_owned = false;
13811         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(&orig_conv);
13812         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13813         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13814         uint64_t ret_ref = (uint64_t)ret_var.inner;
13815         if (ret_var.is_owned) {
13816                 ret_ref |= 1;
13817         }
13818         return ret_ref;
13819 }
13820
13821 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
13822         LDKChannelMonitorUpdate obj_conv;
13823         obj_conv.inner = (void*)(obj & (~1));
13824         obj_conv.is_owned = false;
13825         LDKCVec_u8Z ret_var = ChannelMonitorUpdate_write(&obj_conv);
13826         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
13827         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
13828         CVec_u8Z_free(ret_var);
13829         return ret_arr;
13830 }
13831
13832 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
13833         LDKu8slice ser_ref;
13834         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
13835         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
13836         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
13837         *ret_conv = ChannelMonitorUpdate_read(ser_ref);
13838         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
13839         return (uint64_t)ret_conv;
13840 }
13841
13842 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateErr_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13843         LDKChannelMonitorUpdateErr* orig_conv = (LDKChannelMonitorUpdateErr*)(orig & ~1);
13844         jclass ret_conv = LDKChannelMonitorUpdateErr_to_java(env, ChannelMonitorUpdateErr_clone(orig_conv));
13845         return ret_conv;
13846 }
13847
13848 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorUpdateError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
13849         LDKMonitorUpdateError this_obj_conv;
13850         this_obj_conv.inner = (void*)(this_obj & (~1));
13851         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13852         MonitorUpdateError_free(this_obj_conv);
13853 }
13854
13855 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorUpdateError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13856         LDKMonitorUpdateError orig_conv;
13857         orig_conv.inner = (void*)(orig & (~1));
13858         orig_conv.is_owned = false;
13859         LDKMonitorUpdateError ret_var = MonitorUpdateError_clone(&orig_conv);
13860         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13861         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13862         uint64_t ret_ref = (uint64_t)ret_var.inner;
13863         if (ret_var.is_owned) {
13864                 ret_ref |= 1;
13865         }
13866         return ret_ref;
13867 }
13868
13869 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
13870         if ((this_ptr & 1) != 0) return;
13871         LDKMonitorEvent this_ptr_conv = *(LDKMonitorEvent*)(((uint64_t)this_ptr) & ~1);
13872         FREE((void*)this_ptr);
13873         MonitorEvent_free(this_ptr_conv);
13874 }
13875
13876 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13877         LDKMonitorEvent* orig_conv = (LDKMonitorEvent*)orig;
13878         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
13879         *ret_copy = MonitorEvent_clone(orig_conv);
13880         uint64_t ret_ref = (uint64_t)ret_copy;
13881         return ret_ref;
13882 }
13883
13884 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
13885         LDKHTLCUpdate this_obj_conv;
13886         this_obj_conv.inner = (void*)(this_obj & (~1));
13887         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13888         HTLCUpdate_free(this_obj_conv);
13889 }
13890
13891 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13892         LDKHTLCUpdate orig_conv;
13893         orig_conv.inner = (void*)(orig & (~1));
13894         orig_conv.is_owned = false;
13895         LDKHTLCUpdate ret_var = HTLCUpdate_clone(&orig_conv);
13896         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13897         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13898         uint64_t ret_ref = (uint64_t)ret_var.inner;
13899         if (ret_var.is_owned) {
13900                 ret_ref |= 1;
13901         }
13902         return ret_ref;
13903 }
13904
13905 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
13906         LDKHTLCUpdate obj_conv;
13907         obj_conv.inner = (void*)(obj & (~1));
13908         obj_conv.is_owned = false;
13909         LDKCVec_u8Z ret_var = HTLCUpdate_write(&obj_conv);
13910         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
13911         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
13912         CVec_u8Z_free(ret_var);
13913         return ret_arr;
13914 }
13915
13916 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
13917         LDKu8slice ser_ref;
13918         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
13919         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
13920         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
13921         *ret_conv = HTLCUpdate_read(ser_ref);
13922         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
13923         return (uint64_t)ret_conv;
13924 }
13925
13926 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
13927         LDKChannelMonitor this_obj_conv;
13928         this_obj_conv.inner = (void*)(this_obj & (~1));
13929         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13930         ChannelMonitor_free(this_obj_conv);
13931 }
13932
13933 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13934         LDKChannelMonitor orig_conv;
13935         orig_conv.inner = (void*)(orig & (~1));
13936         orig_conv.is_owned = false;
13937         LDKChannelMonitor ret_var = ChannelMonitor_clone(&orig_conv);
13938         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13939         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13940         uint64_t ret_ref = (uint64_t)ret_var.inner;
13941         if (ret_var.is_owned) {
13942                 ret_ref |= 1;
13943         }
13944         return ret_ref;
13945 }
13946
13947 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1write(JNIEnv *env, jclass clz, int64_t obj) {
13948         LDKChannelMonitor obj_conv;
13949         obj_conv.inner = (void*)(obj & (~1));
13950         obj_conv.is_owned = false;
13951         LDKCVec_u8Z ret_var = ChannelMonitor_write(&obj_conv);
13952         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
13953         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
13954         CVec_u8Z_free(ret_var);
13955         return ret_arr;
13956 }
13957
13958 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) {
13959         LDKChannelMonitor this_arg_conv;
13960         this_arg_conv.inner = (void*)(this_arg & (~1));
13961         this_arg_conv.is_owned = false;
13962         LDKChannelMonitorUpdate updates_conv;
13963         updates_conv.inner = (void*)(updates & (~1));
13964         updates_conv.is_owned = false;
13965         LDKBroadcasterInterface* broadcaster_conv = (LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
13966         LDKFeeEstimator* fee_estimator_conv = (LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
13967         LDKLogger* logger_conv = (LDKLogger*)(((uint64_t)logger) & ~1);
13968         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
13969         *ret_conv = ChannelMonitor_update_monitor(&this_arg_conv, &updates_conv, broadcaster_conv, fee_estimator_conv, logger_conv);
13970         return (uint64_t)ret_conv;
13971 }
13972
13973 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1latest_1update_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
13974         LDKChannelMonitor this_arg_conv;
13975         this_arg_conv.inner = (void*)(this_arg & (~1));
13976         this_arg_conv.is_owned = false;
13977         int64_t ret_val = ChannelMonitor_get_latest_update_id(&this_arg_conv);
13978         return ret_val;
13979 }
13980
13981 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_arg) {
13982         LDKChannelMonitor this_arg_conv;
13983         this_arg_conv.inner = (void*)(this_arg & (~1));
13984         this_arg_conv.is_owned = false;
13985         LDKC2Tuple_OutPointScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
13986         *ret_ref = ChannelMonitor_get_funding_txo(&this_arg_conv);
13987         return (uint64_t)ret_ref;
13988 }
13989
13990 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1outputs_1to_1watch(JNIEnv *env, jclass clz, int64_t this_arg) {
13991         LDKChannelMonitor this_arg_conv;
13992         this_arg_conv.inner = (void*)(this_arg & (~1));
13993         this_arg_conv.is_owned = false;
13994         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ ret_var = ChannelMonitor_get_outputs_to_watch(&this_arg_conv);
13995         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
13996         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
13997         for (size_t v = 0; v < ret_var.datalen; v++) {
13998                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv_47_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
13999                 *ret_conv_47_ref = ret_var.data[v];
14000                 ret_arr_ptr[v] = (uint64_t)ret_conv_47_ref;
14001         }
14002         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
14003         FREE(ret_var.data);
14004         return ret_arr;
14005 }
14006
14007 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1load_1outputs_1to_1watch(JNIEnv *env, jclass clz, int64_t this_arg, int64_t filter) {
14008         LDKChannelMonitor this_arg_conv;
14009         this_arg_conv.inner = (void*)(this_arg & (~1));
14010         this_arg_conv.is_owned = false;
14011         LDKFilter* filter_conv = (LDKFilter*)(((uint64_t)filter) & ~1);
14012         ChannelMonitor_load_outputs_to_watch(&this_arg_conv, filter_conv);
14013 }
14014
14015 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1and_1clear_1pending_1monitor_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
14016         LDKChannelMonitor this_arg_conv;
14017         this_arg_conv.inner = (void*)(this_arg & (~1));
14018         this_arg_conv.is_owned = false;
14019         LDKCVec_MonitorEventZ ret_var = ChannelMonitor_get_and_clear_pending_monitor_events(&this_arg_conv);
14020         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
14021         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
14022         for (size_t o = 0; o < ret_var.datalen; o++) {
14023                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
14024                 *ret_conv_14_copy = MonitorEvent_clone(&ret_var.data[o]);
14025                 uint64_t ret_conv_14_ref = (uint64_t)ret_conv_14_copy;
14026                 ret_arr_ptr[o] = ret_conv_14_ref;
14027         }
14028         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
14029         FREE(ret_var.data);
14030         return ret_arr;
14031 }
14032
14033 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1and_1clear_1pending_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
14034         LDKChannelMonitor this_arg_conv;
14035         this_arg_conv.inner = (void*)(this_arg & (~1));
14036         this_arg_conv.is_owned = false;
14037         LDKCVec_EventZ ret_var = ChannelMonitor_get_and_clear_pending_events(&this_arg_conv);
14038         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
14039         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
14040         for (size_t h = 0; h < ret_var.datalen; h++) {
14041                 LDKEvent *ret_conv_7_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
14042                 *ret_conv_7_copy = Event_clone(&ret_var.data[h]);
14043                 uint64_t ret_conv_7_ref = (uint64_t)ret_conv_7_copy;
14044                 ret_arr_ptr[h] = ret_conv_7_ref;
14045         }
14046         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
14047         FREE(ret_var.data);
14048         return ret_arr;
14049 }
14050
14051 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) {
14052         LDKChannelMonitor this_arg_conv;
14053         this_arg_conv.inner = (void*)(this_arg & (~1));
14054         this_arg_conv.is_owned = false;
14055         LDKLogger* logger_conv = (LDKLogger*)(((uint64_t)logger) & ~1);
14056         LDKCVec_TransactionZ ret_var = ChannelMonitor_get_latest_holder_commitment_txn(&this_arg_conv, logger_conv);
14057         jobjectArray ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
14058         ;
14059         for (size_t i = 0; i < ret_var.datalen; i++) {
14060                 LDKTransaction ret_conv_8_var = ret_var.data[i];
14061                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, ret_conv_8_var.datalen);
14062                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, ret_conv_8_var.datalen, ret_conv_8_var.data);
14063                 Transaction_free(ret_conv_8_var);
14064                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
14065         }
14066         FREE(ret_var.data);
14067         return ret_arr;
14068 }
14069
14070 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) {
14071         LDKChannelMonitor this_arg_conv;
14072         this_arg_conv.inner = (void*)(this_arg & (~1));
14073         this_arg_conv.is_owned = false;
14074         unsigned char header_arr[80];
14075         CHECK((*env)->GetArrayLength(env, header) == 80);
14076         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
14077         unsigned char (*header_ref)[80] = &header_arr;
14078         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
14079         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
14080         if (txdata_constr.datalen > 0)
14081                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
14082         else
14083                 txdata_constr.data = NULL;
14084         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
14085         for (size_t y = 0; y < txdata_constr.datalen; y++) {
14086                 int64_t txdata_conv_24 = txdata_vals[y];
14087                 LDKC2Tuple_usizeTransactionZ txdata_conv_24_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_24) & ~1);
14088                 txdata_conv_24_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_24) & ~1));
14089                 txdata_constr.data[y] = txdata_conv_24_conv;
14090         }
14091         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
14092         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
14093         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
14094                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14095                 LDKBroadcasterInterface_JCalls_clone(broadcaster_conv.this_arg);
14096         }
14097         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
14098         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
14099                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14100                 LDKFeeEstimator_JCalls_clone(fee_estimator_conv.this_arg);
14101         }
14102         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
14103         if (logger_conv.free == LDKLogger_JCalls_free) {
14104                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14105                 LDKLogger_JCalls_clone(logger_conv.this_arg);
14106         }
14107         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);
14108         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
14109         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
14110         for (size_t u = 0; u < ret_var.datalen; u++) {
14111                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_46_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
14112                 *ret_conv_46_ref = ret_var.data[u];
14113                 ret_arr_ptr[u] = (uint64_t)ret_conv_46_ref;
14114         }
14115         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
14116         FREE(ret_var.data);
14117         return ret_arr;
14118 }
14119
14120 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) {
14121         LDKChannelMonitor this_arg_conv;
14122         this_arg_conv.inner = (void*)(this_arg & (~1));
14123         this_arg_conv.is_owned = false;
14124         unsigned char header_arr[80];
14125         CHECK((*env)->GetArrayLength(env, header) == 80);
14126         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
14127         unsigned char (*header_ref)[80] = &header_arr;
14128         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
14129         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
14130                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14131                 LDKBroadcasterInterface_JCalls_clone(broadcaster_conv.this_arg);
14132         }
14133         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
14134         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
14135                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14136                 LDKFeeEstimator_JCalls_clone(fee_estimator_conv.this_arg);
14137         }
14138         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
14139         if (logger_conv.free == LDKLogger_JCalls_free) {
14140                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14141                 LDKLogger_JCalls_clone(logger_conv.this_arg);
14142         }
14143         ChannelMonitor_block_disconnected(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
14144 }
14145
14146 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) {
14147         LDKChannelMonitor this_arg_conv;
14148         this_arg_conv.inner = (void*)(this_arg & (~1));
14149         this_arg_conv.is_owned = false;
14150         unsigned char header_arr[80];
14151         CHECK((*env)->GetArrayLength(env, header) == 80);
14152         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
14153         unsigned char (*header_ref)[80] = &header_arr;
14154         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
14155         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
14156         if (txdata_constr.datalen > 0)
14157                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
14158         else
14159                 txdata_constr.data = NULL;
14160         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
14161         for (size_t y = 0; y < txdata_constr.datalen; y++) {
14162                 int64_t txdata_conv_24 = txdata_vals[y];
14163                 LDKC2Tuple_usizeTransactionZ txdata_conv_24_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_24) & ~1);
14164                 txdata_conv_24_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_24) & ~1));
14165                 txdata_constr.data[y] = txdata_conv_24_conv;
14166         }
14167         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
14168         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
14169         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
14170                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14171                 LDKBroadcasterInterface_JCalls_clone(broadcaster_conv.this_arg);
14172         }
14173         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
14174         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
14175                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14176                 LDKFeeEstimator_JCalls_clone(fee_estimator_conv.this_arg);
14177         }
14178         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
14179         if (logger_conv.free == LDKLogger_JCalls_free) {
14180                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14181                 LDKLogger_JCalls_clone(logger_conv.this_arg);
14182         }
14183         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);
14184         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
14185         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
14186         for (size_t u = 0; u < ret_var.datalen; u++) {
14187                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_46_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
14188                 *ret_conv_46_ref = ret_var.data[u];
14189                 ret_arr_ptr[u] = (uint64_t)ret_conv_46_ref;
14190         }
14191         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
14192         FREE(ret_var.data);
14193         return ret_arr;
14194 }
14195
14196 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) {
14197         LDKChannelMonitor this_arg_conv;
14198         this_arg_conv.inner = (void*)(this_arg & (~1));
14199         this_arg_conv.is_owned = false;
14200         unsigned char txid_arr[32];
14201         CHECK((*env)->GetArrayLength(env, txid) == 32);
14202         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
14203         unsigned char (*txid_ref)[32] = &txid_arr;
14204         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
14205         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
14206                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14207                 LDKBroadcasterInterface_JCalls_clone(broadcaster_conv.this_arg);
14208         }
14209         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
14210         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
14211                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14212                 LDKFeeEstimator_JCalls_clone(fee_estimator_conv.this_arg);
14213         }
14214         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
14215         if (logger_conv.free == LDKLogger_JCalls_free) {
14216                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14217                 LDKLogger_JCalls_clone(logger_conv.this_arg);
14218         }
14219         ChannelMonitor_transaction_unconfirmed(&this_arg_conv, txid_ref, broadcaster_conv, fee_estimator_conv, logger_conv);
14220 }
14221
14222 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) {
14223         LDKChannelMonitor this_arg_conv;
14224         this_arg_conv.inner = (void*)(this_arg & (~1));
14225         this_arg_conv.is_owned = false;
14226         unsigned char header_arr[80];
14227         CHECK((*env)->GetArrayLength(env, header) == 80);
14228         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
14229         unsigned char (*header_ref)[80] = &header_arr;
14230         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
14231         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
14232                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14233                 LDKBroadcasterInterface_JCalls_clone(broadcaster_conv.this_arg);
14234         }
14235         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
14236         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
14237                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14238                 LDKFeeEstimator_JCalls_clone(fee_estimator_conv.this_arg);
14239         }
14240         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
14241         if (logger_conv.free == LDKLogger_JCalls_free) {
14242                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14243                 LDKLogger_JCalls_clone(logger_conv.this_arg);
14244         }
14245         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ ret_var = ChannelMonitor_best_block_updated(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
14246         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
14247         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
14248         for (size_t u = 0; u < ret_var.datalen; u++) {
14249                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_46_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
14250                 *ret_conv_46_ref = ret_var.data[u];
14251                 ret_arr_ptr[u] = (uint64_t)ret_conv_46_ref;
14252         }
14253         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
14254         FREE(ret_var.data);
14255         return ret_arr;
14256 }
14257
14258 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1relevant_1txids(JNIEnv *env, jclass clz, int64_t this_arg) {
14259         LDKChannelMonitor this_arg_conv;
14260         this_arg_conv.inner = (void*)(this_arg & (~1));
14261         this_arg_conv.is_owned = false;
14262         LDKCVec_TxidZ ret_var = ChannelMonitor_get_relevant_txids(&this_arg_conv);
14263         jobjectArray ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
14264         ;
14265         for (size_t i = 0; i < ret_var.datalen; i++) {
14266                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 32);
14267                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 32, ret_var.data[i].data);
14268                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
14269         }
14270         FREE(ret_var.data);
14271         return ret_arr;
14272 }
14273
14274 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Persist_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
14275         if ((this_ptr & 1) != 0) return;
14276         LDKPersist this_ptr_conv = *(LDKPersist*)(((uint64_t)this_ptr) & ~1);
14277         FREE((void*)this_ptr);
14278         Persist_free(this_ptr_conv);
14279 }
14280
14281 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
14282         LDKu8slice ser_ref;
14283         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
14284         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
14285         LDKKeysInterface* arg_conv = (LDKKeysInterface*)(((uint64_t)arg) & ~1);
14286         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
14287         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_read(ser_ref, arg_conv);
14288         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
14289         return (uint64_t)ret_conv;
14290 }
14291
14292 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14293         LDKOutPoint this_obj_conv;
14294         this_obj_conv.inner = (void*)(this_obj & (~1));
14295         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14296         OutPoint_free(this_obj_conv);
14297 }
14298
14299 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1get_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
14300         LDKOutPoint this_ptr_conv;
14301         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14302         this_ptr_conv.is_owned = false;
14303         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14304         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OutPoint_get_txid(&this_ptr_conv));
14305         return ret_arr;
14306 }
14307
14308 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1set_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14309         LDKOutPoint this_ptr_conv;
14310         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14311         this_ptr_conv.is_owned = false;
14312         LDKThirtyTwoBytes val_ref;
14313         CHECK((*env)->GetArrayLength(env, val) == 32);
14314         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
14315         OutPoint_set_txid(&this_ptr_conv, val_ref);
14316 }
14317
14318 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1get_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
14319         LDKOutPoint this_ptr_conv;
14320         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14321         this_ptr_conv.is_owned = false;
14322         int16_t ret_val = OutPoint_get_index(&this_ptr_conv);
14323         return ret_val;
14324 }
14325
14326 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1set_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
14327         LDKOutPoint this_ptr_conv;
14328         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14329         this_ptr_conv.is_owned = false;
14330         OutPoint_set_index(&this_ptr_conv, val);
14331 }
14332
14333 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1new(JNIEnv *env, jclass clz, int8_tArray txid_arg, int16_t index_arg) {
14334         LDKThirtyTwoBytes txid_arg_ref;
14335         CHECK((*env)->GetArrayLength(env, txid_arg) == 32);
14336         (*env)->GetByteArrayRegion(env, txid_arg, 0, 32, txid_arg_ref.data);
14337         LDKOutPoint ret_var = OutPoint_new(txid_arg_ref, index_arg);
14338         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14339         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14340         uint64_t ret_ref = (uint64_t)ret_var.inner;
14341         if (ret_var.is_owned) {
14342                 ret_ref |= 1;
14343         }
14344         return ret_ref;
14345 }
14346
14347 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14348         LDKOutPoint orig_conv;
14349         orig_conv.inner = (void*)(orig & (~1));
14350         orig_conv.is_owned = false;
14351         LDKOutPoint ret_var = OutPoint_clone(&orig_conv);
14352         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14353         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14354         uint64_t ret_ref = (uint64_t)ret_var.inner;
14355         if (ret_var.is_owned) {
14356                 ret_ref |= 1;
14357         }
14358         return ret_ref;
14359 }
14360
14361 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_OutPoint_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
14362         LDKOutPoint a_conv;
14363         a_conv.inner = (void*)(a & (~1));
14364         a_conv.is_owned = false;
14365         LDKOutPoint b_conv;
14366         b_conv.inner = (void*)(b & (~1));
14367         b_conv.is_owned = false;
14368         jboolean ret_val = OutPoint_eq(&a_conv, &b_conv);
14369         return ret_val;
14370 }
14371
14372 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1hash(JNIEnv *env, jclass clz, int64_t o) {
14373         LDKOutPoint o_conv;
14374         o_conv.inner = (void*)(o & (~1));
14375         o_conv.is_owned = false;
14376         int64_t ret_val = OutPoint_hash(&o_conv);
14377         return ret_val;
14378 }
14379
14380 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1to_1channel_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
14381         LDKOutPoint this_arg_conv;
14382         this_arg_conv.inner = (void*)(this_arg & (~1));
14383         this_arg_conv.is_owned = false;
14384         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14385         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, OutPoint_to_channel_id(&this_arg_conv).data);
14386         return ret_arr;
14387 }
14388
14389 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1write(JNIEnv *env, jclass clz, int64_t obj) {
14390         LDKOutPoint obj_conv;
14391         obj_conv.inner = (void*)(obj & (~1));
14392         obj_conv.is_owned = false;
14393         LDKCVec_u8Z ret_var = OutPoint_write(&obj_conv);
14394         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
14395         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
14396         CVec_u8Z_free(ret_var);
14397         return ret_arr;
14398 }
14399
14400 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
14401         LDKu8slice ser_ref;
14402         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
14403         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
14404         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
14405         *ret_conv = OutPoint_read(ser_ref);
14406         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
14407         return (uint64_t)ret_conv;
14408 }
14409
14410 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14411         LDKDelayedPaymentOutputDescriptor this_obj_conv;
14412         this_obj_conv.inner = (void*)(this_obj & (~1));
14413         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14414         DelayedPaymentOutputDescriptor_free(this_obj_conv);
14415 }
14416
14417 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
14418         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
14419         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14420         this_ptr_conv.is_owned = false;
14421         LDKOutPoint ret_var = DelayedPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
14422         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14423         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14424         uint64_t ret_ref = (uint64_t)ret_var.inner;
14425         if (ret_var.is_owned) {
14426                 ret_ref |= 1;
14427         }
14428         return ret_ref;
14429 }
14430
14431 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
14432         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
14433         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14434         this_ptr_conv.is_owned = false;
14435         LDKOutPoint val_conv;
14436         val_conv.inner = (void*)(val & (~1));
14437         val_conv.is_owned = (val & 1) || (val == 0);
14438         val_conv = OutPoint_clone(&val_conv);
14439         DelayedPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
14440 }
14441
14442 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
14443         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
14444         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14445         this_ptr_conv.is_owned = false;
14446         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
14447         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DelayedPaymentOutputDescriptor_get_per_commitment_point(&this_ptr_conv).compressed_form);
14448         return ret_arr;
14449 }
14450
14451 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14452         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
14453         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14454         this_ptr_conv.is_owned = false;
14455         LDKPublicKey val_ref;
14456         CHECK((*env)->GetArrayLength(env, val) == 33);
14457         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
14458         DelayedPaymentOutputDescriptor_set_per_commitment_point(&this_ptr_conv, val_ref);
14459 }
14460
14461 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
14462         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
14463         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14464         this_ptr_conv.is_owned = false;
14465         int16_t ret_val = DelayedPaymentOutputDescriptor_get_to_self_delay(&this_ptr_conv);
14466         return ret_val;
14467 }
14468
14469 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
14470         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
14471         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14472         this_ptr_conv.is_owned = false;
14473         DelayedPaymentOutputDescriptor_set_to_self_delay(&this_ptr_conv, val);
14474 }
14475
14476 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1output(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
14477         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
14478         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14479         this_ptr_conv.is_owned = false;
14480         LDKTxOut val_conv = *(LDKTxOut*)(((uint64_t)val) & ~1);
14481         DelayedPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
14482 }
14483
14484 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1revocation_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
14485         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
14486         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14487         this_ptr_conv.is_owned = false;
14488         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
14489         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DelayedPaymentOutputDescriptor_get_revocation_pubkey(&this_ptr_conv).compressed_form);
14490         return ret_arr;
14491 }
14492
14493 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1revocation_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14494         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
14495         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14496         this_ptr_conv.is_owned = false;
14497         LDKPublicKey val_ref;
14498         CHECK((*env)->GetArrayLength(env, val) == 33);
14499         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
14500         DelayedPaymentOutputDescriptor_set_revocation_pubkey(&this_ptr_conv, val_ref);
14501 }
14502
14503 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
14504         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
14505         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14506         this_ptr_conv.is_owned = false;
14507         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14508         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *DelayedPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv));
14509         return ret_arr;
14510 }
14511
14512 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14513         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
14514         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14515         this_ptr_conv.is_owned = false;
14516         LDKThirtyTwoBytes val_ref;
14517         CHECK((*env)->GetArrayLength(env, val) == 32);
14518         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
14519         DelayedPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
14520 }
14521
14522 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
14523         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
14524         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14525         this_ptr_conv.is_owned = false;
14526         int64_t ret_val = DelayedPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
14527         return ret_val;
14528 }
14529
14530 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
14531         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
14532         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14533         this_ptr_conv.is_owned = false;
14534         DelayedPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
14535 }
14536
14537 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) {
14538         LDKOutPoint outpoint_arg_conv;
14539         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
14540         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
14541         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
14542         LDKPublicKey per_commitment_point_arg_ref;
14543         CHECK((*env)->GetArrayLength(env, per_commitment_point_arg) == 33);
14544         (*env)->GetByteArrayRegion(env, per_commitment_point_arg, 0, 33, per_commitment_point_arg_ref.compressed_form);
14545         LDKTxOut output_arg_conv = *(LDKTxOut*)(((uint64_t)output_arg) & ~1);
14546         LDKPublicKey revocation_pubkey_arg_ref;
14547         CHECK((*env)->GetArrayLength(env, revocation_pubkey_arg) == 33);
14548         (*env)->GetByteArrayRegion(env, revocation_pubkey_arg, 0, 33, revocation_pubkey_arg_ref.compressed_form);
14549         LDKThirtyTwoBytes channel_keys_id_arg_ref;
14550         CHECK((*env)->GetArrayLength(env, channel_keys_id_arg) == 32);
14551         (*env)->GetByteArrayRegion(env, channel_keys_id_arg, 0, 32, channel_keys_id_arg_ref.data);
14552         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);
14553         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14554         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14555         uint64_t ret_ref = (uint64_t)ret_var.inner;
14556         if (ret_var.is_owned) {
14557                 ret_ref |= 1;
14558         }
14559         return ret_ref;
14560 }
14561
14562 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14563         LDKDelayedPaymentOutputDescriptor orig_conv;
14564         orig_conv.inner = (void*)(orig & (~1));
14565         orig_conv.is_owned = false;
14566         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(&orig_conv);
14567         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14568         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14569         uint64_t ret_ref = (uint64_t)ret_var.inner;
14570         if (ret_var.is_owned) {
14571                 ret_ref |= 1;
14572         }
14573         return ret_ref;
14574 }
14575
14576 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
14577         LDKDelayedPaymentOutputDescriptor obj_conv;
14578         obj_conv.inner = (void*)(obj & (~1));
14579         obj_conv.is_owned = false;
14580         LDKCVec_u8Z ret_var = DelayedPaymentOutputDescriptor_write(&obj_conv);
14581         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
14582         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
14583         CVec_u8Z_free(ret_var);
14584         return ret_arr;
14585 }
14586
14587 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
14588         LDKu8slice ser_ref;
14589         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
14590         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
14591         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
14592         *ret_conv = DelayedPaymentOutputDescriptor_read(ser_ref);
14593         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
14594         return (uint64_t)ret_conv;
14595 }
14596
14597 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14598         LDKStaticPaymentOutputDescriptor this_obj_conv;
14599         this_obj_conv.inner = (void*)(this_obj & (~1));
14600         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14601         StaticPaymentOutputDescriptor_free(this_obj_conv);
14602 }
14603
14604 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
14605         LDKStaticPaymentOutputDescriptor this_ptr_conv;
14606         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14607         this_ptr_conv.is_owned = false;
14608         LDKOutPoint ret_var = StaticPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
14609         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14610         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14611         uint64_t ret_ref = (uint64_t)ret_var.inner;
14612         if (ret_var.is_owned) {
14613                 ret_ref |= 1;
14614         }
14615         return ret_ref;
14616 }
14617
14618 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
14619         LDKStaticPaymentOutputDescriptor this_ptr_conv;
14620         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14621         this_ptr_conv.is_owned = false;
14622         LDKOutPoint val_conv;
14623         val_conv.inner = (void*)(val & (~1));
14624         val_conv.is_owned = (val & 1) || (val == 0);
14625         val_conv = OutPoint_clone(&val_conv);
14626         StaticPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
14627 }
14628
14629 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1output(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
14630         LDKStaticPaymentOutputDescriptor this_ptr_conv;
14631         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14632         this_ptr_conv.is_owned = false;
14633         LDKTxOut val_conv = *(LDKTxOut*)(((uint64_t)val) & ~1);
14634         StaticPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
14635 }
14636
14637 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
14638         LDKStaticPaymentOutputDescriptor this_ptr_conv;
14639         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14640         this_ptr_conv.is_owned = false;
14641         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14642         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *StaticPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv));
14643         return ret_arr;
14644 }
14645
14646 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14647         LDKStaticPaymentOutputDescriptor this_ptr_conv;
14648         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14649         this_ptr_conv.is_owned = false;
14650         LDKThirtyTwoBytes val_ref;
14651         CHECK((*env)->GetArrayLength(env, val) == 32);
14652         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
14653         StaticPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
14654 }
14655
14656 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
14657         LDKStaticPaymentOutputDescriptor this_ptr_conv;
14658         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14659         this_ptr_conv.is_owned = false;
14660         int64_t ret_val = StaticPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
14661         return ret_val;
14662 }
14663
14664 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
14665         LDKStaticPaymentOutputDescriptor this_ptr_conv;
14666         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14667         this_ptr_conv.is_owned = false;
14668         StaticPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
14669 }
14670
14671 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) {
14672         LDKOutPoint outpoint_arg_conv;
14673         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
14674         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
14675         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
14676         LDKTxOut output_arg_conv = *(LDKTxOut*)(((uint64_t)output_arg) & ~1);
14677         LDKThirtyTwoBytes channel_keys_id_arg_ref;
14678         CHECK((*env)->GetArrayLength(env, channel_keys_id_arg) == 32);
14679         (*env)->GetByteArrayRegion(env, channel_keys_id_arg, 0, 32, channel_keys_id_arg_ref.data);
14680         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_new(outpoint_arg_conv, output_arg_conv, channel_keys_id_arg_ref, channel_value_satoshis_arg);
14681         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14682         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14683         uint64_t ret_ref = (uint64_t)ret_var.inner;
14684         if (ret_var.is_owned) {
14685                 ret_ref |= 1;
14686         }
14687         return ret_ref;
14688 }
14689
14690 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14691         LDKStaticPaymentOutputDescriptor orig_conv;
14692         orig_conv.inner = (void*)(orig & (~1));
14693         orig_conv.is_owned = false;
14694         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(&orig_conv);
14695         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14696         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14697         uint64_t ret_ref = (uint64_t)ret_var.inner;
14698         if (ret_var.is_owned) {
14699                 ret_ref |= 1;
14700         }
14701         return ret_ref;
14702 }
14703
14704 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
14705         LDKStaticPaymentOutputDescriptor obj_conv;
14706         obj_conv.inner = (void*)(obj & (~1));
14707         obj_conv.is_owned = false;
14708         LDKCVec_u8Z ret_var = StaticPaymentOutputDescriptor_write(&obj_conv);
14709         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
14710         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
14711         CVec_u8Z_free(ret_var);
14712         return ret_arr;
14713 }
14714
14715 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
14716         LDKu8slice ser_ref;
14717         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
14718         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
14719         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
14720         *ret_conv = StaticPaymentOutputDescriptor_read(ser_ref);
14721         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
14722         return (uint64_t)ret_conv;
14723 }
14724
14725 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
14726         if ((this_ptr & 1) != 0) return;
14727         LDKSpendableOutputDescriptor this_ptr_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)this_ptr) & ~1);
14728         FREE((void*)this_ptr);
14729         SpendableOutputDescriptor_free(this_ptr_conv);
14730 }
14731
14732 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14733         LDKSpendableOutputDescriptor* orig_conv = (LDKSpendableOutputDescriptor*)orig;
14734         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
14735         *ret_copy = SpendableOutputDescriptor_clone(orig_conv);
14736         uint64_t ret_ref = (uint64_t)ret_copy;
14737         return ret_ref;
14738 }
14739
14740 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
14741         LDKSpendableOutputDescriptor* obj_conv = (LDKSpendableOutputDescriptor*)obj;
14742         LDKCVec_u8Z ret_var = SpendableOutputDescriptor_write(obj_conv);
14743         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
14744         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
14745         CVec_u8Z_free(ret_var);
14746         return ret_arr;
14747 }
14748
14749 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
14750         LDKu8slice ser_ref;
14751         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
14752         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
14753         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
14754         *ret_conv = SpendableOutputDescriptor_read(ser_ref);
14755         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
14756         return (uint64_t)ret_conv;
14757 }
14758
14759 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BaseSign_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
14760         if ((this_ptr & 1) != 0) return;
14761         LDKBaseSign this_ptr_conv = *(LDKBaseSign*)(((uint64_t)this_ptr) & ~1);
14762         FREE((void*)this_ptr);
14763         BaseSign_free(this_ptr_conv);
14764 }
14765
14766 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sign_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14767         LDKSign* orig_conv = (LDKSign*)(((uint64_t)orig) & ~1);
14768         LDKSign* ret = MALLOC(sizeof(LDKSign), "LDKSign");
14769         *ret = Sign_clone(orig_conv);
14770         return (uint64_t)ret;
14771 }
14772
14773 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Sign_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
14774         if ((this_ptr & 1) != 0) return;
14775         LDKSign this_ptr_conv = *(LDKSign*)(((uint64_t)this_ptr) & ~1);
14776         FREE((void*)this_ptr);
14777         Sign_free(this_ptr_conv);
14778 }
14779
14780 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_KeysInterface_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
14781         if ((this_ptr & 1) != 0) return;
14782         LDKKeysInterface this_ptr_conv = *(LDKKeysInterface*)(((uint64_t)this_ptr) & ~1);
14783         FREE((void*)this_ptr);
14784         KeysInterface_free(this_ptr_conv);
14785 }
14786
14787 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14788         LDKInMemorySigner this_obj_conv;
14789         this_obj_conv.inner = (void*)(this_obj & (~1));
14790         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14791         InMemorySigner_free(this_obj_conv);
14792 }
14793
14794 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1funding_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
14795         LDKInMemorySigner this_ptr_conv;
14796         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14797         this_ptr_conv.is_owned = false;
14798         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14799         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_funding_key(&this_ptr_conv));
14800         return ret_arr;
14801 }
14802
14803 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1funding_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14804         LDKInMemorySigner this_ptr_conv;
14805         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14806         this_ptr_conv.is_owned = false;
14807         LDKSecretKey val_ref;
14808         CHECK((*env)->GetArrayLength(env, val) == 32);
14809         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
14810         InMemorySigner_set_funding_key(&this_ptr_conv, val_ref);
14811 }
14812
14813 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1revocation_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
14814         LDKInMemorySigner this_ptr_conv;
14815         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14816         this_ptr_conv.is_owned = false;
14817         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14818         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_revocation_base_key(&this_ptr_conv));
14819         return ret_arr;
14820 }
14821
14822 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1revocation_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14823         LDKInMemorySigner this_ptr_conv;
14824         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14825         this_ptr_conv.is_owned = false;
14826         LDKSecretKey val_ref;
14827         CHECK((*env)->GetArrayLength(env, val) == 32);
14828         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
14829         InMemorySigner_set_revocation_base_key(&this_ptr_conv, val_ref);
14830 }
14831
14832 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
14833         LDKInMemorySigner this_ptr_conv;
14834         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14835         this_ptr_conv.is_owned = false;
14836         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14837         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_payment_key(&this_ptr_conv));
14838         return ret_arr;
14839 }
14840
14841 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14842         LDKInMemorySigner this_ptr_conv;
14843         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14844         this_ptr_conv.is_owned = false;
14845         LDKSecretKey val_ref;
14846         CHECK((*env)->GetArrayLength(env, val) == 32);
14847         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
14848         InMemorySigner_set_payment_key(&this_ptr_conv, val_ref);
14849 }
14850
14851 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1delayed_1payment_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
14852         LDKInMemorySigner this_ptr_conv;
14853         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14854         this_ptr_conv.is_owned = false;
14855         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14856         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_delayed_payment_base_key(&this_ptr_conv));
14857         return ret_arr;
14858 }
14859
14860 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) {
14861         LDKInMemorySigner this_ptr_conv;
14862         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14863         this_ptr_conv.is_owned = false;
14864         LDKSecretKey val_ref;
14865         CHECK((*env)->GetArrayLength(env, val) == 32);
14866         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
14867         InMemorySigner_set_delayed_payment_base_key(&this_ptr_conv, val_ref);
14868 }
14869
14870 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1htlc_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
14871         LDKInMemorySigner this_ptr_conv;
14872         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14873         this_ptr_conv.is_owned = false;
14874         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14875         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_htlc_base_key(&this_ptr_conv));
14876         return ret_arr;
14877 }
14878
14879 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1htlc_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14880         LDKInMemorySigner this_ptr_conv;
14881         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14882         this_ptr_conv.is_owned = false;
14883         LDKSecretKey val_ref;
14884         CHECK((*env)->GetArrayLength(env, val) == 32);
14885         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
14886         InMemorySigner_set_htlc_base_key(&this_ptr_conv, val_ref);
14887 }
14888
14889 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1commitment_1seed(JNIEnv *env, jclass clz, int64_t this_ptr) {
14890         LDKInMemorySigner this_ptr_conv;
14891         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14892         this_ptr_conv.is_owned = false;
14893         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14894         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_commitment_seed(&this_ptr_conv));
14895         return ret_arr;
14896 }
14897
14898 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1commitment_1seed(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14899         LDKInMemorySigner this_ptr_conv;
14900         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14901         this_ptr_conv.is_owned = false;
14902         LDKThirtyTwoBytes val_ref;
14903         CHECK((*env)->GetArrayLength(env, val) == 32);
14904         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
14905         InMemorySigner_set_commitment_seed(&this_ptr_conv, val_ref);
14906 }
14907
14908 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14909         LDKInMemorySigner orig_conv;
14910         orig_conv.inner = (void*)(orig & (~1));
14911         orig_conv.is_owned = false;
14912         LDKInMemorySigner ret_var = InMemorySigner_clone(&orig_conv);
14913         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14914         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14915         uint64_t ret_ref = (uint64_t)ret_var.inner;
14916         if (ret_var.is_owned) {
14917                 ret_ref |= 1;
14918         }
14919         return ret_ref;
14920 }
14921
14922 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) {
14923         LDKSecretKey funding_key_ref;
14924         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
14925         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_ref.bytes);
14926         LDKSecretKey revocation_base_key_ref;
14927         CHECK((*env)->GetArrayLength(env, revocation_base_key) == 32);
14928         (*env)->GetByteArrayRegion(env, revocation_base_key, 0, 32, revocation_base_key_ref.bytes);
14929         LDKSecretKey payment_key_ref;
14930         CHECK((*env)->GetArrayLength(env, payment_key) == 32);
14931         (*env)->GetByteArrayRegion(env, payment_key, 0, 32, payment_key_ref.bytes);
14932         LDKSecretKey delayed_payment_base_key_ref;
14933         CHECK((*env)->GetArrayLength(env, delayed_payment_base_key) == 32);
14934         (*env)->GetByteArrayRegion(env, delayed_payment_base_key, 0, 32, delayed_payment_base_key_ref.bytes);
14935         LDKSecretKey htlc_base_key_ref;
14936         CHECK((*env)->GetArrayLength(env, htlc_base_key) == 32);
14937         (*env)->GetByteArrayRegion(env, htlc_base_key, 0, 32, htlc_base_key_ref.bytes);
14938         LDKThirtyTwoBytes commitment_seed_ref;
14939         CHECK((*env)->GetArrayLength(env, commitment_seed) == 32);
14940         (*env)->GetByteArrayRegion(env, commitment_seed, 0, 32, commitment_seed_ref.data);
14941         LDKThirtyTwoBytes channel_keys_id_ref;
14942         CHECK((*env)->GetArrayLength(env, channel_keys_id) == 32);
14943         (*env)->GetByteArrayRegion(env, channel_keys_id, 0, 32, channel_keys_id_ref.data);
14944         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);
14945         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14946         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14947         uint64_t ret_ref = (uint64_t)ret_var.inner;
14948         if (ret_var.is_owned) {
14949                 ret_ref |= 1;
14950         }
14951         return ret_ref;
14952 }
14953
14954 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1counterparty_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
14955         LDKInMemorySigner this_arg_conv;
14956         this_arg_conv.inner = (void*)(this_arg & (~1));
14957         this_arg_conv.is_owned = false;
14958         LDKChannelPublicKeys ret_var = InMemorySigner_counterparty_pubkeys(&this_arg_conv);
14959         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14960         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14961         uint64_t ret_ref = (uint64_t)ret_var.inner;
14962         if (ret_var.is_owned) {
14963                 ret_ref |= 1;
14964         }
14965         return ret_ref;
14966 }
14967
14968 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1counterparty_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
14969         LDKInMemorySigner this_arg_conv;
14970         this_arg_conv.inner = (void*)(this_arg & (~1));
14971         this_arg_conv.is_owned = false;
14972         int16_t ret_val = InMemorySigner_counterparty_selected_contest_delay(&this_arg_conv);
14973         return ret_val;
14974 }
14975
14976 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1holder_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
14977         LDKInMemorySigner this_arg_conv;
14978         this_arg_conv.inner = (void*)(this_arg & (~1));
14979         this_arg_conv.is_owned = false;
14980         int16_t ret_val = InMemorySigner_holder_selected_contest_delay(&this_arg_conv);
14981         return ret_val;
14982 }
14983
14984 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_arg) {
14985         LDKInMemorySigner this_arg_conv;
14986         this_arg_conv.inner = (void*)(this_arg & (~1));
14987         this_arg_conv.is_owned = false;
14988         jboolean ret_val = InMemorySigner_is_outbound(&this_arg_conv);
14989         return ret_val;
14990 }
14991
14992 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_arg) {
14993         LDKInMemorySigner this_arg_conv;
14994         this_arg_conv.inner = (void*)(this_arg & (~1));
14995         this_arg_conv.is_owned = false;
14996         LDKOutPoint ret_var = InMemorySigner_funding_outpoint(&this_arg_conv);
14997         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14998         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14999         uint64_t ret_ref = (uint64_t)ret_var.inner;
15000         if (ret_var.is_owned) {
15001                 ret_ref |= 1;
15002         }
15003         return ret_ref;
15004 }
15005
15006 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1channel_1parameters(JNIEnv *env, jclass clz, int64_t this_arg) {
15007         LDKInMemorySigner this_arg_conv;
15008         this_arg_conv.inner = (void*)(this_arg & (~1));
15009         this_arg_conv.is_owned = false;
15010         LDKChannelTransactionParameters ret_var = InMemorySigner_get_channel_parameters(&this_arg_conv);
15011         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15012         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15013         uint64_t ret_ref = (uint64_t)ret_var.inner;
15014         if (ret_var.is_owned) {
15015                 ret_ref |= 1;
15016         }
15017         return ret_ref;
15018 }
15019
15020 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) {
15021         LDKInMemorySigner this_arg_conv;
15022         this_arg_conv.inner = (void*)(this_arg & (~1));
15023         this_arg_conv.is_owned = false;
15024         LDKTransaction spend_tx_ref;
15025         spend_tx_ref.datalen = (*env)->GetArrayLength(env, spend_tx);
15026         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
15027         (*env)->GetByteArrayRegion(env, spend_tx, 0, spend_tx_ref.datalen, spend_tx_ref.data);
15028         spend_tx_ref.data_is_owned = true;
15029         LDKStaticPaymentOutputDescriptor descriptor_conv;
15030         descriptor_conv.inner = (void*)(descriptor & (~1));
15031         descriptor_conv.is_owned = false;
15032         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
15033         *ret_conv = InMemorySigner_sign_counterparty_payment_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
15034         return (uint64_t)ret_conv;
15035 }
15036
15037 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) {
15038         LDKInMemorySigner this_arg_conv;
15039         this_arg_conv.inner = (void*)(this_arg & (~1));
15040         this_arg_conv.is_owned = false;
15041         LDKTransaction spend_tx_ref;
15042         spend_tx_ref.datalen = (*env)->GetArrayLength(env, spend_tx);
15043         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
15044         (*env)->GetByteArrayRegion(env, spend_tx, 0, spend_tx_ref.datalen, spend_tx_ref.data);
15045         spend_tx_ref.data_is_owned = true;
15046         LDKDelayedPaymentOutputDescriptor descriptor_conv;
15047         descriptor_conv.inner = (void*)(descriptor & (~1));
15048         descriptor_conv.is_owned = false;
15049         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
15050         *ret_conv = InMemorySigner_sign_dynamic_p2wsh_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
15051         return (uint64_t)ret_conv;
15052 }
15053
15054 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1as_1BaseSign(JNIEnv *env, jclass clz, int64_t this_arg) {
15055         LDKInMemorySigner this_arg_conv;
15056         this_arg_conv.inner = (void*)(this_arg & (~1));
15057         this_arg_conv.is_owned = false;
15058         LDKBaseSign* ret = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
15059         *ret = InMemorySigner_as_BaseSign(&this_arg_conv);
15060         return (uint64_t)ret;
15061 }
15062
15063 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1as_1Sign(JNIEnv *env, jclass clz, int64_t this_arg) {
15064         LDKInMemorySigner this_arg_conv;
15065         this_arg_conv.inner = (void*)(this_arg & (~1));
15066         this_arg_conv.is_owned = false;
15067         LDKSign* ret = MALLOC(sizeof(LDKSign), "LDKSign");
15068         *ret = InMemorySigner_as_Sign(&this_arg_conv);
15069         return (uint64_t)ret;
15070 }
15071
15072 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1write(JNIEnv *env, jclass clz, int64_t obj) {
15073         LDKInMemorySigner obj_conv;
15074         obj_conv.inner = (void*)(obj & (~1));
15075         obj_conv.is_owned = false;
15076         LDKCVec_u8Z ret_var = InMemorySigner_write(&obj_conv);
15077         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
15078         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
15079         CVec_u8Z_free(ret_var);
15080         return ret_arr;
15081 }
15082
15083 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
15084         LDKu8slice ser_ref;
15085         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
15086         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
15087         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
15088         *ret_conv = InMemorySigner_read(ser_ref);
15089         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
15090         return (uint64_t)ret_conv;
15091 }
15092
15093 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_KeysManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
15094         LDKKeysManager this_obj_conv;
15095         this_obj_conv.inner = (void*)(this_obj & (~1));
15096         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15097         KeysManager_free(this_obj_conv);
15098 }
15099
15100 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) {
15101         unsigned char seed_arr[32];
15102         CHECK((*env)->GetArrayLength(env, seed) == 32);
15103         (*env)->GetByteArrayRegion(env, seed, 0, 32, seed_arr);
15104         unsigned char (*seed_ref)[32] = &seed_arr;
15105         LDKKeysManager ret_var = KeysManager_new(seed_ref, starting_time_secs, starting_time_nanos);
15106         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15107         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15108         uint64_t ret_ref = (uint64_t)ret_var.inner;
15109         if (ret_var.is_owned) {
15110                 ret_ref |= 1;
15111         }
15112         return ret_ref;
15113 }
15114
15115 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) {
15116         LDKKeysManager this_arg_conv;
15117         this_arg_conv.inner = (void*)(this_arg & (~1));
15118         this_arg_conv.is_owned = false;
15119         unsigned char params_arr[32];
15120         CHECK((*env)->GetArrayLength(env, params) == 32);
15121         (*env)->GetByteArrayRegion(env, params, 0, 32, params_arr);
15122         unsigned char (*params_ref)[32] = &params_arr;
15123         LDKInMemorySigner ret_var = KeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
15124         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15125         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15126         uint64_t ret_ref = (uint64_t)ret_var.inner;
15127         if (ret_var.is_owned) {
15128                 ret_ref |= 1;
15129         }
15130         return ret_ref;
15131 }
15132
15133 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) {
15134         LDKKeysManager this_arg_conv;
15135         this_arg_conv.inner = (void*)(this_arg & (~1));
15136         this_arg_conv.is_owned = false;
15137         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
15138         descriptors_constr.datalen = (*env)->GetArrayLength(env, descriptors);
15139         if (descriptors_constr.datalen > 0)
15140                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
15141         else
15142                 descriptors_constr.data = NULL;
15143         int64_t* descriptors_vals = (*env)->GetLongArrayElements (env, descriptors, NULL);
15144         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
15145                 int64_t descriptors_conv_27 = descriptors_vals[b];
15146                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)descriptors_conv_27) & ~1);
15147                 descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uint64_t)descriptors_conv_27) & ~1));
15148                 descriptors_constr.data[b] = descriptors_conv_27_conv;
15149         }
15150         (*env)->ReleaseLongArrayElements(env, descriptors, descriptors_vals, 0);
15151         LDKCVec_TxOutZ outputs_constr;
15152         outputs_constr.datalen = (*env)->GetArrayLength(env, outputs);
15153         if (outputs_constr.datalen > 0)
15154                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
15155         else
15156                 outputs_constr.data = NULL;
15157         int64_t* outputs_vals = (*env)->GetLongArrayElements (env, outputs, NULL);
15158         for (size_t h = 0; h < outputs_constr.datalen; h++) {
15159                 int64_t outputs_conv_7 = outputs_vals[h];
15160                 LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(((uint64_t)outputs_conv_7) & ~1);
15161                 outputs_conv_7_conv = TxOut_clone((LDKTxOut*)(((uint64_t)outputs_conv_7) & ~1));
15162                 outputs_constr.data[h] = outputs_conv_7_conv;
15163         }
15164         (*env)->ReleaseLongArrayElements(env, outputs, outputs_vals, 0);
15165         LDKCVec_u8Z change_destination_script_ref;
15166         change_destination_script_ref.datalen = (*env)->GetArrayLength(env, change_destination_script);
15167         change_destination_script_ref.data = MALLOC(change_destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
15168         (*env)->GetByteArrayRegion(env, change_destination_script, 0, change_destination_script_ref.datalen, change_destination_script_ref.data);
15169         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
15170         *ret_conv = KeysManager_spend_spendable_outputs(&this_arg_conv, descriptors_constr, outputs_constr, change_destination_script_ref, feerate_sat_per_1000_weight);
15171         return (uint64_t)ret_conv;
15172 }
15173
15174 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysManager_1as_1KeysInterface(JNIEnv *env, jclass clz, int64_t this_arg) {
15175         LDKKeysManager this_arg_conv;
15176         this_arg_conv.inner = (void*)(this_arg & (~1));
15177         this_arg_conv.is_owned = false;
15178         LDKKeysInterface* ret = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
15179         *ret = KeysManager_as_KeysInterface(&this_arg_conv);
15180         return (uint64_t)ret;
15181 }
15182
15183 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
15184         LDKChannelManager this_obj_conv;
15185         this_obj_conv.inner = (void*)(this_obj & (~1));
15186         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15187         ChannelManager_free(this_obj_conv);
15188 }
15189
15190 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
15191         LDKChainParameters this_obj_conv;
15192         this_obj_conv.inner = (void*)(this_obj & (~1));
15193         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15194         ChainParameters_free(this_obj_conv);
15195 }
15196
15197 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChainParameters_1get_1network(JNIEnv *env, jclass clz, int64_t this_ptr) {
15198         LDKChainParameters this_ptr_conv;
15199         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15200         this_ptr_conv.is_owned = false;
15201         jclass ret_conv = LDKNetwork_to_java(env, ChainParameters_get_network(&this_ptr_conv));
15202         return ret_conv;
15203 }
15204
15205 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1set_1network(JNIEnv *env, jclass clz, int64_t this_ptr, jclass val) {
15206         LDKChainParameters this_ptr_conv;
15207         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15208         this_ptr_conv.is_owned = false;
15209         LDKNetwork val_conv = LDKNetwork_from_java(env, val);
15210         ChainParameters_set_network(&this_ptr_conv, val_conv);
15211 }
15212
15213 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1get_1best_1block(JNIEnv *env, jclass clz, int64_t this_ptr) {
15214         LDKChainParameters this_ptr_conv;
15215         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15216         this_ptr_conv.is_owned = false;
15217         LDKBestBlock ret_var = ChainParameters_get_best_block(&this_ptr_conv);
15218         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15219         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15220         uint64_t ret_ref = (uint64_t)ret_var.inner;
15221         if (ret_var.is_owned) {
15222                 ret_ref |= 1;
15223         }
15224         return ret_ref;
15225 }
15226
15227 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1set_1best_1block(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15228         LDKChainParameters this_ptr_conv;
15229         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15230         this_ptr_conv.is_owned = false;
15231         LDKBestBlock val_conv;
15232         val_conv.inner = (void*)(val & (~1));
15233         val_conv.is_owned = (val & 1) || (val == 0);
15234         val_conv = BestBlock_clone(&val_conv);
15235         ChainParameters_set_best_block(&this_ptr_conv, val_conv);
15236 }
15237
15238 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1new(JNIEnv *env, jclass clz, jclass network_arg, int64_t best_block_arg) {
15239         LDKNetwork network_arg_conv = LDKNetwork_from_java(env, network_arg);
15240         LDKBestBlock best_block_arg_conv;
15241         best_block_arg_conv.inner = (void*)(best_block_arg & (~1));
15242         best_block_arg_conv.is_owned = (best_block_arg & 1) || (best_block_arg == 0);
15243         best_block_arg_conv = BestBlock_clone(&best_block_arg_conv);
15244         LDKChainParameters ret_var = ChainParameters_new(network_arg_conv, best_block_arg_conv);
15245         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15246         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15247         uint64_t ret_ref = (uint64_t)ret_var.inner;
15248         if (ret_var.is_owned) {
15249                 ret_ref |= 1;
15250         }
15251         return ret_ref;
15252 }
15253
15254 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15255         LDKChainParameters orig_conv;
15256         orig_conv.inner = (void*)(orig & (~1));
15257         orig_conv.is_owned = false;
15258         LDKChainParameters ret_var = ChainParameters_clone(&orig_conv);
15259         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15260         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15261         uint64_t ret_ref = (uint64_t)ret_var.inner;
15262         if (ret_var.is_owned) {
15263                 ret_ref |= 1;
15264         }
15265         return ret_ref;
15266 }
15267
15268 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BestBlock_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
15269         LDKBestBlock this_obj_conv;
15270         this_obj_conv.inner = (void*)(this_obj & (~1));
15271         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15272         BestBlock_free(this_obj_conv);
15273 }
15274
15275 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15276         LDKBestBlock orig_conv;
15277         orig_conv.inner = (void*)(orig & (~1));
15278         orig_conv.is_owned = false;
15279         LDKBestBlock ret_var = BestBlock_clone(&orig_conv);
15280         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15281         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15282         uint64_t ret_ref = (uint64_t)ret_var.inner;
15283         if (ret_var.is_owned) {
15284                 ret_ref |= 1;
15285         }
15286         return ret_ref;
15287 }
15288
15289 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1from_1genesis(JNIEnv *env, jclass clz, jclass network) {
15290         LDKNetwork network_conv = LDKNetwork_from_java(env, network);
15291         LDKBestBlock ret_var = BestBlock_from_genesis(network_conv);
15292         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15293         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15294         uint64_t ret_ref = (uint64_t)ret_var.inner;
15295         if (ret_var.is_owned) {
15296                 ret_ref |= 1;
15297         }
15298         return ret_ref;
15299 }
15300
15301 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1new(JNIEnv *env, jclass clz, int8_tArray block_hash, int32_t height) {
15302         LDKThirtyTwoBytes block_hash_ref;
15303         CHECK((*env)->GetArrayLength(env, block_hash) == 32);
15304         (*env)->GetByteArrayRegion(env, block_hash, 0, 32, block_hash_ref.data);
15305         LDKBestBlock ret_var = BestBlock_new(block_hash_ref, height);
15306         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15307         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15308         uint64_t ret_ref = (uint64_t)ret_var.inner;
15309         if (ret_var.is_owned) {
15310                 ret_ref |= 1;
15311         }
15312         return ret_ref;
15313 }
15314
15315 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BestBlock_1block_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
15316         LDKBestBlock this_arg_conv;
15317         this_arg_conv.inner = (void*)(this_arg & (~1));
15318         this_arg_conv.is_owned = false;
15319         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
15320         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, BestBlock_block_hash(&this_arg_conv).data);
15321         return ret_arr;
15322 }
15323
15324 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1height(JNIEnv *env, jclass clz, int64_t this_arg) {
15325         LDKBestBlock this_arg_conv;
15326         this_arg_conv.inner = (void*)(this_arg & (~1));
15327         this_arg_conv.is_owned = false;
15328         int32_t ret_val = BestBlock_height(&this_arg_conv);
15329         return ret_val;
15330 }
15331
15332 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
15333         LDKChannelDetails this_obj_conv;
15334         this_obj_conv.inner = (void*)(this_obj & (~1));
15335         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15336         ChannelDetails_free(this_obj_conv);
15337 }
15338
15339 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
15340         LDKChannelDetails this_ptr_conv;
15341         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15342         this_ptr_conv.is_owned = false;
15343         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
15344         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ChannelDetails_get_channel_id(&this_ptr_conv));
15345         return ret_arr;
15346 }
15347
15348 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15349         LDKChannelDetails this_ptr_conv;
15350         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15351         this_ptr_conv.is_owned = false;
15352         LDKThirtyTwoBytes val_ref;
15353         CHECK((*env)->GetArrayLength(env, val) == 32);
15354         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
15355         ChannelDetails_set_channel_id(&this_ptr_conv, val_ref);
15356 }
15357
15358 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_ptr) {
15359         LDKChannelDetails this_ptr_conv;
15360         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15361         this_ptr_conv.is_owned = false;
15362         LDKOutPoint ret_var = ChannelDetails_get_funding_txo(&this_ptr_conv);
15363         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15364         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15365         uint64_t ret_ref = (uint64_t)ret_var.inner;
15366         if (ret_var.is_owned) {
15367                 ret_ref |= 1;
15368         }
15369         return ret_ref;
15370 }
15371
15372 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15373         LDKChannelDetails this_ptr_conv;
15374         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15375         this_ptr_conv.is_owned = false;
15376         LDKOutPoint val_conv;
15377         val_conv.inner = (void*)(val & (~1));
15378         val_conv.is_owned = (val & 1) || (val == 0);
15379         val_conv = OutPoint_clone(&val_conv);
15380         ChannelDetails_set_funding_txo(&this_ptr_conv, val_conv);
15381 }
15382
15383 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
15384         LDKChannelDetails this_ptr_conv;
15385         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15386         this_ptr_conv.is_owned = false;
15387         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
15388         *ret_copy = ChannelDetails_get_short_channel_id(&this_ptr_conv);
15389         uint64_t ret_ref = (uint64_t)ret_copy;
15390         return ret_ref;
15391 }
15392
15393 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15394         LDKChannelDetails this_ptr_conv;
15395         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15396         this_ptr_conv.is_owned = false;
15397         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
15398         ChannelDetails_set_short_channel_id(&this_ptr_conv, val_conv);
15399 }
15400
15401 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1remote_1network_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
15402         LDKChannelDetails this_ptr_conv;
15403         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15404         this_ptr_conv.is_owned = false;
15405         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
15406         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelDetails_get_remote_network_id(&this_ptr_conv).compressed_form);
15407         return ret_arr;
15408 }
15409
15410 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1remote_1network_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15411         LDKChannelDetails this_ptr_conv;
15412         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15413         this_ptr_conv.is_owned = false;
15414         LDKPublicKey val_ref;
15415         CHECK((*env)->GetArrayLength(env, val) == 33);
15416         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
15417         ChannelDetails_set_remote_network_id(&this_ptr_conv, val_ref);
15418 }
15419
15420 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1counterparty_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
15421         LDKChannelDetails this_ptr_conv;
15422         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15423         this_ptr_conv.is_owned = false;
15424         LDKInitFeatures ret_var = ChannelDetails_get_counterparty_features(&this_ptr_conv);
15425         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15426         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15427         uint64_t ret_ref = (uint64_t)ret_var.inner;
15428         if (ret_var.is_owned) {
15429                 ret_ref |= 1;
15430         }
15431         return ret_ref;
15432 }
15433
15434 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1counterparty_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15435         LDKChannelDetails this_ptr_conv;
15436         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15437         this_ptr_conv.is_owned = false;
15438         LDKInitFeatures val_conv;
15439         val_conv.inner = (void*)(val & (~1));
15440         val_conv.is_owned = (val & 1) || (val == 0);
15441         val_conv = InitFeatures_clone(&val_conv);
15442         ChannelDetails_set_counterparty_features(&this_ptr_conv, val_conv);
15443 }
15444
15445 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
15446         LDKChannelDetails this_ptr_conv;
15447         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15448         this_ptr_conv.is_owned = false;
15449         int64_t ret_val = ChannelDetails_get_channel_value_satoshis(&this_ptr_conv);
15450         return ret_val;
15451 }
15452
15453 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15454         LDKChannelDetails this_ptr_conv;
15455         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15456         this_ptr_conv.is_owned = false;
15457         ChannelDetails_set_channel_value_satoshis(&this_ptr_conv, val);
15458 }
15459
15460 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1user_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
15461         LDKChannelDetails this_ptr_conv;
15462         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15463         this_ptr_conv.is_owned = false;
15464         int64_t ret_val = ChannelDetails_get_user_id(&this_ptr_conv);
15465         return ret_val;
15466 }
15467
15468 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1user_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15469         LDKChannelDetails this_ptr_conv;
15470         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15471         this_ptr_conv.is_owned = false;
15472         ChannelDetails_set_user_id(&this_ptr_conv, val);
15473 }
15474
15475 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1outbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
15476         LDKChannelDetails this_ptr_conv;
15477         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15478         this_ptr_conv.is_owned = false;
15479         int64_t ret_val = ChannelDetails_get_outbound_capacity_msat(&this_ptr_conv);
15480         return ret_val;
15481 }
15482
15483 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1outbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15484         LDKChannelDetails this_ptr_conv;
15485         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15486         this_ptr_conv.is_owned = false;
15487         ChannelDetails_set_outbound_capacity_msat(&this_ptr_conv, val);
15488 }
15489
15490 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
15491         LDKChannelDetails this_ptr_conv;
15492         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15493         this_ptr_conv.is_owned = false;
15494         int64_t ret_val = ChannelDetails_get_inbound_capacity_msat(&this_ptr_conv);
15495         return ret_val;
15496 }
15497
15498 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1inbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15499         LDKChannelDetails this_ptr_conv;
15500         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15501         this_ptr_conv.is_owned = false;
15502         ChannelDetails_set_inbound_capacity_msat(&this_ptr_conv, val);
15503 }
15504
15505 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_ptr) {
15506         LDKChannelDetails this_ptr_conv;
15507         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15508         this_ptr_conv.is_owned = false;
15509         jboolean ret_val = ChannelDetails_get_is_outbound(&this_ptr_conv);
15510         return ret_val;
15511 }
15512
15513 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
15514         LDKChannelDetails this_ptr_conv;
15515         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15516         this_ptr_conv.is_owned = false;
15517         ChannelDetails_set_is_outbound(&this_ptr_conv, val);
15518 }
15519
15520 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1funding_1locked(JNIEnv *env, jclass clz, int64_t this_ptr) {
15521         LDKChannelDetails this_ptr_conv;
15522         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15523         this_ptr_conv.is_owned = false;
15524         jboolean ret_val = ChannelDetails_get_is_funding_locked(&this_ptr_conv);
15525         return ret_val;
15526 }
15527
15528 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1funding_1locked(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
15529         LDKChannelDetails this_ptr_conv;
15530         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15531         this_ptr_conv.is_owned = false;
15532         ChannelDetails_set_is_funding_locked(&this_ptr_conv, val);
15533 }
15534
15535 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1usable(JNIEnv *env, jclass clz, int64_t this_ptr) {
15536         LDKChannelDetails this_ptr_conv;
15537         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15538         this_ptr_conv.is_owned = false;
15539         jboolean ret_val = ChannelDetails_get_is_usable(&this_ptr_conv);
15540         return ret_val;
15541 }
15542
15543 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1usable(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
15544         LDKChannelDetails this_ptr_conv;
15545         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15546         this_ptr_conv.is_owned = false;
15547         ChannelDetails_set_is_usable(&this_ptr_conv, val);
15548 }
15549
15550 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1public(JNIEnv *env, jclass clz, int64_t this_ptr) {
15551         LDKChannelDetails this_ptr_conv;
15552         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15553         this_ptr_conv.is_owned = false;
15554         jboolean ret_val = ChannelDetails_get_is_public(&this_ptr_conv);
15555         return ret_val;
15556 }
15557
15558 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1public(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
15559         LDKChannelDetails this_ptr_conv;
15560         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15561         this_ptr_conv.is_owned = false;
15562         ChannelDetails_set_is_public(&this_ptr_conv, val);
15563 }
15564
15565 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15566         LDKChannelDetails orig_conv;
15567         orig_conv.inner = (void*)(orig & (~1));
15568         orig_conv.is_owned = false;
15569         LDKChannelDetails ret_var = ChannelDetails_clone(&orig_conv);
15570         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15571         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15572         uint64_t ret_ref = (uint64_t)ret_var.inner;
15573         if (ret_var.is_owned) {
15574                 ret_ref |= 1;
15575         }
15576         return ret_ref;
15577 }
15578
15579 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
15580         if ((this_ptr & 1) != 0) return;
15581         LDKPaymentSendFailure this_ptr_conv = *(LDKPaymentSendFailure*)(((uint64_t)this_ptr) & ~1);
15582         FREE((void*)this_ptr);
15583         PaymentSendFailure_free(this_ptr_conv);
15584 }
15585
15586 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15587         LDKPaymentSendFailure* orig_conv = (LDKPaymentSendFailure*)orig;
15588         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
15589         *ret_copy = PaymentSendFailure_clone(orig_conv);
15590         uint64_t ret_ref = (uint64_t)ret_copy;
15591         return ret_ref;
15592 }
15593
15594 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) {
15595         LDKFeeEstimator fee_est_conv = *(LDKFeeEstimator*)(((uint64_t)fee_est) & ~1);
15596         if (fee_est_conv.free == LDKFeeEstimator_JCalls_free) {
15597                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
15598                 LDKFeeEstimator_JCalls_clone(fee_est_conv.this_arg);
15599         }
15600         LDKWatch chain_monitor_conv = *(LDKWatch*)(((uint64_t)chain_monitor) & ~1);
15601         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
15602                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
15603                 LDKWatch_JCalls_clone(chain_monitor_conv.this_arg);
15604         }
15605         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)tx_broadcaster) & ~1);
15606         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
15607                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
15608                 LDKBroadcasterInterface_JCalls_clone(tx_broadcaster_conv.this_arg);
15609         }
15610         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
15611         if (logger_conv.free == LDKLogger_JCalls_free) {
15612                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
15613                 LDKLogger_JCalls_clone(logger_conv.this_arg);
15614         }
15615         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
15616         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
15617                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
15618                 LDKKeysInterface_JCalls_clone(keys_manager_conv.this_arg);
15619         }
15620         LDKUserConfig config_conv;
15621         config_conv.inner = (void*)(config & (~1));
15622         config_conv.is_owned = (config & 1) || (config == 0);
15623         config_conv = UserConfig_clone(&config_conv);
15624         LDKChainParameters params_conv;
15625         params_conv.inner = (void*)(params & (~1));
15626         params_conv.is_owned = (params & 1) || (params == 0);
15627         params_conv = ChainParameters_clone(&params_conv);
15628         LDKChannelManager ret_var = ChannelManager_new(fee_est_conv, chain_monitor_conv, tx_broadcaster_conv, logger_conv, keys_manager_conv, config_conv, params_conv);
15629         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15630         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15631         uint64_t ret_ref = (uint64_t)ret_var.inner;
15632         if (ret_var.is_owned) {
15633                 ret_ref |= 1;
15634         }
15635         return ret_ref;
15636 }
15637
15638 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1current_1default_1configuration(JNIEnv *env, jclass clz, int64_t this_arg) {
15639         LDKChannelManager this_arg_conv;
15640         this_arg_conv.inner = (void*)(this_arg & (~1));
15641         this_arg_conv.is_owned = false;
15642         LDKUserConfig ret_var = ChannelManager_get_current_default_configuration(&this_arg_conv);
15643         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15644         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15645         uint64_t ret_ref = (uint64_t)ret_var.inner;
15646         if (ret_var.is_owned) {
15647                 ret_ref |= 1;
15648         }
15649         return ret_ref;
15650 }
15651
15652 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) {
15653         LDKChannelManager this_arg_conv;
15654         this_arg_conv.inner = (void*)(this_arg & (~1));
15655         this_arg_conv.is_owned = false;
15656         LDKPublicKey their_network_key_ref;
15657         CHECK((*env)->GetArrayLength(env, their_network_key) == 33);
15658         (*env)->GetByteArrayRegion(env, their_network_key, 0, 33, their_network_key_ref.compressed_form);
15659         LDKUserConfig override_config_conv;
15660         override_config_conv.inner = (void*)(override_config & (~1));
15661         override_config_conv.is_owned = (override_config & 1) || (override_config == 0);
15662         override_config_conv = UserConfig_clone(&override_config_conv);
15663         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
15664         *ret_conv = ChannelManager_create_channel(&this_arg_conv, their_network_key_ref, channel_value_satoshis, push_msat, user_id, override_config_conv);
15665         return (uint64_t)ret_conv;
15666 }
15667
15668 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
15669         LDKChannelManager this_arg_conv;
15670         this_arg_conv.inner = (void*)(this_arg & (~1));
15671         this_arg_conv.is_owned = false;
15672         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_channels(&this_arg_conv);
15673         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
15674         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
15675         for (size_t q = 0; q < ret_var.datalen; q++) {
15676                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
15677                 CHECK((((uint64_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15678                 CHECK((((uint64_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15679                 uint64_t ret_conv_16_ref = (uint64_t)ret_conv_16_var.inner;
15680                 if (ret_conv_16_var.is_owned) {
15681                         ret_conv_16_ref |= 1;
15682                 }
15683                 ret_arr_ptr[q] = ret_conv_16_ref;
15684         }
15685         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
15686         FREE(ret_var.data);
15687         return ret_arr;
15688 }
15689
15690 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1usable_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
15691         LDKChannelManager this_arg_conv;
15692         this_arg_conv.inner = (void*)(this_arg & (~1));
15693         this_arg_conv.is_owned = false;
15694         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_usable_channels(&this_arg_conv);
15695         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
15696         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
15697         for (size_t q = 0; q < ret_var.datalen; q++) {
15698                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
15699                 CHECK((((uint64_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15700                 CHECK((((uint64_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15701                 uint64_t ret_conv_16_ref = (uint64_t)ret_conv_16_var.inner;
15702                 if (ret_conv_16_var.is_owned) {
15703                         ret_conv_16_ref |= 1;
15704                 }
15705                 ret_arr_ptr[q] = ret_conv_16_ref;
15706         }
15707         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
15708         FREE(ret_var.data);
15709         return ret_arr;
15710 }
15711
15712 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1close_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray channel_id) {
15713         LDKChannelManager this_arg_conv;
15714         this_arg_conv.inner = (void*)(this_arg & (~1));
15715         this_arg_conv.is_owned = false;
15716         unsigned char channel_id_arr[32];
15717         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
15718         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
15719         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
15720         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
15721         *ret_conv = ChannelManager_close_channel(&this_arg_conv, channel_id_ref);
15722         return (uint64_t)ret_conv;
15723 }
15724
15725 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) {
15726         LDKChannelManager this_arg_conv;
15727         this_arg_conv.inner = (void*)(this_arg & (~1));
15728         this_arg_conv.is_owned = false;
15729         unsigned char channel_id_arr[32];
15730         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
15731         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
15732         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
15733         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
15734         *ret_conv = ChannelManager_force_close_channel(&this_arg_conv, channel_id_ref);
15735         return (uint64_t)ret_conv;
15736 }
15737
15738 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1force_1close_1all_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
15739         LDKChannelManager this_arg_conv;
15740         this_arg_conv.inner = (void*)(this_arg & (~1));
15741         this_arg_conv.is_owned = false;
15742         ChannelManager_force_close_all_channels(&this_arg_conv);
15743 }
15744
15745 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) {
15746         LDKChannelManager this_arg_conv;
15747         this_arg_conv.inner = (void*)(this_arg & (~1));
15748         this_arg_conv.is_owned = false;
15749         LDKRoute route_conv;
15750         route_conv.inner = (void*)(route & (~1));
15751         route_conv.is_owned = false;
15752         LDKThirtyTwoBytes payment_hash_ref;
15753         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
15754         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
15755         LDKThirtyTwoBytes payment_secret_ref;
15756         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
15757         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
15758         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
15759         *ret_conv = ChannelManager_send_payment(&this_arg_conv, &route_conv, payment_hash_ref, payment_secret_ref);
15760         return (uint64_t)ret_conv;
15761 }
15762
15763 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) {
15764         LDKChannelManager this_arg_conv;
15765         this_arg_conv.inner = (void*)(this_arg & (~1));
15766         this_arg_conv.is_owned = false;
15767         unsigned char temporary_channel_id_arr[32];
15768         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
15769         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_arr);
15770         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
15771         LDKTransaction funding_transaction_ref;
15772         funding_transaction_ref.datalen = (*env)->GetArrayLength(env, funding_transaction);
15773         funding_transaction_ref.data = MALLOC(funding_transaction_ref.datalen, "LDKTransaction Bytes");
15774         (*env)->GetByteArrayRegion(env, funding_transaction, 0, funding_transaction_ref.datalen, funding_transaction_ref.data);
15775         funding_transaction_ref.data_is_owned = true;
15776         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
15777         *ret_conv = ChannelManager_funding_transaction_generated(&this_arg_conv, temporary_channel_id_ref, funding_transaction_ref);
15778         return (uint64_t)ret_conv;
15779 }
15780
15781 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) {
15782         LDKChannelManager this_arg_conv;
15783         this_arg_conv.inner = (void*)(this_arg & (~1));
15784         this_arg_conv.is_owned = false;
15785         LDKThreeBytes rgb_ref;
15786         CHECK((*env)->GetArrayLength(env, rgb) == 3);
15787         (*env)->GetByteArrayRegion(env, rgb, 0, 3, rgb_ref.data);
15788         LDKThirtyTwoBytes alias_ref;
15789         CHECK((*env)->GetArrayLength(env, alias) == 32);
15790         (*env)->GetByteArrayRegion(env, alias, 0, 32, alias_ref.data);
15791         LDKCVec_NetAddressZ addresses_constr;
15792         addresses_constr.datalen = (*env)->GetArrayLength(env, addresses);
15793         if (addresses_constr.datalen > 0)
15794                 addresses_constr.data = MALLOC(addresses_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
15795         else
15796                 addresses_constr.data = NULL;
15797         int64_t* addresses_vals = (*env)->GetLongArrayElements (env, addresses, NULL);
15798         for (size_t m = 0; m < addresses_constr.datalen; m++) {
15799                 int64_t addresses_conv_12 = addresses_vals[m];
15800                 LDKNetAddress addresses_conv_12_conv = *(LDKNetAddress*)(((uint64_t)addresses_conv_12) & ~1);
15801                 addresses_constr.data[m] = addresses_conv_12_conv;
15802         }
15803         (*env)->ReleaseLongArrayElements(env, addresses, addresses_vals, 0);
15804         ChannelManager_broadcast_node_announcement(&this_arg_conv, rgb_ref, alias_ref, addresses_constr);
15805 }
15806
15807 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1process_1pending_1htlc_1forwards(JNIEnv *env, jclass clz, int64_t this_arg) {
15808         LDKChannelManager this_arg_conv;
15809         this_arg_conv.inner = (void*)(this_arg & (~1));
15810         this_arg_conv.is_owned = false;
15811         ChannelManager_process_pending_htlc_forwards(&this_arg_conv);
15812 }
15813
15814 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1timer_1tick_1occurred(JNIEnv *env, jclass clz, int64_t this_arg) {
15815         LDKChannelManager this_arg_conv;
15816         this_arg_conv.inner = (void*)(this_arg & (~1));
15817         this_arg_conv.is_owned = false;
15818         ChannelManager_timer_tick_occurred(&this_arg_conv);
15819 }
15820
15821 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelManager_1fail_1htlc_1backwards(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_hash) {
15822         LDKChannelManager this_arg_conv;
15823         this_arg_conv.inner = (void*)(this_arg & (~1));
15824         this_arg_conv.is_owned = false;
15825         unsigned char payment_hash_arr[32];
15826         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
15827         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_arr);
15828         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
15829         jboolean ret_val = ChannelManager_fail_htlc_backwards(&this_arg_conv, payment_hash_ref);
15830         return ret_val;
15831 }
15832
15833 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelManager_1claim_1funds(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_preimage) {
15834         LDKChannelManager this_arg_conv;
15835         this_arg_conv.inner = (void*)(this_arg & (~1));
15836         this_arg_conv.is_owned = false;
15837         LDKThirtyTwoBytes payment_preimage_ref;
15838         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
15839         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
15840         jboolean ret_val = ChannelManager_claim_funds(&this_arg_conv, payment_preimage_ref);
15841         return ret_val;
15842 }
15843
15844 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1our_1node_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
15845         LDKChannelManager this_arg_conv;
15846         this_arg_conv.inner = (void*)(this_arg & (~1));
15847         this_arg_conv.is_owned = false;
15848         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
15849         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelManager_get_our_node_id(&this_arg_conv).compressed_form);
15850         return ret_arr;
15851 }
15852
15853 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) {
15854         LDKChannelManager this_arg_conv;
15855         this_arg_conv.inner = (void*)(this_arg & (~1));
15856         this_arg_conv.is_owned = false;
15857         LDKOutPoint funding_txo_conv;
15858         funding_txo_conv.inner = (void*)(funding_txo & (~1));
15859         funding_txo_conv.is_owned = false;
15860         ChannelManager_channel_monitor_updated(&this_arg_conv, &funding_txo_conv, highest_applied_update_id);
15861 }
15862
15863 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) {
15864         LDKChannelManager this_arg_conv;
15865         this_arg_conv.inner = (void*)(this_arg & (~1));
15866         this_arg_conv.is_owned = false;
15867         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(((uint64_t)min_value_msat) & ~1);
15868         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
15869         *ret_ref = ChannelManager_create_inbound_payment(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs, user_payment_id);
15870         return (uint64_t)ret_ref;
15871 }
15872
15873 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) {
15874         LDKChannelManager this_arg_conv;
15875         this_arg_conv.inner = (void*)(this_arg & (~1));
15876         this_arg_conv.is_owned = false;
15877         LDKThirtyTwoBytes payment_hash_ref;
15878         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
15879         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
15880         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(((uint64_t)min_value_msat) & ~1);
15881         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
15882         *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);
15883         return (uint64_t)ret_conv;
15884 }
15885
15886 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
15887         LDKChannelManager this_arg_conv;
15888         this_arg_conv.inner = (void*)(this_arg & (~1));
15889         this_arg_conv.is_owned = false;
15890         LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
15891         *ret = ChannelManager_as_MessageSendEventsProvider(&this_arg_conv);
15892         return (uint64_t)ret;
15893 }
15894
15895 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1EventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
15896         LDKChannelManager this_arg_conv;
15897         this_arg_conv.inner = (void*)(this_arg & (~1));
15898         this_arg_conv.is_owned = false;
15899         LDKEventsProvider* ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
15900         *ret = ChannelManager_as_EventsProvider(&this_arg_conv);
15901         return (uint64_t)ret;
15902 }
15903
15904 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Listen(JNIEnv *env, jclass clz, int64_t this_arg) {
15905         LDKChannelManager this_arg_conv;
15906         this_arg_conv.inner = (void*)(this_arg & (~1));
15907         this_arg_conv.is_owned = false;
15908         LDKListen* ret = MALLOC(sizeof(LDKListen), "LDKListen");
15909         *ret = ChannelManager_as_Listen(&this_arg_conv);
15910         return (uint64_t)ret;
15911 }
15912
15913 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Confirm(JNIEnv *env, jclass clz, int64_t this_arg) {
15914         LDKChannelManager this_arg_conv;
15915         this_arg_conv.inner = (void*)(this_arg & (~1));
15916         this_arg_conv.is_owned = false;
15917         LDKConfirm* ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
15918         *ret = ChannelManager_as_Confirm(&this_arg_conv);
15919         return (uint64_t)ret;
15920 }
15921
15922 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) {
15923         LDKChannelManager this_arg_conv;
15924         this_arg_conv.inner = (void*)(this_arg & (~1));
15925         this_arg_conv.is_owned = false;
15926         jboolean ret_val = ChannelManager_await_persistable_update_timeout(&this_arg_conv, max_wait);
15927         return ret_val;
15928 }
15929
15930 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1await_1persistable_1update(JNIEnv *env, jclass clz, int64_t this_arg) {
15931         LDKChannelManager this_arg_conv;
15932         this_arg_conv.inner = (void*)(this_arg & (~1));
15933         this_arg_conv.is_owned = false;
15934         ChannelManager_await_persistable_update(&this_arg_conv);
15935 }
15936
15937 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1ChannelMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
15938         LDKChannelManager this_arg_conv;
15939         this_arg_conv.inner = (void*)(this_arg & (~1));
15940         this_arg_conv.is_owned = false;
15941         LDKChannelMessageHandler* ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
15942         *ret = ChannelManager_as_ChannelMessageHandler(&this_arg_conv);
15943         return (uint64_t)ret;
15944 }
15945
15946 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1write(JNIEnv *env, jclass clz, int64_t obj) {
15947         LDKChannelManager obj_conv;
15948         obj_conv.inner = (void*)(obj & (~1));
15949         obj_conv.is_owned = false;
15950         LDKCVec_u8Z ret_var = ChannelManager_write(&obj_conv);
15951         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
15952         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
15953         CVec_u8Z_free(ret_var);
15954         return ret_arr;
15955 }
15956
15957 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
15958         LDKChannelManagerReadArgs this_obj_conv;
15959         this_obj_conv.inner = (void*)(this_obj & (~1));
15960         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15961         ChannelManagerReadArgs_free(this_obj_conv);
15962 }
15963
15964 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1keys_1manager(JNIEnv *env, jclass clz, int64_t this_ptr) {
15965         LDKChannelManagerReadArgs this_ptr_conv;
15966         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15967         this_ptr_conv.is_owned = false;
15968         uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_keys_manager(&this_ptr_conv);
15969         return ret_ret;
15970 }
15971
15972 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1keys_1manager(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15973         LDKChannelManagerReadArgs this_ptr_conv;
15974         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15975         this_ptr_conv.is_owned = false;
15976         LDKKeysInterface val_conv = *(LDKKeysInterface*)(((uint64_t)val) & ~1);
15977         if (val_conv.free == LDKKeysInterface_JCalls_free) {
15978                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
15979                 LDKKeysInterface_JCalls_clone(val_conv.this_arg);
15980         }
15981         ChannelManagerReadArgs_set_keys_manager(&this_ptr_conv, val_conv);
15982 }
15983
15984 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1fee_1estimator(JNIEnv *env, jclass clz, int64_t this_ptr) {
15985         LDKChannelManagerReadArgs this_ptr_conv;
15986         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15987         this_ptr_conv.is_owned = false;
15988         uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_fee_estimator(&this_ptr_conv);
15989         return ret_ret;
15990 }
15991
15992 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1fee_1estimator(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15993         LDKChannelManagerReadArgs this_ptr_conv;
15994         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15995         this_ptr_conv.is_owned = false;
15996         LDKFeeEstimator val_conv = *(LDKFeeEstimator*)(((uint64_t)val) & ~1);
15997         if (val_conv.free == LDKFeeEstimator_JCalls_free) {
15998                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
15999                 LDKFeeEstimator_JCalls_clone(val_conv.this_arg);
16000         }
16001         ChannelManagerReadArgs_set_fee_estimator(&this_ptr_conv, val_conv);
16002 }
16003
16004 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1chain_1monitor(JNIEnv *env, jclass clz, int64_t this_ptr) {
16005         LDKChannelManagerReadArgs this_ptr_conv;
16006         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16007         this_ptr_conv.is_owned = false;
16008         uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_chain_monitor(&this_ptr_conv);
16009         return ret_ret;
16010 }
16011
16012 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1chain_1monitor(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16013         LDKChannelManagerReadArgs this_ptr_conv;
16014         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16015         this_ptr_conv.is_owned = false;
16016         LDKWatch val_conv = *(LDKWatch*)(((uint64_t)val) & ~1);
16017         if (val_conv.free == LDKWatch_JCalls_free) {
16018                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16019                 LDKWatch_JCalls_clone(val_conv.this_arg);
16020         }
16021         ChannelManagerReadArgs_set_chain_monitor(&this_ptr_conv, val_conv);
16022 }
16023
16024 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1tx_1broadcaster(JNIEnv *env, jclass clz, int64_t this_ptr) {
16025         LDKChannelManagerReadArgs this_ptr_conv;
16026         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16027         this_ptr_conv.is_owned = false;
16028         uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_tx_broadcaster(&this_ptr_conv);
16029         return ret_ret;
16030 }
16031
16032 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1tx_1broadcaster(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16033         LDKChannelManagerReadArgs this_ptr_conv;
16034         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16035         this_ptr_conv.is_owned = false;
16036         LDKBroadcasterInterface val_conv = *(LDKBroadcasterInterface*)(((uint64_t)val) & ~1);
16037         if (val_conv.free == LDKBroadcasterInterface_JCalls_free) {
16038                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16039                 LDKBroadcasterInterface_JCalls_clone(val_conv.this_arg);
16040         }
16041         ChannelManagerReadArgs_set_tx_broadcaster(&this_ptr_conv, val_conv);
16042 }
16043
16044 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1logger(JNIEnv *env, jclass clz, int64_t this_ptr) {
16045         LDKChannelManagerReadArgs this_ptr_conv;
16046         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16047         this_ptr_conv.is_owned = false;
16048         uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_logger(&this_ptr_conv);
16049         return ret_ret;
16050 }
16051
16052 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1logger(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16053         LDKChannelManagerReadArgs this_ptr_conv;
16054         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16055         this_ptr_conv.is_owned = false;
16056         LDKLogger val_conv = *(LDKLogger*)(((uint64_t)val) & ~1);
16057         if (val_conv.free == LDKLogger_JCalls_free) {
16058                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16059                 LDKLogger_JCalls_clone(val_conv.this_arg);
16060         }
16061         ChannelManagerReadArgs_set_logger(&this_ptr_conv, val_conv);
16062 }
16063
16064 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1default_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
16065         LDKChannelManagerReadArgs this_ptr_conv;
16066         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16067         this_ptr_conv.is_owned = false;
16068         LDKUserConfig ret_var = ChannelManagerReadArgs_get_default_config(&this_ptr_conv);
16069         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16070         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16071         uint64_t ret_ref = (uint64_t)ret_var.inner;
16072         if (ret_var.is_owned) {
16073                 ret_ref |= 1;
16074         }
16075         return ret_ref;
16076 }
16077
16078 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1default_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16079         LDKChannelManagerReadArgs this_ptr_conv;
16080         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16081         this_ptr_conv.is_owned = false;
16082         LDKUserConfig val_conv;
16083         val_conv.inner = (void*)(val & (~1));
16084         val_conv.is_owned = (val & 1) || (val == 0);
16085         val_conv = UserConfig_clone(&val_conv);
16086         ChannelManagerReadArgs_set_default_config(&this_ptr_conv, val_conv);
16087 }
16088
16089 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) {
16090         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
16091         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
16092                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16093                 LDKKeysInterface_JCalls_clone(keys_manager_conv.this_arg);
16094         }
16095         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
16096         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
16097                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16098                 LDKFeeEstimator_JCalls_clone(fee_estimator_conv.this_arg);
16099         }
16100         LDKWatch chain_monitor_conv = *(LDKWatch*)(((uint64_t)chain_monitor) & ~1);
16101         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
16102                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16103                 LDKWatch_JCalls_clone(chain_monitor_conv.this_arg);
16104         }
16105         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)tx_broadcaster) & ~1);
16106         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
16107                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16108                 LDKBroadcasterInterface_JCalls_clone(tx_broadcaster_conv.this_arg);
16109         }
16110         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
16111         if (logger_conv.free == LDKLogger_JCalls_free) {
16112                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16113                 LDKLogger_JCalls_clone(logger_conv.this_arg);
16114         }
16115         LDKUserConfig default_config_conv;
16116         default_config_conv.inner = (void*)(default_config & (~1));
16117         default_config_conv.is_owned = (default_config & 1) || (default_config == 0);
16118         default_config_conv = UserConfig_clone(&default_config_conv);
16119         LDKCVec_ChannelMonitorZ channel_monitors_constr;
16120         channel_monitors_constr.datalen = (*env)->GetArrayLength(env, channel_monitors);
16121         if (channel_monitors_constr.datalen > 0)
16122                 channel_monitors_constr.data = MALLOC(channel_monitors_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
16123         else
16124                 channel_monitors_constr.data = NULL;
16125         int64_t* channel_monitors_vals = (*env)->GetLongArrayElements (env, channel_monitors, NULL);
16126         for (size_t q = 0; q < channel_monitors_constr.datalen; q++) {
16127                 int64_t channel_monitors_conv_16 = channel_monitors_vals[q];
16128                 LDKChannelMonitor channel_monitors_conv_16_conv;
16129                 channel_monitors_conv_16_conv.inner = (void*)(channel_monitors_conv_16 & (~1));
16130                 channel_monitors_conv_16_conv.is_owned = (channel_monitors_conv_16 & 1) || (channel_monitors_conv_16 == 0);
16131                 channel_monitors_constr.data[q] = channel_monitors_conv_16_conv;
16132         }
16133         (*env)->ReleaseLongArrayElements(env, channel_monitors, channel_monitors_vals, 0);
16134         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);
16135         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16136         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16137         uint64_t ret_ref = (uint64_t)ret_var.inner;
16138         if (ret_var.is_owned) {
16139                 ret_ref |= 1;
16140         }
16141         return ret_ref;
16142 }
16143
16144 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
16145         LDKu8slice ser_ref;
16146         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
16147         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
16148         LDKChannelManagerReadArgs arg_conv;
16149         arg_conv.inner = (void*)(arg & (~1));
16150         arg_conv.is_owned = (arg & 1) || (arg == 0);
16151         // Warning: we need a move here but no clone is available for LDKChannelManagerReadArgs
16152         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
16153         *ret_conv = C2Tuple_BlockHashChannelManagerZ_read(ser_ref, arg_conv);
16154         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
16155         return (uint64_t)ret_conv;
16156 }
16157
16158 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DecodeError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
16159         LDKDecodeError this_obj_conv;
16160         this_obj_conv.inner = (void*)(this_obj & (~1));
16161         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16162         DecodeError_free(this_obj_conv);
16163 }
16164
16165 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16166         LDKDecodeError orig_conv;
16167         orig_conv.inner = (void*)(orig & (~1));
16168         orig_conv.is_owned = false;
16169         LDKDecodeError ret_var = DecodeError_clone(&orig_conv);
16170         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16171         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16172         uint64_t ret_ref = (uint64_t)ret_var.inner;
16173         if (ret_var.is_owned) {
16174                 ret_ref |= 1;
16175         }
16176         return ret_ref;
16177 }
16178
16179 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
16180         LDKInit this_obj_conv;
16181         this_obj_conv.inner = (void*)(this_obj & (~1));
16182         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16183         Init_free(this_obj_conv);
16184 }
16185
16186 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
16187         LDKInit this_ptr_conv;
16188         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16189         this_ptr_conv.is_owned = false;
16190         LDKInitFeatures ret_var = Init_get_features(&this_ptr_conv);
16191         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16192         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16193         uint64_t ret_ref = (uint64_t)ret_var.inner;
16194         if (ret_var.is_owned) {
16195                 ret_ref |= 1;
16196         }
16197         return ret_ref;
16198 }
16199
16200 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16201         LDKInit this_ptr_conv;
16202         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16203         this_ptr_conv.is_owned = false;
16204         LDKInitFeatures val_conv;
16205         val_conv.inner = (void*)(val & (~1));
16206         val_conv.is_owned = (val & 1) || (val == 0);
16207         val_conv = InitFeatures_clone(&val_conv);
16208         Init_set_features(&this_ptr_conv, val_conv);
16209 }
16210
16211 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1new(JNIEnv *env, jclass clz, int64_t features_arg) {
16212         LDKInitFeatures features_arg_conv;
16213         features_arg_conv.inner = (void*)(features_arg & (~1));
16214         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
16215         features_arg_conv = InitFeatures_clone(&features_arg_conv);
16216         LDKInit ret_var = Init_new(features_arg_conv);
16217         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16218         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16219         uint64_t ret_ref = (uint64_t)ret_var.inner;
16220         if (ret_var.is_owned) {
16221                 ret_ref |= 1;
16222         }
16223         return ret_ref;
16224 }
16225
16226 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16227         LDKInit orig_conv;
16228         orig_conv.inner = (void*)(orig & (~1));
16229         orig_conv.is_owned = false;
16230         LDKInit ret_var = Init_clone(&orig_conv);
16231         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16232         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16233         uint64_t ret_ref = (uint64_t)ret_var.inner;
16234         if (ret_var.is_owned) {
16235                 ret_ref |= 1;
16236         }
16237         return ret_ref;
16238 }
16239
16240 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
16241         LDKErrorMessage this_obj_conv;
16242         this_obj_conv.inner = (void*)(this_obj & (~1));
16243         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16244         ErrorMessage_free(this_obj_conv);
16245 }
16246
16247 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
16248         LDKErrorMessage this_ptr_conv;
16249         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16250         this_ptr_conv.is_owned = false;
16251         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
16252         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ErrorMessage_get_channel_id(&this_ptr_conv));
16253         return ret_arr;
16254 }
16255
16256 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
16257         LDKErrorMessage this_ptr_conv;
16258         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16259         this_ptr_conv.is_owned = false;
16260         LDKThirtyTwoBytes val_ref;
16261         CHECK((*env)->GetArrayLength(env, val) == 32);
16262         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
16263         ErrorMessage_set_channel_id(&this_ptr_conv, val_ref);
16264 }
16265
16266 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1get_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
16267         LDKErrorMessage this_ptr_conv;
16268         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16269         this_ptr_conv.is_owned = false;
16270         LDKStr ret_str = ErrorMessage_get_data(&this_ptr_conv);
16271         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
16272         return ret_conv;
16273 }
16274
16275 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1set_1data(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
16276         LDKErrorMessage this_ptr_conv;
16277         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16278         this_ptr_conv.is_owned = false;
16279         LDKStr val_conv = java_to_owned_str(env, val);
16280         ErrorMessage_set_data(&this_ptr_conv, val_conv);
16281 }
16282
16283 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, jstring data_arg) {
16284         LDKThirtyTwoBytes channel_id_arg_ref;
16285         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
16286         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
16287         LDKStr data_arg_conv = java_to_owned_str(env, data_arg);
16288         LDKErrorMessage ret_var = ErrorMessage_new(channel_id_arg_ref, data_arg_conv);
16289         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16290         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16291         uint64_t ret_ref = (uint64_t)ret_var.inner;
16292         if (ret_var.is_owned) {
16293                 ret_ref |= 1;
16294         }
16295         return ret_ref;
16296 }
16297
16298 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16299         LDKErrorMessage orig_conv;
16300         orig_conv.inner = (void*)(orig & (~1));
16301         orig_conv.is_owned = false;
16302         LDKErrorMessage ret_var = ErrorMessage_clone(&orig_conv);
16303         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16304         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16305         uint64_t ret_ref = (uint64_t)ret_var.inner;
16306         if (ret_var.is_owned) {
16307                 ret_ref |= 1;
16308         }
16309         return ret_ref;
16310 }
16311
16312 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
16313         LDKPing this_obj_conv;
16314         this_obj_conv.inner = (void*)(this_obj & (~1));
16315         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16316         Ping_free(this_obj_conv);
16317 }
16318
16319 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Ping_1get_1ponglen(JNIEnv *env, jclass clz, int64_t this_ptr) {
16320         LDKPing this_ptr_conv;
16321         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16322         this_ptr_conv.is_owned = false;
16323         int16_t ret_val = Ping_get_ponglen(&this_ptr_conv);
16324         return ret_val;
16325 }
16326
16327 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1set_1ponglen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
16328         LDKPing this_ptr_conv;
16329         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16330         this_ptr_conv.is_owned = false;
16331         Ping_set_ponglen(&this_ptr_conv, val);
16332 }
16333
16334 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Ping_1get_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr) {
16335         LDKPing this_ptr_conv;
16336         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16337         this_ptr_conv.is_owned = false;
16338         int16_t ret_val = Ping_get_byteslen(&this_ptr_conv);
16339         return ret_val;
16340 }
16341
16342 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1set_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
16343         LDKPing this_ptr_conv;
16344         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16345         this_ptr_conv.is_owned = false;
16346         Ping_set_byteslen(&this_ptr_conv, val);
16347 }
16348
16349 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1new(JNIEnv *env, jclass clz, int16_t ponglen_arg, int16_t byteslen_arg) {
16350         LDKPing ret_var = Ping_new(ponglen_arg, byteslen_arg);
16351         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16352         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16353         uint64_t ret_ref = (uint64_t)ret_var.inner;
16354         if (ret_var.is_owned) {
16355                 ret_ref |= 1;
16356         }
16357         return ret_ref;
16358 }
16359
16360 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16361         LDKPing orig_conv;
16362         orig_conv.inner = (void*)(orig & (~1));
16363         orig_conv.is_owned = false;
16364         LDKPing ret_var = Ping_clone(&orig_conv);
16365         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16366         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16367         uint64_t ret_ref = (uint64_t)ret_var.inner;
16368         if (ret_var.is_owned) {
16369                 ret_ref |= 1;
16370         }
16371         return ret_ref;
16372 }
16373
16374 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Pong_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
16375         LDKPong this_obj_conv;
16376         this_obj_conv.inner = (void*)(this_obj & (~1));
16377         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16378         Pong_free(this_obj_conv);
16379 }
16380
16381 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Pong_1get_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr) {
16382         LDKPong this_ptr_conv;
16383         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16384         this_ptr_conv.is_owned = false;
16385         int16_t ret_val = Pong_get_byteslen(&this_ptr_conv);
16386         return ret_val;
16387 }
16388
16389 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Pong_1set_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
16390         LDKPong this_ptr_conv;
16391         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16392         this_ptr_conv.is_owned = false;
16393         Pong_set_byteslen(&this_ptr_conv, val);
16394 }
16395
16396 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1new(JNIEnv *env, jclass clz, int16_t byteslen_arg) {
16397         LDKPong ret_var = Pong_new(byteslen_arg);
16398         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16399         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16400         uint64_t ret_ref = (uint64_t)ret_var.inner;
16401         if (ret_var.is_owned) {
16402                 ret_ref |= 1;
16403         }
16404         return ret_ref;
16405 }
16406
16407 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16408         LDKPong orig_conv;
16409         orig_conv.inner = (void*)(orig & (~1));
16410         orig_conv.is_owned = false;
16411         LDKPong ret_var = Pong_clone(&orig_conv);
16412         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16413         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16414         uint64_t ret_ref = (uint64_t)ret_var.inner;
16415         if (ret_var.is_owned) {
16416                 ret_ref |= 1;
16417         }
16418         return ret_ref;
16419 }
16420
16421 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
16422         LDKOpenChannel this_obj_conv;
16423         this_obj_conv.inner = (void*)(this_obj & (~1));
16424         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16425         OpenChannel_free(this_obj_conv);
16426 }
16427
16428 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
16429         LDKOpenChannel this_ptr_conv;
16430         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16431         this_ptr_conv.is_owned = false;
16432         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
16433         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OpenChannel_get_chain_hash(&this_ptr_conv));
16434         return ret_arr;
16435 }
16436
16437 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
16438         LDKOpenChannel this_ptr_conv;
16439         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16440         this_ptr_conv.is_owned = false;
16441         LDKThirtyTwoBytes val_ref;
16442         CHECK((*env)->GetArrayLength(env, val) == 32);
16443         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
16444         OpenChannel_set_chain_hash(&this_ptr_conv, val_ref);
16445 }
16446
16447 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
16448         LDKOpenChannel this_ptr_conv;
16449         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16450         this_ptr_conv.is_owned = false;
16451         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
16452         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OpenChannel_get_temporary_channel_id(&this_ptr_conv));
16453         return ret_arr;
16454 }
16455
16456 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
16457         LDKOpenChannel this_ptr_conv;
16458         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16459         this_ptr_conv.is_owned = false;
16460         LDKThirtyTwoBytes val_ref;
16461         CHECK((*env)->GetArrayLength(env, val) == 32);
16462         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
16463         OpenChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
16464 }
16465
16466 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
16467         LDKOpenChannel this_ptr_conv;
16468         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16469         this_ptr_conv.is_owned = false;
16470         int64_t ret_val = OpenChannel_get_funding_satoshis(&this_ptr_conv);
16471         return ret_val;
16472 }
16473
16474 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16475         LDKOpenChannel this_ptr_conv;
16476         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16477         this_ptr_conv.is_owned = false;
16478         OpenChannel_set_funding_satoshis(&this_ptr_conv, val);
16479 }
16480
16481 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1push_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
16482         LDKOpenChannel this_ptr_conv;
16483         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16484         this_ptr_conv.is_owned = false;
16485         int64_t ret_val = OpenChannel_get_push_msat(&this_ptr_conv);
16486         return ret_val;
16487 }
16488
16489 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1push_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16490         LDKOpenChannel this_ptr_conv;
16491         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16492         this_ptr_conv.is_owned = false;
16493         OpenChannel_set_push_msat(&this_ptr_conv, val);
16494 }
16495
16496 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
16497         LDKOpenChannel this_ptr_conv;
16498         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16499         this_ptr_conv.is_owned = false;
16500         int64_t ret_val = OpenChannel_get_dust_limit_satoshis(&this_ptr_conv);
16501         return ret_val;
16502 }
16503
16504 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16505         LDKOpenChannel this_ptr_conv;
16506         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16507         this_ptr_conv.is_owned = false;
16508         OpenChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
16509 }
16510
16511 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) {
16512         LDKOpenChannel this_ptr_conv;
16513         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16514         this_ptr_conv.is_owned = false;
16515         int64_t ret_val = OpenChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
16516         return ret_val;
16517 }
16518
16519 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) {
16520         LDKOpenChannel this_ptr_conv;
16521         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16522         this_ptr_conv.is_owned = false;
16523         OpenChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
16524 }
16525
16526 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
16527         LDKOpenChannel this_ptr_conv;
16528         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16529         this_ptr_conv.is_owned = false;
16530         int64_t ret_val = OpenChannel_get_channel_reserve_satoshis(&this_ptr_conv);
16531         return ret_val;
16532 }
16533
16534 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16535         LDKOpenChannel this_ptr_conv;
16536         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16537         this_ptr_conv.is_owned = false;
16538         OpenChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
16539 }
16540
16541 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
16542         LDKOpenChannel this_ptr_conv;
16543         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16544         this_ptr_conv.is_owned = false;
16545         int64_t ret_val = OpenChannel_get_htlc_minimum_msat(&this_ptr_conv);
16546         return ret_val;
16547 }
16548
16549 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16550         LDKOpenChannel this_ptr_conv;
16551         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16552         this_ptr_conv.is_owned = false;
16553         OpenChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
16554 }
16555
16556 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr) {
16557         LDKOpenChannel this_ptr_conv;
16558         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16559         this_ptr_conv.is_owned = false;
16560         int32_t ret_val = OpenChannel_get_feerate_per_kw(&this_ptr_conv);
16561         return ret_val;
16562 }
16563
16564 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
16565         LDKOpenChannel this_ptr_conv;
16566         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16567         this_ptr_conv.is_owned = false;
16568         OpenChannel_set_feerate_per_kw(&this_ptr_conv, val);
16569 }
16570
16571 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
16572         LDKOpenChannel this_ptr_conv;
16573         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16574         this_ptr_conv.is_owned = false;
16575         int16_t ret_val = OpenChannel_get_to_self_delay(&this_ptr_conv);
16576         return ret_val;
16577 }
16578
16579 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
16580         LDKOpenChannel this_ptr_conv;
16581         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16582         this_ptr_conv.is_owned = false;
16583         OpenChannel_set_to_self_delay(&this_ptr_conv, val);
16584 }
16585
16586 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
16587         LDKOpenChannel this_ptr_conv;
16588         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16589         this_ptr_conv.is_owned = false;
16590         int16_t ret_val = OpenChannel_get_max_accepted_htlcs(&this_ptr_conv);
16591         return ret_val;
16592 }
16593
16594 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
16595         LDKOpenChannel this_ptr_conv;
16596         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16597         this_ptr_conv.is_owned = false;
16598         OpenChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
16599 }
16600
16601 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
16602         LDKOpenChannel this_ptr_conv;
16603         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16604         this_ptr_conv.is_owned = false;
16605         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
16606         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_funding_pubkey(&this_ptr_conv).compressed_form);
16607         return ret_arr;
16608 }
16609
16610 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
16611         LDKOpenChannel this_ptr_conv;
16612         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16613         this_ptr_conv.is_owned = false;
16614         LDKPublicKey val_ref;
16615         CHECK((*env)->GetArrayLength(env, val) == 33);
16616         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
16617         OpenChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
16618 }
16619
16620 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
16621         LDKOpenChannel this_ptr_conv;
16622         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16623         this_ptr_conv.is_owned = false;
16624         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
16625         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form);
16626         return ret_arr;
16627 }
16628
16629 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
16630         LDKOpenChannel this_ptr_conv;
16631         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16632         this_ptr_conv.is_owned = false;
16633         LDKPublicKey val_ref;
16634         CHECK((*env)->GetArrayLength(env, val) == 33);
16635         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
16636         OpenChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
16637 }
16638
16639 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
16640         LDKOpenChannel this_ptr_conv;
16641         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16642         this_ptr_conv.is_owned = false;
16643         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
16644         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_payment_point(&this_ptr_conv).compressed_form);
16645         return ret_arr;
16646 }
16647
16648 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
16649         LDKOpenChannel this_ptr_conv;
16650         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16651         this_ptr_conv.is_owned = false;
16652         LDKPublicKey val_ref;
16653         CHECK((*env)->GetArrayLength(env, val) == 33);
16654         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
16655         OpenChannel_set_payment_point(&this_ptr_conv, val_ref);
16656 }
16657
16658 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
16659         LDKOpenChannel this_ptr_conv;
16660         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16661         this_ptr_conv.is_owned = false;
16662         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
16663         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
16664         return ret_arr;
16665 }
16666
16667 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
16668         LDKOpenChannel this_ptr_conv;
16669         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16670         this_ptr_conv.is_owned = false;
16671         LDKPublicKey val_ref;
16672         CHECK((*env)->GetArrayLength(env, val) == 33);
16673         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
16674         OpenChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
16675 }
16676
16677 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
16678         LDKOpenChannel this_ptr_conv;
16679         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16680         this_ptr_conv.is_owned = false;
16681         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
16682         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form);
16683         return ret_arr;
16684 }
16685
16686 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
16687         LDKOpenChannel this_ptr_conv;
16688         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16689         this_ptr_conv.is_owned = false;
16690         LDKPublicKey val_ref;
16691         CHECK((*env)->GetArrayLength(env, val) == 33);
16692         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
16693         OpenChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
16694 }
16695
16696 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1first_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
16697         LDKOpenChannel this_ptr_conv;
16698         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16699         this_ptr_conv.is_owned = false;
16700         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
16701         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form);
16702         return ret_arr;
16703 }
16704
16705 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) {
16706         LDKOpenChannel this_ptr_conv;
16707         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16708         this_ptr_conv.is_owned = false;
16709         LDKPublicKey val_ref;
16710         CHECK((*env)->GetArrayLength(env, val) == 33);
16711         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
16712         OpenChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
16713 }
16714
16715 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1flags(JNIEnv *env, jclass clz, int64_t this_ptr) {
16716         LDKOpenChannel this_ptr_conv;
16717         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16718         this_ptr_conv.is_owned = false;
16719         int8_t ret_val = OpenChannel_get_channel_flags(&this_ptr_conv);
16720         return ret_val;
16721 }
16722
16723 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1flags(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
16724         LDKOpenChannel this_ptr_conv;
16725         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16726         this_ptr_conv.is_owned = false;
16727         OpenChannel_set_channel_flags(&this_ptr_conv, val);
16728 }
16729
16730 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16731         LDKOpenChannel orig_conv;
16732         orig_conv.inner = (void*)(orig & (~1));
16733         orig_conv.is_owned = false;
16734         LDKOpenChannel ret_var = OpenChannel_clone(&orig_conv);
16735         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16736         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16737         uint64_t ret_ref = (uint64_t)ret_var.inner;
16738         if (ret_var.is_owned) {
16739                 ret_ref |= 1;
16740         }
16741         return ret_ref;
16742 }
16743
16744 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
16745         LDKAcceptChannel this_obj_conv;
16746         this_obj_conv.inner = (void*)(this_obj & (~1));
16747         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16748         AcceptChannel_free(this_obj_conv);
16749 }
16750
16751 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
16752         LDKAcceptChannel this_ptr_conv;
16753         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16754         this_ptr_conv.is_owned = false;
16755         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
16756         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *AcceptChannel_get_temporary_channel_id(&this_ptr_conv));
16757         return ret_arr;
16758 }
16759
16760 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
16761         LDKAcceptChannel this_ptr_conv;
16762         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16763         this_ptr_conv.is_owned = false;
16764         LDKThirtyTwoBytes val_ref;
16765         CHECK((*env)->GetArrayLength(env, val) == 32);
16766         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
16767         AcceptChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
16768 }
16769
16770 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
16771         LDKAcceptChannel this_ptr_conv;
16772         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16773         this_ptr_conv.is_owned = false;
16774         int64_t ret_val = AcceptChannel_get_dust_limit_satoshis(&this_ptr_conv);
16775         return ret_val;
16776 }
16777
16778 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16779         LDKAcceptChannel this_ptr_conv;
16780         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16781         this_ptr_conv.is_owned = false;
16782         AcceptChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
16783 }
16784
16785 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) {
16786         LDKAcceptChannel this_ptr_conv;
16787         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16788         this_ptr_conv.is_owned = false;
16789         int64_t ret_val = AcceptChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
16790         return ret_val;
16791 }
16792
16793 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) {
16794         LDKAcceptChannel this_ptr_conv;
16795         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16796         this_ptr_conv.is_owned = false;
16797         AcceptChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
16798 }
16799
16800 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
16801         LDKAcceptChannel this_ptr_conv;
16802         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16803         this_ptr_conv.is_owned = false;
16804         int64_t ret_val = AcceptChannel_get_channel_reserve_satoshis(&this_ptr_conv);
16805         return ret_val;
16806 }
16807
16808 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16809         LDKAcceptChannel this_ptr_conv;
16810         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16811         this_ptr_conv.is_owned = false;
16812         AcceptChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
16813 }
16814
16815 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
16816         LDKAcceptChannel this_ptr_conv;
16817         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16818         this_ptr_conv.is_owned = false;
16819         int64_t ret_val = AcceptChannel_get_htlc_minimum_msat(&this_ptr_conv);
16820         return ret_val;
16821 }
16822
16823 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16824         LDKAcceptChannel this_ptr_conv;
16825         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16826         this_ptr_conv.is_owned = false;
16827         AcceptChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
16828 }
16829
16830 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
16831         LDKAcceptChannel this_ptr_conv;
16832         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16833         this_ptr_conv.is_owned = false;
16834         int32_t ret_val = AcceptChannel_get_minimum_depth(&this_ptr_conv);
16835         return ret_val;
16836 }
16837
16838 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
16839         LDKAcceptChannel this_ptr_conv;
16840         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16841         this_ptr_conv.is_owned = false;
16842         AcceptChannel_set_minimum_depth(&this_ptr_conv, val);
16843 }
16844
16845 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
16846         LDKAcceptChannel this_ptr_conv;
16847         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16848         this_ptr_conv.is_owned = false;
16849         int16_t ret_val = AcceptChannel_get_to_self_delay(&this_ptr_conv);
16850         return ret_val;
16851 }
16852
16853 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
16854         LDKAcceptChannel this_ptr_conv;
16855         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16856         this_ptr_conv.is_owned = false;
16857         AcceptChannel_set_to_self_delay(&this_ptr_conv, val);
16858 }
16859
16860 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
16861         LDKAcceptChannel this_ptr_conv;
16862         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16863         this_ptr_conv.is_owned = false;
16864         int16_t ret_val = AcceptChannel_get_max_accepted_htlcs(&this_ptr_conv);
16865         return ret_val;
16866 }
16867
16868 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
16869         LDKAcceptChannel this_ptr_conv;
16870         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16871         this_ptr_conv.is_owned = false;
16872         AcceptChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
16873 }
16874
16875 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
16876         LDKAcceptChannel this_ptr_conv;
16877         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16878         this_ptr_conv.is_owned = false;
16879         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
16880         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_funding_pubkey(&this_ptr_conv).compressed_form);
16881         return ret_arr;
16882 }
16883
16884 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
16885         LDKAcceptChannel this_ptr_conv;
16886         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16887         this_ptr_conv.is_owned = false;
16888         LDKPublicKey val_ref;
16889         CHECK((*env)->GetArrayLength(env, val) == 33);
16890         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
16891         AcceptChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
16892 }
16893
16894 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
16895         LDKAcceptChannel this_ptr_conv;
16896         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16897         this_ptr_conv.is_owned = false;
16898         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
16899         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form);
16900         return ret_arr;
16901 }
16902
16903 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
16904         LDKAcceptChannel this_ptr_conv;
16905         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16906         this_ptr_conv.is_owned = false;
16907         LDKPublicKey val_ref;
16908         CHECK((*env)->GetArrayLength(env, val) == 33);
16909         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
16910         AcceptChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
16911 }
16912
16913 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
16914         LDKAcceptChannel this_ptr_conv;
16915         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16916         this_ptr_conv.is_owned = false;
16917         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
16918         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_payment_point(&this_ptr_conv).compressed_form);
16919         return ret_arr;
16920 }
16921
16922 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
16923         LDKAcceptChannel this_ptr_conv;
16924         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16925         this_ptr_conv.is_owned = false;
16926         LDKPublicKey val_ref;
16927         CHECK((*env)->GetArrayLength(env, val) == 33);
16928         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
16929         AcceptChannel_set_payment_point(&this_ptr_conv, val_ref);
16930 }
16931
16932 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
16933         LDKAcceptChannel this_ptr_conv;
16934         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16935         this_ptr_conv.is_owned = false;
16936         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
16937         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
16938         return ret_arr;
16939 }
16940
16941 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
16942         LDKAcceptChannel this_ptr_conv;
16943         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16944         this_ptr_conv.is_owned = false;
16945         LDKPublicKey val_ref;
16946         CHECK((*env)->GetArrayLength(env, val) == 33);
16947         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
16948         AcceptChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
16949 }
16950
16951 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
16952         LDKAcceptChannel this_ptr_conv;
16953         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16954         this_ptr_conv.is_owned = false;
16955         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
16956         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form);
16957         return ret_arr;
16958 }
16959
16960 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
16961         LDKAcceptChannel this_ptr_conv;
16962         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16963         this_ptr_conv.is_owned = false;
16964         LDKPublicKey val_ref;
16965         CHECK((*env)->GetArrayLength(env, val) == 33);
16966         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
16967         AcceptChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
16968 }
16969
16970 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1first_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
16971         LDKAcceptChannel this_ptr_conv;
16972         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16973         this_ptr_conv.is_owned = false;
16974         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
16975         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form);
16976         return ret_arr;
16977 }
16978
16979 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) {
16980         LDKAcceptChannel this_ptr_conv;
16981         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16982         this_ptr_conv.is_owned = false;
16983         LDKPublicKey val_ref;
16984         CHECK((*env)->GetArrayLength(env, val) == 33);
16985         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
16986         AcceptChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
16987 }
16988
16989 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16990         LDKAcceptChannel orig_conv;
16991         orig_conv.inner = (void*)(orig & (~1));
16992         orig_conv.is_owned = false;
16993         LDKAcceptChannel ret_var = AcceptChannel_clone(&orig_conv);
16994         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16995         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16996         uint64_t ret_ref = (uint64_t)ret_var.inner;
16997         if (ret_var.is_owned) {
16998                 ret_ref |= 1;
16999         }
17000         return ret_ref;
17001 }
17002
17003 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17004         LDKFundingCreated this_obj_conv;
17005         this_obj_conv.inner = (void*)(this_obj & (~1));
17006         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17007         FundingCreated_free(this_obj_conv);
17008 }
17009
17010 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
17011         LDKFundingCreated this_ptr_conv;
17012         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17013         this_ptr_conv.is_owned = false;
17014         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
17015         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingCreated_get_temporary_channel_id(&this_ptr_conv));
17016         return ret_arr;
17017 }
17018
17019 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17020         LDKFundingCreated this_ptr_conv;
17021         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17022         this_ptr_conv.is_owned = false;
17023         LDKThirtyTwoBytes val_ref;
17024         CHECK((*env)->GetArrayLength(env, val) == 32);
17025         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
17026         FundingCreated_set_temporary_channel_id(&this_ptr_conv, val_ref);
17027 }
17028
17029 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1funding_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
17030         LDKFundingCreated this_ptr_conv;
17031         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17032         this_ptr_conv.is_owned = false;
17033         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
17034         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingCreated_get_funding_txid(&this_ptr_conv));
17035         return ret_arr;
17036 }
17037
17038 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1funding_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17039         LDKFundingCreated this_ptr_conv;
17040         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17041         this_ptr_conv.is_owned = false;
17042         LDKThirtyTwoBytes val_ref;
17043         CHECK((*env)->GetArrayLength(env, val) == 32);
17044         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
17045         FundingCreated_set_funding_txid(&this_ptr_conv, val_ref);
17046 }
17047
17048 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1funding_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
17049         LDKFundingCreated this_ptr_conv;
17050         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17051         this_ptr_conv.is_owned = false;
17052         int16_t ret_val = FundingCreated_get_funding_output_index(&this_ptr_conv);
17053         return ret_val;
17054 }
17055
17056 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1funding_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
17057         LDKFundingCreated this_ptr_conv;
17058         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17059         this_ptr_conv.is_owned = false;
17060         FundingCreated_set_funding_output_index(&this_ptr_conv, val);
17061 }
17062
17063 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
17064         LDKFundingCreated this_ptr_conv;
17065         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17066         this_ptr_conv.is_owned = false;
17067         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
17068         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, FundingCreated_get_signature(&this_ptr_conv).compact_form);
17069         return ret_arr;
17070 }
17071
17072 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17073         LDKFundingCreated this_ptr_conv;
17074         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17075         this_ptr_conv.is_owned = false;
17076         LDKSignature val_ref;
17077         CHECK((*env)->GetArrayLength(env, val) == 64);
17078         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
17079         FundingCreated_set_signature(&this_ptr_conv, val_ref);
17080 }
17081
17082 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) {
17083         LDKThirtyTwoBytes temporary_channel_id_arg_ref;
17084         CHECK((*env)->GetArrayLength(env, temporary_channel_id_arg) == 32);
17085         (*env)->GetByteArrayRegion(env, temporary_channel_id_arg, 0, 32, temporary_channel_id_arg_ref.data);
17086         LDKThirtyTwoBytes funding_txid_arg_ref;
17087         CHECK((*env)->GetArrayLength(env, funding_txid_arg) == 32);
17088         (*env)->GetByteArrayRegion(env, funding_txid_arg, 0, 32, funding_txid_arg_ref.data);
17089         LDKSignature signature_arg_ref;
17090         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
17091         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
17092         LDKFundingCreated ret_var = FundingCreated_new(temporary_channel_id_arg_ref, funding_txid_arg_ref, funding_output_index_arg, signature_arg_ref);
17093         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17094         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17095         uint64_t ret_ref = (uint64_t)ret_var.inner;
17096         if (ret_var.is_owned) {
17097                 ret_ref |= 1;
17098         }
17099         return ret_ref;
17100 }
17101
17102 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17103         LDKFundingCreated orig_conv;
17104         orig_conv.inner = (void*)(orig & (~1));
17105         orig_conv.is_owned = false;
17106         LDKFundingCreated ret_var = FundingCreated_clone(&orig_conv);
17107         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17108         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17109         uint64_t ret_ref = (uint64_t)ret_var.inner;
17110         if (ret_var.is_owned) {
17111                 ret_ref |= 1;
17112         }
17113         return ret_ref;
17114 }
17115
17116 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17117         LDKFundingSigned this_obj_conv;
17118         this_obj_conv.inner = (void*)(this_obj & (~1));
17119         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17120         FundingSigned_free(this_obj_conv);
17121 }
17122
17123 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
17124         LDKFundingSigned this_ptr_conv;
17125         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17126         this_ptr_conv.is_owned = false;
17127         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
17128         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingSigned_get_channel_id(&this_ptr_conv));
17129         return ret_arr;
17130 }
17131
17132 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17133         LDKFundingSigned this_ptr_conv;
17134         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17135         this_ptr_conv.is_owned = false;
17136         LDKThirtyTwoBytes val_ref;
17137         CHECK((*env)->GetArrayLength(env, val) == 32);
17138         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
17139         FundingSigned_set_channel_id(&this_ptr_conv, val_ref);
17140 }
17141
17142 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
17143         LDKFundingSigned this_ptr_conv;
17144         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17145         this_ptr_conv.is_owned = false;
17146         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
17147         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, FundingSigned_get_signature(&this_ptr_conv).compact_form);
17148         return ret_arr;
17149 }
17150
17151 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17152         LDKFundingSigned this_ptr_conv;
17153         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17154         this_ptr_conv.is_owned = false;
17155         LDKSignature val_ref;
17156         CHECK((*env)->GetArrayLength(env, val) == 64);
17157         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
17158         FundingSigned_set_signature(&this_ptr_conv, val_ref);
17159 }
17160
17161 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray signature_arg) {
17162         LDKThirtyTwoBytes channel_id_arg_ref;
17163         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
17164         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
17165         LDKSignature signature_arg_ref;
17166         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
17167         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
17168         LDKFundingSigned ret_var = FundingSigned_new(channel_id_arg_ref, signature_arg_ref);
17169         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17170         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17171         uint64_t ret_ref = (uint64_t)ret_var.inner;
17172         if (ret_var.is_owned) {
17173                 ret_ref |= 1;
17174         }
17175         return ret_ref;
17176 }
17177
17178 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17179         LDKFundingSigned orig_conv;
17180         orig_conv.inner = (void*)(orig & (~1));
17181         orig_conv.is_owned = false;
17182         LDKFundingSigned ret_var = FundingSigned_clone(&orig_conv);
17183         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17184         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17185         uint64_t ret_ref = (uint64_t)ret_var.inner;
17186         if (ret_var.is_owned) {
17187                 ret_ref |= 1;
17188         }
17189         return ret_ref;
17190 }
17191
17192 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingLocked_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17193         LDKFundingLocked this_obj_conv;
17194         this_obj_conv.inner = (void*)(this_obj & (~1));
17195         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17196         FundingLocked_free(this_obj_conv);
17197 }
17198
17199 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingLocked_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
17200         LDKFundingLocked this_ptr_conv;
17201         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17202         this_ptr_conv.is_owned = false;
17203         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
17204         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingLocked_get_channel_id(&this_ptr_conv));
17205         return ret_arr;
17206 }
17207
17208 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingLocked_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17209         LDKFundingLocked this_ptr_conv;
17210         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17211         this_ptr_conv.is_owned = false;
17212         LDKThirtyTwoBytes val_ref;
17213         CHECK((*env)->GetArrayLength(env, val) == 32);
17214         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
17215         FundingLocked_set_channel_id(&this_ptr_conv, val_ref);
17216 }
17217
17218 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingLocked_1get_1next_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
17219         LDKFundingLocked this_ptr_conv;
17220         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17221         this_ptr_conv.is_owned = false;
17222         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
17223         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, FundingLocked_get_next_per_commitment_point(&this_ptr_conv).compressed_form);
17224         return ret_arr;
17225 }
17226
17227 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) {
17228         LDKFundingLocked this_ptr_conv;
17229         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17230         this_ptr_conv.is_owned = false;
17231         LDKPublicKey val_ref;
17232         CHECK((*env)->GetArrayLength(env, val) == 33);
17233         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
17234         FundingLocked_set_next_per_commitment_point(&this_ptr_conv, val_ref);
17235 }
17236
17237 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) {
17238         LDKThirtyTwoBytes channel_id_arg_ref;
17239         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
17240         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
17241         LDKPublicKey next_per_commitment_point_arg_ref;
17242         CHECK((*env)->GetArrayLength(env, next_per_commitment_point_arg) == 33);
17243         (*env)->GetByteArrayRegion(env, next_per_commitment_point_arg, 0, 33, next_per_commitment_point_arg_ref.compressed_form);
17244         LDKFundingLocked ret_var = FundingLocked_new(channel_id_arg_ref, next_per_commitment_point_arg_ref);
17245         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17246         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17247         uint64_t ret_ref = (uint64_t)ret_var.inner;
17248         if (ret_var.is_owned) {
17249                 ret_ref |= 1;
17250         }
17251         return ret_ref;
17252 }
17253
17254 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingLocked_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17255         LDKFundingLocked orig_conv;
17256         orig_conv.inner = (void*)(orig & (~1));
17257         orig_conv.is_owned = false;
17258         LDKFundingLocked ret_var = FundingLocked_clone(&orig_conv);
17259         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17260         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17261         uint64_t ret_ref = (uint64_t)ret_var.inner;
17262         if (ret_var.is_owned) {
17263                 ret_ref |= 1;
17264         }
17265         return ret_ref;
17266 }
17267
17268 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17269         LDKShutdown this_obj_conv;
17270         this_obj_conv.inner = (void*)(this_obj & (~1));
17271         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17272         Shutdown_free(this_obj_conv);
17273 }
17274
17275 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
17276         LDKShutdown this_ptr_conv;
17277         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17278         this_ptr_conv.is_owned = false;
17279         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
17280         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *Shutdown_get_channel_id(&this_ptr_conv));
17281         return ret_arr;
17282 }
17283
17284 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17285         LDKShutdown this_ptr_conv;
17286         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17287         this_ptr_conv.is_owned = false;
17288         LDKThirtyTwoBytes val_ref;
17289         CHECK((*env)->GetArrayLength(env, val) == 32);
17290         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
17291         Shutdown_set_channel_id(&this_ptr_conv, val_ref);
17292 }
17293
17294 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1get_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
17295         LDKShutdown this_ptr_conv;
17296         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17297         this_ptr_conv.is_owned = false;
17298         LDKu8slice ret_var = Shutdown_get_scriptpubkey(&this_ptr_conv);
17299         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17300         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17301         return ret_arr;
17302 }
17303
17304 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1set_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17305         LDKShutdown this_ptr_conv;
17306         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17307         this_ptr_conv.is_owned = false;
17308         LDKCVec_u8Z val_ref;
17309         val_ref.datalen = (*env)->GetArrayLength(env, val);
17310         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
17311         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
17312         Shutdown_set_scriptpubkey(&this_ptr_conv, val_ref);
17313 }
17314
17315 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray scriptpubkey_arg) {
17316         LDKThirtyTwoBytes channel_id_arg_ref;
17317         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
17318         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
17319         LDKCVec_u8Z scriptpubkey_arg_ref;
17320         scriptpubkey_arg_ref.datalen = (*env)->GetArrayLength(env, scriptpubkey_arg);
17321         scriptpubkey_arg_ref.data = MALLOC(scriptpubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
17322         (*env)->GetByteArrayRegion(env, scriptpubkey_arg, 0, scriptpubkey_arg_ref.datalen, scriptpubkey_arg_ref.data);
17323         LDKShutdown ret_var = Shutdown_new(channel_id_arg_ref, scriptpubkey_arg_ref);
17324         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17325         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17326         uint64_t ret_ref = (uint64_t)ret_var.inner;
17327         if (ret_var.is_owned) {
17328                 ret_ref |= 1;
17329         }
17330         return ret_ref;
17331 }
17332
17333 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17334         LDKShutdown orig_conv;
17335         orig_conv.inner = (void*)(orig & (~1));
17336         orig_conv.is_owned = false;
17337         LDKShutdown ret_var = Shutdown_clone(&orig_conv);
17338         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17339         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17340         uint64_t ret_ref = (uint64_t)ret_var.inner;
17341         if (ret_var.is_owned) {
17342                 ret_ref |= 1;
17343         }
17344         return ret_ref;
17345 }
17346
17347 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17348         LDKClosingSigned this_obj_conv;
17349         this_obj_conv.inner = (void*)(this_obj & (~1));
17350         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17351         ClosingSigned_free(this_obj_conv);
17352 }
17353
17354 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
17355         LDKClosingSigned this_ptr_conv;
17356         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17357         this_ptr_conv.is_owned = false;
17358         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
17359         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ClosingSigned_get_channel_id(&this_ptr_conv));
17360         return ret_arr;
17361 }
17362
17363 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17364         LDKClosingSigned this_ptr_conv;
17365         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17366         this_ptr_conv.is_owned = false;
17367         LDKThirtyTwoBytes val_ref;
17368         CHECK((*env)->GetArrayLength(env, val) == 32);
17369         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
17370         ClosingSigned_set_channel_id(&this_ptr_conv, val_ref);
17371 }
17372
17373 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
17374         LDKClosingSigned this_ptr_conv;
17375         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17376         this_ptr_conv.is_owned = false;
17377         int64_t ret_val = ClosingSigned_get_fee_satoshis(&this_ptr_conv);
17378         return ret_val;
17379 }
17380
17381 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17382         LDKClosingSigned this_ptr_conv;
17383         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17384         this_ptr_conv.is_owned = false;
17385         ClosingSigned_set_fee_satoshis(&this_ptr_conv, val);
17386 }
17387
17388 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
17389         LDKClosingSigned this_ptr_conv;
17390         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17391         this_ptr_conv.is_owned = false;
17392         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
17393         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ClosingSigned_get_signature(&this_ptr_conv).compact_form);
17394         return ret_arr;
17395 }
17396
17397 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17398         LDKClosingSigned this_ptr_conv;
17399         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17400         this_ptr_conv.is_owned = false;
17401         LDKSignature val_ref;
17402         CHECK((*env)->GetArrayLength(env, val) == 64);
17403         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
17404         ClosingSigned_set_signature(&this_ptr_conv, val_ref);
17405 }
17406
17407 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) {
17408         LDKThirtyTwoBytes channel_id_arg_ref;
17409         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
17410         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
17411         LDKSignature signature_arg_ref;
17412         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
17413         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
17414         LDKClosingSigned ret_var = ClosingSigned_new(channel_id_arg_ref, fee_satoshis_arg, signature_arg_ref);
17415         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17416         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17417         uint64_t ret_ref = (uint64_t)ret_var.inner;
17418         if (ret_var.is_owned) {
17419                 ret_ref |= 1;
17420         }
17421         return ret_ref;
17422 }
17423
17424 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17425         LDKClosingSigned orig_conv;
17426         orig_conv.inner = (void*)(orig & (~1));
17427         orig_conv.is_owned = false;
17428         LDKClosingSigned ret_var = ClosingSigned_clone(&orig_conv);
17429         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17430         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17431         uint64_t ret_ref = (uint64_t)ret_var.inner;
17432         if (ret_var.is_owned) {
17433                 ret_ref |= 1;
17434         }
17435         return ret_ref;
17436 }
17437
17438 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17439         LDKUpdateAddHTLC this_obj_conv;
17440         this_obj_conv.inner = (void*)(this_obj & (~1));
17441         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17442         UpdateAddHTLC_free(this_obj_conv);
17443 }
17444
17445 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
17446         LDKUpdateAddHTLC this_ptr_conv;
17447         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17448         this_ptr_conv.is_owned = false;
17449         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
17450         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateAddHTLC_get_channel_id(&this_ptr_conv));
17451         return ret_arr;
17452 }
17453
17454 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17455         LDKUpdateAddHTLC this_ptr_conv;
17456         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17457         this_ptr_conv.is_owned = false;
17458         LDKThirtyTwoBytes val_ref;
17459         CHECK((*env)->GetArrayLength(env, val) == 32);
17460         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
17461         UpdateAddHTLC_set_channel_id(&this_ptr_conv, val_ref);
17462 }
17463
17464 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
17465         LDKUpdateAddHTLC this_ptr_conv;
17466         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17467         this_ptr_conv.is_owned = false;
17468         int64_t ret_val = UpdateAddHTLC_get_htlc_id(&this_ptr_conv);
17469         return ret_val;
17470 }
17471
17472 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17473         LDKUpdateAddHTLC this_ptr_conv;
17474         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17475         this_ptr_conv.is_owned = false;
17476         UpdateAddHTLC_set_htlc_id(&this_ptr_conv, val);
17477 }
17478
17479 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
17480         LDKUpdateAddHTLC this_ptr_conv;
17481         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17482         this_ptr_conv.is_owned = false;
17483         int64_t ret_val = UpdateAddHTLC_get_amount_msat(&this_ptr_conv);
17484         return ret_val;
17485 }
17486
17487 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17488         LDKUpdateAddHTLC this_ptr_conv;
17489         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17490         this_ptr_conv.is_owned = false;
17491         UpdateAddHTLC_set_amount_msat(&this_ptr_conv, val);
17492 }
17493
17494 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
17495         LDKUpdateAddHTLC this_ptr_conv;
17496         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17497         this_ptr_conv.is_owned = false;
17498         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
17499         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateAddHTLC_get_payment_hash(&this_ptr_conv));
17500         return ret_arr;
17501 }
17502
17503 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17504         LDKUpdateAddHTLC this_ptr_conv;
17505         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17506         this_ptr_conv.is_owned = false;
17507         LDKThirtyTwoBytes val_ref;
17508         CHECK((*env)->GetArrayLength(env, val) == 32);
17509         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
17510         UpdateAddHTLC_set_payment_hash(&this_ptr_conv, val_ref);
17511 }
17512
17513 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr) {
17514         LDKUpdateAddHTLC this_ptr_conv;
17515         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17516         this_ptr_conv.is_owned = false;
17517         int32_t ret_val = UpdateAddHTLC_get_cltv_expiry(&this_ptr_conv);
17518         return ret_val;
17519 }
17520
17521 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
17522         LDKUpdateAddHTLC this_ptr_conv;
17523         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17524         this_ptr_conv.is_owned = false;
17525         UpdateAddHTLC_set_cltv_expiry(&this_ptr_conv, val);
17526 }
17527
17528 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17529         LDKUpdateAddHTLC orig_conv;
17530         orig_conv.inner = (void*)(orig & (~1));
17531         orig_conv.is_owned = false;
17532         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(&orig_conv);
17533         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17534         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17535         uint64_t ret_ref = (uint64_t)ret_var.inner;
17536         if (ret_var.is_owned) {
17537                 ret_ref |= 1;
17538         }
17539         return ret_ref;
17540 }
17541
17542 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17543         LDKUpdateFulfillHTLC this_obj_conv;
17544         this_obj_conv.inner = (void*)(this_obj & (~1));
17545         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17546         UpdateFulfillHTLC_free(this_obj_conv);
17547 }
17548
17549 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
17550         LDKUpdateFulfillHTLC this_ptr_conv;
17551         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17552         this_ptr_conv.is_owned = false;
17553         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
17554         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFulfillHTLC_get_channel_id(&this_ptr_conv));
17555         return ret_arr;
17556 }
17557
17558 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17559         LDKUpdateFulfillHTLC this_ptr_conv;
17560         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17561         this_ptr_conv.is_owned = false;
17562         LDKThirtyTwoBytes val_ref;
17563         CHECK((*env)->GetArrayLength(env, val) == 32);
17564         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
17565         UpdateFulfillHTLC_set_channel_id(&this_ptr_conv, val_ref);
17566 }
17567
17568 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
17569         LDKUpdateFulfillHTLC this_ptr_conv;
17570         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17571         this_ptr_conv.is_owned = false;
17572         int64_t ret_val = UpdateFulfillHTLC_get_htlc_id(&this_ptr_conv);
17573         return ret_val;
17574 }
17575
17576 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17577         LDKUpdateFulfillHTLC this_ptr_conv;
17578         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17579         this_ptr_conv.is_owned = false;
17580         UpdateFulfillHTLC_set_htlc_id(&this_ptr_conv, val);
17581 }
17582
17583 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1payment_1preimage(JNIEnv *env, jclass clz, int64_t this_ptr) {
17584         LDKUpdateFulfillHTLC this_ptr_conv;
17585         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17586         this_ptr_conv.is_owned = false;
17587         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
17588         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFulfillHTLC_get_payment_preimage(&this_ptr_conv));
17589         return ret_arr;
17590 }
17591
17592 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1payment_1preimage(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17593         LDKUpdateFulfillHTLC this_ptr_conv;
17594         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17595         this_ptr_conv.is_owned = false;
17596         LDKThirtyTwoBytes val_ref;
17597         CHECK((*env)->GetArrayLength(env, val) == 32);
17598         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
17599         UpdateFulfillHTLC_set_payment_preimage(&this_ptr_conv, val_ref);
17600 }
17601
17602 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) {
17603         LDKThirtyTwoBytes channel_id_arg_ref;
17604         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
17605         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
17606         LDKThirtyTwoBytes payment_preimage_arg_ref;
17607         CHECK((*env)->GetArrayLength(env, payment_preimage_arg) == 32);
17608         (*env)->GetByteArrayRegion(env, payment_preimage_arg, 0, 32, payment_preimage_arg_ref.data);
17609         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_new(channel_id_arg_ref, htlc_id_arg, payment_preimage_arg_ref);
17610         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17611         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17612         uint64_t ret_ref = (uint64_t)ret_var.inner;
17613         if (ret_var.is_owned) {
17614                 ret_ref |= 1;
17615         }
17616         return ret_ref;
17617 }
17618
17619 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17620         LDKUpdateFulfillHTLC orig_conv;
17621         orig_conv.inner = (void*)(orig & (~1));
17622         orig_conv.is_owned = false;
17623         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(&orig_conv);
17624         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17625         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17626         uint64_t ret_ref = (uint64_t)ret_var.inner;
17627         if (ret_var.is_owned) {
17628                 ret_ref |= 1;
17629         }
17630         return ret_ref;
17631 }
17632
17633 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17634         LDKUpdateFailHTLC this_obj_conv;
17635         this_obj_conv.inner = (void*)(this_obj & (~1));
17636         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17637         UpdateFailHTLC_free(this_obj_conv);
17638 }
17639
17640 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
17641         LDKUpdateFailHTLC this_ptr_conv;
17642         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17643         this_ptr_conv.is_owned = false;
17644         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
17645         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFailHTLC_get_channel_id(&this_ptr_conv));
17646         return ret_arr;
17647 }
17648
17649 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17650         LDKUpdateFailHTLC this_ptr_conv;
17651         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17652         this_ptr_conv.is_owned = false;
17653         LDKThirtyTwoBytes val_ref;
17654         CHECK((*env)->GetArrayLength(env, val) == 32);
17655         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
17656         UpdateFailHTLC_set_channel_id(&this_ptr_conv, val_ref);
17657 }
17658
17659 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
17660         LDKUpdateFailHTLC this_ptr_conv;
17661         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17662         this_ptr_conv.is_owned = false;
17663         int64_t ret_val = UpdateFailHTLC_get_htlc_id(&this_ptr_conv);
17664         return ret_val;
17665 }
17666
17667 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17668         LDKUpdateFailHTLC this_ptr_conv;
17669         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17670         this_ptr_conv.is_owned = false;
17671         UpdateFailHTLC_set_htlc_id(&this_ptr_conv, val);
17672 }
17673
17674 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17675         LDKUpdateFailHTLC orig_conv;
17676         orig_conv.inner = (void*)(orig & (~1));
17677         orig_conv.is_owned = false;
17678         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(&orig_conv);
17679         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17680         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17681         uint64_t ret_ref = (uint64_t)ret_var.inner;
17682         if (ret_var.is_owned) {
17683                 ret_ref |= 1;
17684         }
17685         return ret_ref;
17686 }
17687
17688 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17689         LDKUpdateFailMalformedHTLC this_obj_conv;
17690         this_obj_conv.inner = (void*)(this_obj & (~1));
17691         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17692         UpdateFailMalformedHTLC_free(this_obj_conv);
17693 }
17694
17695 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
17696         LDKUpdateFailMalformedHTLC this_ptr_conv;
17697         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17698         this_ptr_conv.is_owned = false;
17699         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
17700         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFailMalformedHTLC_get_channel_id(&this_ptr_conv));
17701         return ret_arr;
17702 }
17703
17704 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17705         LDKUpdateFailMalformedHTLC this_ptr_conv;
17706         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17707         this_ptr_conv.is_owned = false;
17708         LDKThirtyTwoBytes val_ref;
17709         CHECK((*env)->GetArrayLength(env, val) == 32);
17710         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
17711         UpdateFailMalformedHTLC_set_channel_id(&this_ptr_conv, val_ref);
17712 }
17713
17714 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
17715         LDKUpdateFailMalformedHTLC this_ptr_conv;
17716         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17717         this_ptr_conv.is_owned = false;
17718         int64_t ret_val = UpdateFailMalformedHTLC_get_htlc_id(&this_ptr_conv);
17719         return ret_val;
17720 }
17721
17722 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17723         LDKUpdateFailMalformedHTLC this_ptr_conv;
17724         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17725         this_ptr_conv.is_owned = false;
17726         UpdateFailMalformedHTLC_set_htlc_id(&this_ptr_conv, val);
17727 }
17728
17729 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1failure_1code(JNIEnv *env, jclass clz, int64_t this_ptr) {
17730         LDKUpdateFailMalformedHTLC this_ptr_conv;
17731         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17732         this_ptr_conv.is_owned = false;
17733         int16_t ret_val = UpdateFailMalformedHTLC_get_failure_code(&this_ptr_conv);
17734         return ret_val;
17735 }
17736
17737 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1failure_1code(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
17738         LDKUpdateFailMalformedHTLC this_ptr_conv;
17739         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17740         this_ptr_conv.is_owned = false;
17741         UpdateFailMalformedHTLC_set_failure_code(&this_ptr_conv, val);
17742 }
17743
17744 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17745         LDKUpdateFailMalformedHTLC orig_conv;
17746         orig_conv.inner = (void*)(orig & (~1));
17747         orig_conv.is_owned = false;
17748         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(&orig_conv);
17749         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17750         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17751         uint64_t ret_ref = (uint64_t)ret_var.inner;
17752         if (ret_var.is_owned) {
17753                 ret_ref |= 1;
17754         }
17755         return ret_ref;
17756 }
17757
17758 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17759         LDKCommitmentSigned this_obj_conv;
17760         this_obj_conv.inner = (void*)(this_obj & (~1));
17761         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17762         CommitmentSigned_free(this_obj_conv);
17763 }
17764
17765 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
17766         LDKCommitmentSigned this_ptr_conv;
17767         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17768         this_ptr_conv.is_owned = false;
17769         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
17770         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *CommitmentSigned_get_channel_id(&this_ptr_conv));
17771         return ret_arr;
17772 }
17773
17774 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17775         LDKCommitmentSigned this_ptr_conv;
17776         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17777         this_ptr_conv.is_owned = false;
17778         LDKThirtyTwoBytes val_ref;
17779         CHECK((*env)->GetArrayLength(env, val) == 32);
17780         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
17781         CommitmentSigned_set_channel_id(&this_ptr_conv, val_ref);
17782 }
17783
17784 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
17785         LDKCommitmentSigned this_ptr_conv;
17786         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17787         this_ptr_conv.is_owned = false;
17788         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
17789         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, CommitmentSigned_get_signature(&this_ptr_conv).compact_form);
17790         return ret_arr;
17791 }
17792
17793 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17794         LDKCommitmentSigned this_ptr_conv;
17795         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17796         this_ptr_conv.is_owned = false;
17797         LDKSignature val_ref;
17798         CHECK((*env)->GetArrayLength(env, val) == 64);
17799         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
17800         CommitmentSigned_set_signature(&this_ptr_conv, val_ref);
17801 }
17802
17803 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1htlc_1signatures(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
17804         LDKCommitmentSigned this_ptr_conv;
17805         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17806         this_ptr_conv.is_owned = false;
17807         LDKCVec_SignatureZ val_constr;
17808         val_constr.datalen = (*env)->GetArrayLength(env, val);
17809         if (val_constr.datalen > 0)
17810                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
17811         else
17812                 val_constr.data = NULL;
17813         for (size_t i = 0; i < val_constr.datalen; i++) {
17814                 int8_tArray val_conv_8 = (*env)->GetObjectArrayElement(env, val, i);
17815                 LDKSignature val_conv_8_ref;
17816                 CHECK((*env)->GetArrayLength(env, val_conv_8) == 64);
17817                 (*env)->GetByteArrayRegion(env, val_conv_8, 0, 64, val_conv_8_ref.compact_form);
17818                 val_constr.data[i] = val_conv_8_ref;
17819         }
17820         CommitmentSigned_set_htlc_signatures(&this_ptr_conv, val_constr);
17821 }
17822
17823 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) {
17824         LDKThirtyTwoBytes channel_id_arg_ref;
17825         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
17826         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
17827         LDKSignature signature_arg_ref;
17828         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
17829         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
17830         LDKCVec_SignatureZ htlc_signatures_arg_constr;
17831         htlc_signatures_arg_constr.datalen = (*env)->GetArrayLength(env, htlc_signatures_arg);
17832         if (htlc_signatures_arg_constr.datalen > 0)
17833                 htlc_signatures_arg_constr.data = MALLOC(htlc_signatures_arg_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
17834         else
17835                 htlc_signatures_arg_constr.data = NULL;
17836         for (size_t i = 0; i < htlc_signatures_arg_constr.datalen; i++) {
17837                 int8_tArray htlc_signatures_arg_conv_8 = (*env)->GetObjectArrayElement(env, htlc_signatures_arg, i);
17838                 LDKSignature htlc_signatures_arg_conv_8_ref;
17839                 CHECK((*env)->GetArrayLength(env, htlc_signatures_arg_conv_8) == 64);
17840                 (*env)->GetByteArrayRegion(env, htlc_signatures_arg_conv_8, 0, 64, htlc_signatures_arg_conv_8_ref.compact_form);
17841                 htlc_signatures_arg_constr.data[i] = htlc_signatures_arg_conv_8_ref;
17842         }
17843         LDKCommitmentSigned ret_var = CommitmentSigned_new(channel_id_arg_ref, signature_arg_ref, htlc_signatures_arg_constr);
17844         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17845         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17846         uint64_t ret_ref = (uint64_t)ret_var.inner;
17847         if (ret_var.is_owned) {
17848                 ret_ref |= 1;
17849         }
17850         return ret_ref;
17851 }
17852
17853 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17854         LDKCommitmentSigned orig_conv;
17855         orig_conv.inner = (void*)(orig & (~1));
17856         orig_conv.is_owned = false;
17857         LDKCommitmentSigned ret_var = CommitmentSigned_clone(&orig_conv);
17858         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17859         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17860         uint64_t ret_ref = (uint64_t)ret_var.inner;
17861         if (ret_var.is_owned) {
17862                 ret_ref |= 1;
17863         }
17864         return ret_ref;
17865 }
17866
17867 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17868         LDKRevokeAndACK this_obj_conv;
17869         this_obj_conv.inner = (void*)(this_obj & (~1));
17870         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17871         RevokeAndACK_free(this_obj_conv);
17872 }
17873
17874 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
17875         LDKRevokeAndACK this_ptr_conv;
17876         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17877         this_ptr_conv.is_owned = false;
17878         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
17879         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *RevokeAndACK_get_channel_id(&this_ptr_conv));
17880         return ret_arr;
17881 }
17882
17883 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17884         LDKRevokeAndACK this_ptr_conv;
17885         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17886         this_ptr_conv.is_owned = false;
17887         LDKThirtyTwoBytes val_ref;
17888         CHECK((*env)->GetArrayLength(env, val) == 32);
17889         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
17890         RevokeAndACK_set_channel_id(&this_ptr_conv, val_ref);
17891 }
17892
17893 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr) {
17894         LDKRevokeAndACK this_ptr_conv;
17895         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17896         this_ptr_conv.is_owned = false;
17897         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
17898         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *RevokeAndACK_get_per_commitment_secret(&this_ptr_conv));
17899         return ret_arr;
17900 }
17901
17902 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1set_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17903         LDKRevokeAndACK this_ptr_conv;
17904         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17905         this_ptr_conv.is_owned = false;
17906         LDKThirtyTwoBytes val_ref;
17907         CHECK((*env)->GetArrayLength(env, val) == 32);
17908         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
17909         RevokeAndACK_set_per_commitment_secret(&this_ptr_conv, val_ref);
17910 }
17911
17912 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1next_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
17913         LDKRevokeAndACK this_ptr_conv;
17914         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17915         this_ptr_conv.is_owned = false;
17916         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
17917         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RevokeAndACK_get_next_per_commitment_point(&this_ptr_conv).compressed_form);
17918         return ret_arr;
17919 }
17920
17921 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) {
17922         LDKRevokeAndACK this_ptr_conv;
17923         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17924         this_ptr_conv.is_owned = false;
17925         LDKPublicKey val_ref;
17926         CHECK((*env)->GetArrayLength(env, val) == 33);
17927         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
17928         RevokeAndACK_set_next_per_commitment_point(&this_ptr_conv, val_ref);
17929 }
17930
17931 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) {
17932         LDKThirtyTwoBytes channel_id_arg_ref;
17933         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
17934         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
17935         LDKThirtyTwoBytes per_commitment_secret_arg_ref;
17936         CHECK((*env)->GetArrayLength(env, per_commitment_secret_arg) == 32);
17937         (*env)->GetByteArrayRegion(env, per_commitment_secret_arg, 0, 32, per_commitment_secret_arg_ref.data);
17938         LDKPublicKey next_per_commitment_point_arg_ref;
17939         CHECK((*env)->GetArrayLength(env, next_per_commitment_point_arg) == 33);
17940         (*env)->GetByteArrayRegion(env, next_per_commitment_point_arg, 0, 33, next_per_commitment_point_arg_ref.compressed_form);
17941         LDKRevokeAndACK ret_var = RevokeAndACK_new(channel_id_arg_ref, per_commitment_secret_arg_ref, next_per_commitment_point_arg_ref);
17942         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17943         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17944         uint64_t ret_ref = (uint64_t)ret_var.inner;
17945         if (ret_var.is_owned) {
17946                 ret_ref |= 1;
17947         }
17948         return ret_ref;
17949 }
17950
17951 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17952         LDKRevokeAndACK orig_conv;
17953         orig_conv.inner = (void*)(orig & (~1));
17954         orig_conv.is_owned = false;
17955         LDKRevokeAndACK ret_var = RevokeAndACK_clone(&orig_conv);
17956         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17957         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17958         uint64_t ret_ref = (uint64_t)ret_var.inner;
17959         if (ret_var.is_owned) {
17960                 ret_ref |= 1;
17961         }
17962         return ret_ref;
17963 }
17964
17965 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17966         LDKUpdateFee this_obj_conv;
17967         this_obj_conv.inner = (void*)(this_obj & (~1));
17968         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17969         UpdateFee_free(this_obj_conv);
17970 }
17971
17972 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFee_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
17973         LDKUpdateFee this_ptr_conv;
17974         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17975         this_ptr_conv.is_owned = false;
17976         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
17977         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFee_get_channel_id(&this_ptr_conv));
17978         return ret_arr;
17979 }
17980
17981 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17982         LDKUpdateFee this_ptr_conv;
17983         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17984         this_ptr_conv.is_owned = false;
17985         LDKThirtyTwoBytes val_ref;
17986         CHECK((*env)->GetArrayLength(env, val) == 32);
17987         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
17988         UpdateFee_set_channel_id(&this_ptr_conv, val_ref);
17989 }
17990
17991 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1get_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr) {
17992         LDKUpdateFee this_ptr_conv;
17993         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17994         this_ptr_conv.is_owned = false;
17995         int32_t ret_val = UpdateFee_get_feerate_per_kw(&this_ptr_conv);
17996         return ret_val;
17997 }
17998
17999 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1set_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
18000         LDKUpdateFee this_ptr_conv;
18001         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18002         this_ptr_conv.is_owned = false;
18003         UpdateFee_set_feerate_per_kw(&this_ptr_conv, val);
18004 }
18005
18006 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) {
18007         LDKThirtyTwoBytes channel_id_arg_ref;
18008         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
18009         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
18010         LDKUpdateFee ret_var = UpdateFee_new(channel_id_arg_ref, feerate_per_kw_arg);
18011         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18012         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18013         uint64_t ret_ref = (uint64_t)ret_var.inner;
18014         if (ret_var.is_owned) {
18015                 ret_ref |= 1;
18016         }
18017         return ret_ref;
18018 }
18019
18020 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18021         LDKUpdateFee orig_conv;
18022         orig_conv.inner = (void*)(orig & (~1));
18023         orig_conv.is_owned = false;
18024         LDKUpdateFee ret_var = UpdateFee_clone(&orig_conv);
18025         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18026         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18027         uint64_t ret_ref = (uint64_t)ret_var.inner;
18028         if (ret_var.is_owned) {
18029                 ret_ref |= 1;
18030         }
18031         return ret_ref;
18032 }
18033
18034 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18035         LDKDataLossProtect this_obj_conv;
18036         this_obj_conv.inner = (void*)(this_obj & (~1));
18037         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18038         DataLossProtect_free(this_obj_conv);
18039 }
18040
18041 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1get_1your_1last_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr) {
18042         LDKDataLossProtect this_ptr_conv;
18043         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18044         this_ptr_conv.is_owned = false;
18045         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18046         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *DataLossProtect_get_your_last_per_commitment_secret(&this_ptr_conv));
18047         return ret_arr;
18048 }
18049
18050 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) {
18051         LDKDataLossProtect this_ptr_conv;
18052         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18053         this_ptr_conv.is_owned = false;
18054         LDKThirtyTwoBytes val_ref;
18055         CHECK((*env)->GetArrayLength(env, val) == 32);
18056         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18057         DataLossProtect_set_your_last_per_commitment_secret(&this_ptr_conv, val_ref);
18058 }
18059
18060 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1get_1my_1current_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
18061         LDKDataLossProtect this_ptr_conv;
18062         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18063         this_ptr_conv.is_owned = false;
18064         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
18065         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DataLossProtect_get_my_current_per_commitment_point(&this_ptr_conv).compressed_form);
18066         return ret_arr;
18067 }
18068
18069 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) {
18070         LDKDataLossProtect this_ptr_conv;
18071         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18072         this_ptr_conv.is_owned = false;
18073         LDKPublicKey val_ref;
18074         CHECK((*env)->GetArrayLength(env, val) == 33);
18075         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
18076         DataLossProtect_set_my_current_per_commitment_point(&this_ptr_conv, val_ref);
18077 }
18078
18079 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) {
18080         LDKThirtyTwoBytes your_last_per_commitment_secret_arg_ref;
18081         CHECK((*env)->GetArrayLength(env, your_last_per_commitment_secret_arg) == 32);
18082         (*env)->GetByteArrayRegion(env, your_last_per_commitment_secret_arg, 0, 32, your_last_per_commitment_secret_arg_ref.data);
18083         LDKPublicKey my_current_per_commitment_point_arg_ref;
18084         CHECK((*env)->GetArrayLength(env, my_current_per_commitment_point_arg) == 33);
18085         (*env)->GetByteArrayRegion(env, my_current_per_commitment_point_arg, 0, 33, my_current_per_commitment_point_arg_ref.compressed_form);
18086         LDKDataLossProtect ret_var = DataLossProtect_new(your_last_per_commitment_secret_arg_ref, my_current_per_commitment_point_arg_ref);
18087         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18088         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18089         uint64_t ret_ref = (uint64_t)ret_var.inner;
18090         if (ret_var.is_owned) {
18091                 ret_ref |= 1;
18092         }
18093         return ret_ref;
18094 }
18095
18096 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18097         LDKDataLossProtect orig_conv;
18098         orig_conv.inner = (void*)(orig & (~1));
18099         orig_conv.is_owned = false;
18100         LDKDataLossProtect ret_var = DataLossProtect_clone(&orig_conv);
18101         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18102         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18103         uint64_t ret_ref = (uint64_t)ret_var.inner;
18104         if (ret_var.is_owned) {
18105                 ret_ref |= 1;
18106         }
18107         return ret_ref;
18108 }
18109
18110 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18111         LDKChannelReestablish this_obj_conv;
18112         this_obj_conv.inner = (void*)(this_obj & (~1));
18113         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18114         ChannelReestablish_free(this_obj_conv);
18115 }
18116
18117 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18118         LDKChannelReestablish this_ptr_conv;
18119         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18120         this_ptr_conv.is_owned = false;
18121         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18122         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ChannelReestablish_get_channel_id(&this_ptr_conv));
18123         return ret_arr;
18124 }
18125
18126 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18127         LDKChannelReestablish this_ptr_conv;
18128         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18129         this_ptr_conv.is_owned = false;
18130         LDKThirtyTwoBytes val_ref;
18131         CHECK((*env)->GetArrayLength(env, val) == 32);
18132         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18133         ChannelReestablish_set_channel_id(&this_ptr_conv, val_ref);
18134 }
18135
18136 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1next_1local_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_ptr) {
18137         LDKChannelReestablish this_ptr_conv;
18138         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18139         this_ptr_conv.is_owned = false;
18140         int64_t ret_val = ChannelReestablish_get_next_local_commitment_number(&this_ptr_conv);
18141         return ret_val;
18142 }
18143
18144 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) {
18145         LDKChannelReestablish this_ptr_conv;
18146         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18147         this_ptr_conv.is_owned = false;
18148         ChannelReestablish_set_next_local_commitment_number(&this_ptr_conv, val);
18149 }
18150
18151 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1next_1remote_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_ptr) {
18152         LDKChannelReestablish this_ptr_conv;
18153         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18154         this_ptr_conv.is_owned = false;
18155         int64_t ret_val = ChannelReestablish_get_next_remote_commitment_number(&this_ptr_conv);
18156         return ret_val;
18157 }
18158
18159 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) {
18160         LDKChannelReestablish this_ptr_conv;
18161         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18162         this_ptr_conv.is_owned = false;
18163         ChannelReestablish_set_next_remote_commitment_number(&this_ptr_conv, val);
18164 }
18165
18166 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18167         LDKChannelReestablish orig_conv;
18168         orig_conv.inner = (void*)(orig & (~1));
18169         orig_conv.is_owned = false;
18170         LDKChannelReestablish ret_var = ChannelReestablish_clone(&orig_conv);
18171         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18172         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18173         uint64_t ret_ref = (uint64_t)ret_var.inner;
18174         if (ret_var.is_owned) {
18175                 ret_ref |= 1;
18176         }
18177         return ret_ref;
18178 }
18179
18180 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18181         LDKAnnouncementSignatures this_obj_conv;
18182         this_obj_conv.inner = (void*)(this_obj & (~1));
18183         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18184         AnnouncementSignatures_free(this_obj_conv);
18185 }
18186
18187 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18188         LDKAnnouncementSignatures this_ptr_conv;
18189         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18190         this_ptr_conv.is_owned = false;
18191         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18192         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *AnnouncementSignatures_get_channel_id(&this_ptr_conv));
18193         return ret_arr;
18194 }
18195
18196 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18197         LDKAnnouncementSignatures this_ptr_conv;
18198         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18199         this_ptr_conv.is_owned = false;
18200         LDKThirtyTwoBytes val_ref;
18201         CHECK((*env)->GetArrayLength(env, val) == 32);
18202         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18203         AnnouncementSignatures_set_channel_id(&this_ptr_conv, val_ref);
18204 }
18205
18206 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18207         LDKAnnouncementSignatures this_ptr_conv;
18208         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18209         this_ptr_conv.is_owned = false;
18210         int64_t ret_val = AnnouncementSignatures_get_short_channel_id(&this_ptr_conv);
18211         return ret_val;
18212 }
18213
18214 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18215         LDKAnnouncementSignatures this_ptr_conv;
18216         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18217         this_ptr_conv.is_owned = false;
18218         AnnouncementSignatures_set_short_channel_id(&this_ptr_conv, val);
18219 }
18220
18221 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1node_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
18222         LDKAnnouncementSignatures this_ptr_conv;
18223         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18224         this_ptr_conv.is_owned = false;
18225         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
18226         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, AnnouncementSignatures_get_node_signature(&this_ptr_conv).compact_form);
18227         return ret_arr;
18228 }
18229
18230 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1node_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18231         LDKAnnouncementSignatures this_ptr_conv;
18232         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18233         this_ptr_conv.is_owned = false;
18234         LDKSignature val_ref;
18235         CHECK((*env)->GetArrayLength(env, val) == 64);
18236         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
18237         AnnouncementSignatures_set_node_signature(&this_ptr_conv, val_ref);
18238 }
18239
18240 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1bitcoin_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
18241         LDKAnnouncementSignatures this_ptr_conv;
18242         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18243         this_ptr_conv.is_owned = false;
18244         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
18245         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, AnnouncementSignatures_get_bitcoin_signature(&this_ptr_conv).compact_form);
18246         return ret_arr;
18247 }
18248
18249 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1bitcoin_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18250         LDKAnnouncementSignatures this_ptr_conv;
18251         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18252         this_ptr_conv.is_owned = false;
18253         LDKSignature val_ref;
18254         CHECK((*env)->GetArrayLength(env, val) == 64);
18255         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
18256         AnnouncementSignatures_set_bitcoin_signature(&this_ptr_conv, val_ref);
18257 }
18258
18259 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) {
18260         LDKThirtyTwoBytes channel_id_arg_ref;
18261         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
18262         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
18263         LDKSignature node_signature_arg_ref;
18264         CHECK((*env)->GetArrayLength(env, node_signature_arg) == 64);
18265         (*env)->GetByteArrayRegion(env, node_signature_arg, 0, 64, node_signature_arg_ref.compact_form);
18266         LDKSignature bitcoin_signature_arg_ref;
18267         CHECK((*env)->GetArrayLength(env, bitcoin_signature_arg) == 64);
18268         (*env)->GetByteArrayRegion(env, bitcoin_signature_arg, 0, 64, bitcoin_signature_arg_ref.compact_form);
18269         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_new(channel_id_arg_ref, short_channel_id_arg, node_signature_arg_ref, bitcoin_signature_arg_ref);
18270         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18271         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18272         uint64_t ret_ref = (uint64_t)ret_var.inner;
18273         if (ret_var.is_owned) {
18274                 ret_ref |= 1;
18275         }
18276         return ret_ref;
18277 }
18278
18279 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18280         LDKAnnouncementSignatures orig_conv;
18281         orig_conv.inner = (void*)(orig & (~1));
18282         orig_conv.is_owned = false;
18283         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(&orig_conv);
18284         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18285         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18286         uint64_t ret_ref = (uint64_t)ret_var.inner;
18287         if (ret_var.is_owned) {
18288                 ret_ref |= 1;
18289         }
18290         return ret_ref;
18291 }
18292
18293 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetAddress_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
18294         if ((this_ptr & 1) != 0) return;
18295         LDKNetAddress this_ptr_conv = *(LDKNetAddress*)(((uint64_t)this_ptr) & ~1);
18296         FREE((void*)this_ptr);
18297         NetAddress_free(this_ptr_conv);
18298 }
18299
18300 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18301         LDKNetAddress* orig_conv = (LDKNetAddress*)orig;
18302         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
18303         *ret_copy = NetAddress_clone(orig_conv);
18304         uint64_t ret_ref = (uint64_t)ret_copy;
18305         return ret_ref;
18306 }
18307
18308 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetAddress_1write(JNIEnv *env, jclass clz, int64_t obj) {
18309         LDKNetAddress* obj_conv = (LDKNetAddress*)obj;
18310         LDKCVec_u8Z ret_var = NetAddress_write(obj_conv);
18311         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
18312         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
18313         CVec_u8Z_free(ret_var);
18314         return ret_arr;
18315 }
18316
18317 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Result_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
18318         LDKu8slice ser_ref;
18319         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
18320         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
18321         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
18322         *ret_conv = Result_read(ser_ref);
18323         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
18324         return (uint64_t)ret_conv;
18325 }
18326
18327 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
18328         LDKu8slice ser_ref;
18329         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
18330         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
18331         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
18332         *ret_conv = NetAddress_read(ser_ref);
18333         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
18334         return (uint64_t)ret_conv;
18335 }
18336
18337 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18338         LDKUnsignedNodeAnnouncement this_obj_conv;
18339         this_obj_conv.inner = (void*)(this_obj & (~1));
18340         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18341         UnsignedNodeAnnouncement_free(this_obj_conv);
18342 }
18343
18344 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
18345         LDKUnsignedNodeAnnouncement this_ptr_conv;
18346         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18347         this_ptr_conv.is_owned = false;
18348         LDKNodeFeatures ret_var = UnsignedNodeAnnouncement_get_features(&this_ptr_conv);
18349         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18350         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18351         uint64_t ret_ref = (uint64_t)ret_var.inner;
18352         if (ret_var.is_owned) {
18353                 ret_ref |= 1;
18354         }
18355         return ret_ref;
18356 }
18357
18358 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18359         LDKUnsignedNodeAnnouncement this_ptr_conv;
18360         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18361         this_ptr_conv.is_owned = false;
18362         LDKNodeFeatures val_conv;
18363         val_conv.inner = (void*)(val & (~1));
18364         val_conv.is_owned = (val & 1) || (val == 0);
18365         val_conv = NodeFeatures_clone(&val_conv);
18366         UnsignedNodeAnnouncement_set_features(&this_ptr_conv, val_conv);
18367 }
18368
18369 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
18370         LDKUnsignedNodeAnnouncement this_ptr_conv;
18371         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18372         this_ptr_conv.is_owned = false;
18373         int32_t ret_val = UnsignedNodeAnnouncement_get_timestamp(&this_ptr_conv);
18374         return ret_val;
18375 }
18376
18377 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
18378         LDKUnsignedNodeAnnouncement this_ptr_conv;
18379         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18380         this_ptr_conv.is_owned = false;
18381         UnsignedNodeAnnouncement_set_timestamp(&this_ptr_conv, val);
18382 }
18383
18384 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18385         LDKUnsignedNodeAnnouncement this_ptr_conv;
18386         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18387         this_ptr_conv.is_owned = false;
18388         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
18389         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedNodeAnnouncement_get_node_id(&this_ptr_conv).compressed_form);
18390         return ret_arr;
18391 }
18392
18393 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18394         LDKUnsignedNodeAnnouncement this_ptr_conv;
18395         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18396         this_ptr_conv.is_owned = false;
18397         LDKPublicKey val_ref;
18398         CHECK((*env)->GetArrayLength(env, val) == 33);
18399         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
18400         UnsignedNodeAnnouncement_set_node_id(&this_ptr_conv, val_ref);
18401 }
18402
18403 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr) {
18404         LDKUnsignedNodeAnnouncement this_ptr_conv;
18405         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18406         this_ptr_conv.is_owned = false;
18407         int8_tArray ret_arr = (*env)->NewByteArray(env, 3);
18408         (*env)->SetByteArrayRegion(env, ret_arr, 0, 3, *UnsignedNodeAnnouncement_get_rgb(&this_ptr_conv));
18409         return ret_arr;
18410 }
18411
18412 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18413         LDKUnsignedNodeAnnouncement this_ptr_conv;
18414         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18415         this_ptr_conv.is_owned = false;
18416         LDKThreeBytes val_ref;
18417         CHECK((*env)->GetArrayLength(env, val) == 3);
18418         (*env)->GetByteArrayRegion(env, val, 0, 3, val_ref.data);
18419         UnsignedNodeAnnouncement_set_rgb(&this_ptr_conv, val_ref);
18420 }
18421
18422 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
18423         LDKUnsignedNodeAnnouncement this_ptr_conv;
18424         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18425         this_ptr_conv.is_owned = false;
18426         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18427         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedNodeAnnouncement_get_alias(&this_ptr_conv));
18428         return ret_arr;
18429 }
18430
18431 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18432         LDKUnsignedNodeAnnouncement this_ptr_conv;
18433         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18434         this_ptr_conv.is_owned = false;
18435         LDKThirtyTwoBytes val_ref;
18436         CHECK((*env)->GetArrayLength(env, val) == 32);
18437         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18438         UnsignedNodeAnnouncement_set_alias(&this_ptr_conv, val_ref);
18439 }
18440
18441 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1addresses(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
18442         LDKUnsignedNodeAnnouncement this_ptr_conv;
18443         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18444         this_ptr_conv.is_owned = false;
18445         LDKCVec_NetAddressZ val_constr;
18446         val_constr.datalen = (*env)->GetArrayLength(env, val);
18447         if (val_constr.datalen > 0)
18448                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
18449         else
18450                 val_constr.data = NULL;
18451         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
18452         for (size_t m = 0; m < val_constr.datalen; m++) {
18453                 int64_t val_conv_12 = val_vals[m];
18454                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(((uint64_t)val_conv_12) & ~1);
18455                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)val_conv_12) & ~1));
18456                 val_constr.data[m] = val_conv_12_conv;
18457         }
18458         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
18459         UnsignedNodeAnnouncement_set_addresses(&this_ptr_conv, val_constr);
18460 }
18461
18462 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18463         LDKUnsignedNodeAnnouncement orig_conv;
18464         orig_conv.inner = (void*)(orig & (~1));
18465         orig_conv.is_owned = false;
18466         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(&orig_conv);
18467         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18468         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18469         uint64_t ret_ref = (uint64_t)ret_var.inner;
18470         if (ret_var.is_owned) {
18471                 ret_ref |= 1;
18472         }
18473         return ret_ref;
18474 }
18475
18476 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18477         LDKNodeAnnouncement this_obj_conv;
18478         this_obj_conv.inner = (void*)(this_obj & (~1));
18479         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18480         NodeAnnouncement_free(this_obj_conv);
18481 }
18482
18483 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
18484         LDKNodeAnnouncement this_ptr_conv;
18485         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18486         this_ptr_conv.is_owned = false;
18487         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
18488         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, NodeAnnouncement_get_signature(&this_ptr_conv).compact_form);
18489         return ret_arr;
18490 }
18491
18492 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18493         LDKNodeAnnouncement this_ptr_conv;
18494         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18495         this_ptr_conv.is_owned = false;
18496         LDKSignature val_ref;
18497         CHECK((*env)->GetArrayLength(env, val) == 64);
18498         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
18499         NodeAnnouncement_set_signature(&this_ptr_conv, val_ref);
18500 }
18501
18502 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
18503         LDKNodeAnnouncement this_ptr_conv;
18504         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18505         this_ptr_conv.is_owned = false;
18506         LDKUnsignedNodeAnnouncement ret_var = NodeAnnouncement_get_contents(&this_ptr_conv);
18507         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18508         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18509         uint64_t ret_ref = (uint64_t)ret_var.inner;
18510         if (ret_var.is_owned) {
18511                 ret_ref |= 1;
18512         }
18513         return ret_ref;
18514 }
18515
18516 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18517         LDKNodeAnnouncement this_ptr_conv;
18518         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18519         this_ptr_conv.is_owned = false;
18520         LDKUnsignedNodeAnnouncement val_conv;
18521         val_conv.inner = (void*)(val & (~1));
18522         val_conv.is_owned = (val & 1) || (val == 0);
18523         val_conv = UnsignedNodeAnnouncement_clone(&val_conv);
18524         NodeAnnouncement_set_contents(&this_ptr_conv, val_conv);
18525 }
18526
18527 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1new(JNIEnv *env, jclass clz, int8_tArray signature_arg, int64_t contents_arg) {
18528         LDKSignature signature_arg_ref;
18529         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
18530         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
18531         LDKUnsignedNodeAnnouncement contents_arg_conv;
18532         contents_arg_conv.inner = (void*)(contents_arg & (~1));
18533         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
18534         contents_arg_conv = UnsignedNodeAnnouncement_clone(&contents_arg_conv);
18535         LDKNodeAnnouncement ret_var = NodeAnnouncement_new(signature_arg_ref, contents_arg_conv);
18536         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18537         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18538         uint64_t ret_ref = (uint64_t)ret_var.inner;
18539         if (ret_var.is_owned) {
18540                 ret_ref |= 1;
18541         }
18542         return ret_ref;
18543 }
18544
18545 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18546         LDKNodeAnnouncement orig_conv;
18547         orig_conv.inner = (void*)(orig & (~1));
18548         orig_conv.is_owned = false;
18549         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(&orig_conv);
18550         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18551         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18552         uint64_t ret_ref = (uint64_t)ret_var.inner;
18553         if (ret_var.is_owned) {
18554                 ret_ref |= 1;
18555         }
18556         return ret_ref;
18557 }
18558
18559 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18560         LDKUnsignedChannelAnnouncement this_obj_conv;
18561         this_obj_conv.inner = (void*)(this_obj & (~1));
18562         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18563         UnsignedChannelAnnouncement_free(this_obj_conv);
18564 }
18565
18566 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
18567         LDKUnsignedChannelAnnouncement this_ptr_conv;
18568         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18569         this_ptr_conv.is_owned = false;
18570         LDKChannelFeatures ret_var = UnsignedChannelAnnouncement_get_features(&this_ptr_conv);
18571         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18572         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18573         uint64_t ret_ref = (uint64_t)ret_var.inner;
18574         if (ret_var.is_owned) {
18575                 ret_ref |= 1;
18576         }
18577         return ret_ref;
18578 }
18579
18580 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18581         LDKUnsignedChannelAnnouncement this_ptr_conv;
18582         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18583         this_ptr_conv.is_owned = false;
18584         LDKChannelFeatures val_conv;
18585         val_conv.inner = (void*)(val & (~1));
18586         val_conv.is_owned = (val & 1) || (val == 0);
18587         val_conv = ChannelFeatures_clone(&val_conv);
18588         UnsignedChannelAnnouncement_set_features(&this_ptr_conv, val_conv);
18589 }
18590
18591 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
18592         LDKUnsignedChannelAnnouncement this_ptr_conv;
18593         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18594         this_ptr_conv.is_owned = false;
18595         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18596         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedChannelAnnouncement_get_chain_hash(&this_ptr_conv));
18597         return ret_arr;
18598 }
18599
18600 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18601         LDKUnsignedChannelAnnouncement this_ptr_conv;
18602         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18603         this_ptr_conv.is_owned = false;
18604         LDKThirtyTwoBytes val_ref;
18605         CHECK((*env)->GetArrayLength(env, val) == 32);
18606         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18607         UnsignedChannelAnnouncement_set_chain_hash(&this_ptr_conv, val_ref);
18608 }
18609
18610 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18611         LDKUnsignedChannelAnnouncement this_ptr_conv;
18612         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18613         this_ptr_conv.is_owned = false;
18614         int64_t ret_val = UnsignedChannelAnnouncement_get_short_channel_id(&this_ptr_conv);
18615         return ret_val;
18616 }
18617
18618 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18619         LDKUnsignedChannelAnnouncement this_ptr_conv;
18620         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18621         this_ptr_conv.is_owned = false;
18622         UnsignedChannelAnnouncement_set_short_channel_id(&this_ptr_conv, val);
18623 }
18624
18625 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1node_1id_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
18626         LDKUnsignedChannelAnnouncement this_ptr_conv;
18627         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18628         this_ptr_conv.is_owned = false;
18629         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
18630         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_node_id_1(&this_ptr_conv).compressed_form);
18631         return ret_arr;
18632 }
18633
18634 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1node_1id_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18635         LDKUnsignedChannelAnnouncement this_ptr_conv;
18636         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18637         this_ptr_conv.is_owned = false;
18638         LDKPublicKey val_ref;
18639         CHECK((*env)->GetArrayLength(env, val) == 33);
18640         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
18641         UnsignedChannelAnnouncement_set_node_id_1(&this_ptr_conv, val_ref);
18642 }
18643
18644 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1node_1id_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
18645         LDKUnsignedChannelAnnouncement this_ptr_conv;
18646         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18647         this_ptr_conv.is_owned = false;
18648         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
18649         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_node_id_2(&this_ptr_conv).compressed_form);
18650         return ret_arr;
18651 }
18652
18653 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1node_1id_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18654         LDKUnsignedChannelAnnouncement this_ptr_conv;
18655         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18656         this_ptr_conv.is_owned = false;
18657         LDKPublicKey val_ref;
18658         CHECK((*env)->GetArrayLength(env, val) == 33);
18659         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
18660         UnsignedChannelAnnouncement_set_node_id_2(&this_ptr_conv, val_ref);
18661 }
18662
18663 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1bitcoin_1key_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
18664         LDKUnsignedChannelAnnouncement this_ptr_conv;
18665         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18666         this_ptr_conv.is_owned = false;
18667         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
18668         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_bitcoin_key_1(&this_ptr_conv).compressed_form);
18669         return ret_arr;
18670 }
18671
18672 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1bitcoin_1key_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18673         LDKUnsignedChannelAnnouncement this_ptr_conv;
18674         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18675         this_ptr_conv.is_owned = false;
18676         LDKPublicKey val_ref;
18677         CHECK((*env)->GetArrayLength(env, val) == 33);
18678         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
18679         UnsignedChannelAnnouncement_set_bitcoin_key_1(&this_ptr_conv, val_ref);
18680 }
18681
18682 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1bitcoin_1key_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
18683         LDKUnsignedChannelAnnouncement this_ptr_conv;
18684         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18685         this_ptr_conv.is_owned = false;
18686         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
18687         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_bitcoin_key_2(&this_ptr_conv).compressed_form);
18688         return ret_arr;
18689 }
18690
18691 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1bitcoin_1key_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18692         LDKUnsignedChannelAnnouncement this_ptr_conv;
18693         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18694         this_ptr_conv.is_owned = false;
18695         LDKPublicKey val_ref;
18696         CHECK((*env)->GetArrayLength(env, val) == 33);
18697         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
18698         UnsignedChannelAnnouncement_set_bitcoin_key_2(&this_ptr_conv, val_ref);
18699 }
18700
18701 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18702         LDKUnsignedChannelAnnouncement orig_conv;
18703         orig_conv.inner = (void*)(orig & (~1));
18704         orig_conv.is_owned = false;
18705         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(&orig_conv);
18706         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18707         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18708         uint64_t ret_ref = (uint64_t)ret_var.inner;
18709         if (ret_var.is_owned) {
18710                 ret_ref |= 1;
18711         }
18712         return ret_ref;
18713 }
18714
18715 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18716         LDKChannelAnnouncement this_obj_conv;
18717         this_obj_conv.inner = (void*)(this_obj & (~1));
18718         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18719         ChannelAnnouncement_free(this_obj_conv);
18720 }
18721
18722 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1node_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
18723         LDKChannelAnnouncement this_ptr_conv;
18724         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18725         this_ptr_conv.is_owned = false;
18726         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
18727         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_node_signature_1(&this_ptr_conv).compact_form);
18728         return ret_arr;
18729 }
18730
18731 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1node_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18732         LDKChannelAnnouncement this_ptr_conv;
18733         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18734         this_ptr_conv.is_owned = false;
18735         LDKSignature val_ref;
18736         CHECK((*env)->GetArrayLength(env, val) == 64);
18737         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
18738         ChannelAnnouncement_set_node_signature_1(&this_ptr_conv, val_ref);
18739 }
18740
18741 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1node_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
18742         LDKChannelAnnouncement this_ptr_conv;
18743         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18744         this_ptr_conv.is_owned = false;
18745         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
18746         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_node_signature_2(&this_ptr_conv).compact_form);
18747         return ret_arr;
18748 }
18749
18750 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1node_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18751         LDKChannelAnnouncement this_ptr_conv;
18752         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18753         this_ptr_conv.is_owned = false;
18754         LDKSignature val_ref;
18755         CHECK((*env)->GetArrayLength(env, val) == 64);
18756         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
18757         ChannelAnnouncement_set_node_signature_2(&this_ptr_conv, val_ref);
18758 }
18759
18760 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1bitcoin_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
18761         LDKChannelAnnouncement this_ptr_conv;
18762         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18763         this_ptr_conv.is_owned = false;
18764         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
18765         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_bitcoin_signature_1(&this_ptr_conv).compact_form);
18766         return ret_arr;
18767 }
18768
18769 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1bitcoin_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18770         LDKChannelAnnouncement this_ptr_conv;
18771         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18772         this_ptr_conv.is_owned = false;
18773         LDKSignature val_ref;
18774         CHECK((*env)->GetArrayLength(env, val) == 64);
18775         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
18776         ChannelAnnouncement_set_bitcoin_signature_1(&this_ptr_conv, val_ref);
18777 }
18778
18779 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1bitcoin_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
18780         LDKChannelAnnouncement this_ptr_conv;
18781         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18782         this_ptr_conv.is_owned = false;
18783         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
18784         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_bitcoin_signature_2(&this_ptr_conv).compact_form);
18785         return ret_arr;
18786 }
18787
18788 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1bitcoin_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18789         LDKChannelAnnouncement this_ptr_conv;
18790         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18791         this_ptr_conv.is_owned = false;
18792         LDKSignature val_ref;
18793         CHECK((*env)->GetArrayLength(env, val) == 64);
18794         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
18795         ChannelAnnouncement_set_bitcoin_signature_2(&this_ptr_conv, val_ref);
18796 }
18797
18798 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
18799         LDKChannelAnnouncement this_ptr_conv;
18800         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18801         this_ptr_conv.is_owned = false;
18802         LDKUnsignedChannelAnnouncement ret_var = ChannelAnnouncement_get_contents(&this_ptr_conv);
18803         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18804         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18805         uint64_t ret_ref = (uint64_t)ret_var.inner;
18806         if (ret_var.is_owned) {
18807                 ret_ref |= 1;
18808         }
18809         return ret_ref;
18810 }
18811
18812 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18813         LDKChannelAnnouncement this_ptr_conv;
18814         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18815         this_ptr_conv.is_owned = false;
18816         LDKUnsignedChannelAnnouncement val_conv;
18817         val_conv.inner = (void*)(val & (~1));
18818         val_conv.is_owned = (val & 1) || (val == 0);
18819         val_conv = UnsignedChannelAnnouncement_clone(&val_conv);
18820         ChannelAnnouncement_set_contents(&this_ptr_conv, val_conv);
18821 }
18822
18823 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) {
18824         LDKSignature node_signature_1_arg_ref;
18825         CHECK((*env)->GetArrayLength(env, node_signature_1_arg) == 64);
18826         (*env)->GetByteArrayRegion(env, node_signature_1_arg, 0, 64, node_signature_1_arg_ref.compact_form);
18827         LDKSignature node_signature_2_arg_ref;
18828         CHECK((*env)->GetArrayLength(env, node_signature_2_arg) == 64);
18829         (*env)->GetByteArrayRegion(env, node_signature_2_arg, 0, 64, node_signature_2_arg_ref.compact_form);
18830         LDKSignature bitcoin_signature_1_arg_ref;
18831         CHECK((*env)->GetArrayLength(env, bitcoin_signature_1_arg) == 64);
18832         (*env)->GetByteArrayRegion(env, bitcoin_signature_1_arg, 0, 64, bitcoin_signature_1_arg_ref.compact_form);
18833         LDKSignature bitcoin_signature_2_arg_ref;
18834         CHECK((*env)->GetArrayLength(env, bitcoin_signature_2_arg) == 64);
18835         (*env)->GetByteArrayRegion(env, bitcoin_signature_2_arg, 0, 64, bitcoin_signature_2_arg_ref.compact_form);
18836         LDKUnsignedChannelAnnouncement contents_arg_conv;
18837         contents_arg_conv.inner = (void*)(contents_arg & (~1));
18838         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
18839         contents_arg_conv = UnsignedChannelAnnouncement_clone(&contents_arg_conv);
18840         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);
18841         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18842         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18843         uint64_t ret_ref = (uint64_t)ret_var.inner;
18844         if (ret_var.is_owned) {
18845                 ret_ref |= 1;
18846         }
18847         return ret_ref;
18848 }
18849
18850 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18851         LDKChannelAnnouncement orig_conv;
18852         orig_conv.inner = (void*)(orig & (~1));
18853         orig_conv.is_owned = false;
18854         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(&orig_conv);
18855         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18856         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18857         uint64_t ret_ref = (uint64_t)ret_var.inner;
18858         if (ret_var.is_owned) {
18859                 ret_ref |= 1;
18860         }
18861         return ret_ref;
18862 }
18863
18864 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18865         LDKUnsignedChannelUpdate this_obj_conv;
18866         this_obj_conv.inner = (void*)(this_obj & (~1));
18867         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18868         UnsignedChannelUpdate_free(this_obj_conv);
18869 }
18870
18871 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
18872         LDKUnsignedChannelUpdate this_ptr_conv;
18873         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18874         this_ptr_conv.is_owned = false;
18875         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18876         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedChannelUpdate_get_chain_hash(&this_ptr_conv));
18877         return ret_arr;
18878 }
18879
18880 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18881         LDKUnsignedChannelUpdate this_ptr_conv;
18882         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18883         this_ptr_conv.is_owned = false;
18884         LDKThirtyTwoBytes val_ref;
18885         CHECK((*env)->GetArrayLength(env, val) == 32);
18886         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18887         UnsignedChannelUpdate_set_chain_hash(&this_ptr_conv, val_ref);
18888 }
18889
18890 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18891         LDKUnsignedChannelUpdate this_ptr_conv;
18892         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18893         this_ptr_conv.is_owned = false;
18894         int64_t ret_val = UnsignedChannelUpdate_get_short_channel_id(&this_ptr_conv);
18895         return ret_val;
18896 }
18897
18898 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18899         LDKUnsignedChannelUpdate this_ptr_conv;
18900         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18901         this_ptr_conv.is_owned = false;
18902         UnsignedChannelUpdate_set_short_channel_id(&this_ptr_conv, val);
18903 }
18904
18905 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
18906         LDKUnsignedChannelUpdate this_ptr_conv;
18907         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18908         this_ptr_conv.is_owned = false;
18909         int32_t ret_val = UnsignedChannelUpdate_get_timestamp(&this_ptr_conv);
18910         return ret_val;
18911 }
18912
18913 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
18914         LDKUnsignedChannelUpdate this_ptr_conv;
18915         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18916         this_ptr_conv.is_owned = false;
18917         UnsignedChannelUpdate_set_timestamp(&this_ptr_conv, val);
18918 }
18919
18920 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1flags(JNIEnv *env, jclass clz, int64_t this_ptr) {
18921         LDKUnsignedChannelUpdate this_ptr_conv;
18922         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18923         this_ptr_conv.is_owned = false;
18924         int8_t ret_val = UnsignedChannelUpdate_get_flags(&this_ptr_conv);
18925         return ret_val;
18926 }
18927
18928 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1flags(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
18929         LDKUnsignedChannelUpdate this_ptr_conv;
18930         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18931         this_ptr_conv.is_owned = false;
18932         UnsignedChannelUpdate_set_flags(&this_ptr_conv, val);
18933 }
18934
18935 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
18936         LDKUnsignedChannelUpdate this_ptr_conv;
18937         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18938         this_ptr_conv.is_owned = false;
18939         int16_t ret_val = UnsignedChannelUpdate_get_cltv_expiry_delta(&this_ptr_conv);
18940         return ret_val;
18941 }
18942
18943 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
18944         LDKUnsignedChannelUpdate this_ptr_conv;
18945         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18946         this_ptr_conv.is_owned = false;
18947         UnsignedChannelUpdate_set_cltv_expiry_delta(&this_ptr_conv, val);
18948 }
18949
18950 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
18951         LDKUnsignedChannelUpdate this_ptr_conv;
18952         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18953         this_ptr_conv.is_owned = false;
18954         int64_t ret_val = UnsignedChannelUpdate_get_htlc_minimum_msat(&this_ptr_conv);
18955         return ret_val;
18956 }
18957
18958 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18959         LDKUnsignedChannelUpdate this_ptr_conv;
18960         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18961         this_ptr_conv.is_owned = false;
18962         UnsignedChannelUpdate_set_htlc_minimum_msat(&this_ptr_conv, val);
18963 }
18964
18965 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
18966         LDKUnsignedChannelUpdate this_ptr_conv;
18967         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18968         this_ptr_conv.is_owned = false;
18969         int32_t ret_val = UnsignedChannelUpdate_get_fee_base_msat(&this_ptr_conv);
18970         return ret_val;
18971 }
18972
18973 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
18974         LDKUnsignedChannelUpdate this_ptr_conv;
18975         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18976         this_ptr_conv.is_owned = false;
18977         UnsignedChannelUpdate_set_fee_base_msat(&this_ptr_conv, val);
18978 }
18979
18980 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
18981         LDKUnsignedChannelUpdate this_ptr_conv;
18982         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18983         this_ptr_conv.is_owned = false;
18984         int32_t ret_val = UnsignedChannelUpdate_get_fee_proportional_millionths(&this_ptr_conv);
18985         return ret_val;
18986 }
18987
18988 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
18989         LDKUnsignedChannelUpdate this_ptr_conv;
18990         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18991         this_ptr_conv.is_owned = false;
18992         UnsignedChannelUpdate_set_fee_proportional_millionths(&this_ptr_conv, val);
18993 }
18994
18995 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18996         LDKUnsignedChannelUpdate orig_conv;
18997         orig_conv.inner = (void*)(orig & (~1));
18998         orig_conv.is_owned = false;
18999         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(&orig_conv);
19000         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19001         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19002         uint64_t ret_ref = (uint64_t)ret_var.inner;
19003         if (ret_var.is_owned) {
19004                 ret_ref |= 1;
19005         }
19006         return ret_ref;
19007 }
19008
19009 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19010         LDKChannelUpdate this_obj_conv;
19011         this_obj_conv.inner = (void*)(this_obj & (~1));
19012         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19013         ChannelUpdate_free(this_obj_conv);
19014 }
19015
19016 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
19017         LDKChannelUpdate this_ptr_conv;
19018         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19019         this_ptr_conv.is_owned = false;
19020         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
19021         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelUpdate_get_signature(&this_ptr_conv).compact_form);
19022         return ret_arr;
19023 }
19024
19025 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19026         LDKChannelUpdate this_ptr_conv;
19027         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19028         this_ptr_conv.is_owned = false;
19029         LDKSignature val_ref;
19030         CHECK((*env)->GetArrayLength(env, val) == 64);
19031         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
19032         ChannelUpdate_set_signature(&this_ptr_conv, val_ref);
19033 }
19034
19035 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
19036         LDKChannelUpdate this_ptr_conv;
19037         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19038         this_ptr_conv.is_owned = false;
19039         LDKUnsignedChannelUpdate ret_var = ChannelUpdate_get_contents(&this_ptr_conv);
19040         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19041         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19042         uint64_t ret_ref = (uint64_t)ret_var.inner;
19043         if (ret_var.is_owned) {
19044                 ret_ref |= 1;
19045         }
19046         return ret_ref;
19047 }
19048
19049 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19050         LDKChannelUpdate this_ptr_conv;
19051         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19052         this_ptr_conv.is_owned = false;
19053         LDKUnsignedChannelUpdate val_conv;
19054         val_conv.inner = (void*)(val & (~1));
19055         val_conv.is_owned = (val & 1) || (val == 0);
19056         val_conv = UnsignedChannelUpdate_clone(&val_conv);
19057         ChannelUpdate_set_contents(&this_ptr_conv, val_conv);
19058 }
19059
19060 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1new(JNIEnv *env, jclass clz, int8_tArray signature_arg, int64_t contents_arg) {
19061         LDKSignature signature_arg_ref;
19062         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
19063         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
19064         LDKUnsignedChannelUpdate contents_arg_conv;
19065         contents_arg_conv.inner = (void*)(contents_arg & (~1));
19066         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
19067         contents_arg_conv = UnsignedChannelUpdate_clone(&contents_arg_conv);
19068         LDKChannelUpdate ret_var = ChannelUpdate_new(signature_arg_ref, contents_arg_conv);
19069         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19070         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19071         uint64_t ret_ref = (uint64_t)ret_var.inner;
19072         if (ret_var.is_owned) {
19073                 ret_ref |= 1;
19074         }
19075         return ret_ref;
19076 }
19077
19078 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19079         LDKChannelUpdate orig_conv;
19080         orig_conv.inner = (void*)(orig & (~1));
19081         orig_conv.is_owned = false;
19082         LDKChannelUpdate ret_var = ChannelUpdate_clone(&orig_conv);
19083         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19084         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19085         uint64_t ret_ref = (uint64_t)ret_var.inner;
19086         if (ret_var.is_owned) {
19087                 ret_ref |= 1;
19088         }
19089         return ret_ref;
19090 }
19091
19092 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19093         LDKQueryChannelRange this_obj_conv;
19094         this_obj_conv.inner = (void*)(this_obj & (~1));
19095         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19096         QueryChannelRange_free(this_obj_conv);
19097 }
19098
19099 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
19100         LDKQueryChannelRange this_ptr_conv;
19101         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19102         this_ptr_conv.is_owned = false;
19103         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
19104         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *QueryChannelRange_get_chain_hash(&this_ptr_conv));
19105         return ret_arr;
19106 }
19107
19108 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19109         LDKQueryChannelRange this_ptr_conv;
19110         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19111         this_ptr_conv.is_owned = false;
19112         LDKThirtyTwoBytes val_ref;
19113         CHECK((*env)->GetArrayLength(env, val) == 32);
19114         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
19115         QueryChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
19116 }
19117
19118 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr) {
19119         LDKQueryChannelRange this_ptr_conv;
19120         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19121         this_ptr_conv.is_owned = false;
19122         int32_t ret_val = QueryChannelRange_get_first_blocknum(&this_ptr_conv);
19123         return ret_val;
19124 }
19125
19126 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
19127         LDKQueryChannelRange this_ptr_conv;
19128         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19129         this_ptr_conv.is_owned = false;
19130         QueryChannelRange_set_first_blocknum(&this_ptr_conv, val);
19131 }
19132
19133 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr) {
19134         LDKQueryChannelRange this_ptr_conv;
19135         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19136         this_ptr_conv.is_owned = false;
19137         int32_t ret_val = QueryChannelRange_get_number_of_blocks(&this_ptr_conv);
19138         return ret_val;
19139 }
19140
19141 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
19142         LDKQueryChannelRange this_ptr_conv;
19143         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19144         this_ptr_conv.is_owned = false;
19145         QueryChannelRange_set_number_of_blocks(&this_ptr_conv, val);
19146 }
19147
19148 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) {
19149         LDKThirtyTwoBytes chain_hash_arg_ref;
19150         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
19151         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
19152         LDKQueryChannelRange ret_var = QueryChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg);
19153         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19154         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19155         uint64_t ret_ref = (uint64_t)ret_var.inner;
19156         if (ret_var.is_owned) {
19157                 ret_ref |= 1;
19158         }
19159         return ret_ref;
19160 }
19161
19162 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19163         LDKQueryChannelRange orig_conv;
19164         orig_conv.inner = (void*)(orig & (~1));
19165         orig_conv.is_owned = false;
19166         LDKQueryChannelRange ret_var = QueryChannelRange_clone(&orig_conv);
19167         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19168         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19169         uint64_t ret_ref = (uint64_t)ret_var.inner;
19170         if (ret_var.is_owned) {
19171                 ret_ref |= 1;
19172         }
19173         return ret_ref;
19174 }
19175
19176 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19177         LDKReplyChannelRange this_obj_conv;
19178         this_obj_conv.inner = (void*)(this_obj & (~1));
19179         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19180         ReplyChannelRange_free(this_obj_conv);
19181 }
19182
19183 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
19184         LDKReplyChannelRange this_ptr_conv;
19185         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19186         this_ptr_conv.is_owned = false;
19187         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
19188         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ReplyChannelRange_get_chain_hash(&this_ptr_conv));
19189         return ret_arr;
19190 }
19191
19192 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19193         LDKReplyChannelRange this_ptr_conv;
19194         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19195         this_ptr_conv.is_owned = false;
19196         LDKThirtyTwoBytes val_ref;
19197         CHECK((*env)->GetArrayLength(env, val) == 32);
19198         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
19199         ReplyChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
19200 }
19201
19202 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr) {
19203         LDKReplyChannelRange this_ptr_conv;
19204         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19205         this_ptr_conv.is_owned = false;
19206         int32_t ret_val = ReplyChannelRange_get_first_blocknum(&this_ptr_conv);
19207         return ret_val;
19208 }
19209
19210 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
19211         LDKReplyChannelRange this_ptr_conv;
19212         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19213         this_ptr_conv.is_owned = false;
19214         ReplyChannelRange_set_first_blocknum(&this_ptr_conv, val);
19215 }
19216
19217 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr) {
19218         LDKReplyChannelRange this_ptr_conv;
19219         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19220         this_ptr_conv.is_owned = false;
19221         int32_t ret_val = ReplyChannelRange_get_number_of_blocks(&this_ptr_conv);
19222         return ret_val;
19223 }
19224
19225 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
19226         LDKReplyChannelRange this_ptr_conv;
19227         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19228         this_ptr_conv.is_owned = false;
19229         ReplyChannelRange_set_number_of_blocks(&this_ptr_conv, val);
19230 }
19231
19232 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1sync_1complete(JNIEnv *env, jclass clz, int64_t this_ptr) {
19233         LDKReplyChannelRange this_ptr_conv;
19234         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19235         this_ptr_conv.is_owned = false;
19236         jboolean ret_val = ReplyChannelRange_get_sync_complete(&this_ptr_conv);
19237         return ret_val;
19238 }
19239
19240 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1sync_1complete(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
19241         LDKReplyChannelRange this_ptr_conv;
19242         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19243         this_ptr_conv.is_owned = false;
19244         ReplyChannelRange_set_sync_complete(&this_ptr_conv, val);
19245 }
19246
19247 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
19248         LDKReplyChannelRange this_ptr_conv;
19249         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19250         this_ptr_conv.is_owned = false;
19251         LDKCVec_u64Z val_constr;
19252         val_constr.datalen = (*env)->GetArrayLength(env, val);
19253         if (val_constr.datalen > 0)
19254                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
19255         else
19256                 val_constr.data = NULL;
19257         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
19258         for (size_t g = 0; g < val_constr.datalen; g++) {
19259                 int64_t val_conv_6 = val_vals[g];
19260                 val_constr.data[g] = val_conv_6;
19261         }
19262         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
19263         ReplyChannelRange_set_short_channel_ids(&this_ptr_conv, val_constr);
19264 }
19265
19266 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) {
19267         LDKThirtyTwoBytes chain_hash_arg_ref;
19268         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
19269         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
19270         LDKCVec_u64Z short_channel_ids_arg_constr;
19271         short_channel_ids_arg_constr.datalen = (*env)->GetArrayLength(env, short_channel_ids_arg);
19272         if (short_channel_ids_arg_constr.datalen > 0)
19273                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
19274         else
19275                 short_channel_ids_arg_constr.data = NULL;
19276         int64_t* short_channel_ids_arg_vals = (*env)->GetLongArrayElements (env, short_channel_ids_arg, NULL);
19277         for (size_t g = 0; g < short_channel_ids_arg_constr.datalen; g++) {
19278                 int64_t short_channel_ids_arg_conv_6 = short_channel_ids_arg_vals[g];
19279                 short_channel_ids_arg_constr.data[g] = short_channel_ids_arg_conv_6;
19280         }
19281         (*env)->ReleaseLongArrayElements(env, short_channel_ids_arg, short_channel_ids_arg_vals, 0);
19282         LDKReplyChannelRange ret_var = ReplyChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg, sync_complete_arg, short_channel_ids_arg_constr);
19283         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19284         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19285         uint64_t ret_ref = (uint64_t)ret_var.inner;
19286         if (ret_var.is_owned) {
19287                 ret_ref |= 1;
19288         }
19289         return ret_ref;
19290 }
19291
19292 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19293         LDKReplyChannelRange orig_conv;
19294         orig_conv.inner = (void*)(orig & (~1));
19295         orig_conv.is_owned = false;
19296         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(&orig_conv);
19297         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19298         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19299         uint64_t ret_ref = (uint64_t)ret_var.inner;
19300         if (ret_var.is_owned) {
19301                 ret_ref |= 1;
19302         }
19303         return ret_ref;
19304 }
19305
19306 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19307         LDKQueryShortChannelIds this_obj_conv;
19308         this_obj_conv.inner = (void*)(this_obj & (~1));
19309         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19310         QueryShortChannelIds_free(this_obj_conv);
19311 }
19312
19313 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
19314         LDKQueryShortChannelIds this_ptr_conv;
19315         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19316         this_ptr_conv.is_owned = false;
19317         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
19318         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *QueryShortChannelIds_get_chain_hash(&this_ptr_conv));
19319         return ret_arr;
19320 }
19321
19322 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19323         LDKQueryShortChannelIds this_ptr_conv;
19324         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19325         this_ptr_conv.is_owned = false;
19326         LDKThirtyTwoBytes val_ref;
19327         CHECK((*env)->GetArrayLength(env, val) == 32);
19328         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
19329         QueryShortChannelIds_set_chain_hash(&this_ptr_conv, val_ref);
19330 }
19331
19332 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1set_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
19333         LDKQueryShortChannelIds this_ptr_conv;
19334         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19335         this_ptr_conv.is_owned = false;
19336         LDKCVec_u64Z val_constr;
19337         val_constr.datalen = (*env)->GetArrayLength(env, val);
19338         if (val_constr.datalen > 0)
19339                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
19340         else
19341                 val_constr.data = NULL;
19342         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
19343         for (size_t g = 0; g < val_constr.datalen; g++) {
19344                 int64_t val_conv_6 = val_vals[g];
19345                 val_constr.data[g] = val_conv_6;
19346         }
19347         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
19348         QueryShortChannelIds_set_short_channel_ids(&this_ptr_conv, val_constr);
19349 }
19350
19351 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) {
19352         LDKThirtyTwoBytes chain_hash_arg_ref;
19353         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
19354         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
19355         LDKCVec_u64Z short_channel_ids_arg_constr;
19356         short_channel_ids_arg_constr.datalen = (*env)->GetArrayLength(env, short_channel_ids_arg);
19357         if (short_channel_ids_arg_constr.datalen > 0)
19358                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
19359         else
19360                 short_channel_ids_arg_constr.data = NULL;
19361         int64_t* short_channel_ids_arg_vals = (*env)->GetLongArrayElements (env, short_channel_ids_arg, NULL);
19362         for (size_t g = 0; g < short_channel_ids_arg_constr.datalen; g++) {
19363                 int64_t short_channel_ids_arg_conv_6 = short_channel_ids_arg_vals[g];
19364                 short_channel_ids_arg_constr.data[g] = short_channel_ids_arg_conv_6;
19365         }
19366         (*env)->ReleaseLongArrayElements(env, short_channel_ids_arg, short_channel_ids_arg_vals, 0);
19367         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_new(chain_hash_arg_ref, short_channel_ids_arg_constr);
19368         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19369         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19370         uint64_t ret_ref = (uint64_t)ret_var.inner;
19371         if (ret_var.is_owned) {
19372                 ret_ref |= 1;
19373         }
19374         return ret_ref;
19375 }
19376
19377 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19378         LDKQueryShortChannelIds orig_conv;
19379         orig_conv.inner = (void*)(orig & (~1));
19380         orig_conv.is_owned = false;
19381         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(&orig_conv);
19382         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19383         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19384         uint64_t ret_ref = (uint64_t)ret_var.inner;
19385         if (ret_var.is_owned) {
19386                 ret_ref |= 1;
19387         }
19388         return ret_ref;
19389 }
19390
19391 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19392         LDKReplyShortChannelIdsEnd this_obj_conv;
19393         this_obj_conv.inner = (void*)(this_obj & (~1));
19394         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19395         ReplyShortChannelIdsEnd_free(this_obj_conv);
19396 }
19397
19398 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
19399         LDKReplyShortChannelIdsEnd this_ptr_conv;
19400         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19401         this_ptr_conv.is_owned = false;
19402         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
19403         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ReplyShortChannelIdsEnd_get_chain_hash(&this_ptr_conv));
19404         return ret_arr;
19405 }
19406
19407 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19408         LDKReplyShortChannelIdsEnd this_ptr_conv;
19409         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19410         this_ptr_conv.is_owned = false;
19411         LDKThirtyTwoBytes val_ref;
19412         CHECK((*env)->GetArrayLength(env, val) == 32);
19413         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
19414         ReplyShortChannelIdsEnd_set_chain_hash(&this_ptr_conv, val_ref);
19415 }
19416
19417 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1get_1full_1information(JNIEnv *env, jclass clz, int64_t this_ptr) {
19418         LDKReplyShortChannelIdsEnd this_ptr_conv;
19419         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19420         this_ptr_conv.is_owned = false;
19421         jboolean ret_val = ReplyShortChannelIdsEnd_get_full_information(&this_ptr_conv);
19422         return ret_val;
19423 }
19424
19425 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1set_1full_1information(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
19426         LDKReplyShortChannelIdsEnd this_ptr_conv;
19427         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19428         this_ptr_conv.is_owned = false;
19429         ReplyShortChannelIdsEnd_set_full_information(&this_ptr_conv, val);
19430 }
19431
19432 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1new(JNIEnv *env, jclass clz, int8_tArray chain_hash_arg, jboolean full_information_arg) {
19433         LDKThirtyTwoBytes chain_hash_arg_ref;
19434         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
19435         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
19436         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_new(chain_hash_arg_ref, full_information_arg);
19437         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19438         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19439         uint64_t ret_ref = (uint64_t)ret_var.inner;
19440         if (ret_var.is_owned) {
19441                 ret_ref |= 1;
19442         }
19443         return ret_ref;
19444 }
19445
19446 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19447         LDKReplyShortChannelIdsEnd orig_conv;
19448         orig_conv.inner = (void*)(orig & (~1));
19449         orig_conv.is_owned = false;
19450         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(&orig_conv);
19451         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19452         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19453         uint64_t ret_ref = (uint64_t)ret_var.inner;
19454         if (ret_var.is_owned) {
19455                 ret_ref |= 1;
19456         }
19457         return ret_ref;
19458 }
19459
19460 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19461         LDKGossipTimestampFilter this_obj_conv;
19462         this_obj_conv.inner = (void*)(this_obj & (~1));
19463         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19464         GossipTimestampFilter_free(this_obj_conv);
19465 }
19466
19467 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
19468         LDKGossipTimestampFilter this_ptr_conv;
19469         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19470         this_ptr_conv.is_owned = false;
19471         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
19472         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *GossipTimestampFilter_get_chain_hash(&this_ptr_conv));
19473         return ret_arr;
19474 }
19475
19476 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19477         LDKGossipTimestampFilter this_ptr_conv;
19478         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19479         this_ptr_conv.is_owned = false;
19480         LDKThirtyTwoBytes val_ref;
19481         CHECK((*env)->GetArrayLength(env, val) == 32);
19482         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
19483         GossipTimestampFilter_set_chain_hash(&this_ptr_conv, val_ref);
19484 }
19485
19486 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1first_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
19487         LDKGossipTimestampFilter this_ptr_conv;
19488         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19489         this_ptr_conv.is_owned = false;
19490         int32_t ret_val = GossipTimestampFilter_get_first_timestamp(&this_ptr_conv);
19491         return ret_val;
19492 }
19493
19494 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1first_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
19495         LDKGossipTimestampFilter this_ptr_conv;
19496         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19497         this_ptr_conv.is_owned = false;
19498         GossipTimestampFilter_set_first_timestamp(&this_ptr_conv, val);
19499 }
19500
19501 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1timestamp_1range(JNIEnv *env, jclass clz, int64_t this_ptr) {
19502         LDKGossipTimestampFilter this_ptr_conv;
19503         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19504         this_ptr_conv.is_owned = false;
19505         int32_t ret_val = GossipTimestampFilter_get_timestamp_range(&this_ptr_conv);
19506         return ret_val;
19507 }
19508
19509 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1timestamp_1range(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
19510         LDKGossipTimestampFilter this_ptr_conv;
19511         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19512         this_ptr_conv.is_owned = false;
19513         GossipTimestampFilter_set_timestamp_range(&this_ptr_conv, val);
19514 }
19515
19516 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) {
19517         LDKThirtyTwoBytes chain_hash_arg_ref;
19518         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
19519         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
19520         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_new(chain_hash_arg_ref, first_timestamp_arg, timestamp_range_arg);
19521         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19522         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19523         uint64_t ret_ref = (uint64_t)ret_var.inner;
19524         if (ret_var.is_owned) {
19525                 ret_ref |= 1;
19526         }
19527         return ret_ref;
19528 }
19529
19530 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19531         LDKGossipTimestampFilter orig_conv;
19532         orig_conv.inner = (void*)(orig & (~1));
19533         orig_conv.is_owned = false;
19534         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(&orig_conv);
19535         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19536         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19537         uint64_t ret_ref = (uint64_t)ret_var.inner;
19538         if (ret_var.is_owned) {
19539                 ret_ref |= 1;
19540         }
19541         return ret_ref;
19542 }
19543
19544 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorAction_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
19545         if ((this_ptr & 1) != 0) return;
19546         LDKErrorAction this_ptr_conv = *(LDKErrorAction*)(((uint64_t)this_ptr) & ~1);
19547         FREE((void*)this_ptr);
19548         ErrorAction_free(this_ptr_conv);
19549 }
19550
19551 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19552         LDKErrorAction* orig_conv = (LDKErrorAction*)orig;
19553         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
19554         *ret_copy = ErrorAction_clone(orig_conv);
19555         uint64_t ret_ref = (uint64_t)ret_copy;
19556         return ret_ref;
19557 }
19558
19559 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19560         LDKLightningError this_obj_conv;
19561         this_obj_conv.inner = (void*)(this_obj & (~1));
19562         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19563         LightningError_free(this_obj_conv);
19564 }
19565
19566 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_LightningError_1get_1err(JNIEnv *env, jclass clz, int64_t this_ptr) {
19567         LDKLightningError this_ptr_conv;
19568         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19569         this_ptr_conv.is_owned = false;
19570         LDKStr ret_str = LightningError_get_err(&this_ptr_conv);
19571         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
19572         return ret_conv;
19573 }
19574
19575 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1set_1err(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
19576         LDKLightningError this_ptr_conv;
19577         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19578         this_ptr_conv.is_owned = false;
19579         LDKStr val_conv = java_to_owned_str(env, val);
19580         LightningError_set_err(&this_ptr_conv, val_conv);
19581 }
19582
19583 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1get_1action(JNIEnv *env, jclass clz, int64_t this_ptr) {
19584         LDKLightningError this_ptr_conv;
19585         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19586         this_ptr_conv.is_owned = false;
19587         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
19588         *ret_copy = LightningError_get_action(&this_ptr_conv);
19589         uint64_t ret_ref = (uint64_t)ret_copy;
19590         return ret_ref;
19591 }
19592
19593 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1set_1action(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19594         LDKLightningError this_ptr_conv;
19595         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19596         this_ptr_conv.is_owned = false;
19597         LDKErrorAction val_conv = *(LDKErrorAction*)(((uint64_t)val) & ~1);
19598         LightningError_set_action(&this_ptr_conv, val_conv);
19599 }
19600
19601 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1new(JNIEnv *env, jclass clz, jstring err_arg, int64_t action_arg) {
19602         LDKStr err_arg_conv = java_to_owned_str(env, err_arg);
19603         LDKErrorAction action_arg_conv = *(LDKErrorAction*)(((uint64_t)action_arg) & ~1);
19604         LDKLightningError ret_var = LightningError_new(err_arg_conv, action_arg_conv);
19605         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19606         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19607         uint64_t ret_ref = (uint64_t)ret_var.inner;
19608         if (ret_var.is_owned) {
19609                 ret_ref |= 1;
19610         }
19611         return ret_ref;
19612 }
19613
19614 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19615         LDKLightningError orig_conv;
19616         orig_conv.inner = (void*)(orig & (~1));
19617         orig_conv.is_owned = false;
19618         LDKLightningError ret_var = LightningError_clone(&orig_conv);
19619         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19620         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19621         uint64_t ret_ref = (uint64_t)ret_var.inner;
19622         if (ret_var.is_owned) {
19623                 ret_ref |= 1;
19624         }
19625         return ret_ref;
19626 }
19627
19628 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19629         LDKCommitmentUpdate this_obj_conv;
19630         this_obj_conv.inner = (void*)(this_obj & (~1));
19631         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19632         CommitmentUpdate_free(this_obj_conv);
19633 }
19634
19635 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1add_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
19636         LDKCommitmentUpdate this_ptr_conv;
19637         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19638         this_ptr_conv.is_owned = false;
19639         LDKCVec_UpdateAddHTLCZ val_constr;
19640         val_constr.datalen = (*env)->GetArrayLength(env, val);
19641         if (val_constr.datalen > 0)
19642                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
19643         else
19644                 val_constr.data = NULL;
19645         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
19646         for (size_t p = 0; p < val_constr.datalen; p++) {
19647                 int64_t val_conv_15 = val_vals[p];
19648                 LDKUpdateAddHTLC val_conv_15_conv;
19649                 val_conv_15_conv.inner = (void*)(val_conv_15 & (~1));
19650                 val_conv_15_conv.is_owned = (val_conv_15 & 1) || (val_conv_15 == 0);
19651                 val_conv_15_conv = UpdateAddHTLC_clone(&val_conv_15_conv);
19652                 val_constr.data[p] = val_conv_15_conv;
19653         }
19654         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
19655         CommitmentUpdate_set_update_add_htlcs(&this_ptr_conv, val_constr);
19656 }
19657
19658 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fulfill_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
19659         LDKCommitmentUpdate this_ptr_conv;
19660         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19661         this_ptr_conv.is_owned = false;
19662         LDKCVec_UpdateFulfillHTLCZ val_constr;
19663         val_constr.datalen = (*env)->GetArrayLength(env, val);
19664         if (val_constr.datalen > 0)
19665                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
19666         else
19667                 val_constr.data = NULL;
19668         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
19669         for (size_t t = 0; t < val_constr.datalen; t++) {
19670                 int64_t val_conv_19 = val_vals[t];
19671                 LDKUpdateFulfillHTLC val_conv_19_conv;
19672                 val_conv_19_conv.inner = (void*)(val_conv_19 & (~1));
19673                 val_conv_19_conv.is_owned = (val_conv_19 & 1) || (val_conv_19 == 0);
19674                 val_conv_19_conv = UpdateFulfillHTLC_clone(&val_conv_19_conv);
19675                 val_constr.data[t] = val_conv_19_conv;
19676         }
19677         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
19678         CommitmentUpdate_set_update_fulfill_htlcs(&this_ptr_conv, val_constr);
19679 }
19680
19681 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fail_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
19682         LDKCommitmentUpdate this_ptr_conv;
19683         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19684         this_ptr_conv.is_owned = false;
19685         LDKCVec_UpdateFailHTLCZ val_constr;
19686         val_constr.datalen = (*env)->GetArrayLength(env, val);
19687         if (val_constr.datalen > 0)
19688                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
19689         else
19690                 val_constr.data = NULL;
19691         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
19692         for (size_t q = 0; q < val_constr.datalen; q++) {
19693                 int64_t val_conv_16 = val_vals[q];
19694                 LDKUpdateFailHTLC val_conv_16_conv;
19695                 val_conv_16_conv.inner = (void*)(val_conv_16 & (~1));
19696                 val_conv_16_conv.is_owned = (val_conv_16 & 1) || (val_conv_16 == 0);
19697                 val_conv_16_conv = UpdateFailHTLC_clone(&val_conv_16_conv);
19698                 val_constr.data[q] = val_conv_16_conv;
19699         }
19700         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
19701         CommitmentUpdate_set_update_fail_htlcs(&this_ptr_conv, val_constr);
19702 }
19703
19704 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) {
19705         LDKCommitmentUpdate this_ptr_conv;
19706         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19707         this_ptr_conv.is_owned = false;
19708         LDKCVec_UpdateFailMalformedHTLCZ val_constr;
19709         val_constr.datalen = (*env)->GetArrayLength(env, val);
19710         if (val_constr.datalen > 0)
19711                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
19712         else
19713                 val_constr.data = NULL;
19714         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
19715         for (size_t z = 0; z < val_constr.datalen; z++) {
19716                 int64_t val_conv_25 = val_vals[z];
19717                 LDKUpdateFailMalformedHTLC val_conv_25_conv;
19718                 val_conv_25_conv.inner = (void*)(val_conv_25 & (~1));
19719                 val_conv_25_conv.is_owned = (val_conv_25 & 1) || (val_conv_25 == 0);
19720                 val_conv_25_conv = UpdateFailMalformedHTLC_clone(&val_conv_25_conv);
19721                 val_constr.data[z] = val_conv_25_conv;
19722         }
19723         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
19724         CommitmentUpdate_set_update_fail_malformed_htlcs(&this_ptr_conv, val_constr);
19725 }
19726
19727 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fee(JNIEnv *env, jclass clz, int64_t this_ptr) {
19728         LDKCommitmentUpdate this_ptr_conv;
19729         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19730         this_ptr_conv.is_owned = false;
19731         LDKUpdateFee ret_var = CommitmentUpdate_get_update_fee(&this_ptr_conv);
19732         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19733         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19734         uint64_t ret_ref = (uint64_t)ret_var.inner;
19735         if (ret_var.is_owned) {
19736                 ret_ref |= 1;
19737         }
19738         return ret_ref;
19739 }
19740
19741 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fee(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19742         LDKCommitmentUpdate this_ptr_conv;
19743         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19744         this_ptr_conv.is_owned = false;
19745         LDKUpdateFee val_conv;
19746         val_conv.inner = (void*)(val & (~1));
19747         val_conv.is_owned = (val & 1) || (val == 0);
19748         val_conv = UpdateFee_clone(&val_conv);
19749         CommitmentUpdate_set_update_fee(&this_ptr_conv, val_conv);
19750 }
19751
19752 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1commitment_1signed(JNIEnv *env, jclass clz, int64_t this_ptr) {
19753         LDKCommitmentUpdate this_ptr_conv;
19754         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19755         this_ptr_conv.is_owned = false;
19756         LDKCommitmentSigned ret_var = CommitmentUpdate_get_commitment_signed(&this_ptr_conv);
19757         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19758         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19759         uint64_t ret_ref = (uint64_t)ret_var.inner;
19760         if (ret_var.is_owned) {
19761                 ret_ref |= 1;
19762         }
19763         return ret_ref;
19764 }
19765
19766 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1commitment_1signed(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19767         LDKCommitmentUpdate this_ptr_conv;
19768         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19769         this_ptr_conv.is_owned = false;
19770         LDKCommitmentSigned val_conv;
19771         val_conv.inner = (void*)(val & (~1));
19772         val_conv.is_owned = (val & 1) || (val == 0);
19773         val_conv = CommitmentSigned_clone(&val_conv);
19774         CommitmentUpdate_set_commitment_signed(&this_ptr_conv, val_conv);
19775 }
19776
19777 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) {
19778         LDKCVec_UpdateAddHTLCZ update_add_htlcs_arg_constr;
19779         update_add_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_add_htlcs_arg);
19780         if (update_add_htlcs_arg_constr.datalen > 0)
19781                 update_add_htlcs_arg_constr.data = MALLOC(update_add_htlcs_arg_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
19782         else
19783                 update_add_htlcs_arg_constr.data = NULL;
19784         int64_t* update_add_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_add_htlcs_arg, NULL);
19785         for (size_t p = 0; p < update_add_htlcs_arg_constr.datalen; p++) {
19786                 int64_t update_add_htlcs_arg_conv_15 = update_add_htlcs_arg_vals[p];
19787                 LDKUpdateAddHTLC update_add_htlcs_arg_conv_15_conv;
19788                 update_add_htlcs_arg_conv_15_conv.inner = (void*)(update_add_htlcs_arg_conv_15 & (~1));
19789                 update_add_htlcs_arg_conv_15_conv.is_owned = (update_add_htlcs_arg_conv_15 & 1) || (update_add_htlcs_arg_conv_15 == 0);
19790                 update_add_htlcs_arg_conv_15_conv = UpdateAddHTLC_clone(&update_add_htlcs_arg_conv_15_conv);
19791                 update_add_htlcs_arg_constr.data[p] = update_add_htlcs_arg_conv_15_conv;
19792         }
19793         (*env)->ReleaseLongArrayElements(env, update_add_htlcs_arg, update_add_htlcs_arg_vals, 0);
19794         LDKCVec_UpdateFulfillHTLCZ update_fulfill_htlcs_arg_constr;
19795         update_fulfill_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fulfill_htlcs_arg);
19796         if (update_fulfill_htlcs_arg_constr.datalen > 0)
19797                 update_fulfill_htlcs_arg_constr.data = MALLOC(update_fulfill_htlcs_arg_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
19798         else
19799                 update_fulfill_htlcs_arg_constr.data = NULL;
19800         int64_t* update_fulfill_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fulfill_htlcs_arg, NULL);
19801         for (size_t t = 0; t < update_fulfill_htlcs_arg_constr.datalen; t++) {
19802                 int64_t update_fulfill_htlcs_arg_conv_19 = update_fulfill_htlcs_arg_vals[t];
19803                 LDKUpdateFulfillHTLC update_fulfill_htlcs_arg_conv_19_conv;
19804                 update_fulfill_htlcs_arg_conv_19_conv.inner = (void*)(update_fulfill_htlcs_arg_conv_19 & (~1));
19805                 update_fulfill_htlcs_arg_conv_19_conv.is_owned = (update_fulfill_htlcs_arg_conv_19 & 1) || (update_fulfill_htlcs_arg_conv_19 == 0);
19806                 update_fulfill_htlcs_arg_conv_19_conv = UpdateFulfillHTLC_clone(&update_fulfill_htlcs_arg_conv_19_conv);
19807                 update_fulfill_htlcs_arg_constr.data[t] = update_fulfill_htlcs_arg_conv_19_conv;
19808         }
19809         (*env)->ReleaseLongArrayElements(env, update_fulfill_htlcs_arg, update_fulfill_htlcs_arg_vals, 0);
19810         LDKCVec_UpdateFailHTLCZ update_fail_htlcs_arg_constr;
19811         update_fail_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fail_htlcs_arg);
19812         if (update_fail_htlcs_arg_constr.datalen > 0)
19813                 update_fail_htlcs_arg_constr.data = MALLOC(update_fail_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
19814         else
19815                 update_fail_htlcs_arg_constr.data = NULL;
19816         int64_t* update_fail_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fail_htlcs_arg, NULL);
19817         for (size_t q = 0; q < update_fail_htlcs_arg_constr.datalen; q++) {
19818                 int64_t update_fail_htlcs_arg_conv_16 = update_fail_htlcs_arg_vals[q];
19819                 LDKUpdateFailHTLC update_fail_htlcs_arg_conv_16_conv;
19820                 update_fail_htlcs_arg_conv_16_conv.inner = (void*)(update_fail_htlcs_arg_conv_16 & (~1));
19821                 update_fail_htlcs_arg_conv_16_conv.is_owned = (update_fail_htlcs_arg_conv_16 & 1) || (update_fail_htlcs_arg_conv_16 == 0);
19822                 update_fail_htlcs_arg_conv_16_conv = UpdateFailHTLC_clone(&update_fail_htlcs_arg_conv_16_conv);
19823                 update_fail_htlcs_arg_constr.data[q] = update_fail_htlcs_arg_conv_16_conv;
19824         }
19825         (*env)->ReleaseLongArrayElements(env, update_fail_htlcs_arg, update_fail_htlcs_arg_vals, 0);
19826         LDKCVec_UpdateFailMalformedHTLCZ update_fail_malformed_htlcs_arg_constr;
19827         update_fail_malformed_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fail_malformed_htlcs_arg);
19828         if (update_fail_malformed_htlcs_arg_constr.datalen > 0)
19829                 update_fail_malformed_htlcs_arg_constr.data = MALLOC(update_fail_malformed_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
19830         else
19831                 update_fail_malformed_htlcs_arg_constr.data = NULL;
19832         int64_t* update_fail_malformed_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fail_malformed_htlcs_arg, NULL);
19833         for (size_t z = 0; z < update_fail_malformed_htlcs_arg_constr.datalen; z++) {
19834                 int64_t update_fail_malformed_htlcs_arg_conv_25 = update_fail_malformed_htlcs_arg_vals[z];
19835                 LDKUpdateFailMalformedHTLC update_fail_malformed_htlcs_arg_conv_25_conv;
19836                 update_fail_malformed_htlcs_arg_conv_25_conv.inner = (void*)(update_fail_malformed_htlcs_arg_conv_25 & (~1));
19837                 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);
19838                 update_fail_malformed_htlcs_arg_conv_25_conv = UpdateFailMalformedHTLC_clone(&update_fail_malformed_htlcs_arg_conv_25_conv);
19839                 update_fail_malformed_htlcs_arg_constr.data[z] = update_fail_malformed_htlcs_arg_conv_25_conv;
19840         }
19841         (*env)->ReleaseLongArrayElements(env, update_fail_malformed_htlcs_arg, update_fail_malformed_htlcs_arg_vals, 0);
19842         LDKUpdateFee update_fee_arg_conv;
19843         update_fee_arg_conv.inner = (void*)(update_fee_arg & (~1));
19844         update_fee_arg_conv.is_owned = (update_fee_arg & 1) || (update_fee_arg == 0);
19845         update_fee_arg_conv = UpdateFee_clone(&update_fee_arg_conv);
19846         LDKCommitmentSigned commitment_signed_arg_conv;
19847         commitment_signed_arg_conv.inner = (void*)(commitment_signed_arg & (~1));
19848         commitment_signed_arg_conv.is_owned = (commitment_signed_arg & 1) || (commitment_signed_arg == 0);
19849         commitment_signed_arg_conv = CommitmentSigned_clone(&commitment_signed_arg_conv);
19850         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);
19851         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19852         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19853         uint64_t ret_ref = (uint64_t)ret_var.inner;
19854         if (ret_var.is_owned) {
19855                 ret_ref |= 1;
19856         }
19857         return ret_ref;
19858 }
19859
19860 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19861         LDKCommitmentUpdate orig_conv;
19862         orig_conv.inner = (void*)(orig & (~1));
19863         orig_conv.is_owned = false;
19864         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(&orig_conv);
19865         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19866         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19867         uint64_t ret_ref = (uint64_t)ret_var.inner;
19868         if (ret_var.is_owned) {
19869                 ret_ref |= 1;
19870         }
19871         return ret_ref;
19872 }
19873
19874 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCFailChannelUpdate_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
19875         if ((this_ptr & 1) != 0) return;
19876         LDKHTLCFailChannelUpdate this_ptr_conv = *(LDKHTLCFailChannelUpdate*)(((uint64_t)this_ptr) & ~1);
19877         FREE((void*)this_ptr);
19878         HTLCFailChannelUpdate_free(this_ptr_conv);
19879 }
19880
19881 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCFailChannelUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19882         LDKHTLCFailChannelUpdate* orig_conv = (LDKHTLCFailChannelUpdate*)orig;
19883         LDKHTLCFailChannelUpdate *ret_copy = MALLOC(sizeof(LDKHTLCFailChannelUpdate), "LDKHTLCFailChannelUpdate");
19884         *ret_copy = HTLCFailChannelUpdate_clone(orig_conv);
19885         uint64_t ret_ref = (uint64_t)ret_copy;
19886         return ret_ref;
19887 }
19888
19889 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
19890         if ((this_ptr & 1) != 0) return;
19891         LDKChannelMessageHandler this_ptr_conv = *(LDKChannelMessageHandler*)(((uint64_t)this_ptr) & ~1);
19892         FREE((void*)this_ptr);
19893         ChannelMessageHandler_free(this_ptr_conv);
19894 }
19895
19896 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
19897         if ((this_ptr & 1) != 0) return;
19898         LDKRoutingMessageHandler this_ptr_conv = *(LDKRoutingMessageHandler*)(((uint64_t)this_ptr) & ~1);
19899         FREE((void*)this_ptr);
19900         RoutingMessageHandler_free(this_ptr_conv);
19901 }
19902
19903 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1write(JNIEnv *env, jclass clz, int64_t obj) {
19904         LDKAcceptChannel obj_conv;
19905         obj_conv.inner = (void*)(obj & (~1));
19906         obj_conv.is_owned = false;
19907         LDKCVec_u8Z ret_var = AcceptChannel_write(&obj_conv);
19908         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
19909         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
19910         CVec_u8Z_free(ret_var);
19911         return ret_arr;
19912 }
19913
19914 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
19915         LDKu8slice ser_ref;
19916         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
19917         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
19918         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
19919         *ret_conv = AcceptChannel_read(ser_ref);
19920         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
19921         return (uint64_t)ret_conv;
19922 }
19923
19924 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
19925         LDKAnnouncementSignatures obj_conv;
19926         obj_conv.inner = (void*)(obj & (~1));
19927         obj_conv.is_owned = false;
19928         LDKCVec_u8Z ret_var = AnnouncementSignatures_write(&obj_conv);
19929         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
19930         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
19931         CVec_u8Z_free(ret_var);
19932         return ret_arr;
19933 }
19934
19935 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
19936         LDKu8slice ser_ref;
19937         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
19938         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
19939         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
19940         *ret_conv = AnnouncementSignatures_read(ser_ref);
19941         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
19942         return (uint64_t)ret_conv;
19943 }
19944
19945 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1write(JNIEnv *env, jclass clz, int64_t obj) {
19946         LDKChannelReestablish obj_conv;
19947         obj_conv.inner = (void*)(obj & (~1));
19948         obj_conv.is_owned = false;
19949         LDKCVec_u8Z ret_var = ChannelReestablish_write(&obj_conv);
19950         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
19951         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
19952         CVec_u8Z_free(ret_var);
19953         return ret_arr;
19954 }
19955
19956 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
19957         LDKu8slice ser_ref;
19958         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
19959         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
19960         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
19961         *ret_conv = ChannelReestablish_read(ser_ref);
19962         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
19963         return (uint64_t)ret_conv;
19964 }
19965
19966 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
19967         LDKClosingSigned obj_conv;
19968         obj_conv.inner = (void*)(obj & (~1));
19969         obj_conv.is_owned = false;
19970         LDKCVec_u8Z ret_var = ClosingSigned_write(&obj_conv);
19971         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
19972         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
19973         CVec_u8Z_free(ret_var);
19974         return ret_arr;
19975 }
19976
19977 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
19978         LDKu8slice ser_ref;
19979         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
19980         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
19981         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
19982         *ret_conv = ClosingSigned_read(ser_ref);
19983         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
19984         return (uint64_t)ret_conv;
19985 }
19986
19987 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
19988         LDKCommitmentSigned obj_conv;
19989         obj_conv.inner = (void*)(obj & (~1));
19990         obj_conv.is_owned = false;
19991         LDKCVec_u8Z ret_var = CommitmentSigned_write(&obj_conv);
19992         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
19993         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
19994         CVec_u8Z_free(ret_var);
19995         return ret_arr;
19996 }
19997
19998 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
19999         LDKu8slice ser_ref;
20000         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20001         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20002         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
20003         *ret_conv = CommitmentSigned_read(ser_ref);
20004         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20005         return (uint64_t)ret_conv;
20006 }
20007
20008 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1write(JNIEnv *env, jclass clz, int64_t obj) {
20009         LDKFundingCreated obj_conv;
20010         obj_conv.inner = (void*)(obj & (~1));
20011         obj_conv.is_owned = false;
20012         LDKCVec_u8Z ret_var = FundingCreated_write(&obj_conv);
20013         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20014         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20015         CVec_u8Z_free(ret_var);
20016         return ret_arr;
20017 }
20018
20019 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20020         LDKu8slice ser_ref;
20021         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20022         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20023         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
20024         *ret_conv = FundingCreated_read(ser_ref);
20025         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20026         return (uint64_t)ret_conv;
20027 }
20028
20029 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
20030         LDKFundingSigned obj_conv;
20031         obj_conv.inner = (void*)(obj & (~1));
20032         obj_conv.is_owned = false;
20033         LDKCVec_u8Z ret_var = FundingSigned_write(&obj_conv);
20034         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20035         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20036         CVec_u8Z_free(ret_var);
20037         return ret_arr;
20038 }
20039
20040 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20041         LDKu8slice ser_ref;
20042         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20043         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20044         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
20045         *ret_conv = FundingSigned_read(ser_ref);
20046         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20047         return (uint64_t)ret_conv;
20048 }
20049
20050 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingLocked_1write(JNIEnv *env, jclass clz, int64_t obj) {
20051         LDKFundingLocked obj_conv;
20052         obj_conv.inner = (void*)(obj & (~1));
20053         obj_conv.is_owned = false;
20054         LDKCVec_u8Z ret_var = FundingLocked_write(&obj_conv);
20055         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20056         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20057         CVec_u8Z_free(ret_var);
20058         return ret_arr;
20059 }
20060
20061 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingLocked_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20062         LDKu8slice ser_ref;
20063         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20064         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20065         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
20066         *ret_conv = FundingLocked_read(ser_ref);
20067         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20068         return (uint64_t)ret_conv;
20069 }
20070
20071 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Init_1write(JNIEnv *env, jclass clz, int64_t obj) {
20072         LDKInit obj_conv;
20073         obj_conv.inner = (void*)(obj & (~1));
20074         obj_conv.is_owned = false;
20075         LDKCVec_u8Z ret_var = Init_write(&obj_conv);
20076         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20077         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20078         CVec_u8Z_free(ret_var);
20079         return ret_arr;
20080 }
20081
20082 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20083         LDKu8slice ser_ref;
20084         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20085         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20086         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
20087         *ret_conv = Init_read(ser_ref);
20088         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20089         return (uint64_t)ret_conv;
20090 }
20091
20092 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1write(JNIEnv *env, jclass clz, int64_t obj) {
20093         LDKOpenChannel obj_conv;
20094         obj_conv.inner = (void*)(obj & (~1));
20095         obj_conv.is_owned = false;
20096         LDKCVec_u8Z ret_var = OpenChannel_write(&obj_conv);
20097         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20098         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20099         CVec_u8Z_free(ret_var);
20100         return ret_arr;
20101 }
20102
20103 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20104         LDKu8slice ser_ref;
20105         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20106         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20107         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
20108         *ret_conv = OpenChannel_read(ser_ref);
20109         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20110         return (uint64_t)ret_conv;
20111 }
20112
20113 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1write(JNIEnv *env, jclass clz, int64_t obj) {
20114         LDKRevokeAndACK obj_conv;
20115         obj_conv.inner = (void*)(obj & (~1));
20116         obj_conv.is_owned = false;
20117         LDKCVec_u8Z ret_var = RevokeAndACK_write(&obj_conv);
20118         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20119         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20120         CVec_u8Z_free(ret_var);
20121         return ret_arr;
20122 }
20123
20124 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20125         LDKu8slice ser_ref;
20126         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20127         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20128         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
20129         *ret_conv = RevokeAndACK_read(ser_ref);
20130         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20131         return (uint64_t)ret_conv;
20132 }
20133
20134 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1write(JNIEnv *env, jclass clz, int64_t obj) {
20135         LDKShutdown obj_conv;
20136         obj_conv.inner = (void*)(obj & (~1));
20137         obj_conv.is_owned = false;
20138         LDKCVec_u8Z ret_var = Shutdown_write(&obj_conv);
20139         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20140         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20141         CVec_u8Z_free(ret_var);
20142         return ret_arr;
20143 }
20144
20145 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20146         LDKu8slice ser_ref;
20147         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20148         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20149         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
20150         *ret_conv = Shutdown_read(ser_ref);
20151         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20152         return (uint64_t)ret_conv;
20153 }
20154
20155 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
20156         LDKUpdateFailHTLC obj_conv;
20157         obj_conv.inner = (void*)(obj & (~1));
20158         obj_conv.is_owned = false;
20159         LDKCVec_u8Z ret_var = UpdateFailHTLC_write(&obj_conv);
20160         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20161         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20162         CVec_u8Z_free(ret_var);
20163         return ret_arr;
20164 }
20165
20166 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20167         LDKu8slice ser_ref;
20168         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20169         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20170         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
20171         *ret_conv = UpdateFailHTLC_read(ser_ref);
20172         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20173         return (uint64_t)ret_conv;
20174 }
20175
20176 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
20177         LDKUpdateFailMalformedHTLC obj_conv;
20178         obj_conv.inner = (void*)(obj & (~1));
20179         obj_conv.is_owned = false;
20180         LDKCVec_u8Z ret_var = UpdateFailMalformedHTLC_write(&obj_conv);
20181         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20182         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20183         CVec_u8Z_free(ret_var);
20184         return ret_arr;
20185 }
20186
20187 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20188         LDKu8slice ser_ref;
20189         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20190         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20191         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
20192         *ret_conv = UpdateFailMalformedHTLC_read(ser_ref);
20193         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20194         return (uint64_t)ret_conv;
20195 }
20196
20197 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFee_1write(JNIEnv *env, jclass clz, int64_t obj) {
20198         LDKUpdateFee obj_conv;
20199         obj_conv.inner = (void*)(obj & (~1));
20200         obj_conv.is_owned = false;
20201         LDKCVec_u8Z ret_var = UpdateFee_write(&obj_conv);
20202         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20203         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20204         CVec_u8Z_free(ret_var);
20205         return ret_arr;
20206 }
20207
20208 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20209         LDKu8slice ser_ref;
20210         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20211         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20212         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
20213         *ret_conv = UpdateFee_read(ser_ref);
20214         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20215         return (uint64_t)ret_conv;
20216 }
20217
20218 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
20219         LDKUpdateFulfillHTLC obj_conv;
20220         obj_conv.inner = (void*)(obj & (~1));
20221         obj_conv.is_owned = false;
20222         LDKCVec_u8Z ret_var = UpdateFulfillHTLC_write(&obj_conv);
20223         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20224         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20225         CVec_u8Z_free(ret_var);
20226         return ret_arr;
20227 }
20228
20229 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20230         LDKu8slice ser_ref;
20231         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20232         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20233         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
20234         *ret_conv = UpdateFulfillHTLC_read(ser_ref);
20235         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20236         return (uint64_t)ret_conv;
20237 }
20238
20239 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
20240         LDKUpdateAddHTLC obj_conv;
20241         obj_conv.inner = (void*)(obj & (~1));
20242         obj_conv.is_owned = false;
20243         LDKCVec_u8Z ret_var = UpdateAddHTLC_write(&obj_conv);
20244         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20245         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20246         CVec_u8Z_free(ret_var);
20247         return ret_arr;
20248 }
20249
20250 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20251         LDKu8slice ser_ref;
20252         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20253         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20254         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
20255         *ret_conv = UpdateAddHTLC_read(ser_ref);
20256         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20257         return (uint64_t)ret_conv;
20258 }
20259
20260 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Ping_1write(JNIEnv *env, jclass clz, int64_t obj) {
20261         LDKPing obj_conv;
20262         obj_conv.inner = (void*)(obj & (~1));
20263         obj_conv.is_owned = false;
20264         LDKCVec_u8Z ret_var = Ping_write(&obj_conv);
20265         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20266         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20267         CVec_u8Z_free(ret_var);
20268         return ret_arr;
20269 }
20270
20271 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20272         LDKu8slice ser_ref;
20273         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20274         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20275         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
20276         *ret_conv = Ping_read(ser_ref);
20277         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20278         return (uint64_t)ret_conv;
20279 }
20280
20281 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Pong_1write(JNIEnv *env, jclass clz, int64_t obj) {
20282         LDKPong obj_conv;
20283         obj_conv.inner = (void*)(obj & (~1));
20284         obj_conv.is_owned = false;
20285         LDKCVec_u8Z ret_var = Pong_write(&obj_conv);
20286         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20287         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20288         CVec_u8Z_free(ret_var);
20289         return ret_arr;
20290 }
20291
20292 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20293         LDKu8slice ser_ref;
20294         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20295         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20296         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
20297         *ret_conv = Pong_read(ser_ref);
20298         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20299         return (uint64_t)ret_conv;
20300 }
20301
20302 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
20303         LDKUnsignedChannelAnnouncement obj_conv;
20304         obj_conv.inner = (void*)(obj & (~1));
20305         obj_conv.is_owned = false;
20306         LDKCVec_u8Z ret_var = UnsignedChannelAnnouncement_write(&obj_conv);
20307         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20308         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20309         CVec_u8Z_free(ret_var);
20310         return ret_arr;
20311 }
20312
20313 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20314         LDKu8slice ser_ref;
20315         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20316         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20317         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
20318         *ret_conv = UnsignedChannelAnnouncement_read(ser_ref);
20319         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20320         return (uint64_t)ret_conv;
20321 }
20322
20323 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
20324         LDKChannelAnnouncement obj_conv;
20325         obj_conv.inner = (void*)(obj & (~1));
20326         obj_conv.is_owned = false;
20327         LDKCVec_u8Z ret_var = ChannelAnnouncement_write(&obj_conv);
20328         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20329         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20330         CVec_u8Z_free(ret_var);
20331         return ret_arr;
20332 }
20333
20334 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20335         LDKu8slice ser_ref;
20336         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20337         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20338         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
20339         *ret_conv = ChannelAnnouncement_read(ser_ref);
20340         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20341         return (uint64_t)ret_conv;
20342 }
20343
20344 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
20345         LDKUnsignedChannelUpdate obj_conv;
20346         obj_conv.inner = (void*)(obj & (~1));
20347         obj_conv.is_owned = false;
20348         LDKCVec_u8Z ret_var = UnsignedChannelUpdate_write(&obj_conv);
20349         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20350         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20351         CVec_u8Z_free(ret_var);
20352         return ret_arr;
20353 }
20354
20355 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20356         LDKu8slice ser_ref;
20357         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20358         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20359         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
20360         *ret_conv = UnsignedChannelUpdate_read(ser_ref);
20361         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20362         return (uint64_t)ret_conv;
20363 }
20364
20365 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
20366         LDKChannelUpdate obj_conv;
20367         obj_conv.inner = (void*)(obj & (~1));
20368         obj_conv.is_owned = false;
20369         LDKCVec_u8Z ret_var = ChannelUpdate_write(&obj_conv);
20370         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20371         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20372         CVec_u8Z_free(ret_var);
20373         return ret_arr;
20374 }
20375
20376 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20377         LDKu8slice ser_ref;
20378         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20379         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20380         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
20381         *ret_conv = ChannelUpdate_read(ser_ref);
20382         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20383         return (uint64_t)ret_conv;
20384 }
20385
20386 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1write(JNIEnv *env, jclass clz, int64_t obj) {
20387         LDKErrorMessage obj_conv;
20388         obj_conv.inner = (void*)(obj & (~1));
20389         obj_conv.is_owned = false;
20390         LDKCVec_u8Z ret_var = ErrorMessage_write(&obj_conv);
20391         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20392         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20393         CVec_u8Z_free(ret_var);
20394         return ret_arr;
20395 }
20396
20397 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20398         LDKu8slice ser_ref;
20399         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20400         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20401         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
20402         *ret_conv = ErrorMessage_read(ser_ref);
20403         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20404         return (uint64_t)ret_conv;
20405 }
20406
20407 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
20408         LDKUnsignedNodeAnnouncement obj_conv;
20409         obj_conv.inner = (void*)(obj & (~1));
20410         obj_conv.is_owned = false;
20411         LDKCVec_u8Z ret_var = UnsignedNodeAnnouncement_write(&obj_conv);
20412         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20413         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20414         CVec_u8Z_free(ret_var);
20415         return ret_arr;
20416 }
20417
20418 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20419         LDKu8slice ser_ref;
20420         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20421         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20422         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
20423         *ret_conv = UnsignedNodeAnnouncement_read(ser_ref);
20424         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20425         return (uint64_t)ret_conv;
20426 }
20427
20428 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
20429         LDKNodeAnnouncement obj_conv;
20430         obj_conv.inner = (void*)(obj & (~1));
20431         obj_conv.is_owned = false;
20432         LDKCVec_u8Z ret_var = NodeAnnouncement_write(&obj_conv);
20433         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20434         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20435         CVec_u8Z_free(ret_var);
20436         return ret_arr;
20437 }
20438
20439 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20440         LDKu8slice ser_ref;
20441         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20442         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20443         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
20444         *ret_conv = NodeAnnouncement_read(ser_ref);
20445         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20446         return (uint64_t)ret_conv;
20447 }
20448
20449 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20450         LDKu8slice ser_ref;
20451         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20452         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20453         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
20454         *ret_conv = QueryShortChannelIds_read(ser_ref);
20455         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20456         return (uint64_t)ret_conv;
20457 }
20458
20459 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1write(JNIEnv *env, jclass clz, int64_t obj) {
20460         LDKQueryShortChannelIds obj_conv;
20461         obj_conv.inner = (void*)(obj & (~1));
20462         obj_conv.is_owned = false;
20463         LDKCVec_u8Z ret_var = QueryShortChannelIds_write(&obj_conv);
20464         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20465         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20466         CVec_u8Z_free(ret_var);
20467         return ret_arr;
20468 }
20469
20470 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20471         LDKu8slice ser_ref;
20472         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20473         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20474         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
20475         *ret_conv = ReplyShortChannelIdsEnd_read(ser_ref);
20476         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20477         return (uint64_t)ret_conv;
20478 }
20479
20480 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1write(JNIEnv *env, jclass clz, int64_t obj) {
20481         LDKReplyShortChannelIdsEnd obj_conv;
20482         obj_conv.inner = (void*)(obj & (~1));
20483         obj_conv.is_owned = false;
20484         LDKCVec_u8Z ret_var = ReplyShortChannelIdsEnd_write(&obj_conv);
20485         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20486         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20487         CVec_u8Z_free(ret_var);
20488         return ret_arr;
20489 }
20490
20491 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1end_1blocknum(JNIEnv *env, jclass clz, int64_t this_arg) {
20492         LDKQueryChannelRange this_arg_conv;
20493         this_arg_conv.inner = (void*)(this_arg & (~1));
20494         this_arg_conv.is_owned = false;
20495         int32_t ret_val = QueryChannelRange_end_blocknum(&this_arg_conv);
20496         return ret_val;
20497 }
20498
20499 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20500         LDKu8slice ser_ref;
20501         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20502         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20503         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
20504         *ret_conv = QueryChannelRange_read(ser_ref);
20505         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20506         return (uint64_t)ret_conv;
20507 }
20508
20509 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
20510         LDKQueryChannelRange obj_conv;
20511         obj_conv.inner = (void*)(obj & (~1));
20512         obj_conv.is_owned = false;
20513         LDKCVec_u8Z ret_var = QueryChannelRange_write(&obj_conv);
20514         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20515         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20516         CVec_u8Z_free(ret_var);
20517         return ret_arr;
20518 }
20519
20520 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20521         LDKu8slice ser_ref;
20522         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20523         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20524         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
20525         *ret_conv = ReplyChannelRange_read(ser_ref);
20526         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20527         return (uint64_t)ret_conv;
20528 }
20529
20530 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
20531         LDKReplyChannelRange obj_conv;
20532         obj_conv.inner = (void*)(obj & (~1));
20533         obj_conv.is_owned = false;
20534         LDKCVec_u8Z ret_var = ReplyChannelRange_write(&obj_conv);
20535         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20536         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20537         CVec_u8Z_free(ret_var);
20538         return ret_arr;
20539 }
20540
20541 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20542         LDKu8slice ser_ref;
20543         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20544         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20545         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
20546         *ret_conv = GossipTimestampFilter_read(ser_ref);
20547         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20548         return (uint64_t)ret_conv;
20549 }
20550
20551 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1write(JNIEnv *env, jclass clz, int64_t obj) {
20552         LDKGossipTimestampFilter obj_conv;
20553         obj_conv.inner = (void*)(obj & (~1));
20554         obj_conv.is_owned = false;
20555         LDKCVec_u8Z ret_var = GossipTimestampFilter_write(&obj_conv);
20556         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20557         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20558         CVec_u8Z_free(ret_var);
20559         return ret_arr;
20560 }
20561
20562 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20563         LDKIgnoringMessageHandler this_obj_conv;
20564         this_obj_conv.inner = (void*)(this_obj & (~1));
20565         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20566         IgnoringMessageHandler_free(this_obj_conv);
20567 }
20568
20569 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1new(JNIEnv *env, jclass clz) {
20570         LDKIgnoringMessageHandler ret_var = IgnoringMessageHandler_new();
20571         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20572         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20573         uint64_t ret_ref = (uint64_t)ret_var.inner;
20574         if (ret_var.is_owned) {
20575                 ret_ref |= 1;
20576         }
20577         return ret_ref;
20578 }
20579
20580 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
20581         LDKIgnoringMessageHandler this_arg_conv;
20582         this_arg_conv.inner = (void*)(this_arg & (~1));
20583         this_arg_conv.is_owned = false;
20584         LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
20585         *ret = IgnoringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
20586         return (uint64_t)ret;
20587 }
20588
20589 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1RoutingMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
20590         LDKIgnoringMessageHandler this_arg_conv;
20591         this_arg_conv.inner = (void*)(this_arg & (~1));
20592         this_arg_conv.is_owned = false;
20593         LDKRoutingMessageHandler* ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
20594         *ret = IgnoringMessageHandler_as_RoutingMessageHandler(&this_arg_conv);
20595         return (uint64_t)ret;
20596 }
20597
20598 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20599         LDKErroringMessageHandler this_obj_conv;
20600         this_obj_conv.inner = (void*)(this_obj & (~1));
20601         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20602         ErroringMessageHandler_free(this_obj_conv);
20603 }
20604
20605 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1new(JNIEnv *env, jclass clz) {
20606         LDKErroringMessageHandler ret_var = ErroringMessageHandler_new();
20607         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20608         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20609         uint64_t ret_ref = (uint64_t)ret_var.inner;
20610         if (ret_var.is_owned) {
20611                 ret_ref |= 1;
20612         }
20613         return ret_ref;
20614 }
20615
20616 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
20617         LDKErroringMessageHandler this_arg_conv;
20618         this_arg_conv.inner = (void*)(this_arg & (~1));
20619         this_arg_conv.is_owned = false;
20620         LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
20621         *ret = ErroringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
20622         return (uint64_t)ret;
20623 }
20624
20625 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1as_1ChannelMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
20626         LDKErroringMessageHandler this_arg_conv;
20627         this_arg_conv.inner = (void*)(this_arg & (~1));
20628         this_arg_conv.is_owned = false;
20629         LDKChannelMessageHandler* ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
20630         *ret = ErroringMessageHandler_as_ChannelMessageHandler(&this_arg_conv);
20631         return (uint64_t)ret;
20632 }
20633
20634 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20635         LDKMessageHandler this_obj_conv;
20636         this_obj_conv.inner = (void*)(this_obj & (~1));
20637         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20638         MessageHandler_free(this_obj_conv);
20639 }
20640
20641 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1chan_1handler(JNIEnv *env, jclass clz, int64_t this_ptr) {
20642         LDKMessageHandler this_ptr_conv;
20643         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20644         this_ptr_conv.is_owned = false;
20645         uint64_t ret_ret = (uint64_t)MessageHandler_get_chan_handler(&this_ptr_conv);
20646         return ret_ret;
20647 }
20648
20649 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1chan_1handler(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20650         LDKMessageHandler this_ptr_conv;
20651         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20652         this_ptr_conv.is_owned = false;
20653         LDKChannelMessageHandler val_conv = *(LDKChannelMessageHandler*)(((uint64_t)val) & ~1);
20654         if (val_conv.free == LDKChannelMessageHandler_JCalls_free) {
20655                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
20656                 LDKChannelMessageHandler_JCalls_clone(val_conv.this_arg);
20657         }
20658         MessageHandler_set_chan_handler(&this_ptr_conv, val_conv);
20659 }
20660
20661 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1route_1handler(JNIEnv *env, jclass clz, int64_t this_ptr) {
20662         LDKMessageHandler this_ptr_conv;
20663         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20664         this_ptr_conv.is_owned = false;
20665         uint64_t ret_ret = (uint64_t)MessageHandler_get_route_handler(&this_ptr_conv);
20666         return ret_ret;
20667 }
20668
20669 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1route_1handler(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20670         LDKMessageHandler this_ptr_conv;
20671         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20672         this_ptr_conv.is_owned = false;
20673         LDKRoutingMessageHandler val_conv = *(LDKRoutingMessageHandler*)(((uint64_t)val) & ~1);
20674         if (val_conv.free == LDKRoutingMessageHandler_JCalls_free) {
20675                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
20676                 LDKRoutingMessageHandler_JCalls_clone(val_conv.this_arg);
20677         }
20678         MessageHandler_set_route_handler(&this_ptr_conv, val_conv);
20679 }
20680
20681 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) {
20682         LDKChannelMessageHandler chan_handler_arg_conv = *(LDKChannelMessageHandler*)(((uint64_t)chan_handler_arg) & ~1);
20683         if (chan_handler_arg_conv.free == LDKChannelMessageHandler_JCalls_free) {
20684                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
20685                 LDKChannelMessageHandler_JCalls_clone(chan_handler_arg_conv.this_arg);
20686         }
20687         LDKRoutingMessageHandler route_handler_arg_conv = *(LDKRoutingMessageHandler*)(((uint64_t)route_handler_arg) & ~1);
20688         if (route_handler_arg_conv.free == LDKRoutingMessageHandler_JCalls_free) {
20689                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
20690                 LDKRoutingMessageHandler_JCalls_clone(route_handler_arg_conv.this_arg);
20691         }
20692         LDKMessageHandler ret_var = MessageHandler_new(chan_handler_arg_conv, route_handler_arg_conv);
20693         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20694         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20695         uint64_t ret_ref = (uint64_t)ret_var.inner;
20696         if (ret_var.is_owned) {
20697                 ret_ref |= 1;
20698         }
20699         return ret_ref;
20700 }
20701
20702 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20703         LDKSocketDescriptor* orig_conv = (LDKSocketDescriptor*)(((uint64_t)orig) & ~1);
20704         LDKSocketDescriptor* ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
20705         *ret = SocketDescriptor_clone(orig_conv);
20706         return (uint64_t)ret;
20707 }
20708
20709 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
20710         if ((this_ptr & 1) != 0) return;
20711         LDKSocketDescriptor this_ptr_conv = *(LDKSocketDescriptor*)(((uint64_t)this_ptr) & ~1);
20712         FREE((void*)this_ptr);
20713         SocketDescriptor_free(this_ptr_conv);
20714 }
20715
20716 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20717         LDKPeerHandleError this_obj_conv;
20718         this_obj_conv.inner = (void*)(this_obj & (~1));
20719         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20720         PeerHandleError_free(this_obj_conv);
20721 }
20722
20723 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1get_1no_1connection_1possible(JNIEnv *env, jclass clz, int64_t this_ptr) {
20724         LDKPeerHandleError this_ptr_conv;
20725         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20726         this_ptr_conv.is_owned = false;
20727         jboolean ret_val = PeerHandleError_get_no_connection_possible(&this_ptr_conv);
20728         return ret_val;
20729 }
20730
20731 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1set_1no_1connection_1possible(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
20732         LDKPeerHandleError this_ptr_conv;
20733         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20734         this_ptr_conv.is_owned = false;
20735         PeerHandleError_set_no_connection_possible(&this_ptr_conv, val);
20736 }
20737
20738 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1new(JNIEnv *env, jclass clz, jboolean no_connection_possible_arg) {
20739         LDKPeerHandleError ret_var = PeerHandleError_new(no_connection_possible_arg);
20740         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20741         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20742         uint64_t ret_ref = (uint64_t)ret_var.inner;
20743         if (ret_var.is_owned) {
20744                 ret_ref |= 1;
20745         }
20746         return ret_ref;
20747 }
20748
20749 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20750         LDKPeerHandleError orig_conv;
20751         orig_conv.inner = (void*)(orig & (~1));
20752         orig_conv.is_owned = false;
20753         LDKPeerHandleError ret_var = PeerHandleError_clone(&orig_conv);
20754         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20755         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20756         uint64_t ret_ref = (uint64_t)ret_var.inner;
20757         if (ret_var.is_owned) {
20758                 ret_ref |= 1;
20759         }
20760         return ret_ref;
20761 }
20762
20763 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20764         LDKPeerManager this_obj_conv;
20765         this_obj_conv.inner = (void*)(this_obj & (~1));
20766         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20767         PeerManager_free(this_obj_conv);
20768 }
20769
20770 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) {
20771         LDKMessageHandler message_handler_conv;
20772         message_handler_conv.inner = (void*)(message_handler & (~1));
20773         message_handler_conv.is_owned = (message_handler & 1) || (message_handler == 0);
20774         // Warning: we need a move here but no clone is available for LDKMessageHandler
20775         LDKSecretKey our_node_secret_ref;
20776         CHECK((*env)->GetArrayLength(env, our_node_secret) == 32);
20777         (*env)->GetByteArrayRegion(env, our_node_secret, 0, 32, our_node_secret_ref.bytes);
20778         unsigned char ephemeral_random_data_arr[32];
20779         CHECK((*env)->GetArrayLength(env, ephemeral_random_data) == 32);
20780         (*env)->GetByteArrayRegion(env, ephemeral_random_data, 0, 32, ephemeral_random_data_arr);
20781         unsigned char (*ephemeral_random_data_ref)[32] = &ephemeral_random_data_arr;
20782         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
20783         if (logger_conv.free == LDKLogger_JCalls_free) {
20784                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
20785                 LDKLogger_JCalls_clone(logger_conv.this_arg);
20786         }
20787         LDKPeerManager ret_var = PeerManager_new(message_handler_conv, our_node_secret_ref, ephemeral_random_data_ref, logger_conv);
20788         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20789         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20790         uint64_t ret_ref = (uint64_t)ret_var.inner;
20791         if (ret_var.is_owned) {
20792                 ret_ref |= 1;
20793         }
20794         return ret_ref;
20795 }
20796
20797 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_PeerManager_1get_1peer_1node_1ids(JNIEnv *env, jclass clz, int64_t this_arg) {
20798         LDKPeerManager this_arg_conv;
20799         this_arg_conv.inner = (void*)(this_arg & (~1));
20800         this_arg_conv.is_owned = false;
20801         LDKCVec_PublicKeyZ ret_var = PeerManager_get_peer_node_ids(&this_arg_conv);
20802         jobjectArray ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
20803         ;
20804         for (size_t i = 0; i < ret_var.datalen; i++) {
20805                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 33);
20806                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 33, ret_var.data[i].compressed_form);
20807                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
20808         }
20809         FREE(ret_var.data);
20810         return ret_arr;
20811 }
20812
20813 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) {
20814         LDKPeerManager this_arg_conv;
20815         this_arg_conv.inner = (void*)(this_arg & (~1));
20816         this_arg_conv.is_owned = false;
20817         LDKPublicKey their_node_id_ref;
20818         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
20819         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
20820         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
20821         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
20822                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
20823                 LDKSocketDescriptor_JCalls_clone(descriptor_conv.this_arg);
20824         }
20825         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
20826         *ret_conv = PeerManager_new_outbound_connection(&this_arg_conv, their_node_id_ref, descriptor_conv);
20827         return (uint64_t)ret_conv;
20828 }
20829
20830 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerManager_1new_1inbound_1connection(JNIEnv *env, jclass clz, int64_t this_arg, int64_t descriptor) {
20831         LDKPeerManager this_arg_conv;
20832         this_arg_conv.inner = (void*)(this_arg & (~1));
20833         this_arg_conv.is_owned = false;
20834         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
20835         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
20836                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
20837                 LDKSocketDescriptor_JCalls_clone(descriptor_conv.this_arg);
20838         }
20839         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
20840         *ret_conv = PeerManager_new_inbound_connection(&this_arg_conv, descriptor_conv);
20841         return (uint64_t)ret_conv;
20842 }
20843
20844 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) {
20845         LDKPeerManager this_arg_conv;
20846         this_arg_conv.inner = (void*)(this_arg & (~1));
20847         this_arg_conv.is_owned = false;
20848         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
20849         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
20850         *ret_conv = PeerManager_write_buffer_space_avail(&this_arg_conv, descriptor_conv);
20851         return (uint64_t)ret_conv;
20852 }
20853
20854 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) {
20855         LDKPeerManager this_arg_conv;
20856         this_arg_conv.inner = (void*)(this_arg & (~1));
20857         this_arg_conv.is_owned = false;
20858         LDKSocketDescriptor* peer_descriptor_conv = (LDKSocketDescriptor*)(((uint64_t)peer_descriptor) & ~1);
20859         LDKu8slice data_ref;
20860         data_ref.datalen = (*env)->GetArrayLength(env, data);
20861         data_ref.data = (*env)->GetByteArrayElements (env, data, NULL);
20862         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
20863         *ret_conv = PeerManager_read_event(&this_arg_conv, peer_descriptor_conv, data_ref);
20864         (*env)->ReleaseByteArrayElements(env, data, (int8_t*)data_ref.data, 0);
20865         return (uint64_t)ret_conv;
20866 }
20867
20868 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1process_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
20869         LDKPeerManager this_arg_conv;
20870         this_arg_conv.inner = (void*)(this_arg & (~1));
20871         this_arg_conv.is_owned = false;
20872         PeerManager_process_events(&this_arg_conv);
20873 }
20874
20875 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1socket_1disconnected(JNIEnv *env, jclass clz, int64_t this_arg, int64_t descriptor) {
20876         LDKPeerManager this_arg_conv;
20877         this_arg_conv.inner = (void*)(this_arg & (~1));
20878         this_arg_conv.is_owned = false;
20879         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
20880         PeerManager_socket_disconnected(&this_arg_conv, descriptor_conv);
20881 }
20882
20883 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) {
20884         LDKPeerManager this_arg_conv;
20885         this_arg_conv.inner = (void*)(this_arg & (~1));
20886         this_arg_conv.is_owned = false;
20887         LDKPublicKey node_id_ref;
20888         CHECK((*env)->GetArrayLength(env, node_id) == 33);
20889         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
20890         PeerManager_disconnect_by_node_id(&this_arg_conv, node_id_ref, no_connection_possible);
20891 }
20892
20893 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1timer_1tick_1occurred(JNIEnv *env, jclass clz, int64_t this_arg) {
20894         LDKPeerManager this_arg_conv;
20895         this_arg_conv.inner = (void*)(this_arg & (~1));
20896         this_arg_conv.is_owned = false;
20897         PeerManager_timer_tick_occurred(&this_arg_conv);
20898 }
20899
20900 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_build_1commitment_1secret(JNIEnv *env, jclass clz, int8_tArray commitment_seed, int64_t idx) {
20901         unsigned char commitment_seed_arr[32];
20902         CHECK((*env)->GetArrayLength(env, commitment_seed) == 32);
20903         (*env)->GetByteArrayRegion(env, commitment_seed, 0, 32, commitment_seed_arr);
20904         unsigned char (*commitment_seed_ref)[32] = &commitment_seed_arr;
20905         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
20906         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, build_commitment_secret(commitment_seed_ref, idx).data);
20907         return ret_arr;
20908 }
20909
20910 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) {
20911         LDKPublicKey per_commitment_point_ref;
20912         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
20913         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
20914         unsigned char base_secret_arr[32];
20915         CHECK((*env)->GetArrayLength(env, base_secret) == 32);
20916         (*env)->GetByteArrayRegion(env, base_secret, 0, 32, base_secret_arr);
20917         unsigned char (*base_secret_ref)[32] = &base_secret_arr;
20918         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
20919         *ret_conv = derive_private_key(per_commitment_point_ref, base_secret_ref);
20920         return (uint64_t)ret_conv;
20921 }
20922
20923 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) {
20924         LDKPublicKey per_commitment_point_ref;
20925         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
20926         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
20927         LDKPublicKey base_point_ref;
20928         CHECK((*env)->GetArrayLength(env, base_point) == 33);
20929         (*env)->GetByteArrayRegion(env, base_point, 0, 33, base_point_ref.compressed_form);
20930         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
20931         *ret_conv = derive_public_key(per_commitment_point_ref, base_point_ref);
20932         return (uint64_t)ret_conv;
20933 }
20934
20935 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) {
20936         unsigned char per_commitment_secret_arr[32];
20937         CHECK((*env)->GetArrayLength(env, per_commitment_secret) == 32);
20938         (*env)->GetByteArrayRegion(env, per_commitment_secret, 0, 32, per_commitment_secret_arr);
20939         unsigned char (*per_commitment_secret_ref)[32] = &per_commitment_secret_arr;
20940         unsigned char countersignatory_revocation_base_secret_arr[32];
20941         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base_secret) == 32);
20942         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base_secret, 0, 32, countersignatory_revocation_base_secret_arr);
20943         unsigned char (*countersignatory_revocation_base_secret_ref)[32] = &countersignatory_revocation_base_secret_arr;
20944         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
20945         *ret_conv = derive_private_revocation_key(per_commitment_secret_ref, countersignatory_revocation_base_secret_ref);
20946         return (uint64_t)ret_conv;
20947 }
20948
20949 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) {
20950         LDKPublicKey per_commitment_point_ref;
20951         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
20952         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
20953         LDKPublicKey countersignatory_revocation_base_point_ref;
20954         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base_point) == 33);
20955         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base_point, 0, 33, countersignatory_revocation_base_point_ref.compressed_form);
20956         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
20957         *ret_conv = derive_public_revocation_key(per_commitment_point_ref, countersignatory_revocation_base_point_ref);
20958         return (uint64_t)ret_conv;
20959 }
20960
20961 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20962         LDKTxCreationKeys this_obj_conv;
20963         this_obj_conv.inner = (void*)(this_obj & (~1));
20964         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20965         TxCreationKeys_free(this_obj_conv);
20966 }
20967
20968 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
20969         LDKTxCreationKeys this_ptr_conv;
20970         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20971         this_ptr_conv.is_owned = false;
20972         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
20973         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_per_commitment_point(&this_ptr_conv).compressed_form);
20974         return ret_arr;
20975 }
20976
20977 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20978         LDKTxCreationKeys this_ptr_conv;
20979         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20980         this_ptr_conv.is_owned = false;
20981         LDKPublicKey val_ref;
20982         CHECK((*env)->GetArrayLength(env, val) == 33);
20983         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
20984         TxCreationKeys_set_per_commitment_point(&this_ptr_conv, val_ref);
20985 }
20986
20987 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1revocation_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
20988         LDKTxCreationKeys this_ptr_conv;
20989         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20990         this_ptr_conv.is_owned = false;
20991         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
20992         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_revocation_key(&this_ptr_conv).compressed_form);
20993         return ret_arr;
20994 }
20995
20996 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1revocation_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20997         LDKTxCreationKeys this_ptr_conv;
20998         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20999         this_ptr_conv.is_owned = false;
21000         LDKPublicKey val_ref;
21001         CHECK((*env)->GetArrayLength(env, val) == 33);
21002         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
21003         TxCreationKeys_set_revocation_key(&this_ptr_conv, val_ref);
21004 }
21005
21006 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1broadcaster_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
21007         LDKTxCreationKeys this_ptr_conv;
21008         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21009         this_ptr_conv.is_owned = false;
21010         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
21011         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_broadcaster_htlc_key(&this_ptr_conv).compressed_form);
21012         return ret_arr;
21013 }
21014
21015 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1broadcaster_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21016         LDKTxCreationKeys this_ptr_conv;
21017         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21018         this_ptr_conv.is_owned = false;
21019         LDKPublicKey val_ref;
21020         CHECK((*env)->GetArrayLength(env, val) == 33);
21021         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
21022         TxCreationKeys_set_broadcaster_htlc_key(&this_ptr_conv, val_ref);
21023 }
21024
21025 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1countersignatory_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
21026         LDKTxCreationKeys this_ptr_conv;
21027         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21028         this_ptr_conv.is_owned = false;
21029         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
21030         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_countersignatory_htlc_key(&this_ptr_conv).compressed_form);
21031         return ret_arr;
21032 }
21033
21034 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1countersignatory_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21035         LDKTxCreationKeys this_ptr_conv;
21036         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21037         this_ptr_conv.is_owned = false;
21038         LDKPublicKey val_ref;
21039         CHECK((*env)->GetArrayLength(env, val) == 33);
21040         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
21041         TxCreationKeys_set_countersignatory_htlc_key(&this_ptr_conv, val_ref);
21042 }
21043
21044 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1broadcaster_1delayed_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
21045         LDKTxCreationKeys this_ptr_conv;
21046         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21047         this_ptr_conv.is_owned = false;
21048         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
21049         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_broadcaster_delayed_payment_key(&this_ptr_conv).compressed_form);
21050         return ret_arr;
21051 }
21052
21053 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) {
21054         LDKTxCreationKeys this_ptr_conv;
21055         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21056         this_ptr_conv.is_owned = false;
21057         LDKPublicKey val_ref;
21058         CHECK((*env)->GetArrayLength(env, val) == 33);
21059         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
21060         TxCreationKeys_set_broadcaster_delayed_payment_key(&this_ptr_conv, val_ref);
21061 }
21062
21063 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) {
21064         LDKPublicKey per_commitment_point_arg_ref;
21065         CHECK((*env)->GetArrayLength(env, per_commitment_point_arg) == 33);
21066         (*env)->GetByteArrayRegion(env, per_commitment_point_arg, 0, 33, per_commitment_point_arg_ref.compressed_form);
21067         LDKPublicKey revocation_key_arg_ref;
21068         CHECK((*env)->GetArrayLength(env, revocation_key_arg) == 33);
21069         (*env)->GetByteArrayRegion(env, revocation_key_arg, 0, 33, revocation_key_arg_ref.compressed_form);
21070         LDKPublicKey broadcaster_htlc_key_arg_ref;
21071         CHECK((*env)->GetArrayLength(env, broadcaster_htlc_key_arg) == 33);
21072         (*env)->GetByteArrayRegion(env, broadcaster_htlc_key_arg, 0, 33, broadcaster_htlc_key_arg_ref.compressed_form);
21073         LDKPublicKey countersignatory_htlc_key_arg_ref;
21074         CHECK((*env)->GetArrayLength(env, countersignatory_htlc_key_arg) == 33);
21075         (*env)->GetByteArrayRegion(env, countersignatory_htlc_key_arg, 0, 33, countersignatory_htlc_key_arg_ref.compressed_form);
21076         LDKPublicKey broadcaster_delayed_payment_key_arg_ref;
21077         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key_arg) == 33);
21078         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key_arg, 0, 33, broadcaster_delayed_payment_key_arg_ref.compressed_form);
21079         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);
21080         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21081         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21082         uint64_t ret_ref = (uint64_t)ret_var.inner;
21083         if (ret_var.is_owned) {
21084                 ret_ref |= 1;
21085         }
21086         return ret_ref;
21087 }
21088
21089 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21090         LDKTxCreationKeys orig_conv;
21091         orig_conv.inner = (void*)(orig & (~1));
21092         orig_conv.is_owned = false;
21093         LDKTxCreationKeys ret_var = TxCreationKeys_clone(&orig_conv);
21094         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21095         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21096         uint64_t ret_ref = (uint64_t)ret_var.inner;
21097         if (ret_var.is_owned) {
21098                 ret_ref |= 1;
21099         }
21100         return ret_ref;
21101 }
21102
21103 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1write(JNIEnv *env, jclass clz, int64_t obj) {
21104         LDKTxCreationKeys obj_conv;
21105         obj_conv.inner = (void*)(obj & (~1));
21106         obj_conv.is_owned = false;
21107         LDKCVec_u8Z ret_var = TxCreationKeys_write(&obj_conv);
21108         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21109         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21110         CVec_u8Z_free(ret_var);
21111         return ret_arr;
21112 }
21113
21114 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21115         LDKu8slice ser_ref;
21116         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21117         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21118         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
21119         *ret_conv = TxCreationKeys_read(ser_ref);
21120         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21121         return (uint64_t)ret_conv;
21122 }
21123
21124 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
21125         LDKChannelPublicKeys this_obj_conv;
21126         this_obj_conv.inner = (void*)(this_obj & (~1));
21127         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21128         ChannelPublicKeys_free(this_obj_conv);
21129 }
21130
21131 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
21132         LDKChannelPublicKeys this_ptr_conv;
21133         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21134         this_ptr_conv.is_owned = false;
21135         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
21136         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_funding_pubkey(&this_ptr_conv).compressed_form);
21137         return ret_arr;
21138 }
21139
21140 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21141         LDKChannelPublicKeys this_ptr_conv;
21142         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21143         this_ptr_conv.is_owned = false;
21144         LDKPublicKey val_ref;
21145         CHECK((*env)->GetArrayLength(env, val) == 33);
21146         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
21147         ChannelPublicKeys_set_funding_pubkey(&this_ptr_conv, val_ref);
21148 }
21149
21150 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
21151         LDKChannelPublicKeys this_ptr_conv;
21152         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21153         this_ptr_conv.is_owned = false;
21154         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
21155         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_revocation_basepoint(&this_ptr_conv).compressed_form);
21156         return ret_arr;
21157 }
21158
21159 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21160         LDKChannelPublicKeys this_ptr_conv;
21161         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21162         this_ptr_conv.is_owned = false;
21163         LDKPublicKey val_ref;
21164         CHECK((*env)->GetArrayLength(env, val) == 33);
21165         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
21166         ChannelPublicKeys_set_revocation_basepoint(&this_ptr_conv, val_ref);
21167 }
21168
21169 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
21170         LDKChannelPublicKeys this_ptr_conv;
21171         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21172         this_ptr_conv.is_owned = false;
21173         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
21174         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_payment_point(&this_ptr_conv).compressed_form);
21175         return ret_arr;
21176 }
21177
21178 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21179         LDKChannelPublicKeys this_ptr_conv;
21180         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21181         this_ptr_conv.is_owned = false;
21182         LDKPublicKey val_ref;
21183         CHECK((*env)->GetArrayLength(env, val) == 33);
21184         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
21185         ChannelPublicKeys_set_payment_point(&this_ptr_conv, val_ref);
21186 }
21187
21188 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
21189         LDKChannelPublicKeys this_ptr_conv;
21190         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21191         this_ptr_conv.is_owned = false;
21192         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
21193         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
21194         return ret_arr;
21195 }
21196
21197 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21198         LDKChannelPublicKeys this_ptr_conv;
21199         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21200         this_ptr_conv.is_owned = false;
21201         LDKPublicKey val_ref;
21202         CHECK((*env)->GetArrayLength(env, val) == 33);
21203         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
21204         ChannelPublicKeys_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
21205 }
21206
21207 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
21208         LDKChannelPublicKeys this_ptr_conv;
21209         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21210         this_ptr_conv.is_owned = false;
21211         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
21212         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_htlc_basepoint(&this_ptr_conv).compressed_form);
21213         return ret_arr;
21214 }
21215
21216 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21217         LDKChannelPublicKeys this_ptr_conv;
21218         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21219         this_ptr_conv.is_owned = false;
21220         LDKPublicKey val_ref;
21221         CHECK((*env)->GetArrayLength(env, val) == 33);
21222         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
21223         ChannelPublicKeys_set_htlc_basepoint(&this_ptr_conv, val_ref);
21224 }
21225
21226 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) {
21227         LDKPublicKey funding_pubkey_arg_ref;
21228         CHECK((*env)->GetArrayLength(env, funding_pubkey_arg) == 33);
21229         (*env)->GetByteArrayRegion(env, funding_pubkey_arg, 0, 33, funding_pubkey_arg_ref.compressed_form);
21230         LDKPublicKey revocation_basepoint_arg_ref;
21231         CHECK((*env)->GetArrayLength(env, revocation_basepoint_arg) == 33);
21232         (*env)->GetByteArrayRegion(env, revocation_basepoint_arg, 0, 33, revocation_basepoint_arg_ref.compressed_form);
21233         LDKPublicKey payment_point_arg_ref;
21234         CHECK((*env)->GetArrayLength(env, payment_point_arg) == 33);
21235         (*env)->GetByteArrayRegion(env, payment_point_arg, 0, 33, payment_point_arg_ref.compressed_form);
21236         LDKPublicKey delayed_payment_basepoint_arg_ref;
21237         CHECK((*env)->GetArrayLength(env, delayed_payment_basepoint_arg) == 33);
21238         (*env)->GetByteArrayRegion(env, delayed_payment_basepoint_arg, 0, 33, delayed_payment_basepoint_arg_ref.compressed_form);
21239         LDKPublicKey htlc_basepoint_arg_ref;
21240         CHECK((*env)->GetArrayLength(env, htlc_basepoint_arg) == 33);
21241         (*env)->GetByteArrayRegion(env, htlc_basepoint_arg, 0, 33, htlc_basepoint_arg_ref.compressed_form);
21242         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);
21243         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21244         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21245         uint64_t ret_ref = (uint64_t)ret_var.inner;
21246         if (ret_var.is_owned) {
21247                 ret_ref |= 1;
21248         }
21249         return ret_ref;
21250 }
21251
21252 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21253         LDKChannelPublicKeys orig_conv;
21254         orig_conv.inner = (void*)(orig & (~1));
21255         orig_conv.is_owned = false;
21256         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(&orig_conv);
21257         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21258         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21259         uint64_t ret_ref = (uint64_t)ret_var.inner;
21260         if (ret_var.is_owned) {
21261                 ret_ref |= 1;
21262         }
21263         return ret_ref;
21264 }
21265
21266 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1write(JNIEnv *env, jclass clz, int64_t obj) {
21267         LDKChannelPublicKeys obj_conv;
21268         obj_conv.inner = (void*)(obj & (~1));
21269         obj_conv.is_owned = false;
21270         LDKCVec_u8Z ret_var = ChannelPublicKeys_write(&obj_conv);
21271         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21272         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21273         CVec_u8Z_free(ret_var);
21274         return ret_arr;
21275 }
21276
21277 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21278         LDKu8slice ser_ref;
21279         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21280         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21281         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
21282         *ret_conv = ChannelPublicKeys_read(ser_ref);
21283         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21284         return (uint64_t)ret_conv;
21285 }
21286
21287 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) {
21288         LDKPublicKey per_commitment_point_ref;
21289         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
21290         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
21291         LDKPublicKey broadcaster_delayed_payment_base_ref;
21292         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_base) == 33);
21293         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_base, 0, 33, broadcaster_delayed_payment_base_ref.compressed_form);
21294         LDKPublicKey broadcaster_htlc_base_ref;
21295         CHECK((*env)->GetArrayLength(env, broadcaster_htlc_base) == 33);
21296         (*env)->GetByteArrayRegion(env, broadcaster_htlc_base, 0, 33, broadcaster_htlc_base_ref.compressed_form);
21297         LDKPublicKey countersignatory_revocation_base_ref;
21298         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base) == 33);
21299         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base, 0, 33, countersignatory_revocation_base_ref.compressed_form);
21300         LDKPublicKey countersignatory_htlc_base_ref;
21301         CHECK((*env)->GetArrayLength(env, countersignatory_htlc_base) == 33);
21302         (*env)->GetByteArrayRegion(env, countersignatory_htlc_base, 0, 33, countersignatory_htlc_base_ref.compressed_form);
21303         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
21304         *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);
21305         return (uint64_t)ret_conv;
21306 }
21307
21308 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) {
21309         LDKPublicKey per_commitment_point_ref;
21310         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
21311         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
21312         LDKChannelPublicKeys broadcaster_keys_conv;
21313         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
21314         broadcaster_keys_conv.is_owned = false;
21315         LDKChannelPublicKeys countersignatory_keys_conv;
21316         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
21317         countersignatory_keys_conv.is_owned = false;
21318         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
21319         *ret_conv = TxCreationKeys_from_channel_static_keys(per_commitment_point_ref, &broadcaster_keys_conv, &countersignatory_keys_conv);
21320         return (uint64_t)ret_conv;
21321 }
21322
21323 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) {
21324         LDKPublicKey revocation_key_ref;
21325         CHECK((*env)->GetArrayLength(env, revocation_key) == 33);
21326         (*env)->GetByteArrayRegion(env, revocation_key, 0, 33, revocation_key_ref.compressed_form);
21327         LDKPublicKey broadcaster_delayed_payment_key_ref;
21328         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key) == 33);
21329         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key, 0, 33, broadcaster_delayed_payment_key_ref.compressed_form);
21330         LDKCVec_u8Z ret_var = get_revokeable_redeemscript(revocation_key_ref, contest_delay, broadcaster_delayed_payment_key_ref);
21331         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21332         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21333         CVec_u8Z_free(ret_var);
21334         return ret_arr;
21335 }
21336
21337 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
21338         LDKHTLCOutputInCommitment this_obj_conv;
21339         this_obj_conv.inner = (void*)(this_obj & (~1));
21340         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21341         HTLCOutputInCommitment_free(this_obj_conv);
21342 }
21343
21344 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1offered(JNIEnv *env, jclass clz, int64_t this_ptr) {
21345         LDKHTLCOutputInCommitment this_ptr_conv;
21346         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21347         this_ptr_conv.is_owned = false;
21348         jboolean ret_val = HTLCOutputInCommitment_get_offered(&this_ptr_conv);
21349         return ret_val;
21350 }
21351
21352 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1offered(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
21353         LDKHTLCOutputInCommitment this_ptr_conv;
21354         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21355         this_ptr_conv.is_owned = false;
21356         HTLCOutputInCommitment_set_offered(&this_ptr_conv, val);
21357 }
21358
21359 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
21360         LDKHTLCOutputInCommitment this_ptr_conv;
21361         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21362         this_ptr_conv.is_owned = false;
21363         int64_t ret_val = HTLCOutputInCommitment_get_amount_msat(&this_ptr_conv);
21364         return ret_val;
21365 }
21366
21367 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
21368         LDKHTLCOutputInCommitment this_ptr_conv;
21369         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21370         this_ptr_conv.is_owned = false;
21371         HTLCOutputInCommitment_set_amount_msat(&this_ptr_conv, val);
21372 }
21373
21374 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr) {
21375         LDKHTLCOutputInCommitment this_ptr_conv;
21376         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21377         this_ptr_conv.is_owned = false;
21378         int32_t ret_val = HTLCOutputInCommitment_get_cltv_expiry(&this_ptr_conv);
21379         return ret_val;
21380 }
21381
21382 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
21383         LDKHTLCOutputInCommitment this_ptr_conv;
21384         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21385         this_ptr_conv.is_owned = false;
21386         HTLCOutputInCommitment_set_cltv_expiry(&this_ptr_conv, val);
21387 }
21388
21389 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
21390         LDKHTLCOutputInCommitment this_ptr_conv;
21391         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21392         this_ptr_conv.is_owned = false;
21393         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
21394         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *HTLCOutputInCommitment_get_payment_hash(&this_ptr_conv));
21395         return ret_arr;
21396 }
21397
21398 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21399         LDKHTLCOutputInCommitment this_ptr_conv;
21400         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21401         this_ptr_conv.is_owned = false;
21402         LDKThirtyTwoBytes val_ref;
21403         CHECK((*env)->GetArrayLength(env, val) == 32);
21404         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
21405         HTLCOutputInCommitment_set_payment_hash(&this_ptr_conv, val_ref);
21406 }
21407
21408 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1transaction_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
21409         LDKHTLCOutputInCommitment this_ptr_conv;
21410         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21411         this_ptr_conv.is_owned = false;
21412         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
21413         *ret_copy = HTLCOutputInCommitment_get_transaction_output_index(&this_ptr_conv);
21414         uint64_t ret_ref = (uint64_t)ret_copy;
21415         return ret_ref;
21416 }
21417
21418 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1transaction_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
21419         LDKHTLCOutputInCommitment this_ptr_conv;
21420         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21421         this_ptr_conv.is_owned = false;
21422         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(((uint64_t)val) & ~1);
21423         HTLCOutputInCommitment_set_transaction_output_index(&this_ptr_conv, val_conv);
21424 }
21425
21426 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) {
21427         LDKThirtyTwoBytes payment_hash_arg_ref;
21428         CHECK((*env)->GetArrayLength(env, payment_hash_arg) == 32);
21429         (*env)->GetByteArrayRegion(env, payment_hash_arg, 0, 32, payment_hash_arg_ref.data);
21430         LDKCOption_u32Z transaction_output_index_arg_conv = *(LDKCOption_u32Z*)(((uint64_t)transaction_output_index_arg) & ~1);
21431         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_new(offered_arg, amount_msat_arg, cltv_expiry_arg, payment_hash_arg_ref, transaction_output_index_arg_conv);
21432         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21433         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21434         uint64_t ret_ref = (uint64_t)ret_var.inner;
21435         if (ret_var.is_owned) {
21436                 ret_ref |= 1;
21437         }
21438         return ret_ref;
21439 }
21440
21441 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21442         LDKHTLCOutputInCommitment orig_conv;
21443         orig_conv.inner = (void*)(orig & (~1));
21444         orig_conv.is_owned = false;
21445         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(&orig_conv);
21446         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21447         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21448         uint64_t ret_ref = (uint64_t)ret_var.inner;
21449         if (ret_var.is_owned) {
21450                 ret_ref |= 1;
21451         }
21452         return ret_ref;
21453 }
21454
21455 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1write(JNIEnv *env, jclass clz, int64_t obj) {
21456         LDKHTLCOutputInCommitment obj_conv;
21457         obj_conv.inner = (void*)(obj & (~1));
21458         obj_conv.is_owned = false;
21459         LDKCVec_u8Z ret_var = HTLCOutputInCommitment_write(&obj_conv);
21460         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21461         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21462         CVec_u8Z_free(ret_var);
21463         return ret_arr;
21464 }
21465
21466 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21467         LDKu8slice ser_ref;
21468         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21469         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21470         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
21471         *ret_conv = HTLCOutputInCommitment_read(ser_ref);
21472         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21473         return (uint64_t)ret_conv;
21474 }
21475
21476 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_get_1htlc_1redeemscript(JNIEnv *env, jclass clz, int64_t htlc, int64_t keys) {
21477         LDKHTLCOutputInCommitment htlc_conv;
21478         htlc_conv.inner = (void*)(htlc & (~1));
21479         htlc_conv.is_owned = false;
21480         LDKTxCreationKeys keys_conv;
21481         keys_conv.inner = (void*)(keys & (~1));
21482         keys_conv.is_owned = false;
21483         LDKCVec_u8Z ret_var = get_htlc_redeemscript(&htlc_conv, &keys_conv);
21484         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21485         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21486         CVec_u8Z_free(ret_var);
21487         return ret_arr;
21488 }
21489
21490 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_make_1funding_1redeemscript(JNIEnv *env, jclass clz, int8_tArray broadcaster, int8_tArray countersignatory) {
21491         LDKPublicKey broadcaster_ref;
21492         CHECK((*env)->GetArrayLength(env, broadcaster) == 33);
21493         (*env)->GetByteArrayRegion(env, broadcaster, 0, 33, broadcaster_ref.compressed_form);
21494         LDKPublicKey countersignatory_ref;
21495         CHECK((*env)->GetArrayLength(env, countersignatory) == 33);
21496         (*env)->GetByteArrayRegion(env, countersignatory, 0, 33, countersignatory_ref.compressed_form);
21497         LDKCVec_u8Z ret_var = make_funding_redeemscript(broadcaster_ref, countersignatory_ref);
21498         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21499         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21500         CVec_u8Z_free(ret_var);
21501         return ret_arr;
21502 }
21503
21504 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) {
21505         unsigned char commitment_txid_arr[32];
21506         CHECK((*env)->GetArrayLength(env, commitment_txid) == 32);
21507         (*env)->GetByteArrayRegion(env, commitment_txid, 0, 32, commitment_txid_arr);
21508         unsigned char (*commitment_txid_ref)[32] = &commitment_txid_arr;
21509         LDKHTLCOutputInCommitment htlc_conv;
21510         htlc_conv.inner = (void*)(htlc & (~1));
21511         htlc_conv.is_owned = false;
21512         LDKPublicKey broadcaster_delayed_payment_key_ref;
21513         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key) == 33);
21514         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key, 0, 33, broadcaster_delayed_payment_key_ref.compressed_form);
21515         LDKPublicKey revocation_key_ref;
21516         CHECK((*env)->GetArrayLength(env, revocation_key) == 33);
21517         (*env)->GetByteArrayRegion(env, revocation_key, 0, 33, revocation_key_ref.compressed_form);
21518         LDKTransaction ret_var = build_htlc_transaction(commitment_txid_ref, feerate_per_kw, contest_delay, &htlc_conv, broadcaster_delayed_payment_key_ref, revocation_key_ref);
21519         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21520         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21521         Transaction_free(ret_var);
21522         return ret_arr;
21523 }
21524
21525 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
21526         LDKChannelTransactionParameters this_obj_conv;
21527         this_obj_conv.inner = (void*)(this_obj & (~1));
21528         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21529         ChannelTransactionParameters_free(this_obj_conv);
21530 }
21531
21532 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1holder_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr) {
21533         LDKChannelTransactionParameters this_ptr_conv;
21534         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21535         this_ptr_conv.is_owned = false;
21536         LDKChannelPublicKeys ret_var = ChannelTransactionParameters_get_holder_pubkeys(&this_ptr_conv);
21537         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21538         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21539         uint64_t ret_ref = (uint64_t)ret_var.inner;
21540         if (ret_var.is_owned) {
21541                 ret_ref |= 1;
21542         }
21543         return ret_ref;
21544 }
21545
21546 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1holder_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
21547         LDKChannelTransactionParameters this_ptr_conv;
21548         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21549         this_ptr_conv.is_owned = false;
21550         LDKChannelPublicKeys val_conv;
21551         val_conv.inner = (void*)(val & (~1));
21552         val_conv.is_owned = (val & 1) || (val == 0);
21553         val_conv = ChannelPublicKeys_clone(&val_conv);
21554         ChannelTransactionParameters_set_holder_pubkeys(&this_ptr_conv, val_conv);
21555 }
21556
21557 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1holder_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
21558         LDKChannelTransactionParameters this_ptr_conv;
21559         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21560         this_ptr_conv.is_owned = false;
21561         int16_t ret_val = ChannelTransactionParameters_get_holder_selected_contest_delay(&this_ptr_conv);
21562         return ret_val;
21563 }
21564
21565 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) {
21566         LDKChannelTransactionParameters this_ptr_conv;
21567         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21568         this_ptr_conv.is_owned = false;
21569         ChannelTransactionParameters_set_holder_selected_contest_delay(&this_ptr_conv, val);
21570 }
21571
21572 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1is_1outbound_1from_1holder(JNIEnv *env, jclass clz, int64_t this_ptr) {
21573         LDKChannelTransactionParameters this_ptr_conv;
21574         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21575         this_ptr_conv.is_owned = false;
21576         jboolean ret_val = ChannelTransactionParameters_get_is_outbound_from_holder(&this_ptr_conv);
21577         return ret_val;
21578 }
21579
21580 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1is_1outbound_1from_1holder(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
21581         LDKChannelTransactionParameters this_ptr_conv;
21582         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21583         this_ptr_conv.is_owned = false;
21584         ChannelTransactionParameters_set_is_outbound_from_holder(&this_ptr_conv, val);
21585 }
21586
21587 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1counterparty_1parameters(JNIEnv *env, jclass clz, int64_t this_ptr) {
21588         LDKChannelTransactionParameters this_ptr_conv;
21589         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21590         this_ptr_conv.is_owned = false;
21591         LDKCounterpartyChannelTransactionParameters ret_var = ChannelTransactionParameters_get_counterparty_parameters(&this_ptr_conv);
21592         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21593         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21594         uint64_t ret_ref = (uint64_t)ret_var.inner;
21595         if (ret_var.is_owned) {
21596                 ret_ref |= 1;
21597         }
21598         return ret_ref;
21599 }
21600
21601 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1counterparty_1parameters(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
21602         LDKChannelTransactionParameters this_ptr_conv;
21603         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21604         this_ptr_conv.is_owned = false;
21605         LDKCounterpartyChannelTransactionParameters val_conv;
21606         val_conv.inner = (void*)(val & (~1));
21607         val_conv.is_owned = (val & 1) || (val == 0);
21608         val_conv = CounterpartyChannelTransactionParameters_clone(&val_conv);
21609         ChannelTransactionParameters_set_counterparty_parameters(&this_ptr_conv, val_conv);
21610 }
21611
21612 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
21613         LDKChannelTransactionParameters this_ptr_conv;
21614         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21615         this_ptr_conv.is_owned = false;
21616         LDKOutPoint ret_var = ChannelTransactionParameters_get_funding_outpoint(&this_ptr_conv);
21617         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21618         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21619         uint64_t ret_ref = (uint64_t)ret_var.inner;
21620         if (ret_var.is_owned) {
21621                 ret_ref |= 1;
21622         }
21623         return ret_ref;
21624 }
21625
21626 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
21627         LDKChannelTransactionParameters this_ptr_conv;
21628         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21629         this_ptr_conv.is_owned = false;
21630         LDKOutPoint val_conv;
21631         val_conv.inner = (void*)(val & (~1));
21632         val_conv.is_owned = (val & 1) || (val == 0);
21633         val_conv = OutPoint_clone(&val_conv);
21634         ChannelTransactionParameters_set_funding_outpoint(&this_ptr_conv, val_conv);
21635 }
21636
21637 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) {
21638         LDKChannelPublicKeys holder_pubkeys_arg_conv;
21639         holder_pubkeys_arg_conv.inner = (void*)(holder_pubkeys_arg & (~1));
21640         holder_pubkeys_arg_conv.is_owned = (holder_pubkeys_arg & 1) || (holder_pubkeys_arg == 0);
21641         holder_pubkeys_arg_conv = ChannelPublicKeys_clone(&holder_pubkeys_arg_conv);
21642         LDKCounterpartyChannelTransactionParameters counterparty_parameters_arg_conv;
21643         counterparty_parameters_arg_conv.inner = (void*)(counterparty_parameters_arg & (~1));
21644         counterparty_parameters_arg_conv.is_owned = (counterparty_parameters_arg & 1) || (counterparty_parameters_arg == 0);
21645         counterparty_parameters_arg_conv = CounterpartyChannelTransactionParameters_clone(&counterparty_parameters_arg_conv);
21646         LDKOutPoint funding_outpoint_arg_conv;
21647         funding_outpoint_arg_conv.inner = (void*)(funding_outpoint_arg & (~1));
21648         funding_outpoint_arg_conv.is_owned = (funding_outpoint_arg & 1) || (funding_outpoint_arg == 0);
21649         funding_outpoint_arg_conv = OutPoint_clone(&funding_outpoint_arg_conv);
21650         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);
21651         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21652         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21653         uint64_t ret_ref = (uint64_t)ret_var.inner;
21654         if (ret_var.is_owned) {
21655                 ret_ref |= 1;
21656         }
21657         return ret_ref;
21658 }
21659
21660 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21661         LDKChannelTransactionParameters orig_conv;
21662         orig_conv.inner = (void*)(orig & (~1));
21663         orig_conv.is_owned = false;
21664         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(&orig_conv);
21665         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21666         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21667         uint64_t ret_ref = (uint64_t)ret_var.inner;
21668         if (ret_var.is_owned) {
21669                 ret_ref |= 1;
21670         }
21671         return ret_ref;
21672 }
21673
21674 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
21675         LDKCounterpartyChannelTransactionParameters this_obj_conv;
21676         this_obj_conv.inner = (void*)(this_obj & (~1));
21677         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21678         CounterpartyChannelTransactionParameters_free(this_obj_conv);
21679 }
21680
21681 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1get_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr) {
21682         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
21683         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21684         this_ptr_conv.is_owned = false;
21685         LDKChannelPublicKeys ret_var = CounterpartyChannelTransactionParameters_get_pubkeys(&this_ptr_conv);
21686         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21687         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21688         uint64_t ret_ref = (uint64_t)ret_var.inner;
21689         if (ret_var.is_owned) {
21690                 ret_ref |= 1;
21691         }
21692         return ret_ref;
21693 }
21694
21695 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1set_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
21696         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
21697         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21698         this_ptr_conv.is_owned = false;
21699         LDKChannelPublicKeys val_conv;
21700         val_conv.inner = (void*)(val & (~1));
21701         val_conv.is_owned = (val & 1) || (val == 0);
21702         val_conv = ChannelPublicKeys_clone(&val_conv);
21703         CounterpartyChannelTransactionParameters_set_pubkeys(&this_ptr_conv, val_conv);
21704 }
21705
21706 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1get_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
21707         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
21708         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21709         this_ptr_conv.is_owned = false;
21710         int16_t ret_val = CounterpartyChannelTransactionParameters_get_selected_contest_delay(&this_ptr_conv);
21711         return ret_val;
21712 }
21713
21714 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1set_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
21715         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
21716         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21717         this_ptr_conv.is_owned = false;
21718         CounterpartyChannelTransactionParameters_set_selected_contest_delay(&this_ptr_conv, val);
21719 }
21720
21721 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) {
21722         LDKChannelPublicKeys pubkeys_arg_conv;
21723         pubkeys_arg_conv.inner = (void*)(pubkeys_arg & (~1));
21724         pubkeys_arg_conv.is_owned = (pubkeys_arg & 1) || (pubkeys_arg == 0);
21725         pubkeys_arg_conv = ChannelPublicKeys_clone(&pubkeys_arg_conv);
21726         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_new(pubkeys_arg_conv, selected_contest_delay_arg);
21727         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21728         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21729         uint64_t ret_ref = (uint64_t)ret_var.inner;
21730         if (ret_var.is_owned) {
21731                 ret_ref |= 1;
21732         }
21733         return ret_ref;
21734 }
21735
21736 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21737         LDKCounterpartyChannelTransactionParameters orig_conv;
21738         orig_conv.inner = (void*)(orig & (~1));
21739         orig_conv.is_owned = false;
21740         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(&orig_conv);
21741         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21742         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21743         uint64_t ret_ref = (uint64_t)ret_var.inner;
21744         if (ret_var.is_owned) {
21745                 ret_ref |= 1;
21746         }
21747         return ret_ref;
21748 }
21749
21750 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1is_1populated(JNIEnv *env, jclass clz, int64_t this_arg) {
21751         LDKChannelTransactionParameters this_arg_conv;
21752         this_arg_conv.inner = (void*)(this_arg & (~1));
21753         this_arg_conv.is_owned = false;
21754         jboolean ret_val = ChannelTransactionParameters_is_populated(&this_arg_conv);
21755         return ret_val;
21756 }
21757
21758 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1as_1holder_1broadcastable(JNIEnv *env, jclass clz, int64_t this_arg) {
21759         LDKChannelTransactionParameters this_arg_conv;
21760         this_arg_conv.inner = (void*)(this_arg & (~1));
21761         this_arg_conv.is_owned = false;
21762         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_holder_broadcastable(&this_arg_conv);
21763         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21764         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21765         uint64_t ret_ref = (uint64_t)ret_var.inner;
21766         if (ret_var.is_owned) {
21767                 ret_ref |= 1;
21768         }
21769         return ret_ref;
21770 }
21771
21772 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1as_1counterparty_1broadcastable(JNIEnv *env, jclass clz, int64_t this_arg) {
21773         LDKChannelTransactionParameters this_arg_conv;
21774         this_arg_conv.inner = (void*)(this_arg & (~1));
21775         this_arg_conv.is_owned = false;
21776         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_counterparty_broadcastable(&this_arg_conv);
21777         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21778         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21779         uint64_t ret_ref = (uint64_t)ret_var.inner;
21780         if (ret_var.is_owned) {
21781                 ret_ref |= 1;
21782         }
21783         return ret_ref;
21784 }
21785
21786 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
21787         LDKCounterpartyChannelTransactionParameters obj_conv;
21788         obj_conv.inner = (void*)(obj & (~1));
21789         obj_conv.is_owned = false;
21790         LDKCVec_u8Z ret_var = CounterpartyChannelTransactionParameters_write(&obj_conv);
21791         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21792         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21793         CVec_u8Z_free(ret_var);
21794         return ret_arr;
21795 }
21796
21797 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21798         LDKu8slice ser_ref;
21799         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21800         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21801         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
21802         *ret_conv = CounterpartyChannelTransactionParameters_read(ser_ref);
21803         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21804         return (uint64_t)ret_conv;
21805 }
21806
21807 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
21808         LDKChannelTransactionParameters obj_conv;
21809         obj_conv.inner = (void*)(obj & (~1));
21810         obj_conv.is_owned = false;
21811         LDKCVec_u8Z ret_var = ChannelTransactionParameters_write(&obj_conv);
21812         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21813         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21814         CVec_u8Z_free(ret_var);
21815         return ret_arr;
21816 }
21817
21818 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21819         LDKu8slice ser_ref;
21820         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21821         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21822         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
21823         *ret_conv = ChannelTransactionParameters_read(ser_ref);
21824         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21825         return (uint64_t)ret_conv;
21826 }
21827
21828 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
21829         LDKDirectedChannelTransactionParameters this_obj_conv;
21830         this_obj_conv.inner = (void*)(this_obj & (~1));
21831         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21832         DirectedChannelTransactionParameters_free(this_obj_conv);
21833 }
21834
21835 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1broadcaster_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
21836         LDKDirectedChannelTransactionParameters this_arg_conv;
21837         this_arg_conv.inner = (void*)(this_arg & (~1));
21838         this_arg_conv.is_owned = false;
21839         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_broadcaster_pubkeys(&this_arg_conv);
21840         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21841         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21842         uint64_t ret_ref = (uint64_t)ret_var.inner;
21843         if (ret_var.is_owned) {
21844                 ret_ref |= 1;
21845         }
21846         return ret_ref;
21847 }
21848
21849 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1countersignatory_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
21850         LDKDirectedChannelTransactionParameters this_arg_conv;
21851         this_arg_conv.inner = (void*)(this_arg & (~1));
21852         this_arg_conv.is_owned = false;
21853         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_countersignatory_pubkeys(&this_arg_conv);
21854         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21855         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21856         uint64_t ret_ref = (uint64_t)ret_var.inner;
21857         if (ret_var.is_owned) {
21858                 ret_ref |= 1;
21859         }
21860         return ret_ref;
21861 }
21862
21863 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
21864         LDKDirectedChannelTransactionParameters this_arg_conv;
21865         this_arg_conv.inner = (void*)(this_arg & (~1));
21866         this_arg_conv.is_owned = false;
21867         int16_t ret_val = DirectedChannelTransactionParameters_contest_delay(&this_arg_conv);
21868         return ret_val;
21869 }
21870
21871 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_arg) {
21872         LDKDirectedChannelTransactionParameters this_arg_conv;
21873         this_arg_conv.inner = (void*)(this_arg & (~1));
21874         this_arg_conv.is_owned = false;
21875         jboolean ret_val = DirectedChannelTransactionParameters_is_outbound(&this_arg_conv);
21876         return ret_val;
21877 }
21878
21879 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_arg) {
21880         LDKDirectedChannelTransactionParameters this_arg_conv;
21881         this_arg_conv.inner = (void*)(this_arg & (~1));
21882         this_arg_conv.is_owned = false;
21883         LDKOutPoint ret_var = DirectedChannelTransactionParameters_funding_outpoint(&this_arg_conv);
21884         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21885         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21886         uint64_t ret_ref = (uint64_t)ret_var.inner;
21887         if (ret_var.is_owned) {
21888                 ret_ref |= 1;
21889         }
21890         return ret_ref;
21891 }
21892
21893 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
21894         LDKHolderCommitmentTransaction this_obj_conv;
21895         this_obj_conv.inner = (void*)(this_obj & (~1));
21896         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21897         HolderCommitmentTransaction_free(this_obj_conv);
21898 }
21899
21900 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1get_1counterparty_1sig(JNIEnv *env, jclass clz, int64_t this_ptr) {
21901         LDKHolderCommitmentTransaction this_ptr_conv;
21902         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21903         this_ptr_conv.is_owned = false;
21904         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
21905         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, HolderCommitmentTransaction_get_counterparty_sig(&this_ptr_conv).compact_form);
21906         return ret_arr;
21907 }
21908
21909 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1counterparty_1sig(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21910         LDKHolderCommitmentTransaction this_ptr_conv;
21911         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21912         this_ptr_conv.is_owned = false;
21913         LDKSignature val_ref;
21914         CHECK((*env)->GetArrayLength(env, val) == 64);
21915         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
21916         HolderCommitmentTransaction_set_counterparty_sig(&this_ptr_conv, val_ref);
21917 }
21918
21919 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1counterparty_1htlc_1sigs(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
21920         LDKHolderCommitmentTransaction this_ptr_conv;
21921         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21922         this_ptr_conv.is_owned = false;
21923         LDKCVec_SignatureZ val_constr;
21924         val_constr.datalen = (*env)->GetArrayLength(env, val);
21925         if (val_constr.datalen > 0)
21926                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
21927         else
21928                 val_constr.data = NULL;
21929         for (size_t i = 0; i < val_constr.datalen; i++) {
21930                 int8_tArray val_conv_8 = (*env)->GetObjectArrayElement(env, val, i);
21931                 LDKSignature val_conv_8_ref;
21932                 CHECK((*env)->GetArrayLength(env, val_conv_8) == 64);
21933                 (*env)->GetByteArrayRegion(env, val_conv_8, 0, 64, val_conv_8_ref.compact_form);
21934                 val_constr.data[i] = val_conv_8_ref;
21935         }
21936         HolderCommitmentTransaction_set_counterparty_htlc_sigs(&this_ptr_conv, val_constr);
21937 }
21938
21939 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21940         LDKHolderCommitmentTransaction orig_conv;
21941         orig_conv.inner = (void*)(orig & (~1));
21942         orig_conv.is_owned = false;
21943         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(&orig_conv);
21944         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21945         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21946         uint64_t ret_ref = (uint64_t)ret_var.inner;
21947         if (ret_var.is_owned) {
21948                 ret_ref |= 1;
21949         }
21950         return ret_ref;
21951 }
21952
21953 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
21954         LDKHolderCommitmentTransaction obj_conv;
21955         obj_conv.inner = (void*)(obj & (~1));
21956         obj_conv.is_owned = false;
21957         LDKCVec_u8Z ret_var = HolderCommitmentTransaction_write(&obj_conv);
21958         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21959         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21960         CVec_u8Z_free(ret_var);
21961         return ret_arr;
21962 }
21963
21964 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21965         LDKu8slice ser_ref;
21966         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21967         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21968         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
21969         *ret_conv = HolderCommitmentTransaction_read(ser_ref);
21970         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21971         return (uint64_t)ret_conv;
21972 }
21973
21974 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) {
21975         LDKCommitmentTransaction commitment_tx_conv;
21976         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
21977         commitment_tx_conv.is_owned = (commitment_tx & 1) || (commitment_tx == 0);
21978         commitment_tx_conv = CommitmentTransaction_clone(&commitment_tx_conv);
21979         LDKSignature counterparty_sig_ref;
21980         CHECK((*env)->GetArrayLength(env, counterparty_sig) == 64);
21981         (*env)->GetByteArrayRegion(env, counterparty_sig, 0, 64, counterparty_sig_ref.compact_form);
21982         LDKCVec_SignatureZ counterparty_htlc_sigs_constr;
21983         counterparty_htlc_sigs_constr.datalen = (*env)->GetArrayLength(env, counterparty_htlc_sigs);
21984         if (counterparty_htlc_sigs_constr.datalen > 0)
21985                 counterparty_htlc_sigs_constr.data = MALLOC(counterparty_htlc_sigs_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
21986         else
21987                 counterparty_htlc_sigs_constr.data = NULL;
21988         for (size_t i = 0; i < counterparty_htlc_sigs_constr.datalen; i++) {
21989                 int8_tArray counterparty_htlc_sigs_conv_8 = (*env)->GetObjectArrayElement(env, counterparty_htlc_sigs, i);
21990                 LDKSignature counterparty_htlc_sigs_conv_8_ref;
21991                 CHECK((*env)->GetArrayLength(env, counterparty_htlc_sigs_conv_8) == 64);
21992                 (*env)->GetByteArrayRegion(env, counterparty_htlc_sigs_conv_8, 0, 64, counterparty_htlc_sigs_conv_8_ref.compact_form);
21993                 counterparty_htlc_sigs_constr.data[i] = counterparty_htlc_sigs_conv_8_ref;
21994         }
21995         LDKPublicKey holder_funding_key_ref;
21996         CHECK((*env)->GetArrayLength(env, holder_funding_key) == 33);
21997         (*env)->GetByteArrayRegion(env, holder_funding_key, 0, 33, holder_funding_key_ref.compressed_form);
21998         LDKPublicKey counterparty_funding_key_ref;
21999         CHECK((*env)->GetArrayLength(env, counterparty_funding_key) == 33);
22000         (*env)->GetByteArrayRegion(env, counterparty_funding_key, 0, 33, counterparty_funding_key_ref.compressed_form);
22001         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_new(commitment_tx_conv, counterparty_sig_ref, counterparty_htlc_sigs_constr, holder_funding_key_ref, counterparty_funding_key_ref);
22002         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22003         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22004         uint64_t ret_ref = (uint64_t)ret_var.inner;
22005         if (ret_var.is_owned) {
22006                 ret_ref |= 1;
22007         }
22008         return ret_ref;
22009 }
22010
22011 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22012         LDKBuiltCommitmentTransaction this_obj_conv;
22013         this_obj_conv.inner = (void*)(this_obj & (~1));
22014         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22015         BuiltCommitmentTransaction_free(this_obj_conv);
22016 }
22017
22018 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1get_1transaction(JNIEnv *env, jclass clz, int64_t this_ptr) {
22019         LDKBuiltCommitmentTransaction this_ptr_conv;
22020         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22021         this_ptr_conv.is_owned = false;
22022         LDKTransaction ret_var = BuiltCommitmentTransaction_get_transaction(&this_ptr_conv);
22023         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22024         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22025         Transaction_free(ret_var);
22026         return ret_arr;
22027 }
22028
22029 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1set_1transaction(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22030         LDKBuiltCommitmentTransaction this_ptr_conv;
22031         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22032         this_ptr_conv.is_owned = false;
22033         LDKTransaction val_ref;
22034         val_ref.datalen = (*env)->GetArrayLength(env, val);
22035         val_ref.data = MALLOC(val_ref.datalen, "LDKTransaction Bytes");
22036         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
22037         val_ref.data_is_owned = true;
22038         BuiltCommitmentTransaction_set_transaction(&this_ptr_conv, val_ref);
22039 }
22040
22041 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1get_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
22042         LDKBuiltCommitmentTransaction this_ptr_conv;
22043         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22044         this_ptr_conv.is_owned = false;
22045         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
22046         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *BuiltCommitmentTransaction_get_txid(&this_ptr_conv));
22047         return ret_arr;
22048 }
22049
22050 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1set_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22051         LDKBuiltCommitmentTransaction this_ptr_conv;
22052         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22053         this_ptr_conv.is_owned = false;
22054         LDKThirtyTwoBytes val_ref;
22055         CHECK((*env)->GetArrayLength(env, val) == 32);
22056         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
22057         BuiltCommitmentTransaction_set_txid(&this_ptr_conv, val_ref);
22058 }
22059
22060 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1new(JNIEnv *env, jclass clz, int8_tArray transaction_arg, int8_tArray txid_arg) {
22061         LDKTransaction transaction_arg_ref;
22062         transaction_arg_ref.datalen = (*env)->GetArrayLength(env, transaction_arg);
22063         transaction_arg_ref.data = MALLOC(transaction_arg_ref.datalen, "LDKTransaction Bytes");
22064         (*env)->GetByteArrayRegion(env, transaction_arg, 0, transaction_arg_ref.datalen, transaction_arg_ref.data);
22065         transaction_arg_ref.data_is_owned = true;
22066         LDKThirtyTwoBytes txid_arg_ref;
22067         CHECK((*env)->GetArrayLength(env, txid_arg) == 32);
22068         (*env)->GetByteArrayRegion(env, txid_arg, 0, 32, txid_arg_ref.data);
22069         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_new(transaction_arg_ref, txid_arg_ref);
22070         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22071         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22072         uint64_t ret_ref = (uint64_t)ret_var.inner;
22073         if (ret_var.is_owned) {
22074                 ret_ref |= 1;
22075         }
22076         return ret_ref;
22077 }
22078
22079 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22080         LDKBuiltCommitmentTransaction orig_conv;
22081         orig_conv.inner = (void*)(orig & (~1));
22082         orig_conv.is_owned = false;
22083         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(&orig_conv);
22084         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22085         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22086         uint64_t ret_ref = (uint64_t)ret_var.inner;
22087         if (ret_var.is_owned) {
22088                 ret_ref |= 1;
22089         }
22090         return ret_ref;
22091 }
22092
22093 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
22094         LDKBuiltCommitmentTransaction obj_conv;
22095         obj_conv.inner = (void*)(obj & (~1));
22096         obj_conv.is_owned = false;
22097         LDKCVec_u8Z ret_var = BuiltCommitmentTransaction_write(&obj_conv);
22098         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22099         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22100         CVec_u8Z_free(ret_var);
22101         return ret_arr;
22102 }
22103
22104 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
22105         LDKu8slice ser_ref;
22106         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
22107         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
22108         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
22109         *ret_conv = BuiltCommitmentTransaction_read(ser_ref);
22110         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
22111         return (uint64_t)ret_conv;
22112 }
22113
22114 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) {
22115         LDKBuiltCommitmentTransaction this_arg_conv;
22116         this_arg_conv.inner = (void*)(this_arg & (~1));
22117         this_arg_conv.is_owned = false;
22118         LDKu8slice funding_redeemscript_ref;
22119         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
22120         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
22121         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
22122         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, BuiltCommitmentTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data);
22123         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
22124         return ret_arr;
22125 }
22126
22127 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) {
22128         LDKBuiltCommitmentTransaction this_arg_conv;
22129         this_arg_conv.inner = (void*)(this_arg & (~1));
22130         this_arg_conv.is_owned = false;
22131         unsigned char funding_key_arr[32];
22132         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
22133         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_arr);
22134         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
22135         LDKu8slice funding_redeemscript_ref;
22136         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
22137         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
22138         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
22139         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, BuiltCommitmentTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form);
22140         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
22141         return ret_arr;
22142 }
22143
22144 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22145         LDKCommitmentTransaction this_obj_conv;
22146         this_obj_conv.inner = (void*)(this_obj & (~1));
22147         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22148         CommitmentTransaction_free(this_obj_conv);
22149 }
22150
22151 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22152         LDKCommitmentTransaction orig_conv;
22153         orig_conv.inner = (void*)(orig & (~1));
22154         orig_conv.is_owned = false;
22155         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(&orig_conv);
22156         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22157         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22158         uint64_t ret_ref = (uint64_t)ret_var.inner;
22159         if (ret_var.is_owned) {
22160                 ret_ref |= 1;
22161         }
22162         return ret_ref;
22163 }
22164
22165 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
22166         LDKCommitmentTransaction obj_conv;
22167         obj_conv.inner = (void*)(obj & (~1));
22168         obj_conv.is_owned = false;
22169         LDKCVec_u8Z ret_var = CommitmentTransaction_write(&obj_conv);
22170         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22171         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22172         CVec_u8Z_free(ret_var);
22173         return ret_arr;
22174 }
22175
22176 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
22177         LDKu8slice ser_ref;
22178         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
22179         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
22180         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
22181         *ret_conv = CommitmentTransaction_read(ser_ref);
22182         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
22183         return (uint64_t)ret_conv;
22184 }
22185
22186 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_arg) {
22187         LDKCommitmentTransaction this_arg_conv;
22188         this_arg_conv.inner = (void*)(this_arg & (~1));
22189         this_arg_conv.is_owned = false;
22190         int64_t ret_val = CommitmentTransaction_commitment_number(&this_arg_conv);
22191         return ret_val;
22192 }
22193
22194 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1to_1broadcaster_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
22195         LDKCommitmentTransaction this_arg_conv;
22196         this_arg_conv.inner = (void*)(this_arg & (~1));
22197         this_arg_conv.is_owned = false;
22198         int64_t ret_val = CommitmentTransaction_to_broadcaster_value_sat(&this_arg_conv);
22199         return ret_val;
22200 }
22201
22202 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1to_1countersignatory_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
22203         LDKCommitmentTransaction this_arg_conv;
22204         this_arg_conv.inner = (void*)(this_arg & (~1));
22205         this_arg_conv.is_owned = false;
22206         int64_t ret_val = CommitmentTransaction_to_countersignatory_value_sat(&this_arg_conv);
22207         return ret_val;
22208 }
22209
22210 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_arg) {
22211         LDKCommitmentTransaction this_arg_conv;
22212         this_arg_conv.inner = (void*)(this_arg & (~1));
22213         this_arg_conv.is_owned = false;
22214         int32_t ret_val = CommitmentTransaction_feerate_per_kw(&this_arg_conv);
22215         return ret_val;
22216 }
22217
22218 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1trust(JNIEnv *env, jclass clz, int64_t this_arg) {
22219         LDKCommitmentTransaction this_arg_conv;
22220         this_arg_conv.inner = (void*)(this_arg & (~1));
22221         this_arg_conv.is_owned = false;
22222         LDKTrustedCommitmentTransaction ret_var = CommitmentTransaction_trust(&this_arg_conv);
22223         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22224         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22225         uint64_t ret_ref = (uint64_t)ret_var.inner;
22226         if (ret_var.is_owned) {
22227                 ret_ref |= 1;
22228         }
22229         return ret_ref;
22230 }
22231
22232 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) {
22233         LDKCommitmentTransaction this_arg_conv;
22234         this_arg_conv.inner = (void*)(this_arg & (~1));
22235         this_arg_conv.is_owned = false;
22236         LDKDirectedChannelTransactionParameters channel_parameters_conv;
22237         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
22238         channel_parameters_conv.is_owned = false;
22239         LDKChannelPublicKeys broadcaster_keys_conv;
22240         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
22241         broadcaster_keys_conv.is_owned = false;
22242         LDKChannelPublicKeys countersignatory_keys_conv;
22243         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
22244         countersignatory_keys_conv.is_owned = false;
22245         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
22246         *ret_conv = CommitmentTransaction_verify(&this_arg_conv, &channel_parameters_conv, &broadcaster_keys_conv, &countersignatory_keys_conv);
22247         return (uint64_t)ret_conv;
22248 }
22249
22250 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22251         LDKTrustedCommitmentTransaction this_obj_conv;
22252         this_obj_conv.inner = (void*)(this_obj & (~1));
22253         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22254         TrustedCommitmentTransaction_free(this_obj_conv);
22255 }
22256
22257 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1txid(JNIEnv *env, jclass clz, int64_t this_arg) {
22258         LDKTrustedCommitmentTransaction this_arg_conv;
22259         this_arg_conv.inner = (void*)(this_arg & (~1));
22260         this_arg_conv.is_owned = false;
22261         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
22262         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, TrustedCommitmentTransaction_txid(&this_arg_conv).data);
22263         return ret_arr;
22264 }
22265
22266 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1built_1transaction(JNIEnv *env, jclass clz, int64_t this_arg) {
22267         LDKTrustedCommitmentTransaction this_arg_conv;
22268         this_arg_conv.inner = (void*)(this_arg & (~1));
22269         this_arg_conv.is_owned = false;
22270         LDKBuiltCommitmentTransaction ret_var = TrustedCommitmentTransaction_built_transaction(&this_arg_conv);
22271         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22272         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22273         uint64_t ret_ref = (uint64_t)ret_var.inner;
22274         if (ret_var.is_owned) {
22275                 ret_ref |= 1;
22276         }
22277         return ret_ref;
22278 }
22279
22280 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1keys(JNIEnv *env, jclass clz, int64_t this_arg) {
22281         LDKTrustedCommitmentTransaction this_arg_conv;
22282         this_arg_conv.inner = (void*)(this_arg & (~1));
22283         this_arg_conv.is_owned = false;
22284         LDKTxCreationKeys ret_var = TrustedCommitmentTransaction_keys(&this_arg_conv);
22285         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22286         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22287         uint64_t ret_ref = (uint64_t)ret_var.inner;
22288         if (ret_var.is_owned) {
22289                 ret_ref |= 1;
22290         }
22291         return ret_ref;
22292 }
22293
22294 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) {
22295         LDKTrustedCommitmentTransaction this_arg_conv;
22296         this_arg_conv.inner = (void*)(this_arg & (~1));
22297         this_arg_conv.is_owned = false;
22298         unsigned char htlc_base_key_arr[32];
22299         CHECK((*env)->GetArrayLength(env, htlc_base_key) == 32);
22300         (*env)->GetByteArrayRegion(env, htlc_base_key, 0, 32, htlc_base_key_arr);
22301         unsigned char (*htlc_base_key_ref)[32] = &htlc_base_key_arr;
22302         LDKDirectedChannelTransactionParameters channel_parameters_conv;
22303         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
22304         channel_parameters_conv.is_owned = false;
22305         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
22306         *ret_conv = TrustedCommitmentTransaction_get_htlc_sigs(&this_arg_conv, htlc_base_key_ref, &channel_parameters_conv);
22307         return (uint64_t)ret_conv;
22308 }
22309
22310 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) {
22311         LDKPublicKey broadcaster_payment_basepoint_ref;
22312         CHECK((*env)->GetArrayLength(env, broadcaster_payment_basepoint) == 33);
22313         (*env)->GetByteArrayRegion(env, broadcaster_payment_basepoint, 0, 33, broadcaster_payment_basepoint_ref.compressed_form);
22314         LDKPublicKey countersignatory_payment_basepoint_ref;
22315         CHECK((*env)->GetArrayLength(env, countersignatory_payment_basepoint) == 33);
22316         (*env)->GetByteArrayRegion(env, countersignatory_payment_basepoint, 0, 33, countersignatory_payment_basepoint_ref.compressed_form);
22317         int64_t ret_val = get_commitment_transaction_number_obscure_factor(broadcaster_payment_basepoint_ref, countersignatory_payment_basepoint_ref, outbound_from_broadcaster);
22318         return ret_val;
22319 }
22320
22321 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
22322         LDKInitFeatures a_conv;
22323         a_conv.inner = (void*)(a & (~1));
22324         a_conv.is_owned = false;
22325         LDKInitFeatures b_conv;
22326         b_conv.inner = (void*)(b & (~1));
22327         b_conv.is_owned = false;
22328         jboolean ret_val = InitFeatures_eq(&a_conv, &b_conv);
22329         return ret_val;
22330 }
22331
22332 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
22333         LDKNodeFeatures a_conv;
22334         a_conv.inner = (void*)(a & (~1));
22335         a_conv.is_owned = false;
22336         LDKNodeFeatures b_conv;
22337         b_conv.inner = (void*)(b & (~1));
22338         b_conv.is_owned = false;
22339         jboolean ret_val = NodeFeatures_eq(&a_conv, &b_conv);
22340         return ret_val;
22341 }
22342
22343 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
22344         LDKChannelFeatures a_conv;
22345         a_conv.inner = (void*)(a & (~1));
22346         a_conv.is_owned = false;
22347         LDKChannelFeatures b_conv;
22348         b_conv.inner = (void*)(b & (~1));
22349         b_conv.is_owned = false;
22350         jboolean ret_val = ChannelFeatures_eq(&a_conv, &b_conv);
22351         return ret_val;
22352 }
22353
22354 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
22355         LDKInvoiceFeatures a_conv;
22356         a_conv.inner = (void*)(a & (~1));
22357         a_conv.is_owned = false;
22358         LDKInvoiceFeatures b_conv;
22359         b_conv.inner = (void*)(b & (~1));
22360         b_conv.is_owned = false;
22361         jboolean ret_val = InvoiceFeatures_eq(&a_conv, &b_conv);
22362         return ret_val;
22363 }
22364
22365 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22366         LDKInitFeatures orig_conv;
22367         orig_conv.inner = (void*)(orig & (~1));
22368         orig_conv.is_owned = false;
22369         LDKInitFeatures ret_var = InitFeatures_clone(&orig_conv);
22370         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22371         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22372         uint64_t ret_ref = (uint64_t)ret_var.inner;
22373         if (ret_var.is_owned) {
22374                 ret_ref |= 1;
22375         }
22376         return ret_ref;
22377 }
22378
22379 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22380         LDKNodeFeatures orig_conv;
22381         orig_conv.inner = (void*)(orig & (~1));
22382         orig_conv.is_owned = false;
22383         LDKNodeFeatures ret_var = NodeFeatures_clone(&orig_conv);
22384         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22385         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22386         uint64_t ret_ref = (uint64_t)ret_var.inner;
22387         if (ret_var.is_owned) {
22388                 ret_ref |= 1;
22389         }
22390         return ret_ref;
22391 }
22392
22393 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22394         LDKChannelFeatures orig_conv;
22395         orig_conv.inner = (void*)(orig & (~1));
22396         orig_conv.is_owned = false;
22397         LDKChannelFeatures ret_var = ChannelFeatures_clone(&orig_conv);
22398         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22399         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22400         uint64_t ret_ref = (uint64_t)ret_var.inner;
22401         if (ret_var.is_owned) {
22402                 ret_ref |= 1;
22403         }
22404         return ret_ref;
22405 }
22406
22407 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22408         LDKInvoiceFeatures orig_conv;
22409         orig_conv.inner = (void*)(orig & (~1));
22410         orig_conv.is_owned = false;
22411         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(&orig_conv);
22412         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22413         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22414         uint64_t ret_ref = (uint64_t)ret_var.inner;
22415         if (ret_var.is_owned) {
22416                 ret_ref |= 1;
22417         }
22418         return ret_ref;
22419 }
22420
22421 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22422         LDKInitFeatures this_obj_conv;
22423         this_obj_conv.inner = (void*)(this_obj & (~1));
22424         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22425         InitFeatures_free(this_obj_conv);
22426 }
22427
22428 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22429         LDKNodeFeatures this_obj_conv;
22430         this_obj_conv.inner = (void*)(this_obj & (~1));
22431         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22432         NodeFeatures_free(this_obj_conv);
22433 }
22434
22435 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22436         LDKChannelFeatures this_obj_conv;
22437         this_obj_conv.inner = (void*)(this_obj & (~1));
22438         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22439         ChannelFeatures_free(this_obj_conv);
22440 }
22441
22442 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22443         LDKInvoiceFeatures this_obj_conv;
22444         this_obj_conv.inner = (void*)(this_obj & (~1));
22445         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22446         InvoiceFeatures_free(this_obj_conv);
22447 }
22448
22449 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1empty(JNIEnv *env, jclass clz) {
22450         LDKInitFeatures ret_var = InitFeatures_empty();
22451         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22452         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22453         uint64_t ret_ref = (uint64_t)ret_var.inner;
22454         if (ret_var.is_owned) {
22455                 ret_ref |= 1;
22456         }
22457         return ret_ref;
22458 }
22459
22460 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1known(JNIEnv *env, jclass clz) {
22461         LDKInitFeatures ret_var = InitFeatures_known();
22462         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22463         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22464         uint64_t ret_ref = (uint64_t)ret_var.inner;
22465         if (ret_var.is_owned) {
22466                 ret_ref |= 1;
22467         }
22468         return ret_ref;
22469 }
22470
22471 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1empty(JNIEnv *env, jclass clz) {
22472         LDKNodeFeatures ret_var = NodeFeatures_empty();
22473         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22474         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22475         uint64_t ret_ref = (uint64_t)ret_var.inner;
22476         if (ret_var.is_owned) {
22477                 ret_ref |= 1;
22478         }
22479         return ret_ref;
22480 }
22481
22482 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1known(JNIEnv *env, jclass clz) {
22483         LDKNodeFeatures ret_var = NodeFeatures_known();
22484         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22485         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22486         uint64_t ret_ref = (uint64_t)ret_var.inner;
22487         if (ret_var.is_owned) {
22488                 ret_ref |= 1;
22489         }
22490         return ret_ref;
22491 }
22492
22493 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1empty(JNIEnv *env, jclass clz) {
22494         LDKChannelFeatures ret_var = ChannelFeatures_empty();
22495         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22496         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22497         uint64_t ret_ref = (uint64_t)ret_var.inner;
22498         if (ret_var.is_owned) {
22499                 ret_ref |= 1;
22500         }
22501         return ret_ref;
22502 }
22503
22504 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1known(JNIEnv *env, jclass clz) {
22505         LDKChannelFeatures ret_var = ChannelFeatures_known();
22506         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22507         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22508         uint64_t ret_ref = (uint64_t)ret_var.inner;
22509         if (ret_var.is_owned) {
22510                 ret_ref |= 1;
22511         }
22512         return ret_ref;
22513 }
22514
22515 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1empty(JNIEnv *env, jclass clz) {
22516         LDKInvoiceFeatures ret_var = InvoiceFeatures_empty();
22517         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22518         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22519         uint64_t ret_ref = (uint64_t)ret_var.inner;
22520         if (ret_var.is_owned) {
22521                 ret_ref |= 1;
22522         }
22523         return ret_ref;
22524 }
22525
22526 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1known(JNIEnv *env, jclass clz) {
22527         LDKInvoiceFeatures ret_var = InvoiceFeatures_known();
22528         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22529         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22530         uint64_t ret_ref = (uint64_t)ret_var.inner;
22531         if (ret_var.is_owned) {
22532                 ret_ref |= 1;
22533         }
22534         return ret_ref;
22535 }
22536
22537 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
22538         LDKInitFeatures this_arg_conv;
22539         this_arg_conv.inner = (void*)(this_arg & (~1));
22540         this_arg_conv.is_owned = false;
22541         jboolean ret_val = InitFeatures_supports_payment_secret(&this_arg_conv);
22542         return ret_val;
22543 }
22544
22545 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
22546         LDKNodeFeatures this_arg_conv;
22547         this_arg_conv.inner = (void*)(this_arg & (~1));
22548         this_arg_conv.is_owned = false;
22549         jboolean ret_val = NodeFeatures_supports_payment_secret(&this_arg_conv);
22550         return ret_val;
22551 }
22552
22553 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1supports_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
22554         LDKInvoiceFeatures this_arg_conv;
22555         this_arg_conv.inner = (void*)(this_arg & (~1));
22556         this_arg_conv.is_owned = false;
22557         jboolean ret_val = InvoiceFeatures_supports_payment_secret(&this_arg_conv);
22558         return ret_val;
22559 }
22560
22561 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InitFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
22562         LDKInitFeatures obj_conv;
22563         obj_conv.inner = (void*)(obj & (~1));
22564         obj_conv.is_owned = false;
22565         LDKCVec_u8Z ret_var = InitFeatures_write(&obj_conv);
22566         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22567         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22568         CVec_u8Z_free(ret_var);
22569         return ret_arr;
22570 }
22571
22572 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
22573         LDKNodeFeatures obj_conv;
22574         obj_conv.inner = (void*)(obj & (~1));
22575         obj_conv.is_owned = false;
22576         LDKCVec_u8Z ret_var = NodeFeatures_write(&obj_conv);
22577         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22578         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22579         CVec_u8Z_free(ret_var);
22580         return ret_arr;
22581 }
22582
22583 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
22584         LDKChannelFeatures obj_conv;
22585         obj_conv.inner = (void*)(obj & (~1));
22586         obj_conv.is_owned = false;
22587         LDKCVec_u8Z ret_var = ChannelFeatures_write(&obj_conv);
22588         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22589         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22590         CVec_u8Z_free(ret_var);
22591         return ret_arr;
22592 }
22593
22594 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
22595         LDKInvoiceFeatures obj_conv;
22596         obj_conv.inner = (void*)(obj & (~1));
22597         obj_conv.is_owned = false;
22598         LDKCVec_u8Z ret_var = InvoiceFeatures_write(&obj_conv);
22599         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22600         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22601         CVec_u8Z_free(ret_var);
22602         return ret_arr;
22603 }
22604
22605 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
22606         LDKu8slice ser_ref;
22607         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
22608         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
22609         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
22610         *ret_conv = InitFeatures_read(ser_ref);
22611         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
22612         return (uint64_t)ret_conv;
22613 }
22614
22615 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
22616         LDKu8slice ser_ref;
22617         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
22618         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
22619         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
22620         *ret_conv = NodeFeatures_read(ser_ref);
22621         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
22622         return (uint64_t)ret_conv;
22623 }
22624
22625 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
22626         LDKu8slice ser_ref;
22627         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
22628         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
22629         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
22630         *ret_conv = ChannelFeatures_read(ser_ref);
22631         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
22632         return (uint64_t)ret_conv;
22633 }
22634
22635 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
22636         LDKu8slice ser_ref;
22637         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
22638         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
22639         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
22640         *ret_conv = InvoiceFeatures_read(ser_ref);
22641         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
22642         return (uint64_t)ret_conv;
22643 }
22644
22645 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22646         LDKRouteHop this_obj_conv;
22647         this_obj_conv.inner = (void*)(this_obj & (~1));
22648         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22649         RouteHop_free(this_obj_conv);
22650 }
22651
22652 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
22653         LDKRouteHop this_ptr_conv;
22654         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22655         this_ptr_conv.is_owned = false;
22656         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
22657         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RouteHop_get_pubkey(&this_ptr_conv).compressed_form);
22658         return ret_arr;
22659 }
22660
22661 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22662         LDKRouteHop this_ptr_conv;
22663         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22664         this_ptr_conv.is_owned = false;
22665         LDKPublicKey val_ref;
22666         CHECK((*env)->GetArrayLength(env, val) == 33);
22667         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
22668         RouteHop_set_pubkey(&this_ptr_conv, val_ref);
22669 }
22670
22671 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1node_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
22672         LDKRouteHop this_ptr_conv;
22673         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22674         this_ptr_conv.is_owned = false;
22675         LDKNodeFeatures ret_var = RouteHop_get_node_features(&this_ptr_conv);
22676         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22677         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22678         uint64_t ret_ref = (uint64_t)ret_var.inner;
22679         if (ret_var.is_owned) {
22680                 ret_ref |= 1;
22681         }
22682         return ret_ref;
22683 }
22684
22685 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1node_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
22686         LDKRouteHop this_ptr_conv;
22687         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22688         this_ptr_conv.is_owned = false;
22689         LDKNodeFeatures val_conv;
22690         val_conv.inner = (void*)(val & (~1));
22691         val_conv.is_owned = (val & 1) || (val == 0);
22692         val_conv = NodeFeatures_clone(&val_conv);
22693         RouteHop_set_node_features(&this_ptr_conv, val_conv);
22694 }
22695
22696 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
22697         LDKRouteHop this_ptr_conv;
22698         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22699         this_ptr_conv.is_owned = false;
22700         int64_t ret_val = RouteHop_get_short_channel_id(&this_ptr_conv);
22701         return ret_val;
22702 }
22703
22704 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
22705         LDKRouteHop this_ptr_conv;
22706         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22707         this_ptr_conv.is_owned = false;
22708         RouteHop_set_short_channel_id(&this_ptr_conv, val);
22709 }
22710
22711 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1channel_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
22712         LDKRouteHop this_ptr_conv;
22713         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22714         this_ptr_conv.is_owned = false;
22715         LDKChannelFeatures ret_var = RouteHop_get_channel_features(&this_ptr_conv);
22716         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22717         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22718         uint64_t ret_ref = (uint64_t)ret_var.inner;
22719         if (ret_var.is_owned) {
22720                 ret_ref |= 1;
22721         }
22722         return ret_ref;
22723 }
22724
22725 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1channel_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
22726         LDKRouteHop this_ptr_conv;
22727         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22728         this_ptr_conv.is_owned = false;
22729         LDKChannelFeatures val_conv;
22730         val_conv.inner = (void*)(val & (~1));
22731         val_conv.is_owned = (val & 1) || (val == 0);
22732         val_conv = ChannelFeatures_clone(&val_conv);
22733         RouteHop_set_channel_features(&this_ptr_conv, val_conv);
22734 }
22735
22736 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1fee_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
22737         LDKRouteHop this_ptr_conv;
22738         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22739         this_ptr_conv.is_owned = false;
22740         int64_t ret_val = RouteHop_get_fee_msat(&this_ptr_conv);
22741         return ret_val;
22742 }
22743
22744 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1fee_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
22745         LDKRouteHop this_ptr_conv;
22746         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22747         this_ptr_conv.is_owned = false;
22748         RouteHop_set_fee_msat(&this_ptr_conv, val);
22749 }
22750
22751 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
22752         LDKRouteHop this_ptr_conv;
22753         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22754         this_ptr_conv.is_owned = false;
22755         int32_t ret_val = RouteHop_get_cltv_expiry_delta(&this_ptr_conv);
22756         return ret_val;
22757 }
22758
22759 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
22760         LDKRouteHop this_ptr_conv;
22761         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22762         this_ptr_conv.is_owned = false;
22763         RouteHop_set_cltv_expiry_delta(&this_ptr_conv, val);
22764 }
22765
22766 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) {
22767         LDKPublicKey pubkey_arg_ref;
22768         CHECK((*env)->GetArrayLength(env, pubkey_arg) == 33);
22769         (*env)->GetByteArrayRegion(env, pubkey_arg, 0, 33, pubkey_arg_ref.compressed_form);
22770         LDKNodeFeatures node_features_arg_conv;
22771         node_features_arg_conv.inner = (void*)(node_features_arg & (~1));
22772         node_features_arg_conv.is_owned = (node_features_arg & 1) || (node_features_arg == 0);
22773         node_features_arg_conv = NodeFeatures_clone(&node_features_arg_conv);
22774         LDKChannelFeatures channel_features_arg_conv;
22775         channel_features_arg_conv.inner = (void*)(channel_features_arg & (~1));
22776         channel_features_arg_conv.is_owned = (channel_features_arg & 1) || (channel_features_arg == 0);
22777         channel_features_arg_conv = ChannelFeatures_clone(&channel_features_arg_conv);
22778         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);
22779         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22780         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22781         uint64_t ret_ref = (uint64_t)ret_var.inner;
22782         if (ret_var.is_owned) {
22783                 ret_ref |= 1;
22784         }
22785         return ret_ref;
22786 }
22787
22788 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22789         LDKRouteHop orig_conv;
22790         orig_conv.inner = (void*)(orig & (~1));
22791         orig_conv.is_owned = false;
22792         LDKRouteHop ret_var = RouteHop_clone(&orig_conv);
22793         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22794         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22795         uint64_t ret_ref = (uint64_t)ret_var.inner;
22796         if (ret_var.is_owned) {
22797                 ret_ref |= 1;
22798         }
22799         return ret_ref;
22800 }
22801
22802 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHop_1write(JNIEnv *env, jclass clz, int64_t obj) {
22803         LDKRouteHop obj_conv;
22804         obj_conv.inner = (void*)(obj & (~1));
22805         obj_conv.is_owned = false;
22806         LDKCVec_u8Z ret_var = RouteHop_write(&obj_conv);
22807         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22808         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22809         CVec_u8Z_free(ret_var);
22810         return ret_arr;
22811 }
22812
22813 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
22814         LDKu8slice ser_ref;
22815         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
22816         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
22817         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
22818         *ret_conv = RouteHop_read(ser_ref);
22819         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
22820         return (uint64_t)ret_conv;
22821 }
22822
22823 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22824         LDKRoute this_obj_conv;
22825         this_obj_conv.inner = (void*)(this_obj & (~1));
22826         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22827         Route_free(this_obj_conv);
22828 }
22829
22830 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1set_1paths(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
22831         LDKRoute this_ptr_conv;
22832         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22833         this_ptr_conv.is_owned = false;
22834         LDKCVec_CVec_RouteHopZZ val_constr;
22835         val_constr.datalen = (*env)->GetArrayLength(env, val);
22836         if (val_constr.datalen > 0)
22837                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
22838         else
22839                 val_constr.data = NULL;
22840         for (size_t m = 0; m < val_constr.datalen; m++) {
22841                 int64_tArray val_conv_12 = (*env)->GetObjectArrayElement(env, val, m);
22842                 LDKCVec_RouteHopZ val_conv_12_constr;
22843                 val_conv_12_constr.datalen = (*env)->GetArrayLength(env, val_conv_12);
22844                 if (val_conv_12_constr.datalen > 0)
22845                         val_conv_12_constr.data = MALLOC(val_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
22846                 else
22847                         val_conv_12_constr.data = NULL;
22848                 int64_t* val_conv_12_vals = (*env)->GetLongArrayElements (env, val_conv_12, NULL);
22849                 for (size_t k = 0; k < val_conv_12_constr.datalen; k++) {
22850                         int64_t val_conv_12_conv_10 = val_conv_12_vals[k];
22851                         LDKRouteHop val_conv_12_conv_10_conv;
22852                         val_conv_12_conv_10_conv.inner = (void*)(val_conv_12_conv_10 & (~1));
22853                         val_conv_12_conv_10_conv.is_owned = (val_conv_12_conv_10 & 1) || (val_conv_12_conv_10 == 0);
22854                         val_conv_12_conv_10_conv = RouteHop_clone(&val_conv_12_conv_10_conv);
22855                         val_conv_12_constr.data[k] = val_conv_12_conv_10_conv;
22856                 }
22857                 (*env)->ReleaseLongArrayElements(env, val_conv_12, val_conv_12_vals, 0);
22858                 val_constr.data[m] = val_conv_12_constr;
22859         }
22860         Route_set_paths(&this_ptr_conv, val_constr);
22861 }
22862
22863 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1new(JNIEnv *env, jclass clz, jobjectArray paths_arg) {
22864         LDKCVec_CVec_RouteHopZZ paths_arg_constr;
22865         paths_arg_constr.datalen = (*env)->GetArrayLength(env, paths_arg);
22866         if (paths_arg_constr.datalen > 0)
22867                 paths_arg_constr.data = MALLOC(paths_arg_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
22868         else
22869                 paths_arg_constr.data = NULL;
22870         for (size_t m = 0; m < paths_arg_constr.datalen; m++) {
22871                 int64_tArray paths_arg_conv_12 = (*env)->GetObjectArrayElement(env, paths_arg, m);
22872                 LDKCVec_RouteHopZ paths_arg_conv_12_constr;
22873                 paths_arg_conv_12_constr.datalen = (*env)->GetArrayLength(env, paths_arg_conv_12);
22874                 if (paths_arg_conv_12_constr.datalen > 0)
22875                         paths_arg_conv_12_constr.data = MALLOC(paths_arg_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
22876                 else
22877                         paths_arg_conv_12_constr.data = NULL;
22878                 int64_t* paths_arg_conv_12_vals = (*env)->GetLongArrayElements (env, paths_arg_conv_12, NULL);
22879                 for (size_t k = 0; k < paths_arg_conv_12_constr.datalen; k++) {
22880                         int64_t paths_arg_conv_12_conv_10 = paths_arg_conv_12_vals[k];
22881                         LDKRouteHop paths_arg_conv_12_conv_10_conv;
22882                         paths_arg_conv_12_conv_10_conv.inner = (void*)(paths_arg_conv_12_conv_10 & (~1));
22883                         paths_arg_conv_12_conv_10_conv.is_owned = (paths_arg_conv_12_conv_10 & 1) || (paths_arg_conv_12_conv_10 == 0);
22884                         paths_arg_conv_12_conv_10_conv = RouteHop_clone(&paths_arg_conv_12_conv_10_conv);
22885                         paths_arg_conv_12_constr.data[k] = paths_arg_conv_12_conv_10_conv;
22886                 }
22887                 (*env)->ReleaseLongArrayElements(env, paths_arg_conv_12, paths_arg_conv_12_vals, 0);
22888                 paths_arg_constr.data[m] = paths_arg_conv_12_constr;
22889         }
22890         LDKRoute ret_var = Route_new(paths_arg_constr);
22891         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22892         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22893         uint64_t ret_ref = (uint64_t)ret_var.inner;
22894         if (ret_var.is_owned) {
22895                 ret_ref |= 1;
22896         }
22897         return ret_ref;
22898 }
22899
22900 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22901         LDKRoute orig_conv;
22902         orig_conv.inner = (void*)(orig & (~1));
22903         orig_conv.is_owned = false;
22904         LDKRoute ret_var = Route_clone(&orig_conv);
22905         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22906         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22907         uint64_t ret_ref = (uint64_t)ret_var.inner;
22908         if (ret_var.is_owned) {
22909                 ret_ref |= 1;
22910         }
22911         return ret_ref;
22912 }
22913
22914 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Route_1write(JNIEnv *env, jclass clz, int64_t obj) {
22915         LDKRoute obj_conv;
22916         obj_conv.inner = (void*)(obj & (~1));
22917         obj_conv.is_owned = false;
22918         LDKCVec_u8Z ret_var = Route_write(&obj_conv);
22919         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22920         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22921         CVec_u8Z_free(ret_var);
22922         return ret_arr;
22923 }
22924
22925 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
22926         LDKu8slice ser_ref;
22927         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
22928         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
22929         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
22930         *ret_conv = Route_read(ser_ref);
22931         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
22932         return (uint64_t)ret_conv;
22933 }
22934
22935 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22936         LDKRouteHint this_obj_conv;
22937         this_obj_conv.inner = (void*)(this_obj & (~1));
22938         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22939         RouteHint_free(this_obj_conv);
22940 }
22941
22942 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHint_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
22943         LDKRouteHint a_conv;
22944         a_conv.inner = (void*)(a & (~1));
22945         a_conv.is_owned = false;
22946         LDKRouteHint b_conv;
22947         b_conv.inner = (void*)(b & (~1));
22948         b_conv.is_owned = false;
22949         jboolean ret_val = RouteHint_eq(&a_conv, &b_conv);
22950         return ret_val;
22951 }
22952
22953 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22954         LDKRouteHint orig_conv;
22955         orig_conv.inner = (void*)(orig & (~1));
22956         orig_conv.is_owned = false;
22957         LDKRouteHint ret_var = RouteHint_clone(&orig_conv);
22958         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22959         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22960         uint64_t ret_ref = (uint64_t)ret_var.inner;
22961         if (ret_var.is_owned) {
22962                 ret_ref |= 1;
22963         }
22964         return ret_ref;
22965 }
22966
22967 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22968         LDKRouteHintHop this_obj_conv;
22969         this_obj_conv.inner = (void*)(this_obj & (~1));
22970         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22971         RouteHintHop_free(this_obj_conv);
22972 }
22973
22974 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1src_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
22975         LDKRouteHintHop this_ptr_conv;
22976         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22977         this_ptr_conv.is_owned = false;
22978         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
22979         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RouteHintHop_get_src_node_id(&this_ptr_conv).compressed_form);
22980         return ret_arr;
22981 }
22982
22983 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1src_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22984         LDKRouteHintHop this_ptr_conv;
22985         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22986         this_ptr_conv.is_owned = false;
22987         LDKPublicKey val_ref;
22988         CHECK((*env)->GetArrayLength(env, val) == 33);
22989         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
22990         RouteHintHop_set_src_node_id(&this_ptr_conv, val_ref);
22991 }
22992
22993 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
22994         LDKRouteHintHop this_ptr_conv;
22995         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22996         this_ptr_conv.is_owned = false;
22997         int64_t ret_val = RouteHintHop_get_short_channel_id(&this_ptr_conv);
22998         return ret_val;
22999 }
23000
23001 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23002         LDKRouteHintHop this_ptr_conv;
23003         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23004         this_ptr_conv.is_owned = false;
23005         RouteHintHop_set_short_channel_id(&this_ptr_conv, val);
23006 }
23007
23008 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
23009         LDKRouteHintHop this_ptr_conv;
23010         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23011         this_ptr_conv.is_owned = false;
23012         LDKRoutingFees ret_var = RouteHintHop_get_fees(&this_ptr_conv);
23013         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23014         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23015         uint64_t ret_ref = (uint64_t)ret_var.inner;
23016         if (ret_var.is_owned) {
23017                 ret_ref |= 1;
23018         }
23019         return ret_ref;
23020 }
23021
23022 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1fees(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23023         LDKRouteHintHop this_ptr_conv;
23024         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23025         this_ptr_conv.is_owned = false;
23026         LDKRoutingFees val_conv;
23027         val_conv.inner = (void*)(val & (~1));
23028         val_conv.is_owned = (val & 1) || (val == 0);
23029         val_conv = RoutingFees_clone(&val_conv);
23030         RouteHintHop_set_fees(&this_ptr_conv, val_conv);
23031 }
23032
23033 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
23034         LDKRouteHintHop this_ptr_conv;
23035         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23036         this_ptr_conv.is_owned = false;
23037         int16_t ret_val = RouteHintHop_get_cltv_expiry_delta(&this_ptr_conv);
23038         return ret_val;
23039 }
23040
23041 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
23042         LDKRouteHintHop this_ptr_conv;
23043         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23044         this_ptr_conv.is_owned = false;
23045         RouteHintHop_set_cltv_expiry_delta(&this_ptr_conv, val);
23046 }
23047
23048 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
23049         LDKRouteHintHop this_ptr_conv;
23050         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23051         this_ptr_conv.is_owned = false;
23052         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
23053         *ret_copy = RouteHintHop_get_htlc_minimum_msat(&this_ptr_conv);
23054         uint64_t ret_ref = (uint64_t)ret_copy;
23055         return ret_ref;
23056 }
23057
23058 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23059         LDKRouteHintHop this_ptr_conv;
23060         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23061         this_ptr_conv.is_owned = false;
23062         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
23063         RouteHintHop_set_htlc_minimum_msat(&this_ptr_conv, val_conv);
23064 }
23065
23066 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
23067         LDKRouteHintHop this_ptr_conv;
23068         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23069         this_ptr_conv.is_owned = false;
23070         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
23071         *ret_copy = RouteHintHop_get_htlc_maximum_msat(&this_ptr_conv);
23072         uint64_t ret_ref = (uint64_t)ret_copy;
23073         return ret_ref;
23074 }
23075
23076 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23077         LDKRouteHintHop this_ptr_conv;
23078         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23079         this_ptr_conv.is_owned = false;
23080         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
23081         RouteHintHop_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
23082 }
23083
23084 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) {
23085         LDKPublicKey src_node_id_arg_ref;
23086         CHECK((*env)->GetArrayLength(env, src_node_id_arg) == 33);
23087         (*env)->GetByteArrayRegion(env, src_node_id_arg, 0, 33, src_node_id_arg_ref.compressed_form);
23088         LDKRoutingFees fees_arg_conv;
23089         fees_arg_conv.inner = (void*)(fees_arg & (~1));
23090         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
23091         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
23092         LDKCOption_u64Z htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)htlc_minimum_msat_arg) & ~1);
23093         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)htlc_maximum_msat_arg) & ~1);
23094         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);
23095         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23096         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23097         uint64_t ret_ref = (uint64_t)ret_var.inner;
23098         if (ret_var.is_owned) {
23099                 ret_ref |= 1;
23100         }
23101         return ret_ref;
23102 }
23103
23104 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
23105         LDKRouteHintHop a_conv;
23106         a_conv.inner = (void*)(a & (~1));
23107         a_conv.is_owned = false;
23108         LDKRouteHintHop b_conv;
23109         b_conv.inner = (void*)(b & (~1));
23110         b_conv.is_owned = false;
23111         jboolean ret_val = RouteHintHop_eq(&a_conv, &b_conv);
23112         return ret_val;
23113 }
23114
23115 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23116         LDKRouteHintHop orig_conv;
23117         orig_conv.inner = (void*)(orig & (~1));
23118         orig_conv.is_owned = false;
23119         LDKRouteHintHop ret_var = RouteHintHop_clone(&orig_conv);
23120         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23121         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23122         uint64_t ret_ref = (uint64_t)ret_var.inner;
23123         if (ret_var.is_owned) {
23124                 ret_ref |= 1;
23125         }
23126         return ret_ref;
23127 }
23128
23129 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) {
23130         LDKPublicKey our_node_id_ref;
23131         CHECK((*env)->GetArrayLength(env, our_node_id) == 33);
23132         (*env)->GetByteArrayRegion(env, our_node_id, 0, 33, our_node_id_ref.compressed_form);
23133         LDKNetworkGraph network_conv;
23134         network_conv.inner = (void*)(network & (~1));
23135         network_conv.is_owned = false;
23136         LDKPublicKey payee_ref;
23137         CHECK((*env)->GetArrayLength(env, payee) == 33);
23138         (*env)->GetByteArrayRegion(env, payee, 0, 33, payee_ref.compressed_form);
23139         LDKInvoiceFeatures payee_features_conv;
23140         payee_features_conv.inner = (void*)(payee_features & (~1));
23141         payee_features_conv.is_owned = (payee_features & 1) || (payee_features == 0);
23142         payee_features_conv = InvoiceFeatures_clone(&payee_features_conv);
23143         LDKCVec_ChannelDetailsZ first_hops_constr;
23144         first_hops_constr.datalen = (*env)->GetArrayLength(env, first_hops);
23145         if (first_hops_constr.datalen > 0)
23146                 first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
23147         else
23148                 first_hops_constr.data = NULL;
23149         int64_t* first_hops_vals = (*env)->GetLongArrayElements (env, first_hops, NULL);
23150         for (size_t q = 0; q < first_hops_constr.datalen; q++) {
23151                 int64_t first_hops_conv_16 = first_hops_vals[q];
23152                 LDKChannelDetails first_hops_conv_16_conv;
23153                 first_hops_conv_16_conv.inner = (void*)(first_hops_conv_16 & (~1));
23154                 first_hops_conv_16_conv.is_owned = (first_hops_conv_16 & 1) || (first_hops_conv_16 == 0);
23155                 first_hops_constr.data[q] = first_hops_conv_16_conv;
23156         }
23157         (*env)->ReleaseLongArrayElements(env, first_hops, first_hops_vals, 0);
23158         LDKCVec_RouteHintZ last_hops_constr;
23159         last_hops_constr.datalen = (*env)->GetArrayLength(env, last_hops);
23160         if (last_hops_constr.datalen > 0)
23161                 last_hops_constr.data = MALLOC(last_hops_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
23162         else
23163                 last_hops_constr.data = NULL;
23164         int64_t* last_hops_vals = (*env)->GetLongArrayElements (env, last_hops, NULL);
23165         for (size_t l = 0; l < last_hops_constr.datalen; l++) {
23166                 int64_t last_hops_conv_11 = last_hops_vals[l];
23167                 LDKRouteHint last_hops_conv_11_conv;
23168                 last_hops_conv_11_conv.inner = (void*)(last_hops_conv_11 & (~1));
23169                 last_hops_conv_11_conv.is_owned = (last_hops_conv_11 & 1) || (last_hops_conv_11 == 0);
23170                 last_hops_conv_11_conv = RouteHint_clone(&last_hops_conv_11_conv);
23171                 last_hops_constr.data[l] = last_hops_conv_11_conv;
23172         }
23173         (*env)->ReleaseLongArrayElements(env, last_hops, last_hops_vals, 0);
23174         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
23175         if (logger_conv.free == LDKLogger_JCalls_free) {
23176                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23177                 LDKLogger_JCalls_clone(logger_conv.this_arg);
23178         }
23179         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
23180         *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);
23181         FREE(first_hops_constr.data);
23182         return (uint64_t)ret_conv;
23183 }
23184
23185 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23186         LDKNetworkGraph this_obj_conv;
23187         this_obj_conv.inner = (void*)(this_obj & (~1));
23188         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23189         NetworkGraph_free(this_obj_conv);
23190 }
23191
23192 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23193         LDKNetworkGraph orig_conv;
23194         orig_conv.inner = (void*)(orig & (~1));
23195         orig_conv.is_owned = false;
23196         LDKNetworkGraph ret_var = NetworkGraph_clone(&orig_conv);
23197         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23198         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23199         uint64_t ret_ref = (uint64_t)ret_var.inner;
23200         if (ret_var.is_owned) {
23201                 ret_ref |= 1;
23202         }
23203         return ret_ref;
23204 }
23205
23206 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LockedNetworkGraph_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23207         LDKLockedNetworkGraph this_obj_conv;
23208         this_obj_conv.inner = (void*)(this_obj & (~1));
23209         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23210         LockedNetworkGraph_free(this_obj_conv);
23211 }
23212
23213 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23214         LDKNetGraphMsgHandler this_obj_conv;
23215         this_obj_conv.inner = (void*)(this_obj & (~1));
23216         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23217         NetGraphMsgHandler_free(this_obj_conv);
23218 }
23219
23220 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) {
23221         LDKThirtyTwoBytes genesis_hash_ref;
23222         CHECK((*env)->GetArrayLength(env, genesis_hash) == 32);
23223         (*env)->GetByteArrayRegion(env, genesis_hash, 0, 32, genesis_hash_ref.data);
23224         LDKAccess *chain_access_conv_ptr = NULL;
23225         if (chain_access != 0) {
23226                 LDKAccess chain_access_conv;
23227                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
23228                 if (chain_access_conv.free == LDKAccess_JCalls_free) {
23229                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23230                         LDKAccess_JCalls_clone(chain_access_conv.this_arg);
23231                 }
23232                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
23233                 *chain_access_conv_ptr = chain_access_conv;
23234         }
23235         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
23236         if (logger_conv.free == LDKLogger_JCalls_free) {
23237                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23238                 LDKLogger_JCalls_clone(logger_conv.this_arg);
23239         }
23240         LDKNetGraphMsgHandler ret_var = NetGraphMsgHandler_new(genesis_hash_ref, chain_access_conv_ptr, logger_conv);
23241         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23242         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23243         uint64_t ret_ref = (uint64_t)ret_var.inner;
23244         if (ret_var.is_owned) {
23245                 ret_ref |= 1;
23246         }
23247         return ret_ref;
23248 }
23249
23250 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) {
23251         LDKAccess *chain_access_conv_ptr = NULL;
23252         if (chain_access != 0) {
23253                 LDKAccess chain_access_conv;
23254                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
23255                 if (chain_access_conv.free == LDKAccess_JCalls_free) {
23256                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23257                         LDKAccess_JCalls_clone(chain_access_conv.this_arg);
23258                 }
23259                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
23260                 *chain_access_conv_ptr = chain_access_conv;
23261         }
23262         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
23263         if (logger_conv.free == LDKLogger_JCalls_free) {
23264                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23265                 LDKLogger_JCalls_clone(logger_conv.this_arg);
23266         }
23267         LDKNetworkGraph network_graph_conv;
23268         network_graph_conv.inner = (void*)(network_graph & (~1));
23269         network_graph_conv.is_owned = (network_graph & 1) || (network_graph == 0);
23270         network_graph_conv = NetworkGraph_clone(&network_graph_conv);
23271         LDKNetGraphMsgHandler ret_var = NetGraphMsgHandler_from_net_graph(chain_access_conv_ptr, logger_conv, network_graph_conv);
23272         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23273         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23274         uint64_t ret_ref = (uint64_t)ret_var.inner;
23275         if (ret_var.is_owned) {
23276                 ret_ref |= 1;
23277         }
23278         return ret_ref;
23279 }
23280
23281 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1add_1chain_1access(JNIEnv *env, jclass clz, int64_t this_arg, int64_t chain_access) {
23282         LDKNetGraphMsgHandler this_arg_conv;
23283         this_arg_conv.inner = (void*)(this_arg & (~1));
23284         this_arg_conv.is_owned = false;
23285         LDKAccess *chain_access_conv_ptr = NULL;
23286         if (chain_access != 0) {
23287                 LDKAccess chain_access_conv;
23288                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
23289                 if (chain_access_conv.free == LDKAccess_JCalls_free) {
23290                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23291                         LDKAccess_JCalls_clone(chain_access_conv.this_arg);
23292                 }
23293                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
23294                 *chain_access_conv_ptr = chain_access_conv;
23295         }
23296         NetGraphMsgHandler_add_chain_access(&this_arg_conv, chain_access_conv_ptr);
23297 }
23298
23299 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1read_1locked_1graph(JNIEnv *env, jclass clz, int64_t this_arg) {
23300         LDKNetGraphMsgHandler this_arg_conv;
23301         this_arg_conv.inner = (void*)(this_arg & (~1));
23302         this_arg_conv.is_owned = false;
23303         LDKLockedNetworkGraph ret_var = NetGraphMsgHandler_read_locked_graph(&this_arg_conv);
23304         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23305         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23306         uint64_t ret_ref = (uint64_t)ret_var.inner;
23307         if (ret_var.is_owned) {
23308                 ret_ref |= 1;
23309         }
23310         return ret_ref;
23311 }
23312
23313 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LockedNetworkGraph_1graph(JNIEnv *env, jclass clz, int64_t this_arg) {
23314         LDKLockedNetworkGraph this_arg_conv;
23315         this_arg_conv.inner = (void*)(this_arg & (~1));
23316         this_arg_conv.is_owned = false;
23317         LDKNetworkGraph ret_var = LockedNetworkGraph_graph(&this_arg_conv);
23318         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23319         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23320         uint64_t ret_ref = (uint64_t)ret_var.inner;
23321         if (ret_var.is_owned) {
23322                 ret_ref |= 1;
23323         }
23324         return ret_ref;
23325 }
23326
23327 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1as_1RoutingMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
23328         LDKNetGraphMsgHandler this_arg_conv;
23329         this_arg_conv.inner = (void*)(this_arg & (~1));
23330         this_arg_conv.is_owned = false;
23331         LDKRoutingMessageHandler* ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
23332         *ret = NetGraphMsgHandler_as_RoutingMessageHandler(&this_arg_conv);
23333         return (uint64_t)ret;
23334 }
23335
23336 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
23337         LDKNetGraphMsgHandler this_arg_conv;
23338         this_arg_conv.inner = (void*)(this_arg & (~1));
23339         this_arg_conv.is_owned = false;
23340         LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
23341         *ret = NetGraphMsgHandler_as_MessageSendEventsProvider(&this_arg_conv);
23342         return (uint64_t)ret;
23343 }
23344
23345 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23346         LDKDirectionalChannelInfo this_obj_conv;
23347         this_obj_conv.inner = (void*)(this_obj & (~1));
23348         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23349         DirectionalChannelInfo_free(this_obj_conv);
23350 }
23351
23352 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr) {
23353         LDKDirectionalChannelInfo this_ptr_conv;
23354         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23355         this_ptr_conv.is_owned = false;
23356         int32_t ret_val = DirectionalChannelInfo_get_last_update(&this_ptr_conv);
23357         return ret_val;
23358 }
23359
23360 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
23361         LDKDirectionalChannelInfo this_ptr_conv;
23362         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23363         this_ptr_conv.is_owned = false;
23364         DirectionalChannelInfo_set_last_update(&this_ptr_conv, val);
23365 }
23366
23367 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1enabled(JNIEnv *env, jclass clz, int64_t this_ptr) {
23368         LDKDirectionalChannelInfo this_ptr_conv;
23369         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23370         this_ptr_conv.is_owned = false;
23371         jboolean ret_val = DirectionalChannelInfo_get_enabled(&this_ptr_conv);
23372         return ret_val;
23373 }
23374
23375 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1enabled(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
23376         LDKDirectionalChannelInfo this_ptr_conv;
23377         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23378         this_ptr_conv.is_owned = false;
23379         DirectionalChannelInfo_set_enabled(&this_ptr_conv, val);
23380 }
23381
23382 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
23383         LDKDirectionalChannelInfo this_ptr_conv;
23384         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23385         this_ptr_conv.is_owned = false;
23386         int16_t ret_val = DirectionalChannelInfo_get_cltv_expiry_delta(&this_ptr_conv);
23387         return ret_val;
23388 }
23389
23390 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
23391         LDKDirectionalChannelInfo this_ptr_conv;
23392         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23393         this_ptr_conv.is_owned = false;
23394         DirectionalChannelInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
23395 }
23396
23397 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
23398         LDKDirectionalChannelInfo this_ptr_conv;
23399         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23400         this_ptr_conv.is_owned = false;
23401         int64_t ret_val = DirectionalChannelInfo_get_htlc_minimum_msat(&this_ptr_conv);
23402         return ret_val;
23403 }
23404
23405 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23406         LDKDirectionalChannelInfo this_ptr_conv;
23407         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23408         this_ptr_conv.is_owned = false;
23409         DirectionalChannelInfo_set_htlc_minimum_msat(&this_ptr_conv, val);
23410 }
23411
23412 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
23413         LDKDirectionalChannelInfo this_ptr_conv;
23414         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23415         this_ptr_conv.is_owned = false;
23416         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
23417         *ret_copy = DirectionalChannelInfo_get_htlc_maximum_msat(&this_ptr_conv);
23418         uint64_t ret_ref = (uint64_t)ret_copy;
23419         return ret_ref;
23420 }
23421
23422 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23423         LDKDirectionalChannelInfo this_ptr_conv;
23424         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23425         this_ptr_conv.is_owned = false;
23426         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
23427         DirectionalChannelInfo_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
23428 }
23429
23430 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
23431         LDKDirectionalChannelInfo this_ptr_conv;
23432         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23433         this_ptr_conv.is_owned = false;
23434         LDKRoutingFees ret_var = DirectionalChannelInfo_get_fees(&this_ptr_conv);
23435         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23436         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23437         uint64_t ret_ref = (uint64_t)ret_var.inner;
23438         if (ret_var.is_owned) {
23439                 ret_ref |= 1;
23440         }
23441         return ret_ref;
23442 }
23443
23444 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1fees(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23445         LDKDirectionalChannelInfo this_ptr_conv;
23446         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23447         this_ptr_conv.is_owned = false;
23448         LDKRoutingFees val_conv;
23449         val_conv.inner = (void*)(val & (~1));
23450         val_conv.is_owned = (val & 1) || (val == 0);
23451         val_conv = RoutingFees_clone(&val_conv);
23452         DirectionalChannelInfo_set_fees(&this_ptr_conv, val_conv);
23453 }
23454
23455 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1last_1update_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
23456         LDKDirectionalChannelInfo this_ptr_conv;
23457         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23458         this_ptr_conv.is_owned = false;
23459         LDKChannelUpdate ret_var = DirectionalChannelInfo_get_last_update_message(&this_ptr_conv);
23460         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23461         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23462         uint64_t ret_ref = (uint64_t)ret_var.inner;
23463         if (ret_var.is_owned) {
23464                 ret_ref |= 1;
23465         }
23466         return ret_ref;
23467 }
23468
23469 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1last_1update_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23470         LDKDirectionalChannelInfo this_ptr_conv;
23471         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23472         this_ptr_conv.is_owned = false;
23473         LDKChannelUpdate val_conv;
23474         val_conv.inner = (void*)(val & (~1));
23475         val_conv.is_owned = (val & 1) || (val == 0);
23476         val_conv = ChannelUpdate_clone(&val_conv);
23477         DirectionalChannelInfo_set_last_update_message(&this_ptr_conv, val_conv);
23478 }
23479
23480 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) {
23481         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)htlc_maximum_msat_arg) & ~1);
23482         LDKRoutingFees fees_arg_conv;
23483         fees_arg_conv.inner = (void*)(fees_arg & (~1));
23484         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
23485         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
23486         LDKChannelUpdate last_update_message_arg_conv;
23487         last_update_message_arg_conv.inner = (void*)(last_update_message_arg & (~1));
23488         last_update_message_arg_conv.is_owned = (last_update_message_arg & 1) || (last_update_message_arg == 0);
23489         last_update_message_arg_conv = ChannelUpdate_clone(&last_update_message_arg_conv);
23490         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);
23491         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23492         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23493         uint64_t ret_ref = (uint64_t)ret_var.inner;
23494         if (ret_var.is_owned) {
23495                 ret_ref |= 1;
23496         }
23497         return ret_ref;
23498 }
23499
23500 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23501         LDKDirectionalChannelInfo orig_conv;
23502         orig_conv.inner = (void*)(orig & (~1));
23503         orig_conv.is_owned = false;
23504         LDKDirectionalChannelInfo ret_var = DirectionalChannelInfo_clone(&orig_conv);
23505         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23506         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23507         uint64_t ret_ref = (uint64_t)ret_var.inner;
23508         if (ret_var.is_owned) {
23509                 ret_ref |= 1;
23510         }
23511         return ret_ref;
23512 }
23513
23514 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
23515         LDKDirectionalChannelInfo obj_conv;
23516         obj_conv.inner = (void*)(obj & (~1));
23517         obj_conv.is_owned = false;
23518         LDKCVec_u8Z ret_var = DirectionalChannelInfo_write(&obj_conv);
23519         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23520         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23521         CVec_u8Z_free(ret_var);
23522         return ret_arr;
23523 }
23524
23525 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23526         LDKu8slice ser_ref;
23527         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23528         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23529         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
23530         *ret_conv = DirectionalChannelInfo_read(ser_ref);
23531         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23532         return (uint64_t)ret_conv;
23533 }
23534
23535 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23536         LDKChannelInfo this_obj_conv;
23537         this_obj_conv.inner = (void*)(this_obj & (~1));
23538         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23539         ChannelInfo_free(this_obj_conv);
23540 }
23541
23542 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
23543         LDKChannelInfo this_ptr_conv;
23544         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23545         this_ptr_conv.is_owned = false;
23546         LDKChannelFeatures ret_var = ChannelInfo_get_features(&this_ptr_conv);
23547         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23548         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23549         uint64_t ret_ref = (uint64_t)ret_var.inner;
23550         if (ret_var.is_owned) {
23551                 ret_ref |= 1;
23552         }
23553         return ret_ref;
23554 }
23555
23556 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23557         LDKChannelInfo this_ptr_conv;
23558         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23559         this_ptr_conv.is_owned = false;
23560         LDKChannelFeatures val_conv;
23561         val_conv.inner = (void*)(val & (~1));
23562         val_conv.is_owned = (val & 1) || (val == 0);
23563         val_conv = ChannelFeatures_clone(&val_conv);
23564         ChannelInfo_set_features(&this_ptr_conv, val_conv);
23565 }
23566
23567 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1node_1one(JNIEnv *env, jclass clz, int64_t this_ptr) {
23568         LDKChannelInfo this_ptr_conv;
23569         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23570         this_ptr_conv.is_owned = false;
23571         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
23572         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelInfo_get_node_one(&this_ptr_conv).compressed_form);
23573         return ret_arr;
23574 }
23575
23576 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1node_1one(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
23577         LDKChannelInfo this_ptr_conv;
23578         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23579         this_ptr_conv.is_owned = false;
23580         LDKPublicKey val_ref;
23581         CHECK((*env)->GetArrayLength(env, val) == 33);
23582         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
23583         ChannelInfo_set_node_one(&this_ptr_conv, val_ref);
23584 }
23585
23586 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1one_1to_1two(JNIEnv *env, jclass clz, int64_t this_ptr) {
23587         LDKChannelInfo this_ptr_conv;
23588         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23589         this_ptr_conv.is_owned = false;
23590         LDKDirectionalChannelInfo ret_var = ChannelInfo_get_one_to_two(&this_ptr_conv);
23591         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23592         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23593         uint64_t ret_ref = (uint64_t)ret_var.inner;
23594         if (ret_var.is_owned) {
23595                 ret_ref |= 1;
23596         }
23597         return ret_ref;
23598 }
23599
23600 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1one_1to_1two(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23601         LDKChannelInfo this_ptr_conv;
23602         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23603         this_ptr_conv.is_owned = false;
23604         LDKDirectionalChannelInfo val_conv;
23605         val_conv.inner = (void*)(val & (~1));
23606         val_conv.is_owned = (val & 1) || (val == 0);
23607         val_conv = DirectionalChannelInfo_clone(&val_conv);
23608         ChannelInfo_set_one_to_two(&this_ptr_conv, val_conv);
23609 }
23610
23611 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1node_1two(JNIEnv *env, jclass clz, int64_t this_ptr) {
23612         LDKChannelInfo this_ptr_conv;
23613         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23614         this_ptr_conv.is_owned = false;
23615         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
23616         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelInfo_get_node_two(&this_ptr_conv).compressed_form);
23617         return ret_arr;
23618 }
23619
23620 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1node_1two(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
23621         LDKChannelInfo this_ptr_conv;
23622         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23623         this_ptr_conv.is_owned = false;
23624         LDKPublicKey val_ref;
23625         CHECK((*env)->GetArrayLength(env, val) == 33);
23626         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
23627         ChannelInfo_set_node_two(&this_ptr_conv, val_ref);
23628 }
23629
23630 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1two_1to_1one(JNIEnv *env, jclass clz, int64_t this_ptr) {
23631         LDKChannelInfo this_ptr_conv;
23632         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23633         this_ptr_conv.is_owned = false;
23634         LDKDirectionalChannelInfo ret_var = ChannelInfo_get_two_to_one(&this_ptr_conv);
23635         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23636         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23637         uint64_t ret_ref = (uint64_t)ret_var.inner;
23638         if (ret_var.is_owned) {
23639                 ret_ref |= 1;
23640         }
23641         return ret_ref;
23642 }
23643
23644 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1two_1to_1one(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23645         LDKChannelInfo this_ptr_conv;
23646         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23647         this_ptr_conv.is_owned = false;
23648         LDKDirectionalChannelInfo val_conv;
23649         val_conv.inner = (void*)(val & (~1));
23650         val_conv.is_owned = (val & 1) || (val == 0);
23651         val_conv = DirectionalChannelInfo_clone(&val_conv);
23652         ChannelInfo_set_two_to_one(&this_ptr_conv, val_conv);
23653 }
23654
23655 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1capacity_1sats(JNIEnv *env, jclass clz, int64_t this_ptr) {
23656         LDKChannelInfo this_ptr_conv;
23657         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23658         this_ptr_conv.is_owned = false;
23659         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
23660         *ret_copy = ChannelInfo_get_capacity_sats(&this_ptr_conv);
23661         uint64_t ret_ref = (uint64_t)ret_copy;
23662         return ret_ref;
23663 }
23664
23665 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1capacity_1sats(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23666         LDKChannelInfo this_ptr_conv;
23667         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23668         this_ptr_conv.is_owned = false;
23669         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
23670         ChannelInfo_set_capacity_sats(&this_ptr_conv, val_conv);
23671 }
23672
23673 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
23674         LDKChannelInfo this_ptr_conv;
23675         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23676         this_ptr_conv.is_owned = false;
23677         LDKChannelAnnouncement ret_var = ChannelInfo_get_announcement_message(&this_ptr_conv);
23678         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23679         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23680         uint64_t ret_ref = (uint64_t)ret_var.inner;
23681         if (ret_var.is_owned) {
23682                 ret_ref |= 1;
23683         }
23684         return ret_ref;
23685 }
23686
23687 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23688         LDKChannelInfo this_ptr_conv;
23689         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23690         this_ptr_conv.is_owned = false;
23691         LDKChannelAnnouncement val_conv;
23692         val_conv.inner = (void*)(val & (~1));
23693         val_conv.is_owned = (val & 1) || (val == 0);
23694         val_conv = ChannelAnnouncement_clone(&val_conv);
23695         ChannelInfo_set_announcement_message(&this_ptr_conv, val_conv);
23696 }
23697
23698 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) {
23699         LDKChannelFeatures features_arg_conv;
23700         features_arg_conv.inner = (void*)(features_arg & (~1));
23701         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
23702         features_arg_conv = ChannelFeatures_clone(&features_arg_conv);
23703         LDKPublicKey node_one_arg_ref;
23704         CHECK((*env)->GetArrayLength(env, node_one_arg) == 33);
23705         (*env)->GetByteArrayRegion(env, node_one_arg, 0, 33, node_one_arg_ref.compressed_form);
23706         LDKDirectionalChannelInfo one_to_two_arg_conv;
23707         one_to_two_arg_conv.inner = (void*)(one_to_two_arg & (~1));
23708         one_to_two_arg_conv.is_owned = (one_to_two_arg & 1) || (one_to_two_arg == 0);
23709         one_to_two_arg_conv = DirectionalChannelInfo_clone(&one_to_two_arg_conv);
23710         LDKPublicKey node_two_arg_ref;
23711         CHECK((*env)->GetArrayLength(env, node_two_arg) == 33);
23712         (*env)->GetByteArrayRegion(env, node_two_arg, 0, 33, node_two_arg_ref.compressed_form);
23713         LDKDirectionalChannelInfo two_to_one_arg_conv;
23714         two_to_one_arg_conv.inner = (void*)(two_to_one_arg & (~1));
23715         two_to_one_arg_conv.is_owned = (two_to_one_arg & 1) || (two_to_one_arg == 0);
23716         two_to_one_arg_conv = DirectionalChannelInfo_clone(&two_to_one_arg_conv);
23717         LDKCOption_u64Z capacity_sats_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)capacity_sats_arg) & ~1);
23718         LDKChannelAnnouncement announcement_message_arg_conv;
23719         announcement_message_arg_conv.inner = (void*)(announcement_message_arg & (~1));
23720         announcement_message_arg_conv.is_owned = (announcement_message_arg & 1) || (announcement_message_arg == 0);
23721         announcement_message_arg_conv = ChannelAnnouncement_clone(&announcement_message_arg_conv);
23722         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);
23723         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23724         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23725         uint64_t ret_ref = (uint64_t)ret_var.inner;
23726         if (ret_var.is_owned) {
23727                 ret_ref |= 1;
23728         }
23729         return ret_ref;
23730 }
23731
23732 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23733         LDKChannelInfo orig_conv;
23734         orig_conv.inner = (void*)(orig & (~1));
23735         orig_conv.is_owned = false;
23736         LDKChannelInfo ret_var = ChannelInfo_clone(&orig_conv);
23737         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23738         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23739         uint64_t ret_ref = (uint64_t)ret_var.inner;
23740         if (ret_var.is_owned) {
23741                 ret_ref |= 1;
23742         }
23743         return ret_ref;
23744 }
23745
23746 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
23747         LDKChannelInfo obj_conv;
23748         obj_conv.inner = (void*)(obj & (~1));
23749         obj_conv.is_owned = false;
23750         LDKCVec_u8Z ret_var = ChannelInfo_write(&obj_conv);
23751         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23752         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23753         CVec_u8Z_free(ret_var);
23754         return ret_arr;
23755 }
23756
23757 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23758         LDKu8slice ser_ref;
23759         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23760         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23761         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
23762         *ret_conv = ChannelInfo_read(ser_ref);
23763         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23764         return (uint64_t)ret_conv;
23765 }
23766
23767 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23768         LDKRoutingFees this_obj_conv;
23769         this_obj_conv.inner = (void*)(this_obj & (~1));
23770         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23771         RoutingFees_free(this_obj_conv);
23772 }
23773
23774 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1get_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
23775         LDKRoutingFees this_ptr_conv;
23776         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23777         this_ptr_conv.is_owned = false;
23778         int32_t ret_val = RoutingFees_get_base_msat(&this_ptr_conv);
23779         return ret_val;
23780 }
23781
23782 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1set_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
23783         LDKRoutingFees this_ptr_conv;
23784         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23785         this_ptr_conv.is_owned = false;
23786         RoutingFees_set_base_msat(&this_ptr_conv, val);
23787 }
23788
23789 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1get_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
23790         LDKRoutingFees this_ptr_conv;
23791         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23792         this_ptr_conv.is_owned = false;
23793         int32_t ret_val = RoutingFees_get_proportional_millionths(&this_ptr_conv);
23794         return ret_val;
23795 }
23796
23797 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1set_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
23798         LDKRoutingFees this_ptr_conv;
23799         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23800         this_ptr_conv.is_owned = false;
23801         RoutingFees_set_proportional_millionths(&this_ptr_conv, val);
23802 }
23803
23804 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) {
23805         LDKRoutingFees ret_var = RoutingFees_new(base_msat_arg, proportional_millionths_arg);
23806         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23807         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23808         uint64_t ret_ref = (uint64_t)ret_var.inner;
23809         if (ret_var.is_owned) {
23810                 ret_ref |= 1;
23811         }
23812         return ret_ref;
23813 }
23814
23815 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RoutingFees_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
23816         LDKRoutingFees a_conv;
23817         a_conv.inner = (void*)(a & (~1));
23818         a_conv.is_owned = false;
23819         LDKRoutingFees b_conv;
23820         b_conv.inner = (void*)(b & (~1));
23821         b_conv.is_owned = false;
23822         jboolean ret_val = RoutingFees_eq(&a_conv, &b_conv);
23823         return ret_val;
23824 }
23825
23826 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23827         LDKRoutingFees orig_conv;
23828         orig_conv.inner = (void*)(orig & (~1));
23829         orig_conv.is_owned = false;
23830         LDKRoutingFees ret_var = RoutingFees_clone(&orig_conv);
23831         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23832         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23833         uint64_t ret_ref = (uint64_t)ret_var.inner;
23834         if (ret_var.is_owned) {
23835                 ret_ref |= 1;
23836         }
23837         return ret_ref;
23838 }
23839
23840 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RoutingFees_1write(JNIEnv *env, jclass clz, int64_t obj) {
23841         LDKRoutingFees obj_conv;
23842         obj_conv.inner = (void*)(obj & (~1));
23843         obj_conv.is_owned = false;
23844         LDKCVec_u8Z ret_var = RoutingFees_write(&obj_conv);
23845         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23846         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23847         CVec_u8Z_free(ret_var);
23848         return ret_arr;
23849 }
23850
23851 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23852         LDKu8slice ser_ref;
23853         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23854         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23855         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
23856         *ret_conv = RoutingFees_read(ser_ref);
23857         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23858         return (uint64_t)ret_conv;
23859 }
23860
23861 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23862         LDKNodeAnnouncementInfo this_obj_conv;
23863         this_obj_conv.inner = (void*)(this_obj & (~1));
23864         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23865         NodeAnnouncementInfo_free(this_obj_conv);
23866 }
23867
23868 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
23869         LDKNodeAnnouncementInfo this_ptr_conv;
23870         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23871         this_ptr_conv.is_owned = false;
23872         LDKNodeFeatures ret_var = NodeAnnouncementInfo_get_features(&this_ptr_conv);
23873         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23874         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23875         uint64_t ret_ref = (uint64_t)ret_var.inner;
23876         if (ret_var.is_owned) {
23877                 ret_ref |= 1;
23878         }
23879         return ret_ref;
23880 }
23881
23882 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23883         LDKNodeAnnouncementInfo this_ptr_conv;
23884         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23885         this_ptr_conv.is_owned = false;
23886         LDKNodeFeatures val_conv;
23887         val_conv.inner = (void*)(val & (~1));
23888         val_conv.is_owned = (val & 1) || (val == 0);
23889         val_conv = NodeFeatures_clone(&val_conv);
23890         NodeAnnouncementInfo_set_features(&this_ptr_conv, val_conv);
23891 }
23892
23893 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr) {
23894         LDKNodeAnnouncementInfo this_ptr_conv;
23895         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23896         this_ptr_conv.is_owned = false;
23897         int32_t ret_val = NodeAnnouncementInfo_get_last_update(&this_ptr_conv);
23898         return ret_val;
23899 }
23900
23901 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
23902         LDKNodeAnnouncementInfo this_ptr_conv;
23903         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23904         this_ptr_conv.is_owned = false;
23905         NodeAnnouncementInfo_set_last_update(&this_ptr_conv, val);
23906 }
23907
23908 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr) {
23909         LDKNodeAnnouncementInfo this_ptr_conv;
23910         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23911         this_ptr_conv.is_owned = false;
23912         int8_tArray ret_arr = (*env)->NewByteArray(env, 3);
23913         (*env)->SetByteArrayRegion(env, ret_arr, 0, 3, *NodeAnnouncementInfo_get_rgb(&this_ptr_conv));
23914         return ret_arr;
23915 }
23916
23917 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
23918         LDKNodeAnnouncementInfo this_ptr_conv;
23919         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23920         this_ptr_conv.is_owned = false;
23921         LDKThreeBytes val_ref;
23922         CHECK((*env)->GetArrayLength(env, val) == 3);
23923         (*env)->GetByteArrayRegion(env, val, 0, 3, val_ref.data);
23924         NodeAnnouncementInfo_set_rgb(&this_ptr_conv, val_ref);
23925 }
23926
23927 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
23928         LDKNodeAnnouncementInfo this_ptr_conv;
23929         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23930         this_ptr_conv.is_owned = false;
23931         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
23932         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *NodeAnnouncementInfo_get_alias(&this_ptr_conv));
23933         return ret_arr;
23934 }
23935
23936 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
23937         LDKNodeAnnouncementInfo this_ptr_conv;
23938         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23939         this_ptr_conv.is_owned = false;
23940         LDKThirtyTwoBytes val_ref;
23941         CHECK((*env)->GetArrayLength(env, val) == 32);
23942         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
23943         NodeAnnouncementInfo_set_alias(&this_ptr_conv, val_ref);
23944 }
23945
23946 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1addresses(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
23947         LDKNodeAnnouncementInfo this_ptr_conv;
23948         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23949         this_ptr_conv.is_owned = false;
23950         LDKCVec_NetAddressZ val_constr;
23951         val_constr.datalen = (*env)->GetArrayLength(env, val);
23952         if (val_constr.datalen > 0)
23953                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
23954         else
23955                 val_constr.data = NULL;
23956         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
23957         for (size_t m = 0; m < val_constr.datalen; m++) {
23958                 int64_t val_conv_12 = val_vals[m];
23959                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(((uint64_t)val_conv_12) & ~1);
23960                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)val_conv_12) & ~1));
23961                 val_constr.data[m] = val_conv_12_conv;
23962         }
23963         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
23964         NodeAnnouncementInfo_set_addresses(&this_ptr_conv, val_constr);
23965 }
23966
23967 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
23968         LDKNodeAnnouncementInfo this_ptr_conv;
23969         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23970         this_ptr_conv.is_owned = false;
23971         LDKNodeAnnouncement ret_var = NodeAnnouncementInfo_get_announcement_message(&this_ptr_conv);
23972         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23973         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23974         uint64_t ret_ref = (uint64_t)ret_var.inner;
23975         if (ret_var.is_owned) {
23976                 ret_ref |= 1;
23977         }
23978         return ret_ref;
23979 }
23980
23981 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23982         LDKNodeAnnouncementInfo this_ptr_conv;
23983         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23984         this_ptr_conv.is_owned = false;
23985         LDKNodeAnnouncement val_conv;
23986         val_conv.inner = (void*)(val & (~1));
23987         val_conv.is_owned = (val & 1) || (val == 0);
23988         val_conv = NodeAnnouncement_clone(&val_conv);
23989         NodeAnnouncementInfo_set_announcement_message(&this_ptr_conv, val_conv);
23990 }
23991
23992 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) {
23993         LDKNodeFeatures features_arg_conv;
23994         features_arg_conv.inner = (void*)(features_arg & (~1));
23995         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
23996         features_arg_conv = NodeFeatures_clone(&features_arg_conv);
23997         LDKThreeBytes rgb_arg_ref;
23998         CHECK((*env)->GetArrayLength(env, rgb_arg) == 3);
23999         (*env)->GetByteArrayRegion(env, rgb_arg, 0, 3, rgb_arg_ref.data);
24000         LDKThirtyTwoBytes alias_arg_ref;
24001         CHECK((*env)->GetArrayLength(env, alias_arg) == 32);
24002         (*env)->GetByteArrayRegion(env, alias_arg, 0, 32, alias_arg_ref.data);
24003         LDKCVec_NetAddressZ addresses_arg_constr;
24004         addresses_arg_constr.datalen = (*env)->GetArrayLength(env, addresses_arg);
24005         if (addresses_arg_constr.datalen > 0)
24006                 addresses_arg_constr.data = MALLOC(addresses_arg_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
24007         else
24008                 addresses_arg_constr.data = NULL;
24009         int64_t* addresses_arg_vals = (*env)->GetLongArrayElements (env, addresses_arg, NULL);
24010         for (size_t m = 0; m < addresses_arg_constr.datalen; m++) {
24011                 int64_t addresses_arg_conv_12 = addresses_arg_vals[m];
24012                 LDKNetAddress addresses_arg_conv_12_conv = *(LDKNetAddress*)(((uint64_t)addresses_arg_conv_12) & ~1);
24013                 addresses_arg_constr.data[m] = addresses_arg_conv_12_conv;
24014         }
24015         (*env)->ReleaseLongArrayElements(env, addresses_arg, addresses_arg_vals, 0);
24016         LDKNodeAnnouncement announcement_message_arg_conv;
24017         announcement_message_arg_conv.inner = (void*)(announcement_message_arg & (~1));
24018         announcement_message_arg_conv.is_owned = (announcement_message_arg & 1) || (announcement_message_arg == 0);
24019         announcement_message_arg_conv = NodeAnnouncement_clone(&announcement_message_arg_conv);
24020         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_new(features_arg_conv, last_update_arg, rgb_arg_ref, alias_arg_ref, addresses_arg_constr, announcement_message_arg_conv);
24021         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24022         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24023         uint64_t ret_ref = (uint64_t)ret_var.inner;
24024         if (ret_var.is_owned) {
24025                 ret_ref |= 1;
24026         }
24027         return ret_ref;
24028 }
24029
24030 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24031         LDKNodeAnnouncementInfo orig_conv;
24032         orig_conv.inner = (void*)(orig & (~1));
24033         orig_conv.is_owned = false;
24034         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(&orig_conv);
24035         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24036         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24037         uint64_t ret_ref = (uint64_t)ret_var.inner;
24038         if (ret_var.is_owned) {
24039                 ret_ref |= 1;
24040         }
24041         return ret_ref;
24042 }
24043
24044 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
24045         LDKNodeAnnouncementInfo obj_conv;
24046         obj_conv.inner = (void*)(obj & (~1));
24047         obj_conv.is_owned = false;
24048         LDKCVec_u8Z ret_var = NodeAnnouncementInfo_write(&obj_conv);
24049         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24050         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24051         CVec_u8Z_free(ret_var);
24052         return ret_arr;
24053 }
24054
24055 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24056         LDKu8slice ser_ref;
24057         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24058         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24059         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
24060         *ret_conv = NodeAnnouncementInfo_read(ser_ref);
24061         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24062         return (uint64_t)ret_conv;
24063 }
24064
24065 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24066         LDKNodeInfo this_obj_conv;
24067         this_obj_conv.inner = (void*)(this_obj & (~1));
24068         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24069         NodeInfo_free(this_obj_conv);
24070 }
24071
24072 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
24073         LDKNodeInfo this_ptr_conv;
24074         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24075         this_ptr_conv.is_owned = false;
24076         LDKCVec_u64Z val_constr;
24077         val_constr.datalen = (*env)->GetArrayLength(env, val);
24078         if (val_constr.datalen > 0)
24079                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
24080         else
24081                 val_constr.data = NULL;
24082         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
24083         for (size_t g = 0; g < val_constr.datalen; g++) {
24084                 int64_t val_conv_6 = val_vals[g];
24085                 val_constr.data[g] = val_conv_6;
24086         }
24087         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
24088         NodeInfo_set_channels(&this_ptr_conv, val_constr);
24089 }
24090
24091 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1lowest_1inbound_1channel_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
24092         LDKNodeInfo this_ptr_conv;
24093         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24094         this_ptr_conv.is_owned = false;
24095         LDKRoutingFees ret_var = NodeInfo_get_lowest_inbound_channel_fees(&this_ptr_conv);
24096         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24097         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24098         uint64_t ret_ref = (uint64_t)ret_var.inner;
24099         if (ret_var.is_owned) {
24100                 ret_ref |= 1;
24101         }
24102         return ret_ref;
24103 }
24104
24105 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) {
24106         LDKNodeInfo this_ptr_conv;
24107         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24108         this_ptr_conv.is_owned = false;
24109         LDKRoutingFees val_conv;
24110         val_conv.inner = (void*)(val & (~1));
24111         val_conv.is_owned = (val & 1) || (val == 0);
24112         val_conv = RoutingFees_clone(&val_conv);
24113         NodeInfo_set_lowest_inbound_channel_fees(&this_ptr_conv, val_conv);
24114 }
24115
24116 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1announcement_1info(JNIEnv *env, jclass clz, int64_t this_ptr) {
24117         LDKNodeInfo this_ptr_conv;
24118         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24119         this_ptr_conv.is_owned = false;
24120         LDKNodeAnnouncementInfo ret_var = NodeInfo_get_announcement_info(&this_ptr_conv);
24121         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24122         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24123         uint64_t ret_ref = (uint64_t)ret_var.inner;
24124         if (ret_var.is_owned) {
24125                 ret_ref |= 1;
24126         }
24127         return ret_ref;
24128 }
24129
24130 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1announcement_1info(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24131         LDKNodeInfo this_ptr_conv;
24132         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24133         this_ptr_conv.is_owned = false;
24134         LDKNodeAnnouncementInfo val_conv;
24135         val_conv.inner = (void*)(val & (~1));
24136         val_conv.is_owned = (val & 1) || (val == 0);
24137         val_conv = NodeAnnouncementInfo_clone(&val_conv);
24138         NodeInfo_set_announcement_info(&this_ptr_conv, val_conv);
24139 }
24140
24141 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) {
24142         LDKCVec_u64Z channels_arg_constr;
24143         channels_arg_constr.datalen = (*env)->GetArrayLength(env, channels_arg);
24144         if (channels_arg_constr.datalen > 0)
24145                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
24146         else
24147                 channels_arg_constr.data = NULL;
24148         int64_t* channels_arg_vals = (*env)->GetLongArrayElements (env, channels_arg, NULL);
24149         for (size_t g = 0; g < channels_arg_constr.datalen; g++) {
24150                 int64_t channels_arg_conv_6 = channels_arg_vals[g];
24151                 channels_arg_constr.data[g] = channels_arg_conv_6;
24152         }
24153         (*env)->ReleaseLongArrayElements(env, channels_arg, channels_arg_vals, 0);
24154         LDKRoutingFees lowest_inbound_channel_fees_arg_conv;
24155         lowest_inbound_channel_fees_arg_conv.inner = (void*)(lowest_inbound_channel_fees_arg & (~1));
24156         lowest_inbound_channel_fees_arg_conv.is_owned = (lowest_inbound_channel_fees_arg & 1) || (lowest_inbound_channel_fees_arg == 0);
24157         lowest_inbound_channel_fees_arg_conv = RoutingFees_clone(&lowest_inbound_channel_fees_arg_conv);
24158         LDKNodeAnnouncementInfo announcement_info_arg_conv;
24159         announcement_info_arg_conv.inner = (void*)(announcement_info_arg & (~1));
24160         announcement_info_arg_conv.is_owned = (announcement_info_arg & 1) || (announcement_info_arg == 0);
24161         announcement_info_arg_conv = NodeAnnouncementInfo_clone(&announcement_info_arg_conv);
24162         LDKNodeInfo ret_var = NodeInfo_new(channels_arg_constr, lowest_inbound_channel_fees_arg_conv, announcement_info_arg_conv);
24163         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24164         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24165         uint64_t ret_ref = (uint64_t)ret_var.inner;
24166         if (ret_var.is_owned) {
24167                 ret_ref |= 1;
24168         }
24169         return ret_ref;
24170 }
24171
24172 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24173         LDKNodeInfo orig_conv;
24174         orig_conv.inner = (void*)(orig & (~1));
24175         orig_conv.is_owned = false;
24176         LDKNodeInfo ret_var = NodeInfo_clone(&orig_conv);
24177         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24178         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24179         uint64_t ret_ref = (uint64_t)ret_var.inner;
24180         if (ret_var.is_owned) {
24181                 ret_ref |= 1;
24182         }
24183         return ret_ref;
24184 }
24185
24186 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
24187         LDKNodeInfo obj_conv;
24188         obj_conv.inner = (void*)(obj & (~1));
24189         obj_conv.is_owned = false;
24190         LDKCVec_u8Z ret_var = NodeInfo_write(&obj_conv);
24191         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24192         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24193         CVec_u8Z_free(ret_var);
24194         return ret_arr;
24195 }
24196
24197 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24198         LDKu8slice ser_ref;
24199         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24200         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24201         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
24202         *ret_conv = NodeInfo_read(ser_ref);
24203         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24204         return (uint64_t)ret_conv;
24205 }
24206
24207 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1write(JNIEnv *env, jclass clz, int64_t obj) {
24208         LDKNetworkGraph obj_conv;
24209         obj_conv.inner = (void*)(obj & (~1));
24210         obj_conv.is_owned = false;
24211         LDKCVec_u8Z ret_var = NetworkGraph_write(&obj_conv);
24212         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24213         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24214         CVec_u8Z_free(ret_var);
24215         return ret_arr;
24216 }
24217
24218 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24219         LDKu8slice ser_ref;
24220         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24221         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24222         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
24223         *ret_conv = NetworkGraph_read(ser_ref);
24224         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24225         return (uint64_t)ret_conv;
24226 }
24227
24228 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1new(JNIEnv *env, jclass clz, int8_tArray genesis_hash) {
24229         LDKThirtyTwoBytes genesis_hash_ref;
24230         CHECK((*env)->GetArrayLength(env, genesis_hash) == 32);
24231         (*env)->GetByteArrayRegion(env, genesis_hash, 0, 32, genesis_hash_ref.data);
24232         LDKNetworkGraph ret_var = NetworkGraph_new(genesis_hash_ref);
24233         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24234         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24235         uint64_t ret_ref = (uint64_t)ret_var.inner;
24236         if (ret_var.is_owned) {
24237                 ret_ref |= 1;
24238         }
24239         return ret_ref;
24240 }
24241
24242 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) {
24243         LDKNetworkGraph this_arg_conv;
24244         this_arg_conv.inner = (void*)(this_arg & (~1));
24245         this_arg_conv.is_owned = false;
24246         LDKNodeAnnouncement msg_conv;
24247         msg_conv.inner = (void*)(msg & (~1));
24248         msg_conv.is_owned = false;
24249         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
24250         *ret_conv = NetworkGraph_update_node_from_announcement(&this_arg_conv, &msg_conv);
24251         return (uint64_t)ret_conv;
24252 }
24253
24254 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) {
24255         LDKNetworkGraph this_arg_conv;
24256         this_arg_conv.inner = (void*)(this_arg & (~1));
24257         this_arg_conv.is_owned = false;
24258         LDKUnsignedNodeAnnouncement msg_conv;
24259         msg_conv.inner = (void*)(msg & (~1));
24260         msg_conv.is_owned = false;
24261         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
24262         *ret_conv = NetworkGraph_update_node_from_unsigned_announcement(&this_arg_conv, &msg_conv);
24263         return (uint64_t)ret_conv;
24264 }
24265
24266 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) {
24267         LDKNetworkGraph this_arg_conv;
24268         this_arg_conv.inner = (void*)(this_arg & (~1));
24269         this_arg_conv.is_owned = false;
24270         LDKChannelAnnouncement msg_conv;
24271         msg_conv.inner = (void*)(msg & (~1));
24272         msg_conv.is_owned = false;
24273         LDKAccess *chain_access_conv_ptr = NULL;
24274         if (chain_access != 0) {
24275                 LDKAccess chain_access_conv;
24276                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
24277                 if (chain_access_conv.free == LDKAccess_JCalls_free) {
24278                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24279                         LDKAccess_JCalls_clone(chain_access_conv.this_arg);
24280                 }
24281                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
24282                 *chain_access_conv_ptr = chain_access_conv;
24283         }
24284         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
24285         *ret_conv = NetworkGraph_update_channel_from_announcement(&this_arg_conv, &msg_conv, chain_access_conv_ptr);
24286         return (uint64_t)ret_conv;
24287 }
24288
24289 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) {
24290         LDKNetworkGraph this_arg_conv;
24291         this_arg_conv.inner = (void*)(this_arg & (~1));
24292         this_arg_conv.is_owned = false;
24293         LDKUnsignedChannelAnnouncement msg_conv;
24294         msg_conv.inner = (void*)(msg & (~1));
24295         msg_conv.is_owned = false;
24296         LDKAccess *chain_access_conv_ptr = NULL;
24297         if (chain_access != 0) {
24298                 LDKAccess chain_access_conv;
24299                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
24300                 if (chain_access_conv.free == LDKAccess_JCalls_free) {
24301                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24302                         LDKAccess_JCalls_clone(chain_access_conv.this_arg);
24303                 }
24304                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
24305                 *chain_access_conv_ptr = chain_access_conv;
24306         }
24307         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
24308         *ret_conv = NetworkGraph_update_channel_from_unsigned_announcement(&this_arg_conv, &msg_conv, chain_access_conv_ptr);
24309         return (uint64_t)ret_conv;
24310 }
24311
24312 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) {
24313         LDKNetworkGraph this_arg_conv;
24314         this_arg_conv.inner = (void*)(this_arg & (~1));
24315         this_arg_conv.is_owned = false;
24316         NetworkGraph_close_channel_from_update(&this_arg_conv, short_channel_id, is_permanent);
24317 }
24318
24319 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1update_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
24320         LDKNetworkGraph this_arg_conv;
24321         this_arg_conv.inner = (void*)(this_arg & (~1));
24322         this_arg_conv.is_owned = false;
24323         LDKChannelUpdate msg_conv;
24324         msg_conv.inner = (void*)(msg & (~1));
24325         msg_conv.is_owned = false;
24326         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
24327         *ret_conv = NetworkGraph_update_channel(&this_arg_conv, &msg_conv);
24328         return (uint64_t)ret_conv;
24329 }
24330
24331 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1update_1channel_1unsigned(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
24332         LDKNetworkGraph this_arg_conv;
24333         this_arg_conv.inner = (void*)(this_arg & (~1));
24334         this_arg_conv.is_owned = false;
24335         LDKUnsignedChannelUpdate msg_conv;
24336         msg_conv.inner = (void*)(msg & (~1));
24337         msg_conv.is_owned = false;
24338         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
24339         *ret_conv = NetworkGraph_update_channel_unsigned(&this_arg_conv, &msg_conv);
24340         return (uint64_t)ret_conv;
24341 }
24342
24343 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24344         LDKFilesystemPersister this_obj_conv;
24345         this_obj_conv.inner = (void*)(this_obj & (~1));
24346         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24347         FilesystemPersister_free(this_obj_conv);
24348 }
24349
24350 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1new(JNIEnv *env, jclass clz, jstring path_to_channel_data) {
24351         LDKStr path_to_channel_data_conv = java_to_owned_str(env, path_to_channel_data);
24352         LDKFilesystemPersister ret_var = FilesystemPersister_new(path_to_channel_data_conv);
24353         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24354         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24355         uint64_t ret_ref = (uint64_t)ret_var.inner;
24356         if (ret_var.is_owned) {
24357                 ret_ref |= 1;
24358         }
24359         return ret_ref;
24360 }
24361
24362 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1get_1data_1dir(JNIEnv *env, jclass clz, int64_t this_arg) {
24363         LDKFilesystemPersister this_arg_conv;
24364         this_arg_conv.inner = (void*)(this_arg & (~1));
24365         this_arg_conv.is_owned = false;
24366         LDKStr ret_str = FilesystemPersister_get_data_dir(&this_arg_conv);
24367         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
24368         return ret_conv;
24369 }
24370
24371 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1persist_1manager(JNIEnv *env, jclass clz, jstring data_dir, int64_t manager) {
24372         LDKStr data_dir_conv = java_to_owned_str(env, data_dir);
24373         LDKChannelManager manager_conv;
24374         manager_conv.inner = (void*)(manager & (~1));
24375         manager_conv.is_owned = false;
24376         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
24377         *ret_conv = FilesystemPersister_persist_manager(data_dir_conv, &manager_conv);
24378         return (uint64_t)ret_conv;
24379 }
24380
24381 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1read_1channelmonitors(JNIEnv *env, jclass clz, int64_t this_arg, int64_t keys_manager) {
24382         LDKFilesystemPersister this_arg_conv;
24383         this_arg_conv.inner = (void*)(this_arg & (~1));
24384         this_arg_conv.is_owned = false;
24385         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
24386         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
24387                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24388                 LDKKeysInterface_JCalls_clone(keys_manager_conv.this_arg);
24389         }
24390         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
24391         *ret_conv = FilesystemPersister_read_channelmonitors(&this_arg_conv, keys_manager_conv);
24392         return (uint64_t)ret_conv;
24393 }
24394
24395 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1as_1Persist(JNIEnv *env, jclass clz, int64_t this_arg) {
24396         LDKFilesystemPersister this_arg_conv;
24397         this_arg_conv.inner = (void*)(this_arg & (~1));
24398         this_arg_conv.is_owned = false;
24399         LDKPersist* ret = MALLOC(sizeof(LDKPersist), "LDKPersist");
24400         *ret = FilesystemPersister_as_Persist(&this_arg_conv);
24401         return (uint64_t)ret;
24402 }
24403
24404 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24405         LDKBackgroundProcessor this_obj_conv;
24406         this_obj_conv.inner = (void*)(this_obj & (~1));
24407         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24408         BackgroundProcessor_free(this_obj_conv);
24409 }
24410
24411 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerPersister_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
24412         if ((this_ptr & 1) != 0) return;
24413         LDKChannelManagerPersister this_ptr_conv = *(LDKChannelManagerPersister*)(((uint64_t)this_ptr) & ~1);
24414         FREE((void*)this_ptr);
24415         ChannelManagerPersister_free(this_ptr_conv);
24416 }
24417
24418 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) {
24419         LDKChannelManagerPersister persister_conv = *(LDKChannelManagerPersister*)(((uint64_t)persister) & ~1);
24420         if (persister_conv.free == LDKChannelManagerPersister_JCalls_free) {
24421                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24422                 LDKChannelManagerPersister_JCalls_clone(persister_conv.this_arg);
24423         }
24424         LDKEventHandler event_handler_conv = *(LDKEventHandler*)(((uint64_t)event_handler) & ~1);
24425         if (event_handler_conv.free == LDKEventHandler_JCalls_free) {
24426                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24427                 LDKEventHandler_JCalls_clone(event_handler_conv.this_arg);
24428         }
24429         LDKChainMonitor chain_monitor_conv;
24430         chain_monitor_conv.inner = (void*)(chain_monitor & (~1));
24431         chain_monitor_conv.is_owned = false;
24432         LDKChannelManager channel_manager_conv;
24433         channel_manager_conv.inner = (void*)(channel_manager & (~1));
24434         channel_manager_conv.is_owned = false;
24435         LDKPeerManager peer_manager_conv;
24436         peer_manager_conv.inner = (void*)(peer_manager & (~1));
24437         peer_manager_conv.is_owned = false;
24438         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
24439         if (logger_conv.free == LDKLogger_JCalls_free) {
24440                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24441                 LDKLogger_JCalls_clone(logger_conv.this_arg);
24442         }
24443         LDKBackgroundProcessor ret_var = BackgroundProcessor_start(persister_conv, event_handler_conv, &chain_monitor_conv, &channel_manager_conv, &peer_manager_conv, logger_conv);
24444         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24445         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24446         uint64_t ret_ref = (uint64_t)ret_var.inner;
24447         if (ret_var.is_owned) {
24448                 ret_ref |= 1;
24449         }
24450         return ret_ref;
24451 }
24452
24453 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1stop(JNIEnv *env, jclass clz, int64_t this_arg) {
24454         LDKBackgroundProcessor this_arg_conv;
24455         this_arg_conv.inner = (void*)(this_arg & (~1));
24456         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
24457         // Warning: we need a move here but no clone is available for LDKBackgroundProcessor
24458         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
24459         *ret_conv = BackgroundProcessor_stop(this_arg_conv);
24460         return (uint64_t)ret_conv;
24461 }
24462
24463 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_check_1platform(JNIEnv *env, jclass clz) {
24464         check_platform();
24465 }
24466
24467 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Invoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24468         LDKInvoice this_obj_conv;
24469         this_obj_conv.inner = (void*)(this_obj & (~1));
24470         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24471         Invoice_free(this_obj_conv);
24472 }
24473
24474 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Invoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
24475         LDKInvoice a_conv;
24476         a_conv.inner = (void*)(a & (~1));
24477         a_conv.is_owned = false;
24478         LDKInvoice b_conv;
24479         b_conv.inner = (void*)(b & (~1));
24480         b_conv.is_owned = false;
24481         jboolean ret_val = Invoice_eq(&a_conv, &b_conv);
24482         return ret_val;
24483 }
24484
24485 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24486         LDKInvoice orig_conv;
24487         orig_conv.inner = (void*)(orig & (~1));
24488         orig_conv.is_owned = false;
24489         LDKInvoice ret_var = Invoice_clone(&orig_conv);
24490         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24491         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24492         uint64_t ret_ref = (uint64_t)ret_var.inner;
24493         if (ret_var.is_owned) {
24494                 ret_ref |= 1;
24495         }
24496         return ret_ref;
24497 }
24498
24499 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24500         LDKSignedRawInvoice this_obj_conv;
24501         this_obj_conv.inner = (void*)(this_obj & (~1));
24502         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24503         SignedRawInvoice_free(this_obj_conv);
24504 }
24505
24506 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
24507         LDKSignedRawInvoice a_conv;
24508         a_conv.inner = (void*)(a & (~1));
24509         a_conv.is_owned = false;
24510         LDKSignedRawInvoice b_conv;
24511         b_conv.inner = (void*)(b & (~1));
24512         b_conv.is_owned = false;
24513         jboolean ret_val = SignedRawInvoice_eq(&a_conv, &b_conv);
24514         return ret_val;
24515 }
24516
24517 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24518         LDKSignedRawInvoice orig_conv;
24519         orig_conv.inner = (void*)(orig & (~1));
24520         orig_conv.is_owned = false;
24521         LDKSignedRawInvoice ret_var = SignedRawInvoice_clone(&orig_conv);
24522         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24523         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24524         uint64_t ret_ref = (uint64_t)ret_var.inner;
24525         if (ret_var.is_owned) {
24526                 ret_ref |= 1;
24527         }
24528         return ret_ref;
24529 }
24530
24531 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawInvoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24532         LDKRawInvoice this_obj_conv;
24533         this_obj_conv.inner = (void*)(this_obj & (~1));
24534         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24535         RawInvoice_free(this_obj_conv);
24536 }
24537
24538 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1get_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
24539         LDKRawInvoice this_ptr_conv;
24540         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24541         this_ptr_conv.is_owned = false;
24542         LDKRawDataPart ret_var = RawInvoice_get_data(&this_ptr_conv);
24543         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24544         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24545         uint64_t ret_ref = (uint64_t)ret_var.inner;
24546         if (ret_var.is_owned) {
24547                 ret_ref |= 1;
24548         }
24549         return ret_ref;
24550 }
24551
24552 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawInvoice_1set_1data(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24553         LDKRawInvoice this_ptr_conv;
24554         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24555         this_ptr_conv.is_owned = false;
24556         LDKRawDataPart val_conv;
24557         val_conv.inner = (void*)(val & (~1));
24558         val_conv.is_owned = (val & 1) || (val == 0);
24559         val_conv = RawDataPart_clone(&val_conv);
24560         RawInvoice_set_data(&this_ptr_conv, val_conv);
24561 }
24562
24563 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RawInvoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
24564         LDKRawInvoice a_conv;
24565         a_conv.inner = (void*)(a & (~1));
24566         a_conv.is_owned = false;
24567         LDKRawInvoice b_conv;
24568         b_conv.inner = (void*)(b & (~1));
24569         b_conv.is_owned = false;
24570         jboolean ret_val = RawInvoice_eq(&a_conv, &b_conv);
24571         return ret_val;
24572 }
24573
24574 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24575         LDKRawInvoice orig_conv;
24576         orig_conv.inner = (void*)(orig & (~1));
24577         orig_conv.is_owned = false;
24578         LDKRawInvoice ret_var = RawInvoice_clone(&orig_conv);
24579         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24580         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24581         uint64_t ret_ref = (uint64_t)ret_var.inner;
24582         if (ret_var.is_owned) {
24583                 ret_ref |= 1;
24584         }
24585         return ret_ref;
24586 }
24587
24588 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawDataPart_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24589         LDKRawDataPart this_obj_conv;
24590         this_obj_conv.inner = (void*)(this_obj & (~1));
24591         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24592         RawDataPart_free(this_obj_conv);
24593 }
24594
24595 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
24596         LDKRawDataPart this_ptr_conv;
24597         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24598         this_ptr_conv.is_owned = false;
24599         LDKPositiveTimestamp ret_var = RawDataPart_get_timestamp(&this_ptr_conv);
24600         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24601         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24602         uint64_t ret_ref = (uint64_t)ret_var.inner;
24603         if (ret_var.is_owned) {
24604                 ret_ref |= 1;
24605         }
24606         return ret_ref;
24607 }
24608
24609 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawDataPart_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24610         LDKRawDataPart this_ptr_conv;
24611         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24612         this_ptr_conv.is_owned = false;
24613         LDKPositiveTimestamp val_conv;
24614         val_conv.inner = (void*)(val & (~1));
24615         val_conv.is_owned = (val & 1) || (val == 0);
24616         val_conv = PositiveTimestamp_clone(&val_conv);
24617         RawDataPart_set_timestamp(&this_ptr_conv, val_conv);
24618 }
24619
24620 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RawDataPart_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
24621         LDKRawDataPart a_conv;
24622         a_conv.inner = (void*)(a & (~1));
24623         a_conv.is_owned = false;
24624         LDKRawDataPart b_conv;
24625         b_conv.inner = (void*)(b & (~1));
24626         b_conv.is_owned = false;
24627         jboolean ret_val = RawDataPart_eq(&a_conv, &b_conv);
24628         return ret_val;
24629 }
24630
24631 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24632         LDKRawDataPart orig_conv;
24633         orig_conv.inner = (void*)(orig & (~1));
24634         orig_conv.is_owned = false;
24635         LDKRawDataPart ret_var = RawDataPart_clone(&orig_conv);
24636         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24637         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24638         uint64_t ret_ref = (uint64_t)ret_var.inner;
24639         if (ret_var.is_owned) {
24640                 ret_ref |= 1;
24641         }
24642         return ret_ref;
24643 }
24644
24645 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24646         LDKPositiveTimestamp this_obj_conv;
24647         this_obj_conv.inner = (void*)(this_obj & (~1));
24648         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24649         PositiveTimestamp_free(this_obj_conv);
24650 }
24651
24652 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
24653         LDKPositiveTimestamp a_conv;
24654         a_conv.inner = (void*)(a & (~1));
24655         a_conv.is_owned = false;
24656         LDKPositiveTimestamp b_conv;
24657         b_conv.inner = (void*)(b & (~1));
24658         b_conv.is_owned = false;
24659         jboolean ret_val = PositiveTimestamp_eq(&a_conv, &b_conv);
24660         return ret_val;
24661 }
24662
24663 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24664         LDKPositiveTimestamp orig_conv;
24665         orig_conv.inner = (void*)(orig & (~1));
24666         orig_conv.is_owned = false;
24667         LDKPositiveTimestamp ret_var = PositiveTimestamp_clone(&orig_conv);
24668         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24669         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24670         uint64_t ret_ref = (uint64_t)ret_var.inner;
24671         if (ret_var.is_owned) {
24672                 ret_ref |= 1;
24673         }
24674         return ret_ref;
24675 }
24676
24677 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24678         LDKSiPrefix* orig_conv = (LDKSiPrefix*)(orig & ~1);
24679         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_clone(orig_conv));
24680         return ret_conv;
24681 }
24682
24683 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SiPrefix_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
24684         LDKSiPrefix* a_conv = (LDKSiPrefix*)(a & ~1);
24685         LDKSiPrefix* b_conv = (LDKSiPrefix*)(b & ~1);
24686         jboolean ret_val = SiPrefix_eq(a_conv, b_conv);
24687         return ret_val;
24688 }
24689
24690 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SiPrefix_1multiplier(JNIEnv *env, jclass clz, int64_t this_arg) {
24691         LDKSiPrefix* this_arg_conv = (LDKSiPrefix*)(this_arg & ~1);
24692         int64_t ret_val = SiPrefix_multiplier(this_arg_conv);
24693         return ret_val;
24694 }
24695
24696 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24697         LDKCurrency* orig_conv = (LDKCurrency*)(orig & ~1);
24698         jclass ret_conv = LDKCurrency_to_java(env, Currency_clone(orig_conv));
24699         return ret_conv;
24700 }
24701
24702 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Currency_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
24703         LDKCurrency* a_conv = (LDKCurrency*)(a & ~1);
24704         LDKCurrency* b_conv = (LDKCurrency*)(b & ~1);
24705         jboolean ret_val = Currency_eq(a_conv, b_conv);
24706         return ret_val;
24707 }
24708
24709 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Sha256_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24710         LDKSha256 this_obj_conv;
24711         this_obj_conv.inner = (void*)(this_obj & (~1));
24712         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24713         Sha256_free(this_obj_conv);
24714 }
24715
24716 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Sha256_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
24717         LDKSha256 a_conv;
24718         a_conv.inner = (void*)(a & (~1));
24719         a_conv.is_owned = false;
24720         LDKSha256 b_conv;
24721         b_conv.inner = (void*)(b & (~1));
24722         b_conv.is_owned = false;
24723         jboolean ret_val = Sha256_eq(&a_conv, &b_conv);
24724         return ret_val;
24725 }
24726
24727 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sha256_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24728         LDKSha256 orig_conv;
24729         orig_conv.inner = (void*)(orig & (~1));
24730         orig_conv.is_owned = false;
24731         LDKSha256 ret_var = Sha256_clone(&orig_conv);
24732         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24733         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24734         uint64_t ret_ref = (uint64_t)ret_var.inner;
24735         if (ret_var.is_owned) {
24736                 ret_ref |= 1;
24737         }
24738         return ret_ref;
24739 }
24740
24741 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Description_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24742         LDKDescription this_obj_conv;
24743         this_obj_conv.inner = (void*)(this_obj & (~1));
24744         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24745         Description_free(this_obj_conv);
24746 }
24747
24748 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Description_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
24749         LDKDescription a_conv;
24750         a_conv.inner = (void*)(a & (~1));
24751         a_conv.is_owned = false;
24752         LDKDescription b_conv;
24753         b_conv.inner = (void*)(b & (~1));
24754         b_conv.is_owned = false;
24755         jboolean ret_val = Description_eq(&a_conv, &b_conv);
24756         return ret_val;
24757 }
24758
24759 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24760         LDKDescription orig_conv;
24761         orig_conv.inner = (void*)(orig & (~1));
24762         orig_conv.is_owned = false;
24763         LDKDescription ret_var = Description_clone(&orig_conv);
24764         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24765         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24766         uint64_t ret_ref = (uint64_t)ret_var.inner;
24767         if (ret_var.is_owned) {
24768                 ret_ref |= 1;
24769         }
24770         return ret_ref;
24771 }
24772
24773 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24774         LDKPayeePubKey this_obj_conv;
24775         this_obj_conv.inner = (void*)(this_obj & (~1));
24776         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24777         PayeePubKey_free(this_obj_conv);
24778 }
24779
24780 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
24781         LDKPayeePubKey a_conv;
24782         a_conv.inner = (void*)(a & (~1));
24783         a_conv.is_owned = false;
24784         LDKPayeePubKey b_conv;
24785         b_conv.inner = (void*)(b & (~1));
24786         b_conv.is_owned = false;
24787         jboolean ret_val = PayeePubKey_eq(&a_conv, &b_conv);
24788         return ret_val;
24789 }
24790
24791 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24792         LDKPayeePubKey orig_conv;
24793         orig_conv.inner = (void*)(orig & (~1));
24794         orig_conv.is_owned = false;
24795         LDKPayeePubKey ret_var = PayeePubKey_clone(&orig_conv);
24796         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24797         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24798         uint64_t ret_ref = (uint64_t)ret_var.inner;
24799         if (ret_var.is_owned) {
24800                 ret_ref |= 1;
24801         }
24802         return ret_ref;
24803 }
24804
24805 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24806         LDKExpiryTime this_obj_conv;
24807         this_obj_conv.inner = (void*)(this_obj & (~1));
24808         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24809         ExpiryTime_free(this_obj_conv);
24810 }
24811
24812 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
24813         LDKExpiryTime a_conv;
24814         a_conv.inner = (void*)(a & (~1));
24815         a_conv.is_owned = false;
24816         LDKExpiryTime b_conv;
24817         b_conv.inner = (void*)(b & (~1));
24818         b_conv.is_owned = false;
24819         jboolean ret_val = ExpiryTime_eq(&a_conv, &b_conv);
24820         return ret_val;
24821 }
24822
24823 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24824         LDKExpiryTime orig_conv;
24825         orig_conv.inner = (void*)(orig & (~1));
24826         orig_conv.is_owned = false;
24827         LDKExpiryTime ret_var = ExpiryTime_clone(&orig_conv);
24828         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24829         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24830         uint64_t ret_ref = (uint64_t)ret_var.inner;
24831         if (ret_var.is_owned) {
24832                 ret_ref |= 1;
24833         }
24834         return ret_ref;
24835 }
24836
24837 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24838         LDKMinFinalCltvExpiry this_obj_conv;
24839         this_obj_conv.inner = (void*)(this_obj & (~1));
24840         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24841         MinFinalCltvExpiry_free(this_obj_conv);
24842 }
24843
24844 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
24845         LDKMinFinalCltvExpiry a_conv;
24846         a_conv.inner = (void*)(a & (~1));
24847         a_conv.is_owned = false;
24848         LDKMinFinalCltvExpiry b_conv;
24849         b_conv.inner = (void*)(b & (~1));
24850         b_conv.is_owned = false;
24851         jboolean ret_val = MinFinalCltvExpiry_eq(&a_conv, &b_conv);
24852         return ret_val;
24853 }
24854
24855 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24856         LDKMinFinalCltvExpiry orig_conv;
24857         orig_conv.inner = (void*)(orig & (~1));
24858         orig_conv.is_owned = false;
24859         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_clone(&orig_conv);
24860         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24861         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24862         uint64_t ret_ref = (uint64_t)ret_var.inner;
24863         if (ret_var.is_owned) {
24864                 ret_ref |= 1;
24865         }
24866         return ret_ref;
24867 }
24868
24869 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Fallback_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
24870         if ((this_ptr & 1) != 0) return;
24871         LDKFallback this_ptr_conv = *(LDKFallback*)(((uint64_t)this_ptr) & ~1);
24872         FREE((void*)this_ptr);
24873         Fallback_free(this_ptr_conv);
24874 }
24875
24876 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24877         LDKFallback* orig_conv = (LDKFallback*)orig;
24878         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
24879         *ret_copy = Fallback_clone(orig_conv);
24880         uint64_t ret_ref = (uint64_t)ret_copy;
24881         return ret_ref;
24882 }
24883
24884 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Fallback_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
24885         LDKFallback* a_conv = (LDKFallback*)a;
24886         LDKFallback* b_conv = (LDKFallback*)b;
24887         jboolean ret_val = Fallback_eq(a_conv, b_conv);
24888         return ret_val;
24889 }
24890
24891 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24892         LDKInvoiceSignature this_obj_conv;
24893         this_obj_conv.inner = (void*)(this_obj & (~1));
24894         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24895         InvoiceSignature_free(this_obj_conv);
24896 }
24897
24898 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
24899         LDKInvoiceSignature a_conv;
24900         a_conv.inner = (void*)(a & (~1));
24901         a_conv.is_owned = false;
24902         LDKInvoiceSignature b_conv;
24903         b_conv.inner = (void*)(b & (~1));
24904         b_conv.is_owned = false;
24905         jboolean ret_val = InvoiceSignature_eq(&a_conv, &b_conv);
24906         return ret_val;
24907 }
24908
24909 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24910         LDKInvoiceSignature orig_conv;
24911         orig_conv.inner = (void*)(orig & (~1));
24912         orig_conv.is_owned = false;
24913         LDKInvoiceSignature ret_var = InvoiceSignature_clone(&orig_conv);
24914         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24915         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24916         uint64_t ret_ref = (uint64_t)ret_var.inner;
24917         if (ret_var.is_owned) {
24918                 ret_ref |= 1;
24919         }
24920         return ret_ref;
24921 }
24922
24923 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24924         LDKPrivateRoute this_obj_conv;
24925         this_obj_conv.inner = (void*)(this_obj & (~1));
24926         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24927         PrivateRoute_free(this_obj_conv);
24928 }
24929
24930 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
24931         LDKPrivateRoute a_conv;
24932         a_conv.inner = (void*)(a & (~1));
24933         a_conv.is_owned = false;
24934         LDKPrivateRoute b_conv;
24935         b_conv.inner = (void*)(b & (~1));
24936         b_conv.is_owned = false;
24937         jboolean ret_val = PrivateRoute_eq(&a_conv, &b_conv);
24938         return ret_val;
24939 }
24940
24941 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24942         LDKPrivateRoute orig_conv;
24943         orig_conv.inner = (void*)(orig & (~1));
24944         orig_conv.is_owned = false;
24945         LDKPrivateRoute ret_var = PrivateRoute_clone(&orig_conv);
24946         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24947         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24948         uint64_t ret_ref = (uint64_t)ret_var.inner;
24949         if (ret_var.is_owned) {
24950                 ret_ref |= 1;
24951         }
24952         return ret_ref;
24953 }
24954
24955 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1into_1parts(JNIEnv *env, jclass clz, int64_t this_arg) {
24956         LDKSignedRawInvoice this_arg_conv;
24957         this_arg_conv.inner = (void*)(this_arg & (~1));
24958         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
24959         this_arg_conv = SignedRawInvoice_clone(&this_arg_conv);
24960         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_ref = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
24961         *ret_ref = SignedRawInvoice_into_parts(this_arg_conv);
24962         return (uint64_t)ret_ref;
24963 }
24964
24965 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1raw_1invoice(JNIEnv *env, jclass clz, int64_t this_arg) {
24966         LDKSignedRawInvoice this_arg_conv;
24967         this_arg_conv.inner = (void*)(this_arg & (~1));
24968         this_arg_conv.is_owned = false;
24969         LDKRawInvoice ret_var = SignedRawInvoice_raw_invoice(&this_arg_conv);
24970         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24971         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24972         uint64_t ret_ref = (uint64_t)ret_var.inner;
24973         if (ret_var.is_owned) {
24974                 ret_ref |= 1;
24975         }
24976         return ret_ref;
24977 }
24978
24979 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
24980         LDKSignedRawInvoice this_arg_conv;
24981         this_arg_conv.inner = (void*)(this_arg & (~1));
24982         this_arg_conv.is_owned = false;
24983         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
24984         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *SignedRawInvoice_hash(&this_arg_conv));
24985         return ret_arr;
24986 }
24987
24988 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
24989         LDKSignedRawInvoice this_arg_conv;
24990         this_arg_conv.inner = (void*)(this_arg & (~1));
24991         this_arg_conv.is_owned = false;
24992         LDKInvoiceSignature ret_var = SignedRawInvoice_signature(&this_arg_conv);
24993         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24994         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24995         uint64_t ret_ref = (uint64_t)ret_var.inner;
24996         if (ret_var.is_owned) {
24997                 ret_ref |= 1;
24998         }
24999         return ret_ref;
25000 }
25001
25002 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1recover_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
25003         LDKSignedRawInvoice this_arg_conv;
25004         this_arg_conv.inner = (void*)(this_arg & (~1));
25005         this_arg_conv.is_owned = false;
25006         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
25007         *ret_conv = SignedRawInvoice_recover_payee_pub_key(&this_arg_conv);
25008         return (uint64_t)ret_conv;
25009 }
25010
25011 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1check_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
25012         LDKSignedRawInvoice this_arg_conv;
25013         this_arg_conv.inner = (void*)(this_arg & (~1));
25014         this_arg_conv.is_owned = false;
25015         jboolean ret_val = SignedRawInvoice_check_signature(&this_arg_conv);
25016         return ret_val;
25017 }
25018
25019 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
25020         LDKRawInvoice this_arg_conv;
25021         this_arg_conv.inner = (void*)(this_arg & (~1));
25022         this_arg_conv.is_owned = false;
25023         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
25024         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, RawInvoice_hash(&this_arg_conv).data);
25025         return ret_arr;
25026 }
25027
25028 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
25029         LDKRawInvoice this_arg_conv;
25030         this_arg_conv.inner = (void*)(this_arg & (~1));
25031         this_arg_conv.is_owned = false;
25032         LDKSha256 ret_var = RawInvoice_payment_hash(&this_arg_conv);
25033         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25034         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25035         uint64_t ret_ref = (uint64_t)ret_var.inner;
25036         if (ret_var.is_owned) {
25037                 ret_ref |= 1;
25038         }
25039         return ret_ref;
25040 }
25041
25042 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1description(JNIEnv *env, jclass clz, int64_t this_arg) {
25043         LDKRawInvoice this_arg_conv;
25044         this_arg_conv.inner = (void*)(this_arg & (~1));
25045         this_arg_conv.is_owned = false;
25046         LDKDescription ret_var = RawInvoice_description(&this_arg_conv);
25047         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25048         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25049         uint64_t ret_ref = (uint64_t)ret_var.inner;
25050         if (ret_var.is_owned) {
25051                 ret_ref |= 1;
25052         }
25053         return ret_ref;
25054 }
25055
25056 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
25057         LDKRawInvoice this_arg_conv;
25058         this_arg_conv.inner = (void*)(this_arg & (~1));
25059         this_arg_conv.is_owned = false;
25060         LDKPayeePubKey ret_var = RawInvoice_payee_pub_key(&this_arg_conv);
25061         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25062         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25063         uint64_t ret_ref = (uint64_t)ret_var.inner;
25064         if (ret_var.is_owned) {
25065                 ret_ref |= 1;
25066         }
25067         return ret_ref;
25068 }
25069
25070 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1description_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
25071         LDKRawInvoice this_arg_conv;
25072         this_arg_conv.inner = (void*)(this_arg & (~1));
25073         this_arg_conv.is_owned = false;
25074         LDKSha256 ret_var = RawInvoice_description_hash(&this_arg_conv);
25075         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25076         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25077         uint64_t ret_ref = (uint64_t)ret_var.inner;
25078         if (ret_var.is_owned) {
25079                 ret_ref |= 1;
25080         }
25081         return ret_ref;
25082 }
25083
25084 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
25085         LDKRawInvoice this_arg_conv;
25086         this_arg_conv.inner = (void*)(this_arg & (~1));
25087         this_arg_conv.is_owned = false;
25088         LDKExpiryTime ret_var = RawInvoice_expiry_time(&this_arg_conv);
25089         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25090         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25091         uint64_t ret_ref = (uint64_t)ret_var.inner;
25092         if (ret_var.is_owned) {
25093                 ret_ref |= 1;
25094         }
25095         return ret_ref;
25096 }
25097
25098 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1min_1final_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_arg) {
25099         LDKRawInvoice this_arg_conv;
25100         this_arg_conv.inner = (void*)(this_arg & (~1));
25101         this_arg_conv.is_owned = false;
25102         LDKMinFinalCltvExpiry ret_var = RawInvoice_min_final_cltv_expiry(&this_arg_conv);
25103         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25104         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25105         uint64_t ret_ref = (uint64_t)ret_var.inner;
25106         if (ret_var.is_owned) {
25107                 ret_ref |= 1;
25108         }
25109         return ret_ref;
25110 }
25111
25112 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
25113         LDKRawInvoice this_arg_conv;
25114         this_arg_conv.inner = (void*)(this_arg & (~1));
25115         this_arg_conv.is_owned = false;
25116         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
25117         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, RawInvoice_payment_secret(&this_arg_conv).data);
25118         return ret_arr;
25119 }
25120
25121 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
25122         LDKRawInvoice this_arg_conv;
25123         this_arg_conv.inner = (void*)(this_arg & (~1));
25124         this_arg_conv.is_owned = false;
25125         LDKInvoiceFeatures ret_var = RawInvoice_features(&this_arg_conv);
25126         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25127         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25128         uint64_t ret_ref = (uint64_t)ret_var.inner;
25129         if (ret_var.is_owned) {
25130                 ret_ref |= 1;
25131         }
25132         return ret_ref;
25133 }
25134
25135 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1private_1routes(JNIEnv *env, jclass clz, int64_t this_arg) {
25136         LDKRawInvoice this_arg_conv;
25137         this_arg_conv.inner = (void*)(this_arg & (~1));
25138         this_arg_conv.is_owned = false;
25139         LDKCVec_PrivateRouteZ ret_var = RawInvoice_private_routes(&this_arg_conv);
25140         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
25141         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
25142         for (size_t o = 0; o < ret_var.datalen; o++) {
25143                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
25144                 CHECK((((uint64_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25145                 CHECK((((uint64_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25146                 uint64_t ret_conv_14_ref = (uint64_t)ret_conv_14_var.inner;
25147                 if (ret_conv_14_var.is_owned) {
25148                         ret_conv_14_ref |= 1;
25149                 }
25150                 ret_arr_ptr[o] = ret_conv_14_ref;
25151         }
25152         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
25153         FREE(ret_var.data);
25154         return ret_arr;
25155 }
25156
25157 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1amount_1pico_1btc(JNIEnv *env, jclass clz, int64_t this_arg) {
25158         LDKRawInvoice this_arg_conv;
25159         this_arg_conv.inner = (void*)(this_arg & (~1));
25160         this_arg_conv.is_owned = false;
25161         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
25162         *ret_copy = RawInvoice_amount_pico_btc(&this_arg_conv);
25163         uint64_t ret_ref = (uint64_t)ret_copy;
25164         return ret_ref;
25165 }
25166
25167 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_RawInvoice_1currency(JNIEnv *env, jclass clz, int64_t this_arg) {
25168         LDKRawInvoice this_arg_conv;
25169         this_arg_conv.inner = (void*)(this_arg & (~1));
25170         this_arg_conv.is_owned = false;
25171         jclass ret_conv = LDKCurrency_to_java(env, RawInvoice_currency(&this_arg_conv));
25172         return ret_conv;
25173 }
25174
25175 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1from_1unix_1timestamp(JNIEnv *env, jclass clz, int64_t unix_seconds) {
25176         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
25177         *ret_conv = PositiveTimestamp_from_unix_timestamp(unix_seconds);
25178         return (uint64_t)ret_conv;
25179 }
25180
25181 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1from_1system_1time(JNIEnv *env, jclass clz, int64_t time) {
25182         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
25183         *ret_conv = PositiveTimestamp_from_system_time(time);
25184         return (uint64_t)ret_conv;
25185 }
25186
25187 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1as_1unix_1timestamp(JNIEnv *env, jclass clz, int64_t this_arg) {
25188         LDKPositiveTimestamp this_arg_conv;
25189         this_arg_conv.inner = (void*)(this_arg & (~1));
25190         this_arg_conv.is_owned = false;
25191         int64_t ret_val = PositiveTimestamp_as_unix_timestamp(&this_arg_conv);
25192         return ret_val;
25193 }
25194
25195 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1as_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
25196         LDKPositiveTimestamp this_arg_conv;
25197         this_arg_conv.inner = (void*)(this_arg & (~1));
25198         this_arg_conv.is_owned = false;
25199         int64_t ret_val = PositiveTimestamp_as_time(&this_arg_conv);
25200         return ret_val;
25201 }
25202
25203 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1into_1signed_1raw(JNIEnv *env, jclass clz, int64_t this_arg) {
25204         LDKInvoice this_arg_conv;
25205         this_arg_conv.inner = (void*)(this_arg & (~1));
25206         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
25207         this_arg_conv = Invoice_clone(&this_arg_conv);
25208         LDKSignedRawInvoice ret_var = Invoice_into_signed_raw(this_arg_conv);
25209         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25210         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25211         uint64_t ret_ref = (uint64_t)ret_var.inner;
25212         if (ret_var.is_owned) {
25213                 ret_ref |= 1;
25214         }
25215         return ret_ref;
25216 }
25217
25218 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1check_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
25219         LDKInvoice this_arg_conv;
25220         this_arg_conv.inner = (void*)(this_arg & (~1));
25221         this_arg_conv.is_owned = false;
25222         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
25223         *ret_conv = Invoice_check_signature(&this_arg_conv);
25224         return (uint64_t)ret_conv;
25225 }
25226
25227 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1from_1signed(JNIEnv *env, jclass clz, int64_t signed_invoice) {
25228         LDKSignedRawInvoice signed_invoice_conv;
25229         signed_invoice_conv.inner = (void*)(signed_invoice & (~1));
25230         signed_invoice_conv.is_owned = (signed_invoice & 1) || (signed_invoice == 0);
25231         signed_invoice_conv = SignedRawInvoice_clone(&signed_invoice_conv);
25232         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
25233         *ret_conv = Invoice_from_signed(signed_invoice_conv);
25234         return (uint64_t)ret_conv;
25235 }
25236
25237 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1timestamp(JNIEnv *env, jclass clz, int64_t this_arg) {
25238         LDKInvoice this_arg_conv;
25239         this_arg_conv.inner = (void*)(this_arg & (~1));
25240         this_arg_conv.is_owned = false;
25241         int64_t ret_val = Invoice_timestamp(&this_arg_conv);
25242         return ret_val;
25243 }
25244
25245 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
25246         LDKInvoice this_arg_conv;
25247         this_arg_conv.inner = (void*)(this_arg & (~1));
25248         this_arg_conv.is_owned = false;
25249         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
25250         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *Invoice_payment_hash(&this_arg_conv));
25251         return ret_arr;
25252 }
25253
25254 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
25255         LDKInvoice this_arg_conv;
25256         this_arg_conv.inner = (void*)(this_arg & (~1));
25257         this_arg_conv.is_owned = false;
25258         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
25259         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, Invoice_payee_pub_key(&this_arg_conv).compressed_form);
25260         return ret_arr;
25261 }
25262
25263 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
25264         LDKInvoice this_arg_conv;
25265         this_arg_conv.inner = (void*)(this_arg & (~1));
25266         this_arg_conv.is_owned = false;
25267         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
25268         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, Invoice_payment_secret(&this_arg_conv).data);
25269         return ret_arr;
25270 }
25271
25272 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
25273         LDKInvoice this_arg_conv;
25274         this_arg_conv.inner = (void*)(this_arg & (~1));
25275         this_arg_conv.is_owned = false;
25276         LDKInvoiceFeatures ret_var = Invoice_features(&this_arg_conv);
25277         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25278         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25279         uint64_t ret_ref = (uint64_t)ret_var.inner;
25280         if (ret_var.is_owned) {
25281                 ret_ref |= 1;
25282         }
25283         return ret_ref;
25284 }
25285
25286 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1recover_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
25287         LDKInvoice this_arg_conv;
25288         this_arg_conv.inner = (void*)(this_arg & (~1));
25289         this_arg_conv.is_owned = false;
25290         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
25291         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, Invoice_recover_payee_pub_key(&this_arg_conv).compressed_form);
25292         return ret_arr;
25293 }
25294
25295 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
25296         LDKInvoice this_arg_conv;
25297         this_arg_conv.inner = (void*)(this_arg & (~1));
25298         this_arg_conv.is_owned = false;
25299         int64_t ret_val = Invoice_expiry_time(&this_arg_conv);
25300         return ret_val;
25301 }
25302
25303 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1min_1final_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_arg) {
25304         LDKInvoice this_arg_conv;
25305         this_arg_conv.inner = (void*)(this_arg & (~1));
25306         this_arg_conv.is_owned = false;
25307         int64_t ret_val = Invoice_min_final_cltv_expiry(&this_arg_conv);
25308         return ret_val;
25309 }
25310
25311 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1private_1routes(JNIEnv *env, jclass clz, int64_t this_arg) {
25312         LDKInvoice this_arg_conv;
25313         this_arg_conv.inner = (void*)(this_arg & (~1));
25314         this_arg_conv.is_owned = false;
25315         LDKCVec_PrivateRouteZ ret_var = Invoice_private_routes(&this_arg_conv);
25316         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
25317         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
25318         for (size_t o = 0; o < ret_var.datalen; o++) {
25319                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
25320                 CHECK((((uint64_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25321                 CHECK((((uint64_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25322                 uint64_t ret_conv_14_ref = (uint64_t)ret_conv_14_var.inner;
25323                 if (ret_conv_14_var.is_owned) {
25324                         ret_conv_14_ref |= 1;
25325                 }
25326                 ret_arr_ptr[o] = ret_conv_14_ref;
25327         }
25328         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
25329         FREE(ret_var.data);
25330         return ret_arr;
25331 }
25332
25333 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1route_1hints(JNIEnv *env, jclass clz, int64_t this_arg) {
25334         LDKInvoice this_arg_conv;
25335         this_arg_conv.inner = (void*)(this_arg & (~1));
25336         this_arg_conv.is_owned = false;
25337         LDKCVec_RouteHintZ ret_var = Invoice_route_hints(&this_arg_conv);
25338         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
25339         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
25340         for (size_t l = 0; l < ret_var.datalen; l++) {
25341                 LDKRouteHint ret_conv_11_var = ret_var.data[l];
25342                 CHECK((((uint64_t)ret_conv_11_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25343                 CHECK((((uint64_t)&ret_conv_11_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25344                 uint64_t ret_conv_11_ref = (uint64_t)ret_conv_11_var.inner;
25345                 if (ret_conv_11_var.is_owned) {
25346                         ret_conv_11_ref |= 1;
25347                 }
25348                 ret_arr_ptr[l] = ret_conv_11_ref;
25349         }
25350         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
25351         FREE(ret_var.data);
25352         return ret_arr;
25353 }
25354
25355 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Invoice_1currency(JNIEnv *env, jclass clz, int64_t this_arg) {
25356         LDKInvoice this_arg_conv;
25357         this_arg_conv.inner = (void*)(this_arg & (~1));
25358         this_arg_conv.is_owned = false;
25359         jclass ret_conv = LDKCurrency_to_java(env, Invoice_currency(&this_arg_conv));
25360         return ret_conv;
25361 }
25362
25363 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1amount_1pico_1btc(JNIEnv *env, jclass clz, int64_t this_arg) {
25364         LDKInvoice this_arg_conv;
25365         this_arg_conv.inner = (void*)(this_arg & (~1));
25366         this_arg_conv.is_owned = false;
25367         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
25368         *ret_copy = Invoice_amount_pico_btc(&this_arg_conv);
25369         uint64_t ret_ref = (uint64_t)ret_copy;
25370         return ret_ref;
25371 }
25372
25373 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1new(JNIEnv *env, jclass clz, jstring description) {
25374         LDKStr description_conv = java_to_owned_str(env, description);
25375         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
25376         *ret_conv = Description_new(description_conv);
25377         return (uint64_t)ret_conv;
25378 }
25379
25380 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Description_1into_1inner(JNIEnv *env, jclass clz, int64_t this_arg) {
25381         LDKDescription this_arg_conv;
25382         this_arg_conv.inner = (void*)(this_arg & (~1));
25383         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
25384         this_arg_conv = Description_clone(&this_arg_conv);
25385         LDKStr ret_str = Description_into_inner(this_arg_conv);
25386         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
25387         return ret_conv;
25388 }
25389
25390 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1from_1seconds(JNIEnv *env, jclass clz, int64_t seconds) {
25391         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
25392         *ret_conv = ExpiryTime_from_seconds(seconds);
25393         return (uint64_t)ret_conv;
25394 }
25395
25396 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1from_1duration(JNIEnv *env, jclass clz, int64_t duration) {
25397         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
25398         *ret_conv = ExpiryTime_from_duration(duration);
25399         return (uint64_t)ret_conv;
25400 }
25401
25402 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1as_1seconds(JNIEnv *env, jclass clz, int64_t this_arg) {
25403         LDKExpiryTime this_arg_conv;
25404         this_arg_conv.inner = (void*)(this_arg & (~1));
25405         this_arg_conv.is_owned = false;
25406         int64_t ret_val = ExpiryTime_as_seconds(&this_arg_conv);
25407         return ret_val;
25408 }
25409
25410 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1as_1duration(JNIEnv *env, jclass clz, int64_t this_arg) {
25411         LDKExpiryTime this_arg_conv;
25412         this_arg_conv.inner = (void*)(this_arg & (~1));
25413         this_arg_conv.is_owned = false;
25414         int64_t ret_val = ExpiryTime_as_duration(&this_arg_conv);
25415         return ret_val;
25416 }
25417
25418 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1new(JNIEnv *env, jclass clz, int64_t hops) {
25419         LDKRouteHint hops_conv;
25420         hops_conv.inner = (void*)(hops & (~1));
25421         hops_conv.is_owned = (hops & 1) || (hops == 0);
25422         hops_conv = RouteHint_clone(&hops_conv);
25423         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
25424         *ret_conv = PrivateRoute_new(hops_conv);
25425         return (uint64_t)ret_conv;
25426 }
25427
25428 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1into_1inner(JNIEnv *env, jclass clz, int64_t this_arg) {
25429         LDKPrivateRoute this_arg_conv;
25430         this_arg_conv.inner = (void*)(this_arg & (~1));
25431         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
25432         this_arg_conv = PrivateRoute_clone(&this_arg_conv);
25433         LDKRouteHint ret_var = PrivateRoute_into_inner(this_arg_conv);
25434         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25435         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25436         uint64_t ret_ref = (uint64_t)ret_var.inner;
25437         if (ret_var.is_owned) {
25438                 ret_ref |= 1;
25439         }
25440         return ret_ref;
25441 }
25442
25443 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25444         LDKCreationError* orig_conv = (LDKCreationError*)(orig & ~1);
25445         jclass ret_conv = LDKCreationError_to_java(env, CreationError_clone(orig_conv));
25446         return ret_conv;
25447 }
25448
25449 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CreationError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
25450         LDKCreationError* a_conv = (LDKCreationError*)(a & ~1);
25451         LDKCreationError* b_conv = (LDKCreationError*)(b & ~1);
25452         jboolean ret_val = CreationError_eq(a_conv, b_conv);
25453         return ret_val;
25454 }
25455
25456 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_CreationError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
25457         LDKCreationError* o_conv = (LDKCreationError*)(o & ~1);
25458         LDKStr ret_str = CreationError_to_str(o_conv);
25459         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
25460         return ret_conv;
25461 }
25462
25463 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25464         LDKSemanticError* orig_conv = (LDKSemanticError*)(orig & ~1);
25465         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_clone(orig_conv));
25466         return ret_conv;
25467 }
25468
25469 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SemanticError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
25470         LDKSemanticError* a_conv = (LDKSemanticError*)(a & ~1);
25471         LDKSemanticError* b_conv = (LDKSemanticError*)(b & ~1);
25472         jboolean ret_val = SemanticError_eq(a_conv, b_conv);
25473         return ret_val;
25474 }
25475
25476 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SemanticError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
25477         LDKSemanticError* o_conv = (LDKSemanticError*)(o & ~1);
25478         LDKStr ret_str = SemanticError_to_str(o_conv);
25479         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
25480         return ret_conv;
25481 }
25482
25483 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
25484         if ((this_ptr & 1) != 0) return;
25485         LDKSignOrCreationError this_ptr_conv = *(LDKSignOrCreationError*)(((uint64_t)this_ptr) & ~1);
25486         FREE((void*)this_ptr);
25487         SignOrCreationError_free(this_ptr_conv);
25488 }
25489
25490 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25491         LDKSignOrCreationError* orig_conv = (LDKSignOrCreationError*)orig;
25492         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
25493         *ret_copy = SignOrCreationError_clone(orig_conv);
25494         uint64_t ret_ref = (uint64_t)ret_copy;
25495         return ret_ref;
25496 }
25497
25498 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
25499         LDKSignOrCreationError* a_conv = (LDKSignOrCreationError*)a;
25500         LDKSignOrCreationError* b_conv = (LDKSignOrCreationError*)b;
25501         jboolean ret_val = SignOrCreationError_eq(a_conv, b_conv);
25502         return ret_val;
25503 }
25504
25505 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
25506         LDKSignOrCreationError* o_conv = (LDKSignOrCreationError*)o;
25507         LDKStr ret_str = SignOrCreationError_to_str(o_conv);
25508         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
25509         return ret_conv;
25510 }
25511
25512 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) {
25513         LDKChannelManager channelmanager_conv;
25514         channelmanager_conv.inner = (void*)(channelmanager & (~1));
25515         channelmanager_conv.is_owned = false;
25516         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
25517         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
25518                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25519                 LDKKeysInterface_JCalls_clone(keys_manager_conv.this_arg);
25520         }
25521         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
25522         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(((uint64_t)amt_msat) & ~1);
25523         LDKStr description_conv = java_to_owned_str(env, description);
25524         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
25525         *ret_conv = create_invoice_from_channelmanager(&channelmanager_conv, keys_manager_conv, network_conv, amt_msat_conv, description_conv);
25526         return (uint64_t)ret_conv;
25527 }
25528
25529 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SiPrefix_1from_1str(JNIEnv *env, jclass clz, jstring s) {
25530         LDKStr s_conv = java_to_owned_str(env, s);
25531         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
25532         *ret_conv = SiPrefix_from_str(s_conv);
25533         return (uint64_t)ret_conv;
25534 }
25535
25536 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1from_1str(JNIEnv *env, jclass clz, jstring s) {
25537         LDKStr s_conv = java_to_owned_str(env, s);
25538         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
25539         *ret_conv = Invoice_from_str(s_conv);
25540         return (uint64_t)ret_conv;
25541 }
25542
25543 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1from_1str(JNIEnv *env, jclass clz, jstring s) {
25544         LDKStr s_conv = java_to_owned_str(env, s);
25545         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
25546         *ret_conv = SignedRawInvoice_from_str(s_conv);
25547         return (uint64_t)ret_conv;
25548 }
25549
25550 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Invoice_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
25551         LDKInvoice o_conv;
25552         o_conv.inner = (void*)(o & (~1));
25553         o_conv.is_owned = false;
25554         LDKStr ret_str = Invoice_to_str(&o_conv);
25555         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
25556         return ret_conv;
25557 }
25558
25559 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
25560         LDKSignedRawInvoice o_conv;
25561         o_conv.inner = (void*)(o & (~1));
25562         o_conv.is_owned = false;
25563         LDKStr ret_str = SignedRawInvoice_to_str(&o_conv);
25564         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
25565         return ret_conv;
25566 }
25567
25568 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Currency_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
25569         LDKCurrency* o_conv = (LDKCurrency*)(o & ~1);
25570         LDKStr ret_str = Currency_to_str(o_conv);
25571         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
25572         return ret_conv;
25573 }
25574
25575 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SiPrefix_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
25576         LDKSiPrefix* o_conv = (LDKSiPrefix*)(o & ~1);
25577         LDKStr ret_str = SiPrefix_to_str(o_conv);
25578         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
25579         return ret_conv;
25580 }
25581