Update auto-generated bindings
[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 <jni.h>
4 // On OSX jlong (ie long long) is not equivalent to int64_t, so we override here
5 #define int64_t jlong
6 #include "org_ldk_impl_bindings.h"
7 #include <lightning.h>
8 #include <string.h>
9 #include <stdatomic.h>
10 #include <stdlib.h>
11
12 #define DEBUG_PRINT(...) fprintf(stderr, __VA_ARGS__)
13 #define MALLOC(a, _) malloc(a)
14 #define FREE(p) if ((uint64_t)(p) > 1024) { free(p); }
15 #define DO_ASSERT(a) (void)(a)
16 #define CHECK(a)
17
18 static jmethodID ordinal_meth = NULL;
19 static jmethodID slicedef_meth = NULL;
20 static jclass slicedef_cls = NULL;
21 JNIEXPORT void Java_org_ldk_impl_bindings_init(JNIEnv * env, jclass _b, jclass enum_class, jclass slicedef_class) {
22         ordinal_meth = (*env)->GetMethodID(env, enum_class, "ordinal", "()I");
23         CHECK(ordinal_meth != NULL);
24         slicedef_meth = (*env)->GetMethodID(env, slicedef_class, "<init>", "(JJJ)V");
25         CHECK(slicedef_meth != NULL);
26         slicedef_cls = (*env)->NewGlobalRef(env, slicedef_class);
27         CHECK(slicedef_cls != NULL);
28 }
29
30 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_deref_1bool (JNIEnv * env, jclass _a, jlong ptr) {
31         return *((bool*)ptr);
32 }
33 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_deref_1long (JNIEnv * env, jclass _a, jlong ptr) {
34         return *((long*)ptr);
35 }
36 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_free_1heap_1ptr (JNIEnv * env, jclass _a, jlong ptr) {
37         FREE((void*)ptr);
38 }
39 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_read_1bytes (JNIEnv * env, jclass _b, jlong ptr, jlong len) {
40         jbyteArray ret_arr = (*env)->NewByteArray(env, len);
41         (*env)->SetByteArrayRegion(env, ret_arr, 0, len, (unsigned char*)ptr);
42         return ret_arr;
43 }
44 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_get_1u8_1slice_1bytes (JNIEnv * env, jclass _b, jlong slice_ptr) {
45         LDKu8slice *slice = (LDKu8slice*)slice_ptr;
46         jbyteArray ret_arr = (*env)->NewByteArray(env, slice->datalen);
47         (*env)->SetByteArrayRegion(env, ret_arr, 0, slice->datalen, slice->data);
48         return ret_arr;
49 }
50 JNIEXPORT int64_t impl_bindings_bytes_1to_1u8_1vec (JNIEnv * env, jclass _b, jbyteArray bytes) {
51         LDKCVec_u8Z *vec = (LDKCVec_u8Z*)MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8");
52         vec->datalen = (*env)->GetArrayLength(env, bytes);
53         vec->data = (uint8_t*)MALLOC(vec->datalen, "LDKCVec_u8Z Bytes");
54         (*env)->GetByteArrayRegion (env, bytes, 0, vec->datalen, vec->data);
55         return (uint64_t)vec;
56 }
57 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_txpointer_1get_1buffer (JNIEnv * env, jclass _b, jlong ptr) {
58         LDKTransaction *txdata = (LDKTransaction*)ptr;
59         LDKu8slice slice;
60         slice.data = txdata->data;
61         slice.datalen = txdata->datalen;
62         return Java_org_ldk_impl_bindings_get_1u8_1slice_1bytes(env, _b, (uint64_t)&slice);
63 }
64 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_new_1txpointer_1copy_1data (JNIEnv * env, jclass _b, jbyteArray bytes) {
65         LDKTransaction *txdata = (LDKTransaction*)MALLOC(sizeof(LDKTransaction), "LDKTransaction");
66         txdata->datalen = (*env)->GetArrayLength(env, bytes);
67         txdata->data = (uint8_t*)MALLOC(txdata->datalen, "Tx Data Bytes");
68         txdata->data_is_owned = false;
69         (*env)->GetByteArrayRegion (env, bytes, 0, txdata->datalen, txdata->data);
70         return (uint64_t)txdata;
71 }
72 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_txpointer_1free (JNIEnv * env, jclass _b, jlong ptr) {
73         LDKTransaction *tx = (LDKTransaction*)ptr;
74         tx->data_is_owned = true;
75         Transaction_free(*tx);
76         FREE((void*)ptr);
77 }
78 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_vec_1slice_1len (JNIEnv * env, jclass _a, jlong ptr) {
79         // Check offsets of a few Vec types are all consistent as we're meant to be generic across types
80         _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_SignatureZ, datalen), "Vec<*> needs to be mapped identically");
81         _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_MessageSendEventZ, datalen), "Vec<*> needs to be mapped identically");
82         _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_EventZ, datalen), "Vec<*> needs to be mapped identically");
83         _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_C2Tuple_usizeTransactionZZ, datalen), "Vec<*> needs to be mapped identically");
84         LDKCVec_u8Z *vec = (LDKCVec_u8Z*)ptr;
85         return (uint64_t)vec->datalen;
86 }
87 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_new_1empty_1slice_1vec (JNIEnv * env, jclass _b) {
88         // Check sizes of a few Vec types are all consistent as we're meant to be generic across types
89         _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_SignatureZ), "Vec<*> needs to be mapped identically");
90         _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_MessageSendEventZ), "Vec<*> needs to be mapped identically");
91         _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_EventZ), "Vec<*> needs to be mapped identically");
92         _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_C2Tuple_usizeTransactionZZ), "Vec<*> needs to be mapped identically");
93         LDKCVec_u8Z *vec = (LDKCVec_u8Z*)MALLOC(sizeof(LDKCVec_u8Z), "Empty LDKCVec");
94         vec->data = NULL;
95         vec->datalen = 0;
96         return (uint64_t)vec;
97 }
98
99 // We assume that CVec_u8Z and u8slice are the same size and layout (and thus pointers to the two can be mixed)
100 _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKu8slice), "Vec<u8> and [u8] need to have been mapped identically");
101 _Static_assert(offsetof(LDKCVec_u8Z, data) == offsetof(LDKu8slice, data), "Vec<u8> and [u8] need to have been mapped identically");
102 _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKu8slice, datalen), "Vec<u8> and [u8] need to have been mapped identically");
103
104 _Static_assert(sizeof(jlong) == sizeof(int64_t), "We assume that j-types are the same as C types");
105 _Static_assert(sizeof(jbyte) == sizeof(char), "We assume that j-types are the same as C types");
106 _Static_assert(sizeof(void*) <= 8, "Pointers must fit into 64 bits");
107
108 typedef jlongArray int64_tArray;
109 typedef jbyteArray int8_tArray;
110
111 static inline jstring str_ref_to_java(JNIEnv *env, const char* chars, size_t len) {
112         // Sadly we need to create a temporary because Java can't accept a char* without a 0-terminator
113         char* conv_buf = MALLOC(len + 1, "str conv buf");
114         memcpy(conv_buf, chars, len);
115         conv_buf[len] = 0;
116         jstring ret = (*env)->NewStringUTF(env, conv_buf);
117         FREE(conv_buf);
118         return ret;
119 }
120 static inline LDKStr java_to_owned_str(JNIEnv *env, jstring str) {
121         uint64_t str_len = (*env)->GetStringUTFLength(env, str);
122         char* newchars = MALLOC(str_len + 1, "String chars");
123         const char* jchars = (*env)->GetStringUTFChars(env, str, NULL);
124         memcpy(newchars, jchars, str_len);
125         newchars[str_len] = 0;
126         (*env)->ReleaseStringUTFChars(env, str, jchars);
127         LDKStr res = {
128                 .chars = newchars,
129                 .len = str_len,
130                 .chars_is_owned = true
131         };
132         return res;
133 }
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 #include "version.c"
142 static jclass arr_of_B_clz = NULL;
143 static jclass arr_of_J_clz = NULL;
144 JNIEXPORT void Java_org_ldk_impl_bindings_init_1class_1cache(JNIEnv * env, jclass clz) {
145         arr_of_B_clz = (*env)->FindClass(env, "[B");
146         CHECK(arr_of_B_clz != NULL);
147         arr_of_B_clz = (*env)->NewGlobalRef(env, arr_of_B_clz);
148         arr_of_J_clz = (*env)->FindClass(env, "[J");
149         CHECK(arr_of_J_clz != NULL);
150         arr_of_J_clz = (*env)->NewGlobalRef(env, arr_of_J_clz);
151 }
152 static inline struct LDKThirtyTwoBytes ThirtyTwoBytes_clone(const struct LDKThirtyTwoBytes *orig) { struct LDKThirtyTwoBytes ret; memcpy(ret.data, orig->data, 32); return ret; }
153 static inline LDKAccessError LDKAccessError_from_java(JNIEnv *env, jclass clz) {
154         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
155                 case 0: return LDKAccessError_UnknownChain;
156                 case 1: return LDKAccessError_UnknownTx;
157         }
158         abort();
159 }
160 static jclass AccessError_class = NULL;
161 static jfieldID AccessError_LDKAccessError_UnknownChain = NULL;
162 static jfieldID AccessError_LDKAccessError_UnknownTx = NULL;
163 JNIEXPORT void JNICALL Java_org_ldk_enums_AccessError_init (JNIEnv *env, jclass clz) {
164         AccessError_class = (*env)->NewGlobalRef(env, clz);
165         CHECK(AccessError_class != NULL);
166         AccessError_LDKAccessError_UnknownChain = (*env)->GetStaticFieldID(env, AccessError_class, "LDKAccessError_UnknownChain", "Lorg/ldk/enums/AccessError;");
167         CHECK(AccessError_LDKAccessError_UnknownChain != NULL);
168         AccessError_LDKAccessError_UnknownTx = (*env)->GetStaticFieldID(env, AccessError_class, "LDKAccessError_UnknownTx", "Lorg/ldk/enums/AccessError;");
169         CHECK(AccessError_LDKAccessError_UnknownTx != NULL);
170 }
171 static inline jclass LDKAccessError_to_java(JNIEnv *env, LDKAccessError val) {
172         switch (val) {
173                 case LDKAccessError_UnknownChain:
174                         return (*env)->GetStaticObjectField(env, AccessError_class, AccessError_LDKAccessError_UnknownChain);
175                 case LDKAccessError_UnknownTx:
176                         return (*env)->GetStaticObjectField(env, AccessError_class, AccessError_LDKAccessError_UnknownTx);
177                 default: abort();
178         }
179 }
180
181 static inline LDKChannelMonitorUpdateErr LDKChannelMonitorUpdateErr_from_java(JNIEnv *env, jclass clz) {
182         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
183                 case 0: return LDKChannelMonitorUpdateErr_TemporaryFailure;
184                 case 1: return LDKChannelMonitorUpdateErr_PermanentFailure;
185         }
186         abort();
187 }
188 static jclass ChannelMonitorUpdateErr_class = NULL;
189 static jfieldID ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_TemporaryFailure = NULL;
190 static jfieldID ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_PermanentFailure = NULL;
191 JNIEXPORT void JNICALL Java_org_ldk_enums_ChannelMonitorUpdateErr_init (JNIEnv *env, jclass clz) {
192         ChannelMonitorUpdateErr_class = (*env)->NewGlobalRef(env, clz);
193         CHECK(ChannelMonitorUpdateErr_class != NULL);
194         ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_TemporaryFailure = (*env)->GetStaticFieldID(env, ChannelMonitorUpdateErr_class, "LDKChannelMonitorUpdateErr_TemporaryFailure", "Lorg/ldk/enums/ChannelMonitorUpdateErr;");
195         CHECK(ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_TemporaryFailure != NULL);
196         ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_PermanentFailure = (*env)->GetStaticFieldID(env, ChannelMonitorUpdateErr_class, "LDKChannelMonitorUpdateErr_PermanentFailure", "Lorg/ldk/enums/ChannelMonitorUpdateErr;");
197         CHECK(ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_PermanentFailure != NULL);
198 }
199 static inline jclass LDKChannelMonitorUpdateErr_to_java(JNIEnv *env, LDKChannelMonitorUpdateErr val) {
200         switch (val) {
201                 case LDKChannelMonitorUpdateErr_TemporaryFailure:
202                         return (*env)->GetStaticObjectField(env, ChannelMonitorUpdateErr_class, ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_TemporaryFailure);
203                 case LDKChannelMonitorUpdateErr_PermanentFailure:
204                         return (*env)->GetStaticObjectField(env, ChannelMonitorUpdateErr_class, ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_PermanentFailure);
205                 default: abort();
206         }
207 }
208
209 static inline LDKConfirmationTarget LDKConfirmationTarget_from_java(JNIEnv *env, jclass clz) {
210         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
211                 case 0: return LDKConfirmationTarget_Background;
212                 case 1: return LDKConfirmationTarget_Normal;
213                 case 2: return LDKConfirmationTarget_HighPriority;
214         }
215         abort();
216 }
217 static jclass ConfirmationTarget_class = NULL;
218 static jfieldID ConfirmationTarget_LDKConfirmationTarget_Background = NULL;
219 static jfieldID ConfirmationTarget_LDKConfirmationTarget_Normal = NULL;
220 static jfieldID ConfirmationTarget_LDKConfirmationTarget_HighPriority = NULL;
221 JNIEXPORT void JNICALL Java_org_ldk_enums_ConfirmationTarget_init (JNIEnv *env, jclass clz) {
222         ConfirmationTarget_class = (*env)->NewGlobalRef(env, clz);
223         CHECK(ConfirmationTarget_class != NULL);
224         ConfirmationTarget_LDKConfirmationTarget_Background = (*env)->GetStaticFieldID(env, ConfirmationTarget_class, "LDKConfirmationTarget_Background", "Lorg/ldk/enums/ConfirmationTarget;");
225         CHECK(ConfirmationTarget_LDKConfirmationTarget_Background != NULL);
226         ConfirmationTarget_LDKConfirmationTarget_Normal = (*env)->GetStaticFieldID(env, ConfirmationTarget_class, "LDKConfirmationTarget_Normal", "Lorg/ldk/enums/ConfirmationTarget;");
227         CHECK(ConfirmationTarget_LDKConfirmationTarget_Normal != NULL);
228         ConfirmationTarget_LDKConfirmationTarget_HighPriority = (*env)->GetStaticFieldID(env, ConfirmationTarget_class, "LDKConfirmationTarget_HighPriority", "Lorg/ldk/enums/ConfirmationTarget;");
229         CHECK(ConfirmationTarget_LDKConfirmationTarget_HighPriority != NULL);
230 }
231 static inline jclass LDKConfirmationTarget_to_java(JNIEnv *env, LDKConfirmationTarget val) {
232         switch (val) {
233                 case LDKConfirmationTarget_Background:
234                         return (*env)->GetStaticObjectField(env, ConfirmationTarget_class, ConfirmationTarget_LDKConfirmationTarget_Background);
235                 case LDKConfirmationTarget_Normal:
236                         return (*env)->GetStaticObjectField(env, ConfirmationTarget_class, ConfirmationTarget_LDKConfirmationTarget_Normal);
237                 case LDKConfirmationTarget_HighPriority:
238                         return (*env)->GetStaticObjectField(env, ConfirmationTarget_class, ConfirmationTarget_LDKConfirmationTarget_HighPriority);
239                 default: abort();
240         }
241 }
242
243 static inline LDKCreationError LDKCreationError_from_java(JNIEnv *env, jclass clz) {
244         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
245                 case 0: return LDKCreationError_DescriptionTooLong;
246                 case 1: return LDKCreationError_RouteTooLong;
247                 case 2: return LDKCreationError_TimestampOutOfBounds;
248                 case 3: return LDKCreationError_ExpiryTimeOutOfBounds;
249         }
250         abort();
251 }
252 static jclass CreationError_class = NULL;
253 static jfieldID CreationError_LDKCreationError_DescriptionTooLong = NULL;
254 static jfieldID CreationError_LDKCreationError_RouteTooLong = NULL;
255 static jfieldID CreationError_LDKCreationError_TimestampOutOfBounds = NULL;
256 static jfieldID CreationError_LDKCreationError_ExpiryTimeOutOfBounds = NULL;
257 JNIEXPORT void JNICALL Java_org_ldk_enums_CreationError_init (JNIEnv *env, jclass clz) {
258         CreationError_class = (*env)->NewGlobalRef(env, clz);
259         CHECK(CreationError_class != NULL);
260         CreationError_LDKCreationError_DescriptionTooLong = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_DescriptionTooLong", "Lorg/ldk/enums/CreationError;");
261         CHECK(CreationError_LDKCreationError_DescriptionTooLong != NULL);
262         CreationError_LDKCreationError_RouteTooLong = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_RouteTooLong", "Lorg/ldk/enums/CreationError;");
263         CHECK(CreationError_LDKCreationError_RouteTooLong != NULL);
264         CreationError_LDKCreationError_TimestampOutOfBounds = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_TimestampOutOfBounds", "Lorg/ldk/enums/CreationError;");
265         CHECK(CreationError_LDKCreationError_TimestampOutOfBounds != NULL);
266         CreationError_LDKCreationError_ExpiryTimeOutOfBounds = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_ExpiryTimeOutOfBounds", "Lorg/ldk/enums/CreationError;");
267         CHECK(CreationError_LDKCreationError_ExpiryTimeOutOfBounds != NULL);
268 }
269 static inline jclass LDKCreationError_to_java(JNIEnv *env, LDKCreationError val) {
270         switch (val) {
271                 case LDKCreationError_DescriptionTooLong:
272                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_DescriptionTooLong);
273                 case LDKCreationError_RouteTooLong:
274                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_RouteTooLong);
275                 case LDKCreationError_TimestampOutOfBounds:
276                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_TimestampOutOfBounds);
277                 case LDKCreationError_ExpiryTimeOutOfBounds:
278                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_ExpiryTimeOutOfBounds);
279                 default: abort();
280         }
281 }
282
283 static inline LDKCurrency LDKCurrency_from_java(JNIEnv *env, jclass clz) {
284         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
285                 case 0: return LDKCurrency_Bitcoin;
286                 case 1: return LDKCurrency_BitcoinTestnet;
287                 case 2: return LDKCurrency_Regtest;
288                 case 3: return LDKCurrency_Simnet;
289                 case 4: return LDKCurrency_Signet;
290         }
291         abort();
292 }
293 static jclass Currency_class = NULL;
294 static jfieldID Currency_LDKCurrency_Bitcoin = NULL;
295 static jfieldID Currency_LDKCurrency_BitcoinTestnet = NULL;
296 static jfieldID Currency_LDKCurrency_Regtest = NULL;
297 static jfieldID Currency_LDKCurrency_Simnet = NULL;
298 static jfieldID Currency_LDKCurrency_Signet = NULL;
299 JNIEXPORT void JNICALL Java_org_ldk_enums_Currency_init (JNIEnv *env, jclass clz) {
300         Currency_class = (*env)->NewGlobalRef(env, clz);
301         CHECK(Currency_class != NULL);
302         Currency_LDKCurrency_Bitcoin = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_Bitcoin", "Lorg/ldk/enums/Currency;");
303         CHECK(Currency_LDKCurrency_Bitcoin != NULL);
304         Currency_LDKCurrency_BitcoinTestnet = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_BitcoinTestnet", "Lorg/ldk/enums/Currency;");
305         CHECK(Currency_LDKCurrency_BitcoinTestnet != NULL);
306         Currency_LDKCurrency_Regtest = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_Regtest", "Lorg/ldk/enums/Currency;");
307         CHECK(Currency_LDKCurrency_Regtest != NULL);
308         Currency_LDKCurrency_Simnet = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_Simnet", "Lorg/ldk/enums/Currency;");
309         CHECK(Currency_LDKCurrency_Simnet != NULL);
310         Currency_LDKCurrency_Signet = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_Signet", "Lorg/ldk/enums/Currency;");
311         CHECK(Currency_LDKCurrency_Signet != NULL);
312 }
313 static inline jclass LDKCurrency_to_java(JNIEnv *env, LDKCurrency val) {
314         switch (val) {
315                 case LDKCurrency_Bitcoin:
316                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_Bitcoin);
317                 case LDKCurrency_BitcoinTestnet:
318                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_BitcoinTestnet);
319                 case LDKCurrency_Regtest:
320                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_Regtest);
321                 case LDKCurrency_Simnet:
322                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_Simnet);
323                 case LDKCurrency_Signet:
324                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_Signet);
325                 default: abort();
326         }
327 }
328
329 static inline LDKIOError LDKIOError_from_java(JNIEnv *env, jclass clz) {
330         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
331                 case 0: return LDKIOError_NotFound;
332                 case 1: return LDKIOError_PermissionDenied;
333                 case 2: return LDKIOError_ConnectionRefused;
334                 case 3: return LDKIOError_ConnectionReset;
335                 case 4: return LDKIOError_ConnectionAborted;
336                 case 5: return LDKIOError_NotConnected;
337                 case 6: return LDKIOError_AddrInUse;
338                 case 7: return LDKIOError_AddrNotAvailable;
339                 case 8: return LDKIOError_BrokenPipe;
340                 case 9: return LDKIOError_AlreadyExists;
341                 case 10: return LDKIOError_WouldBlock;
342                 case 11: return LDKIOError_InvalidInput;
343                 case 12: return LDKIOError_InvalidData;
344                 case 13: return LDKIOError_TimedOut;
345                 case 14: return LDKIOError_WriteZero;
346                 case 15: return LDKIOError_Interrupted;
347                 case 16: return LDKIOError_Other;
348                 case 17: return LDKIOError_UnexpectedEof;
349         }
350         abort();
351 }
352 static jclass IOError_class = NULL;
353 static jfieldID IOError_LDKIOError_NotFound = NULL;
354 static jfieldID IOError_LDKIOError_PermissionDenied = NULL;
355 static jfieldID IOError_LDKIOError_ConnectionRefused = NULL;
356 static jfieldID IOError_LDKIOError_ConnectionReset = NULL;
357 static jfieldID IOError_LDKIOError_ConnectionAborted = NULL;
358 static jfieldID IOError_LDKIOError_NotConnected = NULL;
359 static jfieldID IOError_LDKIOError_AddrInUse = NULL;
360 static jfieldID IOError_LDKIOError_AddrNotAvailable = NULL;
361 static jfieldID IOError_LDKIOError_BrokenPipe = NULL;
362 static jfieldID IOError_LDKIOError_AlreadyExists = NULL;
363 static jfieldID IOError_LDKIOError_WouldBlock = NULL;
364 static jfieldID IOError_LDKIOError_InvalidInput = NULL;
365 static jfieldID IOError_LDKIOError_InvalidData = NULL;
366 static jfieldID IOError_LDKIOError_TimedOut = NULL;
367 static jfieldID IOError_LDKIOError_WriteZero = NULL;
368 static jfieldID IOError_LDKIOError_Interrupted = NULL;
369 static jfieldID IOError_LDKIOError_Other = NULL;
370 static jfieldID IOError_LDKIOError_UnexpectedEof = NULL;
371 JNIEXPORT void JNICALL Java_org_ldk_enums_IOError_init (JNIEnv *env, jclass clz) {
372         IOError_class = (*env)->NewGlobalRef(env, clz);
373         CHECK(IOError_class != NULL);
374         IOError_LDKIOError_NotFound = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_NotFound", "Lorg/ldk/enums/IOError;");
375         CHECK(IOError_LDKIOError_NotFound != NULL);
376         IOError_LDKIOError_PermissionDenied = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_PermissionDenied", "Lorg/ldk/enums/IOError;");
377         CHECK(IOError_LDKIOError_PermissionDenied != NULL);
378         IOError_LDKIOError_ConnectionRefused = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_ConnectionRefused", "Lorg/ldk/enums/IOError;");
379         CHECK(IOError_LDKIOError_ConnectionRefused != NULL);
380         IOError_LDKIOError_ConnectionReset = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_ConnectionReset", "Lorg/ldk/enums/IOError;");
381         CHECK(IOError_LDKIOError_ConnectionReset != NULL);
382         IOError_LDKIOError_ConnectionAborted = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_ConnectionAborted", "Lorg/ldk/enums/IOError;");
383         CHECK(IOError_LDKIOError_ConnectionAborted != NULL);
384         IOError_LDKIOError_NotConnected = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_NotConnected", "Lorg/ldk/enums/IOError;");
385         CHECK(IOError_LDKIOError_NotConnected != NULL);
386         IOError_LDKIOError_AddrInUse = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_AddrInUse", "Lorg/ldk/enums/IOError;");
387         CHECK(IOError_LDKIOError_AddrInUse != NULL);
388         IOError_LDKIOError_AddrNotAvailable = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_AddrNotAvailable", "Lorg/ldk/enums/IOError;");
389         CHECK(IOError_LDKIOError_AddrNotAvailable != NULL);
390         IOError_LDKIOError_BrokenPipe = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_BrokenPipe", "Lorg/ldk/enums/IOError;");
391         CHECK(IOError_LDKIOError_BrokenPipe != NULL);
392         IOError_LDKIOError_AlreadyExists = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_AlreadyExists", "Lorg/ldk/enums/IOError;");
393         CHECK(IOError_LDKIOError_AlreadyExists != NULL);
394         IOError_LDKIOError_WouldBlock = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_WouldBlock", "Lorg/ldk/enums/IOError;");
395         CHECK(IOError_LDKIOError_WouldBlock != NULL);
396         IOError_LDKIOError_InvalidInput = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_InvalidInput", "Lorg/ldk/enums/IOError;");
397         CHECK(IOError_LDKIOError_InvalidInput != NULL);
398         IOError_LDKIOError_InvalidData = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_InvalidData", "Lorg/ldk/enums/IOError;");
399         CHECK(IOError_LDKIOError_InvalidData != NULL);
400         IOError_LDKIOError_TimedOut = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_TimedOut", "Lorg/ldk/enums/IOError;");
401         CHECK(IOError_LDKIOError_TimedOut != NULL);
402         IOError_LDKIOError_WriteZero = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_WriteZero", "Lorg/ldk/enums/IOError;");
403         CHECK(IOError_LDKIOError_WriteZero != NULL);
404         IOError_LDKIOError_Interrupted = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_Interrupted", "Lorg/ldk/enums/IOError;");
405         CHECK(IOError_LDKIOError_Interrupted != NULL);
406         IOError_LDKIOError_Other = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_Other", "Lorg/ldk/enums/IOError;");
407         CHECK(IOError_LDKIOError_Other != NULL);
408         IOError_LDKIOError_UnexpectedEof = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_UnexpectedEof", "Lorg/ldk/enums/IOError;");
409         CHECK(IOError_LDKIOError_UnexpectedEof != NULL);
410 }
411 static inline jclass LDKIOError_to_java(JNIEnv *env, LDKIOError val) {
412         switch (val) {
413                 case LDKIOError_NotFound:
414                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_NotFound);
415                 case LDKIOError_PermissionDenied:
416                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_PermissionDenied);
417                 case LDKIOError_ConnectionRefused:
418                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_ConnectionRefused);
419                 case LDKIOError_ConnectionReset:
420                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_ConnectionReset);
421                 case LDKIOError_ConnectionAborted:
422                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_ConnectionAborted);
423                 case LDKIOError_NotConnected:
424                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_NotConnected);
425                 case LDKIOError_AddrInUse:
426                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_AddrInUse);
427                 case LDKIOError_AddrNotAvailable:
428                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_AddrNotAvailable);
429                 case LDKIOError_BrokenPipe:
430                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_BrokenPipe);
431                 case LDKIOError_AlreadyExists:
432                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_AlreadyExists);
433                 case LDKIOError_WouldBlock:
434                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_WouldBlock);
435                 case LDKIOError_InvalidInput:
436                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_InvalidInput);
437                 case LDKIOError_InvalidData:
438                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_InvalidData);
439                 case LDKIOError_TimedOut:
440                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_TimedOut);
441                 case LDKIOError_WriteZero:
442                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_WriteZero);
443                 case LDKIOError_Interrupted:
444                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_Interrupted);
445                 case LDKIOError_Other:
446                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_Other);
447                 case LDKIOError_UnexpectedEof:
448                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_UnexpectedEof);
449                 default: abort();
450         }
451 }
452
453 static inline LDKLevel LDKLevel_from_java(JNIEnv *env, jclass clz) {
454         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
455                 case 0: return LDKLevel_Trace;
456                 case 1: return LDKLevel_Debug;
457                 case 2: return LDKLevel_Info;
458                 case 3: return LDKLevel_Warn;
459                 case 4: return LDKLevel_Error;
460         }
461         abort();
462 }
463 static jclass Level_class = NULL;
464 static jfieldID Level_LDKLevel_Trace = NULL;
465 static jfieldID Level_LDKLevel_Debug = NULL;
466 static jfieldID Level_LDKLevel_Info = NULL;
467 static jfieldID Level_LDKLevel_Warn = NULL;
468 static jfieldID Level_LDKLevel_Error = NULL;
469 JNIEXPORT void JNICALL Java_org_ldk_enums_Level_init (JNIEnv *env, jclass clz) {
470         Level_class = (*env)->NewGlobalRef(env, clz);
471         CHECK(Level_class != NULL);
472         Level_LDKLevel_Trace = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Trace", "Lorg/ldk/enums/Level;");
473         CHECK(Level_LDKLevel_Trace != NULL);
474         Level_LDKLevel_Debug = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Debug", "Lorg/ldk/enums/Level;");
475         CHECK(Level_LDKLevel_Debug != NULL);
476         Level_LDKLevel_Info = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Info", "Lorg/ldk/enums/Level;");
477         CHECK(Level_LDKLevel_Info != NULL);
478         Level_LDKLevel_Warn = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Warn", "Lorg/ldk/enums/Level;");
479         CHECK(Level_LDKLevel_Warn != NULL);
480         Level_LDKLevel_Error = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Error", "Lorg/ldk/enums/Level;");
481         CHECK(Level_LDKLevel_Error != NULL);
482 }
483 static inline jclass LDKLevel_to_java(JNIEnv *env, LDKLevel val) {
484         switch (val) {
485                 case LDKLevel_Trace:
486                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Trace);
487                 case LDKLevel_Debug:
488                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Debug);
489                 case LDKLevel_Info:
490                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Info);
491                 case LDKLevel_Warn:
492                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Warn);
493                 case LDKLevel_Error:
494                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Error);
495                 default: abort();
496         }
497 }
498
499 static inline LDKNetwork LDKNetwork_from_java(JNIEnv *env, jclass clz) {
500         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
501                 case 0: return LDKNetwork_Bitcoin;
502                 case 1: return LDKNetwork_Testnet;
503                 case 2: return LDKNetwork_Regtest;
504                 case 3: return LDKNetwork_Signet;
505         }
506         abort();
507 }
508 static jclass Network_class = NULL;
509 static jfieldID Network_LDKNetwork_Bitcoin = NULL;
510 static jfieldID Network_LDKNetwork_Testnet = NULL;
511 static jfieldID Network_LDKNetwork_Regtest = NULL;
512 static jfieldID Network_LDKNetwork_Signet = NULL;
513 JNIEXPORT void JNICALL Java_org_ldk_enums_Network_init (JNIEnv *env, jclass clz) {
514         Network_class = (*env)->NewGlobalRef(env, clz);
515         CHECK(Network_class != NULL);
516         Network_LDKNetwork_Bitcoin = (*env)->GetStaticFieldID(env, Network_class, "LDKNetwork_Bitcoin", "Lorg/ldk/enums/Network;");
517         CHECK(Network_LDKNetwork_Bitcoin != NULL);
518         Network_LDKNetwork_Testnet = (*env)->GetStaticFieldID(env, Network_class, "LDKNetwork_Testnet", "Lorg/ldk/enums/Network;");
519         CHECK(Network_LDKNetwork_Testnet != NULL);
520         Network_LDKNetwork_Regtest = (*env)->GetStaticFieldID(env, Network_class, "LDKNetwork_Regtest", "Lorg/ldk/enums/Network;");
521         CHECK(Network_LDKNetwork_Regtest != NULL);
522         Network_LDKNetwork_Signet = (*env)->GetStaticFieldID(env, Network_class, "LDKNetwork_Signet", "Lorg/ldk/enums/Network;");
523         CHECK(Network_LDKNetwork_Signet != NULL);
524 }
525 static inline jclass LDKNetwork_to_java(JNIEnv *env, LDKNetwork val) {
526         switch (val) {
527                 case LDKNetwork_Bitcoin:
528                         return (*env)->GetStaticObjectField(env, Network_class, Network_LDKNetwork_Bitcoin);
529                 case LDKNetwork_Testnet:
530                         return (*env)->GetStaticObjectField(env, Network_class, Network_LDKNetwork_Testnet);
531                 case LDKNetwork_Regtest:
532                         return (*env)->GetStaticObjectField(env, Network_class, Network_LDKNetwork_Regtest);
533                 case LDKNetwork_Signet:
534                         return (*env)->GetStaticObjectField(env, Network_class, Network_LDKNetwork_Signet);
535                 default: abort();
536         }
537 }
538
539 static inline LDKSecp256k1Error LDKSecp256k1Error_from_java(JNIEnv *env, jclass clz) {
540         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
541                 case 0: return LDKSecp256k1Error_IncorrectSignature;
542                 case 1: return LDKSecp256k1Error_InvalidMessage;
543                 case 2: return LDKSecp256k1Error_InvalidPublicKey;
544                 case 3: return LDKSecp256k1Error_InvalidSignature;
545                 case 4: return LDKSecp256k1Error_InvalidSecretKey;
546                 case 5: return LDKSecp256k1Error_InvalidRecoveryId;
547                 case 6: return LDKSecp256k1Error_InvalidTweak;
548                 case 7: return LDKSecp256k1Error_TweakCheckFailed;
549                 case 8: return LDKSecp256k1Error_NotEnoughMemory;
550         }
551         abort();
552 }
553 static jclass Secp256k1Error_class = NULL;
554 static jfieldID Secp256k1Error_LDKSecp256k1Error_IncorrectSignature = NULL;
555 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidMessage = NULL;
556 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey = NULL;
557 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidSignature = NULL;
558 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey = NULL;
559 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId = NULL;
560 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidTweak = NULL;
561 static jfieldID Secp256k1Error_LDKSecp256k1Error_TweakCheckFailed = NULL;
562 static jfieldID Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory = NULL;
563 JNIEXPORT void JNICALL Java_org_ldk_enums_Secp256k1Error_init (JNIEnv *env, jclass clz) {
564         Secp256k1Error_class = (*env)->NewGlobalRef(env, clz);
565         CHECK(Secp256k1Error_class != NULL);
566         Secp256k1Error_LDKSecp256k1Error_IncorrectSignature = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_IncorrectSignature", "Lorg/ldk/enums/Secp256k1Error;");
567         CHECK(Secp256k1Error_LDKSecp256k1Error_IncorrectSignature != NULL);
568         Secp256k1Error_LDKSecp256k1Error_InvalidMessage = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidMessage", "Lorg/ldk/enums/Secp256k1Error;");
569         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidMessage != NULL);
570         Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidPublicKey", "Lorg/ldk/enums/Secp256k1Error;");
571         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey != NULL);
572         Secp256k1Error_LDKSecp256k1Error_InvalidSignature = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidSignature", "Lorg/ldk/enums/Secp256k1Error;");
573         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidSignature != NULL);
574         Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidSecretKey", "Lorg/ldk/enums/Secp256k1Error;");
575         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey != NULL);
576         Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidRecoveryId", "Lorg/ldk/enums/Secp256k1Error;");
577         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId != NULL);
578         Secp256k1Error_LDKSecp256k1Error_InvalidTweak = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidTweak", "Lorg/ldk/enums/Secp256k1Error;");
579         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidTweak != NULL);
580         Secp256k1Error_LDKSecp256k1Error_TweakCheckFailed = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_TweakCheckFailed", "Lorg/ldk/enums/Secp256k1Error;");
581         CHECK(Secp256k1Error_LDKSecp256k1Error_TweakCheckFailed != NULL);
582         Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_NotEnoughMemory", "Lorg/ldk/enums/Secp256k1Error;");
583         CHECK(Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory != NULL);
584 }
585 static inline jclass LDKSecp256k1Error_to_java(JNIEnv *env, LDKSecp256k1Error val) {
586         switch (val) {
587                 case LDKSecp256k1Error_IncorrectSignature:
588                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_IncorrectSignature);
589                 case LDKSecp256k1Error_InvalidMessage:
590                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidMessage);
591                 case LDKSecp256k1Error_InvalidPublicKey:
592                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey);
593                 case LDKSecp256k1Error_InvalidSignature:
594                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidSignature);
595                 case LDKSecp256k1Error_InvalidSecretKey:
596                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey);
597                 case LDKSecp256k1Error_InvalidRecoveryId:
598                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId);
599                 case LDKSecp256k1Error_InvalidTweak:
600                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidTweak);
601                 case LDKSecp256k1Error_TweakCheckFailed:
602                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_TweakCheckFailed);
603                 case LDKSecp256k1Error_NotEnoughMemory:
604                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory);
605                 default: abort();
606         }
607 }
608
609 static inline LDKSemanticError LDKSemanticError_from_java(JNIEnv *env, jclass clz) {
610         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
611                 case 0: return LDKSemanticError_NoPaymentHash;
612                 case 1: return LDKSemanticError_MultiplePaymentHashes;
613                 case 2: return LDKSemanticError_NoDescription;
614                 case 3: return LDKSemanticError_MultipleDescriptions;
615                 case 4: return LDKSemanticError_NoPaymentSecret;
616                 case 5: return LDKSemanticError_MultiplePaymentSecrets;
617                 case 6: return LDKSemanticError_InvalidFeatures;
618                 case 7: return LDKSemanticError_InvalidRecoveryId;
619                 case 8: return LDKSemanticError_InvalidSignature;
620                 case 9: return LDKSemanticError_ImpreciseAmount;
621         }
622         abort();
623 }
624 static jclass SemanticError_class = NULL;
625 static jfieldID SemanticError_LDKSemanticError_NoPaymentHash = NULL;
626 static jfieldID SemanticError_LDKSemanticError_MultiplePaymentHashes = NULL;
627 static jfieldID SemanticError_LDKSemanticError_NoDescription = NULL;
628 static jfieldID SemanticError_LDKSemanticError_MultipleDescriptions = NULL;
629 static jfieldID SemanticError_LDKSemanticError_NoPaymentSecret = NULL;
630 static jfieldID SemanticError_LDKSemanticError_MultiplePaymentSecrets = NULL;
631 static jfieldID SemanticError_LDKSemanticError_InvalidFeatures = NULL;
632 static jfieldID SemanticError_LDKSemanticError_InvalidRecoveryId = NULL;
633 static jfieldID SemanticError_LDKSemanticError_InvalidSignature = NULL;
634 static jfieldID SemanticError_LDKSemanticError_ImpreciseAmount = NULL;
635 JNIEXPORT void JNICALL Java_org_ldk_enums_SemanticError_init (JNIEnv *env, jclass clz) {
636         SemanticError_class = (*env)->NewGlobalRef(env, clz);
637         CHECK(SemanticError_class != NULL);
638         SemanticError_LDKSemanticError_NoPaymentHash = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_NoPaymentHash", "Lorg/ldk/enums/SemanticError;");
639         CHECK(SemanticError_LDKSemanticError_NoPaymentHash != NULL);
640         SemanticError_LDKSemanticError_MultiplePaymentHashes = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_MultiplePaymentHashes", "Lorg/ldk/enums/SemanticError;");
641         CHECK(SemanticError_LDKSemanticError_MultiplePaymentHashes != NULL);
642         SemanticError_LDKSemanticError_NoDescription = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_NoDescription", "Lorg/ldk/enums/SemanticError;");
643         CHECK(SemanticError_LDKSemanticError_NoDescription != NULL);
644         SemanticError_LDKSemanticError_MultipleDescriptions = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_MultipleDescriptions", "Lorg/ldk/enums/SemanticError;");
645         CHECK(SemanticError_LDKSemanticError_MultipleDescriptions != NULL);
646         SemanticError_LDKSemanticError_NoPaymentSecret = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_NoPaymentSecret", "Lorg/ldk/enums/SemanticError;");
647         CHECK(SemanticError_LDKSemanticError_NoPaymentSecret != NULL);
648         SemanticError_LDKSemanticError_MultiplePaymentSecrets = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_MultiplePaymentSecrets", "Lorg/ldk/enums/SemanticError;");
649         CHECK(SemanticError_LDKSemanticError_MultiplePaymentSecrets != NULL);
650         SemanticError_LDKSemanticError_InvalidFeatures = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_InvalidFeatures", "Lorg/ldk/enums/SemanticError;");
651         CHECK(SemanticError_LDKSemanticError_InvalidFeatures != NULL);
652         SemanticError_LDKSemanticError_InvalidRecoveryId = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_InvalidRecoveryId", "Lorg/ldk/enums/SemanticError;");
653         CHECK(SemanticError_LDKSemanticError_InvalidRecoveryId != NULL);
654         SemanticError_LDKSemanticError_InvalidSignature = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_InvalidSignature", "Lorg/ldk/enums/SemanticError;");
655         CHECK(SemanticError_LDKSemanticError_InvalidSignature != NULL);
656         SemanticError_LDKSemanticError_ImpreciseAmount = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_ImpreciseAmount", "Lorg/ldk/enums/SemanticError;");
657         CHECK(SemanticError_LDKSemanticError_ImpreciseAmount != NULL);
658 }
659 static inline jclass LDKSemanticError_to_java(JNIEnv *env, LDKSemanticError val) {
660         switch (val) {
661                 case LDKSemanticError_NoPaymentHash:
662                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_NoPaymentHash);
663                 case LDKSemanticError_MultiplePaymentHashes:
664                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_MultiplePaymentHashes);
665                 case LDKSemanticError_NoDescription:
666                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_NoDescription);
667                 case LDKSemanticError_MultipleDescriptions:
668                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_MultipleDescriptions);
669                 case LDKSemanticError_NoPaymentSecret:
670                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_NoPaymentSecret);
671                 case LDKSemanticError_MultiplePaymentSecrets:
672                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_MultiplePaymentSecrets);
673                 case LDKSemanticError_InvalidFeatures:
674                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_InvalidFeatures);
675                 case LDKSemanticError_InvalidRecoveryId:
676                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_InvalidRecoveryId);
677                 case LDKSemanticError_InvalidSignature:
678                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_InvalidSignature);
679                 case LDKSemanticError_ImpreciseAmount:
680                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_ImpreciseAmount);
681                 default: abort();
682         }
683 }
684
685 static inline LDKSiPrefix LDKSiPrefix_from_java(JNIEnv *env, jclass clz) {
686         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
687                 case 0: return LDKSiPrefix_Milli;
688                 case 1: return LDKSiPrefix_Micro;
689                 case 2: return LDKSiPrefix_Nano;
690                 case 3: return LDKSiPrefix_Pico;
691         }
692         abort();
693 }
694 static jclass SiPrefix_class = NULL;
695 static jfieldID SiPrefix_LDKSiPrefix_Milli = NULL;
696 static jfieldID SiPrefix_LDKSiPrefix_Micro = NULL;
697 static jfieldID SiPrefix_LDKSiPrefix_Nano = NULL;
698 static jfieldID SiPrefix_LDKSiPrefix_Pico = NULL;
699 JNIEXPORT void JNICALL Java_org_ldk_enums_SiPrefix_init (JNIEnv *env, jclass clz) {
700         SiPrefix_class = (*env)->NewGlobalRef(env, clz);
701         CHECK(SiPrefix_class != NULL);
702         SiPrefix_LDKSiPrefix_Milli = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Milli", "Lorg/ldk/enums/SiPrefix;");
703         CHECK(SiPrefix_LDKSiPrefix_Milli != NULL);
704         SiPrefix_LDKSiPrefix_Micro = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Micro", "Lorg/ldk/enums/SiPrefix;");
705         CHECK(SiPrefix_LDKSiPrefix_Micro != NULL);
706         SiPrefix_LDKSiPrefix_Nano = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Nano", "Lorg/ldk/enums/SiPrefix;");
707         CHECK(SiPrefix_LDKSiPrefix_Nano != NULL);
708         SiPrefix_LDKSiPrefix_Pico = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Pico", "Lorg/ldk/enums/SiPrefix;");
709         CHECK(SiPrefix_LDKSiPrefix_Pico != NULL);
710 }
711 static inline jclass LDKSiPrefix_to_java(JNIEnv *env, LDKSiPrefix val) {
712         switch (val) {
713                 case LDKSiPrefix_Milli:
714                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Milli);
715                 case LDKSiPrefix_Micro:
716                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Micro);
717                 case LDKSiPrefix_Nano:
718                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Nano);
719                 case LDKSiPrefix_Pico:
720                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Pico);
721                 default: abort();
722         }
723 }
724
725 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1u8Z_1new(JNIEnv *env, jclass clz, int8_tArray elems) {
726         LDKCVec_u8Z *ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
727         ret->datalen = (*env)->GetArrayLength(env, elems);
728         if (ret->datalen == 0) {
729                 ret->data = NULL;
730         } else {
731                 ret->data = MALLOC(sizeof(uint8_t) * ret->datalen, "LDKCVec_u8Z Data");
732                 int8_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
733                 for (size_t i = 0; i < ret->datalen; i++) {
734                         ret->data[i] = java_elems[i];
735                 }
736                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
737         }
738         return (uint64_t)ret;
739 }
740 static inline LDKCVec_u8Z CVec_u8Z_clone(const LDKCVec_u8Z *orig) {
741         LDKCVec_u8Z ret = { .data = MALLOC(sizeof(int8_t) * orig->datalen, "LDKCVec_u8Z clone bytes"), .datalen = orig->datalen };
742         memcpy(ret.data, orig->data, sizeof(int8_t) * ret.datalen);
743         return ret;
744 }
745 struct LDKCVec_u8Z TxOut_get_script_pubkey (struct LDKTxOut* thing) {   return CVec_u8Z_clone(&thing->script_pubkey);}JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxOut_1get_1script_1pubkey(JNIEnv *env, jclass clz, int64_t thing) {
746         LDKTxOut* thing_conv = (LDKTxOut*)(thing & ~1);
747         LDKCVec_u8Z ret_var = TxOut_get_script_pubkey(thing_conv);
748         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
749         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
750         CVec_u8Z_free(ret_var);
751         return ret_arr;
752 }
753
754 uint64_t TxOut_get_value (struct LDKTxOut* thing) {     return thing->value;}JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxOut_1get_1value(JNIEnv *env, jclass clz, int64_t thing) {
755         LDKTxOut* thing_conv = (LDKTxOut*)(thing & ~1);
756         int64_t ret_val = TxOut_get_value(thing_conv);
757         return ret_val;
758 }
759
760 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SecretKeyErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
761         return ((LDKCResult_SecretKeyErrorZ*)arg)->result_ok;
762 }
763 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SecretKeyErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
764         LDKCResult_SecretKeyErrorZ *val = (LDKCResult_SecretKeyErrorZ*)(arg & ~1);
765         CHECK(val->result_ok);
766         int8_tArray res_arr = (*env)->NewByteArray(env, 32);
767         (*env)->SetByteArrayRegion(env, res_arr, 0, 32, (*val->contents.result).bytes);
768         return res_arr;
769 }
770 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SecretKeyErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
771         LDKCResult_SecretKeyErrorZ *val = (LDKCResult_SecretKeyErrorZ*)(arg & ~1);
772         CHECK(!val->result_ok);
773         jclass err_conv = LDKSecp256k1Error_to_java(env, (*val->contents.err));
774         return err_conv;
775 }
776 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PublicKeyErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
777         return ((LDKCResult_PublicKeyErrorZ*)arg)->result_ok;
778 }
779 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PublicKeyErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
780         LDKCResult_PublicKeyErrorZ *val = (LDKCResult_PublicKeyErrorZ*)(arg & ~1);
781         CHECK(val->result_ok);
782         int8_tArray res_arr = (*env)->NewByteArray(env, 33);
783         (*env)->SetByteArrayRegion(env, res_arr, 0, 33, (*val->contents.result).compressed_form);
784         return res_arr;
785 }
786 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PublicKeyErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
787         LDKCResult_PublicKeyErrorZ *val = (LDKCResult_PublicKeyErrorZ*)(arg & ~1);
788         CHECK(!val->result_ok);
789         jclass err_conv = LDKSecp256k1Error_to_java(env, (*val->contents.err));
790         return err_conv;
791 }
792 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
793         return ((LDKCResult_TxCreationKeysDecodeErrorZ*)arg)->result_ok;
794 }
795 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
796         LDKCResult_TxCreationKeysDecodeErrorZ *val = (LDKCResult_TxCreationKeysDecodeErrorZ*)(arg & ~1);
797         CHECK(val->result_ok);
798         LDKTxCreationKeys res_var = (*val->contents.result);
799         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
800         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
801         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
802         return res_ref;
803 }
804 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
805         LDKCResult_TxCreationKeysDecodeErrorZ *val = (LDKCResult_TxCreationKeysDecodeErrorZ*)(arg & ~1);
806         CHECK(!val->result_ok);
807         LDKDecodeError err_var = (*val->contents.err);
808         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
809         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
810         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
811         return err_ref;
812 }
813 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelPublicKeysDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
814         return ((LDKCResult_ChannelPublicKeysDecodeErrorZ*)arg)->result_ok;
815 }
816 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelPublicKeysDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
817         LDKCResult_ChannelPublicKeysDecodeErrorZ *val = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(arg & ~1);
818         CHECK(val->result_ok);
819         LDKChannelPublicKeys res_var = (*val->contents.result);
820         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
821         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
822         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
823         return res_ref;
824 }
825 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelPublicKeysDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
826         LDKCResult_ChannelPublicKeysDecodeErrorZ *val = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(arg & ~1);
827         CHECK(!val->result_ok);
828         LDKDecodeError err_var = (*val->contents.err);
829         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
830         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
831         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
832         return err_ref;
833 }
834 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
835         return ((LDKCResult_TxCreationKeysErrorZ*)arg)->result_ok;
836 }
837 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
838         LDKCResult_TxCreationKeysErrorZ *val = (LDKCResult_TxCreationKeysErrorZ*)(arg & ~1);
839         CHECK(val->result_ok);
840         LDKTxCreationKeys res_var = (*val->contents.result);
841         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
842         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
843         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
844         return res_ref;
845 }
846 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
847         LDKCResult_TxCreationKeysErrorZ *val = (LDKCResult_TxCreationKeysErrorZ*)(arg & ~1);
848         CHECK(!val->result_ok);
849         jclass err_conv = LDKSecp256k1Error_to_java(env, (*val->contents.err));
850         return err_conv;
851 }
852 static jclass LDKCOption_u32Z_Some_class = NULL;
853 static jmethodID LDKCOption_u32Z_Some_meth = NULL;
854 static jclass LDKCOption_u32Z_None_class = NULL;
855 static jmethodID LDKCOption_u32Z_None_meth = NULL;
856 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u32Z_init (JNIEnv *env, jclass clz) {
857         LDKCOption_u32Z_Some_class =
858                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_u32Z$Some;"));
859         CHECK(LDKCOption_u32Z_Some_class != NULL);
860         LDKCOption_u32Z_Some_meth = (*env)->GetMethodID(env, LDKCOption_u32Z_Some_class, "<init>", "(I)V");
861         CHECK(LDKCOption_u32Z_Some_meth != NULL);
862         LDKCOption_u32Z_None_class =
863                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_u32Z$None;"));
864         CHECK(LDKCOption_u32Z_None_class != NULL);
865         LDKCOption_u32Z_None_meth = (*env)->GetMethodID(env, LDKCOption_u32Z_None_class, "<init>", "()V");
866         CHECK(LDKCOption_u32Z_None_meth != NULL);
867 }
868 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u32Z_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
869         LDKCOption_u32Z *obj = (LDKCOption_u32Z*)(ptr & ~1);
870         switch(obj->tag) {
871                 case LDKCOption_u32Z_Some: {
872                         return (*env)->NewObject(env, LDKCOption_u32Z_Some_class, LDKCOption_u32Z_Some_meth, obj->some);
873                 }
874                 case LDKCOption_u32Z_None: {
875                         return (*env)->NewObject(env, LDKCOption_u32Z_None_class, LDKCOption_u32Z_None_meth);
876                 }
877                 default: abort();
878         }
879 }
880 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCOutputInCommitmentDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
881         return ((LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)arg)->result_ok;
882 }
883 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCOutputInCommitmentDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
884         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *val = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(arg & ~1);
885         CHECK(val->result_ok);
886         LDKHTLCOutputInCommitment res_var = (*val->contents.result);
887         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
888         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
889         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
890         return res_ref;
891 }
892 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCOutputInCommitmentDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
893         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *val = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(arg & ~1);
894         CHECK(!val->result_ok);
895         LDKDecodeError err_var = (*val->contents.err);
896         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
897         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
898         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
899         return err_ref;
900 }
901 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
902         return ((LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)arg)->result_ok;
903 }
904 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
905         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
906         CHECK(val->result_ok);
907         LDKCounterpartyChannelTransactionParameters res_var = (*val->contents.result);
908         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
909         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
910         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
911         return res_ref;
912 }
913 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
914         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
915         CHECK(!val->result_ok);
916         LDKDecodeError err_var = (*val->contents.err);
917         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
918         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
919         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
920         return err_ref;
921 }
922 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelTransactionParametersDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
923         return ((LDKCResult_ChannelTransactionParametersDecodeErrorZ*)arg)->result_ok;
924 }
925 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelTransactionParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
926         LDKCResult_ChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
927         CHECK(val->result_ok);
928         LDKChannelTransactionParameters res_var = (*val->contents.result);
929         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
930         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
931         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
932         return res_ref;
933 }
934 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelTransactionParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
935         LDKCResult_ChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
936         CHECK(!val->result_ok);
937         LDKDecodeError err_var = (*val->contents.err);
938         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
939         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
940         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
941         return err_ref;
942 }
943 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HolderCommitmentTransactionDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
944         return ((LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)arg)->result_ok;
945 }
946 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HolderCommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
947         LDKCResult_HolderCommitmentTransactionDecodeErrorZ *val = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(arg & ~1);
948         CHECK(val->result_ok);
949         LDKHolderCommitmentTransaction res_var = (*val->contents.result);
950         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
951         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
952         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
953         return res_ref;
954 }
955 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HolderCommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
956         LDKCResult_HolderCommitmentTransactionDecodeErrorZ *val = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(arg & ~1);
957         CHECK(!val->result_ok);
958         LDKDecodeError err_var = (*val->contents.err);
959         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
960         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
961         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
962         return err_ref;
963 }
964 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1BuiltCommitmentTransactionDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
965         return ((LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)arg)->result_ok;
966 }
967 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1BuiltCommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
968         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *val = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(arg & ~1);
969         CHECK(val->result_ok);
970         LDKBuiltCommitmentTransaction res_var = (*val->contents.result);
971         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
972         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
973         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
974         return res_ref;
975 }
976 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1BuiltCommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
977         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *val = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(arg & ~1);
978         CHECK(!val->result_ok);
979         LDKDecodeError err_var = (*val->contents.err);
980         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
981         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
982         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
983         return err_ref;
984 }
985 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TrustedClosingTransactionNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
986         return ((LDKCResult_TrustedClosingTransactionNoneZ*)arg)->result_ok;
987 }
988 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TrustedClosingTransactionNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
989         LDKCResult_TrustedClosingTransactionNoneZ *val = (LDKCResult_TrustedClosingTransactionNoneZ*)(arg & ~1);
990         CHECK(val->result_ok);
991         LDKTrustedClosingTransaction res_var = (*val->contents.result);
992         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
993         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
994         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
995         return res_ref;
996 }
997 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TrustedClosingTransactionNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
998         LDKCResult_TrustedClosingTransactionNoneZ *val = (LDKCResult_TrustedClosingTransactionNoneZ*)(arg & ~1);
999         CHECK(!val->result_ok);
1000         return *val->contents.err;
1001 }
1002 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentTransactionDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1003         return ((LDKCResult_CommitmentTransactionDecodeErrorZ*)arg)->result_ok;
1004 }
1005 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1006         LDKCResult_CommitmentTransactionDecodeErrorZ *val = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(arg & ~1);
1007         CHECK(val->result_ok);
1008         LDKCommitmentTransaction res_var = (*val->contents.result);
1009         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1010         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1011         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1012         return res_ref;
1013 }
1014 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1015         LDKCResult_CommitmentTransactionDecodeErrorZ *val = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(arg & ~1);
1016         CHECK(!val->result_ok);
1017         LDKDecodeError err_var = (*val->contents.err);
1018         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1019         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1020         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1021         return err_ref;
1022 }
1023 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TrustedCommitmentTransactionNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1024         return ((LDKCResult_TrustedCommitmentTransactionNoneZ*)arg)->result_ok;
1025 }
1026 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TrustedCommitmentTransactionNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1027         LDKCResult_TrustedCommitmentTransactionNoneZ *val = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(arg & ~1);
1028         CHECK(val->result_ok);
1029         LDKTrustedCommitmentTransaction res_var = (*val->contents.result);
1030         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1031         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1032         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1033         return res_ref;
1034 }
1035 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TrustedCommitmentTransactionNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1036         LDKCResult_TrustedCommitmentTransactionNoneZ *val = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(arg & ~1);
1037         CHECK(!val->result_ok);
1038         return *val->contents.err;
1039 }
1040 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1SignatureZNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1041         return ((LDKCResult_CVec_SignatureZNoneZ*)arg)->result_ok;
1042 }
1043 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1SignatureZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1044         LDKCResult_CVec_SignatureZNoneZ *val = (LDKCResult_CVec_SignatureZNoneZ*)(arg & ~1);
1045         CHECK(val->result_ok);
1046         LDKCVec_SignatureZ res_var = (*val->contents.result);
1047         jobjectArray res_arr = (*env)->NewObjectArray(env, res_var.datalen, arr_of_B_clz, NULL);
1048         ;
1049         for (size_t i = 0; i < res_var.datalen; i++) {
1050                 int8_tArray res_conv_8_arr = (*env)->NewByteArray(env, 64);
1051                 (*env)->SetByteArrayRegion(env, res_conv_8_arr, 0, 64, res_var.data[i].compact_form);
1052                 (*env)->SetObjectArrayElement(env, res_arr, i, res_conv_8_arr);
1053         }
1054         return res_arr;
1055 }
1056 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1SignatureZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1057         LDKCResult_CVec_SignatureZNoneZ *val = (LDKCResult_CVec_SignatureZNoneZ*)(arg & ~1);
1058         CHECK(!val->result_ok);
1059         return *val->contents.err;
1060 }
1061 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownScriptDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1062         return ((LDKCResult_ShutdownScriptDecodeErrorZ*)arg)->result_ok;
1063 }
1064 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownScriptDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1065         LDKCResult_ShutdownScriptDecodeErrorZ *val = (LDKCResult_ShutdownScriptDecodeErrorZ*)(arg & ~1);
1066         CHECK(val->result_ok);
1067         LDKShutdownScript res_var = (*val->contents.result);
1068         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1069         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1070         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1071         return res_ref;
1072 }
1073 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownScriptDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1074         LDKCResult_ShutdownScriptDecodeErrorZ *val = (LDKCResult_ShutdownScriptDecodeErrorZ*)(arg & ~1);
1075         CHECK(!val->result_ok);
1076         LDKDecodeError err_var = (*val->contents.err);
1077         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1078         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1079         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1080         return err_ref;
1081 }
1082 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownScriptInvalidShutdownScriptZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1083         return ((LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)arg)->result_ok;
1084 }
1085 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownScriptInvalidShutdownScriptZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1086         LDKCResult_ShutdownScriptInvalidShutdownScriptZ *val = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(arg & ~1);
1087         CHECK(val->result_ok);
1088         LDKShutdownScript res_var = (*val->contents.result);
1089         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1090         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1091         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1092         return res_ref;
1093 }
1094 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownScriptInvalidShutdownScriptZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1095         LDKCResult_ShutdownScriptInvalidShutdownScriptZ *val = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(arg & ~1);
1096         CHECK(!val->result_ok);
1097         LDKInvalidShutdownScript err_var = (*val->contents.err);
1098         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1099         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1100         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1101         return err_ref;
1102 }
1103 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1104         return ((LDKCResult_NoneErrorZ*)arg)->result_ok;
1105 }
1106 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1107         LDKCResult_NoneErrorZ *val = (LDKCResult_NoneErrorZ*)(arg & ~1);
1108         CHECK(val->result_ok);
1109         return *val->contents.result;
1110 }
1111 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1112         LDKCResult_NoneErrorZ *val = (LDKCResult_NoneErrorZ*)(arg & ~1);
1113         CHECK(!val->result_ok);
1114         jclass err_conv = LDKIOError_to_java(env, (*val->contents.err));
1115         return err_conv;
1116 }
1117 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteHopDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1118         return ((LDKCResult_RouteHopDecodeErrorZ*)arg)->result_ok;
1119 }
1120 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteHopDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1121         LDKCResult_RouteHopDecodeErrorZ *val = (LDKCResult_RouteHopDecodeErrorZ*)(arg & ~1);
1122         CHECK(val->result_ok);
1123         LDKRouteHop res_var = (*val->contents.result);
1124         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1125         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1126         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1127         return res_ref;
1128 }
1129 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteHopDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1130         LDKCResult_RouteHopDecodeErrorZ *val = (LDKCResult_RouteHopDecodeErrorZ*)(arg & ~1);
1131         CHECK(!val->result_ok);
1132         LDKDecodeError err_var = (*val->contents.err);
1133         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1134         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1135         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1136         return err_ref;
1137 }
1138 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1RouteHopZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1139         LDKCVec_RouteHopZ *ret = MALLOC(sizeof(LDKCVec_RouteHopZ), "LDKCVec_RouteHopZ");
1140         ret->datalen = (*env)->GetArrayLength(env, elems);
1141         if (ret->datalen == 0) {
1142                 ret->data = NULL;
1143         } else {
1144                 ret->data = MALLOC(sizeof(LDKRouteHop) * ret->datalen, "LDKCVec_RouteHopZ Data");
1145                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1146                 for (size_t i = 0; i < ret->datalen; i++) {
1147                         int64_t arr_elem = java_elems[i];
1148                         LDKRouteHop arr_elem_conv;
1149                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
1150                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
1151                         arr_elem_conv = RouteHop_clone(&arr_elem_conv);
1152                         ret->data[i] = arr_elem_conv;
1153                 }
1154                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1155         }
1156         return (uint64_t)ret;
1157 }
1158 static inline LDKCVec_RouteHopZ CVec_RouteHopZ_clone(const LDKCVec_RouteHopZ *orig) {
1159         LDKCVec_RouteHopZ ret = { .data = MALLOC(sizeof(LDKRouteHop) * orig->datalen, "LDKCVec_RouteHopZ clone bytes"), .datalen = orig->datalen };
1160         for (size_t i = 0; i < ret.datalen; i++) {
1161                 ret.data[i] = RouteHop_clone(&orig->data[i]);
1162         }
1163         return ret;
1164 }
1165 static inline LDKCVec_CVec_RouteHopZZ CVec_CVec_RouteHopZZ_clone(const LDKCVec_CVec_RouteHopZZ *orig) {
1166         LDKCVec_CVec_RouteHopZZ ret = { .data = MALLOC(sizeof(LDKCVec_RouteHopZ) * orig->datalen, "LDKCVec_CVec_RouteHopZZ clone bytes"), .datalen = orig->datalen };
1167         for (size_t i = 0; i < ret.datalen; i++) {
1168                 ret.data[i] = CVec_RouteHopZ_clone(&orig->data[i]);
1169         }
1170         return ret;
1171 }
1172 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1173         return ((LDKCResult_RouteDecodeErrorZ*)arg)->result_ok;
1174 }
1175 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1176         LDKCResult_RouteDecodeErrorZ *val = (LDKCResult_RouteDecodeErrorZ*)(arg & ~1);
1177         CHECK(val->result_ok);
1178         LDKRoute res_var = (*val->contents.result);
1179         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1180         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1181         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1182         return res_ref;
1183 }
1184 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1185         LDKCResult_RouteDecodeErrorZ *val = (LDKCResult_RouteDecodeErrorZ*)(arg & ~1);
1186         CHECK(!val->result_ok);
1187         LDKDecodeError err_var = (*val->contents.err);
1188         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1189         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1190         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1191         return err_ref;
1192 }
1193 static jclass LDKCOption_u64Z_Some_class = NULL;
1194 static jmethodID LDKCOption_u64Z_Some_meth = NULL;
1195 static jclass LDKCOption_u64Z_None_class = NULL;
1196 static jmethodID LDKCOption_u64Z_None_meth = NULL;
1197 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u64Z_init (JNIEnv *env, jclass clz) {
1198         LDKCOption_u64Z_Some_class =
1199                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_u64Z$Some;"));
1200         CHECK(LDKCOption_u64Z_Some_class != NULL);
1201         LDKCOption_u64Z_Some_meth = (*env)->GetMethodID(env, LDKCOption_u64Z_Some_class, "<init>", "(J)V");
1202         CHECK(LDKCOption_u64Z_Some_meth != NULL);
1203         LDKCOption_u64Z_None_class =
1204                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_u64Z$None;"));
1205         CHECK(LDKCOption_u64Z_None_class != NULL);
1206         LDKCOption_u64Z_None_meth = (*env)->GetMethodID(env, LDKCOption_u64Z_None_class, "<init>", "()V");
1207         CHECK(LDKCOption_u64Z_None_meth != NULL);
1208 }
1209 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u64Z_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1210         LDKCOption_u64Z *obj = (LDKCOption_u64Z*)(ptr & ~1);
1211         switch(obj->tag) {
1212                 case LDKCOption_u64Z_Some: {
1213                         return (*env)->NewObject(env, LDKCOption_u64Z_Some_class, LDKCOption_u64Z_Some_meth, obj->some);
1214                 }
1215                 case LDKCOption_u64Z_None: {
1216                         return (*env)->NewObject(env, LDKCOption_u64Z_None_class, LDKCOption_u64Z_None_meth);
1217                 }
1218                 default: abort();
1219         }
1220 }
1221 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1ChannelDetailsZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1222         LDKCVec_ChannelDetailsZ *ret = MALLOC(sizeof(LDKCVec_ChannelDetailsZ), "LDKCVec_ChannelDetailsZ");
1223         ret->datalen = (*env)->GetArrayLength(env, elems);
1224         if (ret->datalen == 0) {
1225                 ret->data = NULL;
1226         } else {
1227                 ret->data = MALLOC(sizeof(LDKChannelDetails) * ret->datalen, "LDKCVec_ChannelDetailsZ Data");
1228                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1229                 for (size_t i = 0; i < ret->datalen; i++) {
1230                         int64_t arr_elem = java_elems[i];
1231                         LDKChannelDetails arr_elem_conv;
1232                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
1233                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
1234                         arr_elem_conv = ChannelDetails_clone(&arr_elem_conv);
1235                         ret->data[i] = arr_elem_conv;
1236                 }
1237                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1238         }
1239         return (uint64_t)ret;
1240 }
1241 static inline LDKCVec_ChannelDetailsZ CVec_ChannelDetailsZ_clone(const LDKCVec_ChannelDetailsZ *orig) {
1242         LDKCVec_ChannelDetailsZ ret = { .data = MALLOC(sizeof(LDKChannelDetails) * orig->datalen, "LDKCVec_ChannelDetailsZ clone bytes"), .datalen = orig->datalen };
1243         for (size_t i = 0; i < ret.datalen; i++) {
1244                 ret.data[i] = ChannelDetails_clone(&orig->data[i]);
1245         }
1246         return ret;
1247 }
1248 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1RouteHintZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1249         LDKCVec_RouteHintZ *ret = MALLOC(sizeof(LDKCVec_RouteHintZ), "LDKCVec_RouteHintZ");
1250         ret->datalen = (*env)->GetArrayLength(env, elems);
1251         if (ret->datalen == 0) {
1252                 ret->data = NULL;
1253         } else {
1254                 ret->data = MALLOC(sizeof(LDKRouteHint) * ret->datalen, "LDKCVec_RouteHintZ Data");
1255                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1256                 for (size_t i = 0; i < ret->datalen; i++) {
1257                         int64_t arr_elem = java_elems[i];
1258                         LDKRouteHint arr_elem_conv;
1259                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
1260                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
1261                         arr_elem_conv = RouteHint_clone(&arr_elem_conv);
1262                         ret->data[i] = arr_elem_conv;
1263                 }
1264                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1265         }
1266         return (uint64_t)ret;
1267 }
1268 static inline LDKCVec_RouteHintZ CVec_RouteHintZ_clone(const LDKCVec_RouteHintZ *orig) {
1269         LDKCVec_RouteHintZ ret = { .data = MALLOC(sizeof(LDKRouteHint) * orig->datalen, "LDKCVec_RouteHintZ clone bytes"), .datalen = orig->datalen };
1270         for (size_t i = 0; i < ret.datalen; i++) {
1271                 ret.data[i] = RouteHint_clone(&orig->data[i]);
1272         }
1273         return ret;
1274 }
1275 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteLightningErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1276         return ((LDKCResult_RouteLightningErrorZ*)arg)->result_ok;
1277 }
1278 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1279         LDKCResult_RouteLightningErrorZ *val = (LDKCResult_RouteLightningErrorZ*)(arg & ~1);
1280         CHECK(val->result_ok);
1281         LDKRoute res_var = (*val->contents.result);
1282         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1283         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1284         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1285         return res_ref;
1286 }
1287 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1288         LDKCResult_RouteLightningErrorZ *val = (LDKCResult_RouteLightningErrorZ*)(arg & ~1);
1289         CHECK(!val->result_ok);
1290         LDKLightningError err_var = (*val->contents.err);
1291         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1292         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1293         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1294         return err_ref;
1295 }
1296 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxOutAccessErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1297         return ((LDKCResult_TxOutAccessErrorZ*)arg)->result_ok;
1298 }
1299 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxOutAccessErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1300         LDKCResult_TxOutAccessErrorZ *val = (LDKCResult_TxOutAccessErrorZ*)(arg & ~1);
1301         CHECK(val->result_ok);
1302         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
1303         return (uint64_t)res_ref;
1304 }
1305 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxOutAccessErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1306         LDKCResult_TxOutAccessErrorZ *val = (LDKCResult_TxOutAccessErrorZ*)(arg & ~1);
1307         CHECK(!val->result_ok);
1308         jclass err_conv = LDKAccessError_to_java(env, (*val->contents.err));
1309         return err_conv;
1310 }
1311 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1usizeTransactionZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
1312         LDKC2Tuple_usizeTransactionZ* ret = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
1313         ret->a = a;
1314         LDKTransaction b_ref;
1315         b_ref.datalen = (*env)->GetArrayLength(env, b);
1316         b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
1317         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
1318         b_ref.data_is_owned = false;
1319         ret->b = b_ref;
1320         return (uint64_t)ret;
1321 }
1322 static inline uintptr_t C2Tuple_usizeTransactionZ_get_a(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR tuple){
1323         return tuple->a;
1324 }
1325 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1get_1a(JNIEnv *env, jclass clz, int64_t tuple) {
1326         LDKC2Tuple_usizeTransactionZ* tuple_conv = (LDKC2Tuple_usizeTransactionZ*)(tuple & ~1);
1327         int64_t ret_val = C2Tuple_usizeTransactionZ_get_a(tuple_conv);
1328         return ret_val;
1329 }
1330
1331 static inline struct LDKTransaction C2Tuple_usizeTransactionZ_get_b(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR tuple){
1332         return tuple->b;
1333 }
1334 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1get_1b(JNIEnv *env, jclass clz, int64_t tuple) {
1335         LDKC2Tuple_usizeTransactionZ* tuple_conv = (LDKC2Tuple_usizeTransactionZ*)(tuple & ~1);
1336         LDKTransaction ret_var = C2Tuple_usizeTransactionZ_get_b(tuple_conv);
1337         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
1338         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
1339         Transaction_free(ret_var);
1340         return ret_arr;
1341 }
1342
1343 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1usizeTransactionZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1344         LDKCVec_C2Tuple_usizeTransactionZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_usizeTransactionZZ), "LDKCVec_C2Tuple_usizeTransactionZZ");
1345         ret->datalen = (*env)->GetArrayLength(env, elems);
1346         if (ret->datalen == 0) {
1347                 ret->data = NULL;
1348         } else {
1349                 ret->data = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ) * ret->datalen, "LDKCVec_C2Tuple_usizeTransactionZZ Data");
1350                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1351                 for (size_t i = 0; i < ret->datalen; i++) {
1352                         int64_t arr_elem = java_elems[i];
1353                         LDKC2Tuple_usizeTransactionZ arr_elem_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)arr_elem) & ~1);
1354                         arr_elem_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)arr_elem) & ~1));
1355                         ret->data[i] = arr_elem_conv;
1356                 }
1357                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1358         }
1359         return (uint64_t)ret;
1360 }
1361 static inline LDKCVec_C2Tuple_usizeTransactionZZ CVec_C2Tuple_usizeTransactionZZ_clone(const LDKCVec_C2Tuple_usizeTransactionZZ *orig) {
1362         LDKCVec_C2Tuple_usizeTransactionZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ) * orig->datalen, "LDKCVec_C2Tuple_usizeTransactionZZ clone bytes"), .datalen = orig->datalen };
1363         for (size_t i = 0; i < ret.datalen; i++) {
1364                 ret.data[i] = C2Tuple_usizeTransactionZ_clone(&orig->data[i]);
1365         }
1366         return ret;
1367 }
1368 static inline LDKCVec_TxidZ CVec_ThirtyTwoBytesZ_clone(const LDKCVec_TxidZ *orig) {
1369         LDKCVec_TxidZ ret = { .data = MALLOC(sizeof(LDKThirtyTwoBytes) * orig->datalen, "LDKCVec_TxidZ clone bytes"), .datalen = orig->datalen };
1370         for (size_t i = 0; i < ret.datalen; i++) {
1371                 ret.data[i] = ThirtyTwoBytes_clone(&orig->data[i]);
1372         }
1373         return ret;
1374 }
1375 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneChannelMonitorUpdateErrZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1376         return ((LDKCResult_NoneChannelMonitorUpdateErrZ*)arg)->result_ok;
1377 }
1378 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneChannelMonitorUpdateErrZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1379         LDKCResult_NoneChannelMonitorUpdateErrZ *val = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(arg & ~1);
1380         CHECK(val->result_ok);
1381         return *val->contents.result;
1382 }
1383 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneChannelMonitorUpdateErrZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1384         LDKCResult_NoneChannelMonitorUpdateErrZ *val = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(arg & ~1);
1385         CHECK(!val->result_ok);
1386         jclass err_conv = LDKChannelMonitorUpdateErr_to_java(env, (*val->contents.err));
1387         return err_conv;
1388 }
1389 static jclass LDKMonitorEvent_HTLCEvent_class = NULL;
1390 static jmethodID LDKMonitorEvent_HTLCEvent_meth = NULL;
1391 static jclass LDKMonitorEvent_CommitmentTxConfirmed_class = NULL;
1392 static jmethodID LDKMonitorEvent_CommitmentTxConfirmed_meth = NULL;
1393 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKMonitorEvent_init (JNIEnv *env, jclass clz) {
1394         LDKMonitorEvent_HTLCEvent_class =
1395                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMonitorEvent$HTLCEvent;"));
1396         CHECK(LDKMonitorEvent_HTLCEvent_class != NULL);
1397         LDKMonitorEvent_HTLCEvent_meth = (*env)->GetMethodID(env, LDKMonitorEvent_HTLCEvent_class, "<init>", "(J)V");
1398         CHECK(LDKMonitorEvent_HTLCEvent_meth != NULL);
1399         LDKMonitorEvent_CommitmentTxConfirmed_class =
1400                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMonitorEvent$CommitmentTxConfirmed;"));
1401         CHECK(LDKMonitorEvent_CommitmentTxConfirmed_class != NULL);
1402         LDKMonitorEvent_CommitmentTxConfirmed_meth = (*env)->GetMethodID(env, LDKMonitorEvent_CommitmentTxConfirmed_class, "<init>", "(J)V");
1403         CHECK(LDKMonitorEvent_CommitmentTxConfirmed_meth != NULL);
1404 }
1405 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKMonitorEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1406         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
1407         switch(obj->tag) {
1408                 case LDKMonitorEvent_HTLCEvent: {
1409                         LDKHTLCUpdate htlc_event_var = obj->htlc_event;
1410                         CHECK((((uint64_t)htlc_event_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1411                         CHECK((((uint64_t)&htlc_event_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1412                         uint64_t htlc_event_ref = (uint64_t)htlc_event_var.inner & ~1;
1413                         return (*env)->NewObject(env, LDKMonitorEvent_HTLCEvent_class, LDKMonitorEvent_HTLCEvent_meth, htlc_event_ref);
1414                 }
1415                 case LDKMonitorEvent_CommitmentTxConfirmed: {
1416                         LDKOutPoint commitment_tx_confirmed_var = obj->commitment_tx_confirmed;
1417                         CHECK((((uint64_t)commitment_tx_confirmed_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1418                         CHECK((((uint64_t)&commitment_tx_confirmed_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1419                         uint64_t commitment_tx_confirmed_ref = (uint64_t)commitment_tx_confirmed_var.inner & ~1;
1420                         return (*env)->NewObject(env, LDKMonitorEvent_CommitmentTxConfirmed_class, LDKMonitorEvent_CommitmentTxConfirmed_meth, commitment_tx_confirmed_ref);
1421                 }
1422                 default: abort();
1423         }
1424 }
1425 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1MonitorEventZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1426         LDKCVec_MonitorEventZ *ret = MALLOC(sizeof(LDKCVec_MonitorEventZ), "LDKCVec_MonitorEventZ");
1427         ret->datalen = (*env)->GetArrayLength(env, elems);
1428         if (ret->datalen == 0) {
1429                 ret->data = NULL;
1430         } else {
1431                 ret->data = MALLOC(sizeof(LDKMonitorEvent) * ret->datalen, "LDKCVec_MonitorEventZ Data");
1432                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1433                 for (size_t i = 0; i < ret->datalen; i++) {
1434                         int64_t arr_elem = java_elems[i];
1435                         LDKMonitorEvent arr_elem_conv = *(LDKMonitorEvent*)(((uint64_t)arr_elem) & ~1);
1436                         arr_elem_conv = MonitorEvent_clone((LDKMonitorEvent*)(((uint64_t)arr_elem) & ~1));
1437                         ret->data[i] = arr_elem_conv;
1438                 }
1439                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1440         }
1441         return (uint64_t)ret;
1442 }
1443 static inline LDKCVec_MonitorEventZ CVec_MonitorEventZ_clone(const LDKCVec_MonitorEventZ *orig) {
1444         LDKCVec_MonitorEventZ ret = { .data = MALLOC(sizeof(LDKMonitorEvent) * orig->datalen, "LDKCVec_MonitorEventZ clone bytes"), .datalen = orig->datalen };
1445         for (size_t i = 0; i < ret.datalen; i++) {
1446                 ret.data[i] = MonitorEvent_clone(&orig->data[i]);
1447         }
1448         return ret;
1449 }
1450 static jclass LDKCOption_C2Tuple_usizeTransactionZZ_Some_class = NULL;
1451 static jmethodID LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth = NULL;
1452 static jclass LDKCOption_C2Tuple_usizeTransactionZZ_None_class = NULL;
1453 static jmethodID LDKCOption_C2Tuple_usizeTransactionZZ_None_meth = NULL;
1454 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1C2Tuple_1usizeTransactionZZ_init (JNIEnv *env, jclass clz) {
1455         LDKCOption_C2Tuple_usizeTransactionZZ_Some_class =
1456                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_C2Tuple_usizeTransactionZZ$Some;"));
1457         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_Some_class != NULL);
1458         LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_C2Tuple_usizeTransactionZZ_Some_class, "<init>", "(J)V");
1459         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth != NULL);
1460         LDKCOption_C2Tuple_usizeTransactionZZ_None_class =
1461                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_C2Tuple_usizeTransactionZZ$None;"));
1462         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_None_class != NULL);
1463         LDKCOption_C2Tuple_usizeTransactionZZ_None_meth = (*env)->GetMethodID(env, LDKCOption_C2Tuple_usizeTransactionZZ_None_class, "<init>", "()V");
1464         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_None_meth != NULL);
1465 }
1466 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1C2Tuple_1usizeTransactionZZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1467         LDKCOption_C2Tuple_usizeTransactionZZ *obj = (LDKCOption_C2Tuple_usizeTransactionZZ*)(ptr & ~1);
1468         switch(obj->tag) {
1469                 case LDKCOption_C2Tuple_usizeTransactionZZ_Some: {
1470                         LDKC2Tuple_usizeTransactionZ* some_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
1471                         *some_conv = obj->some;
1472                         *some_conv = C2Tuple_usizeTransactionZ_clone(some_conv);
1473                         return (*env)->NewObject(env, LDKCOption_C2Tuple_usizeTransactionZZ_Some_class, LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth, ((uint64_t)some_conv));
1474                 }
1475                 case LDKCOption_C2Tuple_usizeTransactionZZ_None: {
1476                         return (*env)->NewObject(env, LDKCOption_C2Tuple_usizeTransactionZZ_None_class, LDKCOption_C2Tuple_usizeTransactionZZ_None_meth);
1477                 }
1478                 default: abort();
1479         }
1480 }
1481 static jclass LDKNetworkUpdate_ChannelUpdateMessage_class = NULL;
1482 static jmethodID LDKNetworkUpdate_ChannelUpdateMessage_meth = NULL;
1483 static jclass LDKNetworkUpdate_ChannelClosed_class = NULL;
1484 static jmethodID LDKNetworkUpdate_ChannelClosed_meth = NULL;
1485 static jclass LDKNetworkUpdate_NodeFailure_class = NULL;
1486 static jmethodID LDKNetworkUpdate_NodeFailure_meth = NULL;
1487 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKNetworkUpdate_init (JNIEnv *env, jclass clz) {
1488         LDKNetworkUpdate_ChannelUpdateMessage_class =
1489                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetworkUpdate$ChannelUpdateMessage;"));
1490         CHECK(LDKNetworkUpdate_ChannelUpdateMessage_class != NULL);
1491         LDKNetworkUpdate_ChannelUpdateMessage_meth = (*env)->GetMethodID(env, LDKNetworkUpdate_ChannelUpdateMessage_class, "<init>", "(J)V");
1492         CHECK(LDKNetworkUpdate_ChannelUpdateMessage_meth != NULL);
1493         LDKNetworkUpdate_ChannelClosed_class =
1494                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetworkUpdate$ChannelClosed;"));
1495         CHECK(LDKNetworkUpdate_ChannelClosed_class != NULL);
1496         LDKNetworkUpdate_ChannelClosed_meth = (*env)->GetMethodID(env, LDKNetworkUpdate_ChannelClosed_class, "<init>", "(JZ)V");
1497         CHECK(LDKNetworkUpdate_ChannelClosed_meth != NULL);
1498         LDKNetworkUpdate_NodeFailure_class =
1499                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetworkUpdate$NodeFailure;"));
1500         CHECK(LDKNetworkUpdate_NodeFailure_class != NULL);
1501         LDKNetworkUpdate_NodeFailure_meth = (*env)->GetMethodID(env, LDKNetworkUpdate_NodeFailure_class, "<init>", "([BZ)V");
1502         CHECK(LDKNetworkUpdate_NodeFailure_meth != NULL);
1503 }
1504 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKNetworkUpdate_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1505         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)(ptr & ~1);
1506         switch(obj->tag) {
1507                 case LDKNetworkUpdate_ChannelUpdateMessage: {
1508                         LDKChannelUpdate msg_var = obj->channel_update_message.msg;
1509                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1510                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1511                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1512                         return (*env)->NewObject(env, LDKNetworkUpdate_ChannelUpdateMessage_class, LDKNetworkUpdate_ChannelUpdateMessage_meth, msg_ref);
1513                 }
1514                 case LDKNetworkUpdate_ChannelClosed: {
1515                         return (*env)->NewObject(env, LDKNetworkUpdate_ChannelClosed_class, LDKNetworkUpdate_ChannelClosed_meth, obj->channel_closed.short_channel_id, obj->channel_closed.is_permanent);
1516                 }
1517                 case LDKNetworkUpdate_NodeFailure: {
1518                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1519                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->node_failure.node_id.compressed_form);
1520                         return (*env)->NewObject(env, LDKNetworkUpdate_NodeFailure_class, LDKNetworkUpdate_NodeFailure_meth, node_id_arr, obj->node_failure.is_permanent);
1521                 }
1522                 default: abort();
1523         }
1524 }
1525 static jclass LDKCOption_NetworkUpdateZ_Some_class = NULL;
1526 static jmethodID LDKCOption_NetworkUpdateZ_Some_meth = NULL;
1527 static jclass LDKCOption_NetworkUpdateZ_None_class = NULL;
1528 static jmethodID LDKCOption_NetworkUpdateZ_None_meth = NULL;
1529 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1NetworkUpdateZ_init (JNIEnv *env, jclass clz) {
1530         LDKCOption_NetworkUpdateZ_Some_class =
1531                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_NetworkUpdateZ$Some;"));
1532         CHECK(LDKCOption_NetworkUpdateZ_Some_class != NULL);
1533         LDKCOption_NetworkUpdateZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_NetworkUpdateZ_Some_class, "<init>", "(J)V");
1534         CHECK(LDKCOption_NetworkUpdateZ_Some_meth != NULL);
1535         LDKCOption_NetworkUpdateZ_None_class =
1536                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_NetworkUpdateZ$None;"));
1537         CHECK(LDKCOption_NetworkUpdateZ_None_class != NULL);
1538         LDKCOption_NetworkUpdateZ_None_meth = (*env)->GetMethodID(env, LDKCOption_NetworkUpdateZ_None_class, "<init>", "()V");
1539         CHECK(LDKCOption_NetworkUpdateZ_None_meth != NULL);
1540 }
1541 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1NetworkUpdateZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1542         LDKCOption_NetworkUpdateZ *obj = (LDKCOption_NetworkUpdateZ*)(ptr & ~1);
1543         switch(obj->tag) {
1544                 case LDKCOption_NetworkUpdateZ_Some: {
1545                         uint64_t some_ref = ((uint64_t)&obj->some) | 1;
1546                         return (*env)->NewObject(env, LDKCOption_NetworkUpdateZ_Some_class, LDKCOption_NetworkUpdateZ_Some_meth, some_ref);
1547                 }
1548                 case LDKCOption_NetworkUpdateZ_None: {
1549                         return (*env)->NewObject(env, LDKCOption_NetworkUpdateZ_None_class, LDKCOption_NetworkUpdateZ_None_meth);
1550                 }
1551                 default: abort();
1552         }
1553 }
1554 static jclass LDKSpendableOutputDescriptor_StaticOutput_class = NULL;
1555 static jmethodID LDKSpendableOutputDescriptor_StaticOutput_meth = NULL;
1556 static jclass LDKSpendableOutputDescriptor_DelayedPaymentOutput_class = NULL;
1557 static jmethodID LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth = NULL;
1558 static jclass LDKSpendableOutputDescriptor_StaticPaymentOutput_class = NULL;
1559 static jmethodID LDKSpendableOutputDescriptor_StaticPaymentOutput_meth = NULL;
1560 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKSpendableOutputDescriptor_init (JNIEnv *env, jclass clz) {
1561         LDKSpendableOutputDescriptor_StaticOutput_class =
1562                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKSpendableOutputDescriptor$StaticOutput;"));
1563         CHECK(LDKSpendableOutputDescriptor_StaticOutput_class != NULL);
1564         LDKSpendableOutputDescriptor_StaticOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_StaticOutput_class, "<init>", "(JJ)V");
1565         CHECK(LDKSpendableOutputDescriptor_StaticOutput_meth != NULL);
1566         LDKSpendableOutputDescriptor_DelayedPaymentOutput_class =
1567                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKSpendableOutputDescriptor$DelayedPaymentOutput;"));
1568         CHECK(LDKSpendableOutputDescriptor_DelayedPaymentOutput_class != NULL);
1569         LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_DelayedPaymentOutput_class, "<init>", "(J)V");
1570         CHECK(LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth != NULL);
1571         LDKSpendableOutputDescriptor_StaticPaymentOutput_class =
1572                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKSpendableOutputDescriptor$StaticPaymentOutput;"));
1573         CHECK(LDKSpendableOutputDescriptor_StaticPaymentOutput_class != NULL);
1574         LDKSpendableOutputDescriptor_StaticPaymentOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_StaticPaymentOutput_class, "<init>", "(J)V");
1575         CHECK(LDKSpendableOutputDescriptor_StaticPaymentOutput_meth != NULL);
1576 }
1577 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKSpendableOutputDescriptor_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1578         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)(ptr & ~1);
1579         switch(obj->tag) {
1580                 case LDKSpendableOutputDescriptor_StaticOutput: {
1581                         LDKOutPoint outpoint_var = obj->static_output.outpoint;
1582                         CHECK((((uint64_t)outpoint_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1583                         CHECK((((uint64_t)&outpoint_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1584                         uint64_t outpoint_ref = (uint64_t)outpoint_var.inner & ~1;
1585                         uint64_t output_ref = ((uint64_t)&obj->static_output.output) | 1;
1586                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_StaticOutput_class, LDKSpendableOutputDescriptor_StaticOutput_meth, outpoint_ref, (uint64_t)output_ref);
1587                 }
1588                 case LDKSpendableOutputDescriptor_DelayedPaymentOutput: {
1589                         LDKDelayedPaymentOutputDescriptor delayed_payment_output_var = obj->delayed_payment_output;
1590                         CHECK((((uint64_t)delayed_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1591                         CHECK((((uint64_t)&delayed_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1592                         uint64_t delayed_payment_output_ref = (uint64_t)delayed_payment_output_var.inner & ~1;
1593                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_DelayedPaymentOutput_class, LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth, delayed_payment_output_ref);
1594                 }
1595                 case LDKSpendableOutputDescriptor_StaticPaymentOutput: {
1596                         LDKStaticPaymentOutputDescriptor static_payment_output_var = obj->static_payment_output;
1597                         CHECK((((uint64_t)static_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1598                         CHECK((((uint64_t)&static_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1599                         uint64_t static_payment_output_ref = (uint64_t)static_payment_output_var.inner & ~1;
1600                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_StaticPaymentOutput_class, LDKSpendableOutputDescriptor_StaticPaymentOutput_meth, static_payment_output_ref);
1601                 }
1602                 default: abort();
1603         }
1604 }
1605 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1SpendableOutputDescriptorZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1606         LDKCVec_SpendableOutputDescriptorZ *ret = MALLOC(sizeof(LDKCVec_SpendableOutputDescriptorZ), "LDKCVec_SpendableOutputDescriptorZ");
1607         ret->datalen = (*env)->GetArrayLength(env, elems);
1608         if (ret->datalen == 0) {
1609                 ret->data = NULL;
1610         } else {
1611                 ret->data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * ret->datalen, "LDKCVec_SpendableOutputDescriptorZ Data");
1612                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1613                 for (size_t i = 0; i < ret->datalen; i++) {
1614                         int64_t arr_elem = java_elems[i];
1615                         LDKSpendableOutputDescriptor arr_elem_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)arr_elem) & ~1);
1616                         arr_elem_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uint64_t)arr_elem) & ~1));
1617                         ret->data[i] = arr_elem_conv;
1618                 }
1619                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1620         }
1621         return (uint64_t)ret;
1622 }
1623 static inline LDKCVec_SpendableOutputDescriptorZ CVec_SpendableOutputDescriptorZ_clone(const LDKCVec_SpendableOutputDescriptorZ *orig) {
1624         LDKCVec_SpendableOutputDescriptorZ ret = { .data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * orig->datalen, "LDKCVec_SpendableOutputDescriptorZ clone bytes"), .datalen = orig->datalen };
1625         for (size_t i = 0; i < ret.datalen; i++) {
1626                 ret.data[i] = SpendableOutputDescriptor_clone(&orig->data[i]);
1627         }
1628         return ret;
1629 }
1630 static jclass LDKErrorAction_DisconnectPeer_class = NULL;
1631 static jmethodID LDKErrorAction_DisconnectPeer_meth = NULL;
1632 static jclass LDKErrorAction_IgnoreError_class = NULL;
1633 static jmethodID LDKErrorAction_IgnoreError_meth = NULL;
1634 static jclass LDKErrorAction_IgnoreAndLog_class = NULL;
1635 static jmethodID LDKErrorAction_IgnoreAndLog_meth = NULL;
1636 static jclass LDKErrorAction_SendErrorMessage_class = NULL;
1637 static jmethodID LDKErrorAction_SendErrorMessage_meth = NULL;
1638 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKErrorAction_init (JNIEnv *env, jclass clz) {
1639         LDKErrorAction_DisconnectPeer_class =
1640                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKErrorAction$DisconnectPeer;"));
1641         CHECK(LDKErrorAction_DisconnectPeer_class != NULL);
1642         LDKErrorAction_DisconnectPeer_meth = (*env)->GetMethodID(env, LDKErrorAction_DisconnectPeer_class, "<init>", "(J)V");
1643         CHECK(LDKErrorAction_DisconnectPeer_meth != NULL);
1644         LDKErrorAction_IgnoreError_class =
1645                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKErrorAction$IgnoreError;"));
1646         CHECK(LDKErrorAction_IgnoreError_class != NULL);
1647         LDKErrorAction_IgnoreError_meth = (*env)->GetMethodID(env, LDKErrorAction_IgnoreError_class, "<init>", "()V");
1648         CHECK(LDKErrorAction_IgnoreError_meth != NULL);
1649         LDKErrorAction_IgnoreAndLog_class =
1650                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKErrorAction$IgnoreAndLog;"));
1651         CHECK(LDKErrorAction_IgnoreAndLog_class != NULL);
1652         LDKErrorAction_IgnoreAndLog_meth = (*env)->GetMethodID(env, LDKErrorAction_IgnoreAndLog_class, "<init>", "(Lorg/ldk/enums/Level;)V");
1653         CHECK(LDKErrorAction_IgnoreAndLog_meth != NULL);
1654         LDKErrorAction_SendErrorMessage_class =
1655                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKErrorAction$SendErrorMessage;"));
1656         CHECK(LDKErrorAction_SendErrorMessage_class != NULL);
1657         LDKErrorAction_SendErrorMessage_meth = (*env)->GetMethodID(env, LDKErrorAction_SendErrorMessage_class, "<init>", "(J)V");
1658         CHECK(LDKErrorAction_SendErrorMessage_meth != NULL);
1659 }
1660 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKErrorAction_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1661         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
1662         switch(obj->tag) {
1663                 case LDKErrorAction_DisconnectPeer: {
1664                         LDKErrorMessage msg_var = obj->disconnect_peer.msg;
1665                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1666                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1667                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1668                         return (*env)->NewObject(env, LDKErrorAction_DisconnectPeer_class, LDKErrorAction_DisconnectPeer_meth, msg_ref);
1669                 }
1670                 case LDKErrorAction_IgnoreError: {
1671                         return (*env)->NewObject(env, LDKErrorAction_IgnoreError_class, LDKErrorAction_IgnoreError_meth);
1672                 }
1673                 case LDKErrorAction_IgnoreAndLog: {
1674                         jclass ignore_and_log_conv = LDKLevel_to_java(env, obj->ignore_and_log);
1675                         return (*env)->NewObject(env, LDKErrorAction_IgnoreAndLog_class, LDKErrorAction_IgnoreAndLog_meth, ignore_and_log_conv);
1676                 }
1677                 case LDKErrorAction_SendErrorMessage: {
1678                         LDKErrorMessage msg_var = obj->send_error_message.msg;
1679                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1680                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1681                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1682                         return (*env)->NewObject(env, LDKErrorAction_SendErrorMessage_class, LDKErrorAction_SendErrorMessage_meth, msg_ref);
1683                 }
1684                 default: abort();
1685         }
1686 }
1687 static jclass LDKMessageSendEvent_SendAcceptChannel_class = NULL;
1688 static jmethodID LDKMessageSendEvent_SendAcceptChannel_meth = NULL;
1689 static jclass LDKMessageSendEvent_SendOpenChannel_class = NULL;
1690 static jmethodID LDKMessageSendEvent_SendOpenChannel_meth = NULL;
1691 static jclass LDKMessageSendEvent_SendFundingCreated_class = NULL;
1692 static jmethodID LDKMessageSendEvent_SendFundingCreated_meth = NULL;
1693 static jclass LDKMessageSendEvent_SendFundingSigned_class = NULL;
1694 static jmethodID LDKMessageSendEvent_SendFundingSigned_meth = NULL;
1695 static jclass LDKMessageSendEvent_SendFundingLocked_class = NULL;
1696 static jmethodID LDKMessageSendEvent_SendFundingLocked_meth = NULL;
1697 static jclass LDKMessageSendEvent_SendAnnouncementSignatures_class = NULL;
1698 static jmethodID LDKMessageSendEvent_SendAnnouncementSignatures_meth = NULL;
1699 static jclass LDKMessageSendEvent_UpdateHTLCs_class = NULL;
1700 static jmethodID LDKMessageSendEvent_UpdateHTLCs_meth = NULL;
1701 static jclass LDKMessageSendEvent_SendRevokeAndACK_class = NULL;
1702 static jmethodID LDKMessageSendEvent_SendRevokeAndACK_meth = NULL;
1703 static jclass LDKMessageSendEvent_SendClosingSigned_class = NULL;
1704 static jmethodID LDKMessageSendEvent_SendClosingSigned_meth = NULL;
1705 static jclass LDKMessageSendEvent_SendShutdown_class = NULL;
1706 static jmethodID LDKMessageSendEvent_SendShutdown_meth = NULL;
1707 static jclass LDKMessageSendEvent_SendChannelReestablish_class = NULL;
1708 static jmethodID LDKMessageSendEvent_SendChannelReestablish_meth = NULL;
1709 static jclass LDKMessageSendEvent_BroadcastChannelAnnouncement_class = NULL;
1710 static jmethodID LDKMessageSendEvent_BroadcastChannelAnnouncement_meth = NULL;
1711 static jclass LDKMessageSendEvent_BroadcastNodeAnnouncement_class = NULL;
1712 static jmethodID LDKMessageSendEvent_BroadcastNodeAnnouncement_meth = NULL;
1713 static jclass LDKMessageSendEvent_BroadcastChannelUpdate_class = NULL;
1714 static jmethodID LDKMessageSendEvent_BroadcastChannelUpdate_meth = NULL;
1715 static jclass LDKMessageSendEvent_SendChannelUpdate_class = NULL;
1716 static jmethodID LDKMessageSendEvent_SendChannelUpdate_meth = NULL;
1717 static jclass LDKMessageSendEvent_HandleError_class = NULL;
1718 static jmethodID LDKMessageSendEvent_HandleError_meth = NULL;
1719 static jclass LDKMessageSendEvent_SendChannelRangeQuery_class = NULL;
1720 static jmethodID LDKMessageSendEvent_SendChannelRangeQuery_meth = NULL;
1721 static jclass LDKMessageSendEvent_SendShortIdsQuery_class = NULL;
1722 static jmethodID LDKMessageSendEvent_SendShortIdsQuery_meth = NULL;
1723 static jclass LDKMessageSendEvent_SendReplyChannelRange_class = NULL;
1724 static jmethodID LDKMessageSendEvent_SendReplyChannelRange_meth = NULL;
1725 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKMessageSendEvent_init (JNIEnv *env, jclass clz) {
1726         LDKMessageSendEvent_SendAcceptChannel_class =
1727                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendAcceptChannel;"));
1728         CHECK(LDKMessageSendEvent_SendAcceptChannel_class != NULL);
1729         LDKMessageSendEvent_SendAcceptChannel_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendAcceptChannel_class, "<init>", "([BJ)V");
1730         CHECK(LDKMessageSendEvent_SendAcceptChannel_meth != NULL);
1731         LDKMessageSendEvent_SendOpenChannel_class =
1732                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendOpenChannel;"));
1733         CHECK(LDKMessageSendEvent_SendOpenChannel_class != NULL);
1734         LDKMessageSendEvent_SendOpenChannel_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendOpenChannel_class, "<init>", "([BJ)V");
1735         CHECK(LDKMessageSendEvent_SendOpenChannel_meth != NULL);
1736         LDKMessageSendEvent_SendFundingCreated_class =
1737                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendFundingCreated;"));
1738         CHECK(LDKMessageSendEvent_SendFundingCreated_class != NULL);
1739         LDKMessageSendEvent_SendFundingCreated_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingCreated_class, "<init>", "([BJ)V");
1740         CHECK(LDKMessageSendEvent_SendFundingCreated_meth != NULL);
1741         LDKMessageSendEvent_SendFundingSigned_class =
1742                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendFundingSigned;"));
1743         CHECK(LDKMessageSendEvent_SendFundingSigned_class != NULL);
1744         LDKMessageSendEvent_SendFundingSigned_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingSigned_class, "<init>", "([BJ)V");
1745         CHECK(LDKMessageSendEvent_SendFundingSigned_meth != NULL);
1746         LDKMessageSendEvent_SendFundingLocked_class =
1747                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendFundingLocked;"));
1748         CHECK(LDKMessageSendEvent_SendFundingLocked_class != NULL);
1749         LDKMessageSendEvent_SendFundingLocked_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingLocked_class, "<init>", "([BJ)V");
1750         CHECK(LDKMessageSendEvent_SendFundingLocked_meth != NULL);
1751         LDKMessageSendEvent_SendAnnouncementSignatures_class =
1752                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendAnnouncementSignatures;"));
1753         CHECK(LDKMessageSendEvent_SendAnnouncementSignatures_class != NULL);
1754         LDKMessageSendEvent_SendAnnouncementSignatures_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendAnnouncementSignatures_class, "<init>", "([BJ)V");
1755         CHECK(LDKMessageSendEvent_SendAnnouncementSignatures_meth != NULL);
1756         LDKMessageSendEvent_UpdateHTLCs_class =
1757                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$UpdateHTLCs;"));
1758         CHECK(LDKMessageSendEvent_UpdateHTLCs_class != NULL);
1759         LDKMessageSendEvent_UpdateHTLCs_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_UpdateHTLCs_class, "<init>", "([BJ)V");
1760         CHECK(LDKMessageSendEvent_UpdateHTLCs_meth != NULL);
1761         LDKMessageSendEvent_SendRevokeAndACK_class =
1762                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendRevokeAndACK;"));
1763         CHECK(LDKMessageSendEvent_SendRevokeAndACK_class != NULL);
1764         LDKMessageSendEvent_SendRevokeAndACK_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendRevokeAndACK_class, "<init>", "([BJ)V");
1765         CHECK(LDKMessageSendEvent_SendRevokeAndACK_meth != NULL);
1766         LDKMessageSendEvent_SendClosingSigned_class =
1767                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendClosingSigned;"));
1768         CHECK(LDKMessageSendEvent_SendClosingSigned_class != NULL);
1769         LDKMessageSendEvent_SendClosingSigned_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendClosingSigned_class, "<init>", "([BJ)V");
1770         CHECK(LDKMessageSendEvent_SendClosingSigned_meth != NULL);
1771         LDKMessageSendEvent_SendShutdown_class =
1772                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendShutdown;"));
1773         CHECK(LDKMessageSendEvent_SendShutdown_class != NULL);
1774         LDKMessageSendEvent_SendShutdown_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendShutdown_class, "<init>", "([BJ)V");
1775         CHECK(LDKMessageSendEvent_SendShutdown_meth != NULL);
1776         LDKMessageSendEvent_SendChannelReestablish_class =
1777                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendChannelReestablish;"));
1778         CHECK(LDKMessageSendEvent_SendChannelReestablish_class != NULL);
1779         LDKMessageSendEvent_SendChannelReestablish_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelReestablish_class, "<init>", "([BJ)V");
1780         CHECK(LDKMessageSendEvent_SendChannelReestablish_meth != NULL);
1781         LDKMessageSendEvent_BroadcastChannelAnnouncement_class =
1782                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$BroadcastChannelAnnouncement;"));
1783         CHECK(LDKMessageSendEvent_BroadcastChannelAnnouncement_class != NULL);
1784         LDKMessageSendEvent_BroadcastChannelAnnouncement_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastChannelAnnouncement_class, "<init>", "(JJ)V");
1785         CHECK(LDKMessageSendEvent_BroadcastChannelAnnouncement_meth != NULL);
1786         LDKMessageSendEvent_BroadcastNodeAnnouncement_class =
1787                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$BroadcastNodeAnnouncement;"));
1788         CHECK(LDKMessageSendEvent_BroadcastNodeAnnouncement_class != NULL);
1789         LDKMessageSendEvent_BroadcastNodeAnnouncement_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastNodeAnnouncement_class, "<init>", "(J)V");
1790         CHECK(LDKMessageSendEvent_BroadcastNodeAnnouncement_meth != NULL);
1791         LDKMessageSendEvent_BroadcastChannelUpdate_class =
1792                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$BroadcastChannelUpdate;"));
1793         CHECK(LDKMessageSendEvent_BroadcastChannelUpdate_class != NULL);
1794         LDKMessageSendEvent_BroadcastChannelUpdate_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastChannelUpdate_class, "<init>", "(J)V");
1795         CHECK(LDKMessageSendEvent_BroadcastChannelUpdate_meth != NULL);
1796         LDKMessageSendEvent_SendChannelUpdate_class =
1797                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendChannelUpdate;"));
1798         CHECK(LDKMessageSendEvent_SendChannelUpdate_class != NULL);
1799         LDKMessageSendEvent_SendChannelUpdate_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelUpdate_class, "<init>", "([BJ)V");
1800         CHECK(LDKMessageSendEvent_SendChannelUpdate_meth != NULL);
1801         LDKMessageSendEvent_HandleError_class =
1802                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$HandleError;"));
1803         CHECK(LDKMessageSendEvent_HandleError_class != NULL);
1804         LDKMessageSendEvent_HandleError_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_HandleError_class, "<init>", "([BJ)V");
1805         CHECK(LDKMessageSendEvent_HandleError_meth != NULL);
1806         LDKMessageSendEvent_SendChannelRangeQuery_class =
1807                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendChannelRangeQuery;"));
1808         CHECK(LDKMessageSendEvent_SendChannelRangeQuery_class != NULL);
1809         LDKMessageSendEvent_SendChannelRangeQuery_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelRangeQuery_class, "<init>", "([BJ)V");
1810         CHECK(LDKMessageSendEvent_SendChannelRangeQuery_meth != NULL);
1811         LDKMessageSendEvent_SendShortIdsQuery_class =
1812                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendShortIdsQuery;"));
1813         CHECK(LDKMessageSendEvent_SendShortIdsQuery_class != NULL);
1814         LDKMessageSendEvent_SendShortIdsQuery_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendShortIdsQuery_class, "<init>", "([BJ)V");
1815         CHECK(LDKMessageSendEvent_SendShortIdsQuery_meth != NULL);
1816         LDKMessageSendEvent_SendReplyChannelRange_class =
1817                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendReplyChannelRange;"));
1818         CHECK(LDKMessageSendEvent_SendReplyChannelRange_class != NULL);
1819         LDKMessageSendEvent_SendReplyChannelRange_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendReplyChannelRange_class, "<init>", "([BJ)V");
1820         CHECK(LDKMessageSendEvent_SendReplyChannelRange_meth != NULL);
1821 }
1822 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1823         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
1824         switch(obj->tag) {
1825                 case LDKMessageSendEvent_SendAcceptChannel: {
1826                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1827                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_accept_channel.node_id.compressed_form);
1828                         LDKAcceptChannel msg_var = obj->send_accept_channel.msg;
1829                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1830                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1831                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1832                         return (*env)->NewObject(env, LDKMessageSendEvent_SendAcceptChannel_class, LDKMessageSendEvent_SendAcceptChannel_meth, node_id_arr, msg_ref);
1833                 }
1834                 case LDKMessageSendEvent_SendOpenChannel: {
1835                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1836                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_open_channel.node_id.compressed_form);
1837                         LDKOpenChannel msg_var = obj->send_open_channel.msg;
1838                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1839                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1840                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1841                         return (*env)->NewObject(env, LDKMessageSendEvent_SendOpenChannel_class, LDKMessageSendEvent_SendOpenChannel_meth, node_id_arr, msg_ref);
1842                 }
1843                 case LDKMessageSendEvent_SendFundingCreated: {
1844                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1845                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_created.node_id.compressed_form);
1846                         LDKFundingCreated msg_var = obj->send_funding_created.msg;
1847                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1848                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1849                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1850                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingCreated_class, LDKMessageSendEvent_SendFundingCreated_meth, node_id_arr, msg_ref);
1851                 }
1852                 case LDKMessageSendEvent_SendFundingSigned: {
1853                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1854                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_signed.node_id.compressed_form);
1855                         LDKFundingSigned msg_var = obj->send_funding_signed.msg;
1856                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1857                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1858                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1859                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingSigned_class, LDKMessageSendEvent_SendFundingSigned_meth, node_id_arr, msg_ref);
1860                 }
1861                 case LDKMessageSendEvent_SendFundingLocked: {
1862                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1863                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_locked.node_id.compressed_form);
1864                         LDKFundingLocked msg_var = obj->send_funding_locked.msg;
1865                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1866                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1867                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1868                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingLocked_class, LDKMessageSendEvent_SendFundingLocked_meth, node_id_arr, msg_ref);
1869                 }
1870                 case LDKMessageSendEvent_SendAnnouncementSignatures: {
1871                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1872                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_announcement_signatures.node_id.compressed_form);
1873                         LDKAnnouncementSignatures msg_var = obj->send_announcement_signatures.msg;
1874                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1875                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1876                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1877                         return (*env)->NewObject(env, LDKMessageSendEvent_SendAnnouncementSignatures_class, LDKMessageSendEvent_SendAnnouncementSignatures_meth, node_id_arr, msg_ref);
1878                 }
1879                 case LDKMessageSendEvent_UpdateHTLCs: {
1880                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1881                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->update_htl_cs.node_id.compressed_form);
1882                         LDKCommitmentUpdate updates_var = obj->update_htl_cs.updates;
1883                         CHECK((((uint64_t)updates_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1884                         CHECK((((uint64_t)&updates_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1885                         uint64_t updates_ref = (uint64_t)updates_var.inner & ~1;
1886                         return (*env)->NewObject(env, LDKMessageSendEvent_UpdateHTLCs_class, LDKMessageSendEvent_UpdateHTLCs_meth, node_id_arr, updates_ref);
1887                 }
1888                 case LDKMessageSendEvent_SendRevokeAndACK: {
1889                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1890                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_revoke_and_ack.node_id.compressed_form);
1891                         LDKRevokeAndACK msg_var = obj->send_revoke_and_ack.msg;
1892                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1893                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1894                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1895                         return (*env)->NewObject(env, LDKMessageSendEvent_SendRevokeAndACK_class, LDKMessageSendEvent_SendRevokeAndACK_meth, node_id_arr, msg_ref);
1896                 }
1897                 case LDKMessageSendEvent_SendClosingSigned: {
1898                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1899                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_closing_signed.node_id.compressed_form);
1900                         LDKClosingSigned msg_var = obj->send_closing_signed.msg;
1901                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1902                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1903                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1904                         return (*env)->NewObject(env, LDKMessageSendEvent_SendClosingSigned_class, LDKMessageSendEvent_SendClosingSigned_meth, node_id_arr, msg_ref);
1905                 }
1906                 case LDKMessageSendEvent_SendShutdown: {
1907                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1908                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_shutdown.node_id.compressed_form);
1909                         LDKShutdown msg_var = obj->send_shutdown.msg;
1910                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1911                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1912                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1913                         return (*env)->NewObject(env, LDKMessageSendEvent_SendShutdown_class, LDKMessageSendEvent_SendShutdown_meth, node_id_arr, msg_ref);
1914                 }
1915                 case LDKMessageSendEvent_SendChannelReestablish: {
1916                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1917                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_reestablish.node_id.compressed_form);
1918                         LDKChannelReestablish msg_var = obj->send_channel_reestablish.msg;
1919                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1920                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1921                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1922                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelReestablish_class, LDKMessageSendEvent_SendChannelReestablish_meth, node_id_arr, msg_ref);
1923                 }
1924                 case LDKMessageSendEvent_BroadcastChannelAnnouncement: {
1925                         LDKChannelAnnouncement msg_var = obj->broadcast_channel_announcement.msg;
1926                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1927                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1928                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1929                         LDKChannelUpdate update_msg_var = obj->broadcast_channel_announcement.update_msg;
1930                         CHECK((((uint64_t)update_msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1931                         CHECK((((uint64_t)&update_msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1932                         uint64_t update_msg_ref = (uint64_t)update_msg_var.inner & ~1;
1933                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastChannelAnnouncement_class, LDKMessageSendEvent_BroadcastChannelAnnouncement_meth, msg_ref, update_msg_ref);
1934                 }
1935                 case LDKMessageSendEvent_BroadcastNodeAnnouncement: {
1936                         LDKNodeAnnouncement msg_var = obj->broadcast_node_announcement.msg;
1937                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1938                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1939                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1940                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastNodeAnnouncement_class, LDKMessageSendEvent_BroadcastNodeAnnouncement_meth, msg_ref);
1941                 }
1942                 case LDKMessageSendEvent_BroadcastChannelUpdate: {
1943                         LDKChannelUpdate msg_var = obj->broadcast_channel_update.msg;
1944                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1945                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1946                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1947                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastChannelUpdate_class, LDKMessageSendEvent_BroadcastChannelUpdate_meth, msg_ref);
1948                 }
1949                 case LDKMessageSendEvent_SendChannelUpdate: {
1950                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1951                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_update.node_id.compressed_form);
1952                         LDKChannelUpdate msg_var = obj->send_channel_update.msg;
1953                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1954                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1955                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1956                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelUpdate_class, LDKMessageSendEvent_SendChannelUpdate_meth, node_id_arr, msg_ref);
1957                 }
1958                 case LDKMessageSendEvent_HandleError: {
1959                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1960                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->handle_error.node_id.compressed_form);
1961                         uint64_t action_ref = ((uint64_t)&obj->handle_error.action) | 1;
1962                         return (*env)->NewObject(env, LDKMessageSendEvent_HandleError_class, LDKMessageSendEvent_HandleError_meth, node_id_arr, action_ref);
1963                 }
1964                 case LDKMessageSendEvent_SendChannelRangeQuery: {
1965                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1966                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_range_query.node_id.compressed_form);
1967                         LDKQueryChannelRange msg_var = obj->send_channel_range_query.msg;
1968                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1969                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1970                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1971                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelRangeQuery_class, LDKMessageSendEvent_SendChannelRangeQuery_meth, node_id_arr, msg_ref);
1972                 }
1973                 case LDKMessageSendEvent_SendShortIdsQuery: {
1974                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1975                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_short_ids_query.node_id.compressed_form);
1976                         LDKQueryShortChannelIds msg_var = obj->send_short_ids_query.msg;
1977                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1978                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1979                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1980                         return (*env)->NewObject(env, LDKMessageSendEvent_SendShortIdsQuery_class, LDKMessageSendEvent_SendShortIdsQuery_meth, node_id_arr, msg_ref);
1981                 }
1982                 case LDKMessageSendEvent_SendReplyChannelRange: {
1983                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1984                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_reply_channel_range.node_id.compressed_form);
1985                         LDKReplyChannelRange msg_var = obj->send_reply_channel_range.msg;
1986                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1987                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1988                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1989                         return (*env)->NewObject(env, LDKMessageSendEvent_SendReplyChannelRange_class, LDKMessageSendEvent_SendReplyChannelRange_meth, node_id_arr, msg_ref);
1990                 }
1991                 default: abort();
1992         }
1993 }
1994 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1MessageSendEventZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1995         LDKCVec_MessageSendEventZ *ret = MALLOC(sizeof(LDKCVec_MessageSendEventZ), "LDKCVec_MessageSendEventZ");
1996         ret->datalen = (*env)->GetArrayLength(env, elems);
1997         if (ret->datalen == 0) {
1998                 ret->data = NULL;
1999         } else {
2000                 ret->data = MALLOC(sizeof(LDKMessageSendEvent) * ret->datalen, "LDKCVec_MessageSendEventZ Data");
2001                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
2002                 for (size_t i = 0; i < ret->datalen; i++) {
2003                         int64_t arr_elem = java_elems[i];
2004                         LDKMessageSendEvent arr_elem_conv = *(LDKMessageSendEvent*)(((uint64_t)arr_elem) & ~1);
2005                         arr_elem_conv = MessageSendEvent_clone((LDKMessageSendEvent*)(((uint64_t)arr_elem) & ~1));
2006                         ret->data[i] = arr_elem_conv;
2007                 }
2008                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
2009         }
2010         return (uint64_t)ret;
2011 }
2012 static inline LDKCVec_MessageSendEventZ CVec_MessageSendEventZ_clone(const LDKCVec_MessageSendEventZ *orig) {
2013         LDKCVec_MessageSendEventZ ret = { .data = MALLOC(sizeof(LDKMessageSendEvent) * orig->datalen, "LDKCVec_MessageSendEventZ clone bytes"), .datalen = orig->datalen };
2014         for (size_t i = 0; i < ret.datalen; i++) {
2015                 ret.data[i] = MessageSendEvent_clone(&orig->data[i]);
2016         }
2017         return ret;
2018 }
2019 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitFeaturesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2020         return ((LDKCResult_InitFeaturesDecodeErrorZ*)arg)->result_ok;
2021 }
2022 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2023         LDKCResult_InitFeaturesDecodeErrorZ *val = (LDKCResult_InitFeaturesDecodeErrorZ*)(arg & ~1);
2024         CHECK(val->result_ok);
2025         LDKInitFeatures res_var = (*val->contents.result);
2026         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2027         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2028         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
2029         return res_ref;
2030 }
2031 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2032         LDKCResult_InitFeaturesDecodeErrorZ *val = (LDKCResult_InitFeaturesDecodeErrorZ*)(arg & ~1);
2033         CHECK(!val->result_ok);
2034         LDKDecodeError err_var = (*val->contents.err);
2035         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2036         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2037         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
2038         return err_ref;
2039 }
2040 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeFeaturesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2041         return ((LDKCResult_NodeFeaturesDecodeErrorZ*)arg)->result_ok;
2042 }
2043 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2044         LDKCResult_NodeFeaturesDecodeErrorZ *val = (LDKCResult_NodeFeaturesDecodeErrorZ*)(arg & ~1);
2045         CHECK(val->result_ok);
2046         LDKNodeFeatures res_var = (*val->contents.result);
2047         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2048         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2049         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
2050         return res_ref;
2051 }
2052 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2053         LDKCResult_NodeFeaturesDecodeErrorZ *val = (LDKCResult_NodeFeaturesDecodeErrorZ*)(arg & ~1);
2054         CHECK(!val->result_ok);
2055         LDKDecodeError err_var = (*val->contents.err);
2056         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2057         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2058         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
2059         return err_ref;
2060 }
2061 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelFeaturesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2062         return ((LDKCResult_ChannelFeaturesDecodeErrorZ*)arg)->result_ok;
2063 }
2064 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2065         LDKCResult_ChannelFeaturesDecodeErrorZ *val = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(arg & ~1);
2066         CHECK(val->result_ok);
2067         LDKChannelFeatures res_var = (*val->contents.result);
2068         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2069         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2070         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
2071         return res_ref;
2072 }
2073 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2074         LDKCResult_ChannelFeaturesDecodeErrorZ *val = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(arg & ~1);
2075         CHECK(!val->result_ok);
2076         LDKDecodeError err_var = (*val->contents.err);
2077         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2078         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2079         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
2080         return err_ref;
2081 }
2082 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceFeaturesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2083         return ((LDKCResult_InvoiceFeaturesDecodeErrorZ*)arg)->result_ok;
2084 }
2085 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2086         LDKCResult_InvoiceFeaturesDecodeErrorZ *val = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(arg & ~1);
2087         CHECK(val->result_ok);
2088         LDKInvoiceFeatures res_var = (*val->contents.result);
2089         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2090         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2091         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
2092         return res_ref;
2093 }
2094 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2095         LDKCResult_InvoiceFeaturesDecodeErrorZ *val = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(arg & ~1);
2096         CHECK(!val->result_ok);
2097         LDKDecodeError err_var = (*val->contents.err);
2098         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2099         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2100         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
2101         return err_ref;
2102 }
2103 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2104         return ((LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)arg)->result_ok;
2105 }
2106 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2107         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
2108         CHECK(val->result_ok);
2109         LDKDelayedPaymentOutputDescriptor res_var = (*val->contents.result);
2110         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2111         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2112         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
2113         return res_ref;
2114 }
2115 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2116         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
2117         CHECK(!val->result_ok);
2118         LDKDecodeError err_var = (*val->contents.err);
2119         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2120         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2121         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
2122         return err_ref;
2123 }
2124 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2125         return ((LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)arg)->result_ok;
2126 }
2127 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2128         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
2129         CHECK(val->result_ok);
2130         LDKStaticPaymentOutputDescriptor res_var = (*val->contents.result);
2131         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2132         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2133         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
2134         return res_ref;
2135 }
2136 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2137         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
2138         CHECK(!val->result_ok);
2139         LDKDecodeError err_var = (*val->contents.err);
2140         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2141         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2142         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
2143         return err_ref;
2144 }
2145 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SpendableOutputDescriptorDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2146         return ((LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)arg)->result_ok;
2147 }
2148 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SpendableOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2149         LDKCResult_SpendableOutputDescriptorDecodeErrorZ *val = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(arg & ~1);
2150         CHECK(val->result_ok);
2151         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
2152         return res_ref;
2153 }
2154 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SpendableOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2155         LDKCResult_SpendableOutputDescriptorDecodeErrorZ *val = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(arg & ~1);
2156         CHECK(!val->result_ok);
2157         LDKDecodeError err_var = (*val->contents.err);
2158         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2159         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2160         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
2161         return err_ref;
2162 }
2163 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2164         return ((LDKCResult_NoneNoneZ*)arg)->result_ok;
2165 }
2166 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2167         LDKCResult_NoneNoneZ *val = (LDKCResult_NoneNoneZ*)(arg & ~1);
2168         CHECK(val->result_ok);
2169         return *val->contents.result;
2170 }
2171 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2172         LDKCResult_NoneNoneZ *val = (LDKCResult_NoneNoneZ*)(arg & ~1);
2173         CHECK(!val->result_ok);
2174         return *val->contents.err;
2175 }
2176 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1SignatureCVec_1SignatureZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, jobjectArray b) {
2177         LDKC2Tuple_SignatureCVec_SignatureZZ* ret = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
2178         LDKSignature a_ref;
2179         CHECK((*env)->GetArrayLength(env, a) == 64);
2180         (*env)->GetByteArrayRegion(env, a, 0, 64, a_ref.compact_form);
2181         ret->a = a_ref;
2182         LDKCVec_SignatureZ b_constr;
2183         b_constr.datalen = (*env)->GetArrayLength(env, b);
2184         if (b_constr.datalen > 0)
2185                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
2186         else
2187                 b_constr.data = NULL;
2188         for (size_t i = 0; i < b_constr.datalen; i++) {
2189                 int8_tArray b_conv_8 = (*env)->GetObjectArrayElement(env, b, i);
2190                 LDKSignature b_conv_8_ref;
2191                 CHECK((*env)->GetArrayLength(env, b_conv_8) == 64);
2192                 (*env)->GetByteArrayRegion(env, b_conv_8, 0, 64, b_conv_8_ref.compact_form);
2193                 b_constr.data[i] = b_conv_8_ref;
2194         }
2195         ret->b = b_constr;
2196         return (uint64_t)ret;
2197 }
2198 static inline struct LDKSignature C2Tuple_SignatureCVec_SignatureZZ_get_a(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR tuple){
2199         return tuple->a;
2200 }
2201 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1get_1a(JNIEnv *env, jclass clz, int64_t tuple) {
2202         LDKC2Tuple_SignatureCVec_SignatureZZ* tuple_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(tuple & ~1);
2203         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
2204         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, C2Tuple_SignatureCVec_SignatureZZ_get_a(tuple_conv).compact_form);
2205         return ret_arr;
2206 }
2207
2208 static inline struct LDKCVec_SignatureZ C2Tuple_SignatureCVec_SignatureZZ_get_b(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR tuple){
2209         return tuple->b;
2210 }
2211 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1get_1b(JNIEnv *env, jclass clz, int64_t tuple) {
2212         LDKC2Tuple_SignatureCVec_SignatureZZ* tuple_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(tuple & ~1);
2213         LDKCVec_SignatureZ ret_var = C2Tuple_SignatureCVec_SignatureZZ_get_b(tuple_conv);
2214         jobjectArray ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
2215         ;
2216         for (size_t i = 0; i < ret_var.datalen; i++) {
2217                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 64);
2218                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 64, ret_var.data[i].compact_form);
2219                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
2220         }
2221         FREE(ret_var.data);
2222         return ret_arr;
2223 }
2224
2225 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2226         return ((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)arg)->result_ok;
2227 }
2228 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2229         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *val = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(arg & ~1);
2230         CHECK(val->result_ok);
2231         LDKC2Tuple_SignatureCVec_SignatureZZ* res_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
2232         *res_conv = (*val->contents.result);
2233         *res_conv = C2Tuple_SignatureCVec_SignatureZZ_clone(res_conv);
2234         return ((uint64_t)res_conv);
2235 }
2236 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2237         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *val = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(arg & ~1);
2238         CHECK(!val->result_ok);
2239         return *val->contents.err;
2240 }
2241 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignatureNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2242         return ((LDKCResult_SignatureNoneZ*)arg)->result_ok;
2243 }
2244 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignatureNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2245         LDKCResult_SignatureNoneZ *val = (LDKCResult_SignatureNoneZ*)(arg & ~1);
2246         CHECK(val->result_ok);
2247         int8_tArray res_arr = (*env)->NewByteArray(env, 64);
2248         (*env)->SetByteArrayRegion(env, res_arr, 0, 64, (*val->contents.result).compact_form);
2249         return res_arr;
2250 }
2251 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignatureNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2252         LDKCResult_SignatureNoneZ *val = (LDKCResult_SignatureNoneZ*)(arg & ~1);
2253         CHECK(!val->result_ok);
2254         return *val->contents.err;
2255 }
2256 typedef struct LDKBaseSign_JCalls {
2257         atomic_size_t refcnt;
2258         JavaVM *vm;
2259         jweak o;
2260         jmethodID get_per_commitment_point_meth;
2261         jmethodID release_commitment_secret_meth;
2262         jmethodID validate_holder_commitment_meth;
2263         jmethodID channel_keys_id_meth;
2264         jmethodID sign_counterparty_commitment_meth;
2265         jmethodID validate_counterparty_revocation_meth;
2266         jmethodID sign_holder_commitment_and_htlcs_meth;
2267         jmethodID sign_justice_revoked_output_meth;
2268         jmethodID sign_justice_revoked_htlc_meth;
2269         jmethodID sign_counterparty_htlc_transaction_meth;
2270         jmethodID sign_closing_transaction_meth;
2271         jmethodID sign_channel_announcement_meth;
2272         jmethodID ready_channel_meth;
2273 } LDKBaseSign_JCalls;
2274 static void LDKBaseSign_JCalls_free(void* this_arg) {
2275         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2276         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2277                 JNIEnv *env;
2278                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2279                 if (get_jenv_res == JNI_EDETACHED) {
2280                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2281                 } else {
2282                         DO_ASSERT(get_jenv_res == JNI_OK);
2283                 }
2284                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
2285                 if (get_jenv_res == JNI_EDETACHED) {
2286                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2287                 }
2288                 FREE(j_calls);
2289         }
2290 }
2291 LDKPublicKey get_per_commitment_point_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
2292         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2293         JNIEnv *env;
2294         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2295         if (get_jenv_res == JNI_EDETACHED) {
2296                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2297         } else {
2298                 DO_ASSERT(get_jenv_res == JNI_OK);
2299         }
2300         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2301         CHECK(obj != NULL);
2302         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_per_commitment_point_meth, idx);
2303         if ((*env)->ExceptionCheck(env)) {
2304                 (*env)->ExceptionDescribe(env);
2305                 (*env)->FatalError(env, "A call to get_per_commitment_point in LDKBaseSign from rust threw an exception.");
2306         }
2307         LDKPublicKey ret_ref;
2308         CHECK((*env)->GetArrayLength(env, ret) == 33);
2309         (*env)->GetByteArrayRegion(env, ret, 0, 33, ret_ref.compressed_form);
2310         if (get_jenv_res == JNI_EDETACHED) {
2311                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2312         }
2313         return ret_ref;
2314 }
2315 LDKThirtyTwoBytes release_commitment_secret_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
2316         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2317         JNIEnv *env;
2318         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2319         if (get_jenv_res == JNI_EDETACHED) {
2320                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2321         } else {
2322                 DO_ASSERT(get_jenv_res == JNI_OK);
2323         }
2324         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2325         CHECK(obj != NULL);
2326         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->release_commitment_secret_meth, idx);
2327         if ((*env)->ExceptionCheck(env)) {
2328                 (*env)->ExceptionDescribe(env);
2329                 (*env)->FatalError(env, "A call to release_commitment_secret in LDKBaseSign from rust threw an exception.");
2330         }
2331         LDKThirtyTwoBytes ret_ref;
2332         CHECK((*env)->GetArrayLength(env, ret) == 32);
2333         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
2334         if (get_jenv_res == JNI_EDETACHED) {
2335                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2336         }
2337         return ret_ref;
2338 }
2339 LDKCResult_NoneNoneZ validate_holder_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * holder_tx) {
2340         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2341         JNIEnv *env;
2342         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2343         if (get_jenv_res == JNI_EDETACHED) {
2344                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2345         } else {
2346                 DO_ASSERT(get_jenv_res == JNI_OK);
2347         }
2348         LDKHolderCommitmentTransaction holder_tx_var = *holder_tx;
2349         holder_tx_var = HolderCommitmentTransaction_clone(holder_tx);
2350         CHECK((((uint64_t)holder_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2351         CHECK((((uint64_t)&holder_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2352         uint64_t holder_tx_ref = (uint64_t)holder_tx_var.inner;
2353         if (holder_tx_var.is_owned) {
2354                 holder_tx_ref |= 1;
2355         }
2356         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2357         CHECK(obj != NULL);
2358         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->validate_holder_commitment_meth, holder_tx_ref);
2359         if ((*env)->ExceptionCheck(env)) {
2360                 (*env)->ExceptionDescribe(env);
2361                 (*env)->FatalError(env, "A call to validate_holder_commitment in LDKBaseSign from rust threw an exception.");
2362         }
2363         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(((uint64_t)ret) & ~1);
2364         ret_conv = CResult_NoneNoneZ_clone((LDKCResult_NoneNoneZ*)(((uint64_t)ret) & ~1));
2365         if (get_jenv_res == JNI_EDETACHED) {
2366                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2367         }
2368         return ret_conv;
2369 }
2370 LDKThirtyTwoBytes channel_keys_id_LDKBaseSign_jcall(const void* this_arg) {
2371         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2372         JNIEnv *env;
2373         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2374         if (get_jenv_res == JNI_EDETACHED) {
2375                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2376         } else {
2377                 DO_ASSERT(get_jenv_res == JNI_OK);
2378         }
2379         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2380         CHECK(obj != NULL);
2381         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->channel_keys_id_meth);
2382         if ((*env)->ExceptionCheck(env)) {
2383                 (*env)->ExceptionDescribe(env);
2384                 (*env)->FatalError(env, "A call to channel_keys_id in LDKBaseSign from rust threw an exception.");
2385         }
2386         LDKThirtyTwoBytes ret_ref;
2387         CHECK((*env)->GetArrayLength(env, ret) == 32);
2388         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
2389         if (get_jenv_res == JNI_EDETACHED) {
2390                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2391         }
2392         return ret_ref;
2393 }
2394 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKCommitmentTransaction * commitment_tx) {
2395         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2396         JNIEnv *env;
2397         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2398         if (get_jenv_res == JNI_EDETACHED) {
2399                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2400         } else {
2401                 DO_ASSERT(get_jenv_res == JNI_OK);
2402         }
2403         LDKCommitmentTransaction commitment_tx_var = *commitment_tx;
2404         commitment_tx_var = CommitmentTransaction_clone(commitment_tx);
2405         CHECK((((uint64_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2406         CHECK((((uint64_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2407         uint64_t commitment_tx_ref = (uint64_t)commitment_tx_var.inner;
2408         if (commitment_tx_var.is_owned) {
2409                 commitment_tx_ref |= 1;
2410         }
2411         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2412         CHECK(obj != NULL);
2413         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_counterparty_commitment_meth, commitment_tx_ref);
2414         if ((*env)->ExceptionCheck(env)) {
2415                 (*env)->ExceptionDescribe(env);
2416                 (*env)->FatalError(env, "A call to sign_counterparty_commitment in LDKBaseSign from rust threw an exception.");
2417         }
2418         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1);
2419         ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1));
2420         if (get_jenv_res == JNI_EDETACHED) {
2421                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2422         }
2423         return ret_conv;
2424 }
2425 LDKCResult_NoneNoneZ validate_counterparty_revocation_LDKBaseSign_jcall(const void* this_arg, uint64_t idx, const uint8_t (* secret)[32]) {
2426         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2427         JNIEnv *env;
2428         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2429         if (get_jenv_res == JNI_EDETACHED) {
2430                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2431         } else {
2432                 DO_ASSERT(get_jenv_res == JNI_OK);
2433         }
2434         int8_tArray secret_arr = (*env)->NewByteArray(env, 32);
2435         (*env)->SetByteArrayRegion(env, secret_arr, 0, 32, *secret);
2436         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2437         CHECK(obj != NULL);
2438         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->validate_counterparty_revocation_meth, idx, secret_arr);
2439         if ((*env)->ExceptionCheck(env)) {
2440                 (*env)->ExceptionDescribe(env);
2441                 (*env)->FatalError(env, "A call to validate_counterparty_revocation in LDKBaseSign from rust threw an exception.");
2442         }
2443         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(((uint64_t)ret) & ~1);
2444         ret_conv = CResult_NoneNoneZ_clone((LDKCResult_NoneNoneZ*)(((uint64_t)ret) & ~1));
2445         if (get_jenv_res == JNI_EDETACHED) {
2446                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2447         }
2448         return ret_conv;
2449 }
2450 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_holder_commitment_and_htlcs_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * commitment_tx) {
2451         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2452         JNIEnv *env;
2453         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2454         if (get_jenv_res == JNI_EDETACHED) {
2455                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2456         } else {
2457                 DO_ASSERT(get_jenv_res == JNI_OK);
2458         }
2459         LDKHolderCommitmentTransaction commitment_tx_var = *commitment_tx;
2460         commitment_tx_var = HolderCommitmentTransaction_clone(commitment_tx);
2461         CHECK((((uint64_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2462         CHECK((((uint64_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2463         uint64_t commitment_tx_ref = (uint64_t)commitment_tx_var.inner;
2464         if (commitment_tx_var.is_owned) {
2465                 commitment_tx_ref |= 1;
2466         }
2467         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2468         CHECK(obj != NULL);
2469         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_holder_commitment_and_htlcs_meth, commitment_tx_ref);
2470         if ((*env)->ExceptionCheck(env)) {
2471                 (*env)->ExceptionDescribe(env);
2472                 (*env)->FatalError(env, "A call to sign_holder_commitment_and_htlcs in LDKBaseSign from rust threw an exception.");
2473         }
2474         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1);
2475         ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1));
2476         if (get_jenv_res == JNI_EDETACHED) {
2477                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2478         }
2479         return ret_conv;
2480 }
2481 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]) {
2482         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2483         JNIEnv *env;
2484         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2485         if (get_jenv_res == JNI_EDETACHED) {
2486                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2487         } else {
2488                 DO_ASSERT(get_jenv_res == JNI_OK);
2489         }
2490         LDKTransaction justice_tx_var = justice_tx;
2491         int8_tArray justice_tx_arr = (*env)->NewByteArray(env, justice_tx_var.datalen);
2492         (*env)->SetByteArrayRegion(env, justice_tx_arr, 0, justice_tx_var.datalen, justice_tx_var.data);
2493         Transaction_free(justice_tx_var);
2494         int8_tArray per_commitment_key_arr = (*env)->NewByteArray(env, 32);
2495         (*env)->SetByteArrayRegion(env, per_commitment_key_arr, 0, 32, *per_commitment_key);
2496         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2497         CHECK(obj != NULL);
2498         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_justice_revoked_output_meth, justice_tx_arr, input, amount, per_commitment_key_arr);
2499         if ((*env)->ExceptionCheck(env)) {
2500                 (*env)->ExceptionDescribe(env);
2501                 (*env)->FatalError(env, "A call to sign_justice_revoked_output in LDKBaseSign from rust threw an exception.");
2502         }
2503         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
2504         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
2505         if (get_jenv_res == JNI_EDETACHED) {
2506                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2507         }
2508         return ret_conv;
2509 }
2510 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) {
2511         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2512         JNIEnv *env;
2513         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2514         if (get_jenv_res == JNI_EDETACHED) {
2515                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2516         } else {
2517                 DO_ASSERT(get_jenv_res == JNI_OK);
2518         }
2519         LDKTransaction justice_tx_var = justice_tx;
2520         int8_tArray justice_tx_arr = (*env)->NewByteArray(env, justice_tx_var.datalen);
2521         (*env)->SetByteArrayRegion(env, justice_tx_arr, 0, justice_tx_var.datalen, justice_tx_var.data);
2522         Transaction_free(justice_tx_var);
2523         int8_tArray per_commitment_key_arr = (*env)->NewByteArray(env, 32);
2524         (*env)->SetByteArrayRegion(env, per_commitment_key_arr, 0, 32, *per_commitment_key);
2525         LDKHTLCOutputInCommitment htlc_var = *htlc;
2526         htlc_var = HTLCOutputInCommitment_clone(htlc);
2527         CHECK((((uint64_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2528         CHECK((((uint64_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2529         uint64_t htlc_ref = (uint64_t)htlc_var.inner;
2530         if (htlc_var.is_owned) {
2531                 htlc_ref |= 1;
2532         }
2533         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2534         CHECK(obj != NULL);
2535         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_justice_revoked_htlc_meth, justice_tx_arr, input, amount, per_commitment_key_arr, htlc_ref);
2536         if ((*env)->ExceptionCheck(env)) {
2537                 (*env)->ExceptionDescribe(env);
2538                 (*env)->FatalError(env, "A call to sign_justice_revoked_htlc in LDKBaseSign from rust threw an exception.");
2539         }
2540         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
2541         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
2542         if (get_jenv_res == JNI_EDETACHED) {
2543                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2544         }
2545         return ret_conv;
2546 }
2547 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) {
2548         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2549         JNIEnv *env;
2550         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2551         if (get_jenv_res == JNI_EDETACHED) {
2552                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2553         } else {
2554                 DO_ASSERT(get_jenv_res == JNI_OK);
2555         }
2556         LDKTransaction htlc_tx_var = htlc_tx;
2557         int8_tArray htlc_tx_arr = (*env)->NewByteArray(env, htlc_tx_var.datalen);
2558         (*env)->SetByteArrayRegion(env, htlc_tx_arr, 0, htlc_tx_var.datalen, htlc_tx_var.data);
2559         Transaction_free(htlc_tx_var);
2560         int8_tArray per_commitment_point_arr = (*env)->NewByteArray(env, 33);
2561         (*env)->SetByteArrayRegion(env, per_commitment_point_arr, 0, 33, per_commitment_point.compressed_form);
2562         LDKHTLCOutputInCommitment htlc_var = *htlc;
2563         htlc_var = HTLCOutputInCommitment_clone(htlc);
2564         CHECK((((uint64_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2565         CHECK((((uint64_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2566         uint64_t htlc_ref = (uint64_t)htlc_var.inner;
2567         if (htlc_var.is_owned) {
2568                 htlc_ref |= 1;
2569         }
2570         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2571         CHECK(obj != NULL);
2572         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_counterparty_htlc_transaction_meth, htlc_tx_arr, input, amount, per_commitment_point_arr, htlc_ref);
2573         if ((*env)->ExceptionCheck(env)) {
2574                 (*env)->ExceptionDescribe(env);
2575                 (*env)->FatalError(env, "A call to sign_counterparty_htlc_transaction in LDKBaseSign from rust threw an exception.");
2576         }
2577         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
2578         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
2579         if (get_jenv_res == JNI_EDETACHED) {
2580                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2581         }
2582         return ret_conv;
2583 }
2584 LDKCResult_SignatureNoneZ sign_closing_transaction_LDKBaseSign_jcall(const void* this_arg, const LDKClosingTransaction * closing_tx) {
2585         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2586         JNIEnv *env;
2587         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2588         if (get_jenv_res == JNI_EDETACHED) {
2589                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2590         } else {
2591                 DO_ASSERT(get_jenv_res == JNI_OK);
2592         }
2593         LDKClosingTransaction closing_tx_var = *closing_tx;
2594         // Warning: we may need a move here but no clone is available for LDKClosingTransaction
2595         CHECK((((uint64_t)closing_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2596         CHECK((((uint64_t)&closing_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2597         uint64_t closing_tx_ref = (uint64_t)closing_tx_var.inner;
2598         if (closing_tx_var.is_owned) {
2599                 closing_tx_ref |= 1;
2600         }
2601         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2602         CHECK(obj != NULL);
2603         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_closing_transaction_meth, closing_tx_ref);
2604         if ((*env)->ExceptionCheck(env)) {
2605                 (*env)->ExceptionDescribe(env);
2606                 (*env)->FatalError(env, "A call to sign_closing_transaction in LDKBaseSign from rust threw an exception.");
2607         }
2608         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
2609         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
2610         if (get_jenv_res == JNI_EDETACHED) {
2611                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2612         }
2613         return ret_conv;
2614 }
2615 LDKCResult_SignatureNoneZ sign_channel_announcement_LDKBaseSign_jcall(const void* this_arg, const LDKUnsignedChannelAnnouncement * msg) {
2616         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2617         JNIEnv *env;
2618         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2619         if (get_jenv_res == JNI_EDETACHED) {
2620                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2621         } else {
2622                 DO_ASSERT(get_jenv_res == JNI_OK);
2623         }
2624         LDKUnsignedChannelAnnouncement msg_var = *msg;
2625         msg_var = UnsignedChannelAnnouncement_clone(msg);
2626         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2627         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2628         uint64_t msg_ref = (uint64_t)msg_var.inner;
2629         if (msg_var.is_owned) {
2630                 msg_ref |= 1;
2631         }
2632         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2633         CHECK(obj != NULL);
2634         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_channel_announcement_meth, msg_ref);
2635         if ((*env)->ExceptionCheck(env)) {
2636                 (*env)->ExceptionDescribe(env);
2637                 (*env)->FatalError(env, "A call to sign_channel_announcement in LDKBaseSign from rust threw an exception.");
2638         }
2639         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
2640         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
2641         if (get_jenv_res == JNI_EDETACHED) {
2642                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2643         }
2644         return ret_conv;
2645 }
2646 void ready_channel_LDKBaseSign_jcall(void* this_arg, const LDKChannelTransactionParameters * channel_parameters) {
2647         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2648         JNIEnv *env;
2649         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2650         if (get_jenv_res == JNI_EDETACHED) {
2651                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2652         } else {
2653                 DO_ASSERT(get_jenv_res == JNI_OK);
2654         }
2655         LDKChannelTransactionParameters channel_parameters_var = *channel_parameters;
2656         channel_parameters_var = ChannelTransactionParameters_clone(channel_parameters);
2657         CHECK((((uint64_t)channel_parameters_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2658         CHECK((((uint64_t)&channel_parameters_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2659         uint64_t channel_parameters_ref = (uint64_t)channel_parameters_var.inner;
2660         if (channel_parameters_var.is_owned) {
2661                 channel_parameters_ref |= 1;
2662         }
2663         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2664         CHECK(obj != NULL);
2665         (*env)->CallVoidMethod(env, obj, j_calls->ready_channel_meth, channel_parameters_ref);
2666         if ((*env)->ExceptionCheck(env)) {
2667                 (*env)->ExceptionDescribe(env);
2668                 (*env)->FatalError(env, "A call to ready_channel in LDKBaseSign from rust threw an exception.");
2669         }
2670         if (get_jenv_res == JNI_EDETACHED) {
2671                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2672         }
2673 }
2674 static inline LDKBaseSign LDKBaseSign_init (JNIEnv *env, jclass clz, jobject o, int64_t pubkeys) {
2675         jclass c = (*env)->GetObjectClass(env, o);
2676         CHECK(c != NULL);
2677         LDKBaseSign_JCalls *calls = MALLOC(sizeof(LDKBaseSign_JCalls), "LDKBaseSign_JCalls");
2678         atomic_init(&calls->refcnt, 1);
2679         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
2680         calls->o = (*env)->NewWeakGlobalRef(env, o);
2681         calls->get_per_commitment_point_meth = (*env)->GetMethodID(env, c, "get_per_commitment_point", "(J)[B");
2682         CHECK(calls->get_per_commitment_point_meth != NULL);
2683         calls->release_commitment_secret_meth = (*env)->GetMethodID(env, c, "release_commitment_secret", "(J)[B");
2684         CHECK(calls->release_commitment_secret_meth != NULL);
2685         calls->validate_holder_commitment_meth = (*env)->GetMethodID(env, c, "validate_holder_commitment", "(J)J");
2686         CHECK(calls->validate_holder_commitment_meth != NULL);
2687         calls->channel_keys_id_meth = (*env)->GetMethodID(env, c, "channel_keys_id", "()[B");
2688         CHECK(calls->channel_keys_id_meth != NULL);
2689         calls->sign_counterparty_commitment_meth = (*env)->GetMethodID(env, c, "sign_counterparty_commitment", "(J)J");
2690         CHECK(calls->sign_counterparty_commitment_meth != NULL);
2691         calls->validate_counterparty_revocation_meth = (*env)->GetMethodID(env, c, "validate_counterparty_revocation", "(J[B)J");
2692         CHECK(calls->validate_counterparty_revocation_meth != NULL);
2693         calls->sign_holder_commitment_and_htlcs_meth = (*env)->GetMethodID(env, c, "sign_holder_commitment_and_htlcs", "(J)J");
2694         CHECK(calls->sign_holder_commitment_and_htlcs_meth != NULL);
2695         calls->sign_justice_revoked_output_meth = (*env)->GetMethodID(env, c, "sign_justice_revoked_output", "([BJJ[B)J");
2696         CHECK(calls->sign_justice_revoked_output_meth != NULL);
2697         calls->sign_justice_revoked_htlc_meth = (*env)->GetMethodID(env, c, "sign_justice_revoked_htlc", "([BJJ[BJ)J");
2698         CHECK(calls->sign_justice_revoked_htlc_meth != NULL);
2699         calls->sign_counterparty_htlc_transaction_meth = (*env)->GetMethodID(env, c, "sign_counterparty_htlc_transaction", "([BJJ[BJ)J");
2700         CHECK(calls->sign_counterparty_htlc_transaction_meth != NULL);
2701         calls->sign_closing_transaction_meth = (*env)->GetMethodID(env, c, "sign_closing_transaction", "(J)J");
2702         CHECK(calls->sign_closing_transaction_meth != NULL);
2703         calls->sign_channel_announcement_meth = (*env)->GetMethodID(env, c, "sign_channel_announcement", "(J)J");
2704         CHECK(calls->sign_channel_announcement_meth != NULL);
2705         calls->ready_channel_meth = (*env)->GetMethodID(env, c, "ready_channel", "(J)V");
2706         CHECK(calls->ready_channel_meth != NULL);
2707
2708         LDKChannelPublicKeys pubkeys_conv;
2709         pubkeys_conv.inner = (void*)(pubkeys & (~1));
2710         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
2711         pubkeys_conv = ChannelPublicKeys_clone(&pubkeys_conv);
2712
2713         LDKBaseSign ret = {
2714                 .this_arg = (void*) calls,
2715                 .get_per_commitment_point = get_per_commitment_point_LDKBaseSign_jcall,
2716                 .release_commitment_secret = release_commitment_secret_LDKBaseSign_jcall,
2717                 .validate_holder_commitment = validate_holder_commitment_LDKBaseSign_jcall,
2718                 .channel_keys_id = channel_keys_id_LDKBaseSign_jcall,
2719                 .sign_counterparty_commitment = sign_counterparty_commitment_LDKBaseSign_jcall,
2720                 .validate_counterparty_revocation = validate_counterparty_revocation_LDKBaseSign_jcall,
2721                 .sign_holder_commitment_and_htlcs = sign_holder_commitment_and_htlcs_LDKBaseSign_jcall,
2722                 .sign_justice_revoked_output = sign_justice_revoked_output_LDKBaseSign_jcall,
2723                 .sign_justice_revoked_htlc = sign_justice_revoked_htlc_LDKBaseSign_jcall,
2724                 .sign_counterparty_htlc_transaction = sign_counterparty_htlc_transaction_LDKBaseSign_jcall,
2725                 .sign_closing_transaction = sign_closing_transaction_LDKBaseSign_jcall,
2726                 .sign_channel_announcement = sign_channel_announcement_LDKBaseSign_jcall,
2727                 .ready_channel = ready_channel_LDKBaseSign_jcall,
2728                 .free = LDKBaseSign_JCalls_free,
2729                 .pubkeys = pubkeys_conv,
2730                 .set_pubkeys = NULL,
2731         };
2732         return ret;
2733 }
2734 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKBaseSign_1new(JNIEnv *env, jclass clz, jobject o, int64_t pubkeys) {
2735         LDKBaseSign *res_ptr = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
2736         *res_ptr = LDKBaseSign_init(env, clz, o, pubkeys);
2737         return (uint64_t)res_ptr;
2738 }
2739 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) {
2740         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2741         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
2742         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, (this_arg_conv->get_per_commitment_point)(this_arg_conv->this_arg, idx).compressed_form);
2743         return ret_arr;
2744 }
2745
2746 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BaseSign_1release_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_arg, int64_t idx) {
2747         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2748         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
2749         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->release_commitment_secret)(this_arg_conv->this_arg, idx).data);
2750         return ret_arr;
2751 }
2752
2753 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1validate_1holder_1commitment(JNIEnv *env, jclass clz, int64_t this_arg, int64_t holder_tx) {
2754         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2755         LDKHolderCommitmentTransaction holder_tx_conv;
2756         holder_tx_conv.inner = (void*)(holder_tx & (~1));
2757         holder_tx_conv.is_owned = false;
2758         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
2759         *ret_conv = (this_arg_conv->validate_holder_commitment)(this_arg_conv->this_arg, &holder_tx_conv);
2760         return (uint64_t)ret_conv;
2761 }
2762
2763 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BaseSign_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
2764         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2765         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
2766         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->channel_keys_id)(this_arg_conv->this_arg).data);
2767         return ret_arr;
2768 }
2769
2770 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) {
2771         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2772         LDKCommitmentTransaction commitment_tx_conv;
2773         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
2774         commitment_tx_conv.is_owned = false;
2775         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
2776         *ret_conv = (this_arg_conv->sign_counterparty_commitment)(this_arg_conv->this_arg, &commitment_tx_conv);
2777         return (uint64_t)ret_conv;
2778 }
2779
2780 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1validate_1counterparty_1revocation(JNIEnv *env, jclass clz, int64_t this_arg, int64_t idx, int8_tArray secret) {
2781         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2782         unsigned char secret_arr[32];
2783         CHECK((*env)->GetArrayLength(env, secret) == 32);
2784         (*env)->GetByteArrayRegion(env, secret, 0, 32, secret_arr);
2785         unsigned char (*secret_ref)[32] = &secret_arr;
2786         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
2787         *ret_conv = (this_arg_conv->validate_counterparty_revocation)(this_arg_conv->this_arg, idx, secret_ref);
2788         return (uint64_t)ret_conv;
2789 }
2790
2791 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) {
2792         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2793         LDKHolderCommitmentTransaction commitment_tx_conv;
2794         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
2795         commitment_tx_conv.is_owned = false;
2796         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
2797         *ret_conv = (this_arg_conv->sign_holder_commitment_and_htlcs)(this_arg_conv->this_arg, &commitment_tx_conv);
2798         return (uint64_t)ret_conv;
2799 }
2800
2801 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) {
2802         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2803         LDKTransaction justice_tx_ref;
2804         justice_tx_ref.datalen = (*env)->GetArrayLength(env, justice_tx);
2805         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
2806         (*env)->GetByteArrayRegion(env, justice_tx, 0, justice_tx_ref.datalen, justice_tx_ref.data);
2807         justice_tx_ref.data_is_owned = true;
2808         unsigned char per_commitment_key_arr[32];
2809         CHECK((*env)->GetArrayLength(env, per_commitment_key) == 32);
2810         (*env)->GetByteArrayRegion(env, per_commitment_key, 0, 32, per_commitment_key_arr);
2811         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
2812         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2813         *ret_conv = (this_arg_conv->sign_justice_revoked_output)(this_arg_conv->this_arg, justice_tx_ref, input, amount, per_commitment_key_ref);
2814         return (uint64_t)ret_conv;
2815 }
2816
2817 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) {
2818         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2819         LDKTransaction justice_tx_ref;
2820         justice_tx_ref.datalen = (*env)->GetArrayLength(env, justice_tx);
2821         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
2822         (*env)->GetByteArrayRegion(env, justice_tx, 0, justice_tx_ref.datalen, justice_tx_ref.data);
2823         justice_tx_ref.data_is_owned = true;
2824         unsigned char per_commitment_key_arr[32];
2825         CHECK((*env)->GetArrayLength(env, per_commitment_key) == 32);
2826         (*env)->GetByteArrayRegion(env, per_commitment_key, 0, 32, per_commitment_key_arr);
2827         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
2828         LDKHTLCOutputInCommitment htlc_conv;
2829         htlc_conv.inner = (void*)(htlc & (~1));
2830         htlc_conv.is_owned = false;
2831         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2832         *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);
2833         return (uint64_t)ret_conv;
2834 }
2835
2836 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) {
2837         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2838         LDKTransaction htlc_tx_ref;
2839         htlc_tx_ref.datalen = (*env)->GetArrayLength(env, htlc_tx);
2840         htlc_tx_ref.data = MALLOC(htlc_tx_ref.datalen, "LDKTransaction Bytes");
2841         (*env)->GetByteArrayRegion(env, htlc_tx, 0, htlc_tx_ref.datalen, htlc_tx_ref.data);
2842         htlc_tx_ref.data_is_owned = true;
2843         LDKPublicKey per_commitment_point_ref;
2844         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
2845         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
2846         LDKHTLCOutputInCommitment htlc_conv;
2847         htlc_conv.inner = (void*)(htlc & (~1));
2848         htlc_conv.is_owned = false;
2849         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2850         *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);
2851         return (uint64_t)ret_conv;
2852 }
2853
2854 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1sign_1closing_1transaction(JNIEnv *env, jclass clz, int64_t this_arg, int64_t closing_tx) {
2855         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2856         LDKClosingTransaction closing_tx_conv;
2857         closing_tx_conv.inner = (void*)(closing_tx & (~1));
2858         closing_tx_conv.is_owned = false;
2859         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2860         *ret_conv = (this_arg_conv->sign_closing_transaction)(this_arg_conv->this_arg, &closing_tx_conv);
2861         return (uint64_t)ret_conv;
2862 }
2863
2864 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1sign_1channel_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
2865         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2866         LDKUnsignedChannelAnnouncement msg_conv;
2867         msg_conv.inner = (void*)(msg & (~1));
2868         msg_conv.is_owned = false;
2869         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2870         *ret_conv = (this_arg_conv->sign_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
2871         return (uint64_t)ret_conv;
2872 }
2873
2874 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BaseSign_1ready_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t channel_parameters) {
2875         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2876         LDKChannelTransactionParameters channel_parameters_conv;
2877         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
2878         channel_parameters_conv.is_owned = false;
2879         (this_arg_conv->ready_channel)(this_arg_conv->this_arg, &channel_parameters_conv);
2880 }
2881
2882 LDKChannelPublicKeys LDKBaseSign_set_get_pubkeys(LDKBaseSign* this_arg) {
2883         if (this_arg->set_pubkeys != NULL)
2884                 this_arg->set_pubkeys(this_arg);
2885         return this_arg->pubkeys;
2886 }
2887 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1get_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
2888         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2889         LDKChannelPublicKeys ret_var = LDKBaseSign_set_get_pubkeys(this_arg_conv);
2890         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2891         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2892         uint64_t ret_ref = (uint64_t)ret_var.inner;
2893         if (ret_var.is_owned) {
2894                 ret_ref |= 1;
2895         }
2896         return ret_ref;
2897 }
2898
2899 typedef struct LDKSign_JCalls {
2900         atomic_size_t refcnt;
2901         JavaVM *vm;
2902         jweak o;
2903         LDKBaseSign_JCalls* BaseSign;
2904         jmethodID write_meth;
2905 } LDKSign_JCalls;
2906 static void LDKSign_JCalls_free(void* this_arg) {
2907         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
2908         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2909                 JNIEnv *env;
2910                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2911                 if (get_jenv_res == JNI_EDETACHED) {
2912                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2913                 } else {
2914                         DO_ASSERT(get_jenv_res == JNI_OK);
2915                 }
2916                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
2917                 if (get_jenv_res == JNI_EDETACHED) {
2918                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2919                 }
2920                 FREE(j_calls);
2921         }
2922 }
2923 LDKCVec_u8Z write_LDKSign_jcall(const void* this_arg) {
2924         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
2925         JNIEnv *env;
2926         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2927         if (get_jenv_res == JNI_EDETACHED) {
2928                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2929         } else {
2930                 DO_ASSERT(get_jenv_res == JNI_OK);
2931         }
2932         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2933         CHECK(obj != NULL);
2934         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->write_meth);
2935         if ((*env)->ExceptionCheck(env)) {
2936                 (*env)->ExceptionDescribe(env);
2937                 (*env)->FatalError(env, "A call to write in LDKSign from rust threw an exception.");
2938         }
2939         LDKCVec_u8Z ret_ref;
2940         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
2941         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
2942         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
2943         if (get_jenv_res == JNI_EDETACHED) {
2944                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2945         }
2946         return ret_ref;
2947 }
2948 static void LDKSign_JCalls_cloned(LDKSign* new_obj) {
2949         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) new_obj->this_arg;
2950         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2951         atomic_fetch_add_explicit(&j_calls->BaseSign->refcnt, 1, memory_order_release);
2952 }
2953 static inline LDKSign LDKSign_init (JNIEnv *env, jclass clz, jobject o, jobject BaseSign, int64_t pubkeys) {
2954         jclass c = (*env)->GetObjectClass(env, o);
2955         CHECK(c != NULL);
2956         LDKSign_JCalls *calls = MALLOC(sizeof(LDKSign_JCalls), "LDKSign_JCalls");
2957         atomic_init(&calls->refcnt, 1);
2958         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
2959         calls->o = (*env)->NewWeakGlobalRef(env, o);
2960         calls->write_meth = (*env)->GetMethodID(env, c, "write", "()[B");
2961         CHECK(calls->write_meth != NULL);
2962
2963         LDKChannelPublicKeys pubkeys_conv;
2964         pubkeys_conv.inner = (void*)(pubkeys & (~1));
2965         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
2966         pubkeys_conv = ChannelPublicKeys_clone(&pubkeys_conv);
2967
2968         LDKSign ret = {
2969                 .this_arg = (void*) calls,
2970                 .write = write_LDKSign_jcall,
2971                 .cloned = LDKSign_JCalls_cloned,
2972                 .free = LDKSign_JCalls_free,
2973                 .BaseSign = LDKBaseSign_init(env, clz, BaseSign, pubkeys),
2974         };
2975         calls->BaseSign = ret.BaseSign.this_arg;
2976         return ret;
2977 }
2978 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSign_1new(JNIEnv *env, jclass clz, jobject o, jobject BaseSign, int64_t pubkeys) {
2979         LDKSign *res_ptr = MALLOC(sizeof(LDKSign), "LDKSign");
2980         *res_ptr = LDKSign_init(env, clz, o, BaseSign, pubkeys);
2981         return (uint64_t)res_ptr;
2982 }
2983 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSign_1get_1BaseSign(JNIEnv *env, jclass clz, int64_t arg) {
2984         LDKSign *inp = (LDKSign *)(arg & ~1);
2985         uint64_t res_ptr = (uint64_t)&inp->BaseSign;
2986         DO_ASSERT((res_ptr & 1) == 0);
2987         return (int64_t)(res_ptr | 1);
2988 }
2989 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Sign_1write(JNIEnv *env, jclass clz, int64_t this_arg) {
2990         LDKSign* this_arg_conv = (LDKSign*)(((uint64_t)this_arg) & ~1);
2991         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
2992         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
2993         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
2994         CVec_u8Z_free(ret_var);
2995         return ret_arr;
2996 }
2997
2998 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2999         return ((LDKCResult_SignDecodeErrorZ*)arg)->result_ok;
3000 }
3001 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3002         LDKCResult_SignDecodeErrorZ *val = (LDKCResult_SignDecodeErrorZ*)(arg & ~1);
3003         CHECK(val->result_ok);
3004         LDKSign* res_ret =MALLOC(sizeof(LDKSign), "LDKSign");
3005         *res_ret = Sign_clone(&(*val->contents.result));
3006         return (uint64_t)res_ret;
3007 }
3008 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3009         LDKCResult_SignDecodeErrorZ *val = (LDKCResult_SignDecodeErrorZ*)(arg & ~1);
3010         CHECK(!val->result_ok);
3011         LDKDecodeError err_var = (*val->contents.err);
3012         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3013         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3014         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
3015         return err_ref;
3016 }
3017 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RecoverableSignatureNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3018         return ((LDKCResult_RecoverableSignatureNoneZ*)arg)->result_ok;
3019 }
3020 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RecoverableSignatureNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3021         LDKCResult_RecoverableSignatureNoneZ *val = (LDKCResult_RecoverableSignatureNoneZ*)(arg & ~1);
3022         CHECK(val->result_ok);
3023         int8_tArray es_arr = (*env)->NewByteArray(env, 68);
3024         (*env)->SetByteArrayRegion(env, es_arr, 0, 68, (*val->contents.result).serialized_form);
3025         return es_arr;
3026 }
3027 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RecoverableSignatureNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3028         LDKCResult_RecoverableSignatureNoneZ *val = (LDKCResult_RecoverableSignatureNoneZ*)(arg & ~1);
3029         CHECK(!val->result_ok);
3030         return *val->contents.err;
3031 }
3032 static inline LDKCVec_CVec_u8ZZ CVec_CVec_u8ZZ_clone(const LDKCVec_CVec_u8ZZ *orig) {
3033         LDKCVec_CVec_u8ZZ ret = { .data = MALLOC(sizeof(LDKCVec_u8Z) * orig->datalen, "LDKCVec_CVec_u8ZZ clone bytes"), .datalen = orig->datalen };
3034         for (size_t i = 0; i < ret.datalen; i++) {
3035                 ret.data[i] = CVec_u8Z_clone(&orig->data[i]);
3036         }
3037         return ret;
3038 }
3039 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1CVec_1u8ZZNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3040         return ((LDKCResult_CVec_CVec_u8ZZNoneZ*)arg)->result_ok;
3041 }
3042 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1CVec_1u8ZZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3043         LDKCResult_CVec_CVec_u8ZZNoneZ *val = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(arg & ~1);
3044         CHECK(val->result_ok);
3045         LDKCVec_CVec_u8ZZ res_var = (*val->contents.result);
3046         jobjectArray res_arr = (*env)->NewObjectArray(env, res_var.datalen, arr_of_B_clz, NULL);
3047         ;
3048         for (size_t i = 0; i < res_var.datalen; i++) {
3049                 LDKCVec_u8Z res_conv_8_var = res_var.data[i];
3050                 int8_tArray res_conv_8_arr = (*env)->NewByteArray(env, res_conv_8_var.datalen);
3051                 (*env)->SetByteArrayRegion(env, res_conv_8_arr, 0, res_conv_8_var.datalen, res_conv_8_var.data);
3052                 (*env)->SetObjectArrayElement(env, res_arr, i, res_conv_8_arr);
3053         }
3054         return res_arr;
3055 }
3056 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1CVec_1u8ZZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3057         LDKCResult_CVec_CVec_u8ZZNoneZ *val = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(arg & ~1);
3058         CHECK(!val->result_ok);
3059         return *val->contents.err;
3060 }
3061 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InMemorySignerDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3062         return ((LDKCResult_InMemorySignerDecodeErrorZ*)arg)->result_ok;
3063 }
3064 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InMemorySignerDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3065         LDKCResult_InMemorySignerDecodeErrorZ *val = (LDKCResult_InMemorySignerDecodeErrorZ*)(arg & ~1);
3066         CHECK(val->result_ok);
3067         LDKInMemorySigner res_var = (*val->contents.result);
3068         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3069         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3070         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
3071         return res_ref;
3072 }
3073 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InMemorySignerDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3074         LDKCResult_InMemorySignerDecodeErrorZ *val = (LDKCResult_InMemorySignerDecodeErrorZ*)(arg & ~1);
3075         CHECK(!val->result_ok);
3076         LDKDecodeError err_var = (*val->contents.err);
3077         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3078         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3079         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
3080         return err_ref;
3081 }
3082 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1TxOutZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
3083         LDKCVec_TxOutZ *ret = MALLOC(sizeof(LDKCVec_TxOutZ), "LDKCVec_TxOutZ");
3084         ret->datalen = (*env)->GetArrayLength(env, elems);
3085         if (ret->datalen == 0) {
3086                 ret->data = NULL;
3087         } else {
3088                 ret->data = MALLOC(sizeof(LDKTxOut) * ret->datalen, "LDKCVec_TxOutZ Data");
3089                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3090                 for (size_t i = 0; i < ret->datalen; i++) {
3091                         int64_t arr_elem = java_elems[i];
3092                         LDKTxOut arr_elem_conv = *(LDKTxOut*)(((uint64_t)arr_elem) & ~1);
3093                         arr_elem_conv = TxOut_clone((LDKTxOut*)(((uint64_t)arr_elem) & ~1));
3094                         ret->data[i] = arr_elem_conv;
3095                 }
3096                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3097         }
3098         return (uint64_t)ret;
3099 }
3100 static inline LDKCVec_TxOutZ CVec_TxOutZ_clone(const LDKCVec_TxOutZ *orig) {
3101         LDKCVec_TxOutZ ret = { .data = MALLOC(sizeof(LDKTxOut) * orig->datalen, "LDKCVec_TxOutZ clone bytes"), .datalen = orig->datalen };
3102         for (size_t i = 0; i < ret.datalen; i++) {
3103                 ret.data[i] = TxOut_clone(&orig->data[i]);
3104         }
3105         return ret;
3106 }
3107 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TransactionNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3108         return ((LDKCResult_TransactionNoneZ*)arg)->result_ok;
3109 }
3110 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TransactionNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3111         LDKCResult_TransactionNoneZ *val = (LDKCResult_TransactionNoneZ*)(arg & ~1);
3112         CHECK(val->result_ok);
3113         LDKTransaction res_var = (*val->contents.result);
3114         int8_tArray res_arr = (*env)->NewByteArray(env, res_var.datalen);
3115         (*env)->SetByteArrayRegion(env, res_arr, 0, res_var.datalen, res_var.data);
3116         return res_arr;
3117 }
3118 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TransactionNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3119         LDKCResult_TransactionNoneZ *val = (LDKCResult_TransactionNoneZ*)(arg & ~1);
3120         CHECK(!val->result_ok);
3121         return *val->contents.err;
3122 }
3123 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1BlockHashChannelMonitorZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
3124         LDKC2Tuple_BlockHashChannelMonitorZ* ret = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
3125         LDKThirtyTwoBytes a_ref;
3126         CHECK((*env)->GetArrayLength(env, a) == 32);
3127         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
3128         ret->a = a_ref;
3129         LDKChannelMonitor b_conv;
3130         b_conv.inner = (void*)(b & (~1));
3131         b_conv.is_owned = (b & 1) || (b == 0);
3132         b_conv = ChannelMonitor_clone(&b_conv);
3133         ret->b = b_conv;
3134         return (uint64_t)ret;
3135 }
3136 static inline struct LDKThirtyTwoBytes C2Tuple_BlockHashChannelMonitorZ_get_a(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR tuple){
3137         return ThirtyTwoBytes_clone(&tuple->a);
3138 }
3139 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1get_1a(JNIEnv *env, jclass clz, int64_t tuple) {
3140         LDKC2Tuple_BlockHashChannelMonitorZ* tuple_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(tuple & ~1);
3141         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
3142         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_BlockHashChannelMonitorZ_get_a(tuple_conv).data);
3143         return ret_arr;
3144 }
3145
3146 static inline struct LDKChannelMonitor C2Tuple_BlockHashChannelMonitorZ_get_b(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR tuple){
3147         return ChannelMonitor_clone(&tuple->b);
3148 }
3149 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1get_1b(JNIEnv *env, jclass clz, int64_t tuple) {
3150         LDKC2Tuple_BlockHashChannelMonitorZ* tuple_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(tuple & ~1);
3151         LDKChannelMonitor ret_var = C2Tuple_BlockHashChannelMonitorZ_get_b(tuple_conv);
3152         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3153         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3154         uint64_t ret_ref = (uint64_t)ret_var.inner;
3155         if (ret_var.is_owned) {
3156                 ret_ref |= 1;
3157         }
3158         return ret_ref;
3159 }
3160
3161 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1BlockHashChannelMonitorZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
3162         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_BlockHashChannelMonitorZZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ");
3163         ret->datalen = (*env)->GetArrayLength(env, elems);
3164         if (ret->datalen == 0) {
3165                 ret->data = NULL;
3166         } else {
3167                 ret->data = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ) * ret->datalen, "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Data");
3168                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3169                 for (size_t i = 0; i < ret->datalen; i++) {
3170                         int64_t arr_elem = java_elems[i];
3171                         LDKC2Tuple_BlockHashChannelMonitorZ arr_elem_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)arr_elem) & ~1);
3172                         arr_elem_conv = C2Tuple_BlockHashChannelMonitorZ_clone((LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)arr_elem) & ~1));
3173                         ret->data[i] = arr_elem_conv;
3174                 }
3175                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3176         }
3177         return (uint64_t)ret;
3178 }
3179 static inline LDKCVec_C2Tuple_BlockHashChannelMonitorZZ CVec_C2Tuple_BlockHashChannelMonitorZZ_clone(const LDKCVec_C2Tuple_BlockHashChannelMonitorZZ *orig) {
3180         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ) * orig->datalen, "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ clone bytes"), .datalen = orig->datalen };
3181         for (size_t i = 0; i < ret.datalen; i++) {
3182                 ret.data[i] = C2Tuple_BlockHashChannelMonitorZ_clone(&orig->data[i]);
3183         }
3184         return ret;
3185 }
3186 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3187         return ((LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)arg)->result_ok;
3188 }
3189 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3190         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *val = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(arg & ~1);
3191         CHECK(val->result_ok);
3192         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ res_var = (*val->contents.result);
3193         int64_tArray res_arr = (*env)->NewLongArray(env, res_var.datalen);
3194         int64_t *res_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, res_arr, NULL);
3195         for (size_t j = 0; j < res_var.datalen; j++) {
3196                 LDKC2Tuple_BlockHashChannelMonitorZ* res_conv_35_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
3197                 *res_conv_35_conv = res_var.data[j];
3198                 *res_conv_35_conv = C2Tuple_BlockHashChannelMonitorZ_clone(res_conv_35_conv);
3199                 res_arr_ptr[j] = ((uint64_t)res_conv_35_conv);
3200         }
3201         (*env)->ReleasePrimitiveArrayCritical(env, res_arr, res_arr_ptr, 0);
3202         return res_arr;
3203 }
3204 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3205         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *val = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(arg & ~1);
3206         CHECK(!val->result_ok);
3207         jclass err_conv = LDKIOError_to_java(env, (*val->contents.err));
3208         return err_conv;
3209 }
3210 static jclass LDKCOption_u16Z_Some_class = NULL;
3211 static jmethodID LDKCOption_u16Z_Some_meth = NULL;
3212 static jclass LDKCOption_u16Z_None_class = NULL;
3213 static jmethodID LDKCOption_u16Z_None_meth = NULL;
3214 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u16Z_init (JNIEnv *env, jclass clz) {
3215         LDKCOption_u16Z_Some_class =
3216                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_u16Z$Some;"));
3217         CHECK(LDKCOption_u16Z_Some_class != NULL);
3218         LDKCOption_u16Z_Some_meth = (*env)->GetMethodID(env, LDKCOption_u16Z_Some_class, "<init>", "(S)V");
3219         CHECK(LDKCOption_u16Z_Some_meth != NULL);
3220         LDKCOption_u16Z_None_class =
3221                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_u16Z$None;"));
3222         CHECK(LDKCOption_u16Z_None_class != NULL);
3223         LDKCOption_u16Z_None_meth = (*env)->GetMethodID(env, LDKCOption_u16Z_None_class, "<init>", "()V");
3224         CHECK(LDKCOption_u16Z_None_meth != NULL);
3225 }
3226 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u16Z_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3227         LDKCOption_u16Z *obj = (LDKCOption_u16Z*)(ptr & ~1);
3228         switch(obj->tag) {
3229                 case LDKCOption_u16Z_Some: {
3230                         return (*env)->NewObject(env, LDKCOption_u16Z_Some_class, LDKCOption_u16Z_Some_meth, obj->some);
3231                 }
3232                 case LDKCOption_u16Z_None: {
3233                         return (*env)->NewObject(env, LDKCOption_u16Z_None_class, LDKCOption_u16Z_None_meth);
3234                 }
3235                 default: abort();
3236         }
3237 }
3238 static jclass LDKAPIError_APIMisuseError_class = NULL;
3239 static jmethodID LDKAPIError_APIMisuseError_meth = NULL;
3240 static jclass LDKAPIError_FeeRateTooHigh_class = NULL;
3241 static jmethodID LDKAPIError_FeeRateTooHigh_meth = NULL;
3242 static jclass LDKAPIError_RouteError_class = NULL;
3243 static jmethodID LDKAPIError_RouteError_meth = NULL;
3244 static jclass LDKAPIError_ChannelUnavailable_class = NULL;
3245 static jmethodID LDKAPIError_ChannelUnavailable_meth = NULL;
3246 static jclass LDKAPIError_MonitorUpdateFailed_class = NULL;
3247 static jmethodID LDKAPIError_MonitorUpdateFailed_meth = NULL;
3248 static jclass LDKAPIError_IncompatibleShutdownScript_class = NULL;
3249 static jmethodID LDKAPIError_IncompatibleShutdownScript_meth = NULL;
3250 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKAPIError_init (JNIEnv *env, jclass clz) {
3251         LDKAPIError_APIMisuseError_class =
3252                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$APIMisuseError;"));
3253         CHECK(LDKAPIError_APIMisuseError_class != NULL);
3254         LDKAPIError_APIMisuseError_meth = (*env)->GetMethodID(env, LDKAPIError_APIMisuseError_class, "<init>", "(Ljava/lang/String;)V");
3255         CHECK(LDKAPIError_APIMisuseError_meth != NULL);
3256         LDKAPIError_FeeRateTooHigh_class =
3257                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$FeeRateTooHigh;"));
3258         CHECK(LDKAPIError_FeeRateTooHigh_class != NULL);
3259         LDKAPIError_FeeRateTooHigh_meth = (*env)->GetMethodID(env, LDKAPIError_FeeRateTooHigh_class, "<init>", "(Ljava/lang/String;I)V");
3260         CHECK(LDKAPIError_FeeRateTooHigh_meth != NULL);
3261         LDKAPIError_RouteError_class =
3262                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$RouteError;"));
3263         CHECK(LDKAPIError_RouteError_class != NULL);
3264         LDKAPIError_RouteError_meth = (*env)->GetMethodID(env, LDKAPIError_RouteError_class, "<init>", "(Ljava/lang/String;)V");
3265         CHECK(LDKAPIError_RouteError_meth != NULL);
3266         LDKAPIError_ChannelUnavailable_class =
3267                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$ChannelUnavailable;"));
3268         CHECK(LDKAPIError_ChannelUnavailable_class != NULL);
3269         LDKAPIError_ChannelUnavailable_meth = (*env)->GetMethodID(env, LDKAPIError_ChannelUnavailable_class, "<init>", "(Ljava/lang/String;)V");
3270         CHECK(LDKAPIError_ChannelUnavailable_meth != NULL);
3271         LDKAPIError_MonitorUpdateFailed_class =
3272                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$MonitorUpdateFailed;"));
3273         CHECK(LDKAPIError_MonitorUpdateFailed_class != NULL);
3274         LDKAPIError_MonitorUpdateFailed_meth = (*env)->GetMethodID(env, LDKAPIError_MonitorUpdateFailed_class, "<init>", "()V");
3275         CHECK(LDKAPIError_MonitorUpdateFailed_meth != NULL);
3276         LDKAPIError_IncompatibleShutdownScript_class =
3277                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$IncompatibleShutdownScript;"));
3278         CHECK(LDKAPIError_IncompatibleShutdownScript_class != NULL);
3279         LDKAPIError_IncompatibleShutdownScript_meth = (*env)->GetMethodID(env, LDKAPIError_IncompatibleShutdownScript_class, "<init>", "(J)V");
3280         CHECK(LDKAPIError_IncompatibleShutdownScript_meth != NULL);
3281 }
3282 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKAPIError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3283         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
3284         switch(obj->tag) {
3285                 case LDKAPIError_APIMisuseError: {
3286                         LDKStr err_str = obj->api_misuse_error.err;
3287                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
3288                         return (*env)->NewObject(env, LDKAPIError_APIMisuseError_class, LDKAPIError_APIMisuseError_meth, err_conv);
3289                 }
3290                 case LDKAPIError_FeeRateTooHigh: {
3291                         LDKStr err_str = obj->fee_rate_too_high.err;
3292                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
3293                         return (*env)->NewObject(env, LDKAPIError_FeeRateTooHigh_class, LDKAPIError_FeeRateTooHigh_meth, err_conv, obj->fee_rate_too_high.feerate);
3294                 }
3295                 case LDKAPIError_RouteError: {
3296                         LDKStr err_str = obj->route_error.err;
3297                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
3298                         return (*env)->NewObject(env, LDKAPIError_RouteError_class, LDKAPIError_RouteError_meth, err_conv);
3299                 }
3300                 case LDKAPIError_ChannelUnavailable: {
3301                         LDKStr err_str = obj->channel_unavailable.err;
3302                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
3303                         return (*env)->NewObject(env, LDKAPIError_ChannelUnavailable_class, LDKAPIError_ChannelUnavailable_meth, err_conv);
3304                 }
3305                 case LDKAPIError_MonitorUpdateFailed: {
3306                         return (*env)->NewObject(env, LDKAPIError_MonitorUpdateFailed_class, LDKAPIError_MonitorUpdateFailed_meth);
3307                 }
3308                 case LDKAPIError_IncompatibleShutdownScript: {
3309                         LDKShutdownScript script_var = obj->incompatible_shutdown_script.script;
3310                         CHECK((((uint64_t)script_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3311                         CHECK((((uint64_t)&script_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3312                         uint64_t script_ref = (uint64_t)script_var.inner & ~1;
3313                         return (*env)->NewObject(env, LDKAPIError_IncompatibleShutdownScript_class, LDKAPIError_IncompatibleShutdownScript_meth, script_ref);
3314                 }
3315                 default: abort();
3316         }
3317 }
3318 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneAPIErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3319         return ((LDKCResult_NoneAPIErrorZ*)arg)->result_ok;
3320 }
3321 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3322         LDKCResult_NoneAPIErrorZ *val = (LDKCResult_NoneAPIErrorZ*)(arg & ~1);
3323         CHECK(val->result_ok);
3324         return *val->contents.result;
3325 }
3326 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3327         LDKCResult_NoneAPIErrorZ *val = (LDKCResult_NoneAPIErrorZ*)(arg & ~1);
3328         CHECK(!val->result_ok);
3329         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
3330         return err_ref;
3331 }
3332 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1CResult_1NoneAPIErrorZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
3333         LDKCVec_CResult_NoneAPIErrorZZ *ret = MALLOC(sizeof(LDKCVec_CResult_NoneAPIErrorZZ), "LDKCVec_CResult_NoneAPIErrorZZ");
3334         ret->datalen = (*env)->GetArrayLength(env, elems);
3335         if (ret->datalen == 0) {
3336                 ret->data = NULL;
3337         } else {
3338                 ret->data = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ) * ret->datalen, "LDKCVec_CResult_NoneAPIErrorZZ Data");
3339                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3340                 for (size_t i = 0; i < ret->datalen; i++) {
3341                         int64_t arr_elem = java_elems[i];
3342                         LDKCResult_NoneAPIErrorZ arr_elem_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)arr_elem) & ~1);
3343                         arr_elem_conv = CResult_NoneAPIErrorZ_clone((LDKCResult_NoneAPIErrorZ*)(((uint64_t)arr_elem) & ~1));
3344                         ret->data[i] = arr_elem_conv;
3345                 }
3346                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3347         }
3348         return (uint64_t)ret;
3349 }
3350 static inline LDKCVec_CResult_NoneAPIErrorZZ CVec_CResult_NoneAPIErrorZZ_clone(const LDKCVec_CResult_NoneAPIErrorZZ *orig) {
3351         LDKCVec_CResult_NoneAPIErrorZZ ret = { .data = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ) * orig->datalen, "LDKCVec_CResult_NoneAPIErrorZZ clone bytes"), .datalen = orig->datalen };
3352         for (size_t i = 0; i < ret.datalen; i++) {
3353                 ret.data[i] = CResult_NoneAPIErrorZ_clone(&orig->data[i]);
3354         }
3355         return ret;
3356 }
3357 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1APIErrorZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
3358         LDKCVec_APIErrorZ *ret = MALLOC(sizeof(LDKCVec_APIErrorZ), "LDKCVec_APIErrorZ");
3359         ret->datalen = (*env)->GetArrayLength(env, elems);
3360         if (ret->datalen == 0) {
3361                 ret->data = NULL;
3362         } else {
3363                 ret->data = MALLOC(sizeof(LDKAPIError) * ret->datalen, "LDKCVec_APIErrorZ Data");
3364                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3365                 for (size_t i = 0; i < ret->datalen; i++) {
3366                         int64_t arr_elem = java_elems[i];
3367                         LDKAPIError arr_elem_conv = *(LDKAPIError*)(((uint64_t)arr_elem) & ~1);
3368                         arr_elem_conv = APIError_clone((LDKAPIError*)(((uint64_t)arr_elem) & ~1));
3369                         ret->data[i] = arr_elem_conv;
3370                 }
3371                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3372         }
3373         return (uint64_t)ret;
3374 }
3375 static inline LDKCVec_APIErrorZ CVec_APIErrorZ_clone(const LDKCVec_APIErrorZ *orig) {
3376         LDKCVec_APIErrorZ ret = { .data = MALLOC(sizeof(LDKAPIError) * orig->datalen, "LDKCVec_APIErrorZ clone bytes"), .datalen = orig->datalen };
3377         for (size_t i = 0; i < ret.datalen; i++) {
3378                 ret.data[i] = APIError_clone(&orig->data[i]);
3379         }
3380         return ret;
3381 }
3382 static jclass LDKPaymentSendFailure_ParameterError_class = NULL;
3383 static jmethodID LDKPaymentSendFailure_ParameterError_meth = NULL;
3384 static jclass LDKPaymentSendFailure_PathParameterError_class = NULL;
3385 static jmethodID LDKPaymentSendFailure_PathParameterError_meth = NULL;
3386 static jclass LDKPaymentSendFailure_AllFailedRetrySafe_class = NULL;
3387 static jmethodID LDKPaymentSendFailure_AllFailedRetrySafe_meth = NULL;
3388 static jclass LDKPaymentSendFailure_PartialFailure_class = NULL;
3389 static jmethodID LDKPaymentSendFailure_PartialFailure_meth = NULL;
3390 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKPaymentSendFailure_init (JNIEnv *env, jclass clz) {
3391         LDKPaymentSendFailure_ParameterError_class =
3392                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentSendFailure$ParameterError;"));
3393         CHECK(LDKPaymentSendFailure_ParameterError_class != NULL);
3394         LDKPaymentSendFailure_ParameterError_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_ParameterError_class, "<init>", "(J)V");
3395         CHECK(LDKPaymentSendFailure_ParameterError_meth != NULL);
3396         LDKPaymentSendFailure_PathParameterError_class =
3397                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentSendFailure$PathParameterError;"));
3398         CHECK(LDKPaymentSendFailure_PathParameterError_class != NULL);
3399         LDKPaymentSendFailure_PathParameterError_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_PathParameterError_class, "<init>", "([J)V");
3400         CHECK(LDKPaymentSendFailure_PathParameterError_meth != NULL);
3401         LDKPaymentSendFailure_AllFailedRetrySafe_class =
3402                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentSendFailure$AllFailedRetrySafe;"));
3403         CHECK(LDKPaymentSendFailure_AllFailedRetrySafe_class != NULL);
3404         LDKPaymentSendFailure_AllFailedRetrySafe_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_AllFailedRetrySafe_class, "<init>", "([J)V");
3405         CHECK(LDKPaymentSendFailure_AllFailedRetrySafe_meth != NULL);
3406         LDKPaymentSendFailure_PartialFailure_class =
3407                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentSendFailure$PartialFailure;"));
3408         CHECK(LDKPaymentSendFailure_PartialFailure_class != NULL);
3409         LDKPaymentSendFailure_PartialFailure_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_PartialFailure_class, "<init>", "([J)V");
3410         CHECK(LDKPaymentSendFailure_PartialFailure_meth != NULL);
3411 }
3412 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPaymentSendFailure_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3413         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
3414         switch(obj->tag) {
3415                 case LDKPaymentSendFailure_ParameterError: {
3416                         uint64_t parameter_error_ref = ((uint64_t)&obj->parameter_error) | 1;
3417                         return (*env)->NewObject(env, LDKPaymentSendFailure_ParameterError_class, LDKPaymentSendFailure_ParameterError_meth, parameter_error_ref);
3418                 }
3419                 case LDKPaymentSendFailure_PathParameterError: {
3420                         LDKCVec_CResult_NoneAPIErrorZZ path_parameter_error_var = obj->path_parameter_error;
3421                         int64_tArray path_parameter_error_arr = (*env)->NewLongArray(env, path_parameter_error_var.datalen);
3422                         int64_t *path_parameter_error_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_parameter_error_arr, NULL);
3423                         for (size_t w = 0; w < path_parameter_error_var.datalen; w++) {
3424                                 LDKCResult_NoneAPIErrorZ* path_parameter_error_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
3425                                 *path_parameter_error_conv_22_conv = path_parameter_error_var.data[w];
3426                                 *path_parameter_error_conv_22_conv = CResult_NoneAPIErrorZ_clone(path_parameter_error_conv_22_conv);
3427                                 path_parameter_error_arr_ptr[w] = (uint64_t)path_parameter_error_conv_22_conv;
3428                         }
3429                         (*env)->ReleasePrimitiveArrayCritical(env, path_parameter_error_arr, path_parameter_error_arr_ptr, 0);
3430                         return (*env)->NewObject(env, LDKPaymentSendFailure_PathParameterError_class, LDKPaymentSendFailure_PathParameterError_meth, path_parameter_error_arr);
3431                 }
3432                 case LDKPaymentSendFailure_AllFailedRetrySafe: {
3433                         LDKCVec_APIErrorZ all_failed_retry_safe_var = obj->all_failed_retry_safe;
3434                         int64_tArray all_failed_retry_safe_arr = (*env)->NewLongArray(env, all_failed_retry_safe_var.datalen);
3435                         int64_t *all_failed_retry_safe_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, all_failed_retry_safe_arr, NULL);
3436                         for (size_t k = 0; k < all_failed_retry_safe_var.datalen; k++) {
3437                                 uint64_t all_failed_retry_safe_conv_10_ref = ((uint64_t)&all_failed_retry_safe_var.data[k]) | 1;
3438                                 all_failed_retry_safe_arr_ptr[k] = all_failed_retry_safe_conv_10_ref;
3439                         }
3440                         (*env)->ReleasePrimitiveArrayCritical(env, all_failed_retry_safe_arr, all_failed_retry_safe_arr_ptr, 0);
3441                         return (*env)->NewObject(env, LDKPaymentSendFailure_AllFailedRetrySafe_class, LDKPaymentSendFailure_AllFailedRetrySafe_meth, all_failed_retry_safe_arr);
3442                 }
3443                 case LDKPaymentSendFailure_PartialFailure: {
3444                         LDKCVec_CResult_NoneAPIErrorZZ partial_failure_var = obj->partial_failure;
3445                         int64_tArray partial_failure_arr = (*env)->NewLongArray(env, partial_failure_var.datalen);
3446                         int64_t *partial_failure_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, partial_failure_arr, NULL);
3447                         for (size_t w = 0; w < partial_failure_var.datalen; w++) {
3448                                 LDKCResult_NoneAPIErrorZ* partial_failure_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
3449                                 *partial_failure_conv_22_conv = partial_failure_var.data[w];
3450                                 *partial_failure_conv_22_conv = CResult_NoneAPIErrorZ_clone(partial_failure_conv_22_conv);
3451                                 partial_failure_arr_ptr[w] = (uint64_t)partial_failure_conv_22_conv;
3452                         }
3453                         (*env)->ReleasePrimitiveArrayCritical(env, partial_failure_arr, partial_failure_arr_ptr, 0);
3454                         return (*env)->NewObject(env, LDKPaymentSendFailure_PartialFailure_class, LDKPaymentSendFailure_PartialFailure_meth, partial_failure_arr);
3455                 }
3456                 default: abort();
3457         }
3458 }
3459 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePaymentSendFailureZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3460         return ((LDKCResult_NonePaymentSendFailureZ*)arg)->result_ok;
3461 }
3462 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePaymentSendFailureZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3463         LDKCResult_NonePaymentSendFailureZ *val = (LDKCResult_NonePaymentSendFailureZ*)(arg & ~1);
3464         CHECK(val->result_ok);
3465         return *val->contents.result;
3466 }
3467 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePaymentSendFailureZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3468         LDKCResult_NonePaymentSendFailureZ *val = (LDKCResult_NonePaymentSendFailureZ*)(arg & ~1);
3469         CHECK(!val->result_ok);
3470         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
3471         return err_ref;
3472 }
3473 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentHashPaymentSendFailureZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3474         return ((LDKCResult_PaymentHashPaymentSendFailureZ*)arg)->result_ok;
3475 }
3476 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentHashPaymentSendFailureZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3477         LDKCResult_PaymentHashPaymentSendFailureZ *val = (LDKCResult_PaymentHashPaymentSendFailureZ*)(arg & ~1);
3478         CHECK(val->result_ok);
3479         int8_tArray res_arr = (*env)->NewByteArray(env, 32);
3480         (*env)->SetByteArrayRegion(env, res_arr, 0, 32, (*val->contents.result).data);
3481         return res_arr;
3482 }
3483 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentHashPaymentSendFailureZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3484         LDKCResult_PaymentHashPaymentSendFailureZ *val = (LDKCResult_PaymentHashPaymentSendFailureZ*)(arg & ~1);
3485         CHECK(!val->result_ok);
3486         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
3487         return err_ref;
3488 }
3489 static jclass LDKNetAddress_IPv4_class = NULL;
3490 static jmethodID LDKNetAddress_IPv4_meth = NULL;
3491 static jclass LDKNetAddress_IPv6_class = NULL;
3492 static jmethodID LDKNetAddress_IPv6_meth = NULL;
3493 static jclass LDKNetAddress_OnionV2_class = NULL;
3494 static jmethodID LDKNetAddress_OnionV2_meth = NULL;
3495 static jclass LDKNetAddress_OnionV3_class = NULL;
3496 static jmethodID LDKNetAddress_OnionV3_meth = NULL;
3497 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKNetAddress_init (JNIEnv *env, jclass clz) {
3498         LDKNetAddress_IPv4_class =
3499                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$IPv4;"));
3500         CHECK(LDKNetAddress_IPv4_class != NULL);
3501         LDKNetAddress_IPv4_meth = (*env)->GetMethodID(env, LDKNetAddress_IPv4_class, "<init>", "([BS)V");
3502         CHECK(LDKNetAddress_IPv4_meth != NULL);
3503         LDKNetAddress_IPv6_class =
3504                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$IPv6;"));
3505         CHECK(LDKNetAddress_IPv6_class != NULL);
3506         LDKNetAddress_IPv6_meth = (*env)->GetMethodID(env, LDKNetAddress_IPv6_class, "<init>", "([BS)V");
3507         CHECK(LDKNetAddress_IPv6_meth != NULL);
3508         LDKNetAddress_OnionV2_class =
3509                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$OnionV2;"));
3510         CHECK(LDKNetAddress_OnionV2_class != NULL);
3511         LDKNetAddress_OnionV2_meth = (*env)->GetMethodID(env, LDKNetAddress_OnionV2_class, "<init>", "([BS)V");
3512         CHECK(LDKNetAddress_OnionV2_meth != NULL);
3513         LDKNetAddress_OnionV3_class =
3514                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$OnionV3;"));
3515         CHECK(LDKNetAddress_OnionV3_class != NULL);
3516         LDKNetAddress_OnionV3_meth = (*env)->GetMethodID(env, LDKNetAddress_OnionV3_class, "<init>", "([BSBS)V");
3517         CHECK(LDKNetAddress_OnionV3_meth != NULL);
3518 }
3519 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKNetAddress_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3520         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3521         switch(obj->tag) {
3522                 case LDKNetAddress_IPv4: {
3523                         int8_tArray addr_arr = (*env)->NewByteArray(env, 4);
3524                         (*env)->SetByteArrayRegion(env, addr_arr, 0, 4, obj->i_pv4.addr.data);
3525                         return (*env)->NewObject(env, LDKNetAddress_IPv4_class, LDKNetAddress_IPv4_meth, addr_arr, obj->i_pv4.port);
3526                 }
3527                 case LDKNetAddress_IPv6: {
3528                         int8_tArray addr_arr = (*env)->NewByteArray(env, 16);
3529                         (*env)->SetByteArrayRegion(env, addr_arr, 0, 16, obj->i_pv6.addr.data);
3530                         return (*env)->NewObject(env, LDKNetAddress_IPv6_class, LDKNetAddress_IPv6_meth, addr_arr, obj->i_pv6.port);
3531                 }
3532                 case LDKNetAddress_OnionV2: {
3533                         int8_tArray addr_arr = (*env)->NewByteArray(env, 10);
3534                         (*env)->SetByteArrayRegion(env, addr_arr, 0, 10, obj->onion_v2.addr.data);
3535                         return (*env)->NewObject(env, LDKNetAddress_OnionV2_class, LDKNetAddress_OnionV2_meth, addr_arr, obj->onion_v2.port);
3536                 }
3537                 case LDKNetAddress_OnionV3: {
3538                         int8_tArray ed25519_pubkey_arr = (*env)->NewByteArray(env, 32);
3539                         (*env)->SetByteArrayRegion(env, ed25519_pubkey_arr, 0, 32, obj->onion_v3.ed25519_pubkey.data);
3540                         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);
3541                 }
3542                 default: abort();
3543         }
3544 }
3545 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1NetAddressZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
3546         LDKCVec_NetAddressZ *ret = MALLOC(sizeof(LDKCVec_NetAddressZ), "LDKCVec_NetAddressZ");
3547         ret->datalen = (*env)->GetArrayLength(env, elems);
3548         if (ret->datalen == 0) {
3549                 ret->data = NULL;
3550         } else {
3551                 ret->data = MALLOC(sizeof(LDKNetAddress) * ret->datalen, "LDKCVec_NetAddressZ Data");
3552                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3553                 for (size_t i = 0; i < ret->datalen; i++) {
3554                         int64_t arr_elem = java_elems[i];
3555                         LDKNetAddress arr_elem_conv = *(LDKNetAddress*)(((uint64_t)arr_elem) & ~1);
3556                         arr_elem_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)arr_elem) & ~1));
3557                         ret->data[i] = arr_elem_conv;
3558                 }
3559                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3560         }
3561         return (uint64_t)ret;
3562 }
3563 static inline LDKCVec_NetAddressZ CVec_NetAddressZ_clone(const LDKCVec_NetAddressZ *orig) {
3564         LDKCVec_NetAddressZ ret = { .data = MALLOC(sizeof(LDKNetAddress) * orig->datalen, "LDKCVec_NetAddressZ clone bytes"), .datalen = orig->datalen };
3565         for (size_t i = 0; i < ret.datalen; i++) {
3566                 ret.data[i] = NetAddress_clone(&orig->data[i]);
3567         }
3568         return ret;
3569 }
3570 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1PaymentHashPaymentSecretZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int8_tArray b) {
3571         LDKC2Tuple_PaymentHashPaymentSecretZ* ret = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
3572         LDKThirtyTwoBytes a_ref;
3573         CHECK((*env)->GetArrayLength(env, a) == 32);
3574         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
3575         ret->a = a_ref;
3576         LDKThirtyTwoBytes b_ref;
3577         CHECK((*env)->GetArrayLength(env, b) == 32);
3578         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
3579         ret->b = b_ref;
3580         return (uint64_t)ret;
3581 }
3582 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentSecretZ_get_a(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR tuple){
3583         return ThirtyTwoBytes_clone(&tuple->a);
3584 }
3585 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1get_1a(JNIEnv *env, jclass clz, int64_t tuple) {
3586         LDKC2Tuple_PaymentHashPaymentSecretZ* tuple_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(tuple & ~1);
3587         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
3588         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_PaymentHashPaymentSecretZ_get_a(tuple_conv).data);
3589         return ret_arr;
3590 }
3591
3592 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentSecretZ_get_b(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR tuple){
3593         return ThirtyTwoBytes_clone(&tuple->b);
3594 }
3595 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1get_1b(JNIEnv *env, jclass clz, int64_t tuple) {
3596         LDKC2Tuple_PaymentHashPaymentSecretZ* tuple_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(tuple & ~1);
3597         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
3598         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_PaymentHashPaymentSecretZ_get_b(tuple_conv).data);
3599         return ret_arr;
3600 }
3601
3602 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentSecretAPIErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3603         return ((LDKCResult_PaymentSecretAPIErrorZ*)arg)->result_ok;
3604 }
3605 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentSecretAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3606         LDKCResult_PaymentSecretAPIErrorZ *val = (LDKCResult_PaymentSecretAPIErrorZ*)(arg & ~1);
3607         CHECK(val->result_ok);
3608         int8_tArray res_arr = (*env)->NewByteArray(env, 32);
3609         (*env)->SetByteArrayRegion(env, res_arr, 0, 32, (*val->contents.result).data);
3610         return res_arr;
3611 }
3612 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentSecretAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3613         LDKCResult_PaymentSecretAPIErrorZ *val = (LDKCResult_PaymentSecretAPIErrorZ*)(arg & ~1);
3614         CHECK(!val->result_ok);
3615         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
3616         return err_ref;
3617 }
3618 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1ChannelMonitorZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
3619         LDKCVec_ChannelMonitorZ *ret = MALLOC(sizeof(LDKCVec_ChannelMonitorZ), "LDKCVec_ChannelMonitorZ");
3620         ret->datalen = (*env)->GetArrayLength(env, elems);
3621         if (ret->datalen == 0) {
3622                 ret->data = NULL;
3623         } else {
3624                 ret->data = MALLOC(sizeof(LDKChannelMonitor) * ret->datalen, "LDKCVec_ChannelMonitorZ Data");
3625                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3626                 for (size_t i = 0; i < ret->datalen; i++) {
3627                         int64_t arr_elem = java_elems[i];
3628                         LDKChannelMonitor arr_elem_conv;
3629                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3630                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3631                         arr_elem_conv = ChannelMonitor_clone(&arr_elem_conv);
3632                         ret->data[i] = arr_elem_conv;
3633                 }
3634                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3635         }
3636         return (uint64_t)ret;
3637 }
3638 static inline LDKCVec_ChannelMonitorZ CVec_ChannelMonitorZ_clone(const LDKCVec_ChannelMonitorZ *orig) {
3639         LDKCVec_ChannelMonitorZ ret = { .data = MALLOC(sizeof(LDKChannelMonitor) * orig->datalen, "LDKCVec_ChannelMonitorZ clone bytes"), .datalen = orig->datalen };
3640         for (size_t i = 0; i < ret.datalen; i++) {
3641                 ret.data[i] = ChannelMonitor_clone(&orig->data[i]);
3642         }
3643         return ret;
3644 }
3645 typedef struct LDKWatch_JCalls {
3646         atomic_size_t refcnt;
3647         JavaVM *vm;
3648         jweak o;
3649         jmethodID watch_channel_meth;
3650         jmethodID update_channel_meth;
3651         jmethodID release_pending_monitor_events_meth;
3652 } LDKWatch_JCalls;
3653 static void LDKWatch_JCalls_free(void* this_arg) {
3654         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
3655         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3656                 JNIEnv *env;
3657                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3658                 if (get_jenv_res == JNI_EDETACHED) {
3659                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3660                 } else {
3661                         DO_ASSERT(get_jenv_res == JNI_OK);
3662                 }
3663                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
3664                 if (get_jenv_res == JNI_EDETACHED) {
3665                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3666                 }
3667                 FREE(j_calls);
3668         }
3669 }
3670 LDKCResult_NoneChannelMonitorUpdateErrZ watch_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitor monitor) {
3671         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
3672         JNIEnv *env;
3673         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3674         if (get_jenv_res == JNI_EDETACHED) {
3675                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3676         } else {
3677                 DO_ASSERT(get_jenv_res == JNI_OK);
3678         }
3679         LDKOutPoint funding_txo_var = funding_txo;
3680         CHECK((((uint64_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3681         CHECK((((uint64_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3682         uint64_t funding_txo_ref = (uint64_t)funding_txo_var.inner;
3683         if (funding_txo_var.is_owned) {
3684                 funding_txo_ref |= 1;
3685         }
3686         LDKChannelMonitor monitor_var = monitor;
3687         CHECK((((uint64_t)monitor_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3688         CHECK((((uint64_t)&monitor_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3689         uint64_t monitor_ref = (uint64_t)monitor_var.inner;
3690         if (monitor_var.is_owned) {
3691                 monitor_ref |= 1;
3692         }
3693         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3694         CHECK(obj != NULL);
3695         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->watch_channel_meth, funding_txo_ref, monitor_ref);
3696         if ((*env)->ExceptionCheck(env)) {
3697                 (*env)->ExceptionDescribe(env);
3698                 (*env)->FatalError(env, "A call to watch_channel in LDKWatch from rust threw an exception.");
3699         }
3700         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
3701         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
3702         if (get_jenv_res == JNI_EDETACHED) {
3703                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3704         }
3705         return ret_conv;
3706 }
3707 LDKCResult_NoneChannelMonitorUpdateErrZ update_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitorUpdate update) {
3708         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
3709         JNIEnv *env;
3710         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3711         if (get_jenv_res == JNI_EDETACHED) {
3712                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3713         } else {
3714                 DO_ASSERT(get_jenv_res == JNI_OK);
3715         }
3716         LDKOutPoint funding_txo_var = funding_txo;
3717         CHECK((((uint64_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3718         CHECK((((uint64_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3719         uint64_t funding_txo_ref = (uint64_t)funding_txo_var.inner;
3720         if (funding_txo_var.is_owned) {
3721                 funding_txo_ref |= 1;
3722         }
3723         LDKChannelMonitorUpdate update_var = update;
3724         CHECK((((uint64_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3725         CHECK((((uint64_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3726         uint64_t update_ref = (uint64_t)update_var.inner;
3727         if (update_var.is_owned) {
3728                 update_ref |= 1;
3729         }
3730         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3731         CHECK(obj != NULL);
3732         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->update_channel_meth, funding_txo_ref, update_ref);
3733         if ((*env)->ExceptionCheck(env)) {
3734                 (*env)->ExceptionDescribe(env);
3735                 (*env)->FatalError(env, "A call to update_channel in LDKWatch from rust threw an exception.");
3736         }
3737         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
3738         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
3739         if (get_jenv_res == JNI_EDETACHED) {
3740                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3741         }
3742         return ret_conv;
3743 }
3744 LDKCVec_MonitorEventZ release_pending_monitor_events_LDKWatch_jcall(const void* this_arg) {
3745         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
3746         JNIEnv *env;
3747         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3748         if (get_jenv_res == JNI_EDETACHED) {
3749                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3750         } else {
3751                 DO_ASSERT(get_jenv_res == JNI_OK);
3752         }
3753         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3754         CHECK(obj != NULL);
3755         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->release_pending_monitor_events_meth);
3756         if ((*env)->ExceptionCheck(env)) {
3757                 (*env)->ExceptionDescribe(env);
3758                 (*env)->FatalError(env, "A call to release_pending_monitor_events in LDKWatch from rust threw an exception.");
3759         }
3760         LDKCVec_MonitorEventZ ret_constr;
3761         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
3762         if (ret_constr.datalen > 0)
3763                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
3764         else
3765                 ret_constr.data = NULL;
3766         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
3767         for (size_t o = 0; o < ret_constr.datalen; o++) {
3768                 int64_t ret_conv_14 = ret_vals[o];
3769                 LDKMonitorEvent ret_conv_14_conv = *(LDKMonitorEvent*)(((uint64_t)ret_conv_14) & ~1);
3770                 ret_conv_14_conv = MonitorEvent_clone((LDKMonitorEvent*)(((uint64_t)ret_conv_14) & ~1));
3771                 ret_constr.data[o] = ret_conv_14_conv;
3772         }
3773         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
3774         if (get_jenv_res == JNI_EDETACHED) {
3775                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3776         }
3777         return ret_constr;
3778 }
3779 static void LDKWatch_JCalls_cloned(LDKWatch* new_obj) {
3780         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) new_obj->this_arg;
3781         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3782 }
3783 static inline LDKWatch LDKWatch_init (JNIEnv *env, jclass clz, jobject o) {
3784         jclass c = (*env)->GetObjectClass(env, o);
3785         CHECK(c != NULL);
3786         LDKWatch_JCalls *calls = MALLOC(sizeof(LDKWatch_JCalls), "LDKWatch_JCalls");
3787         atomic_init(&calls->refcnt, 1);
3788         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
3789         calls->o = (*env)->NewWeakGlobalRef(env, o);
3790         calls->watch_channel_meth = (*env)->GetMethodID(env, c, "watch_channel", "(JJ)J");
3791         CHECK(calls->watch_channel_meth != NULL);
3792         calls->update_channel_meth = (*env)->GetMethodID(env, c, "update_channel", "(JJ)J");
3793         CHECK(calls->update_channel_meth != NULL);
3794         calls->release_pending_monitor_events_meth = (*env)->GetMethodID(env, c, "release_pending_monitor_events", "()[J");
3795         CHECK(calls->release_pending_monitor_events_meth != NULL);
3796
3797         LDKWatch ret = {
3798                 .this_arg = (void*) calls,
3799                 .watch_channel = watch_channel_LDKWatch_jcall,
3800                 .update_channel = update_channel_LDKWatch_jcall,
3801                 .release_pending_monitor_events = release_pending_monitor_events_LDKWatch_jcall,
3802                 .free = LDKWatch_JCalls_free,
3803         };
3804         return ret;
3805 }
3806 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKWatch_1new(JNIEnv *env, jclass clz, jobject o) {
3807         LDKWatch *res_ptr = MALLOC(sizeof(LDKWatch), "LDKWatch");
3808         *res_ptr = LDKWatch_init(env, clz, o);
3809         return (uint64_t)res_ptr;
3810 }
3811 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) {
3812         LDKWatch* this_arg_conv = (LDKWatch*)(((uint64_t)this_arg) & ~1);
3813         LDKOutPoint funding_txo_conv;
3814         funding_txo_conv.inner = (void*)(funding_txo & (~1));
3815         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
3816         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
3817         LDKChannelMonitor monitor_conv;
3818         monitor_conv.inner = (void*)(monitor & (~1));
3819         monitor_conv.is_owned = (monitor & 1) || (monitor == 0);
3820         monitor_conv = ChannelMonitor_clone(&monitor_conv);
3821         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
3822         *ret_conv = (this_arg_conv->watch_channel)(this_arg_conv->this_arg, funding_txo_conv, monitor_conv);
3823         return (uint64_t)ret_conv;
3824 }
3825
3826 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) {
3827         LDKWatch* this_arg_conv = (LDKWatch*)(((uint64_t)this_arg) & ~1);
3828         LDKOutPoint funding_txo_conv;
3829         funding_txo_conv.inner = (void*)(funding_txo & (~1));
3830         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
3831         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
3832         LDKChannelMonitorUpdate update_conv;
3833         update_conv.inner = (void*)(update & (~1));
3834         update_conv.is_owned = (update & 1) || (update == 0);
3835         update_conv = ChannelMonitorUpdate_clone(&update_conv);
3836         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
3837         *ret_conv = (this_arg_conv->update_channel)(this_arg_conv->this_arg, funding_txo_conv, update_conv);
3838         return (uint64_t)ret_conv;
3839 }
3840
3841 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Watch_1release_1pending_1monitor_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
3842         LDKWatch* this_arg_conv = (LDKWatch*)(((uint64_t)this_arg) & ~1);
3843         LDKCVec_MonitorEventZ ret_var = (this_arg_conv->release_pending_monitor_events)(this_arg_conv->this_arg);
3844         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
3845         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
3846         for (size_t o = 0; o < ret_var.datalen; o++) {
3847                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
3848                 *ret_conv_14_copy = MonitorEvent_clone(&ret_var.data[o]);
3849                 uint64_t ret_conv_14_ref = (uint64_t)ret_conv_14_copy;
3850                 ret_arr_ptr[o] = ret_conv_14_ref;
3851         }
3852         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
3853         FREE(ret_var.data);
3854         return ret_arr;
3855 }
3856
3857 typedef struct LDKBroadcasterInterface_JCalls {
3858         atomic_size_t refcnt;
3859         JavaVM *vm;
3860         jweak o;
3861         jmethodID broadcast_transaction_meth;
3862 } LDKBroadcasterInterface_JCalls;
3863 static void LDKBroadcasterInterface_JCalls_free(void* this_arg) {
3864         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
3865         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3866                 JNIEnv *env;
3867                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3868                 if (get_jenv_res == JNI_EDETACHED) {
3869                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3870                 } else {
3871                         DO_ASSERT(get_jenv_res == JNI_OK);
3872                 }
3873                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
3874                 if (get_jenv_res == JNI_EDETACHED) {
3875                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3876                 }
3877                 FREE(j_calls);
3878         }
3879 }
3880 void broadcast_transaction_LDKBroadcasterInterface_jcall(const void* this_arg, LDKTransaction tx) {
3881         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
3882         JNIEnv *env;
3883         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3884         if (get_jenv_res == JNI_EDETACHED) {
3885                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3886         } else {
3887                 DO_ASSERT(get_jenv_res == JNI_OK);
3888         }
3889         LDKTransaction tx_var = tx;
3890         int8_tArray tx_arr = (*env)->NewByteArray(env, tx_var.datalen);
3891         (*env)->SetByteArrayRegion(env, tx_arr, 0, tx_var.datalen, tx_var.data);
3892         Transaction_free(tx_var);
3893         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3894         CHECK(obj != NULL);
3895         (*env)->CallVoidMethod(env, obj, j_calls->broadcast_transaction_meth, tx_arr);
3896         if ((*env)->ExceptionCheck(env)) {
3897                 (*env)->ExceptionDescribe(env);
3898                 (*env)->FatalError(env, "A call to broadcast_transaction in LDKBroadcasterInterface from rust threw an exception.");
3899         }
3900         if (get_jenv_res == JNI_EDETACHED) {
3901                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3902         }
3903 }
3904 static void LDKBroadcasterInterface_JCalls_cloned(LDKBroadcasterInterface* new_obj) {
3905         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) new_obj->this_arg;
3906         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3907 }
3908 static inline LDKBroadcasterInterface LDKBroadcasterInterface_init (JNIEnv *env, jclass clz, jobject o) {
3909         jclass c = (*env)->GetObjectClass(env, o);
3910         CHECK(c != NULL);
3911         LDKBroadcasterInterface_JCalls *calls = MALLOC(sizeof(LDKBroadcasterInterface_JCalls), "LDKBroadcasterInterface_JCalls");
3912         atomic_init(&calls->refcnt, 1);
3913         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
3914         calls->o = (*env)->NewWeakGlobalRef(env, o);
3915         calls->broadcast_transaction_meth = (*env)->GetMethodID(env, c, "broadcast_transaction", "([B)V");
3916         CHECK(calls->broadcast_transaction_meth != NULL);
3917
3918         LDKBroadcasterInterface ret = {
3919                 .this_arg = (void*) calls,
3920                 .broadcast_transaction = broadcast_transaction_LDKBroadcasterInterface_jcall,
3921                 .free = LDKBroadcasterInterface_JCalls_free,
3922         };
3923         return ret;
3924 }
3925 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKBroadcasterInterface_1new(JNIEnv *env, jclass clz, jobject o) {
3926         LDKBroadcasterInterface *res_ptr = MALLOC(sizeof(LDKBroadcasterInterface), "LDKBroadcasterInterface");
3927         *res_ptr = LDKBroadcasterInterface_init(env, clz, o);
3928         return (uint64_t)res_ptr;
3929 }
3930 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BroadcasterInterface_1broadcast_1transaction(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray tx) {
3931         LDKBroadcasterInterface* this_arg_conv = (LDKBroadcasterInterface*)(((uint64_t)this_arg) & ~1);
3932         LDKTransaction tx_ref;
3933         tx_ref.datalen = (*env)->GetArrayLength(env, tx);
3934         tx_ref.data = MALLOC(tx_ref.datalen, "LDKTransaction Bytes");
3935         (*env)->GetByteArrayRegion(env, tx, 0, tx_ref.datalen, tx_ref.data);
3936         tx_ref.data_is_owned = true;
3937         (this_arg_conv->broadcast_transaction)(this_arg_conv->this_arg, tx_ref);
3938 }
3939
3940 typedef struct LDKKeysInterface_JCalls {
3941         atomic_size_t refcnt;
3942         JavaVM *vm;
3943         jweak o;
3944         jmethodID get_node_secret_meth;
3945         jmethodID get_destination_script_meth;
3946         jmethodID get_shutdown_scriptpubkey_meth;
3947         jmethodID get_channel_signer_meth;
3948         jmethodID get_secure_random_bytes_meth;
3949         jmethodID read_chan_signer_meth;
3950         jmethodID sign_invoice_meth;
3951 } LDKKeysInterface_JCalls;
3952 static void LDKKeysInterface_JCalls_free(void* this_arg) {
3953         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3954         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3955                 JNIEnv *env;
3956                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3957                 if (get_jenv_res == JNI_EDETACHED) {
3958                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3959                 } else {
3960                         DO_ASSERT(get_jenv_res == JNI_OK);
3961                 }
3962                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
3963                 if (get_jenv_res == JNI_EDETACHED) {
3964                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3965                 }
3966                 FREE(j_calls);
3967         }
3968 }
3969 LDKSecretKey get_node_secret_LDKKeysInterface_jcall(const void* this_arg) {
3970         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3971         JNIEnv *env;
3972         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3973         if (get_jenv_res == JNI_EDETACHED) {
3974                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3975         } else {
3976                 DO_ASSERT(get_jenv_res == JNI_OK);
3977         }
3978         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3979         CHECK(obj != NULL);
3980         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_node_secret_meth);
3981         if ((*env)->ExceptionCheck(env)) {
3982                 (*env)->ExceptionDescribe(env);
3983                 (*env)->FatalError(env, "A call to get_node_secret in LDKKeysInterface from rust threw an exception.");
3984         }
3985         LDKSecretKey ret_ref;
3986         CHECK((*env)->GetArrayLength(env, ret) == 32);
3987         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.bytes);
3988         if (get_jenv_res == JNI_EDETACHED) {
3989                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3990         }
3991         return ret_ref;
3992 }
3993 LDKCVec_u8Z get_destination_script_LDKKeysInterface_jcall(const void* this_arg) {
3994         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3995         JNIEnv *env;
3996         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3997         if (get_jenv_res == JNI_EDETACHED) {
3998                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3999         } else {
4000                 DO_ASSERT(get_jenv_res == JNI_OK);
4001         }
4002         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4003         CHECK(obj != NULL);
4004         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_destination_script_meth);
4005         if ((*env)->ExceptionCheck(env)) {
4006                 (*env)->ExceptionDescribe(env);
4007                 (*env)->FatalError(env, "A call to get_destination_script in LDKKeysInterface from rust threw an exception.");
4008         }
4009         LDKCVec_u8Z ret_ref;
4010         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
4011         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
4012         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
4013         if (get_jenv_res == JNI_EDETACHED) {
4014                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4015         }
4016         return ret_ref;
4017 }
4018 LDKShutdownScript get_shutdown_scriptpubkey_LDKKeysInterface_jcall(const void* this_arg) {
4019         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4020         JNIEnv *env;
4021         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4022         if (get_jenv_res == JNI_EDETACHED) {
4023                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4024         } else {
4025                 DO_ASSERT(get_jenv_res == JNI_OK);
4026         }
4027         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4028         CHECK(obj != NULL);
4029         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_shutdown_scriptpubkey_meth);
4030         if ((*env)->ExceptionCheck(env)) {
4031                 (*env)->ExceptionDescribe(env);
4032                 (*env)->FatalError(env, "A call to get_shutdown_scriptpubkey in LDKKeysInterface from rust threw an exception.");
4033         }
4034         LDKShutdownScript ret_conv;
4035         ret_conv.inner = (void*)(ret & (~1));
4036         ret_conv.is_owned = (ret & 1) || (ret == 0);
4037         ret_conv = ShutdownScript_clone(&ret_conv);
4038         if (get_jenv_res == JNI_EDETACHED) {
4039                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4040         }
4041         return ret_conv;
4042 }
4043 LDKSign get_channel_signer_LDKKeysInterface_jcall(const void* this_arg, bool inbound, uint64_t channel_value_satoshis) {
4044         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4045         JNIEnv *env;
4046         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4047         if (get_jenv_res == JNI_EDETACHED) {
4048                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4049         } else {
4050                 DO_ASSERT(get_jenv_res == JNI_OK);
4051         }
4052         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4053         CHECK(obj != NULL);
4054         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_channel_signer_meth, inbound, channel_value_satoshis);
4055         if ((*env)->ExceptionCheck(env)) {
4056                 (*env)->ExceptionDescribe(env);
4057                 (*env)->FatalError(env, "A call to get_channel_signer in LDKKeysInterface from rust threw an exception.");
4058         }
4059         LDKSign ret_conv = *(LDKSign*)(((uint64_t)ret) & ~1);
4060         ret_conv = Sign_clone(&ret_conv);
4061         if (get_jenv_res == JNI_EDETACHED) {
4062                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4063         }
4064         return ret_conv;
4065 }
4066 LDKThirtyTwoBytes get_secure_random_bytes_LDKKeysInterface_jcall(const void* this_arg) {
4067         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4068         JNIEnv *env;
4069         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4070         if (get_jenv_res == JNI_EDETACHED) {
4071                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4072         } else {
4073                 DO_ASSERT(get_jenv_res == JNI_OK);
4074         }
4075         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4076         CHECK(obj != NULL);
4077         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_secure_random_bytes_meth);
4078         if ((*env)->ExceptionCheck(env)) {
4079                 (*env)->ExceptionDescribe(env);
4080                 (*env)->FatalError(env, "A call to get_secure_random_bytes in LDKKeysInterface from rust threw an exception.");
4081         }
4082         LDKThirtyTwoBytes ret_ref;
4083         CHECK((*env)->GetArrayLength(env, ret) == 32);
4084         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
4085         if (get_jenv_res == JNI_EDETACHED) {
4086                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4087         }
4088         return ret_ref;
4089 }
4090 LDKCResult_SignDecodeErrorZ read_chan_signer_LDKKeysInterface_jcall(const void* this_arg, LDKu8slice reader) {
4091         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4092         JNIEnv *env;
4093         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4094         if (get_jenv_res == JNI_EDETACHED) {
4095                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4096         } else {
4097                 DO_ASSERT(get_jenv_res == JNI_OK);
4098         }
4099         LDKu8slice reader_var = reader;
4100         int8_tArray reader_arr = (*env)->NewByteArray(env, reader_var.datalen);
4101         (*env)->SetByteArrayRegion(env, reader_arr, 0, reader_var.datalen, reader_var.data);
4102         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4103         CHECK(obj != NULL);
4104         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->read_chan_signer_meth, reader_arr);
4105         if ((*env)->ExceptionCheck(env)) {
4106                 (*env)->ExceptionDescribe(env);
4107                 (*env)->FatalError(env, "A call to read_chan_signer in LDKKeysInterface from rust threw an exception.");
4108         }
4109         LDKCResult_SignDecodeErrorZ ret_conv = *(LDKCResult_SignDecodeErrorZ*)(((uint64_t)ret) & ~1);
4110         ret_conv = CResult_SignDecodeErrorZ_clone((LDKCResult_SignDecodeErrorZ*)(((uint64_t)ret) & ~1));
4111         if (get_jenv_res == JNI_EDETACHED) {
4112                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4113         }
4114         return ret_conv;
4115 }
4116 LDKCResult_RecoverableSignatureNoneZ sign_invoice_LDKKeysInterface_jcall(const void* this_arg, LDKCVec_u8Z invoice_preimage) {
4117         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4118         JNIEnv *env;
4119         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4120         if (get_jenv_res == JNI_EDETACHED) {
4121                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4122         } else {
4123                 DO_ASSERT(get_jenv_res == JNI_OK);
4124         }
4125         LDKCVec_u8Z invoice_preimage_var = invoice_preimage;
4126         int8_tArray invoice_preimage_arr = (*env)->NewByteArray(env, invoice_preimage_var.datalen);
4127         (*env)->SetByteArrayRegion(env, invoice_preimage_arr, 0, invoice_preimage_var.datalen, invoice_preimage_var.data);
4128         CVec_u8Z_free(invoice_preimage_var);
4129         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4130         CHECK(obj != NULL);
4131         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_invoice_meth, invoice_preimage_arr);
4132         if ((*env)->ExceptionCheck(env)) {
4133                 (*env)->ExceptionDescribe(env);
4134                 (*env)->FatalError(env, "A call to sign_invoice in LDKKeysInterface from rust threw an exception.");
4135         }
4136         LDKCResult_RecoverableSignatureNoneZ ret_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(((uint64_t)ret) & ~1);
4137         ret_conv = CResult_RecoverableSignatureNoneZ_clone((LDKCResult_RecoverableSignatureNoneZ*)(((uint64_t)ret) & ~1));
4138         if (get_jenv_res == JNI_EDETACHED) {
4139                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4140         }
4141         return ret_conv;
4142 }
4143 static void LDKKeysInterface_JCalls_cloned(LDKKeysInterface* new_obj) {
4144         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) new_obj->this_arg;
4145         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4146 }
4147 static inline LDKKeysInterface LDKKeysInterface_init (JNIEnv *env, jclass clz, jobject o) {
4148         jclass c = (*env)->GetObjectClass(env, o);
4149         CHECK(c != NULL);
4150         LDKKeysInterface_JCalls *calls = MALLOC(sizeof(LDKKeysInterface_JCalls), "LDKKeysInterface_JCalls");
4151         atomic_init(&calls->refcnt, 1);
4152         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
4153         calls->o = (*env)->NewWeakGlobalRef(env, o);
4154         calls->get_node_secret_meth = (*env)->GetMethodID(env, c, "get_node_secret", "()[B");
4155         CHECK(calls->get_node_secret_meth != NULL);
4156         calls->get_destination_script_meth = (*env)->GetMethodID(env, c, "get_destination_script", "()[B");
4157         CHECK(calls->get_destination_script_meth != NULL);
4158         calls->get_shutdown_scriptpubkey_meth = (*env)->GetMethodID(env, c, "get_shutdown_scriptpubkey", "()J");
4159         CHECK(calls->get_shutdown_scriptpubkey_meth != NULL);
4160         calls->get_channel_signer_meth = (*env)->GetMethodID(env, c, "get_channel_signer", "(ZJ)J");
4161         CHECK(calls->get_channel_signer_meth != NULL);
4162         calls->get_secure_random_bytes_meth = (*env)->GetMethodID(env, c, "get_secure_random_bytes", "()[B");
4163         CHECK(calls->get_secure_random_bytes_meth != NULL);
4164         calls->read_chan_signer_meth = (*env)->GetMethodID(env, c, "read_chan_signer", "([B)J");
4165         CHECK(calls->read_chan_signer_meth != NULL);
4166         calls->sign_invoice_meth = (*env)->GetMethodID(env, c, "sign_invoice", "([B)J");
4167         CHECK(calls->sign_invoice_meth != NULL);
4168
4169         LDKKeysInterface ret = {
4170                 .this_arg = (void*) calls,
4171                 .get_node_secret = get_node_secret_LDKKeysInterface_jcall,
4172                 .get_destination_script = get_destination_script_LDKKeysInterface_jcall,
4173                 .get_shutdown_scriptpubkey = get_shutdown_scriptpubkey_LDKKeysInterface_jcall,
4174                 .get_channel_signer = get_channel_signer_LDKKeysInterface_jcall,
4175                 .get_secure_random_bytes = get_secure_random_bytes_LDKKeysInterface_jcall,
4176                 .read_chan_signer = read_chan_signer_LDKKeysInterface_jcall,
4177                 .sign_invoice = sign_invoice_LDKKeysInterface_jcall,
4178                 .free = LDKKeysInterface_JCalls_free,
4179         };
4180         return ret;
4181 }
4182 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKKeysInterface_1new(JNIEnv *env, jclass clz, jobject o) {
4183         LDKKeysInterface *res_ptr = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
4184         *res_ptr = LDKKeysInterface_init(env, clz, o);
4185         return (uint64_t)res_ptr;
4186 }
4187 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1node_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
4188         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
4189         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
4190         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->get_node_secret)(this_arg_conv->this_arg).bytes);
4191         return ret_arr;
4192 }
4193
4194 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1destination_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
4195         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
4196         LDKCVec_u8Z ret_var = (this_arg_conv->get_destination_script)(this_arg_conv->this_arg);
4197         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
4198         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
4199         CVec_u8Z_free(ret_var);
4200         return ret_arr;
4201 }
4202
4203 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1shutdown_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_arg) {
4204         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
4205         LDKShutdownScript ret_var = (this_arg_conv->get_shutdown_scriptpubkey)(this_arg_conv->this_arg);
4206         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4207         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4208         uint64_t ret_ref = (uint64_t)ret_var.inner;
4209         if (ret_var.is_owned) {
4210                 ret_ref |= 1;
4211         }
4212         return ret_ref;
4213 }
4214
4215 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) {
4216         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
4217         LDKSign* ret_ret =MALLOC(sizeof(LDKSign), "LDKSign");
4218         *ret_ret = (this_arg_conv->get_channel_signer)(this_arg_conv->this_arg, inbound, channel_value_satoshis);
4219         return (uint64_t)ret_ret;
4220 }
4221
4222 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1secure_1random_1bytes(JNIEnv *env, jclass clz, int64_t this_arg) {
4223         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
4224         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
4225         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->get_secure_random_bytes)(this_arg_conv->this_arg).data);
4226         return ret_arr;
4227 }
4228
4229 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1read_1chan_1signer(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray reader) {
4230         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
4231         LDKu8slice reader_ref;
4232         reader_ref.datalen = (*env)->GetArrayLength(env, reader);
4233         reader_ref.data = (*env)->GetByteArrayElements (env, reader, NULL);
4234         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
4235         *ret_conv = (this_arg_conv->read_chan_signer)(this_arg_conv->this_arg, reader_ref);
4236         (*env)->ReleaseByteArrayElements(env, reader, (int8_t*)reader_ref.data, 0);
4237         return (uint64_t)ret_conv;
4238 }
4239
4240 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1sign_1invoice(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray invoice_preimage) {
4241         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
4242         LDKCVec_u8Z invoice_preimage_ref;
4243         invoice_preimage_ref.datalen = (*env)->GetArrayLength(env, invoice_preimage);
4244         invoice_preimage_ref.data = MALLOC(invoice_preimage_ref.datalen, "LDKCVec_u8Z Bytes");
4245         (*env)->GetByteArrayRegion(env, invoice_preimage, 0, invoice_preimage_ref.datalen, invoice_preimage_ref.data);
4246         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
4247         *ret_conv = (this_arg_conv->sign_invoice)(this_arg_conv->this_arg, invoice_preimage_ref);
4248         return (uint64_t)ret_conv;
4249 }
4250
4251 typedef struct LDKFeeEstimator_JCalls {
4252         atomic_size_t refcnt;
4253         JavaVM *vm;
4254         jweak o;
4255         jmethodID get_est_sat_per_1000_weight_meth;
4256 } LDKFeeEstimator_JCalls;
4257 static void LDKFeeEstimator_JCalls_free(void* this_arg) {
4258         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
4259         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4260                 JNIEnv *env;
4261                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4262                 if (get_jenv_res == JNI_EDETACHED) {
4263                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4264                 } else {
4265                         DO_ASSERT(get_jenv_res == JNI_OK);
4266                 }
4267                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
4268                 if (get_jenv_res == JNI_EDETACHED) {
4269                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4270                 }
4271                 FREE(j_calls);
4272         }
4273 }
4274 uint32_t get_est_sat_per_1000_weight_LDKFeeEstimator_jcall(const void* this_arg, LDKConfirmationTarget confirmation_target) {
4275         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
4276         JNIEnv *env;
4277         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4278         if (get_jenv_res == JNI_EDETACHED) {
4279                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4280         } else {
4281                 DO_ASSERT(get_jenv_res == JNI_OK);
4282         }
4283         jclass confirmation_target_conv = LDKConfirmationTarget_to_java(env, confirmation_target);
4284         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4285         CHECK(obj != NULL);
4286         int32_t ret = (*env)->CallIntMethod(env, obj, j_calls->get_est_sat_per_1000_weight_meth, confirmation_target_conv);
4287         if ((*env)->ExceptionCheck(env)) {
4288                 (*env)->ExceptionDescribe(env);
4289                 (*env)->FatalError(env, "A call to get_est_sat_per_1000_weight in LDKFeeEstimator from rust threw an exception.");
4290         }
4291         if (get_jenv_res == JNI_EDETACHED) {
4292                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4293         }
4294         return ret;
4295 }
4296 static void LDKFeeEstimator_JCalls_cloned(LDKFeeEstimator* new_obj) {
4297         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) new_obj->this_arg;
4298         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4299 }
4300 static inline LDKFeeEstimator LDKFeeEstimator_init (JNIEnv *env, jclass clz, jobject o) {
4301         jclass c = (*env)->GetObjectClass(env, o);
4302         CHECK(c != NULL);
4303         LDKFeeEstimator_JCalls *calls = MALLOC(sizeof(LDKFeeEstimator_JCalls), "LDKFeeEstimator_JCalls");
4304         atomic_init(&calls->refcnt, 1);
4305         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
4306         calls->o = (*env)->NewWeakGlobalRef(env, o);
4307         calls->get_est_sat_per_1000_weight_meth = (*env)->GetMethodID(env, c, "get_est_sat_per_1000_weight", "(Lorg/ldk/enums/ConfirmationTarget;)I");
4308         CHECK(calls->get_est_sat_per_1000_weight_meth != NULL);
4309
4310         LDKFeeEstimator ret = {
4311                 .this_arg = (void*) calls,
4312                 .get_est_sat_per_1000_weight = get_est_sat_per_1000_weight_LDKFeeEstimator_jcall,
4313                 .free = LDKFeeEstimator_JCalls_free,
4314         };
4315         return ret;
4316 }
4317 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKFeeEstimator_1new(JNIEnv *env, jclass clz, jobject o) {
4318         LDKFeeEstimator *res_ptr = MALLOC(sizeof(LDKFeeEstimator), "LDKFeeEstimator");
4319         *res_ptr = LDKFeeEstimator_init(env, clz, o);
4320         return (uint64_t)res_ptr;
4321 }
4322 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) {
4323         LDKFeeEstimator* this_arg_conv = (LDKFeeEstimator*)(((uint64_t)this_arg) & ~1);
4324         LDKConfirmationTarget confirmation_target_conv = LDKConfirmationTarget_from_java(env, confirmation_target);
4325         int32_t ret_val = (this_arg_conv->get_est_sat_per_1000_weight)(this_arg_conv->this_arg, confirmation_target_conv);
4326         return ret_val;
4327 }
4328
4329 typedef struct LDKLogger_JCalls {
4330         atomic_size_t refcnt;
4331         JavaVM *vm;
4332         jweak o;
4333         jmethodID log_meth;
4334 } LDKLogger_JCalls;
4335 static void LDKLogger_JCalls_free(void* this_arg) {
4336         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
4337         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4338                 JNIEnv *env;
4339                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4340                 if (get_jenv_res == JNI_EDETACHED) {
4341                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4342                 } else {
4343                         DO_ASSERT(get_jenv_res == JNI_OK);
4344                 }
4345                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
4346                 if (get_jenv_res == JNI_EDETACHED) {
4347                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4348                 }
4349                 FREE(j_calls);
4350         }
4351 }
4352 void log_LDKLogger_jcall(const void* this_arg, const char* record) {
4353         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
4354         JNIEnv *env;
4355         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4356         if (get_jenv_res == JNI_EDETACHED) {
4357                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4358         } else {
4359                 DO_ASSERT(get_jenv_res == JNI_OK);
4360         }
4361         const char* record_str = record;
4362         jstring record_conv = str_ref_to_java(env, record_str, strlen(record_str));
4363         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4364         CHECK(obj != NULL);
4365         (*env)->CallVoidMethod(env, obj, j_calls->log_meth, record_conv);
4366         if ((*env)->ExceptionCheck(env)) {
4367                 (*env)->ExceptionDescribe(env);
4368                 (*env)->FatalError(env, "A call to log in LDKLogger from rust threw an exception.");
4369         }
4370         if (get_jenv_res == JNI_EDETACHED) {
4371                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4372         }
4373 }
4374 static void LDKLogger_JCalls_cloned(LDKLogger* new_obj) {
4375         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) new_obj->this_arg;
4376         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4377 }
4378 static inline LDKLogger LDKLogger_init (JNIEnv *env, jclass clz, jobject o) {
4379         jclass c = (*env)->GetObjectClass(env, o);
4380         CHECK(c != NULL);
4381         LDKLogger_JCalls *calls = MALLOC(sizeof(LDKLogger_JCalls), "LDKLogger_JCalls");
4382         atomic_init(&calls->refcnt, 1);
4383         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
4384         calls->o = (*env)->NewWeakGlobalRef(env, o);
4385         calls->log_meth = (*env)->GetMethodID(env, c, "log", "(Ljava/lang/String;)V");
4386         CHECK(calls->log_meth != NULL);
4387
4388         LDKLogger ret = {
4389                 .this_arg = (void*) calls,
4390                 .log = log_LDKLogger_jcall,
4391                 .free = LDKLogger_JCalls_free,
4392         };
4393         return ret;
4394 }
4395 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKLogger_1new(JNIEnv *env, jclass clz, jobject o) {
4396         LDKLogger *res_ptr = MALLOC(sizeof(LDKLogger), "LDKLogger");
4397         *res_ptr = LDKLogger_init(env, clz, o);
4398         return (uint64_t)res_ptr;
4399 }
4400 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1BlockHashChannelManagerZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
4401         LDKC2Tuple_BlockHashChannelManagerZ* ret = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
4402         LDKThirtyTwoBytes a_ref;
4403         CHECK((*env)->GetArrayLength(env, a) == 32);
4404         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
4405         ret->a = a_ref;
4406         LDKChannelManager b_conv;
4407         b_conv.inner = (void*)(b & (~1));
4408         b_conv.is_owned = (b & 1) || (b == 0);
4409         // Warning: we need a move here but no clone is available for LDKChannelManager
4410         ret->b = b_conv;
4411         return (uint64_t)ret;
4412 }
4413 static inline struct LDKThirtyTwoBytes C2Tuple_BlockHashChannelManagerZ_get_a(LDKC2Tuple_BlockHashChannelManagerZ *NONNULL_PTR tuple){
4414         return ThirtyTwoBytes_clone(&tuple->a);
4415 }
4416 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1get_1a(JNIEnv *env, jclass clz, int64_t tuple) {
4417         LDKC2Tuple_BlockHashChannelManagerZ* tuple_conv = (LDKC2Tuple_BlockHashChannelManagerZ*)(tuple & ~1);
4418         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
4419         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_BlockHashChannelManagerZ_get_a(tuple_conv).data);
4420         return ret_arr;
4421 }
4422
4423 static inline struct LDKChannelManager *C2Tuple_BlockHashChannelManagerZ_get_b(LDKC2Tuple_BlockHashChannelManagerZ *NONNULL_PTR tuple){
4424         return &tuple->b;
4425 }
4426 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1get_1b(JNIEnv *env, jclass clz, int64_t tuple) {
4427         LDKC2Tuple_BlockHashChannelManagerZ* tuple_conv = (LDKC2Tuple_BlockHashChannelManagerZ*)(tuple & ~1);
4428         LDKChannelManager ret_var = *C2Tuple_BlockHashChannelManagerZ_get_b(tuple_conv);
4429         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4430         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4431         uint64_t ret_ref = (uint64_t)ret_var.inner & ~1;
4432         return ret_ref;
4433 }
4434
4435 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4436         return ((LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)arg)->result_ok;
4437 }
4438 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4439         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(arg & ~1);
4440         CHECK(val->result_ok);
4441         LDKC2Tuple_BlockHashChannelManagerZ* res_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
4442         *res_conv = (*val->contents.result);
4443         // Warning: we really need to clone here, but no clone is available for LDKC2Tuple_BlockHashChannelManagerZ
4444         return ((uint64_t)res_conv) | 1;
4445 }
4446 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4447         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(arg & ~1);
4448         CHECK(!val->result_ok);
4449         LDKDecodeError err_var = (*val->contents.err);
4450         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4451         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4452         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4453         return err_ref;
4454 }
4455 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelConfigDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4456         return ((LDKCResult_ChannelConfigDecodeErrorZ*)arg)->result_ok;
4457 }
4458 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelConfigDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4459         LDKCResult_ChannelConfigDecodeErrorZ *val = (LDKCResult_ChannelConfigDecodeErrorZ*)(arg & ~1);
4460         CHECK(val->result_ok);
4461         LDKChannelConfig res_var = (*val->contents.result);
4462         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4463         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4464         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4465         return res_ref;
4466 }
4467 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelConfigDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4468         LDKCResult_ChannelConfigDecodeErrorZ *val = (LDKCResult_ChannelConfigDecodeErrorZ*)(arg & ~1);
4469         CHECK(!val->result_ok);
4470         LDKDecodeError err_var = (*val->contents.err);
4471         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4472         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4473         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4474         return err_ref;
4475 }
4476 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OutPointDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4477         return ((LDKCResult_OutPointDecodeErrorZ*)arg)->result_ok;
4478 }
4479 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OutPointDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4480         LDKCResult_OutPointDecodeErrorZ *val = (LDKCResult_OutPointDecodeErrorZ*)(arg & ~1);
4481         CHECK(val->result_ok);
4482         LDKOutPoint res_var = (*val->contents.result);
4483         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4484         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4485         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4486         return res_ref;
4487 }
4488 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OutPointDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4489         LDKCResult_OutPointDecodeErrorZ *val = (LDKCResult_OutPointDecodeErrorZ*)(arg & ~1);
4490         CHECK(!val->result_ok);
4491         LDKDecodeError err_var = (*val->contents.err);
4492         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4493         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4494         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4495         return err_ref;
4496 }
4497 typedef struct LDKType_JCalls {
4498         atomic_size_t refcnt;
4499         JavaVM *vm;
4500         jweak o;
4501         jmethodID type_id_meth;
4502         jmethodID debug_str_meth;
4503         jmethodID write_meth;
4504 } LDKType_JCalls;
4505 static void LDKType_JCalls_free(void* this_arg) {
4506         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
4507         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4508                 JNIEnv *env;
4509                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4510                 if (get_jenv_res == JNI_EDETACHED) {
4511                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4512                 } else {
4513                         DO_ASSERT(get_jenv_res == JNI_OK);
4514                 }
4515                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
4516                 if (get_jenv_res == JNI_EDETACHED) {
4517                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4518                 }
4519                 FREE(j_calls);
4520         }
4521 }
4522 uint16_t type_id_LDKType_jcall(const void* this_arg) {
4523         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
4524         JNIEnv *env;
4525         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4526         if (get_jenv_res == JNI_EDETACHED) {
4527                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4528         } else {
4529                 DO_ASSERT(get_jenv_res == JNI_OK);
4530         }
4531         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4532         CHECK(obj != NULL);
4533         int16_t ret = (*env)->CallShortMethod(env, obj, j_calls->type_id_meth);
4534         if ((*env)->ExceptionCheck(env)) {
4535                 (*env)->ExceptionDescribe(env);
4536                 (*env)->FatalError(env, "A call to type_id in LDKType from rust threw an exception.");
4537         }
4538         if (get_jenv_res == JNI_EDETACHED) {
4539                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4540         }
4541         return ret;
4542 }
4543 LDKStr debug_str_LDKType_jcall(const void* this_arg) {
4544         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
4545         JNIEnv *env;
4546         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4547         if (get_jenv_res == JNI_EDETACHED) {
4548                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4549         } else {
4550                 DO_ASSERT(get_jenv_res == JNI_OK);
4551         }
4552         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4553         CHECK(obj != NULL);
4554         jstring ret = (*env)->CallObjectMethod(env, obj, j_calls->debug_str_meth);
4555         if ((*env)->ExceptionCheck(env)) {
4556                 (*env)->ExceptionDescribe(env);
4557                 (*env)->FatalError(env, "A call to debug_str in LDKType from rust threw an exception.");
4558         }
4559         LDKStr ret_conv = java_to_owned_str(env, ret);
4560         if (get_jenv_res == JNI_EDETACHED) {
4561                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4562         }
4563         return ret_conv;
4564 }
4565 LDKCVec_u8Z write_LDKType_jcall(const void* this_arg) {
4566         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
4567         JNIEnv *env;
4568         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4569         if (get_jenv_res == JNI_EDETACHED) {
4570                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4571         } else {
4572                 DO_ASSERT(get_jenv_res == JNI_OK);
4573         }
4574         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4575         CHECK(obj != NULL);
4576         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->write_meth);
4577         if ((*env)->ExceptionCheck(env)) {
4578                 (*env)->ExceptionDescribe(env);
4579                 (*env)->FatalError(env, "A call to write in LDKType from rust threw an exception.");
4580         }
4581         LDKCVec_u8Z ret_ref;
4582         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
4583         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
4584         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
4585         if (get_jenv_res == JNI_EDETACHED) {
4586                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4587         }
4588         return ret_ref;
4589 }
4590 static void LDKType_JCalls_cloned(LDKType* new_obj) {
4591         LDKType_JCalls *j_calls = (LDKType_JCalls*) new_obj->this_arg;
4592         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4593 }
4594 static inline LDKType LDKType_init (JNIEnv *env, jclass clz, jobject o) {
4595         jclass c = (*env)->GetObjectClass(env, o);
4596         CHECK(c != NULL);
4597         LDKType_JCalls *calls = MALLOC(sizeof(LDKType_JCalls), "LDKType_JCalls");
4598         atomic_init(&calls->refcnt, 1);
4599         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
4600         calls->o = (*env)->NewWeakGlobalRef(env, o);
4601         calls->type_id_meth = (*env)->GetMethodID(env, c, "type_id", "()S");
4602         CHECK(calls->type_id_meth != NULL);
4603         calls->debug_str_meth = (*env)->GetMethodID(env, c, "debug_str", "()Ljava/lang/String;");
4604         CHECK(calls->debug_str_meth != NULL);
4605         calls->write_meth = (*env)->GetMethodID(env, c, "write", "()[B");
4606         CHECK(calls->write_meth != NULL);
4607
4608         LDKType ret = {
4609                 .this_arg = (void*) calls,
4610                 .type_id = type_id_LDKType_jcall,
4611                 .debug_str = debug_str_LDKType_jcall,
4612                 .write = write_LDKType_jcall,
4613                 .cloned = LDKType_JCalls_cloned,
4614                 .free = LDKType_JCalls_free,
4615         };
4616         return ret;
4617 }
4618 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKType_1new(JNIEnv *env, jclass clz, jobject o) {
4619         LDKType *res_ptr = MALLOC(sizeof(LDKType), "LDKType");
4620         *res_ptr = LDKType_init(env, clz, o);
4621         return (uint64_t)res_ptr;
4622 }
4623 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Type_1type_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
4624         LDKType* this_arg_conv = (LDKType*)(((uint64_t)this_arg) & ~1);
4625         int16_t ret_val = (this_arg_conv->type_id)(this_arg_conv->this_arg);
4626         return ret_val;
4627 }
4628
4629 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Type_1debug_1str(JNIEnv *env, jclass clz, int64_t this_arg) {
4630         LDKType* this_arg_conv = (LDKType*)(((uint64_t)this_arg) & ~1);
4631         LDKStr ret_str = (this_arg_conv->debug_str)(this_arg_conv->this_arg);
4632         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
4633         Str_free(ret_str);
4634         return ret_conv;
4635 }
4636
4637 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Type_1write(JNIEnv *env, jclass clz, int64_t this_arg) {
4638         LDKType* this_arg_conv = (LDKType*)(((uint64_t)this_arg) & ~1);
4639         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
4640         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
4641         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
4642         CVec_u8Z_free(ret_var);
4643         return ret_arr;
4644 }
4645
4646 static jclass LDKCOption_TypeZ_Some_class = NULL;
4647 static jmethodID LDKCOption_TypeZ_Some_meth = NULL;
4648 static jclass LDKCOption_TypeZ_None_class = NULL;
4649 static jmethodID LDKCOption_TypeZ_None_meth = NULL;
4650 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1TypeZ_init (JNIEnv *env, jclass clz) {
4651         LDKCOption_TypeZ_Some_class =
4652                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_TypeZ$Some;"));
4653         CHECK(LDKCOption_TypeZ_Some_class != NULL);
4654         LDKCOption_TypeZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_TypeZ_Some_class, "<init>", "(J)V");
4655         CHECK(LDKCOption_TypeZ_Some_meth != NULL);
4656         LDKCOption_TypeZ_None_class =
4657                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_TypeZ$None;"));
4658         CHECK(LDKCOption_TypeZ_None_class != NULL);
4659         LDKCOption_TypeZ_None_meth = (*env)->GetMethodID(env, LDKCOption_TypeZ_None_class, "<init>", "()V");
4660         CHECK(LDKCOption_TypeZ_None_meth != NULL);
4661 }
4662 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1TypeZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
4663         LDKCOption_TypeZ *obj = (LDKCOption_TypeZ*)(ptr & ~1);
4664         switch(obj->tag) {
4665                 case LDKCOption_TypeZ_Some: {
4666                         LDKType* some_ret =MALLOC(sizeof(LDKType), "LDKType");
4667                         *some_ret = Type_clone(&obj->some);
4668                         return (*env)->NewObject(env, LDKCOption_TypeZ_Some_class, LDKCOption_TypeZ_Some_meth, (uint64_t)some_ret);
4669                 }
4670                 case LDKCOption_TypeZ_None: {
4671                         return (*env)->NewObject(env, LDKCOption_TypeZ_None_class, LDKCOption_TypeZ_None_meth);
4672                 }
4673                 default: abort();
4674         }
4675 }
4676 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1COption_1TypeZDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4677         return ((LDKCResult_COption_TypeZDecodeErrorZ*)arg)->result_ok;
4678 }
4679 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1COption_1TypeZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4680         LDKCResult_COption_TypeZDecodeErrorZ *val = (LDKCResult_COption_TypeZDecodeErrorZ*)(arg & ~1);
4681         CHECK(val->result_ok);
4682         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
4683         return res_ref;
4684 }
4685 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1COption_1TypeZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4686         LDKCResult_COption_TypeZDecodeErrorZ *val = (LDKCResult_COption_TypeZDecodeErrorZ*)(arg & ~1);
4687         CHECK(!val->result_ok);
4688         LDKDecodeError err_var = (*val->contents.err);
4689         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4690         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4691         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4692         return err_ref;
4693 }
4694 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SiPrefixNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4695         return ((LDKCResult_SiPrefixNoneZ*)arg)->result_ok;
4696 }
4697 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SiPrefixNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4698         LDKCResult_SiPrefixNoneZ *val = (LDKCResult_SiPrefixNoneZ*)(arg & ~1);
4699         CHECK(val->result_ok);
4700         jclass res_conv = LDKSiPrefix_to_java(env, (*val->contents.result));
4701         return res_conv;
4702 }
4703 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SiPrefixNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4704         LDKCResult_SiPrefixNoneZ *val = (LDKCResult_SiPrefixNoneZ*)(arg & ~1);
4705         CHECK(!val->result_ok);
4706         return *val->contents.err;
4707 }
4708 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4709         return ((LDKCResult_InvoiceNoneZ*)arg)->result_ok;
4710 }
4711 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4712         LDKCResult_InvoiceNoneZ *val = (LDKCResult_InvoiceNoneZ*)(arg & ~1);
4713         CHECK(val->result_ok);
4714         LDKInvoice res_var = (*val->contents.result);
4715         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4716         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4717         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4718         return res_ref;
4719 }
4720 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4721         LDKCResult_InvoiceNoneZ *val = (LDKCResult_InvoiceNoneZ*)(arg & ~1);
4722         CHECK(!val->result_ok);
4723         return *val->contents.err;
4724 }
4725 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignedRawInvoiceNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4726         return ((LDKCResult_SignedRawInvoiceNoneZ*)arg)->result_ok;
4727 }
4728 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignedRawInvoiceNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4729         LDKCResult_SignedRawInvoiceNoneZ *val = (LDKCResult_SignedRawInvoiceNoneZ*)(arg & ~1);
4730         CHECK(val->result_ok);
4731         LDKSignedRawInvoice res_var = (*val->contents.result);
4732         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4733         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4734         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4735         return res_ref;
4736 }
4737 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignedRawInvoiceNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4738         LDKCResult_SignedRawInvoiceNoneZ *val = (LDKCResult_SignedRawInvoiceNoneZ*)(arg & ~1);
4739         CHECK(!val->result_ok);
4740         return *val->contents.err;
4741 }
4742 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) {
4743         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
4744         LDKRawInvoice a_conv;
4745         a_conv.inner = (void*)(a & (~1));
4746         a_conv.is_owned = (a & 1) || (a == 0);
4747         a_conv = RawInvoice_clone(&a_conv);
4748         ret->a = a_conv;
4749         LDKThirtyTwoBytes b_ref;
4750         CHECK((*env)->GetArrayLength(env, b) == 32);
4751         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
4752         ret->b = b_ref;
4753         LDKInvoiceSignature c_conv;
4754         c_conv.inner = (void*)(c & (~1));
4755         c_conv.is_owned = (c & 1) || (c == 0);
4756         c_conv = InvoiceSignature_clone(&c_conv);
4757         ret->c = c_conv;
4758         return (uint64_t)ret;
4759 }
4760 static inline struct LDKRawInvoice C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR tuple){
4761         return RawInvoice_clone(&tuple->a);
4762 }
4763 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1a(JNIEnv *env, jclass clz, int64_t tuple) {
4764         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* tuple_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(tuple & ~1);
4765         LDKRawInvoice ret_var = C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(tuple_conv);
4766         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4767         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4768         uint64_t ret_ref = (uint64_t)ret_var.inner;
4769         if (ret_var.is_owned) {
4770                 ret_ref |= 1;
4771         }
4772         return ret_ref;
4773 }
4774
4775 static inline struct LDKThirtyTwoBytes C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR tuple){
4776         return ThirtyTwoBytes_clone(&tuple->b);
4777 }
4778 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1b(JNIEnv *env, jclass clz, int64_t tuple) {
4779         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* tuple_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(tuple & ~1);
4780         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
4781         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(tuple_conv).data);
4782         return ret_arr;
4783 }
4784
4785 static inline struct LDKInvoiceSignature C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR tuple){
4786         return InvoiceSignature_clone(&tuple->c);
4787 }
4788 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1c(JNIEnv *env, jclass clz, int64_t tuple) {
4789         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* tuple_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(tuple & ~1);
4790         LDKInvoiceSignature ret_var = C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(tuple_conv);
4791         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4792         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4793         uint64_t ret_ref = (uint64_t)ret_var.inner;
4794         if (ret_var.is_owned) {
4795                 ret_ref |= 1;
4796         }
4797         return ret_ref;
4798 }
4799
4800 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PayeePubKeyErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4801         return ((LDKCResult_PayeePubKeyErrorZ*)arg)->result_ok;
4802 }
4803 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PayeePubKeyErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4804         LDKCResult_PayeePubKeyErrorZ *val = (LDKCResult_PayeePubKeyErrorZ*)(arg & ~1);
4805         CHECK(val->result_ok);
4806         LDKPayeePubKey res_var = (*val->contents.result);
4807         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4808         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4809         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4810         return res_ref;
4811 }
4812 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PayeePubKeyErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4813         LDKCResult_PayeePubKeyErrorZ *val = (LDKCResult_PayeePubKeyErrorZ*)(arg & ~1);
4814         CHECK(!val->result_ok);
4815         jclass err_conv = LDKSecp256k1Error_to_java(env, (*val->contents.err));
4816         return err_conv;
4817 }
4818 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1PrivateRouteZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
4819         LDKCVec_PrivateRouteZ *ret = MALLOC(sizeof(LDKCVec_PrivateRouteZ), "LDKCVec_PrivateRouteZ");
4820         ret->datalen = (*env)->GetArrayLength(env, elems);
4821         if (ret->datalen == 0) {
4822                 ret->data = NULL;
4823         } else {
4824                 ret->data = MALLOC(sizeof(LDKPrivateRoute) * ret->datalen, "LDKCVec_PrivateRouteZ Data");
4825                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
4826                 for (size_t i = 0; i < ret->datalen; i++) {
4827                         int64_t arr_elem = java_elems[i];
4828                         LDKPrivateRoute arr_elem_conv;
4829                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
4830                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
4831                         arr_elem_conv = PrivateRoute_clone(&arr_elem_conv);
4832                         ret->data[i] = arr_elem_conv;
4833                 }
4834                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
4835         }
4836         return (uint64_t)ret;
4837 }
4838 static inline LDKCVec_PrivateRouteZ CVec_PrivateRouteZ_clone(const LDKCVec_PrivateRouteZ *orig) {
4839         LDKCVec_PrivateRouteZ ret = { .data = MALLOC(sizeof(LDKPrivateRoute) * orig->datalen, "LDKCVec_PrivateRouteZ clone bytes"), .datalen = orig->datalen };
4840         for (size_t i = 0; i < ret.datalen; i++) {
4841                 ret.data[i] = PrivateRoute_clone(&orig->data[i]);
4842         }
4843         return ret;
4844 }
4845 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PositiveTimestampCreationErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4846         return ((LDKCResult_PositiveTimestampCreationErrorZ*)arg)->result_ok;
4847 }
4848 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PositiveTimestampCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4849         LDKCResult_PositiveTimestampCreationErrorZ *val = (LDKCResult_PositiveTimestampCreationErrorZ*)(arg & ~1);
4850         CHECK(val->result_ok);
4851         LDKPositiveTimestamp res_var = (*val->contents.result);
4852         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4853         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4854         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4855         return res_ref;
4856 }
4857 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PositiveTimestampCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4858         LDKCResult_PositiveTimestampCreationErrorZ *val = (LDKCResult_PositiveTimestampCreationErrorZ*)(arg & ~1);
4859         CHECK(!val->result_ok);
4860         jclass err_conv = LDKCreationError_to_java(env, (*val->contents.err));
4861         return err_conv;
4862 }
4863 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneSemanticErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4864         return ((LDKCResult_NoneSemanticErrorZ*)arg)->result_ok;
4865 }
4866 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneSemanticErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4867         LDKCResult_NoneSemanticErrorZ *val = (LDKCResult_NoneSemanticErrorZ*)(arg & ~1);
4868         CHECK(val->result_ok);
4869         return *val->contents.result;
4870 }
4871 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneSemanticErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4872         LDKCResult_NoneSemanticErrorZ *val = (LDKCResult_NoneSemanticErrorZ*)(arg & ~1);
4873         CHECK(!val->result_ok);
4874         jclass err_conv = LDKSemanticError_to_java(env, (*val->contents.err));
4875         return err_conv;
4876 }
4877 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceSemanticErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4878         return ((LDKCResult_InvoiceSemanticErrorZ*)arg)->result_ok;
4879 }
4880 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceSemanticErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4881         LDKCResult_InvoiceSemanticErrorZ *val = (LDKCResult_InvoiceSemanticErrorZ*)(arg & ~1);
4882         CHECK(val->result_ok);
4883         LDKInvoice res_var = (*val->contents.result);
4884         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4885         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4886         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4887         return res_ref;
4888 }
4889 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceSemanticErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4890         LDKCResult_InvoiceSemanticErrorZ *val = (LDKCResult_InvoiceSemanticErrorZ*)(arg & ~1);
4891         CHECK(!val->result_ok);
4892         jclass err_conv = LDKSemanticError_to_java(env, (*val->contents.err));
4893         return err_conv;
4894 }
4895 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DescriptionCreationErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4896         return ((LDKCResult_DescriptionCreationErrorZ*)arg)->result_ok;
4897 }
4898 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DescriptionCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4899         LDKCResult_DescriptionCreationErrorZ *val = (LDKCResult_DescriptionCreationErrorZ*)(arg & ~1);
4900         CHECK(val->result_ok);
4901         LDKDescription res_var = (*val->contents.result);
4902         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4903         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4904         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4905         return res_ref;
4906 }
4907 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DescriptionCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4908         LDKCResult_DescriptionCreationErrorZ *val = (LDKCResult_DescriptionCreationErrorZ*)(arg & ~1);
4909         CHECK(!val->result_ok);
4910         jclass err_conv = LDKCreationError_to_java(env, (*val->contents.err));
4911         return err_conv;
4912 }
4913 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ExpiryTimeCreationErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4914         return ((LDKCResult_ExpiryTimeCreationErrorZ*)arg)->result_ok;
4915 }
4916 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ExpiryTimeCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4917         LDKCResult_ExpiryTimeCreationErrorZ *val = (LDKCResult_ExpiryTimeCreationErrorZ*)(arg & ~1);
4918         CHECK(val->result_ok);
4919         LDKExpiryTime res_var = (*val->contents.result);
4920         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4921         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4922         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4923         return res_ref;
4924 }
4925 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ExpiryTimeCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4926         LDKCResult_ExpiryTimeCreationErrorZ *val = (LDKCResult_ExpiryTimeCreationErrorZ*)(arg & ~1);
4927         CHECK(!val->result_ok);
4928         jclass err_conv = LDKCreationError_to_java(env, (*val->contents.err));
4929         return err_conv;
4930 }
4931 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PrivateRouteCreationErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4932         return ((LDKCResult_PrivateRouteCreationErrorZ*)arg)->result_ok;
4933 }
4934 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PrivateRouteCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4935         LDKCResult_PrivateRouteCreationErrorZ *val = (LDKCResult_PrivateRouteCreationErrorZ*)(arg & ~1);
4936         CHECK(val->result_ok);
4937         LDKPrivateRoute res_var = (*val->contents.result);
4938         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4939         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4940         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4941         return res_ref;
4942 }
4943 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PrivateRouteCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4944         LDKCResult_PrivateRouteCreationErrorZ *val = (LDKCResult_PrivateRouteCreationErrorZ*)(arg & ~1);
4945         CHECK(!val->result_ok);
4946         jclass err_conv = LDKCreationError_to_java(env, (*val->contents.err));
4947         return err_conv;
4948 }
4949 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1StringErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4950         return ((LDKCResult_StringErrorZ*)arg)->result_ok;
4951 }
4952 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_LDKCResult_1StringErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4953         LDKCResult_StringErrorZ *val = (LDKCResult_StringErrorZ*)(arg & ~1);
4954         CHECK(val->result_ok);
4955         LDKStr res_str = (*val->contents.result);
4956         jstring res_conv = str_ref_to_java(env, res_str.chars, res_str.len);
4957         return res_conv;
4958 }
4959 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1StringErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4960         LDKCResult_StringErrorZ *val = (LDKCResult_StringErrorZ*)(arg & ~1);
4961         CHECK(!val->result_ok);
4962         jclass err_conv = LDKSecp256k1Error_to_java(env, (*val->contents.err));
4963         return err_conv;
4964 }
4965 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelMonitorUpdateDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4966         return ((LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)arg)->result_ok;
4967 }
4968 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelMonitorUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4969         LDKCResult_ChannelMonitorUpdateDecodeErrorZ *val = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(arg & ~1);
4970         CHECK(val->result_ok);
4971         LDKChannelMonitorUpdate res_var = (*val->contents.result);
4972         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4973         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4974         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4975         return res_ref;
4976 }
4977 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelMonitorUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4978         LDKCResult_ChannelMonitorUpdateDecodeErrorZ *val = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(arg & ~1);
4979         CHECK(!val->result_ok);
4980         LDKDecodeError err_var = (*val->contents.err);
4981         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4982         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4983         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4984         return err_ref;
4985 }
4986 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCUpdateDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4987         return ((LDKCResult_HTLCUpdateDecodeErrorZ*)arg)->result_ok;
4988 }
4989 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4990         LDKCResult_HTLCUpdateDecodeErrorZ *val = (LDKCResult_HTLCUpdateDecodeErrorZ*)(arg & ~1);
4991         CHECK(val->result_ok);
4992         LDKHTLCUpdate res_var = (*val->contents.result);
4993         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4994         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4995         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4996         return res_ref;
4997 }
4998 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4999         LDKCResult_HTLCUpdateDecodeErrorZ *val = (LDKCResult_HTLCUpdateDecodeErrorZ*)(arg & ~1);
5000         CHECK(!val->result_ok);
5001         LDKDecodeError err_var = (*val->contents.err);
5002         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5003         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5004         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5005         return err_ref;
5006 }
5007 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneMonitorUpdateErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5008         return ((LDKCResult_NoneMonitorUpdateErrorZ*)arg)->result_ok;
5009 }
5010 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneMonitorUpdateErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5011         LDKCResult_NoneMonitorUpdateErrorZ *val = (LDKCResult_NoneMonitorUpdateErrorZ*)(arg & ~1);
5012         CHECK(val->result_ok);
5013         return *val->contents.result;
5014 }
5015 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneMonitorUpdateErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5016         LDKCResult_NoneMonitorUpdateErrorZ *val = (LDKCResult_NoneMonitorUpdateErrorZ*)(arg & ~1);
5017         CHECK(!val->result_ok);
5018         LDKMonitorUpdateError err_var = (*val->contents.err);
5019         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5020         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5021         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5022         return err_ref;
5023 }
5024 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1OutPointScriptZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
5025         LDKC2Tuple_OutPointScriptZ* ret = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
5026         LDKOutPoint a_conv;
5027         a_conv.inner = (void*)(a & (~1));
5028         a_conv.is_owned = (a & 1) || (a == 0);
5029         a_conv = OutPoint_clone(&a_conv);
5030         ret->a = a_conv;
5031         LDKCVec_u8Z b_ref;
5032         b_ref.datalen = (*env)->GetArrayLength(env, b);
5033         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
5034         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
5035         ret->b = b_ref;
5036         return (uint64_t)ret;
5037 }
5038 static inline struct LDKOutPoint C2Tuple_OutPointScriptZ_get_a(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR tuple){
5039         return OutPoint_clone(&tuple->a);
5040 }
5041 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1get_1a(JNIEnv *env, jclass clz, int64_t tuple) {
5042         LDKC2Tuple_OutPointScriptZ* tuple_conv = (LDKC2Tuple_OutPointScriptZ*)(tuple & ~1);
5043         LDKOutPoint ret_var = C2Tuple_OutPointScriptZ_get_a(tuple_conv);
5044         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5045         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5046         uint64_t ret_ref = (uint64_t)ret_var.inner;
5047         if (ret_var.is_owned) {
5048                 ret_ref |= 1;
5049         }
5050         return ret_ref;
5051 }
5052
5053 static inline struct LDKCVec_u8Z C2Tuple_OutPointScriptZ_get_b(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR tuple){
5054         return CVec_u8Z_clone(&tuple->b);
5055 }
5056 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1get_1b(JNIEnv *env, jclass clz, int64_t tuple) {
5057         LDKC2Tuple_OutPointScriptZ* tuple_conv = (LDKC2Tuple_OutPointScriptZ*)(tuple & ~1);
5058         LDKCVec_u8Z ret_var = C2Tuple_OutPointScriptZ_get_b(tuple_conv);
5059         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
5060         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
5061         CVec_u8Z_free(ret_var);
5062         return ret_arr;
5063 }
5064
5065 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1u32ScriptZ_1new(JNIEnv *env, jclass clz, int32_t a, int8_tArray b) {
5066         LDKC2Tuple_u32ScriptZ* ret = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
5067         ret->a = a;
5068         LDKCVec_u8Z b_ref;
5069         b_ref.datalen = (*env)->GetArrayLength(env, b);
5070         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
5071         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
5072         ret->b = b_ref;
5073         return (uint64_t)ret;
5074 }
5075 static inline uint32_t C2Tuple_u32ScriptZ_get_a(LDKC2Tuple_u32ScriptZ *NONNULL_PTR tuple){
5076         return tuple->a;
5077 }
5078 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1get_1a(JNIEnv *env, jclass clz, int64_t tuple) {
5079         LDKC2Tuple_u32ScriptZ* tuple_conv = (LDKC2Tuple_u32ScriptZ*)(tuple & ~1);
5080         int32_t ret_val = C2Tuple_u32ScriptZ_get_a(tuple_conv);
5081         return ret_val;
5082 }
5083
5084 static inline struct LDKCVec_u8Z C2Tuple_u32ScriptZ_get_b(LDKC2Tuple_u32ScriptZ *NONNULL_PTR tuple){
5085         return CVec_u8Z_clone(&tuple->b);
5086 }
5087 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1get_1b(JNIEnv *env, jclass clz, int64_t tuple) {
5088         LDKC2Tuple_u32ScriptZ* tuple_conv = (LDKC2Tuple_u32ScriptZ*)(tuple & ~1);
5089         LDKCVec_u8Z ret_var = C2Tuple_u32ScriptZ_get_b(tuple_conv);
5090         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
5091         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
5092         CVec_u8Z_free(ret_var);
5093         return ret_arr;
5094 }
5095
5096 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1u32ScriptZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
5097         LDKCVec_C2Tuple_u32ScriptZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_u32ScriptZZ), "LDKCVec_C2Tuple_u32ScriptZZ");
5098         ret->datalen = (*env)->GetArrayLength(env, elems);
5099         if (ret->datalen == 0) {
5100                 ret->data = NULL;
5101         } else {
5102                 ret->data = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ) * ret->datalen, "LDKCVec_C2Tuple_u32ScriptZZ Data");
5103                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
5104                 for (size_t i = 0; i < ret->datalen; i++) {
5105                         int64_t arr_elem = java_elems[i];
5106                         LDKC2Tuple_u32ScriptZ arr_elem_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)arr_elem) & ~1);
5107                         arr_elem_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)(((uint64_t)arr_elem) & ~1));
5108                         ret->data[i] = arr_elem_conv;
5109                 }
5110                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
5111         }
5112         return (uint64_t)ret;
5113 }
5114 static inline LDKCVec_C2Tuple_u32ScriptZZ CVec_C2Tuple_u32ScriptZZ_clone(const LDKCVec_C2Tuple_u32ScriptZZ *orig) {
5115         LDKCVec_C2Tuple_u32ScriptZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ) * orig->datalen, "LDKCVec_C2Tuple_u32ScriptZZ clone bytes"), .datalen = orig->datalen };
5116         for (size_t i = 0; i < ret.datalen; i++) {
5117                 ret.data[i] = C2Tuple_u32ScriptZ_clone(&orig->data[i]);
5118         }
5119         return ret;
5120 }
5121 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
5122         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
5123         LDKThirtyTwoBytes a_ref;
5124         CHECK((*env)->GetArrayLength(env, a) == 32);
5125         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
5126         ret->a = a_ref;
5127         LDKCVec_C2Tuple_u32ScriptZZ b_constr;
5128         b_constr.datalen = (*env)->GetArrayLength(env, b);
5129         if (b_constr.datalen > 0)
5130                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
5131         else
5132                 b_constr.data = NULL;
5133         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
5134         for (size_t v = 0; v < b_constr.datalen; v++) {
5135                 int64_t b_conv_21 = b_vals[v];
5136                 LDKC2Tuple_u32ScriptZ b_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_21) & ~1);
5137                 b_conv_21_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_21) & ~1));
5138                 b_constr.data[v] = b_conv_21_conv;
5139         }
5140         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
5141         ret->b = b_constr;
5142         return (uint64_t)ret;
5143 }
5144 static inline struct LDKThirtyTwoBytes C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR tuple){
5145         return ThirtyTwoBytes_clone(&tuple->a);
5146 }
5147 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1get_1a(JNIEnv *env, jclass clz, int64_t tuple) {
5148         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* tuple_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(tuple & ~1);
5149         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5150         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(tuple_conv).data);
5151         return ret_arr;
5152 }
5153
5154 static inline struct LDKCVec_C2Tuple_u32ScriptZZ C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR tuple){
5155         return CVec_C2Tuple_u32ScriptZZ_clone(&tuple->b);
5156 }
5157 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1get_1b(JNIEnv *env, jclass clz, int64_t tuple) {
5158         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* tuple_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(tuple & ~1);
5159         LDKCVec_C2Tuple_u32ScriptZZ ret_var = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(tuple_conv);
5160         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
5161         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
5162         for (size_t v = 0; v < ret_var.datalen; v++) {
5163                 LDKC2Tuple_u32ScriptZ* ret_conv_21_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
5164                 *ret_conv_21_conv = ret_var.data[v];
5165                 ret_arr_ptr[v] = ((uint64_t)ret_conv_21_conv);
5166         }
5167         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
5168         FREE(ret_var.data);
5169         return ret_arr;
5170 }
5171
5172 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
5173         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ");
5174         ret->datalen = (*env)->GetArrayLength(env, elems);
5175         if (ret->datalen == 0) {
5176                 ret->data = NULL;
5177         } else {
5178                 ret->data = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ) * ret->datalen, "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ Data");
5179                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
5180                 for (size_t i = 0; i < ret->datalen; i++) {
5181                         int64_t arr_elem = java_elems[i];
5182                         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ arr_elem_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)arr_elem) & ~1);
5183                         arr_elem_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone((LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)arr_elem) & ~1));
5184                         ret->data[i] = arr_elem_conv;
5185                 }
5186                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
5187         }
5188         return (uint64_t)ret;
5189 }
5190 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ *orig) {
5191         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 };
5192         for (size_t i = 0; i < ret.datalen; i++) {
5193                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(&orig->data[i]);
5194         }
5195         return ret;
5196 }
5197 static jclass LDKPaymentPurpose_InvoicePayment_class = NULL;
5198 static jmethodID LDKPaymentPurpose_InvoicePayment_meth = NULL;
5199 static jclass LDKPaymentPurpose_SpontaneousPayment_class = NULL;
5200 static jmethodID LDKPaymentPurpose_SpontaneousPayment_meth = NULL;
5201 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKPaymentPurpose_init (JNIEnv *env, jclass clz) {
5202         LDKPaymentPurpose_InvoicePayment_class =
5203                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentPurpose$InvoicePayment;"));
5204         CHECK(LDKPaymentPurpose_InvoicePayment_class != NULL);
5205         LDKPaymentPurpose_InvoicePayment_meth = (*env)->GetMethodID(env, LDKPaymentPurpose_InvoicePayment_class, "<init>", "([B[BJ)V");
5206         CHECK(LDKPaymentPurpose_InvoicePayment_meth != NULL);
5207         LDKPaymentPurpose_SpontaneousPayment_class =
5208                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentPurpose$SpontaneousPayment;"));
5209         CHECK(LDKPaymentPurpose_SpontaneousPayment_class != NULL);
5210         LDKPaymentPurpose_SpontaneousPayment_meth = (*env)->GetMethodID(env, LDKPaymentPurpose_SpontaneousPayment_class, "<init>", "([B)V");
5211         CHECK(LDKPaymentPurpose_SpontaneousPayment_meth != NULL);
5212 }
5213 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPaymentPurpose_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
5214         LDKPaymentPurpose *obj = (LDKPaymentPurpose*)(ptr & ~1);
5215         switch(obj->tag) {
5216                 case LDKPaymentPurpose_InvoicePayment: {
5217                         int8_tArray payment_preimage_arr = (*env)->NewByteArray(env, 32);
5218                         (*env)->SetByteArrayRegion(env, payment_preimage_arr, 0, 32, obj->invoice_payment.payment_preimage.data);
5219                         int8_tArray payment_secret_arr = (*env)->NewByteArray(env, 32);
5220                         (*env)->SetByteArrayRegion(env, payment_secret_arr, 0, 32, obj->invoice_payment.payment_secret.data);
5221                         return (*env)->NewObject(env, LDKPaymentPurpose_InvoicePayment_class, LDKPaymentPurpose_InvoicePayment_meth, payment_preimage_arr, payment_secret_arr, obj->invoice_payment.user_payment_id);
5222                 }
5223                 case LDKPaymentPurpose_SpontaneousPayment: {
5224                         int8_tArray spontaneous_payment_arr = (*env)->NewByteArray(env, 32);
5225                         (*env)->SetByteArrayRegion(env, spontaneous_payment_arr, 0, 32, obj->spontaneous_payment.data);
5226                         return (*env)->NewObject(env, LDKPaymentPurpose_SpontaneousPayment_class, LDKPaymentPurpose_SpontaneousPayment_meth, spontaneous_payment_arr);
5227                 }
5228                 default: abort();
5229         }
5230 }
5231 static jclass LDKClosureReason_CounterpartyForceClosed_class = NULL;
5232 static jmethodID LDKClosureReason_CounterpartyForceClosed_meth = NULL;
5233 static jclass LDKClosureReason_HolderForceClosed_class = NULL;
5234 static jmethodID LDKClosureReason_HolderForceClosed_meth = NULL;
5235 static jclass LDKClosureReason_CooperativeClosure_class = NULL;
5236 static jmethodID LDKClosureReason_CooperativeClosure_meth = NULL;
5237 static jclass LDKClosureReason_CommitmentTxConfirmed_class = NULL;
5238 static jmethodID LDKClosureReason_CommitmentTxConfirmed_meth = NULL;
5239 static jclass LDKClosureReason_ProcessingError_class = NULL;
5240 static jmethodID LDKClosureReason_ProcessingError_meth = NULL;
5241 static jclass LDKClosureReason_DisconnectedPeer_class = NULL;
5242 static jmethodID LDKClosureReason_DisconnectedPeer_meth = NULL;
5243 static jclass LDKClosureReason_OutdatedChannelManager_class = NULL;
5244 static jmethodID LDKClosureReason_OutdatedChannelManager_meth = NULL;
5245 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKClosureReason_init (JNIEnv *env, jclass clz) {
5246         LDKClosureReason_CounterpartyForceClosed_class =
5247                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKClosureReason$CounterpartyForceClosed;"));
5248         CHECK(LDKClosureReason_CounterpartyForceClosed_class != NULL);
5249         LDKClosureReason_CounterpartyForceClosed_meth = (*env)->GetMethodID(env, LDKClosureReason_CounterpartyForceClosed_class, "<init>", "(Ljava/lang/String;)V");
5250         CHECK(LDKClosureReason_CounterpartyForceClosed_meth != NULL);
5251         LDKClosureReason_HolderForceClosed_class =
5252                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKClosureReason$HolderForceClosed;"));
5253         CHECK(LDKClosureReason_HolderForceClosed_class != NULL);
5254         LDKClosureReason_HolderForceClosed_meth = (*env)->GetMethodID(env, LDKClosureReason_HolderForceClosed_class, "<init>", "()V");
5255         CHECK(LDKClosureReason_HolderForceClosed_meth != NULL);
5256         LDKClosureReason_CooperativeClosure_class =
5257                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKClosureReason$CooperativeClosure;"));
5258         CHECK(LDKClosureReason_CooperativeClosure_class != NULL);
5259         LDKClosureReason_CooperativeClosure_meth = (*env)->GetMethodID(env, LDKClosureReason_CooperativeClosure_class, "<init>", "()V");
5260         CHECK(LDKClosureReason_CooperativeClosure_meth != NULL);
5261         LDKClosureReason_CommitmentTxConfirmed_class =
5262                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKClosureReason$CommitmentTxConfirmed;"));
5263         CHECK(LDKClosureReason_CommitmentTxConfirmed_class != NULL);
5264         LDKClosureReason_CommitmentTxConfirmed_meth = (*env)->GetMethodID(env, LDKClosureReason_CommitmentTxConfirmed_class, "<init>", "()V");
5265         CHECK(LDKClosureReason_CommitmentTxConfirmed_meth != NULL);
5266         LDKClosureReason_ProcessingError_class =
5267                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKClosureReason$ProcessingError;"));
5268         CHECK(LDKClosureReason_ProcessingError_class != NULL);
5269         LDKClosureReason_ProcessingError_meth = (*env)->GetMethodID(env, LDKClosureReason_ProcessingError_class, "<init>", "(Ljava/lang/String;)V");
5270         CHECK(LDKClosureReason_ProcessingError_meth != NULL);
5271         LDKClosureReason_DisconnectedPeer_class =
5272                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKClosureReason$DisconnectedPeer;"));
5273         CHECK(LDKClosureReason_DisconnectedPeer_class != NULL);
5274         LDKClosureReason_DisconnectedPeer_meth = (*env)->GetMethodID(env, LDKClosureReason_DisconnectedPeer_class, "<init>", "()V");
5275         CHECK(LDKClosureReason_DisconnectedPeer_meth != NULL);
5276         LDKClosureReason_OutdatedChannelManager_class =
5277                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKClosureReason$OutdatedChannelManager;"));
5278         CHECK(LDKClosureReason_OutdatedChannelManager_class != NULL);
5279         LDKClosureReason_OutdatedChannelManager_meth = (*env)->GetMethodID(env, LDKClosureReason_OutdatedChannelManager_class, "<init>", "()V");
5280         CHECK(LDKClosureReason_OutdatedChannelManager_meth != NULL);
5281 }
5282 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKClosureReason_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
5283         LDKClosureReason *obj = (LDKClosureReason*)(ptr & ~1);
5284         switch(obj->tag) {
5285                 case LDKClosureReason_CounterpartyForceClosed: {
5286                         LDKStr peer_msg_str = obj->counterparty_force_closed.peer_msg;
5287                         jstring peer_msg_conv = str_ref_to_java(env, peer_msg_str.chars, peer_msg_str.len);
5288                         return (*env)->NewObject(env, LDKClosureReason_CounterpartyForceClosed_class, LDKClosureReason_CounterpartyForceClosed_meth, peer_msg_conv);
5289                 }
5290                 case LDKClosureReason_HolderForceClosed: {
5291                         return (*env)->NewObject(env, LDKClosureReason_HolderForceClosed_class, LDKClosureReason_HolderForceClosed_meth);
5292                 }
5293                 case LDKClosureReason_CooperativeClosure: {
5294                         return (*env)->NewObject(env, LDKClosureReason_CooperativeClosure_class, LDKClosureReason_CooperativeClosure_meth);
5295                 }
5296                 case LDKClosureReason_CommitmentTxConfirmed: {
5297                         return (*env)->NewObject(env, LDKClosureReason_CommitmentTxConfirmed_class, LDKClosureReason_CommitmentTxConfirmed_meth);
5298                 }
5299                 case LDKClosureReason_ProcessingError: {
5300                         LDKStr err_str = obj->processing_error.err;
5301                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
5302                         return (*env)->NewObject(env, LDKClosureReason_ProcessingError_class, LDKClosureReason_ProcessingError_meth, err_conv);
5303                 }
5304                 case LDKClosureReason_DisconnectedPeer: {
5305                         return (*env)->NewObject(env, LDKClosureReason_DisconnectedPeer_class, LDKClosureReason_DisconnectedPeer_meth);
5306                 }
5307                 case LDKClosureReason_OutdatedChannelManager: {
5308                         return (*env)->NewObject(env, LDKClosureReason_OutdatedChannelManager_class, LDKClosureReason_OutdatedChannelManager_meth);
5309                 }
5310                 default: abort();
5311         }
5312 }
5313 static jclass LDKEvent_FundingGenerationReady_class = NULL;
5314 static jmethodID LDKEvent_FundingGenerationReady_meth = NULL;
5315 static jclass LDKEvent_PaymentReceived_class = NULL;
5316 static jmethodID LDKEvent_PaymentReceived_meth = NULL;
5317 static jclass LDKEvent_PaymentSent_class = NULL;
5318 static jmethodID LDKEvent_PaymentSent_meth = NULL;
5319 static jclass LDKEvent_PaymentPathFailed_class = NULL;
5320 static jmethodID LDKEvent_PaymentPathFailed_meth = NULL;
5321 static jclass LDKEvent_PendingHTLCsForwardable_class = NULL;
5322 static jmethodID LDKEvent_PendingHTLCsForwardable_meth = NULL;
5323 static jclass LDKEvent_SpendableOutputs_class = NULL;
5324 static jmethodID LDKEvent_SpendableOutputs_meth = NULL;
5325 static jclass LDKEvent_PaymentForwarded_class = NULL;
5326 static jmethodID LDKEvent_PaymentForwarded_meth = NULL;
5327 static jclass LDKEvent_ChannelClosed_class = NULL;
5328 static jmethodID LDKEvent_ChannelClosed_meth = NULL;
5329 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKEvent_init (JNIEnv *env, jclass clz) {
5330         LDKEvent_FundingGenerationReady_class =
5331                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$FundingGenerationReady;"));
5332         CHECK(LDKEvent_FundingGenerationReady_class != NULL);
5333         LDKEvent_FundingGenerationReady_meth = (*env)->GetMethodID(env, LDKEvent_FundingGenerationReady_class, "<init>", "([BJ[BJ)V");
5334         CHECK(LDKEvent_FundingGenerationReady_meth != NULL);
5335         LDKEvent_PaymentReceived_class =
5336                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PaymentReceived;"));
5337         CHECK(LDKEvent_PaymentReceived_class != NULL);
5338         LDKEvent_PaymentReceived_meth = (*env)->GetMethodID(env, LDKEvent_PaymentReceived_class, "<init>", "([BJJ)V");
5339         CHECK(LDKEvent_PaymentReceived_meth != NULL);
5340         LDKEvent_PaymentSent_class =
5341                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PaymentSent;"));
5342         CHECK(LDKEvent_PaymentSent_class != NULL);
5343         LDKEvent_PaymentSent_meth = (*env)->GetMethodID(env, LDKEvent_PaymentSent_class, "<init>", "([B)V");
5344         CHECK(LDKEvent_PaymentSent_meth != NULL);
5345         LDKEvent_PaymentPathFailed_class =
5346                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PaymentPathFailed;"));
5347         CHECK(LDKEvent_PaymentPathFailed_class != NULL);
5348         LDKEvent_PaymentPathFailed_meth = (*env)->GetMethodID(env, LDKEvent_PaymentPathFailed_class, "<init>", "([BZJZ[J)V");
5349         CHECK(LDKEvent_PaymentPathFailed_meth != NULL);
5350         LDKEvent_PendingHTLCsForwardable_class =
5351                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PendingHTLCsForwardable;"));
5352         CHECK(LDKEvent_PendingHTLCsForwardable_class != NULL);
5353         LDKEvent_PendingHTLCsForwardable_meth = (*env)->GetMethodID(env, LDKEvent_PendingHTLCsForwardable_class, "<init>", "(J)V");
5354         CHECK(LDKEvent_PendingHTLCsForwardable_meth != NULL);
5355         LDKEvent_SpendableOutputs_class =
5356                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$SpendableOutputs;"));
5357         CHECK(LDKEvent_SpendableOutputs_class != NULL);
5358         LDKEvent_SpendableOutputs_meth = (*env)->GetMethodID(env, LDKEvent_SpendableOutputs_class, "<init>", "([J)V");
5359         CHECK(LDKEvent_SpendableOutputs_meth != NULL);
5360         LDKEvent_PaymentForwarded_class =
5361                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PaymentForwarded;"));
5362         CHECK(LDKEvent_PaymentForwarded_class != NULL);
5363         LDKEvent_PaymentForwarded_meth = (*env)->GetMethodID(env, LDKEvent_PaymentForwarded_class, "<init>", "(JZ)V");
5364         CHECK(LDKEvent_PaymentForwarded_meth != NULL);
5365         LDKEvent_ChannelClosed_class =
5366                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$ChannelClosed;"));
5367         CHECK(LDKEvent_ChannelClosed_class != NULL);
5368         LDKEvent_ChannelClosed_meth = (*env)->GetMethodID(env, LDKEvent_ChannelClosed_class, "<init>", "([BJ)V");
5369         CHECK(LDKEvent_ChannelClosed_meth != NULL);
5370 }
5371 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
5372         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
5373         switch(obj->tag) {
5374                 case LDKEvent_FundingGenerationReady: {
5375                         int8_tArray temporary_channel_id_arr = (*env)->NewByteArray(env, 32);
5376                         (*env)->SetByteArrayRegion(env, temporary_channel_id_arr, 0, 32, obj->funding_generation_ready.temporary_channel_id.data);
5377                         LDKCVec_u8Z output_script_var = obj->funding_generation_ready.output_script;
5378                         int8_tArray output_script_arr = (*env)->NewByteArray(env, output_script_var.datalen);
5379                         (*env)->SetByteArrayRegion(env, output_script_arr, 0, output_script_var.datalen, output_script_var.data);
5380                         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);
5381                 }
5382                 case LDKEvent_PaymentReceived: {
5383                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
5384                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_received.payment_hash.data);
5385                         uint64_t purpose_ref = ((uint64_t)&obj->payment_received.purpose) | 1;
5386                         return (*env)->NewObject(env, LDKEvent_PaymentReceived_class, LDKEvent_PaymentReceived_meth, payment_hash_arr, obj->payment_received.amt, purpose_ref);
5387                 }
5388                 case LDKEvent_PaymentSent: {
5389                         int8_tArray payment_preimage_arr = (*env)->NewByteArray(env, 32);
5390                         (*env)->SetByteArrayRegion(env, payment_preimage_arr, 0, 32, obj->payment_sent.payment_preimage.data);
5391                         return (*env)->NewObject(env, LDKEvent_PaymentSent_class, LDKEvent_PaymentSent_meth, payment_preimage_arr);
5392                 }
5393                 case LDKEvent_PaymentPathFailed: {
5394                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
5395                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_path_failed.payment_hash.data);
5396                         uint64_t network_update_ref = ((uint64_t)&obj->payment_path_failed.network_update) | 1;
5397                         LDKCVec_RouteHopZ path_var = obj->payment_path_failed.path;
5398                         int64_tArray path_arr = (*env)->NewLongArray(env, path_var.datalen);
5399                         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
5400                         for (size_t k = 0; k < path_var.datalen; k++) {
5401                                 LDKRouteHop path_conv_10_var = path_var.data[k];
5402                                 CHECK((((uint64_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5403                                 CHECK((((uint64_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5404                                 uint64_t path_conv_10_ref = (uint64_t)path_conv_10_var.inner & ~1;
5405                                 path_arr_ptr[k] = path_conv_10_ref;
5406                         }
5407                         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
5408                         return (*env)->NewObject(env, LDKEvent_PaymentPathFailed_class, LDKEvent_PaymentPathFailed_meth, payment_hash_arr, obj->payment_path_failed.rejected_by_dest, network_update_ref, obj->payment_path_failed.all_paths_failed, path_arr);
5409                 }
5410                 case LDKEvent_PendingHTLCsForwardable: {
5411                         return (*env)->NewObject(env, LDKEvent_PendingHTLCsForwardable_class, LDKEvent_PendingHTLCsForwardable_meth, obj->pending_htl_cs_forwardable.time_forwardable);
5412                 }
5413                 case LDKEvent_SpendableOutputs: {
5414                         LDKCVec_SpendableOutputDescriptorZ outputs_var = obj->spendable_outputs.outputs;
5415                         int64_tArray outputs_arr = (*env)->NewLongArray(env, outputs_var.datalen);
5416                         int64_t *outputs_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, outputs_arr, NULL);
5417                         for (size_t b = 0; b < outputs_var.datalen; b++) {
5418                                 uint64_t outputs_conv_27_ref = ((uint64_t)&outputs_var.data[b]) | 1;
5419                                 outputs_arr_ptr[b] = outputs_conv_27_ref;
5420                         }
5421                         (*env)->ReleasePrimitiveArrayCritical(env, outputs_arr, outputs_arr_ptr, 0);
5422                         return (*env)->NewObject(env, LDKEvent_SpendableOutputs_class, LDKEvent_SpendableOutputs_meth, outputs_arr);
5423                 }
5424                 case LDKEvent_PaymentForwarded: {
5425                         uint64_t fee_earned_msat_ref = ((uint64_t)&obj->payment_forwarded.fee_earned_msat) | 1;
5426                         return (*env)->NewObject(env, LDKEvent_PaymentForwarded_class, LDKEvent_PaymentForwarded_meth, fee_earned_msat_ref, obj->payment_forwarded.claim_from_onchain_tx);
5427                 }
5428                 case LDKEvent_ChannelClosed: {
5429                         int8_tArray channel_id_arr = (*env)->NewByteArray(env, 32);
5430                         (*env)->SetByteArrayRegion(env, channel_id_arr, 0, 32, obj->channel_closed.channel_id.data);
5431                         uint64_t reason_ref = ((uint64_t)&obj->channel_closed.reason) | 1;
5432                         return (*env)->NewObject(env, LDKEvent_ChannelClosed_class, LDKEvent_ChannelClosed_meth, channel_id_arr, reason_ref);
5433                 }
5434                 default: abort();
5435         }
5436 }
5437 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1EventZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
5438         LDKCVec_EventZ *ret = MALLOC(sizeof(LDKCVec_EventZ), "LDKCVec_EventZ");
5439         ret->datalen = (*env)->GetArrayLength(env, elems);
5440         if (ret->datalen == 0) {
5441                 ret->data = NULL;
5442         } else {
5443                 ret->data = MALLOC(sizeof(LDKEvent) * ret->datalen, "LDKCVec_EventZ Data");
5444                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
5445                 for (size_t i = 0; i < ret->datalen; i++) {
5446                         int64_t arr_elem = java_elems[i];
5447                         LDKEvent arr_elem_conv = *(LDKEvent*)(((uint64_t)arr_elem) & ~1);
5448                         arr_elem_conv = Event_clone((LDKEvent*)(((uint64_t)arr_elem) & ~1));
5449                         ret->data[i] = arr_elem_conv;
5450                 }
5451                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
5452         }
5453         return (uint64_t)ret;
5454 }
5455 static inline LDKCVec_EventZ CVec_EventZ_clone(const LDKCVec_EventZ *orig) {
5456         LDKCVec_EventZ ret = { .data = MALLOC(sizeof(LDKEvent) * orig->datalen, "LDKCVec_EventZ clone bytes"), .datalen = orig->datalen };
5457         for (size_t i = 0; i < ret.datalen; i++) {
5458                 ret.data[i] = Event_clone(&orig->data[i]);
5459         }
5460         return ret;
5461 }
5462 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1u32TxOutZ_1new(JNIEnv *env, jclass clz, int32_t a, int64_t b) {
5463         LDKC2Tuple_u32TxOutZ* ret = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
5464         ret->a = a;
5465         LDKTxOut b_conv = *(LDKTxOut*)(((uint64_t)b) & ~1);
5466         b_conv = TxOut_clone((LDKTxOut*)(((uint64_t)b) & ~1));
5467         ret->b = b_conv;
5468         return (uint64_t)ret;
5469 }
5470 static inline uint32_t C2Tuple_u32TxOutZ_get_a(LDKC2Tuple_u32TxOutZ *NONNULL_PTR tuple){
5471         return tuple->a;
5472 }
5473 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1get_1a(JNIEnv *env, jclass clz, int64_t tuple) {
5474         LDKC2Tuple_u32TxOutZ* tuple_conv = (LDKC2Tuple_u32TxOutZ*)(tuple & ~1);
5475         int32_t ret_val = C2Tuple_u32TxOutZ_get_a(tuple_conv);
5476         return ret_val;
5477 }
5478
5479 static inline struct LDKTxOut C2Tuple_u32TxOutZ_get_b(LDKC2Tuple_u32TxOutZ *NONNULL_PTR tuple){
5480         return TxOut_clone(&tuple->b);
5481 }
5482 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1get_1b(JNIEnv *env, jclass clz, int64_t tuple) {
5483         LDKC2Tuple_u32TxOutZ* tuple_conv = (LDKC2Tuple_u32TxOutZ*)(tuple & ~1);
5484         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
5485         *ret_ref = C2Tuple_u32TxOutZ_get_b(tuple_conv);
5486         return (uint64_t)ret_ref;
5487 }
5488
5489 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1u32TxOutZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
5490         LDKCVec_C2Tuple_u32TxOutZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_u32TxOutZZ), "LDKCVec_C2Tuple_u32TxOutZZ");
5491         ret->datalen = (*env)->GetArrayLength(env, elems);
5492         if (ret->datalen == 0) {
5493                 ret->data = NULL;
5494         } else {
5495                 ret->data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * ret->datalen, "LDKCVec_C2Tuple_u32TxOutZZ Data");
5496                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
5497                 for (size_t i = 0; i < ret->datalen; i++) {
5498                         int64_t arr_elem = java_elems[i];
5499                         LDKC2Tuple_u32TxOutZ arr_elem_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)arr_elem) & ~1);
5500                         arr_elem_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uint64_t)arr_elem) & ~1));
5501                         ret->data[i] = arr_elem_conv;
5502                 }
5503                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
5504         }
5505         return (uint64_t)ret;
5506 }
5507 static inline LDKCVec_C2Tuple_u32TxOutZZ CVec_C2Tuple_u32TxOutZZ_clone(const LDKCVec_C2Tuple_u32TxOutZZ *orig) {
5508         LDKCVec_C2Tuple_u32TxOutZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * orig->datalen, "LDKCVec_C2Tuple_u32TxOutZZ clone bytes"), .datalen = orig->datalen };
5509         for (size_t i = 0; i < ret.datalen; i++) {
5510                 ret.data[i] = C2Tuple_u32TxOutZ_clone(&orig->data[i]);
5511         }
5512         return ret;
5513 }
5514 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
5515         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
5516         LDKThirtyTwoBytes a_ref;
5517         CHECK((*env)->GetArrayLength(env, a) == 32);
5518         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
5519         ret->a = a_ref;
5520         LDKCVec_C2Tuple_u32TxOutZZ b_constr;
5521         b_constr.datalen = (*env)->GetArrayLength(env, b);
5522         if (b_constr.datalen > 0)
5523                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
5524         else
5525                 b_constr.data = NULL;
5526         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
5527         for (size_t u = 0; u < b_constr.datalen; u++) {
5528                 int64_t b_conv_20 = b_vals[u];
5529                 LDKC2Tuple_u32TxOutZ b_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_20) & ~1);
5530                 b_conv_20_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_20) & ~1));
5531                 b_constr.data[u] = b_conv_20_conv;
5532         }
5533         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
5534         ret->b = b_constr;
5535         return (uint64_t)ret;
5536 }
5537 static inline struct LDKThirtyTwoBytes C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR tuple){
5538         return ThirtyTwoBytes_clone(&tuple->a);
5539 }
5540 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1get_1a(JNIEnv *env, jclass clz, int64_t tuple) {
5541         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* tuple_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(tuple & ~1);
5542         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5543         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(tuple_conv).data);
5544         return ret_arr;
5545 }
5546
5547 static inline struct LDKCVec_C2Tuple_u32TxOutZZ C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR tuple){
5548         return CVec_C2Tuple_u32TxOutZZ_clone(&tuple->b);
5549 }
5550 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1get_1b(JNIEnv *env, jclass clz, int64_t tuple) {
5551         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* tuple_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(tuple & ~1);
5552         LDKCVec_C2Tuple_u32TxOutZZ ret_var = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(tuple_conv);
5553         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
5554         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
5555         for (size_t u = 0; u < ret_var.datalen; u++) {
5556                 LDKC2Tuple_u32TxOutZ* ret_conv_20_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
5557                 *ret_conv_20_conv = ret_var.data[u];
5558                 ret_arr_ptr[u] = ((uint64_t)ret_conv_20_conv);
5559         }
5560         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
5561         FREE(ret_var.data);
5562         return ret_arr;
5563 }
5564
5565 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
5566         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ");
5567         ret->datalen = (*env)->GetArrayLength(env, elems);
5568         if (ret->datalen == 0) {
5569                 ret->data = NULL;
5570         } else {
5571                 ret->data = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ) * ret->datalen, "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Data");
5572                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
5573                 for (size_t i = 0; i < ret->datalen; i++) {
5574                         int64_t arr_elem = java_elems[i];
5575                         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ arr_elem_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)arr_elem) & ~1);
5576                         arr_elem_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone((LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)arr_elem) & ~1));
5577                         ret->data[i] = arr_elem_conv;
5578                 }
5579                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
5580         }
5581         return (uint64_t)ret;
5582 }
5583 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ *orig) {
5584         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 };
5585         for (size_t i = 0; i < ret.datalen; i++) {
5586                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(&orig->data[i]);
5587         }
5588         return ret;
5589 }
5590 static jclass LDKBalance_ClaimableOnChannelClose_class = NULL;
5591 static jmethodID LDKBalance_ClaimableOnChannelClose_meth = NULL;
5592 static jclass LDKBalance_ClaimableAwaitingConfirmations_class = NULL;
5593 static jmethodID LDKBalance_ClaimableAwaitingConfirmations_meth = NULL;
5594 static jclass LDKBalance_ContentiousClaimable_class = NULL;
5595 static jmethodID LDKBalance_ContentiousClaimable_meth = NULL;
5596 static jclass LDKBalance_MaybeClaimableHTLCAwaitingTimeout_class = NULL;
5597 static jmethodID LDKBalance_MaybeClaimableHTLCAwaitingTimeout_meth = NULL;
5598 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKBalance_init (JNIEnv *env, jclass clz) {
5599         LDKBalance_ClaimableOnChannelClose_class =
5600                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKBalance$ClaimableOnChannelClose;"));
5601         CHECK(LDKBalance_ClaimableOnChannelClose_class != NULL);
5602         LDKBalance_ClaimableOnChannelClose_meth = (*env)->GetMethodID(env, LDKBalance_ClaimableOnChannelClose_class, "<init>", "(J)V");
5603         CHECK(LDKBalance_ClaimableOnChannelClose_meth != NULL);
5604         LDKBalance_ClaimableAwaitingConfirmations_class =
5605                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKBalance$ClaimableAwaitingConfirmations;"));
5606         CHECK(LDKBalance_ClaimableAwaitingConfirmations_class != NULL);
5607         LDKBalance_ClaimableAwaitingConfirmations_meth = (*env)->GetMethodID(env, LDKBalance_ClaimableAwaitingConfirmations_class, "<init>", "(JI)V");
5608         CHECK(LDKBalance_ClaimableAwaitingConfirmations_meth != NULL);
5609         LDKBalance_ContentiousClaimable_class =
5610                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKBalance$ContentiousClaimable;"));
5611         CHECK(LDKBalance_ContentiousClaimable_class != NULL);
5612         LDKBalance_ContentiousClaimable_meth = (*env)->GetMethodID(env, LDKBalance_ContentiousClaimable_class, "<init>", "(JI)V");
5613         CHECK(LDKBalance_ContentiousClaimable_meth != NULL);
5614         LDKBalance_MaybeClaimableHTLCAwaitingTimeout_class =
5615                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKBalance$MaybeClaimableHTLCAwaitingTimeout;"));
5616         CHECK(LDKBalance_MaybeClaimableHTLCAwaitingTimeout_class != NULL);
5617         LDKBalance_MaybeClaimableHTLCAwaitingTimeout_meth = (*env)->GetMethodID(env, LDKBalance_MaybeClaimableHTLCAwaitingTimeout_class, "<init>", "(JI)V");
5618         CHECK(LDKBalance_MaybeClaimableHTLCAwaitingTimeout_meth != NULL);
5619 }
5620 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKBalance_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
5621         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
5622         switch(obj->tag) {
5623                 case LDKBalance_ClaimableOnChannelClose: {
5624                         return (*env)->NewObject(env, LDKBalance_ClaimableOnChannelClose_class, LDKBalance_ClaimableOnChannelClose_meth, obj->claimable_on_channel_close.claimable_amount_satoshis);
5625                 }
5626                 case LDKBalance_ClaimableAwaitingConfirmations: {
5627                         return (*env)->NewObject(env, LDKBalance_ClaimableAwaitingConfirmations_class, LDKBalance_ClaimableAwaitingConfirmations_meth, obj->claimable_awaiting_confirmations.claimable_amount_satoshis, obj->claimable_awaiting_confirmations.confirmation_height);
5628                 }
5629                 case LDKBalance_ContentiousClaimable: {
5630                         return (*env)->NewObject(env, LDKBalance_ContentiousClaimable_class, LDKBalance_ContentiousClaimable_meth, obj->contentious_claimable.claimable_amount_satoshis, obj->contentious_claimable.timeout_height);
5631                 }
5632                 case LDKBalance_MaybeClaimableHTLCAwaitingTimeout: {
5633                         return (*env)->NewObject(env, LDKBalance_MaybeClaimableHTLCAwaitingTimeout_class, LDKBalance_MaybeClaimableHTLCAwaitingTimeout_meth, obj->maybe_claimable_htlc_awaiting_timeout.claimable_amount_satoshis, obj->maybe_claimable_htlc_awaiting_timeout.claimable_height);
5634                 }
5635                 default: abort();
5636         }
5637 }
5638 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1BalanceZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
5639         LDKCVec_BalanceZ *ret = MALLOC(sizeof(LDKCVec_BalanceZ), "LDKCVec_BalanceZ");
5640         ret->datalen = (*env)->GetArrayLength(env, elems);
5641         if (ret->datalen == 0) {
5642                 ret->data = NULL;
5643         } else {
5644                 ret->data = MALLOC(sizeof(LDKBalance) * ret->datalen, "LDKCVec_BalanceZ Data");
5645                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
5646                 for (size_t i = 0; i < ret->datalen; i++) {
5647                         int64_t arr_elem = java_elems[i];
5648                         LDKBalance arr_elem_conv = *(LDKBalance*)(((uint64_t)arr_elem) & ~1);
5649                         arr_elem_conv = Balance_clone((LDKBalance*)(((uint64_t)arr_elem) & ~1));
5650                         ret->data[i] = arr_elem_conv;
5651                 }
5652                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
5653         }
5654         return (uint64_t)ret;
5655 }
5656 static inline LDKCVec_BalanceZ CVec_BalanceZ_clone(const LDKCVec_BalanceZ *orig) {
5657         LDKCVec_BalanceZ ret = { .data = MALLOC(sizeof(LDKBalance) * orig->datalen, "LDKCVec_BalanceZ clone bytes"), .datalen = orig->datalen };
5658         for (size_t i = 0; i < ret.datalen; i++) {
5659                 ret.data[i] = Balance_clone(&orig->data[i]);
5660         }
5661         return ret;
5662 }
5663 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5664         return ((LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)arg)->result_ok;
5665 }
5666 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5667         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1);
5668         CHECK(val->result_ok);
5669         LDKC2Tuple_BlockHashChannelMonitorZ* res_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
5670         *res_conv = (*val->contents.result);
5671         *res_conv = C2Tuple_BlockHashChannelMonitorZ_clone(res_conv);
5672         return ((uint64_t)res_conv);
5673 }
5674 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5675         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1);
5676         CHECK(!val->result_ok);
5677         LDKDecodeError err_var = (*val->contents.err);
5678         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5679         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5680         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5681         return err_ref;
5682 }
5683 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneLightningErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5684         return ((LDKCResult_NoneLightningErrorZ*)arg)->result_ok;
5685 }
5686 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5687         LDKCResult_NoneLightningErrorZ *val = (LDKCResult_NoneLightningErrorZ*)(arg & ~1);
5688         CHECK(val->result_ok);
5689         return *val->contents.result;
5690 }
5691 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5692         LDKCResult_NoneLightningErrorZ *val = (LDKCResult_NoneLightningErrorZ*)(arg & ~1);
5693         CHECK(!val->result_ok);
5694         LDKLightningError err_var = (*val->contents.err);
5695         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5696         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5697         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5698         return err_ref;
5699 }
5700 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1PublicKeyTypeZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
5701         LDKC2Tuple_PublicKeyTypeZ* ret = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
5702         LDKPublicKey a_ref;
5703         CHECK((*env)->GetArrayLength(env, a) == 33);
5704         (*env)->GetByteArrayRegion(env, a, 0, 33, a_ref.compressed_form);
5705         ret->a = a_ref;
5706         LDKType b_conv = *(LDKType*)(((uint64_t)b) & ~1);
5707         b_conv = Type_clone(&b_conv);
5708         ret->b = b_conv;
5709         return (uint64_t)ret;
5710 }
5711 static inline struct LDKPublicKey C2Tuple_PublicKeyTypeZ_get_a(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR tuple){
5712         return tuple->a;
5713 }
5714 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1get_1a(JNIEnv *env, jclass clz, int64_t tuple) {
5715         LDKC2Tuple_PublicKeyTypeZ* tuple_conv = (LDKC2Tuple_PublicKeyTypeZ*)(tuple & ~1);
5716         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
5717         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, C2Tuple_PublicKeyTypeZ_get_a(tuple_conv).compressed_form);
5718         return ret_arr;
5719 }
5720
5721 static inline struct LDKType C2Tuple_PublicKeyTypeZ_get_b(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR tuple){
5722         return Type_clone(&tuple->b);
5723 }
5724 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1get_1b(JNIEnv *env, jclass clz, int64_t tuple) {
5725         LDKC2Tuple_PublicKeyTypeZ* tuple_conv = (LDKC2Tuple_PublicKeyTypeZ*)(tuple & ~1);
5726         LDKType* ret_ret =MALLOC(sizeof(LDKType), "LDKType");
5727         *ret_ret = C2Tuple_PublicKeyTypeZ_get_b(tuple_conv);
5728         return (uint64_t)ret_ret;
5729 }
5730
5731 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1PublicKeyTypeZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
5732         LDKCVec_C2Tuple_PublicKeyTypeZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_PublicKeyTypeZZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ");
5733         ret->datalen = (*env)->GetArrayLength(env, elems);
5734         if (ret->datalen == 0) {
5735                 ret->data = NULL;
5736         } else {
5737                 ret->data = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ) * ret->datalen, "LDKCVec_C2Tuple_PublicKeyTypeZZ Data");
5738                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
5739                 for (size_t i = 0; i < ret->datalen; i++) {
5740                         int64_t arr_elem = java_elems[i];
5741                         LDKC2Tuple_PublicKeyTypeZ arr_elem_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(((uint64_t)arr_elem) & ~1);
5742                         arr_elem_conv = C2Tuple_PublicKeyTypeZ_clone((LDKC2Tuple_PublicKeyTypeZ*)(((uint64_t)arr_elem) & ~1));
5743                         ret->data[i] = arr_elem_conv;
5744                 }
5745                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
5746         }
5747         return (uint64_t)ret;
5748 }
5749 static inline LDKCVec_C2Tuple_PublicKeyTypeZZ CVec_C2Tuple_PublicKeyTypeZZ_clone(const LDKCVec_C2Tuple_PublicKeyTypeZZ *orig) {
5750         LDKCVec_C2Tuple_PublicKeyTypeZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ) * orig->datalen, "LDKCVec_C2Tuple_PublicKeyTypeZZ clone bytes"), .datalen = orig->datalen };
5751         for (size_t i = 0; i < ret.datalen; i++) {
5752                 ret.data[i] = C2Tuple_PublicKeyTypeZ_clone(&orig->data[i]);
5753         }
5754         return ret;
5755 }
5756 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolLightningErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5757         return ((LDKCResult_boolLightningErrorZ*)arg)->result_ok;
5758 }
5759 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5760         LDKCResult_boolLightningErrorZ *val = (LDKCResult_boolLightningErrorZ*)(arg & ~1);
5761         CHECK(val->result_ok);
5762         return *val->contents.result;
5763 }
5764 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5765         LDKCResult_boolLightningErrorZ *val = (LDKCResult_boolLightningErrorZ*)(arg & ~1);
5766         CHECK(!val->result_ok);
5767         LDKLightningError err_var = (*val->contents.err);
5768         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5769         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5770         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5771         return err_ref;
5772 }
5773 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) {
5774         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
5775         LDKChannelAnnouncement a_conv;
5776         a_conv.inner = (void*)(a & (~1));
5777         a_conv.is_owned = (a & 1) || (a == 0);
5778         a_conv = ChannelAnnouncement_clone(&a_conv);
5779         ret->a = a_conv;
5780         LDKChannelUpdate b_conv;
5781         b_conv.inner = (void*)(b & (~1));
5782         b_conv.is_owned = (b & 1) || (b == 0);
5783         b_conv = ChannelUpdate_clone(&b_conv);
5784         ret->b = b_conv;
5785         LDKChannelUpdate c_conv;
5786         c_conv.inner = (void*)(c & (~1));
5787         c_conv.is_owned = (c & 1) || (c == 0);
5788         c_conv = ChannelUpdate_clone(&c_conv);
5789         ret->c = c_conv;
5790         return (uint64_t)ret;
5791 }
5792 static inline struct LDKChannelAnnouncement C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR tuple){
5793         return ChannelAnnouncement_clone(&tuple->a);
5794 }
5795 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1a(JNIEnv *env, jclass clz, int64_t tuple) {
5796         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* tuple_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(tuple & ~1);
5797         LDKChannelAnnouncement ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(tuple_conv);
5798         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5799         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5800         uint64_t ret_ref = (uint64_t)ret_var.inner;
5801         if (ret_var.is_owned) {
5802                 ret_ref |= 1;
5803         }
5804         return ret_ref;
5805 }
5806
5807 static inline struct LDKChannelUpdate C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR tuple){
5808         return ChannelUpdate_clone(&tuple->b);
5809 }
5810 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1b(JNIEnv *env, jclass clz, int64_t tuple) {
5811         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* tuple_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(tuple & ~1);
5812         LDKChannelUpdate ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(tuple_conv);
5813         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5814         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5815         uint64_t ret_ref = (uint64_t)ret_var.inner;
5816         if (ret_var.is_owned) {
5817                 ret_ref |= 1;
5818         }
5819         return ret_ref;
5820 }
5821
5822 static inline struct LDKChannelUpdate C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR tuple){
5823         return ChannelUpdate_clone(&tuple->c);
5824 }
5825 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1c(JNIEnv *env, jclass clz, int64_t tuple) {
5826         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* tuple_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(tuple & ~1);
5827         LDKChannelUpdate ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(tuple_conv);
5828         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5829         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5830         uint64_t ret_ref = (uint64_t)ret_var.inner;
5831         if (ret_var.is_owned) {
5832                 ret_ref |= 1;
5833         }
5834         return ret_ref;
5835 }
5836
5837 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
5838         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *ret = MALLOC(sizeof(LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ");
5839         ret->datalen = (*env)->GetArrayLength(env, elems);
5840         if (ret->datalen == 0) {
5841                 ret->data = NULL;
5842         } else {
5843                 ret->data = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) * ret->datalen, "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Data");
5844                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
5845                 for (size_t i = 0; i < ret->datalen; i++) {
5846                         int64_t arr_elem = java_elems[i];
5847                         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ arr_elem_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)arr_elem) & ~1);
5848                         arr_elem_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone((LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)arr_elem) & ~1));
5849                         ret->data[i] = arr_elem_conv;
5850                 }
5851                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
5852         }
5853         return (uint64_t)ret;
5854 }
5855 static inline LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone(const LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *orig) {
5856         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret = { .data = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) * orig->datalen, "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ clone bytes"), .datalen = orig->datalen };
5857         for (size_t i = 0; i < ret.datalen; i++) {
5858                 ret.data[i] = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(&orig->data[i]);
5859         }
5860         return ret;
5861 }
5862 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1NodeAnnouncementZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
5863         LDKCVec_NodeAnnouncementZ *ret = MALLOC(sizeof(LDKCVec_NodeAnnouncementZ), "LDKCVec_NodeAnnouncementZ");
5864         ret->datalen = (*env)->GetArrayLength(env, elems);
5865         if (ret->datalen == 0) {
5866                 ret->data = NULL;
5867         } else {
5868                 ret->data = MALLOC(sizeof(LDKNodeAnnouncement) * ret->datalen, "LDKCVec_NodeAnnouncementZ Data");
5869                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
5870                 for (size_t i = 0; i < ret->datalen; i++) {
5871                         int64_t arr_elem = java_elems[i];
5872                         LDKNodeAnnouncement arr_elem_conv;
5873                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
5874                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
5875                         arr_elem_conv = NodeAnnouncement_clone(&arr_elem_conv);
5876                         ret->data[i] = arr_elem_conv;
5877                 }
5878                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
5879         }
5880         return (uint64_t)ret;
5881 }
5882 static inline LDKCVec_NodeAnnouncementZ CVec_NodeAnnouncementZ_clone(const LDKCVec_NodeAnnouncementZ *orig) {
5883         LDKCVec_NodeAnnouncementZ ret = { .data = MALLOC(sizeof(LDKNodeAnnouncement) * orig->datalen, "LDKCVec_NodeAnnouncementZ clone bytes"), .datalen = orig->datalen };
5884         for (size_t i = 0; i < ret.datalen; i++) {
5885                 ret.data[i] = NodeAnnouncement_clone(&orig->data[i]);
5886         }
5887         return ret;
5888 }
5889 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1u8ZPeerHandleErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5890         return ((LDKCResult_CVec_u8ZPeerHandleErrorZ*)arg)->result_ok;
5891 }
5892 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1u8ZPeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5893         LDKCResult_CVec_u8ZPeerHandleErrorZ *val = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(arg & ~1);
5894         CHECK(val->result_ok);
5895         LDKCVec_u8Z res_var = (*val->contents.result);
5896         int8_tArray res_arr = (*env)->NewByteArray(env, res_var.datalen);
5897         (*env)->SetByteArrayRegion(env, res_arr, 0, res_var.datalen, res_var.data);
5898         return res_arr;
5899 }
5900 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1u8ZPeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5901         LDKCResult_CVec_u8ZPeerHandleErrorZ *val = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(arg & ~1);
5902         CHECK(!val->result_ok);
5903         LDKPeerHandleError err_var = (*val->contents.err);
5904         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5905         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5906         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5907         return err_ref;
5908 }
5909 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePeerHandleErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5910         return ((LDKCResult_NonePeerHandleErrorZ*)arg)->result_ok;
5911 }
5912 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5913         LDKCResult_NonePeerHandleErrorZ *val = (LDKCResult_NonePeerHandleErrorZ*)(arg & ~1);
5914         CHECK(val->result_ok);
5915         return *val->contents.result;
5916 }
5917 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5918         LDKCResult_NonePeerHandleErrorZ *val = (LDKCResult_NonePeerHandleErrorZ*)(arg & ~1);
5919         CHECK(!val->result_ok);
5920         LDKPeerHandleError err_var = (*val->contents.err);
5921         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5922         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5923         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5924         return err_ref;
5925 }
5926 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolPeerHandleErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5927         return ((LDKCResult_boolPeerHandleErrorZ*)arg)->result_ok;
5928 }
5929 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolPeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5930         LDKCResult_boolPeerHandleErrorZ *val = (LDKCResult_boolPeerHandleErrorZ*)(arg & ~1);
5931         CHECK(val->result_ok);
5932         return *val->contents.result;
5933 }
5934 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolPeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5935         LDKCResult_boolPeerHandleErrorZ *val = (LDKCResult_boolPeerHandleErrorZ*)(arg & ~1);
5936         CHECK(!val->result_ok);
5937         LDKPeerHandleError err_var = (*val->contents.err);
5938         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5939         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5940         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5941         return err_ref;
5942 }
5943 typedef struct LDKAccess_JCalls {
5944         atomic_size_t refcnt;
5945         JavaVM *vm;
5946         jweak o;
5947         jmethodID get_utxo_meth;
5948 } LDKAccess_JCalls;
5949 static void LDKAccess_JCalls_free(void* this_arg) {
5950         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
5951         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5952                 JNIEnv *env;
5953                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5954                 if (get_jenv_res == JNI_EDETACHED) {
5955                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5956                 } else {
5957                         DO_ASSERT(get_jenv_res == JNI_OK);
5958                 }
5959                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
5960                 if (get_jenv_res == JNI_EDETACHED) {
5961                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5962                 }
5963                 FREE(j_calls);
5964         }
5965 }
5966 LDKCResult_TxOutAccessErrorZ get_utxo_LDKAccess_jcall(const void* this_arg, const uint8_t (* genesis_hash)[32], uint64_t short_channel_id) {
5967         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
5968         JNIEnv *env;
5969         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5970         if (get_jenv_res == JNI_EDETACHED) {
5971                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5972         } else {
5973                 DO_ASSERT(get_jenv_res == JNI_OK);
5974         }
5975         int8_tArray genesis_hash_arr = (*env)->NewByteArray(env, 32);
5976         (*env)->SetByteArrayRegion(env, genesis_hash_arr, 0, 32, *genesis_hash);
5977         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5978         CHECK(obj != NULL);
5979         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_utxo_meth, genesis_hash_arr, short_channel_id);
5980         if ((*env)->ExceptionCheck(env)) {
5981                 (*env)->ExceptionDescribe(env);
5982                 (*env)->FatalError(env, "A call to get_utxo in LDKAccess from rust threw an exception.");
5983         }
5984         LDKCResult_TxOutAccessErrorZ ret_conv = *(LDKCResult_TxOutAccessErrorZ*)(((uint64_t)ret) & ~1);
5985         ret_conv = CResult_TxOutAccessErrorZ_clone((LDKCResult_TxOutAccessErrorZ*)(((uint64_t)ret) & ~1));
5986         if (get_jenv_res == JNI_EDETACHED) {
5987                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5988         }
5989         return ret_conv;
5990 }
5991 static void LDKAccess_JCalls_cloned(LDKAccess* new_obj) {
5992         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) new_obj->this_arg;
5993         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5994 }
5995 static inline LDKAccess LDKAccess_init (JNIEnv *env, jclass clz, jobject o) {
5996         jclass c = (*env)->GetObjectClass(env, o);
5997         CHECK(c != NULL);
5998         LDKAccess_JCalls *calls = MALLOC(sizeof(LDKAccess_JCalls), "LDKAccess_JCalls");
5999         atomic_init(&calls->refcnt, 1);
6000         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6001         calls->o = (*env)->NewWeakGlobalRef(env, o);
6002         calls->get_utxo_meth = (*env)->GetMethodID(env, c, "get_utxo", "([BJ)J");
6003         CHECK(calls->get_utxo_meth != NULL);
6004
6005         LDKAccess ret = {
6006                 .this_arg = (void*) calls,
6007                 .get_utxo = get_utxo_LDKAccess_jcall,
6008                 .free = LDKAccess_JCalls_free,
6009         };
6010         return ret;
6011 }
6012 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKAccess_1new(JNIEnv *env, jclass clz, jobject o) {
6013         LDKAccess *res_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
6014         *res_ptr = LDKAccess_init(env, clz, o);
6015         return (uint64_t)res_ptr;
6016 }
6017 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) {
6018         LDKAccess* this_arg_conv = (LDKAccess*)(((uint64_t)this_arg) & ~1);
6019         unsigned char genesis_hash_arr[32];
6020         CHECK((*env)->GetArrayLength(env, genesis_hash) == 32);
6021         (*env)->GetByteArrayRegion(env, genesis_hash, 0, 32, genesis_hash_arr);
6022         unsigned char (*genesis_hash_ref)[32] = &genesis_hash_arr;
6023         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
6024         *ret_conv = (this_arg_conv->get_utxo)(this_arg_conv->this_arg, genesis_hash_ref, short_channel_id);
6025         return (uint64_t)ret_conv;
6026 }
6027
6028 static jclass LDKCOption_AccessZ_Some_class = NULL;
6029 static jmethodID LDKCOption_AccessZ_Some_meth = NULL;
6030 static jclass LDKCOption_AccessZ_None_class = NULL;
6031 static jmethodID LDKCOption_AccessZ_None_meth = NULL;
6032 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1AccessZ_init (JNIEnv *env, jclass clz) {
6033         LDKCOption_AccessZ_Some_class =
6034                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_AccessZ$Some;"));
6035         CHECK(LDKCOption_AccessZ_Some_class != NULL);
6036         LDKCOption_AccessZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_AccessZ_Some_class, "<init>", "(J)V");
6037         CHECK(LDKCOption_AccessZ_Some_meth != NULL);
6038         LDKCOption_AccessZ_None_class =
6039                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_AccessZ$None;"));
6040         CHECK(LDKCOption_AccessZ_None_class != NULL);
6041         LDKCOption_AccessZ_None_meth = (*env)->GetMethodID(env, LDKCOption_AccessZ_None_class, "<init>", "()V");
6042         CHECK(LDKCOption_AccessZ_None_meth != NULL);
6043 }
6044 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1AccessZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
6045         LDKCOption_AccessZ *obj = (LDKCOption_AccessZ*)(ptr & ~1);
6046         switch(obj->tag) {
6047                 case LDKCOption_AccessZ_Some: {
6048                         LDKAccess* some_ret =MALLOC(sizeof(LDKAccess), "LDKAccess");
6049                         *some_ret = obj->some;
6050                         // Warning: We likely need to clone here, but no clone is available, so we just do it for Java instances
6051                         if ((*some_ret).free == LDKAccess_JCalls_free) {
6052                                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
6053                                 LDKAccess_JCalls_cloned(&(*some_ret));
6054                         }
6055                         return (*env)->NewObject(env, LDKCOption_AccessZ_Some_class, LDKCOption_AccessZ_Some_meth, (uint64_t)some_ret);
6056                 }
6057                 case LDKCOption_AccessZ_None: {
6058                         return (*env)->NewObject(env, LDKCOption_AccessZ_None_class, LDKCOption_AccessZ_None_meth);
6059                 }
6060                 default: abort();
6061         }
6062 }
6063 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DirectionalChannelInfoDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6064         return ((LDKCResult_DirectionalChannelInfoDecodeErrorZ*)arg)->result_ok;
6065 }
6066 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DirectionalChannelInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6067         LDKCResult_DirectionalChannelInfoDecodeErrorZ *val = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(arg & ~1);
6068         CHECK(val->result_ok);
6069         LDKDirectionalChannelInfo res_var = (*val->contents.result);
6070         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6071         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6072         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6073         return res_ref;
6074 }
6075 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DirectionalChannelInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6076         LDKCResult_DirectionalChannelInfoDecodeErrorZ *val = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(arg & ~1);
6077         CHECK(!val->result_ok);
6078         LDKDecodeError err_var = (*val->contents.err);
6079         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6080         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6081         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6082         return err_ref;
6083 }
6084 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelInfoDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6085         return ((LDKCResult_ChannelInfoDecodeErrorZ*)arg)->result_ok;
6086 }
6087 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6088         LDKCResult_ChannelInfoDecodeErrorZ *val = (LDKCResult_ChannelInfoDecodeErrorZ*)(arg & ~1);
6089         CHECK(val->result_ok);
6090         LDKChannelInfo res_var = (*val->contents.result);
6091         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6092         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6093         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6094         return res_ref;
6095 }
6096 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6097         LDKCResult_ChannelInfoDecodeErrorZ *val = (LDKCResult_ChannelInfoDecodeErrorZ*)(arg & ~1);
6098         CHECK(!val->result_ok);
6099         LDKDecodeError err_var = (*val->contents.err);
6100         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6101         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6102         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6103         return err_ref;
6104 }
6105 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RoutingFeesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6106         return ((LDKCResult_RoutingFeesDecodeErrorZ*)arg)->result_ok;
6107 }
6108 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RoutingFeesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6109         LDKCResult_RoutingFeesDecodeErrorZ *val = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
6110         CHECK(val->result_ok);
6111         LDKRoutingFees res_var = (*val->contents.result);
6112         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6113         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6114         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6115         return res_ref;
6116 }
6117 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RoutingFeesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6118         LDKCResult_RoutingFeesDecodeErrorZ *val = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
6119         CHECK(!val->result_ok);
6120         LDKDecodeError err_var = (*val->contents.err);
6121         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6122         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6123         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6124         return err_ref;
6125 }
6126 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementInfoDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6127         return ((LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)arg)->result_ok;
6128 }
6129 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6130         LDKCResult_NodeAnnouncementInfoDecodeErrorZ *val = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
6131         CHECK(val->result_ok);
6132         LDKNodeAnnouncementInfo res_var = (*val->contents.result);
6133         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6134         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6135         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6136         return res_ref;
6137 }
6138 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6139         LDKCResult_NodeAnnouncementInfoDecodeErrorZ *val = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
6140         CHECK(!val->result_ok);
6141         LDKDecodeError err_var = (*val->contents.err);
6142         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6143         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6144         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6145         return err_ref;
6146 }
6147 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1u64Z_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
6148         LDKCVec_u64Z *ret = MALLOC(sizeof(LDKCVec_u64Z), "LDKCVec_u64Z");
6149         ret->datalen = (*env)->GetArrayLength(env, elems);
6150         if (ret->datalen == 0) {
6151                 ret->data = NULL;
6152         } else {
6153                 ret->data = MALLOC(sizeof(uint64_t) * ret->datalen, "LDKCVec_u64Z Data");
6154                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
6155                 for (size_t i = 0; i < ret->datalen; i++) {
6156                         ret->data[i] = java_elems[i];
6157                 }
6158                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
6159         }
6160         return (uint64_t)ret;
6161 }
6162 static inline LDKCVec_u64Z CVec_u64Z_clone(const LDKCVec_u64Z *orig) {
6163         LDKCVec_u64Z ret = { .data = MALLOC(sizeof(int64_t) * orig->datalen, "LDKCVec_u64Z clone bytes"), .datalen = orig->datalen };
6164         memcpy(ret.data, orig->data, sizeof(int64_t) * ret.datalen);
6165         return ret;
6166 }
6167 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeInfoDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6168         return ((LDKCResult_NodeInfoDecodeErrorZ*)arg)->result_ok;
6169 }
6170 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6171         LDKCResult_NodeInfoDecodeErrorZ *val = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
6172         CHECK(val->result_ok);
6173         LDKNodeInfo res_var = (*val->contents.result);
6174         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6175         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6176         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6177         return res_ref;
6178 }
6179 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6180         LDKCResult_NodeInfoDecodeErrorZ *val = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
6181         CHECK(!val->result_ok);
6182         LDKDecodeError err_var = (*val->contents.err);
6183         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6184         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6185         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6186         return err_ref;
6187 }
6188 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetworkGraphDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6189         return ((LDKCResult_NetworkGraphDecodeErrorZ*)arg)->result_ok;
6190 }
6191 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetworkGraphDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6192         LDKCResult_NetworkGraphDecodeErrorZ *val = (LDKCResult_NetworkGraphDecodeErrorZ*)(arg & ~1);
6193         CHECK(val->result_ok);
6194         LDKNetworkGraph res_var = (*val->contents.result);
6195         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6196         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6197         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6198         return res_ref;
6199 }
6200 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetworkGraphDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6201         LDKCResult_NetworkGraphDecodeErrorZ *val = (LDKCResult_NetworkGraphDecodeErrorZ*)(arg & ~1);
6202         CHECK(!val->result_ok);
6203         LDKDecodeError err_var = (*val->contents.err);
6204         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6205         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6206         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6207         return err_ref;
6208 }
6209 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressu8Z_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6210         return ((LDKCResult_NetAddressu8Z*)arg)->result_ok;
6211 }
6212 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressu8Z_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6213         LDKCResult_NetAddressu8Z *val = (LDKCResult_NetAddressu8Z*)(arg & ~1);
6214         CHECK(val->result_ok);
6215         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
6216         return res_ref;
6217 }
6218 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressu8Z_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6219         LDKCResult_NetAddressu8Z *val = (LDKCResult_NetAddressu8Z*)(arg & ~1);
6220         CHECK(!val->result_ok);
6221         return *val->contents.err;
6222 }
6223 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CResult_1NetAddressu8ZDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6224         return ((LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)arg)->result_ok;
6225 }
6226 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CResult_1NetAddressu8ZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6227         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ *val = (LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(arg & ~1);
6228         CHECK(val->result_ok);
6229         LDKCResult_NetAddressu8Z* res_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
6230         *res_conv = (*val->contents.result);
6231         *res_conv = CResult_NetAddressu8Z_clone(res_conv);
6232         return (uint64_t)res_conv;
6233 }
6234 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CResult_1NetAddressu8ZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6235         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ *val = (LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(arg & ~1);
6236         CHECK(!val->result_ok);
6237         LDKDecodeError err_var = (*val->contents.err);
6238         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6239         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6240         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6241         return err_ref;
6242 }
6243 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6244         return ((LDKCResult_NetAddressDecodeErrorZ*)arg)->result_ok;
6245 }
6246 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6247         LDKCResult_NetAddressDecodeErrorZ *val = (LDKCResult_NetAddressDecodeErrorZ*)(arg & ~1);
6248         CHECK(val->result_ok);
6249         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
6250         return res_ref;
6251 }
6252 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6253         LDKCResult_NetAddressDecodeErrorZ *val = (LDKCResult_NetAddressDecodeErrorZ*)(arg & ~1);
6254         CHECK(!val->result_ok);
6255         LDKDecodeError err_var = (*val->contents.err);
6256         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6257         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6258         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6259         return err_ref;
6260 }
6261 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1UpdateAddHTLCZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
6262         LDKCVec_UpdateAddHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateAddHTLCZ), "LDKCVec_UpdateAddHTLCZ");
6263         ret->datalen = (*env)->GetArrayLength(env, elems);
6264         if (ret->datalen == 0) {
6265                 ret->data = NULL;
6266         } else {
6267                 ret->data = MALLOC(sizeof(LDKUpdateAddHTLC) * ret->datalen, "LDKCVec_UpdateAddHTLCZ Data");
6268                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
6269                 for (size_t i = 0; i < ret->datalen; i++) {
6270                         int64_t arr_elem = java_elems[i];
6271                         LDKUpdateAddHTLC arr_elem_conv;
6272                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
6273                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
6274                         arr_elem_conv = UpdateAddHTLC_clone(&arr_elem_conv);
6275                         ret->data[i] = arr_elem_conv;
6276                 }
6277                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
6278         }
6279         return (uint64_t)ret;
6280 }
6281 static inline LDKCVec_UpdateAddHTLCZ CVec_UpdateAddHTLCZ_clone(const LDKCVec_UpdateAddHTLCZ *orig) {
6282         LDKCVec_UpdateAddHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateAddHTLC) * orig->datalen, "LDKCVec_UpdateAddHTLCZ clone bytes"), .datalen = orig->datalen };
6283         for (size_t i = 0; i < ret.datalen; i++) {
6284                 ret.data[i] = UpdateAddHTLC_clone(&orig->data[i]);
6285         }
6286         return ret;
6287 }
6288 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1UpdateFulfillHTLCZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
6289         LDKCVec_UpdateFulfillHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateFulfillHTLCZ), "LDKCVec_UpdateFulfillHTLCZ");
6290         ret->datalen = (*env)->GetArrayLength(env, elems);
6291         if (ret->datalen == 0) {
6292                 ret->data = NULL;
6293         } else {
6294                 ret->data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * ret->datalen, "LDKCVec_UpdateFulfillHTLCZ Data");
6295                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
6296                 for (size_t i = 0; i < ret->datalen; i++) {
6297                         int64_t arr_elem = java_elems[i];
6298                         LDKUpdateFulfillHTLC arr_elem_conv;
6299                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
6300                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
6301                         arr_elem_conv = UpdateFulfillHTLC_clone(&arr_elem_conv);
6302                         ret->data[i] = arr_elem_conv;
6303                 }
6304                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
6305         }
6306         return (uint64_t)ret;
6307 }
6308 static inline LDKCVec_UpdateFulfillHTLCZ CVec_UpdateFulfillHTLCZ_clone(const LDKCVec_UpdateFulfillHTLCZ *orig) {
6309         LDKCVec_UpdateFulfillHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * orig->datalen, "LDKCVec_UpdateFulfillHTLCZ clone bytes"), .datalen = orig->datalen };
6310         for (size_t i = 0; i < ret.datalen; i++) {
6311                 ret.data[i] = UpdateFulfillHTLC_clone(&orig->data[i]);
6312         }
6313         return ret;
6314 }
6315 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1UpdateFailHTLCZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
6316         LDKCVec_UpdateFailHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateFailHTLCZ), "LDKCVec_UpdateFailHTLCZ");
6317         ret->datalen = (*env)->GetArrayLength(env, elems);
6318         if (ret->datalen == 0) {
6319                 ret->data = NULL;
6320         } else {
6321                 ret->data = MALLOC(sizeof(LDKUpdateFailHTLC) * ret->datalen, "LDKCVec_UpdateFailHTLCZ Data");
6322                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
6323                 for (size_t i = 0; i < ret->datalen; i++) {
6324                         int64_t arr_elem = java_elems[i];
6325                         LDKUpdateFailHTLC arr_elem_conv;
6326                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
6327                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
6328                         arr_elem_conv = UpdateFailHTLC_clone(&arr_elem_conv);
6329                         ret->data[i] = arr_elem_conv;
6330                 }
6331                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
6332         }
6333         return (uint64_t)ret;
6334 }
6335 static inline LDKCVec_UpdateFailHTLCZ CVec_UpdateFailHTLCZ_clone(const LDKCVec_UpdateFailHTLCZ *orig) {
6336         LDKCVec_UpdateFailHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailHTLC) * orig->datalen, "LDKCVec_UpdateFailHTLCZ clone bytes"), .datalen = orig->datalen };
6337         for (size_t i = 0; i < ret.datalen; i++) {
6338                 ret.data[i] = UpdateFailHTLC_clone(&orig->data[i]);
6339         }
6340         return ret;
6341 }
6342 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1UpdateFailMalformedHTLCZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
6343         LDKCVec_UpdateFailMalformedHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateFailMalformedHTLCZ), "LDKCVec_UpdateFailMalformedHTLCZ");
6344         ret->datalen = (*env)->GetArrayLength(env, elems);
6345         if (ret->datalen == 0) {
6346                 ret->data = NULL;
6347         } else {
6348                 ret->data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * ret->datalen, "LDKCVec_UpdateFailMalformedHTLCZ Data");
6349                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
6350                 for (size_t i = 0; i < ret->datalen; i++) {
6351                         int64_t arr_elem = java_elems[i];
6352                         LDKUpdateFailMalformedHTLC arr_elem_conv;
6353                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
6354                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
6355                         arr_elem_conv = UpdateFailMalformedHTLC_clone(&arr_elem_conv);
6356                         ret->data[i] = arr_elem_conv;
6357                 }
6358                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
6359         }
6360         return (uint64_t)ret;
6361 }
6362 static inline LDKCVec_UpdateFailMalformedHTLCZ CVec_UpdateFailMalformedHTLCZ_clone(const LDKCVec_UpdateFailMalformedHTLCZ *orig) {
6363         LDKCVec_UpdateFailMalformedHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * orig->datalen, "LDKCVec_UpdateFailMalformedHTLCZ clone bytes"), .datalen = orig->datalen };
6364         for (size_t i = 0; i < ret.datalen; i++) {
6365                 ret.data[i] = UpdateFailMalformedHTLC_clone(&orig->data[i]);
6366         }
6367         return ret;
6368 }
6369 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AcceptChannelDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6370         return ((LDKCResult_AcceptChannelDecodeErrorZ*)arg)->result_ok;
6371 }
6372 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AcceptChannelDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6373         LDKCResult_AcceptChannelDecodeErrorZ *val = (LDKCResult_AcceptChannelDecodeErrorZ*)(arg & ~1);
6374         CHECK(val->result_ok);
6375         LDKAcceptChannel res_var = (*val->contents.result);
6376         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6377         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6378         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6379         return res_ref;
6380 }
6381 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AcceptChannelDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6382         LDKCResult_AcceptChannelDecodeErrorZ *val = (LDKCResult_AcceptChannelDecodeErrorZ*)(arg & ~1);
6383         CHECK(!val->result_ok);
6384         LDKDecodeError err_var = (*val->contents.err);
6385         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6386         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6387         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6388         return err_ref;
6389 }
6390 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AnnouncementSignaturesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6391         return ((LDKCResult_AnnouncementSignaturesDecodeErrorZ*)arg)->result_ok;
6392 }
6393 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AnnouncementSignaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6394         LDKCResult_AnnouncementSignaturesDecodeErrorZ *val = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(arg & ~1);
6395         CHECK(val->result_ok);
6396         LDKAnnouncementSignatures res_var = (*val->contents.result);
6397         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6398         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6399         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6400         return res_ref;
6401 }
6402 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AnnouncementSignaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6403         LDKCResult_AnnouncementSignaturesDecodeErrorZ *val = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(arg & ~1);
6404         CHECK(!val->result_ok);
6405         LDKDecodeError err_var = (*val->contents.err);
6406         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6407         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6408         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6409         return err_ref;
6410 }
6411 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelReestablishDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6412         return ((LDKCResult_ChannelReestablishDecodeErrorZ*)arg)->result_ok;
6413 }
6414 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelReestablishDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6415         LDKCResult_ChannelReestablishDecodeErrorZ *val = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
6416         CHECK(val->result_ok);
6417         LDKChannelReestablish res_var = (*val->contents.result);
6418         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6419         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6420         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6421         return res_ref;
6422 }
6423 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelReestablishDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6424         LDKCResult_ChannelReestablishDecodeErrorZ *val = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
6425         CHECK(!val->result_ok);
6426         LDKDecodeError err_var = (*val->contents.err);
6427         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6428         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6429         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6430         return err_ref;
6431 }
6432 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ClosingSignedDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6433         return ((LDKCResult_ClosingSignedDecodeErrorZ*)arg)->result_ok;
6434 }
6435 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ClosingSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6436         LDKCResult_ClosingSignedDecodeErrorZ *val = (LDKCResult_ClosingSignedDecodeErrorZ*)(arg & ~1);
6437         CHECK(val->result_ok);
6438         LDKClosingSigned res_var = (*val->contents.result);
6439         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6440         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6441         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6442         return res_ref;
6443 }
6444 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ClosingSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6445         LDKCResult_ClosingSignedDecodeErrorZ *val = (LDKCResult_ClosingSignedDecodeErrorZ*)(arg & ~1);
6446         CHECK(!val->result_ok);
6447         LDKDecodeError err_var = (*val->contents.err);
6448         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6449         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6450         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6451         return err_ref;
6452 }
6453 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ClosingSignedFeeRangeDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6454         return ((LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)arg)->result_ok;
6455 }
6456 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ClosingSignedFeeRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6457         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *val = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(arg & ~1);
6458         CHECK(val->result_ok);
6459         LDKClosingSignedFeeRange res_var = (*val->contents.result);
6460         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6461         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6462         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6463         return res_ref;
6464 }
6465 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ClosingSignedFeeRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6466         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *val = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(arg & ~1);
6467         CHECK(!val->result_ok);
6468         LDKDecodeError err_var = (*val->contents.err);
6469         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6470         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6471         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6472         return err_ref;
6473 }
6474 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentSignedDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6475         return ((LDKCResult_CommitmentSignedDecodeErrorZ*)arg)->result_ok;
6476 }
6477 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6478         LDKCResult_CommitmentSignedDecodeErrorZ *val = (LDKCResult_CommitmentSignedDecodeErrorZ*)(arg & ~1);
6479         CHECK(val->result_ok);
6480         LDKCommitmentSigned res_var = (*val->contents.result);
6481         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6482         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6483         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6484         return res_ref;
6485 }
6486 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6487         LDKCResult_CommitmentSignedDecodeErrorZ *val = (LDKCResult_CommitmentSignedDecodeErrorZ*)(arg & ~1);
6488         CHECK(!val->result_ok);
6489         LDKDecodeError err_var = (*val->contents.err);
6490         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6491         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6492         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6493         return err_ref;
6494 }
6495 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingCreatedDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6496         return ((LDKCResult_FundingCreatedDecodeErrorZ*)arg)->result_ok;
6497 }
6498 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingCreatedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6499         LDKCResult_FundingCreatedDecodeErrorZ *val = (LDKCResult_FundingCreatedDecodeErrorZ*)(arg & ~1);
6500         CHECK(val->result_ok);
6501         LDKFundingCreated res_var = (*val->contents.result);
6502         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6503         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6504         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6505         return res_ref;
6506 }
6507 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingCreatedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6508         LDKCResult_FundingCreatedDecodeErrorZ *val = (LDKCResult_FundingCreatedDecodeErrorZ*)(arg & ~1);
6509         CHECK(!val->result_ok);
6510         LDKDecodeError err_var = (*val->contents.err);
6511         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6512         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6513         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6514         return err_ref;
6515 }
6516 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingSignedDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6517         return ((LDKCResult_FundingSignedDecodeErrorZ*)arg)->result_ok;
6518 }
6519 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6520         LDKCResult_FundingSignedDecodeErrorZ *val = (LDKCResult_FundingSignedDecodeErrorZ*)(arg & ~1);
6521         CHECK(val->result_ok);
6522         LDKFundingSigned res_var = (*val->contents.result);
6523         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6524         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6525         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6526         return res_ref;
6527 }
6528 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6529         LDKCResult_FundingSignedDecodeErrorZ *val = (LDKCResult_FundingSignedDecodeErrorZ*)(arg & ~1);
6530         CHECK(!val->result_ok);
6531         LDKDecodeError err_var = (*val->contents.err);
6532         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6533         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6534         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6535         return err_ref;
6536 }
6537 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingLockedDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6538         return ((LDKCResult_FundingLockedDecodeErrorZ*)arg)->result_ok;
6539 }
6540 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingLockedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6541         LDKCResult_FundingLockedDecodeErrorZ *val = (LDKCResult_FundingLockedDecodeErrorZ*)(arg & ~1);
6542         CHECK(val->result_ok);
6543         LDKFundingLocked res_var = (*val->contents.result);
6544         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6545         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6546         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6547         return res_ref;
6548 }
6549 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingLockedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6550         LDKCResult_FundingLockedDecodeErrorZ *val = (LDKCResult_FundingLockedDecodeErrorZ*)(arg & ~1);
6551         CHECK(!val->result_ok);
6552         LDKDecodeError err_var = (*val->contents.err);
6553         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6554         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6555         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6556         return err_ref;
6557 }
6558 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6559         return ((LDKCResult_InitDecodeErrorZ*)arg)->result_ok;
6560 }
6561 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6562         LDKCResult_InitDecodeErrorZ *val = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
6563         CHECK(val->result_ok);
6564         LDKInit res_var = (*val->contents.result);
6565         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6566         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6567         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6568         return res_ref;
6569 }
6570 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6571         LDKCResult_InitDecodeErrorZ *val = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
6572         CHECK(!val->result_ok);
6573         LDKDecodeError err_var = (*val->contents.err);
6574         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6575         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6576         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6577         return err_ref;
6578 }
6579 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OpenChannelDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6580         return ((LDKCResult_OpenChannelDecodeErrorZ*)arg)->result_ok;
6581 }
6582 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OpenChannelDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6583         LDKCResult_OpenChannelDecodeErrorZ *val = (LDKCResult_OpenChannelDecodeErrorZ*)(arg & ~1);
6584         CHECK(val->result_ok);
6585         LDKOpenChannel res_var = (*val->contents.result);
6586         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6587         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6588         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6589         return res_ref;
6590 }
6591 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OpenChannelDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6592         LDKCResult_OpenChannelDecodeErrorZ *val = (LDKCResult_OpenChannelDecodeErrorZ*)(arg & ~1);
6593         CHECK(!val->result_ok);
6594         LDKDecodeError err_var = (*val->contents.err);
6595         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6596         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6597         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6598         return err_ref;
6599 }
6600 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RevokeAndACKDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6601         return ((LDKCResult_RevokeAndACKDecodeErrorZ*)arg)->result_ok;
6602 }
6603 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RevokeAndACKDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6604         LDKCResult_RevokeAndACKDecodeErrorZ *val = (LDKCResult_RevokeAndACKDecodeErrorZ*)(arg & ~1);
6605         CHECK(val->result_ok);
6606         LDKRevokeAndACK res_var = (*val->contents.result);
6607         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6608         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6609         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6610         return res_ref;
6611 }
6612 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RevokeAndACKDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6613         LDKCResult_RevokeAndACKDecodeErrorZ *val = (LDKCResult_RevokeAndACKDecodeErrorZ*)(arg & ~1);
6614         CHECK(!val->result_ok);
6615         LDKDecodeError err_var = (*val->contents.err);
6616         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6617         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6618         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6619         return err_ref;
6620 }
6621 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6622         return ((LDKCResult_ShutdownDecodeErrorZ*)arg)->result_ok;
6623 }
6624 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6625         LDKCResult_ShutdownDecodeErrorZ *val = (LDKCResult_ShutdownDecodeErrorZ*)(arg & ~1);
6626         CHECK(val->result_ok);
6627         LDKShutdown res_var = (*val->contents.result);
6628         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6629         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6630         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6631         return res_ref;
6632 }
6633 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6634         LDKCResult_ShutdownDecodeErrorZ *val = (LDKCResult_ShutdownDecodeErrorZ*)(arg & ~1);
6635         CHECK(!val->result_ok);
6636         LDKDecodeError err_var = (*val->contents.err);
6637         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6638         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6639         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6640         return err_ref;
6641 }
6642 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailHTLCDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6643         return ((LDKCResult_UpdateFailHTLCDecodeErrorZ*)arg)->result_ok;
6644 }
6645 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6646         LDKCResult_UpdateFailHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(arg & ~1);
6647         CHECK(val->result_ok);
6648         LDKUpdateFailHTLC res_var = (*val->contents.result);
6649         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6650         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6651         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6652         return res_ref;
6653 }
6654 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6655         LDKCResult_UpdateFailHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(arg & ~1);
6656         CHECK(!val->result_ok);
6657         LDKDecodeError err_var = (*val->contents.err);
6658         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6659         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6660         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6661         return err_ref;
6662 }
6663 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailMalformedHTLCDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6664         return ((LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)arg)->result_ok;
6665 }
6666 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailMalformedHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6667         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(arg & ~1);
6668         CHECK(val->result_ok);
6669         LDKUpdateFailMalformedHTLC res_var = (*val->contents.result);
6670         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6671         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6672         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6673         return res_ref;
6674 }
6675 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailMalformedHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6676         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(arg & ~1);
6677         CHECK(!val->result_ok);
6678         LDKDecodeError err_var = (*val->contents.err);
6679         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6680         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6681         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6682         return err_ref;
6683 }
6684 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFeeDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6685         return ((LDKCResult_UpdateFeeDecodeErrorZ*)arg)->result_ok;
6686 }
6687 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFeeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6688         LDKCResult_UpdateFeeDecodeErrorZ *val = (LDKCResult_UpdateFeeDecodeErrorZ*)(arg & ~1);
6689         CHECK(val->result_ok);
6690         LDKUpdateFee res_var = (*val->contents.result);
6691         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6692         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6693         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6694         return res_ref;
6695 }
6696 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFeeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6697         LDKCResult_UpdateFeeDecodeErrorZ *val = (LDKCResult_UpdateFeeDecodeErrorZ*)(arg & ~1);
6698         CHECK(!val->result_ok);
6699         LDKDecodeError err_var = (*val->contents.err);
6700         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6701         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6702         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6703         return err_ref;
6704 }
6705 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFulfillHTLCDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6706         return ((LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)arg)->result_ok;
6707 }
6708 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFulfillHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6709         LDKCResult_UpdateFulfillHTLCDecodeErrorZ *val = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(arg & ~1);
6710         CHECK(val->result_ok);
6711         LDKUpdateFulfillHTLC res_var = (*val->contents.result);
6712         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6713         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6714         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6715         return res_ref;
6716 }
6717 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFulfillHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6718         LDKCResult_UpdateFulfillHTLCDecodeErrorZ *val = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(arg & ~1);
6719         CHECK(!val->result_ok);
6720         LDKDecodeError err_var = (*val->contents.err);
6721         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6722         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6723         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6724         return err_ref;
6725 }
6726 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateAddHTLCDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6727         return ((LDKCResult_UpdateAddHTLCDecodeErrorZ*)arg)->result_ok;
6728 }
6729 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateAddHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6730         LDKCResult_UpdateAddHTLCDecodeErrorZ *val = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(arg & ~1);
6731         CHECK(val->result_ok);
6732         LDKUpdateAddHTLC res_var = (*val->contents.result);
6733         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6734         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6735         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6736         return res_ref;
6737 }
6738 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateAddHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6739         LDKCResult_UpdateAddHTLCDecodeErrorZ *val = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(arg & ~1);
6740         CHECK(!val->result_ok);
6741         LDKDecodeError err_var = (*val->contents.err);
6742         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6743         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6744         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6745         return err_ref;
6746 }
6747 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PingDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6748         return ((LDKCResult_PingDecodeErrorZ*)arg)->result_ok;
6749 }
6750 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PingDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6751         LDKCResult_PingDecodeErrorZ *val = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
6752         CHECK(val->result_ok);
6753         LDKPing res_var = (*val->contents.result);
6754         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6755         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6756         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6757         return res_ref;
6758 }
6759 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PingDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6760         LDKCResult_PingDecodeErrorZ *val = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
6761         CHECK(!val->result_ok);
6762         LDKDecodeError err_var = (*val->contents.err);
6763         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6764         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6765         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6766         return err_ref;
6767 }
6768 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PongDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6769         return ((LDKCResult_PongDecodeErrorZ*)arg)->result_ok;
6770 }
6771 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PongDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6772         LDKCResult_PongDecodeErrorZ *val = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
6773         CHECK(val->result_ok);
6774         LDKPong res_var = (*val->contents.result);
6775         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6776         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6777         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6778         return res_ref;
6779 }
6780 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PongDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6781         LDKCResult_PongDecodeErrorZ *val = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
6782         CHECK(!val->result_ok);
6783         LDKDecodeError err_var = (*val->contents.err);
6784         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6785         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6786         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6787         return err_ref;
6788 }
6789 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelAnnouncementDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6790         return ((LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)arg)->result_ok;
6791 }
6792 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6793         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
6794         CHECK(val->result_ok);
6795         LDKUnsignedChannelAnnouncement res_var = (*val->contents.result);
6796         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6797         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6798         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6799         return res_ref;
6800 }
6801 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6802         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
6803         CHECK(!val->result_ok);
6804         LDKDecodeError err_var = (*val->contents.err);
6805         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6806         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6807         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6808         return err_ref;
6809 }
6810 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelAnnouncementDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6811         return ((LDKCResult_ChannelAnnouncementDecodeErrorZ*)arg)->result_ok;
6812 }
6813 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6814         LDKCResult_ChannelAnnouncementDecodeErrorZ *val = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(arg & ~1);
6815         CHECK(val->result_ok);
6816         LDKChannelAnnouncement res_var = (*val->contents.result);
6817         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6818         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6819         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6820         return res_ref;
6821 }
6822 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6823         LDKCResult_ChannelAnnouncementDecodeErrorZ *val = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(arg & ~1);
6824         CHECK(!val->result_ok);
6825         LDKDecodeError err_var = (*val->contents.err);
6826         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6827         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6828         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6829         return err_ref;
6830 }
6831 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelUpdateDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6832         return ((LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)arg)->result_ok;
6833 }
6834 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6835         LDKCResult_UnsignedChannelUpdateDecodeErrorZ *val = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
6836         CHECK(val->result_ok);
6837         LDKUnsignedChannelUpdate res_var = (*val->contents.result);
6838         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6839         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6840         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6841         return res_ref;
6842 }
6843 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6844         LDKCResult_UnsignedChannelUpdateDecodeErrorZ *val = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
6845         CHECK(!val->result_ok);
6846         LDKDecodeError err_var = (*val->contents.err);
6847         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6848         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6849         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6850         return err_ref;
6851 }
6852 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelUpdateDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6853         return ((LDKCResult_ChannelUpdateDecodeErrorZ*)arg)->result_ok;
6854 }
6855 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6856         LDKCResult_ChannelUpdateDecodeErrorZ *val = (LDKCResult_ChannelUpdateDecodeErrorZ*)(arg & ~1);
6857         CHECK(val->result_ok);
6858         LDKChannelUpdate res_var = (*val->contents.result);
6859         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6860         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6861         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6862         return res_ref;
6863 }
6864 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6865         LDKCResult_ChannelUpdateDecodeErrorZ *val = (LDKCResult_ChannelUpdateDecodeErrorZ*)(arg & ~1);
6866         CHECK(!val->result_ok);
6867         LDKDecodeError err_var = (*val->contents.err);
6868         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6869         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6870         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6871         return err_ref;
6872 }
6873 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ErrorMessageDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6874         return ((LDKCResult_ErrorMessageDecodeErrorZ*)arg)->result_ok;
6875 }
6876 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ErrorMessageDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6877         LDKCResult_ErrorMessageDecodeErrorZ *val = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
6878         CHECK(val->result_ok);
6879         LDKErrorMessage res_var = (*val->contents.result);
6880         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6881         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6882         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6883         return res_ref;
6884 }
6885 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ErrorMessageDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6886         LDKCResult_ErrorMessageDecodeErrorZ *val = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
6887         CHECK(!val->result_ok);
6888         LDKDecodeError err_var = (*val->contents.err);
6889         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6890         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6891         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6892         return err_ref;
6893 }
6894 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedNodeAnnouncementDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6895         return ((LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)arg)->result_ok;
6896 }
6897 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedNodeAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6898         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
6899         CHECK(val->result_ok);
6900         LDKUnsignedNodeAnnouncement res_var = (*val->contents.result);
6901         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6902         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6903         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6904         return res_ref;
6905 }
6906 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedNodeAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6907         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
6908         CHECK(!val->result_ok);
6909         LDKDecodeError err_var = (*val->contents.err);
6910         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6911         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6912         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6913         return err_ref;
6914 }
6915 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6916         return ((LDKCResult_NodeAnnouncementDecodeErrorZ*)arg)->result_ok;
6917 }
6918 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6919         LDKCResult_NodeAnnouncementDecodeErrorZ *val = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(arg & ~1);
6920         CHECK(val->result_ok);
6921         LDKNodeAnnouncement res_var = (*val->contents.result);
6922         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6923         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6924         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6925         return res_ref;
6926 }
6927 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6928         LDKCResult_NodeAnnouncementDecodeErrorZ *val = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(arg & ~1);
6929         CHECK(!val->result_ok);
6930         LDKDecodeError err_var = (*val->contents.err);
6931         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6932         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6933         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6934         return err_ref;
6935 }
6936 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryShortChannelIdsDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6937         return ((LDKCResult_QueryShortChannelIdsDecodeErrorZ*)arg)->result_ok;
6938 }
6939 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryShortChannelIdsDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6940         LDKCResult_QueryShortChannelIdsDecodeErrorZ *val = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
6941         CHECK(val->result_ok);
6942         LDKQueryShortChannelIds res_var = (*val->contents.result);
6943         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6944         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6945         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6946         return res_ref;
6947 }
6948 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryShortChannelIdsDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6949         LDKCResult_QueryShortChannelIdsDecodeErrorZ *val = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
6950         CHECK(!val->result_ok);
6951         LDKDecodeError err_var = (*val->contents.err);
6952         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6953         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6954         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6955         return err_ref;
6956 }
6957 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyShortChannelIdsEndDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6958         return ((LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)arg)->result_ok;
6959 }
6960 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyShortChannelIdsEndDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6961         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *val = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
6962         CHECK(val->result_ok);
6963         LDKReplyShortChannelIdsEnd res_var = (*val->contents.result);
6964         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6965         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6966         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6967         return res_ref;
6968 }
6969 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyShortChannelIdsEndDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6970         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *val = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
6971         CHECK(!val->result_ok);
6972         LDKDecodeError err_var = (*val->contents.err);
6973         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6974         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6975         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6976         return err_ref;
6977 }
6978 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryChannelRangeDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6979         return ((LDKCResult_QueryChannelRangeDecodeErrorZ*)arg)->result_ok;
6980 }
6981 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryChannelRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6982         LDKCResult_QueryChannelRangeDecodeErrorZ *val = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
6983         CHECK(val->result_ok);
6984         LDKQueryChannelRange res_var = (*val->contents.result);
6985         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6986         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6987         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6988         return res_ref;
6989 }
6990 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryChannelRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6991         LDKCResult_QueryChannelRangeDecodeErrorZ *val = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
6992         CHECK(!val->result_ok);
6993         LDKDecodeError err_var = (*val->contents.err);
6994         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6995         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6996         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6997         return err_ref;
6998 }
6999 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyChannelRangeDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
7000         return ((LDKCResult_ReplyChannelRangeDecodeErrorZ*)arg)->result_ok;
7001 }
7002 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyChannelRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
7003         LDKCResult_ReplyChannelRangeDecodeErrorZ *val = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
7004         CHECK(val->result_ok);
7005         LDKReplyChannelRange res_var = (*val->contents.result);
7006         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7007         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7008         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
7009         return res_ref;
7010 }
7011 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyChannelRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
7012         LDKCResult_ReplyChannelRangeDecodeErrorZ *val = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
7013         CHECK(!val->result_ok);
7014         LDKDecodeError err_var = (*val->contents.err);
7015         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7016         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7017         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
7018         return err_ref;
7019 }
7020 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1GossipTimestampFilterDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
7021         return ((LDKCResult_GossipTimestampFilterDecodeErrorZ*)arg)->result_ok;
7022 }
7023 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1GossipTimestampFilterDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
7024         LDKCResult_GossipTimestampFilterDecodeErrorZ *val = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
7025         CHECK(val->result_ok);
7026         LDKGossipTimestampFilter res_var = (*val->contents.result);
7027         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7028         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7029         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
7030         return res_ref;
7031 }
7032 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1GossipTimestampFilterDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
7033         LDKCResult_GossipTimestampFilterDecodeErrorZ *val = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
7034         CHECK(!val->result_ok);
7035         LDKDecodeError err_var = (*val->contents.err);
7036         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7037         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7038         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
7039         return err_ref;
7040 }
7041 static jclass LDKSignOrCreationError_SignError_class = NULL;
7042 static jmethodID LDKSignOrCreationError_SignError_meth = NULL;
7043 static jclass LDKSignOrCreationError_CreationError_class = NULL;
7044 static jmethodID LDKSignOrCreationError_CreationError_meth = NULL;
7045 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKSignOrCreationError_init (JNIEnv *env, jclass clz) {
7046         LDKSignOrCreationError_SignError_class =
7047                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKSignOrCreationError$SignError;"));
7048         CHECK(LDKSignOrCreationError_SignError_class != NULL);
7049         LDKSignOrCreationError_SignError_meth = (*env)->GetMethodID(env, LDKSignOrCreationError_SignError_class, "<init>", "()V");
7050         CHECK(LDKSignOrCreationError_SignError_meth != NULL);
7051         LDKSignOrCreationError_CreationError_class =
7052                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKSignOrCreationError$CreationError;"));
7053         CHECK(LDKSignOrCreationError_CreationError_class != NULL);
7054         LDKSignOrCreationError_CreationError_meth = (*env)->GetMethodID(env, LDKSignOrCreationError_CreationError_class, "<init>", "(Lorg/ldk/enums/CreationError;)V");
7055         CHECK(LDKSignOrCreationError_CreationError_meth != NULL);
7056 }
7057 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKSignOrCreationError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
7058         LDKSignOrCreationError *obj = (LDKSignOrCreationError*)(ptr & ~1);
7059         switch(obj->tag) {
7060                 case LDKSignOrCreationError_SignError: {
7061                         return (*env)->NewObject(env, LDKSignOrCreationError_SignError_class, LDKSignOrCreationError_SignError_meth);
7062                 }
7063                 case LDKSignOrCreationError_CreationError: {
7064                         jclass creation_error_conv = LDKCreationError_to_java(env, obj->creation_error);
7065                         return (*env)->NewObject(env, LDKSignOrCreationError_CreationError_class, LDKSignOrCreationError_CreationError_meth, creation_error_conv);
7066                 }
7067                 default: abort();
7068         }
7069 }
7070 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceSignOrCreationErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
7071         return ((LDKCResult_InvoiceSignOrCreationErrorZ*)arg)->result_ok;
7072 }
7073 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceSignOrCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
7074         LDKCResult_InvoiceSignOrCreationErrorZ *val = (LDKCResult_InvoiceSignOrCreationErrorZ*)(arg & ~1);
7075         CHECK(val->result_ok);
7076         LDKInvoice res_var = (*val->contents.result);
7077         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7078         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7079         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
7080         return res_ref;
7081 }
7082 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceSignOrCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
7083         LDKCResult_InvoiceSignOrCreationErrorZ *val = (LDKCResult_InvoiceSignOrCreationErrorZ*)(arg & ~1);
7084         CHECK(!val->result_ok);
7085         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
7086         return err_ref;
7087 }
7088 typedef struct LDKFilter_JCalls {
7089         atomic_size_t refcnt;
7090         JavaVM *vm;
7091         jweak o;
7092         jmethodID register_tx_meth;
7093         jmethodID register_output_meth;
7094 } LDKFilter_JCalls;
7095 static void LDKFilter_JCalls_free(void* this_arg) {
7096         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
7097         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7098                 JNIEnv *env;
7099                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7100                 if (get_jenv_res == JNI_EDETACHED) {
7101                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7102                 } else {
7103                         DO_ASSERT(get_jenv_res == JNI_OK);
7104                 }
7105                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
7106                 if (get_jenv_res == JNI_EDETACHED) {
7107                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7108                 }
7109                 FREE(j_calls);
7110         }
7111 }
7112 void register_tx_LDKFilter_jcall(const void* this_arg, const uint8_t (* txid)[32], LDKu8slice script_pubkey) {
7113         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
7114         JNIEnv *env;
7115         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7116         if (get_jenv_res == JNI_EDETACHED) {
7117                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7118         } else {
7119                 DO_ASSERT(get_jenv_res == JNI_OK);
7120         }
7121         int8_tArray txid_arr = (*env)->NewByteArray(env, 32);
7122         (*env)->SetByteArrayRegion(env, txid_arr, 0, 32, *txid);
7123         LDKu8slice script_pubkey_var = script_pubkey;
7124         int8_tArray script_pubkey_arr = (*env)->NewByteArray(env, script_pubkey_var.datalen);
7125         (*env)->SetByteArrayRegion(env, script_pubkey_arr, 0, script_pubkey_var.datalen, script_pubkey_var.data);
7126         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7127         CHECK(obj != NULL);
7128         (*env)->CallVoidMethod(env, obj, j_calls->register_tx_meth, txid_arr, script_pubkey_arr);
7129         if ((*env)->ExceptionCheck(env)) {
7130                 (*env)->ExceptionDescribe(env);
7131                 (*env)->FatalError(env, "A call to register_tx in LDKFilter from rust threw an exception.");
7132         }
7133         if (get_jenv_res == JNI_EDETACHED) {
7134                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7135         }
7136 }
7137 LDKCOption_C2Tuple_usizeTransactionZZ register_output_LDKFilter_jcall(const void* this_arg, LDKWatchedOutput output) {
7138         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
7139         JNIEnv *env;
7140         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7141         if (get_jenv_res == JNI_EDETACHED) {
7142                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7143         } else {
7144                 DO_ASSERT(get_jenv_res == JNI_OK);
7145         }
7146         LDKWatchedOutput output_var = output;
7147         CHECK((((uint64_t)output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7148         CHECK((((uint64_t)&output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7149         uint64_t output_ref = (uint64_t)output_var.inner;
7150         if (output_var.is_owned) {
7151                 output_ref |= 1;
7152         }
7153         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7154         CHECK(obj != NULL);
7155         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->register_output_meth, output_ref);
7156         if ((*env)->ExceptionCheck(env)) {
7157                 (*env)->ExceptionDescribe(env);
7158                 (*env)->FatalError(env, "A call to register_output in LDKFilter from rust threw an exception.");
7159         }
7160         LDKCOption_C2Tuple_usizeTransactionZZ ret_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(((uint64_t)ret) & ~1);
7161         ret_conv = COption_C2Tuple_usizeTransactionZZ_clone((LDKCOption_C2Tuple_usizeTransactionZZ*)(((uint64_t)ret) & ~1));
7162         if (get_jenv_res == JNI_EDETACHED) {
7163                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7164         }
7165         return ret_conv;
7166 }
7167 static void LDKFilter_JCalls_cloned(LDKFilter* new_obj) {
7168         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) new_obj->this_arg;
7169         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7170 }
7171 static inline LDKFilter LDKFilter_init (JNIEnv *env, jclass clz, jobject o) {
7172         jclass c = (*env)->GetObjectClass(env, o);
7173         CHECK(c != NULL);
7174         LDKFilter_JCalls *calls = MALLOC(sizeof(LDKFilter_JCalls), "LDKFilter_JCalls");
7175         atomic_init(&calls->refcnt, 1);
7176         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
7177         calls->o = (*env)->NewWeakGlobalRef(env, o);
7178         calls->register_tx_meth = (*env)->GetMethodID(env, c, "register_tx", "([B[B)V");
7179         CHECK(calls->register_tx_meth != NULL);
7180         calls->register_output_meth = (*env)->GetMethodID(env, c, "register_output", "(J)J");
7181         CHECK(calls->register_output_meth != NULL);
7182
7183         LDKFilter ret = {
7184                 .this_arg = (void*) calls,
7185                 .register_tx = register_tx_LDKFilter_jcall,
7186                 .register_output = register_output_LDKFilter_jcall,
7187                 .free = LDKFilter_JCalls_free,
7188         };
7189         return ret;
7190 }
7191 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKFilter_1new(JNIEnv *env, jclass clz, jobject o) {
7192         LDKFilter *res_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter");
7193         *res_ptr = LDKFilter_init(env, clz, o);
7194         return (uint64_t)res_ptr;
7195 }
7196 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) {
7197         LDKFilter* this_arg_conv = (LDKFilter*)(((uint64_t)this_arg) & ~1);
7198         unsigned char txid_arr[32];
7199         CHECK((*env)->GetArrayLength(env, txid) == 32);
7200         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
7201         unsigned char (*txid_ref)[32] = &txid_arr;
7202         LDKu8slice script_pubkey_ref;
7203         script_pubkey_ref.datalen = (*env)->GetArrayLength(env, script_pubkey);
7204         script_pubkey_ref.data = (*env)->GetByteArrayElements (env, script_pubkey, NULL);
7205         (this_arg_conv->register_tx)(this_arg_conv->this_arg, txid_ref, script_pubkey_ref);
7206         (*env)->ReleaseByteArrayElements(env, script_pubkey, (int8_t*)script_pubkey_ref.data, 0);
7207 }
7208
7209 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Filter_1register_1output(JNIEnv *env, jclass clz, int64_t this_arg, int64_t output) {
7210         LDKFilter* this_arg_conv = (LDKFilter*)(((uint64_t)this_arg) & ~1);
7211         LDKWatchedOutput output_conv;
7212         output_conv.inner = (void*)(output & (~1));
7213         output_conv.is_owned = (output & 1) || (output == 0);
7214         output_conv = WatchedOutput_clone(&output_conv);
7215         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
7216         *ret_copy = (this_arg_conv->register_output)(this_arg_conv->this_arg, output_conv);
7217         uint64_t ret_ref = (uint64_t)ret_copy;
7218         return ret_ref;
7219 }
7220
7221 static jclass LDKCOption_FilterZ_Some_class = NULL;
7222 static jmethodID LDKCOption_FilterZ_Some_meth = NULL;
7223 static jclass LDKCOption_FilterZ_None_class = NULL;
7224 static jmethodID LDKCOption_FilterZ_None_meth = NULL;
7225 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1FilterZ_init (JNIEnv *env, jclass clz) {
7226         LDKCOption_FilterZ_Some_class =
7227                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_FilterZ$Some;"));
7228         CHECK(LDKCOption_FilterZ_Some_class != NULL);
7229         LDKCOption_FilterZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_FilterZ_Some_class, "<init>", "(J)V");
7230         CHECK(LDKCOption_FilterZ_Some_meth != NULL);
7231         LDKCOption_FilterZ_None_class =
7232                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_FilterZ$None;"));
7233         CHECK(LDKCOption_FilterZ_None_class != NULL);
7234         LDKCOption_FilterZ_None_meth = (*env)->GetMethodID(env, LDKCOption_FilterZ_None_class, "<init>", "()V");
7235         CHECK(LDKCOption_FilterZ_None_meth != NULL);
7236 }
7237 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1FilterZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
7238         LDKCOption_FilterZ *obj = (LDKCOption_FilterZ*)(ptr & ~1);
7239         switch(obj->tag) {
7240                 case LDKCOption_FilterZ_Some: {
7241                         LDKFilter* some_ret =MALLOC(sizeof(LDKFilter), "LDKFilter");
7242                         *some_ret = obj->some;
7243                         // Warning: We likely need to clone here, but no clone is available, so we just do it for Java instances
7244                         if ((*some_ret).free == LDKFilter_JCalls_free) {
7245                                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
7246                                 LDKFilter_JCalls_cloned(&(*some_ret));
7247                         }
7248                         return (*env)->NewObject(env, LDKCOption_FilterZ_Some_class, LDKCOption_FilterZ_Some_meth, (uint64_t)some_ret);
7249                 }
7250                 case LDKCOption_FilterZ_None: {
7251                         return (*env)->NewObject(env, LDKCOption_FilterZ_None_class, LDKCOption_FilterZ_None_meth);
7252                 }
7253                 default: abort();
7254         }
7255 }
7256 typedef struct LDKMessageSendEventsProvider_JCalls {
7257         atomic_size_t refcnt;
7258         JavaVM *vm;
7259         jweak o;
7260         jmethodID get_and_clear_pending_msg_events_meth;
7261 } LDKMessageSendEventsProvider_JCalls;
7262 static void LDKMessageSendEventsProvider_JCalls_free(void* this_arg) {
7263         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
7264         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7265                 JNIEnv *env;
7266                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7267                 if (get_jenv_res == JNI_EDETACHED) {
7268                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7269                 } else {
7270                         DO_ASSERT(get_jenv_res == JNI_OK);
7271                 }
7272                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
7273                 if (get_jenv_res == JNI_EDETACHED) {
7274                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7275                 }
7276                 FREE(j_calls);
7277         }
7278 }
7279 LDKCVec_MessageSendEventZ get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall(const void* this_arg) {
7280         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
7281         JNIEnv *env;
7282         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7283         if (get_jenv_res == JNI_EDETACHED) {
7284                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7285         } else {
7286                 DO_ASSERT(get_jenv_res == JNI_OK);
7287         }
7288         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7289         CHECK(obj != NULL);
7290         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_and_clear_pending_msg_events_meth);
7291         if ((*env)->ExceptionCheck(env)) {
7292                 (*env)->ExceptionDescribe(env);
7293                 (*env)->FatalError(env, "A call to get_and_clear_pending_msg_events in LDKMessageSendEventsProvider from rust threw an exception.");
7294         }
7295         LDKCVec_MessageSendEventZ ret_constr;
7296         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
7297         if (ret_constr.datalen > 0)
7298                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
7299         else
7300                 ret_constr.data = NULL;
7301         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
7302         for (size_t s = 0; s < ret_constr.datalen; s++) {
7303                 int64_t ret_conv_18 = ret_vals[s];
7304                 LDKMessageSendEvent ret_conv_18_conv = *(LDKMessageSendEvent*)(((uint64_t)ret_conv_18) & ~1);
7305                 ret_conv_18_conv = MessageSendEvent_clone((LDKMessageSendEvent*)(((uint64_t)ret_conv_18) & ~1));
7306                 ret_constr.data[s] = ret_conv_18_conv;
7307         }
7308         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
7309         if (get_jenv_res == JNI_EDETACHED) {
7310                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7311         }
7312         return ret_constr;
7313 }
7314 static void LDKMessageSendEventsProvider_JCalls_cloned(LDKMessageSendEventsProvider* new_obj) {
7315         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) new_obj->this_arg;
7316         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7317 }
7318 static inline LDKMessageSendEventsProvider LDKMessageSendEventsProvider_init (JNIEnv *env, jclass clz, jobject o) {
7319         jclass c = (*env)->GetObjectClass(env, o);
7320         CHECK(c != NULL);
7321         LDKMessageSendEventsProvider_JCalls *calls = MALLOC(sizeof(LDKMessageSendEventsProvider_JCalls), "LDKMessageSendEventsProvider_JCalls");
7322         atomic_init(&calls->refcnt, 1);
7323         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
7324         calls->o = (*env)->NewWeakGlobalRef(env, o);
7325         calls->get_and_clear_pending_msg_events_meth = (*env)->GetMethodID(env, c, "get_and_clear_pending_msg_events", "()[J");
7326         CHECK(calls->get_and_clear_pending_msg_events_meth != NULL);
7327
7328         LDKMessageSendEventsProvider ret = {
7329                 .this_arg = (void*) calls,
7330                 .get_and_clear_pending_msg_events = get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall,
7331                 .free = LDKMessageSendEventsProvider_JCalls_free,
7332         };
7333         return ret;
7334 }
7335 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEventsProvider_1new(JNIEnv *env, jclass clz, jobject o) {
7336         LDKMessageSendEventsProvider *res_ptr = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
7337         *res_ptr = LDKMessageSendEventsProvider_init(env, clz, o);
7338         return (uint64_t)res_ptr;
7339 }
7340 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_MessageSendEventsProvider_1get_1and_1clear_1pending_1msg_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
7341         LDKMessageSendEventsProvider* this_arg_conv = (LDKMessageSendEventsProvider*)(((uint64_t)this_arg) & ~1);
7342         LDKCVec_MessageSendEventZ ret_var = (this_arg_conv->get_and_clear_pending_msg_events)(this_arg_conv->this_arg);
7343         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
7344         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
7345         for (size_t s = 0; s < ret_var.datalen; s++) {
7346                 LDKMessageSendEvent *ret_conv_18_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
7347                 *ret_conv_18_copy = MessageSendEvent_clone(&ret_var.data[s]);
7348                 uint64_t ret_conv_18_ref = (uint64_t)ret_conv_18_copy;
7349                 ret_arr_ptr[s] = ret_conv_18_ref;
7350         }
7351         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
7352         FREE(ret_var.data);
7353         return ret_arr;
7354 }
7355
7356 typedef struct LDKEventHandler_JCalls {
7357         atomic_size_t refcnt;
7358         JavaVM *vm;
7359         jweak o;
7360         jmethodID handle_event_meth;
7361 } LDKEventHandler_JCalls;
7362 static void LDKEventHandler_JCalls_free(void* this_arg) {
7363         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
7364         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7365                 JNIEnv *env;
7366                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7367                 if (get_jenv_res == JNI_EDETACHED) {
7368                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7369                 } else {
7370                         DO_ASSERT(get_jenv_res == JNI_OK);
7371                 }
7372                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
7373                 if (get_jenv_res == JNI_EDETACHED) {
7374                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7375                 }
7376                 FREE(j_calls);
7377         }
7378 }
7379 void handle_event_LDKEventHandler_jcall(const void* this_arg, const LDKEvent * event) {
7380         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
7381         JNIEnv *env;
7382         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7383         if (get_jenv_res == JNI_EDETACHED) {
7384                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7385         } else {
7386                 DO_ASSERT(get_jenv_res == JNI_OK);
7387         }
7388         LDKEvent *ret_event = MALLOC(sizeof(LDKEvent), "LDKEvent ret conversion");
7389         *ret_event = Event_clone(event);
7390         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7391         CHECK(obj != NULL);
7392         (*env)->CallVoidMethod(env, obj, j_calls->handle_event_meth, (uint64_t)ret_event);
7393         if ((*env)->ExceptionCheck(env)) {
7394                 (*env)->ExceptionDescribe(env);
7395                 (*env)->FatalError(env, "A call to handle_event in LDKEventHandler from rust threw an exception.");
7396         }
7397         if (get_jenv_res == JNI_EDETACHED) {
7398                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7399         }
7400 }
7401 static void LDKEventHandler_JCalls_cloned(LDKEventHandler* new_obj) {
7402         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) new_obj->this_arg;
7403         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7404 }
7405 static inline LDKEventHandler LDKEventHandler_init (JNIEnv *env, jclass clz, jobject o) {
7406         jclass c = (*env)->GetObjectClass(env, o);
7407         CHECK(c != NULL);
7408         LDKEventHandler_JCalls *calls = MALLOC(sizeof(LDKEventHandler_JCalls), "LDKEventHandler_JCalls");
7409         atomic_init(&calls->refcnt, 1);
7410         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
7411         calls->o = (*env)->NewWeakGlobalRef(env, o);
7412         calls->handle_event_meth = (*env)->GetMethodID(env, c, "handle_event", "(J)V");
7413         CHECK(calls->handle_event_meth != NULL);
7414
7415         LDKEventHandler ret = {
7416                 .this_arg = (void*) calls,
7417                 .handle_event = handle_event_LDKEventHandler_jcall,
7418                 .free = LDKEventHandler_JCalls_free,
7419         };
7420         return ret;
7421 }
7422 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKEventHandler_1new(JNIEnv *env, jclass clz, jobject o) {
7423         LDKEventHandler *res_ptr = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
7424         *res_ptr = LDKEventHandler_init(env, clz, o);
7425         return (uint64_t)res_ptr;
7426 }
7427 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventHandler_1handle_1event(JNIEnv *env, jclass clz, int64_t this_arg, int64_t event) {
7428         LDKEventHandler* this_arg_conv = (LDKEventHandler*)(((uint64_t)this_arg) & ~1);
7429         LDKEvent* event_conv = (LDKEvent*)event;
7430         (this_arg_conv->handle_event)(this_arg_conv->this_arg, event_conv);
7431 }
7432
7433 typedef struct LDKEventsProvider_JCalls {
7434         atomic_size_t refcnt;
7435         JavaVM *vm;
7436         jweak o;
7437         jmethodID process_pending_events_meth;
7438 } LDKEventsProvider_JCalls;
7439 static void LDKEventsProvider_JCalls_free(void* this_arg) {
7440         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
7441         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7442                 JNIEnv *env;
7443                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7444                 if (get_jenv_res == JNI_EDETACHED) {
7445                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7446                 } else {
7447                         DO_ASSERT(get_jenv_res == JNI_OK);
7448                 }
7449                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
7450                 if (get_jenv_res == JNI_EDETACHED) {
7451                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7452                 }
7453                 FREE(j_calls);
7454         }
7455 }
7456 void process_pending_events_LDKEventsProvider_jcall(const void* this_arg, LDKEventHandler handler) {
7457         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
7458         JNIEnv *env;
7459         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7460         if (get_jenv_res == JNI_EDETACHED) {
7461                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7462         } else {
7463                 DO_ASSERT(get_jenv_res == JNI_OK);
7464         }
7465         LDKEventHandler* handler_ret =MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
7466         *handler_ret = handler;
7467         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7468         CHECK(obj != NULL);
7469         (*env)->CallVoidMethod(env, obj, j_calls->process_pending_events_meth, (uint64_t)handler_ret);
7470         if ((*env)->ExceptionCheck(env)) {
7471                 (*env)->ExceptionDescribe(env);
7472                 (*env)->FatalError(env, "A call to process_pending_events in LDKEventsProvider from rust threw an exception.");
7473         }
7474         if (get_jenv_res == JNI_EDETACHED) {
7475                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7476         }
7477 }
7478 static void LDKEventsProvider_JCalls_cloned(LDKEventsProvider* new_obj) {
7479         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) new_obj->this_arg;
7480         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7481 }
7482 static inline LDKEventsProvider LDKEventsProvider_init (JNIEnv *env, jclass clz, jobject o) {
7483         jclass c = (*env)->GetObjectClass(env, o);
7484         CHECK(c != NULL);
7485         LDKEventsProvider_JCalls *calls = MALLOC(sizeof(LDKEventsProvider_JCalls), "LDKEventsProvider_JCalls");
7486         atomic_init(&calls->refcnt, 1);
7487         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
7488         calls->o = (*env)->NewWeakGlobalRef(env, o);
7489         calls->process_pending_events_meth = (*env)->GetMethodID(env, c, "process_pending_events", "(J)V");
7490         CHECK(calls->process_pending_events_meth != NULL);
7491
7492         LDKEventsProvider ret = {
7493                 .this_arg = (void*) calls,
7494                 .process_pending_events = process_pending_events_LDKEventsProvider_jcall,
7495                 .free = LDKEventsProvider_JCalls_free,
7496         };
7497         return ret;
7498 }
7499 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKEventsProvider_1new(JNIEnv *env, jclass clz, jobject o) {
7500         LDKEventsProvider *res_ptr = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
7501         *res_ptr = LDKEventsProvider_init(env, clz, o);
7502         return (uint64_t)res_ptr;
7503 }
7504 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventsProvider_1process_1pending_1events(JNIEnv *env, jclass clz, int64_t this_arg, int64_t handler) {
7505         LDKEventsProvider* this_arg_conv = (LDKEventsProvider*)(((uint64_t)this_arg) & ~1);
7506         LDKEventHandler handler_conv = *(LDKEventHandler*)(((uint64_t)handler) & ~1);
7507         if (handler_conv.free == LDKEventHandler_JCalls_free) {
7508                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
7509                 LDKEventHandler_JCalls_cloned(&handler_conv);
7510         }
7511         (this_arg_conv->process_pending_events)(this_arg_conv->this_arg, handler_conv);
7512 }
7513
7514 typedef struct LDKListen_JCalls {
7515         atomic_size_t refcnt;
7516         JavaVM *vm;
7517         jweak o;
7518         jmethodID block_connected_meth;
7519         jmethodID block_disconnected_meth;
7520 } LDKListen_JCalls;
7521 static void LDKListen_JCalls_free(void* this_arg) {
7522         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
7523         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7524                 JNIEnv *env;
7525                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7526                 if (get_jenv_res == JNI_EDETACHED) {
7527                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7528                 } else {
7529                         DO_ASSERT(get_jenv_res == JNI_OK);
7530                 }
7531                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
7532                 if (get_jenv_res == JNI_EDETACHED) {
7533                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7534                 }
7535                 FREE(j_calls);
7536         }
7537 }
7538 void block_connected_LDKListen_jcall(const void* this_arg, LDKu8slice block, uint32_t height) {
7539         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
7540         JNIEnv *env;
7541         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7542         if (get_jenv_res == JNI_EDETACHED) {
7543                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7544         } else {
7545                 DO_ASSERT(get_jenv_res == JNI_OK);
7546         }
7547         LDKu8slice block_var = block;
7548         int8_tArray block_arr = (*env)->NewByteArray(env, block_var.datalen);
7549         (*env)->SetByteArrayRegion(env, block_arr, 0, block_var.datalen, block_var.data);
7550         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7551         CHECK(obj != NULL);
7552         (*env)->CallVoidMethod(env, obj, j_calls->block_connected_meth, block_arr, height);
7553         if ((*env)->ExceptionCheck(env)) {
7554                 (*env)->ExceptionDescribe(env);
7555                 (*env)->FatalError(env, "A call to block_connected in LDKListen from rust threw an exception.");
7556         }
7557         if (get_jenv_res == JNI_EDETACHED) {
7558                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7559         }
7560 }
7561 void block_disconnected_LDKListen_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
7562         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
7563         JNIEnv *env;
7564         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7565         if (get_jenv_res == JNI_EDETACHED) {
7566                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7567         } else {
7568                 DO_ASSERT(get_jenv_res == JNI_OK);
7569         }
7570         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
7571         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
7572         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7573         CHECK(obj != NULL);
7574         (*env)->CallVoidMethod(env, obj, j_calls->block_disconnected_meth, header_arr, height);
7575         if ((*env)->ExceptionCheck(env)) {
7576                 (*env)->ExceptionDescribe(env);
7577                 (*env)->FatalError(env, "A call to block_disconnected in LDKListen from rust threw an exception.");
7578         }
7579         if (get_jenv_res == JNI_EDETACHED) {
7580                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7581         }
7582 }
7583 static void LDKListen_JCalls_cloned(LDKListen* new_obj) {
7584         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) new_obj->this_arg;
7585         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7586 }
7587 static inline LDKListen LDKListen_init (JNIEnv *env, jclass clz, jobject o) {
7588         jclass c = (*env)->GetObjectClass(env, o);
7589         CHECK(c != NULL);
7590         LDKListen_JCalls *calls = MALLOC(sizeof(LDKListen_JCalls), "LDKListen_JCalls");
7591         atomic_init(&calls->refcnt, 1);
7592         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
7593         calls->o = (*env)->NewWeakGlobalRef(env, o);
7594         calls->block_connected_meth = (*env)->GetMethodID(env, c, "block_connected", "([BI)V");
7595         CHECK(calls->block_connected_meth != NULL);
7596         calls->block_disconnected_meth = (*env)->GetMethodID(env, c, "block_disconnected", "([BI)V");
7597         CHECK(calls->block_disconnected_meth != NULL);
7598
7599         LDKListen ret = {
7600                 .this_arg = (void*) calls,
7601                 .block_connected = block_connected_LDKListen_jcall,
7602                 .block_disconnected = block_disconnected_LDKListen_jcall,
7603                 .free = LDKListen_JCalls_free,
7604         };
7605         return ret;
7606 }
7607 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKListen_1new(JNIEnv *env, jclass clz, jobject o) {
7608         LDKListen *res_ptr = MALLOC(sizeof(LDKListen), "LDKListen");
7609         *res_ptr = LDKListen_init(env, clz, o);
7610         return (uint64_t)res_ptr;
7611 }
7612 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) {
7613         LDKListen* this_arg_conv = (LDKListen*)(((uint64_t)this_arg) & ~1);
7614         LDKu8slice block_ref;
7615         block_ref.datalen = (*env)->GetArrayLength(env, block);
7616         block_ref.data = (*env)->GetByteArrayElements (env, block, NULL);
7617         (this_arg_conv->block_connected)(this_arg_conv->this_arg, block_ref, height);
7618         (*env)->ReleaseByteArrayElements(env, block, (int8_t*)block_ref.data, 0);
7619 }
7620
7621 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) {
7622         LDKListen* this_arg_conv = (LDKListen*)(((uint64_t)this_arg) & ~1);
7623         unsigned char header_arr[80];
7624         CHECK((*env)->GetArrayLength(env, header) == 80);
7625         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
7626         unsigned char (*header_ref)[80] = &header_arr;
7627         (this_arg_conv->block_disconnected)(this_arg_conv->this_arg, header_ref, height);
7628 }
7629
7630 typedef struct LDKConfirm_JCalls {
7631         atomic_size_t refcnt;
7632         JavaVM *vm;
7633         jweak o;
7634         jmethodID transactions_confirmed_meth;
7635         jmethodID transaction_unconfirmed_meth;
7636         jmethodID best_block_updated_meth;
7637         jmethodID get_relevant_txids_meth;
7638 } LDKConfirm_JCalls;
7639 static void LDKConfirm_JCalls_free(void* this_arg) {
7640         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
7641         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7642                 JNIEnv *env;
7643                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7644                 if (get_jenv_res == JNI_EDETACHED) {
7645                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7646                 } else {
7647                         DO_ASSERT(get_jenv_res == JNI_OK);
7648                 }
7649                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
7650                 if (get_jenv_res == JNI_EDETACHED) {
7651                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7652                 }
7653                 FREE(j_calls);
7654         }
7655 }
7656 void transactions_confirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height) {
7657         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
7658         JNIEnv *env;
7659         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7660         if (get_jenv_res == JNI_EDETACHED) {
7661                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7662         } else {
7663                 DO_ASSERT(get_jenv_res == JNI_OK);
7664         }
7665         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
7666         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
7667         LDKCVec_C2Tuple_usizeTransactionZZ txdata_var = txdata;
7668         int64_tArray txdata_arr = (*env)->NewLongArray(env, txdata_var.datalen);
7669         int64_t *txdata_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, txdata_arr, NULL);
7670         for (size_t c = 0; c < txdata_var.datalen; c++) {
7671                 LDKC2Tuple_usizeTransactionZ* txdata_conv_28_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
7672                 *txdata_conv_28_conv = txdata_var.data[c];
7673                 txdata_arr_ptr[c] = ((uint64_t)txdata_conv_28_conv);
7674         }
7675         (*env)->ReleasePrimitiveArrayCritical(env, txdata_arr, txdata_arr_ptr, 0);
7676         FREE(txdata_var.data);
7677         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7678         CHECK(obj != NULL);
7679         (*env)->CallVoidMethod(env, obj, j_calls->transactions_confirmed_meth, header_arr, txdata_arr, height);
7680         if ((*env)->ExceptionCheck(env)) {
7681                 (*env)->ExceptionDescribe(env);
7682                 (*env)->FatalError(env, "A call to transactions_confirmed in LDKConfirm from rust threw an exception.");
7683         }
7684         if (get_jenv_res == JNI_EDETACHED) {
7685                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7686         }
7687 }
7688 void transaction_unconfirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* txid)[32]) {
7689         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
7690         JNIEnv *env;
7691         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7692         if (get_jenv_res == JNI_EDETACHED) {
7693                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7694         } else {
7695                 DO_ASSERT(get_jenv_res == JNI_OK);
7696         }
7697         int8_tArray txid_arr = (*env)->NewByteArray(env, 32);
7698         (*env)->SetByteArrayRegion(env, txid_arr, 0, 32, *txid);
7699         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7700         CHECK(obj != NULL);
7701         (*env)->CallVoidMethod(env, obj, j_calls->transaction_unconfirmed_meth, txid_arr);
7702         if ((*env)->ExceptionCheck(env)) {
7703                 (*env)->ExceptionDescribe(env);
7704                 (*env)->FatalError(env, "A call to transaction_unconfirmed in LDKConfirm from rust threw an exception.");
7705         }
7706         if (get_jenv_res == JNI_EDETACHED) {
7707                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7708         }
7709 }
7710 void best_block_updated_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
7711         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
7712         JNIEnv *env;
7713         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7714         if (get_jenv_res == JNI_EDETACHED) {
7715                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7716         } else {
7717                 DO_ASSERT(get_jenv_res == JNI_OK);
7718         }
7719         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
7720         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
7721         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7722         CHECK(obj != NULL);
7723         (*env)->CallVoidMethod(env, obj, j_calls->best_block_updated_meth, header_arr, height);
7724         if ((*env)->ExceptionCheck(env)) {
7725                 (*env)->ExceptionDescribe(env);
7726                 (*env)->FatalError(env, "A call to best_block_updated in LDKConfirm from rust threw an exception.");
7727         }
7728         if (get_jenv_res == JNI_EDETACHED) {
7729                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7730         }
7731 }
7732 LDKCVec_TxidZ get_relevant_txids_LDKConfirm_jcall(const void* this_arg) {
7733         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
7734         JNIEnv *env;
7735         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7736         if (get_jenv_res == JNI_EDETACHED) {
7737                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7738         } else {
7739                 DO_ASSERT(get_jenv_res == JNI_OK);
7740         }
7741         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7742         CHECK(obj != NULL);
7743         jobjectArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_relevant_txids_meth);
7744         if ((*env)->ExceptionCheck(env)) {
7745                 (*env)->ExceptionDescribe(env);
7746                 (*env)->FatalError(env, "A call to get_relevant_txids in LDKConfirm from rust threw an exception.");
7747         }
7748         LDKCVec_TxidZ ret_constr;
7749         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
7750         if (ret_constr.datalen > 0)
7751                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
7752         else
7753                 ret_constr.data = NULL;
7754         for (size_t i = 0; i < ret_constr.datalen; i++) {
7755                 int8_tArray ret_conv_8 = (*env)->GetObjectArrayElement(env, ret, i);
7756                 LDKThirtyTwoBytes ret_conv_8_ref;
7757                 CHECK((*env)->GetArrayLength(env, ret_conv_8) == 32);
7758                 (*env)->GetByteArrayRegion(env, ret_conv_8, 0, 32, ret_conv_8_ref.data);
7759                 ret_constr.data[i] = ret_conv_8_ref;
7760         }
7761         if (get_jenv_res == JNI_EDETACHED) {
7762                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7763         }
7764         return ret_constr;
7765 }
7766 static void LDKConfirm_JCalls_cloned(LDKConfirm* new_obj) {
7767         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) new_obj->this_arg;
7768         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7769 }
7770 static inline LDKConfirm LDKConfirm_init (JNIEnv *env, jclass clz, jobject o) {
7771         jclass c = (*env)->GetObjectClass(env, o);
7772         CHECK(c != NULL);
7773         LDKConfirm_JCalls *calls = MALLOC(sizeof(LDKConfirm_JCalls), "LDKConfirm_JCalls");
7774         atomic_init(&calls->refcnt, 1);
7775         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
7776         calls->o = (*env)->NewWeakGlobalRef(env, o);
7777         calls->transactions_confirmed_meth = (*env)->GetMethodID(env, c, "transactions_confirmed", "([B[JI)V");
7778         CHECK(calls->transactions_confirmed_meth != NULL);
7779         calls->transaction_unconfirmed_meth = (*env)->GetMethodID(env, c, "transaction_unconfirmed", "([B)V");
7780         CHECK(calls->transaction_unconfirmed_meth != NULL);
7781         calls->best_block_updated_meth = (*env)->GetMethodID(env, c, "best_block_updated", "([BI)V");
7782         CHECK(calls->best_block_updated_meth != NULL);
7783         calls->get_relevant_txids_meth = (*env)->GetMethodID(env, c, "get_relevant_txids", "()[[B");
7784         CHECK(calls->get_relevant_txids_meth != NULL);
7785
7786         LDKConfirm ret = {
7787                 .this_arg = (void*) calls,
7788                 .transactions_confirmed = transactions_confirmed_LDKConfirm_jcall,
7789                 .transaction_unconfirmed = transaction_unconfirmed_LDKConfirm_jcall,
7790                 .best_block_updated = best_block_updated_LDKConfirm_jcall,
7791                 .get_relevant_txids = get_relevant_txids_LDKConfirm_jcall,
7792                 .free = LDKConfirm_JCalls_free,
7793         };
7794         return ret;
7795 }
7796 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKConfirm_1new(JNIEnv *env, jclass clz, jobject o) {
7797         LDKConfirm *res_ptr = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
7798         *res_ptr = LDKConfirm_init(env, clz, o);
7799         return (uint64_t)res_ptr;
7800 }
7801 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) {
7802         LDKConfirm* this_arg_conv = (LDKConfirm*)(((uint64_t)this_arg) & ~1);
7803         unsigned char header_arr[80];
7804         CHECK((*env)->GetArrayLength(env, header) == 80);
7805         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
7806         unsigned char (*header_ref)[80] = &header_arr;
7807         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
7808         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
7809         if (txdata_constr.datalen > 0)
7810                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
7811         else
7812                 txdata_constr.data = NULL;
7813         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
7814         for (size_t c = 0; c < txdata_constr.datalen; c++) {
7815                 int64_t txdata_conv_28 = txdata_vals[c];
7816                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_28) & ~1);
7817                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_28) & ~1));
7818                 txdata_constr.data[c] = txdata_conv_28_conv;
7819         }
7820         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
7821         (this_arg_conv->transactions_confirmed)(this_arg_conv->this_arg, header_ref, txdata_constr, height);
7822 }
7823
7824 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Confirm_1transaction_1unconfirmed(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray txid) {
7825         LDKConfirm* this_arg_conv = (LDKConfirm*)(((uint64_t)this_arg) & ~1);
7826         unsigned char txid_arr[32];
7827         CHECK((*env)->GetArrayLength(env, txid) == 32);
7828         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
7829         unsigned char (*txid_ref)[32] = &txid_arr;
7830         (this_arg_conv->transaction_unconfirmed)(this_arg_conv->this_arg, txid_ref);
7831 }
7832
7833 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) {
7834         LDKConfirm* this_arg_conv = (LDKConfirm*)(((uint64_t)this_arg) & ~1);
7835         unsigned char header_arr[80];
7836         CHECK((*env)->GetArrayLength(env, header) == 80);
7837         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
7838         unsigned char (*header_ref)[80] = &header_arr;
7839         (this_arg_conv->best_block_updated)(this_arg_conv->this_arg, header_ref, height);
7840 }
7841
7842 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_Confirm_1get_1relevant_1txids(JNIEnv *env, jclass clz, int64_t this_arg) {
7843         LDKConfirm* this_arg_conv = (LDKConfirm*)(((uint64_t)this_arg) & ~1);
7844         LDKCVec_TxidZ ret_var = (this_arg_conv->get_relevant_txids)(this_arg_conv->this_arg);
7845         jobjectArray ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
7846         ;
7847         for (size_t i = 0; i < ret_var.datalen; i++) {
7848                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 32);
7849                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 32, ret_var.data[i].data);
7850                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
7851         }
7852         FREE(ret_var.data);
7853         return ret_arr;
7854 }
7855
7856 typedef struct LDKPersist_JCalls {
7857         atomic_size_t refcnt;
7858         JavaVM *vm;
7859         jweak o;
7860         jmethodID persist_new_channel_meth;
7861         jmethodID update_persisted_channel_meth;
7862 } LDKPersist_JCalls;
7863 static void LDKPersist_JCalls_free(void* this_arg) {
7864         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
7865         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7866                 JNIEnv *env;
7867                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7868                 if (get_jenv_res == JNI_EDETACHED) {
7869                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7870                 } else {
7871                         DO_ASSERT(get_jenv_res == JNI_OK);
7872                 }
7873                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
7874                 if (get_jenv_res == JNI_EDETACHED) {
7875                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7876                 }
7877                 FREE(j_calls);
7878         }
7879 }
7880 LDKCResult_NoneChannelMonitorUpdateErrZ persist_new_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint id, const LDKChannelMonitor * data) {
7881         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
7882         JNIEnv *env;
7883         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7884         if (get_jenv_res == JNI_EDETACHED) {
7885                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7886         } else {
7887                 DO_ASSERT(get_jenv_res == JNI_OK);
7888         }
7889         LDKOutPoint id_var = id;
7890         CHECK((((uint64_t)id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7891         CHECK((((uint64_t)&id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7892         uint64_t id_ref = (uint64_t)id_var.inner;
7893         if (id_var.is_owned) {
7894                 id_ref |= 1;
7895         }
7896         LDKChannelMonitor data_var = *data;
7897         data_var = ChannelMonitor_clone(data);
7898         CHECK((((uint64_t)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7899         CHECK((((uint64_t)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7900         uint64_t data_ref = (uint64_t)data_var.inner;
7901         if (data_var.is_owned) {
7902                 data_ref |= 1;
7903         }
7904         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7905         CHECK(obj != NULL);
7906         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->persist_new_channel_meth, id_ref, data_ref);
7907         if ((*env)->ExceptionCheck(env)) {
7908                 (*env)->ExceptionDescribe(env);
7909                 (*env)->FatalError(env, "A call to persist_new_channel in LDKPersist from rust threw an exception.");
7910         }
7911         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
7912         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
7913         if (get_jenv_res == JNI_EDETACHED) {
7914                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7915         }
7916         return ret_conv;
7917 }
7918 LDKCResult_NoneChannelMonitorUpdateErrZ update_persisted_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint id, const LDKChannelMonitorUpdate * update, const LDKChannelMonitor * data) {
7919         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
7920         JNIEnv *env;
7921         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7922         if (get_jenv_res == JNI_EDETACHED) {
7923                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7924         } else {
7925                 DO_ASSERT(get_jenv_res == JNI_OK);
7926         }
7927         LDKOutPoint id_var = id;
7928         CHECK((((uint64_t)id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7929         CHECK((((uint64_t)&id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7930         uint64_t id_ref = (uint64_t)id_var.inner;
7931         if (id_var.is_owned) {
7932                 id_ref |= 1;
7933         }
7934         LDKChannelMonitorUpdate update_var = *update;
7935         update_var = ChannelMonitorUpdate_clone(update);
7936         CHECK((((uint64_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7937         CHECK((((uint64_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7938         uint64_t update_ref = (uint64_t)update_var.inner;
7939         if (update_var.is_owned) {
7940                 update_ref |= 1;
7941         }
7942         LDKChannelMonitor data_var = *data;
7943         data_var = ChannelMonitor_clone(data);
7944         CHECK((((uint64_t)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7945         CHECK((((uint64_t)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7946         uint64_t data_ref = (uint64_t)data_var.inner;
7947         if (data_var.is_owned) {
7948                 data_ref |= 1;
7949         }
7950         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7951         CHECK(obj != NULL);
7952         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->update_persisted_channel_meth, id_ref, update_ref, data_ref);
7953         if ((*env)->ExceptionCheck(env)) {
7954                 (*env)->ExceptionDescribe(env);
7955                 (*env)->FatalError(env, "A call to update_persisted_channel in LDKPersist from rust threw an exception.");
7956         }
7957         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
7958         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
7959         if (get_jenv_res == JNI_EDETACHED) {
7960                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7961         }
7962         return ret_conv;
7963 }
7964 static void LDKPersist_JCalls_cloned(LDKPersist* new_obj) {
7965         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) new_obj->this_arg;
7966         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7967 }
7968 static inline LDKPersist LDKPersist_init (JNIEnv *env, jclass clz, jobject o) {
7969         jclass c = (*env)->GetObjectClass(env, o);
7970         CHECK(c != NULL);
7971         LDKPersist_JCalls *calls = MALLOC(sizeof(LDKPersist_JCalls), "LDKPersist_JCalls");
7972         atomic_init(&calls->refcnt, 1);
7973         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
7974         calls->o = (*env)->NewWeakGlobalRef(env, o);
7975         calls->persist_new_channel_meth = (*env)->GetMethodID(env, c, "persist_new_channel", "(JJ)J");
7976         CHECK(calls->persist_new_channel_meth != NULL);
7977         calls->update_persisted_channel_meth = (*env)->GetMethodID(env, c, "update_persisted_channel", "(JJJ)J");
7978         CHECK(calls->update_persisted_channel_meth != NULL);
7979
7980         LDKPersist ret = {
7981                 .this_arg = (void*) calls,
7982                 .persist_new_channel = persist_new_channel_LDKPersist_jcall,
7983                 .update_persisted_channel = update_persisted_channel_LDKPersist_jcall,
7984                 .free = LDKPersist_JCalls_free,
7985         };
7986         return ret;
7987 }
7988 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKPersist_1new(JNIEnv *env, jclass clz, jobject o) {
7989         LDKPersist *res_ptr = MALLOC(sizeof(LDKPersist), "LDKPersist");
7990         *res_ptr = LDKPersist_init(env, clz, o);
7991         return (uint64_t)res_ptr;
7992 }
7993 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) {
7994         LDKPersist* this_arg_conv = (LDKPersist*)(((uint64_t)this_arg) & ~1);
7995         LDKOutPoint id_conv;
7996         id_conv.inner = (void*)(id & (~1));
7997         id_conv.is_owned = (id & 1) || (id == 0);
7998         id_conv = OutPoint_clone(&id_conv);
7999         LDKChannelMonitor data_conv;
8000         data_conv.inner = (void*)(data & (~1));
8001         data_conv.is_owned = false;
8002         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
8003         *ret_conv = (this_arg_conv->persist_new_channel)(this_arg_conv->this_arg, id_conv, &data_conv);
8004         return (uint64_t)ret_conv;
8005 }
8006
8007 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) {
8008         LDKPersist* this_arg_conv = (LDKPersist*)(((uint64_t)this_arg) & ~1);
8009         LDKOutPoint id_conv;
8010         id_conv.inner = (void*)(id & (~1));
8011         id_conv.is_owned = (id & 1) || (id == 0);
8012         id_conv = OutPoint_clone(&id_conv);
8013         LDKChannelMonitorUpdate update_conv;
8014         update_conv.inner = (void*)(update & (~1));
8015         update_conv.is_owned = false;
8016         LDKChannelMonitor data_conv;
8017         data_conv.inner = (void*)(data & (~1));
8018         data_conv.is_owned = false;
8019         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
8020         *ret_conv = (this_arg_conv->update_persisted_channel)(this_arg_conv->this_arg, id_conv, &update_conv, &data_conv);
8021         return (uint64_t)ret_conv;
8022 }
8023
8024 typedef struct LDKChannelMessageHandler_JCalls {
8025         atomic_size_t refcnt;
8026         JavaVM *vm;
8027         jweak o;
8028         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
8029         jmethodID handle_open_channel_meth;
8030         jmethodID handle_accept_channel_meth;
8031         jmethodID handle_funding_created_meth;
8032         jmethodID handle_funding_signed_meth;
8033         jmethodID handle_funding_locked_meth;
8034         jmethodID handle_shutdown_meth;
8035         jmethodID handle_closing_signed_meth;
8036         jmethodID handle_update_add_htlc_meth;
8037         jmethodID handle_update_fulfill_htlc_meth;
8038         jmethodID handle_update_fail_htlc_meth;
8039         jmethodID handle_update_fail_malformed_htlc_meth;
8040         jmethodID handle_commitment_signed_meth;
8041         jmethodID handle_revoke_and_ack_meth;
8042         jmethodID handle_update_fee_meth;
8043         jmethodID handle_announcement_signatures_meth;
8044         jmethodID peer_disconnected_meth;
8045         jmethodID peer_connected_meth;
8046         jmethodID handle_channel_reestablish_meth;
8047         jmethodID handle_channel_update_meth;
8048         jmethodID handle_error_meth;
8049 } LDKChannelMessageHandler_JCalls;
8050 static void LDKChannelMessageHandler_JCalls_free(void* this_arg) {
8051         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8052         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8053                 JNIEnv *env;
8054                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8055                 if (get_jenv_res == JNI_EDETACHED) {
8056                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8057                 } else {
8058                         DO_ASSERT(get_jenv_res == JNI_OK);
8059                 }
8060                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
8061                 if (get_jenv_res == JNI_EDETACHED) {
8062                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8063                 }
8064                 FREE(j_calls);
8065         }
8066 }
8067 void handle_open_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKOpenChannel * msg) {
8068         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8069         JNIEnv *env;
8070         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8071         if (get_jenv_res == JNI_EDETACHED) {
8072                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8073         } else {
8074                 DO_ASSERT(get_jenv_res == JNI_OK);
8075         }
8076         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8077         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8078         LDKInitFeatures their_features_var = their_features;
8079         CHECK((((uint64_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8080         CHECK((((uint64_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8081         uint64_t their_features_ref = (uint64_t)their_features_var.inner;
8082         if (their_features_var.is_owned) {
8083                 their_features_ref |= 1;
8084         }
8085         LDKOpenChannel msg_var = *msg;
8086         msg_var = OpenChannel_clone(msg);
8087         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8088         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8089         uint64_t msg_ref = (uint64_t)msg_var.inner;
8090         if (msg_var.is_owned) {
8091                 msg_ref |= 1;
8092         }
8093         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8094         CHECK(obj != NULL);
8095         (*env)->CallVoidMethod(env, obj, j_calls->handle_open_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
8096         if ((*env)->ExceptionCheck(env)) {
8097                 (*env)->ExceptionDescribe(env);
8098                 (*env)->FatalError(env, "A call to handle_open_channel in LDKChannelMessageHandler from rust threw an exception.");
8099         }
8100         if (get_jenv_res == JNI_EDETACHED) {
8101                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8102         }
8103 }
8104 void handle_accept_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKAcceptChannel * msg) {
8105         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8106         JNIEnv *env;
8107         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8108         if (get_jenv_res == JNI_EDETACHED) {
8109                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8110         } else {
8111                 DO_ASSERT(get_jenv_res == JNI_OK);
8112         }
8113         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8114         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8115         LDKInitFeatures their_features_var = their_features;
8116         CHECK((((uint64_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8117         CHECK((((uint64_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8118         uint64_t their_features_ref = (uint64_t)their_features_var.inner;
8119         if (their_features_var.is_owned) {
8120                 their_features_ref |= 1;
8121         }
8122         LDKAcceptChannel msg_var = *msg;
8123         msg_var = AcceptChannel_clone(msg);
8124         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8125         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8126         uint64_t msg_ref = (uint64_t)msg_var.inner;
8127         if (msg_var.is_owned) {
8128                 msg_ref |= 1;
8129         }
8130         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8131         CHECK(obj != NULL);
8132         (*env)->CallVoidMethod(env, obj, j_calls->handle_accept_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
8133         if ((*env)->ExceptionCheck(env)) {
8134                 (*env)->ExceptionDescribe(env);
8135                 (*env)->FatalError(env, "A call to handle_accept_channel in LDKChannelMessageHandler from rust threw an exception.");
8136         }
8137         if (get_jenv_res == JNI_EDETACHED) {
8138                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8139         }
8140 }
8141 void handle_funding_created_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingCreated * msg) {
8142         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8143         JNIEnv *env;
8144         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8145         if (get_jenv_res == JNI_EDETACHED) {
8146                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8147         } else {
8148                 DO_ASSERT(get_jenv_res == JNI_OK);
8149         }
8150         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8151         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8152         LDKFundingCreated msg_var = *msg;
8153         msg_var = FundingCreated_clone(msg);
8154         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8155         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8156         uint64_t msg_ref = (uint64_t)msg_var.inner;
8157         if (msg_var.is_owned) {
8158                 msg_ref |= 1;
8159         }
8160         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8161         CHECK(obj != NULL);
8162         (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_created_meth, their_node_id_arr, msg_ref);
8163         if ((*env)->ExceptionCheck(env)) {
8164                 (*env)->ExceptionDescribe(env);
8165                 (*env)->FatalError(env, "A call to handle_funding_created in LDKChannelMessageHandler from rust threw an exception.");
8166         }
8167         if (get_jenv_res == JNI_EDETACHED) {
8168                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8169         }
8170 }
8171 void handle_funding_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingSigned * msg) {
8172         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8173         JNIEnv *env;
8174         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8175         if (get_jenv_res == JNI_EDETACHED) {
8176                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8177         } else {
8178                 DO_ASSERT(get_jenv_res == JNI_OK);
8179         }
8180         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8181         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8182         LDKFundingSigned msg_var = *msg;
8183         msg_var = FundingSigned_clone(msg);
8184         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8185         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8186         uint64_t msg_ref = (uint64_t)msg_var.inner;
8187         if (msg_var.is_owned) {
8188                 msg_ref |= 1;
8189         }
8190         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8191         CHECK(obj != NULL);
8192         (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_signed_meth, their_node_id_arr, msg_ref);
8193         if ((*env)->ExceptionCheck(env)) {
8194                 (*env)->ExceptionDescribe(env);
8195                 (*env)->FatalError(env, "A call to handle_funding_signed in LDKChannelMessageHandler from rust threw an exception.");
8196         }
8197         if (get_jenv_res == JNI_EDETACHED) {
8198                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8199         }
8200 }
8201 void handle_funding_locked_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingLocked * msg) {
8202         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8203         JNIEnv *env;
8204         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8205         if (get_jenv_res == JNI_EDETACHED) {
8206                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8207         } else {
8208                 DO_ASSERT(get_jenv_res == JNI_OK);
8209         }
8210         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8211         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8212         LDKFundingLocked msg_var = *msg;
8213         msg_var = FundingLocked_clone(msg);
8214         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8215         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8216         uint64_t msg_ref = (uint64_t)msg_var.inner;
8217         if (msg_var.is_owned) {
8218                 msg_ref |= 1;
8219         }
8220         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8221         CHECK(obj != NULL);
8222         (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_locked_meth, their_node_id_arr, msg_ref);
8223         if ((*env)->ExceptionCheck(env)) {
8224                 (*env)->ExceptionDescribe(env);
8225                 (*env)->FatalError(env, "A call to handle_funding_locked in LDKChannelMessageHandler from rust threw an exception.");
8226         }
8227         if (get_jenv_res == JNI_EDETACHED) {
8228                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8229         }
8230 }
8231 void handle_shutdown_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInitFeatures * their_features, const LDKShutdown * msg) {
8232         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8233         JNIEnv *env;
8234         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8235         if (get_jenv_res == JNI_EDETACHED) {
8236                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8237         } else {
8238                 DO_ASSERT(get_jenv_res == JNI_OK);
8239         }
8240         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8241         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8242         LDKInitFeatures their_features_var = *their_features;
8243         their_features_var = InitFeatures_clone(their_features);
8244         CHECK((((uint64_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8245         CHECK((((uint64_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8246         uint64_t their_features_ref = (uint64_t)their_features_var.inner;
8247         if (their_features_var.is_owned) {
8248                 their_features_ref |= 1;
8249         }
8250         LDKShutdown msg_var = *msg;
8251         msg_var = Shutdown_clone(msg);
8252         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8253         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8254         uint64_t msg_ref = (uint64_t)msg_var.inner;
8255         if (msg_var.is_owned) {
8256                 msg_ref |= 1;
8257         }
8258         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8259         CHECK(obj != NULL);
8260         (*env)->CallVoidMethod(env, obj, j_calls->handle_shutdown_meth, their_node_id_arr, their_features_ref, msg_ref);
8261         if ((*env)->ExceptionCheck(env)) {
8262                 (*env)->ExceptionDescribe(env);
8263                 (*env)->FatalError(env, "A call to handle_shutdown in LDKChannelMessageHandler from rust threw an exception.");
8264         }
8265         if (get_jenv_res == JNI_EDETACHED) {
8266                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8267         }
8268 }
8269 void handle_closing_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKClosingSigned * msg) {
8270         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8271         JNIEnv *env;
8272         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8273         if (get_jenv_res == JNI_EDETACHED) {
8274                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8275         } else {
8276                 DO_ASSERT(get_jenv_res == JNI_OK);
8277         }
8278         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8279         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8280         LDKClosingSigned msg_var = *msg;
8281         msg_var = ClosingSigned_clone(msg);
8282         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8283         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8284         uint64_t msg_ref = (uint64_t)msg_var.inner;
8285         if (msg_var.is_owned) {
8286                 msg_ref |= 1;
8287         }
8288         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8289         CHECK(obj != NULL);
8290         (*env)->CallVoidMethod(env, obj, j_calls->handle_closing_signed_meth, their_node_id_arr, msg_ref);
8291         if ((*env)->ExceptionCheck(env)) {
8292                 (*env)->ExceptionDescribe(env);
8293                 (*env)->FatalError(env, "A call to handle_closing_signed in LDKChannelMessageHandler from rust threw an exception.");
8294         }
8295         if (get_jenv_res == JNI_EDETACHED) {
8296                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8297         }
8298 }
8299 void handle_update_add_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateAddHTLC * msg) {
8300         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8301         JNIEnv *env;
8302         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8303         if (get_jenv_res == JNI_EDETACHED) {
8304                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8305         } else {
8306                 DO_ASSERT(get_jenv_res == JNI_OK);
8307         }
8308         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8309         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8310         LDKUpdateAddHTLC msg_var = *msg;
8311         msg_var = UpdateAddHTLC_clone(msg);
8312         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8313         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8314         uint64_t msg_ref = (uint64_t)msg_var.inner;
8315         if (msg_var.is_owned) {
8316                 msg_ref |= 1;
8317         }
8318         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8319         CHECK(obj != NULL);
8320         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_add_htlc_meth, their_node_id_arr, msg_ref);
8321         if ((*env)->ExceptionCheck(env)) {
8322                 (*env)->ExceptionDescribe(env);
8323                 (*env)->FatalError(env, "A call to handle_update_add_htlc in LDKChannelMessageHandler from rust threw an exception.");
8324         }
8325         if (get_jenv_res == JNI_EDETACHED) {
8326                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8327         }
8328 }
8329 void handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFulfillHTLC * msg) {
8330         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8331         JNIEnv *env;
8332         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8333         if (get_jenv_res == JNI_EDETACHED) {
8334                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8335         } else {
8336                 DO_ASSERT(get_jenv_res == JNI_OK);
8337         }
8338         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8339         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8340         LDKUpdateFulfillHTLC msg_var = *msg;
8341         msg_var = UpdateFulfillHTLC_clone(msg);
8342         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8343         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8344         uint64_t msg_ref = (uint64_t)msg_var.inner;
8345         if (msg_var.is_owned) {
8346                 msg_ref |= 1;
8347         }
8348         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8349         CHECK(obj != NULL);
8350         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fulfill_htlc_meth, their_node_id_arr, msg_ref);
8351         if ((*env)->ExceptionCheck(env)) {
8352                 (*env)->ExceptionDescribe(env);
8353                 (*env)->FatalError(env, "A call to handle_update_fulfill_htlc in LDKChannelMessageHandler from rust threw an exception.");
8354         }
8355         if (get_jenv_res == JNI_EDETACHED) {
8356                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8357         }
8358 }
8359 void handle_update_fail_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailHTLC * msg) {
8360         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8361         JNIEnv *env;
8362         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8363         if (get_jenv_res == JNI_EDETACHED) {
8364                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8365         } else {
8366                 DO_ASSERT(get_jenv_res == JNI_OK);
8367         }
8368         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8369         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8370         LDKUpdateFailHTLC msg_var = *msg;
8371         msg_var = UpdateFailHTLC_clone(msg);
8372         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8373         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8374         uint64_t msg_ref = (uint64_t)msg_var.inner;
8375         if (msg_var.is_owned) {
8376                 msg_ref |= 1;
8377         }
8378         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8379         CHECK(obj != NULL);
8380         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fail_htlc_meth, their_node_id_arr, msg_ref);
8381         if ((*env)->ExceptionCheck(env)) {
8382                 (*env)->ExceptionDescribe(env);
8383                 (*env)->FatalError(env, "A call to handle_update_fail_htlc in LDKChannelMessageHandler from rust threw an exception.");
8384         }
8385         if (get_jenv_res == JNI_EDETACHED) {
8386                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8387         }
8388 }
8389 void handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailMalformedHTLC * msg) {
8390         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8391         JNIEnv *env;
8392         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8393         if (get_jenv_res == JNI_EDETACHED) {
8394                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8395         } else {
8396                 DO_ASSERT(get_jenv_res == JNI_OK);
8397         }
8398         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8399         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8400         LDKUpdateFailMalformedHTLC msg_var = *msg;
8401         msg_var = UpdateFailMalformedHTLC_clone(msg);
8402         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8403         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8404         uint64_t msg_ref = (uint64_t)msg_var.inner;
8405         if (msg_var.is_owned) {
8406                 msg_ref |= 1;
8407         }
8408         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8409         CHECK(obj != NULL);
8410         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fail_malformed_htlc_meth, their_node_id_arr, msg_ref);
8411         if ((*env)->ExceptionCheck(env)) {
8412                 (*env)->ExceptionDescribe(env);
8413                 (*env)->FatalError(env, "A call to handle_update_fail_malformed_htlc in LDKChannelMessageHandler from rust threw an exception.");
8414         }
8415         if (get_jenv_res == JNI_EDETACHED) {
8416                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8417         }
8418 }
8419 void handle_commitment_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKCommitmentSigned * msg) {
8420         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8421         JNIEnv *env;
8422         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8423         if (get_jenv_res == JNI_EDETACHED) {
8424                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8425         } else {
8426                 DO_ASSERT(get_jenv_res == JNI_OK);
8427         }
8428         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8429         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8430         LDKCommitmentSigned msg_var = *msg;
8431         msg_var = CommitmentSigned_clone(msg);
8432         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8433         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8434         uint64_t msg_ref = (uint64_t)msg_var.inner;
8435         if (msg_var.is_owned) {
8436                 msg_ref |= 1;
8437         }
8438         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8439         CHECK(obj != NULL);
8440         (*env)->CallVoidMethod(env, obj, j_calls->handle_commitment_signed_meth, their_node_id_arr, msg_ref);
8441         if ((*env)->ExceptionCheck(env)) {
8442                 (*env)->ExceptionDescribe(env);
8443                 (*env)->FatalError(env, "A call to handle_commitment_signed in LDKChannelMessageHandler from rust threw an exception.");
8444         }
8445         if (get_jenv_res == JNI_EDETACHED) {
8446                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8447         }
8448 }
8449 void handle_revoke_and_ack_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKRevokeAndACK * msg) {
8450         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8451         JNIEnv *env;
8452         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8453         if (get_jenv_res == JNI_EDETACHED) {
8454                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8455         } else {
8456                 DO_ASSERT(get_jenv_res == JNI_OK);
8457         }
8458         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8459         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8460         LDKRevokeAndACK msg_var = *msg;
8461         msg_var = RevokeAndACK_clone(msg);
8462         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8463         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8464         uint64_t msg_ref = (uint64_t)msg_var.inner;
8465         if (msg_var.is_owned) {
8466                 msg_ref |= 1;
8467         }
8468         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8469         CHECK(obj != NULL);
8470         (*env)->CallVoidMethod(env, obj, j_calls->handle_revoke_and_ack_meth, their_node_id_arr, msg_ref);
8471         if ((*env)->ExceptionCheck(env)) {
8472                 (*env)->ExceptionDescribe(env);
8473                 (*env)->FatalError(env, "A call to handle_revoke_and_ack in LDKChannelMessageHandler from rust threw an exception.");
8474         }
8475         if (get_jenv_res == JNI_EDETACHED) {
8476                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8477         }
8478 }
8479 void handle_update_fee_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFee * msg) {
8480         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8481         JNIEnv *env;
8482         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8483         if (get_jenv_res == JNI_EDETACHED) {
8484                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8485         } else {
8486                 DO_ASSERT(get_jenv_res == JNI_OK);
8487         }
8488         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8489         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8490         LDKUpdateFee msg_var = *msg;
8491         msg_var = UpdateFee_clone(msg);
8492         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8493         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8494         uint64_t msg_ref = (uint64_t)msg_var.inner;
8495         if (msg_var.is_owned) {
8496                 msg_ref |= 1;
8497         }
8498         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8499         CHECK(obj != NULL);
8500         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fee_meth, their_node_id_arr, msg_ref);
8501         if ((*env)->ExceptionCheck(env)) {
8502                 (*env)->ExceptionDescribe(env);
8503                 (*env)->FatalError(env, "A call to handle_update_fee in LDKChannelMessageHandler from rust threw an exception.");
8504         }
8505         if (get_jenv_res == JNI_EDETACHED) {
8506                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8507         }
8508 }
8509 void handle_announcement_signatures_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKAnnouncementSignatures * msg) {
8510         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8511         JNIEnv *env;
8512         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8513         if (get_jenv_res == JNI_EDETACHED) {
8514                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8515         } else {
8516                 DO_ASSERT(get_jenv_res == JNI_OK);
8517         }
8518         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8519         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8520         LDKAnnouncementSignatures msg_var = *msg;
8521         msg_var = AnnouncementSignatures_clone(msg);
8522         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8523         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8524         uint64_t msg_ref = (uint64_t)msg_var.inner;
8525         if (msg_var.is_owned) {
8526                 msg_ref |= 1;
8527         }
8528         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8529         CHECK(obj != NULL);
8530         (*env)->CallVoidMethod(env, obj, j_calls->handle_announcement_signatures_meth, their_node_id_arr, msg_ref);
8531         if ((*env)->ExceptionCheck(env)) {
8532                 (*env)->ExceptionDescribe(env);
8533                 (*env)->FatalError(env, "A call to handle_announcement_signatures in LDKChannelMessageHandler from rust threw an exception.");
8534         }
8535         if (get_jenv_res == JNI_EDETACHED) {
8536                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8537         }
8538 }
8539 void peer_disconnected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, bool no_connection_possible) {
8540         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8541         JNIEnv *env;
8542         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8543         if (get_jenv_res == JNI_EDETACHED) {
8544                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8545         } else {
8546                 DO_ASSERT(get_jenv_res == JNI_OK);
8547         }
8548         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8549         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8550         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8551         CHECK(obj != NULL);
8552         (*env)->CallVoidMethod(env, obj, j_calls->peer_disconnected_meth, their_node_id_arr, no_connection_possible);
8553         if ((*env)->ExceptionCheck(env)) {
8554                 (*env)->ExceptionDescribe(env);
8555                 (*env)->FatalError(env, "A call to peer_disconnected in LDKChannelMessageHandler from rust threw an exception.");
8556         }
8557         if (get_jenv_res == JNI_EDETACHED) {
8558                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8559         }
8560 }
8561 void peer_connected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * msg) {
8562         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8563         JNIEnv *env;
8564         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8565         if (get_jenv_res == JNI_EDETACHED) {
8566                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8567         } else {
8568                 DO_ASSERT(get_jenv_res == JNI_OK);
8569         }
8570         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8571         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8572         LDKInit msg_var = *msg;
8573         msg_var = Init_clone(msg);
8574         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8575         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8576         uint64_t msg_ref = (uint64_t)msg_var.inner;
8577         if (msg_var.is_owned) {
8578                 msg_ref |= 1;
8579         }
8580         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8581         CHECK(obj != NULL);
8582         (*env)->CallVoidMethod(env, obj, j_calls->peer_connected_meth, their_node_id_arr, msg_ref);
8583         if ((*env)->ExceptionCheck(env)) {
8584                 (*env)->ExceptionDescribe(env);
8585                 (*env)->FatalError(env, "A call to peer_connected in LDKChannelMessageHandler from rust threw an exception.");
8586         }
8587         if (get_jenv_res == JNI_EDETACHED) {
8588                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8589         }
8590 }
8591 void handle_channel_reestablish_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelReestablish * msg) {
8592         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8593         JNIEnv *env;
8594         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8595         if (get_jenv_res == JNI_EDETACHED) {
8596                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8597         } else {
8598                 DO_ASSERT(get_jenv_res == JNI_OK);
8599         }
8600         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8601         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8602         LDKChannelReestablish msg_var = *msg;
8603         msg_var = ChannelReestablish_clone(msg);
8604         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8605         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8606         uint64_t msg_ref = (uint64_t)msg_var.inner;
8607         if (msg_var.is_owned) {
8608                 msg_ref |= 1;
8609         }
8610         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8611         CHECK(obj != NULL);
8612         (*env)->CallVoidMethod(env, obj, j_calls->handle_channel_reestablish_meth, their_node_id_arr, msg_ref);
8613         if ((*env)->ExceptionCheck(env)) {
8614                 (*env)->ExceptionDescribe(env);
8615                 (*env)->FatalError(env, "A call to handle_channel_reestablish in LDKChannelMessageHandler from rust threw an exception.");
8616         }
8617         if (get_jenv_res == JNI_EDETACHED) {
8618                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8619         }
8620 }
8621 void handle_channel_update_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelUpdate * msg) {
8622         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8623         JNIEnv *env;
8624         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8625         if (get_jenv_res == JNI_EDETACHED) {
8626                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8627         } else {
8628                 DO_ASSERT(get_jenv_res == JNI_OK);
8629         }
8630         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8631         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8632         LDKChannelUpdate msg_var = *msg;
8633         msg_var = ChannelUpdate_clone(msg);
8634         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8635         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8636         uint64_t msg_ref = (uint64_t)msg_var.inner;
8637         if (msg_var.is_owned) {
8638                 msg_ref |= 1;
8639         }
8640         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8641         CHECK(obj != NULL);
8642         (*env)->CallVoidMethod(env, obj, j_calls->handle_channel_update_meth, their_node_id_arr, msg_ref);
8643         if ((*env)->ExceptionCheck(env)) {
8644                 (*env)->ExceptionDescribe(env);
8645                 (*env)->FatalError(env, "A call to handle_channel_update in LDKChannelMessageHandler from rust threw an exception.");
8646         }
8647         if (get_jenv_res == JNI_EDETACHED) {
8648                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8649         }
8650 }
8651 void handle_error_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKErrorMessage * msg) {
8652         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8653         JNIEnv *env;
8654         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8655         if (get_jenv_res == JNI_EDETACHED) {
8656                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8657         } else {
8658                 DO_ASSERT(get_jenv_res == JNI_OK);
8659         }
8660         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8661         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8662         LDKErrorMessage msg_var = *msg;
8663         msg_var = ErrorMessage_clone(msg);
8664         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8665         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8666         uint64_t msg_ref = (uint64_t)msg_var.inner;
8667         if (msg_var.is_owned) {
8668                 msg_ref |= 1;
8669         }
8670         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8671         CHECK(obj != NULL);
8672         (*env)->CallVoidMethod(env, obj, j_calls->handle_error_meth, their_node_id_arr, msg_ref);
8673         if ((*env)->ExceptionCheck(env)) {
8674                 (*env)->ExceptionDescribe(env);
8675                 (*env)->FatalError(env, "A call to handle_error in LDKChannelMessageHandler from rust threw an exception.");
8676         }
8677         if (get_jenv_res == JNI_EDETACHED) {
8678                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8679         }
8680 }
8681 static void LDKChannelMessageHandler_JCalls_cloned(LDKChannelMessageHandler* new_obj) {
8682         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) new_obj->this_arg;
8683         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8684         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
8685 }
8686 static inline LDKChannelMessageHandler LDKChannelMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
8687         jclass c = (*env)->GetObjectClass(env, o);
8688         CHECK(c != NULL);
8689         LDKChannelMessageHandler_JCalls *calls = MALLOC(sizeof(LDKChannelMessageHandler_JCalls), "LDKChannelMessageHandler_JCalls");
8690         atomic_init(&calls->refcnt, 1);
8691         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
8692         calls->o = (*env)->NewWeakGlobalRef(env, o);
8693         calls->handle_open_channel_meth = (*env)->GetMethodID(env, c, "handle_open_channel", "([BJJ)V");
8694         CHECK(calls->handle_open_channel_meth != NULL);
8695         calls->handle_accept_channel_meth = (*env)->GetMethodID(env, c, "handle_accept_channel", "([BJJ)V");
8696         CHECK(calls->handle_accept_channel_meth != NULL);
8697         calls->handle_funding_created_meth = (*env)->GetMethodID(env, c, "handle_funding_created", "([BJ)V");
8698         CHECK(calls->handle_funding_created_meth != NULL);
8699         calls->handle_funding_signed_meth = (*env)->GetMethodID(env, c, "handle_funding_signed", "([BJ)V");
8700         CHECK(calls->handle_funding_signed_meth != NULL);
8701         calls->handle_funding_locked_meth = (*env)->GetMethodID(env, c, "handle_funding_locked", "([BJ)V");
8702         CHECK(calls->handle_funding_locked_meth != NULL);
8703         calls->handle_shutdown_meth = (*env)->GetMethodID(env, c, "handle_shutdown", "([BJJ)V");
8704         CHECK(calls->handle_shutdown_meth != NULL);
8705         calls->handle_closing_signed_meth = (*env)->GetMethodID(env, c, "handle_closing_signed", "([BJ)V");
8706         CHECK(calls->handle_closing_signed_meth != NULL);
8707         calls->handle_update_add_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_add_htlc", "([BJ)V");
8708         CHECK(calls->handle_update_add_htlc_meth != NULL);
8709         calls->handle_update_fulfill_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fulfill_htlc", "([BJ)V");
8710         CHECK(calls->handle_update_fulfill_htlc_meth != NULL);
8711         calls->handle_update_fail_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fail_htlc", "([BJ)V");
8712         CHECK(calls->handle_update_fail_htlc_meth != NULL);
8713         calls->handle_update_fail_malformed_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fail_malformed_htlc", "([BJ)V");
8714         CHECK(calls->handle_update_fail_malformed_htlc_meth != NULL);
8715         calls->handle_commitment_signed_meth = (*env)->GetMethodID(env, c, "handle_commitment_signed", "([BJ)V");
8716         CHECK(calls->handle_commitment_signed_meth != NULL);
8717         calls->handle_revoke_and_ack_meth = (*env)->GetMethodID(env, c, "handle_revoke_and_ack", "([BJ)V");
8718         CHECK(calls->handle_revoke_and_ack_meth != NULL);
8719         calls->handle_update_fee_meth = (*env)->GetMethodID(env, c, "handle_update_fee", "([BJ)V");
8720         CHECK(calls->handle_update_fee_meth != NULL);
8721         calls->handle_announcement_signatures_meth = (*env)->GetMethodID(env, c, "handle_announcement_signatures", "([BJ)V");
8722         CHECK(calls->handle_announcement_signatures_meth != NULL);
8723         calls->peer_disconnected_meth = (*env)->GetMethodID(env, c, "peer_disconnected", "([BZ)V");
8724         CHECK(calls->peer_disconnected_meth != NULL);
8725         calls->peer_connected_meth = (*env)->GetMethodID(env, c, "peer_connected", "([BJ)V");
8726         CHECK(calls->peer_connected_meth != NULL);
8727         calls->handle_channel_reestablish_meth = (*env)->GetMethodID(env, c, "handle_channel_reestablish", "([BJ)V");
8728         CHECK(calls->handle_channel_reestablish_meth != NULL);
8729         calls->handle_channel_update_meth = (*env)->GetMethodID(env, c, "handle_channel_update", "([BJ)V");
8730         CHECK(calls->handle_channel_update_meth != NULL);
8731         calls->handle_error_meth = (*env)->GetMethodID(env, c, "handle_error", "([BJ)V");
8732         CHECK(calls->handle_error_meth != NULL);
8733
8734         LDKChannelMessageHandler ret = {
8735                 .this_arg = (void*) calls,
8736                 .handle_open_channel = handle_open_channel_LDKChannelMessageHandler_jcall,
8737                 .handle_accept_channel = handle_accept_channel_LDKChannelMessageHandler_jcall,
8738                 .handle_funding_created = handle_funding_created_LDKChannelMessageHandler_jcall,
8739                 .handle_funding_signed = handle_funding_signed_LDKChannelMessageHandler_jcall,
8740                 .handle_funding_locked = handle_funding_locked_LDKChannelMessageHandler_jcall,
8741                 .handle_shutdown = handle_shutdown_LDKChannelMessageHandler_jcall,
8742                 .handle_closing_signed = handle_closing_signed_LDKChannelMessageHandler_jcall,
8743                 .handle_update_add_htlc = handle_update_add_htlc_LDKChannelMessageHandler_jcall,
8744                 .handle_update_fulfill_htlc = handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall,
8745                 .handle_update_fail_htlc = handle_update_fail_htlc_LDKChannelMessageHandler_jcall,
8746                 .handle_update_fail_malformed_htlc = handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall,
8747                 .handle_commitment_signed = handle_commitment_signed_LDKChannelMessageHandler_jcall,
8748                 .handle_revoke_and_ack = handle_revoke_and_ack_LDKChannelMessageHandler_jcall,
8749                 .handle_update_fee = handle_update_fee_LDKChannelMessageHandler_jcall,
8750                 .handle_announcement_signatures = handle_announcement_signatures_LDKChannelMessageHandler_jcall,
8751                 .peer_disconnected = peer_disconnected_LDKChannelMessageHandler_jcall,
8752                 .peer_connected = peer_connected_LDKChannelMessageHandler_jcall,
8753                 .handle_channel_reestablish = handle_channel_reestablish_LDKChannelMessageHandler_jcall,
8754                 .handle_channel_update = handle_channel_update_LDKChannelMessageHandler_jcall,
8755                 .handle_error = handle_error_LDKChannelMessageHandler_jcall,
8756                 .free = LDKChannelMessageHandler_JCalls_free,
8757                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(env, clz, MessageSendEventsProvider),
8758         };
8759         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
8760         return ret;
8761 }
8762 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
8763         LDKChannelMessageHandler *res_ptr = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
8764         *res_ptr = LDKChannelMessageHandler_init(env, clz, o, MessageSendEventsProvider);
8765         return (uint64_t)res_ptr;
8766 }
8767 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1get_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t arg) {
8768         LDKChannelMessageHandler *inp = (LDKChannelMessageHandler *)(arg & ~1);
8769         uint64_t res_ptr = (uint64_t)&inp->MessageSendEventsProvider;
8770         DO_ASSERT((res_ptr & 1) == 0);
8771         return (int64_t)(res_ptr | 1);
8772 }
8773 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) {
8774         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
8775         LDKPublicKey their_node_id_ref;
8776         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8777         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8778         LDKInitFeatures their_features_conv;
8779         their_features_conv.inner = (void*)(their_features & (~1));
8780         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
8781         their_features_conv = InitFeatures_clone(&their_features_conv);
8782         LDKOpenChannel msg_conv;
8783         msg_conv.inner = (void*)(msg & (~1));
8784         msg_conv.is_owned = false;
8785         (this_arg_conv->handle_open_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
8786 }
8787
8788 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) {
8789         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
8790         LDKPublicKey their_node_id_ref;
8791         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8792         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8793         LDKInitFeatures their_features_conv;
8794         their_features_conv.inner = (void*)(their_features & (~1));
8795         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
8796         their_features_conv = InitFeatures_clone(&their_features_conv);
8797         LDKAcceptChannel msg_conv;
8798         msg_conv.inner = (void*)(msg & (~1));
8799         msg_conv.is_owned = false;
8800         (this_arg_conv->handle_accept_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
8801 }
8802
8803 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) {
8804         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
8805         LDKPublicKey their_node_id_ref;
8806         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8807         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8808         LDKFundingCreated msg_conv;
8809         msg_conv.inner = (void*)(msg & (~1));
8810         msg_conv.is_owned = false;
8811         (this_arg_conv->handle_funding_created)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8812 }
8813
8814 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) {
8815         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
8816         LDKPublicKey their_node_id_ref;
8817         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8818         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8819         LDKFundingSigned msg_conv;
8820         msg_conv.inner = (void*)(msg & (~1));
8821         msg_conv.is_owned = false;
8822         (this_arg_conv->handle_funding_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8823 }
8824
8825 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) {
8826         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
8827         LDKPublicKey their_node_id_ref;
8828         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8829         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8830         LDKFundingLocked msg_conv;
8831         msg_conv.inner = (void*)(msg & (~1));
8832         msg_conv.is_owned = false;
8833         (this_arg_conv->handle_funding_locked)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8834 }
8835
8836 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) {
8837         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
8838         LDKPublicKey their_node_id_ref;
8839         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8840         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8841         LDKInitFeatures their_features_conv;
8842         their_features_conv.inner = (void*)(their_features & (~1));
8843         their_features_conv.is_owned = false;
8844         LDKShutdown msg_conv;
8845         msg_conv.inner = (void*)(msg & (~1));
8846         msg_conv.is_owned = false;
8847         (this_arg_conv->handle_shutdown)(this_arg_conv->this_arg, their_node_id_ref, &their_features_conv, &msg_conv);
8848 }
8849
8850 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) {
8851         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
8852         LDKPublicKey their_node_id_ref;
8853         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8854         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8855         LDKClosingSigned msg_conv;
8856         msg_conv.inner = (void*)(msg & (~1));
8857         msg_conv.is_owned = false;
8858         (this_arg_conv->handle_closing_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8859 }
8860
8861 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) {
8862         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
8863         LDKPublicKey their_node_id_ref;
8864         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8865         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8866         LDKUpdateAddHTLC msg_conv;
8867         msg_conv.inner = (void*)(msg & (~1));
8868         msg_conv.is_owned = false;
8869         (this_arg_conv->handle_update_add_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8870 }
8871
8872 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) {
8873         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
8874         LDKPublicKey their_node_id_ref;
8875         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8876         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8877         LDKUpdateFulfillHTLC msg_conv;
8878         msg_conv.inner = (void*)(msg & (~1));
8879         msg_conv.is_owned = false;
8880         (this_arg_conv->handle_update_fulfill_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8881 }
8882
8883 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) {
8884         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
8885         LDKPublicKey their_node_id_ref;
8886         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8887         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8888         LDKUpdateFailHTLC msg_conv;
8889         msg_conv.inner = (void*)(msg & (~1));
8890         msg_conv.is_owned = false;
8891         (this_arg_conv->handle_update_fail_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8892 }
8893
8894 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) {
8895         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
8896         LDKPublicKey their_node_id_ref;
8897         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8898         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8899         LDKUpdateFailMalformedHTLC msg_conv;
8900         msg_conv.inner = (void*)(msg & (~1));
8901         msg_conv.is_owned = false;
8902         (this_arg_conv->handle_update_fail_malformed_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8903 }
8904
8905 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) {
8906         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
8907         LDKPublicKey their_node_id_ref;
8908         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8909         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8910         LDKCommitmentSigned msg_conv;
8911         msg_conv.inner = (void*)(msg & (~1));
8912         msg_conv.is_owned = false;
8913         (this_arg_conv->handle_commitment_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8914 }
8915
8916 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) {
8917         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
8918         LDKPublicKey their_node_id_ref;
8919         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8920         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8921         LDKRevokeAndACK msg_conv;
8922         msg_conv.inner = (void*)(msg & (~1));
8923         msg_conv.is_owned = false;
8924         (this_arg_conv->handle_revoke_and_ack)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8925 }
8926
8927 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) {
8928         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
8929         LDKPublicKey their_node_id_ref;
8930         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8931         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8932         LDKUpdateFee msg_conv;
8933         msg_conv.inner = (void*)(msg & (~1));
8934         msg_conv.is_owned = false;
8935         (this_arg_conv->handle_update_fee)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8936 }
8937
8938 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) {
8939         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
8940         LDKPublicKey their_node_id_ref;
8941         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8942         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8943         LDKAnnouncementSignatures msg_conv;
8944         msg_conv.inner = (void*)(msg & (~1));
8945         msg_conv.is_owned = false;
8946         (this_arg_conv->handle_announcement_signatures)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8947 }
8948
8949 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) {
8950         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
8951         LDKPublicKey their_node_id_ref;
8952         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8953         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8954         (this_arg_conv->peer_disconnected)(this_arg_conv->this_arg, their_node_id_ref, no_connection_possible);
8955 }
8956
8957 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) {
8958         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
8959         LDKPublicKey their_node_id_ref;
8960         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8961         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8962         LDKInit msg_conv;
8963         msg_conv.inner = (void*)(msg & (~1));
8964         msg_conv.is_owned = false;
8965         (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8966 }
8967
8968 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) {
8969         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
8970         LDKPublicKey their_node_id_ref;
8971         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8972         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8973         LDKChannelReestablish msg_conv;
8974         msg_conv.inner = (void*)(msg & (~1));
8975         msg_conv.is_owned = false;
8976         (this_arg_conv->handle_channel_reestablish)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8977 }
8978
8979 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) {
8980         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
8981         LDKPublicKey their_node_id_ref;
8982         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8983         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8984         LDKChannelUpdate msg_conv;
8985         msg_conv.inner = (void*)(msg & (~1));
8986         msg_conv.is_owned = false;
8987         (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8988 }
8989
8990 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) {
8991         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
8992         LDKPublicKey their_node_id_ref;
8993         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8994         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8995         LDKErrorMessage msg_conv;
8996         msg_conv.inner = (void*)(msg & (~1));
8997         msg_conv.is_owned = false;
8998         (this_arg_conv->handle_error)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8999 }
9000
9001 typedef struct LDKRoutingMessageHandler_JCalls {
9002         atomic_size_t refcnt;
9003         JavaVM *vm;
9004         jweak o;
9005         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
9006         jmethodID handle_node_announcement_meth;
9007         jmethodID handle_channel_announcement_meth;
9008         jmethodID handle_channel_update_meth;
9009         jmethodID get_next_channel_announcements_meth;
9010         jmethodID get_next_node_announcements_meth;
9011         jmethodID sync_routing_table_meth;
9012         jmethodID handle_reply_channel_range_meth;
9013         jmethodID handle_reply_short_channel_ids_end_meth;
9014         jmethodID handle_query_channel_range_meth;
9015         jmethodID handle_query_short_channel_ids_meth;
9016 } LDKRoutingMessageHandler_JCalls;
9017 static void LDKRoutingMessageHandler_JCalls_free(void* this_arg) {
9018         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9019         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
9020                 JNIEnv *env;
9021                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9022                 if (get_jenv_res == JNI_EDETACHED) {
9023                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9024                 } else {
9025                         DO_ASSERT(get_jenv_res == JNI_OK);
9026                 }
9027                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
9028                 if (get_jenv_res == JNI_EDETACHED) {
9029                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9030                 }
9031                 FREE(j_calls);
9032         }
9033 }
9034 LDKCResult_boolLightningErrorZ handle_node_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKNodeAnnouncement * msg) {
9035         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9036         JNIEnv *env;
9037         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9038         if (get_jenv_res == JNI_EDETACHED) {
9039                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9040         } else {
9041                 DO_ASSERT(get_jenv_res == JNI_OK);
9042         }
9043         LDKNodeAnnouncement msg_var = *msg;
9044         msg_var = NodeAnnouncement_clone(msg);
9045         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9046         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9047         uint64_t msg_ref = (uint64_t)msg_var.inner;
9048         if (msg_var.is_owned) {
9049                 msg_ref |= 1;
9050         }
9051         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9052         CHECK(obj != NULL);
9053         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_node_announcement_meth, msg_ref);
9054         if ((*env)->ExceptionCheck(env)) {
9055                 (*env)->ExceptionDescribe(env);
9056                 (*env)->FatalError(env, "A call to handle_node_announcement in LDKRoutingMessageHandler from rust threw an exception.");
9057         }
9058         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1);
9059         ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1));
9060         if (get_jenv_res == JNI_EDETACHED) {
9061                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9062         }
9063         return ret_conv;
9064 }
9065 LDKCResult_boolLightningErrorZ handle_channel_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelAnnouncement * msg) {
9066         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9067         JNIEnv *env;
9068         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9069         if (get_jenv_res == JNI_EDETACHED) {
9070                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9071         } else {
9072                 DO_ASSERT(get_jenv_res == JNI_OK);
9073         }
9074         LDKChannelAnnouncement msg_var = *msg;
9075         msg_var = ChannelAnnouncement_clone(msg);
9076         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9077         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9078         uint64_t msg_ref = (uint64_t)msg_var.inner;
9079         if (msg_var.is_owned) {
9080                 msg_ref |= 1;
9081         }
9082         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9083         CHECK(obj != NULL);
9084         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_channel_announcement_meth, msg_ref);
9085         if ((*env)->ExceptionCheck(env)) {
9086                 (*env)->ExceptionDescribe(env);
9087                 (*env)->FatalError(env, "A call to handle_channel_announcement in LDKRoutingMessageHandler from rust threw an exception.");
9088         }
9089         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1);
9090         ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1));
9091         if (get_jenv_res == JNI_EDETACHED) {
9092                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9093         }
9094         return ret_conv;
9095 }
9096 LDKCResult_boolLightningErrorZ handle_channel_update_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelUpdate * msg) {
9097         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9098         JNIEnv *env;
9099         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9100         if (get_jenv_res == JNI_EDETACHED) {
9101                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9102         } else {
9103                 DO_ASSERT(get_jenv_res == JNI_OK);
9104         }
9105         LDKChannelUpdate msg_var = *msg;
9106         msg_var = ChannelUpdate_clone(msg);
9107         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9108         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9109         uint64_t msg_ref = (uint64_t)msg_var.inner;
9110         if (msg_var.is_owned) {
9111                 msg_ref |= 1;
9112         }
9113         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9114         CHECK(obj != NULL);
9115         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_channel_update_meth, msg_ref);
9116         if ((*env)->ExceptionCheck(env)) {
9117                 (*env)->ExceptionDescribe(env);
9118                 (*env)->FatalError(env, "A call to handle_channel_update in LDKRoutingMessageHandler from rust threw an exception.");
9119         }
9120         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1);
9121         ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1));
9122         if (get_jenv_res == JNI_EDETACHED) {
9123                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9124         }
9125         return ret_conv;
9126 }
9127 LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ get_next_channel_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, uint64_t starting_point, uint8_t batch_amount) {
9128         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9129         JNIEnv *env;
9130         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9131         if (get_jenv_res == JNI_EDETACHED) {
9132                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9133         } else {
9134                 DO_ASSERT(get_jenv_res == JNI_OK);
9135         }
9136         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9137         CHECK(obj != NULL);
9138         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_next_channel_announcements_meth, starting_point, batch_amount);
9139         if ((*env)->ExceptionCheck(env)) {
9140                 (*env)->ExceptionDescribe(env);
9141                 (*env)->FatalError(env, "A call to get_next_channel_announcements in LDKRoutingMessageHandler from rust threw an exception.");
9142         }
9143         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_constr;
9144         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
9145         if (ret_constr.datalen > 0)
9146                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
9147         else
9148                 ret_constr.data = NULL;
9149         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
9150         for (size_t h = 0; h < ret_constr.datalen; h++) {
9151                 int64_t ret_conv_59 = ret_vals[h];
9152                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ ret_conv_59_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)ret_conv_59) & ~1);
9153                 ret_conv_59_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone((LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)ret_conv_59) & ~1));
9154                 ret_constr.data[h] = ret_conv_59_conv;
9155         }
9156         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
9157         if (get_jenv_res == JNI_EDETACHED) {
9158                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9159         }
9160         return ret_constr;
9161 }
9162 LDKCVec_NodeAnnouncementZ get_next_node_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey starting_point, uint8_t batch_amount) {
9163         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9164         JNIEnv *env;
9165         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9166         if (get_jenv_res == JNI_EDETACHED) {
9167                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9168         } else {
9169                 DO_ASSERT(get_jenv_res == JNI_OK);
9170         }
9171         int8_tArray starting_point_arr = (*env)->NewByteArray(env, 33);
9172         (*env)->SetByteArrayRegion(env, starting_point_arr, 0, 33, starting_point.compressed_form);
9173         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9174         CHECK(obj != NULL);
9175         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_next_node_announcements_meth, starting_point_arr, batch_amount);
9176         if ((*env)->ExceptionCheck(env)) {
9177                 (*env)->ExceptionDescribe(env);
9178                 (*env)->FatalError(env, "A call to get_next_node_announcements in LDKRoutingMessageHandler from rust threw an exception.");
9179         }
9180         LDKCVec_NodeAnnouncementZ ret_constr;
9181         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
9182         if (ret_constr.datalen > 0)
9183                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
9184         else
9185                 ret_constr.data = NULL;
9186         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
9187         for (size_t s = 0; s < ret_constr.datalen; s++) {
9188                 int64_t ret_conv_18 = ret_vals[s];
9189                 LDKNodeAnnouncement ret_conv_18_conv;
9190                 ret_conv_18_conv.inner = (void*)(ret_conv_18 & (~1));
9191                 ret_conv_18_conv.is_owned = (ret_conv_18 & 1) || (ret_conv_18 == 0);
9192                 ret_conv_18_conv = NodeAnnouncement_clone(&ret_conv_18_conv);
9193                 ret_constr.data[s] = ret_conv_18_conv;
9194         }
9195         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
9196         if (get_jenv_res == JNI_EDETACHED) {
9197                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9198         }
9199         return ret_constr;
9200 }
9201 void sync_routing_table_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * init) {
9202         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9203         JNIEnv *env;
9204         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9205         if (get_jenv_res == JNI_EDETACHED) {
9206                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9207         } else {
9208                 DO_ASSERT(get_jenv_res == JNI_OK);
9209         }
9210         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
9211         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
9212         LDKInit init_var = *init;
9213         init_var = Init_clone(init);
9214         CHECK((((uint64_t)init_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9215         CHECK((((uint64_t)&init_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9216         uint64_t init_ref = (uint64_t)init_var.inner;
9217         if (init_var.is_owned) {
9218                 init_ref |= 1;
9219         }
9220         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9221         CHECK(obj != NULL);
9222         (*env)->CallVoidMethod(env, obj, j_calls->sync_routing_table_meth, their_node_id_arr, init_ref);
9223         if ((*env)->ExceptionCheck(env)) {
9224                 (*env)->ExceptionDescribe(env);
9225                 (*env)->FatalError(env, "A call to sync_routing_table in LDKRoutingMessageHandler from rust threw an exception.");
9226         }
9227         if (get_jenv_res == JNI_EDETACHED) {
9228                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9229         }
9230 }
9231 LDKCResult_NoneLightningErrorZ handle_reply_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyChannelRange msg) {
9232         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9233         JNIEnv *env;
9234         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9235         if (get_jenv_res == JNI_EDETACHED) {
9236                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9237         } else {
9238                 DO_ASSERT(get_jenv_res == JNI_OK);
9239         }
9240         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
9241         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
9242         LDKReplyChannelRange msg_var = msg;
9243         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9244         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9245         uint64_t msg_ref = (uint64_t)msg_var.inner;
9246         if (msg_var.is_owned) {
9247                 msg_ref |= 1;
9248         }
9249         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9250         CHECK(obj != NULL);
9251         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_reply_channel_range_meth, their_node_id_arr, msg_ref);
9252         if ((*env)->ExceptionCheck(env)) {
9253                 (*env)->ExceptionDescribe(env);
9254                 (*env)->FatalError(env, "A call to handle_reply_channel_range in LDKRoutingMessageHandler from rust threw an exception.");
9255         }
9256         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
9257         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
9258         if (get_jenv_res == JNI_EDETACHED) {
9259                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9260         }
9261         return ret_conv;
9262 }
9263 LDKCResult_NoneLightningErrorZ handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyShortChannelIdsEnd msg) {
9264         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9265         JNIEnv *env;
9266         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9267         if (get_jenv_res == JNI_EDETACHED) {
9268                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9269         } else {
9270                 DO_ASSERT(get_jenv_res == JNI_OK);
9271         }
9272         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
9273         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
9274         LDKReplyShortChannelIdsEnd msg_var = msg;
9275         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9276         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9277         uint64_t msg_ref = (uint64_t)msg_var.inner;
9278         if (msg_var.is_owned) {
9279                 msg_ref |= 1;
9280         }
9281         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9282         CHECK(obj != NULL);
9283         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_reply_short_channel_ids_end_meth, their_node_id_arr, msg_ref);
9284         if ((*env)->ExceptionCheck(env)) {
9285                 (*env)->ExceptionDescribe(env);
9286                 (*env)->FatalError(env, "A call to handle_reply_short_channel_ids_end in LDKRoutingMessageHandler from rust threw an exception.");
9287         }
9288         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
9289         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
9290         if (get_jenv_res == JNI_EDETACHED) {
9291                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9292         }
9293         return ret_conv;
9294 }
9295 LDKCResult_NoneLightningErrorZ handle_query_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryChannelRange msg) {
9296         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9297         JNIEnv *env;
9298         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9299         if (get_jenv_res == JNI_EDETACHED) {
9300                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9301         } else {
9302                 DO_ASSERT(get_jenv_res == JNI_OK);
9303         }
9304         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
9305         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
9306         LDKQueryChannelRange msg_var = msg;
9307         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9308         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9309         uint64_t msg_ref = (uint64_t)msg_var.inner;
9310         if (msg_var.is_owned) {
9311                 msg_ref |= 1;
9312         }
9313         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9314         CHECK(obj != NULL);
9315         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_query_channel_range_meth, their_node_id_arr, msg_ref);
9316         if ((*env)->ExceptionCheck(env)) {
9317                 (*env)->ExceptionDescribe(env);
9318                 (*env)->FatalError(env, "A call to handle_query_channel_range in LDKRoutingMessageHandler from rust threw an exception.");
9319         }
9320         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
9321         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
9322         if (get_jenv_res == JNI_EDETACHED) {
9323                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9324         }
9325         return ret_conv;
9326 }
9327 LDKCResult_NoneLightningErrorZ handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryShortChannelIds msg) {
9328         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9329         JNIEnv *env;
9330         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9331         if (get_jenv_res == JNI_EDETACHED) {
9332                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9333         } else {
9334                 DO_ASSERT(get_jenv_res == JNI_OK);
9335         }
9336         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
9337         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
9338         LDKQueryShortChannelIds msg_var = msg;
9339         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9340         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9341         uint64_t msg_ref = (uint64_t)msg_var.inner;
9342         if (msg_var.is_owned) {
9343                 msg_ref |= 1;
9344         }
9345         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9346         CHECK(obj != NULL);
9347         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_query_short_channel_ids_meth, their_node_id_arr, msg_ref);
9348         if ((*env)->ExceptionCheck(env)) {
9349                 (*env)->ExceptionDescribe(env);
9350                 (*env)->FatalError(env, "A call to handle_query_short_channel_ids in LDKRoutingMessageHandler from rust threw an exception.");
9351         }
9352         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
9353         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
9354         if (get_jenv_res == JNI_EDETACHED) {
9355                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9356         }
9357         return ret_conv;
9358 }
9359 static void LDKRoutingMessageHandler_JCalls_cloned(LDKRoutingMessageHandler* new_obj) {
9360         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) new_obj->this_arg;
9361         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
9362         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
9363 }
9364 static inline LDKRoutingMessageHandler LDKRoutingMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
9365         jclass c = (*env)->GetObjectClass(env, o);
9366         CHECK(c != NULL);
9367         LDKRoutingMessageHandler_JCalls *calls = MALLOC(sizeof(LDKRoutingMessageHandler_JCalls), "LDKRoutingMessageHandler_JCalls");
9368         atomic_init(&calls->refcnt, 1);
9369         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
9370         calls->o = (*env)->NewWeakGlobalRef(env, o);
9371         calls->handle_node_announcement_meth = (*env)->GetMethodID(env, c, "handle_node_announcement", "(J)J");
9372         CHECK(calls->handle_node_announcement_meth != NULL);
9373         calls->handle_channel_announcement_meth = (*env)->GetMethodID(env, c, "handle_channel_announcement", "(J)J");
9374         CHECK(calls->handle_channel_announcement_meth != NULL);
9375         calls->handle_channel_update_meth = (*env)->GetMethodID(env, c, "handle_channel_update", "(J)J");
9376         CHECK(calls->handle_channel_update_meth != NULL);
9377         calls->get_next_channel_announcements_meth = (*env)->GetMethodID(env, c, "get_next_channel_announcements", "(JB)[J");
9378         CHECK(calls->get_next_channel_announcements_meth != NULL);
9379         calls->get_next_node_announcements_meth = (*env)->GetMethodID(env, c, "get_next_node_announcements", "([BB)[J");
9380         CHECK(calls->get_next_node_announcements_meth != NULL);
9381         calls->sync_routing_table_meth = (*env)->GetMethodID(env, c, "sync_routing_table", "([BJ)V");
9382         CHECK(calls->sync_routing_table_meth != NULL);
9383         calls->handle_reply_channel_range_meth = (*env)->GetMethodID(env, c, "handle_reply_channel_range", "([BJ)J");
9384         CHECK(calls->handle_reply_channel_range_meth != NULL);
9385         calls->handle_reply_short_channel_ids_end_meth = (*env)->GetMethodID(env, c, "handle_reply_short_channel_ids_end", "([BJ)J");
9386         CHECK(calls->handle_reply_short_channel_ids_end_meth != NULL);
9387         calls->handle_query_channel_range_meth = (*env)->GetMethodID(env, c, "handle_query_channel_range", "([BJ)J");
9388         CHECK(calls->handle_query_channel_range_meth != NULL);
9389         calls->handle_query_short_channel_ids_meth = (*env)->GetMethodID(env, c, "handle_query_short_channel_ids", "([BJ)J");
9390         CHECK(calls->handle_query_short_channel_ids_meth != NULL);
9391
9392         LDKRoutingMessageHandler ret = {
9393                 .this_arg = (void*) calls,
9394                 .handle_node_announcement = handle_node_announcement_LDKRoutingMessageHandler_jcall,
9395                 .handle_channel_announcement = handle_channel_announcement_LDKRoutingMessageHandler_jcall,
9396                 .handle_channel_update = handle_channel_update_LDKRoutingMessageHandler_jcall,
9397                 .get_next_channel_announcements = get_next_channel_announcements_LDKRoutingMessageHandler_jcall,
9398                 .get_next_node_announcements = get_next_node_announcements_LDKRoutingMessageHandler_jcall,
9399                 .sync_routing_table = sync_routing_table_LDKRoutingMessageHandler_jcall,
9400                 .handle_reply_channel_range = handle_reply_channel_range_LDKRoutingMessageHandler_jcall,
9401                 .handle_reply_short_channel_ids_end = handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall,
9402                 .handle_query_channel_range = handle_query_channel_range_LDKRoutingMessageHandler_jcall,
9403                 .handle_query_short_channel_ids = handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall,
9404                 .free = LDKRoutingMessageHandler_JCalls_free,
9405                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(env, clz, MessageSendEventsProvider),
9406         };
9407         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
9408         return ret;
9409 }
9410 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
9411         LDKRoutingMessageHandler *res_ptr = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
9412         *res_ptr = LDKRoutingMessageHandler_init(env, clz, o, MessageSendEventsProvider);
9413         return (uint64_t)res_ptr;
9414 }
9415 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1get_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t arg) {
9416         LDKRoutingMessageHandler *inp = (LDKRoutingMessageHandler *)(arg & ~1);
9417         uint64_t res_ptr = (uint64_t)&inp->MessageSendEventsProvider;
9418         DO_ASSERT((res_ptr & 1) == 0);
9419         return (int64_t)(res_ptr | 1);
9420 }
9421 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1node_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
9422         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
9423         LDKNodeAnnouncement msg_conv;
9424         msg_conv.inner = (void*)(msg & (~1));
9425         msg_conv.is_owned = false;
9426         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
9427         *ret_conv = (this_arg_conv->handle_node_announcement)(this_arg_conv->this_arg, &msg_conv);
9428         return (uint64_t)ret_conv;
9429 }
9430
9431 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1channel_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
9432         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
9433         LDKChannelAnnouncement msg_conv;
9434         msg_conv.inner = (void*)(msg & (~1));
9435         msg_conv.is_owned = false;
9436         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
9437         *ret_conv = (this_arg_conv->handle_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
9438         return (uint64_t)ret_conv;
9439 }
9440
9441 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1channel_1update(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
9442         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
9443         LDKChannelUpdate msg_conv;
9444         msg_conv.inner = (void*)(msg & (~1));
9445         msg_conv.is_owned = false;
9446         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
9447         *ret_conv = (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, &msg_conv);
9448         return (uint64_t)ret_conv;
9449 }
9450
9451 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) {
9452         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
9453         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_var = (this_arg_conv->get_next_channel_announcements)(this_arg_conv->this_arg, starting_point, batch_amount);
9454         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
9455         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
9456         for (size_t h = 0; h < ret_var.datalen; h++) {
9457                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv_59_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
9458                 *ret_conv_59_conv = ret_var.data[h];
9459                 ret_arr_ptr[h] = ((uint64_t)ret_conv_59_conv);
9460         }
9461         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
9462         FREE(ret_var.data);
9463         return ret_arr;
9464 }
9465
9466 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) {
9467         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
9468         LDKPublicKey starting_point_ref;
9469         CHECK((*env)->GetArrayLength(env, starting_point) == 33);
9470         (*env)->GetByteArrayRegion(env, starting_point, 0, 33, starting_point_ref.compressed_form);
9471         LDKCVec_NodeAnnouncementZ ret_var = (this_arg_conv->get_next_node_announcements)(this_arg_conv->this_arg, starting_point_ref, batch_amount);
9472         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
9473         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
9474         for (size_t s = 0; s < ret_var.datalen; s++) {
9475                 LDKNodeAnnouncement ret_conv_18_var = ret_var.data[s];
9476                 CHECK((((uint64_t)ret_conv_18_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9477                 CHECK((((uint64_t)&ret_conv_18_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9478                 uint64_t ret_conv_18_ref = (uint64_t)ret_conv_18_var.inner;
9479                 if (ret_conv_18_var.is_owned) {
9480                         ret_conv_18_ref |= 1;
9481                 }
9482                 ret_arr_ptr[s] = ret_conv_18_ref;
9483         }
9484         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
9485         FREE(ret_var.data);
9486         return ret_arr;
9487 }
9488
9489 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) {
9490         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
9491         LDKPublicKey their_node_id_ref;
9492         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9493         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9494         LDKInit init_conv;
9495         init_conv.inner = (void*)(init & (~1));
9496         init_conv.is_owned = false;
9497         (this_arg_conv->sync_routing_table)(this_arg_conv->this_arg, their_node_id_ref, &init_conv);
9498 }
9499
9500 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) {
9501         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
9502         LDKPublicKey their_node_id_ref;
9503         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9504         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9505         LDKReplyChannelRange msg_conv;
9506         msg_conv.inner = (void*)(msg & (~1));
9507         msg_conv.is_owned = (msg & 1) || (msg == 0);
9508         msg_conv = ReplyChannelRange_clone(&msg_conv);
9509         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
9510         *ret_conv = (this_arg_conv->handle_reply_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
9511         return (uint64_t)ret_conv;
9512 }
9513
9514 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) {
9515         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
9516         LDKPublicKey their_node_id_ref;
9517         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9518         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9519         LDKReplyShortChannelIdsEnd msg_conv;
9520         msg_conv.inner = (void*)(msg & (~1));
9521         msg_conv.is_owned = (msg & 1) || (msg == 0);
9522         msg_conv = ReplyShortChannelIdsEnd_clone(&msg_conv);
9523         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
9524         *ret_conv = (this_arg_conv->handle_reply_short_channel_ids_end)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
9525         return (uint64_t)ret_conv;
9526 }
9527
9528 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) {
9529         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
9530         LDKPublicKey their_node_id_ref;
9531         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9532         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9533         LDKQueryChannelRange msg_conv;
9534         msg_conv.inner = (void*)(msg & (~1));
9535         msg_conv.is_owned = (msg & 1) || (msg == 0);
9536         msg_conv = QueryChannelRange_clone(&msg_conv);
9537         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
9538         *ret_conv = (this_arg_conv->handle_query_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
9539         return (uint64_t)ret_conv;
9540 }
9541
9542 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) {
9543         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
9544         LDKPublicKey their_node_id_ref;
9545         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9546         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9547         LDKQueryShortChannelIds msg_conv;
9548         msg_conv.inner = (void*)(msg & (~1));
9549         msg_conv.is_owned = (msg & 1) || (msg == 0);
9550         msg_conv = QueryShortChannelIds_clone(&msg_conv);
9551         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
9552         *ret_conv = (this_arg_conv->handle_query_short_channel_ids)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
9553         return (uint64_t)ret_conv;
9554 }
9555
9556 typedef struct LDKCustomMessageReader_JCalls {
9557         atomic_size_t refcnt;
9558         JavaVM *vm;
9559         jweak o;
9560         jmethodID read_meth;
9561 } LDKCustomMessageReader_JCalls;
9562 static void LDKCustomMessageReader_JCalls_free(void* this_arg) {
9563         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) this_arg;
9564         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
9565                 JNIEnv *env;
9566                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9567                 if (get_jenv_res == JNI_EDETACHED) {
9568                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9569                 } else {
9570                         DO_ASSERT(get_jenv_res == JNI_OK);
9571                 }
9572                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
9573                 if (get_jenv_res == JNI_EDETACHED) {
9574                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9575                 }
9576                 FREE(j_calls);
9577         }
9578 }
9579 LDKCResult_COption_TypeZDecodeErrorZ read_LDKCustomMessageReader_jcall(const void* this_arg, uint16_t message_type, LDKu8slice buffer) {
9580         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) this_arg;
9581         JNIEnv *env;
9582         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9583         if (get_jenv_res == JNI_EDETACHED) {
9584                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9585         } else {
9586                 DO_ASSERT(get_jenv_res == JNI_OK);
9587         }
9588         LDKu8slice buffer_var = buffer;
9589         int8_tArray buffer_arr = (*env)->NewByteArray(env, buffer_var.datalen);
9590         (*env)->SetByteArrayRegion(env, buffer_arr, 0, buffer_var.datalen, buffer_var.data);
9591         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9592         CHECK(obj != NULL);
9593         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->read_meth, message_type, buffer_arr);
9594         if ((*env)->ExceptionCheck(env)) {
9595                 (*env)->ExceptionDescribe(env);
9596                 (*env)->FatalError(env, "A call to read in LDKCustomMessageReader from rust threw an exception.");
9597         }
9598         LDKCResult_COption_TypeZDecodeErrorZ ret_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(((uint64_t)ret) & ~1);
9599         ret_conv = CResult_COption_TypeZDecodeErrorZ_clone((LDKCResult_COption_TypeZDecodeErrorZ*)(((uint64_t)ret) & ~1));
9600         if (get_jenv_res == JNI_EDETACHED) {
9601                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9602         }
9603         return ret_conv;
9604 }
9605 static void LDKCustomMessageReader_JCalls_cloned(LDKCustomMessageReader* new_obj) {
9606         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) new_obj->this_arg;
9607         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
9608 }
9609 static inline LDKCustomMessageReader LDKCustomMessageReader_init (JNIEnv *env, jclass clz, jobject o) {
9610         jclass c = (*env)->GetObjectClass(env, o);
9611         CHECK(c != NULL);
9612         LDKCustomMessageReader_JCalls *calls = MALLOC(sizeof(LDKCustomMessageReader_JCalls), "LDKCustomMessageReader_JCalls");
9613         atomic_init(&calls->refcnt, 1);
9614         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
9615         calls->o = (*env)->NewWeakGlobalRef(env, o);
9616         calls->read_meth = (*env)->GetMethodID(env, c, "read", "(S[B)J");
9617         CHECK(calls->read_meth != NULL);
9618
9619         LDKCustomMessageReader ret = {
9620                 .this_arg = (void*) calls,
9621                 .read = read_LDKCustomMessageReader_jcall,
9622                 .free = LDKCustomMessageReader_JCalls_free,
9623         };
9624         return ret;
9625 }
9626 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCustomMessageReader_1new(JNIEnv *env, jclass clz, jobject o) {
9627         LDKCustomMessageReader *res_ptr = MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader");
9628         *res_ptr = LDKCustomMessageReader_init(env, clz, o);
9629         return (uint64_t)res_ptr;
9630 }
9631 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CustomMessageReader_1read(JNIEnv *env, jclass clz, int64_t this_arg, int16_t message_type, int8_tArray buffer) {
9632         LDKCustomMessageReader* this_arg_conv = (LDKCustomMessageReader*)(((uint64_t)this_arg) & ~1);
9633         LDKu8slice buffer_ref;
9634         buffer_ref.datalen = (*env)->GetArrayLength(env, buffer);
9635         buffer_ref.data = (*env)->GetByteArrayElements (env, buffer, NULL);
9636         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
9637         *ret_conv = (this_arg_conv->read)(this_arg_conv->this_arg, message_type, buffer_ref);
9638         (*env)->ReleaseByteArrayElements(env, buffer, (int8_t*)buffer_ref.data, 0);
9639         return (uint64_t)ret_conv;
9640 }
9641
9642 typedef struct LDKCustomMessageHandler_JCalls {
9643         atomic_size_t refcnt;
9644         JavaVM *vm;
9645         jweak o;
9646         LDKCustomMessageReader_JCalls* CustomMessageReader;
9647         jmethodID handle_custom_message_meth;
9648         jmethodID get_and_clear_pending_msg_meth;
9649 } LDKCustomMessageHandler_JCalls;
9650 static void LDKCustomMessageHandler_JCalls_free(void* this_arg) {
9651         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
9652         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
9653                 JNIEnv *env;
9654                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9655                 if (get_jenv_res == JNI_EDETACHED) {
9656                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9657                 } else {
9658                         DO_ASSERT(get_jenv_res == JNI_OK);
9659                 }
9660                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
9661                 if (get_jenv_res == JNI_EDETACHED) {
9662                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9663                 }
9664                 FREE(j_calls);
9665         }
9666 }
9667 LDKCResult_NoneLightningErrorZ handle_custom_message_LDKCustomMessageHandler_jcall(const void* this_arg, LDKType msg, LDKPublicKey sender_node_id) {
9668         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
9669         JNIEnv *env;
9670         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9671         if (get_jenv_res == JNI_EDETACHED) {
9672                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9673         } else {
9674                 DO_ASSERT(get_jenv_res == JNI_OK);
9675         }
9676         LDKType* msg_ret =MALLOC(sizeof(LDKType), "LDKType");
9677         *msg_ret = msg;
9678         int8_tArray sender_node_id_arr = (*env)->NewByteArray(env, 33);
9679         (*env)->SetByteArrayRegion(env, sender_node_id_arr, 0, 33, sender_node_id.compressed_form);
9680         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9681         CHECK(obj != NULL);
9682         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_custom_message_meth, (uint64_t)msg_ret, sender_node_id_arr);
9683         if ((*env)->ExceptionCheck(env)) {
9684                 (*env)->ExceptionDescribe(env);
9685                 (*env)->FatalError(env, "A call to handle_custom_message in LDKCustomMessageHandler from rust threw an exception.");
9686         }
9687         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
9688         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
9689         if (get_jenv_res == JNI_EDETACHED) {
9690                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9691         }
9692         return ret_conv;
9693 }
9694 LDKCVec_C2Tuple_PublicKeyTypeZZ get_and_clear_pending_msg_LDKCustomMessageHandler_jcall(const void* this_arg) {
9695         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
9696         JNIEnv *env;
9697         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9698         if (get_jenv_res == JNI_EDETACHED) {
9699                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9700         } else {
9701                 DO_ASSERT(get_jenv_res == JNI_OK);
9702         }
9703         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9704         CHECK(obj != NULL);
9705         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_and_clear_pending_msg_meth);
9706         if ((*env)->ExceptionCheck(env)) {
9707                 (*env)->ExceptionDescribe(env);
9708                 (*env)->FatalError(env, "A call to get_and_clear_pending_msg in LDKCustomMessageHandler from rust threw an exception.");
9709         }
9710         LDKCVec_C2Tuple_PublicKeyTypeZZ ret_constr;
9711         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
9712         if (ret_constr.datalen > 0)
9713                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ Elements");
9714         else
9715                 ret_constr.data = NULL;
9716         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
9717         for (size_t z = 0; z < ret_constr.datalen; z++) {
9718                 int64_t ret_conv_25 = ret_vals[z];
9719                 LDKC2Tuple_PublicKeyTypeZ ret_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(((uint64_t)ret_conv_25) & ~1);
9720                 ret_conv_25_conv = C2Tuple_PublicKeyTypeZ_clone((LDKC2Tuple_PublicKeyTypeZ*)(((uint64_t)ret_conv_25) & ~1));
9721                 ret_constr.data[z] = ret_conv_25_conv;
9722         }
9723         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
9724         if (get_jenv_res == JNI_EDETACHED) {
9725                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9726         }
9727         return ret_constr;
9728 }
9729 static void LDKCustomMessageHandler_JCalls_cloned(LDKCustomMessageHandler* new_obj) {
9730         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) new_obj->this_arg;
9731         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
9732         atomic_fetch_add_explicit(&j_calls->CustomMessageReader->refcnt, 1, memory_order_release);
9733 }
9734 static inline LDKCustomMessageHandler LDKCustomMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject CustomMessageReader) {
9735         jclass c = (*env)->GetObjectClass(env, o);
9736         CHECK(c != NULL);
9737         LDKCustomMessageHandler_JCalls *calls = MALLOC(sizeof(LDKCustomMessageHandler_JCalls), "LDKCustomMessageHandler_JCalls");
9738         atomic_init(&calls->refcnt, 1);
9739         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
9740         calls->o = (*env)->NewWeakGlobalRef(env, o);
9741         calls->handle_custom_message_meth = (*env)->GetMethodID(env, c, "handle_custom_message", "(J[B)J");
9742         CHECK(calls->handle_custom_message_meth != NULL);
9743         calls->get_and_clear_pending_msg_meth = (*env)->GetMethodID(env, c, "get_and_clear_pending_msg", "()[J");
9744         CHECK(calls->get_and_clear_pending_msg_meth != NULL);
9745
9746         LDKCustomMessageHandler ret = {
9747                 .this_arg = (void*) calls,
9748                 .handle_custom_message = handle_custom_message_LDKCustomMessageHandler_jcall,
9749                 .get_and_clear_pending_msg = get_and_clear_pending_msg_LDKCustomMessageHandler_jcall,
9750                 .free = LDKCustomMessageHandler_JCalls_free,
9751                 .CustomMessageReader = LDKCustomMessageReader_init(env, clz, CustomMessageReader),
9752         };
9753         calls->CustomMessageReader = ret.CustomMessageReader.this_arg;
9754         return ret;
9755 }
9756 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCustomMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject CustomMessageReader) {
9757         LDKCustomMessageHandler *res_ptr = MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler");
9758         *res_ptr = LDKCustomMessageHandler_init(env, clz, o, CustomMessageReader);
9759         return (uint64_t)res_ptr;
9760 }
9761 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCustomMessageHandler_1get_1CustomMessageReader(JNIEnv *env, jclass clz, int64_t arg) {
9762         LDKCustomMessageHandler *inp = (LDKCustomMessageHandler *)(arg & ~1);
9763         uint64_t res_ptr = (uint64_t)&inp->CustomMessageReader;
9764         DO_ASSERT((res_ptr & 1) == 0);
9765         return (int64_t)(res_ptr | 1);
9766 }
9767 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CustomMessageHandler_1handle_1custom_1message(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg, int8_tArray sender_node_id) {
9768         LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)(((uint64_t)this_arg) & ~1);
9769         LDKType msg_conv = *(LDKType*)(((uint64_t)msg) & ~1);
9770         if (msg_conv.free == LDKType_JCalls_free) {
9771                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
9772                 LDKType_JCalls_cloned(&msg_conv);
9773         }
9774         LDKPublicKey sender_node_id_ref;
9775         CHECK((*env)->GetArrayLength(env, sender_node_id) == 33);
9776         (*env)->GetByteArrayRegion(env, sender_node_id, 0, 33, sender_node_id_ref.compressed_form);
9777         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
9778         *ret_conv = (this_arg_conv->handle_custom_message)(this_arg_conv->this_arg, msg_conv, sender_node_id_ref);
9779         return (uint64_t)ret_conv;
9780 }
9781
9782 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CustomMessageHandler_1get_1and_1clear_1pending_1msg(JNIEnv *env, jclass clz, int64_t this_arg) {
9783         LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)(((uint64_t)this_arg) & ~1);
9784         LDKCVec_C2Tuple_PublicKeyTypeZZ ret_var = (this_arg_conv->get_and_clear_pending_msg)(this_arg_conv->this_arg);
9785         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
9786         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
9787         for (size_t z = 0; z < ret_var.datalen; z++) {
9788                 LDKC2Tuple_PublicKeyTypeZ* ret_conv_25_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
9789                 *ret_conv_25_conv = ret_var.data[z];
9790                 ret_arr_ptr[z] = ((uint64_t)ret_conv_25_conv);
9791         }
9792         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
9793         FREE(ret_var.data);
9794         return ret_arr;
9795 }
9796
9797 typedef struct LDKSocketDescriptor_JCalls {
9798         atomic_size_t refcnt;
9799         JavaVM *vm;
9800         jweak o;
9801         jmethodID send_data_meth;
9802         jmethodID disconnect_socket_meth;
9803         jmethodID eq_meth;
9804         jmethodID hash_meth;
9805 } LDKSocketDescriptor_JCalls;
9806 static void LDKSocketDescriptor_JCalls_free(void* this_arg) {
9807         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
9808         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
9809                 JNIEnv *env;
9810                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9811                 if (get_jenv_res == JNI_EDETACHED) {
9812                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9813                 } else {
9814                         DO_ASSERT(get_jenv_res == JNI_OK);
9815                 }
9816                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
9817                 if (get_jenv_res == JNI_EDETACHED) {
9818                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9819                 }
9820                 FREE(j_calls);
9821         }
9822 }
9823 uintptr_t send_data_LDKSocketDescriptor_jcall(void* this_arg, LDKu8slice data, bool resume_read) {
9824         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
9825         JNIEnv *env;
9826         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9827         if (get_jenv_res == JNI_EDETACHED) {
9828                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9829         } else {
9830                 DO_ASSERT(get_jenv_res == JNI_OK);
9831         }
9832         LDKu8slice data_var = data;
9833         int8_tArray data_arr = (*env)->NewByteArray(env, data_var.datalen);
9834         (*env)->SetByteArrayRegion(env, data_arr, 0, data_var.datalen, data_var.data);
9835         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9836         CHECK(obj != NULL);
9837         int64_t ret = (*env)->CallLongMethod(env, obj, j_calls->send_data_meth, data_arr, resume_read);
9838         if ((*env)->ExceptionCheck(env)) {
9839                 (*env)->ExceptionDescribe(env);
9840                 (*env)->FatalError(env, "A call to send_data in LDKSocketDescriptor from rust threw an exception.");
9841         }
9842         if (get_jenv_res == JNI_EDETACHED) {
9843                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9844         }
9845         return ret;
9846 }
9847 void disconnect_socket_LDKSocketDescriptor_jcall(void* this_arg) {
9848         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
9849         JNIEnv *env;
9850         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9851         if (get_jenv_res == JNI_EDETACHED) {
9852                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9853         } else {
9854                 DO_ASSERT(get_jenv_res == JNI_OK);
9855         }
9856         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9857         CHECK(obj != NULL);
9858         (*env)->CallVoidMethod(env, obj, j_calls->disconnect_socket_meth);
9859         if ((*env)->ExceptionCheck(env)) {
9860                 (*env)->ExceptionDescribe(env);
9861                 (*env)->FatalError(env, "A call to disconnect_socket in LDKSocketDescriptor from rust threw an exception.");
9862         }
9863         if (get_jenv_res == JNI_EDETACHED) {
9864                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9865         }
9866 }
9867 bool eq_LDKSocketDescriptor_jcall(const void* this_arg, const LDKSocketDescriptor * other_arg) {
9868         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
9869         JNIEnv *env;
9870         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9871         if (get_jenv_res == JNI_EDETACHED) {
9872                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9873         } else {
9874                 DO_ASSERT(get_jenv_res == JNI_OK);
9875         }
9876         LDKSocketDescriptor *other_arg_clone = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
9877         *other_arg_clone = SocketDescriptor_clone(other_arg);
9878         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9879         CHECK(obj != NULL);
9880         jboolean ret = (*env)->CallBooleanMethod(env, obj, j_calls->eq_meth, (uint64_t)other_arg_clone);
9881         if ((*env)->ExceptionCheck(env)) {
9882                 (*env)->ExceptionDescribe(env);
9883                 (*env)->FatalError(env, "A call to eq in LDKSocketDescriptor from rust threw an exception.");
9884         }
9885         if (get_jenv_res == JNI_EDETACHED) {
9886                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9887         }
9888         return ret;
9889 }
9890 uint64_t hash_LDKSocketDescriptor_jcall(const void* this_arg) {
9891         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
9892         JNIEnv *env;
9893         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9894         if (get_jenv_res == JNI_EDETACHED) {
9895                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9896         } else {
9897                 DO_ASSERT(get_jenv_res == JNI_OK);
9898         }
9899         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9900         CHECK(obj != NULL);
9901         int64_t ret = (*env)->CallLongMethod(env, obj, j_calls->hash_meth);
9902         if ((*env)->ExceptionCheck(env)) {
9903                 (*env)->ExceptionDescribe(env);
9904                 (*env)->FatalError(env, "A call to hash in LDKSocketDescriptor from rust threw an exception.");
9905         }
9906         if (get_jenv_res == JNI_EDETACHED) {
9907                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9908         }
9909         return ret;
9910 }
9911 static void LDKSocketDescriptor_JCalls_cloned(LDKSocketDescriptor* new_obj) {
9912         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) new_obj->this_arg;
9913         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
9914 }
9915 static inline LDKSocketDescriptor LDKSocketDescriptor_init (JNIEnv *env, jclass clz, jobject o) {
9916         jclass c = (*env)->GetObjectClass(env, o);
9917         CHECK(c != NULL);
9918         LDKSocketDescriptor_JCalls *calls = MALLOC(sizeof(LDKSocketDescriptor_JCalls), "LDKSocketDescriptor_JCalls");
9919         atomic_init(&calls->refcnt, 1);
9920         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
9921         calls->o = (*env)->NewWeakGlobalRef(env, o);
9922         calls->send_data_meth = (*env)->GetMethodID(env, c, "send_data", "([BZ)J");
9923         CHECK(calls->send_data_meth != NULL);
9924         calls->disconnect_socket_meth = (*env)->GetMethodID(env, c, "disconnect_socket", "()V");
9925         CHECK(calls->disconnect_socket_meth != NULL);
9926         calls->eq_meth = (*env)->GetMethodID(env, c, "eq", "(J)Z");
9927         CHECK(calls->eq_meth != NULL);
9928         calls->hash_meth = (*env)->GetMethodID(env, c, "hash", "()J");
9929         CHECK(calls->hash_meth != NULL);
9930
9931         LDKSocketDescriptor ret = {
9932                 .this_arg = (void*) calls,
9933                 .send_data = send_data_LDKSocketDescriptor_jcall,
9934                 .disconnect_socket = disconnect_socket_LDKSocketDescriptor_jcall,
9935                 .eq = eq_LDKSocketDescriptor_jcall,
9936                 .hash = hash_LDKSocketDescriptor_jcall,
9937                 .cloned = LDKSocketDescriptor_JCalls_cloned,
9938                 .free = LDKSocketDescriptor_JCalls_free,
9939         };
9940         return ret;
9941 }
9942 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSocketDescriptor_1new(JNIEnv *env, jclass clz, jobject o) {
9943         LDKSocketDescriptor *res_ptr = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
9944         *res_ptr = LDKSocketDescriptor_init(env, clz, o);
9945         return (uint64_t)res_ptr;
9946 }
9947 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) {
9948         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)(((uint64_t)this_arg) & ~1);
9949         LDKu8slice data_ref;
9950         data_ref.datalen = (*env)->GetArrayLength(env, data);
9951         data_ref.data = (*env)->GetByteArrayElements (env, data, NULL);
9952         int64_t ret_val = (this_arg_conv->send_data)(this_arg_conv->this_arg, data_ref, resume_read);
9953         (*env)->ReleaseByteArrayElements(env, data, (int8_t*)data_ref.data, 0);
9954         return ret_val;
9955 }
9956
9957 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1disconnect_1socket(JNIEnv *env, jclass clz, int64_t this_arg) {
9958         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)(((uint64_t)this_arg) & ~1);
9959         (this_arg_conv->disconnect_socket)(this_arg_conv->this_arg);
9960 }
9961
9962 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
9963         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)(((uint64_t)this_arg) & ~1);
9964         int64_t ret_val = (this_arg_conv->hash)(this_arg_conv->this_arg);
9965         return ret_val;
9966 }
9967
9968 typedef struct LDKChannelManagerPersister_JCalls {
9969         atomic_size_t refcnt;
9970         JavaVM *vm;
9971         jweak o;
9972         jmethodID persist_manager_meth;
9973 } LDKChannelManagerPersister_JCalls;
9974 static void LDKChannelManagerPersister_JCalls_free(void* this_arg) {
9975         LDKChannelManagerPersister_JCalls *j_calls = (LDKChannelManagerPersister_JCalls*) this_arg;
9976         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
9977                 JNIEnv *env;
9978                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9979                 if (get_jenv_res == JNI_EDETACHED) {
9980                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9981                 } else {
9982                         DO_ASSERT(get_jenv_res == JNI_OK);
9983                 }
9984                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
9985                 if (get_jenv_res == JNI_EDETACHED) {
9986                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9987                 }
9988                 FREE(j_calls);
9989         }
9990 }
9991 LDKCResult_NoneErrorZ persist_manager_LDKChannelManagerPersister_jcall(const void* this_arg, const LDKChannelManager * channel_manager) {
9992         LDKChannelManagerPersister_JCalls *j_calls = (LDKChannelManagerPersister_JCalls*) this_arg;
9993         JNIEnv *env;
9994         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9995         if (get_jenv_res == JNI_EDETACHED) {
9996                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9997         } else {
9998                 DO_ASSERT(get_jenv_res == JNI_OK);
9999         }
10000         LDKChannelManager channel_manager_var = *channel_manager;
10001         // Warning: we may need a move here but no clone is available for LDKChannelManager
10002         CHECK((((uint64_t)channel_manager_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10003         CHECK((((uint64_t)&channel_manager_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10004         uint64_t channel_manager_ref = (uint64_t)channel_manager_var.inner;
10005         if (channel_manager_var.is_owned) {
10006                 channel_manager_ref |= 1;
10007         }
10008         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10009         CHECK(obj != NULL);
10010         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->persist_manager_meth, channel_manager_ref);
10011         if ((*env)->ExceptionCheck(env)) {
10012                 (*env)->ExceptionDescribe(env);
10013                 (*env)->FatalError(env, "A call to persist_manager in LDKChannelManagerPersister from rust threw an exception.");
10014         }
10015         LDKCResult_NoneErrorZ ret_conv = *(LDKCResult_NoneErrorZ*)(((uint64_t)ret) & ~1);
10016         ret_conv = CResult_NoneErrorZ_clone((LDKCResult_NoneErrorZ*)(((uint64_t)ret) & ~1));
10017         if (get_jenv_res == JNI_EDETACHED) {
10018                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10019         }
10020         return ret_conv;
10021 }
10022 static void LDKChannelManagerPersister_JCalls_cloned(LDKChannelManagerPersister* new_obj) {
10023         LDKChannelManagerPersister_JCalls *j_calls = (LDKChannelManagerPersister_JCalls*) new_obj->this_arg;
10024         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10025 }
10026 static inline LDKChannelManagerPersister LDKChannelManagerPersister_init (JNIEnv *env, jclass clz, jobject o) {
10027         jclass c = (*env)->GetObjectClass(env, o);
10028         CHECK(c != NULL);
10029         LDKChannelManagerPersister_JCalls *calls = MALLOC(sizeof(LDKChannelManagerPersister_JCalls), "LDKChannelManagerPersister_JCalls");
10030         atomic_init(&calls->refcnt, 1);
10031         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
10032         calls->o = (*env)->NewWeakGlobalRef(env, o);
10033         calls->persist_manager_meth = (*env)->GetMethodID(env, c, "persist_manager", "(J)J");
10034         CHECK(calls->persist_manager_meth != NULL);
10035
10036         LDKChannelManagerPersister ret = {
10037                 .this_arg = (void*) calls,
10038                 .persist_manager = persist_manager_LDKChannelManagerPersister_jcall,
10039                 .free = LDKChannelManagerPersister_JCalls_free,
10040         };
10041         return ret;
10042 }
10043 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKChannelManagerPersister_1new(JNIEnv *env, jclass clz, jobject o) {
10044         LDKChannelManagerPersister *res_ptr = MALLOC(sizeof(LDKChannelManagerPersister), "LDKChannelManagerPersister");
10045         *res_ptr = LDKChannelManagerPersister_init(env, clz, o);
10046         return (uint64_t)res_ptr;
10047 }
10048 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerPersister_1persist_1manager(JNIEnv *env, jclass clz, int64_t this_arg, int64_t channel_manager) {
10049         LDKChannelManagerPersister* this_arg_conv = (LDKChannelManagerPersister*)(((uint64_t)this_arg) & ~1);
10050         LDKChannelManager channel_manager_conv;
10051         channel_manager_conv.inner = (void*)(channel_manager & (~1));
10052         channel_manager_conv.is_owned = false;
10053         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
10054         *ret_conv = (this_arg_conv->persist_manager)(this_arg_conv->this_arg, &channel_manager_conv);
10055         return (uint64_t)ret_conv;
10056 }
10057
10058 static jclass LDKFallback_SegWitProgram_class = NULL;
10059 static jmethodID LDKFallback_SegWitProgram_meth = NULL;
10060 static jclass LDKFallback_PubKeyHash_class = NULL;
10061 static jmethodID LDKFallback_PubKeyHash_meth = NULL;
10062 static jclass LDKFallback_ScriptHash_class = NULL;
10063 static jmethodID LDKFallback_ScriptHash_meth = NULL;
10064 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKFallback_init (JNIEnv *env, jclass clz) {
10065         LDKFallback_SegWitProgram_class =
10066                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKFallback$SegWitProgram;"));
10067         CHECK(LDKFallback_SegWitProgram_class != NULL);
10068         LDKFallback_SegWitProgram_meth = (*env)->GetMethodID(env, LDKFallback_SegWitProgram_class, "<init>", "(B[B)V");
10069         CHECK(LDKFallback_SegWitProgram_meth != NULL);
10070         LDKFallback_PubKeyHash_class =
10071                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKFallback$PubKeyHash;"));
10072         CHECK(LDKFallback_PubKeyHash_class != NULL);
10073         LDKFallback_PubKeyHash_meth = (*env)->GetMethodID(env, LDKFallback_PubKeyHash_class, "<init>", "([B)V");
10074         CHECK(LDKFallback_PubKeyHash_meth != NULL);
10075         LDKFallback_ScriptHash_class =
10076                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKFallback$ScriptHash;"));
10077         CHECK(LDKFallback_ScriptHash_class != NULL);
10078         LDKFallback_ScriptHash_meth = (*env)->GetMethodID(env, LDKFallback_ScriptHash_class, "<init>", "([B)V");
10079         CHECK(LDKFallback_ScriptHash_meth != NULL);
10080 }
10081 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKFallback_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
10082         LDKFallback *obj = (LDKFallback*)(ptr & ~1);
10083         switch(obj->tag) {
10084                 case LDKFallback_SegWitProgram: {
10085                         uint8_t version_val = obj->seg_wit_program.version._0;
10086                         LDKCVec_u8Z program_var = obj->seg_wit_program.program;
10087                         int8_tArray program_arr = (*env)->NewByteArray(env, program_var.datalen);
10088                         (*env)->SetByteArrayRegion(env, program_arr, 0, program_var.datalen, program_var.data);
10089                         return (*env)->NewObject(env, LDKFallback_SegWitProgram_class, LDKFallback_SegWitProgram_meth, version_val, program_arr);
10090                 }
10091                 case LDKFallback_PubKeyHash: {
10092                         int8_tArray pub_key_hash_arr = (*env)->NewByteArray(env, 20);
10093                         (*env)->SetByteArrayRegion(env, pub_key_hash_arr, 0, 20, obj->pub_key_hash.data);
10094                         return (*env)->NewObject(env, LDKFallback_PubKeyHash_class, LDKFallback_PubKeyHash_meth, pub_key_hash_arr);
10095                 }
10096                 case LDKFallback_ScriptHash: {
10097                         int8_tArray script_hash_arr = (*env)->NewByteArray(env, 20);
10098                         (*env)->SetByteArrayRegion(env, script_hash_arr, 0, 20, obj->script_hash.data);
10099                         return (*env)->NewObject(env, LDKFallback_ScriptHash_class, LDKFallback_ScriptHash_meth, script_hash_arr);
10100                 }
10101                 default: abort();
10102         }
10103 }
10104 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings__1ldk_1get_1compiled_1version(JNIEnv *env, jclass clz) {
10105         LDKStr ret_str = _ldk_get_compiled_version();
10106         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
10107         Str_free(ret_str);
10108         return ret_conv;
10109 }
10110
10111 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings__1ldk_1c_1bindings_1get_1compiled_1version(JNIEnv *env, jclass clz) {
10112         LDKStr ret_str = _ldk_c_bindings_get_compiled_version();
10113         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
10114         Str_free(ret_str);
10115         return ret_conv;
10116 }
10117
10118 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Transaction_1free(JNIEnv *env, jclass clz, int8_tArray _res) {
10119         LDKTransaction _res_ref;
10120         _res_ref.datalen = (*env)->GetArrayLength(env, _res);
10121         _res_ref.data = MALLOC(_res_ref.datalen, "LDKTransaction Bytes");
10122         (*env)->GetByteArrayRegion(env, _res, 0, _res_ref.datalen, _res_ref.data);
10123         _res_ref.data_is_owned = true;
10124         Transaction_free(_res_ref);
10125 }
10126
10127 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxOut_1new(JNIEnv *env, jclass clz, int8_tArray script_pubkey, int64_t value) {
10128         LDKCVec_u8Z script_pubkey_ref;
10129         script_pubkey_ref.datalen = (*env)->GetArrayLength(env, script_pubkey);
10130         script_pubkey_ref.data = MALLOC(script_pubkey_ref.datalen, "LDKCVec_u8Z Bytes");
10131         (*env)->GetByteArrayRegion(env, script_pubkey, 0, script_pubkey_ref.datalen, script_pubkey_ref.data);
10132         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
10133         *ret_ref = TxOut_new(script_pubkey_ref, value);
10134         return (uint64_t)ret_ref;
10135 }
10136
10137 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxOut_1free(JNIEnv *env, jclass clz, int64_t _res) {
10138         if ((_res & 1) != 0) return;
10139         LDKTxOut _res_conv = *(LDKTxOut*)(((uint64_t)_res) & ~1);
10140         FREE((void*)_res);
10141         TxOut_free(_res_conv);
10142 }
10143
10144 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxOut_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10145         LDKTxOut* orig_conv = (LDKTxOut*)(orig & ~1);
10146         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
10147         *ret_ref = TxOut_clone(orig_conv);
10148         return (uint64_t)ret_ref;
10149 }
10150
10151 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Str_1free(JNIEnv *env, jclass clz, jstring _res) {
10152         LDKStr dummy = { .chars = NULL, .len = 0, .chars_is_owned = false };
10153         Str_free(dummy);
10154 }
10155
10156 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
10157         LDKSecretKey o_ref;
10158         CHECK((*env)->GetArrayLength(env, o) == 32);
10159         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.bytes);
10160         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
10161         *ret_conv = CResult_SecretKeyErrorZ_ok(o_ref);
10162         return (uint64_t)ret_conv;
10163 }
10164
10165 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
10166         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
10167         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
10168         *ret_conv = CResult_SecretKeyErrorZ_err(e_conv);
10169         return (uint64_t)ret_conv;
10170 }
10171
10172 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10173         if ((_res & 1) != 0) return;
10174         LDKCResult_SecretKeyErrorZ _res_conv = *(LDKCResult_SecretKeyErrorZ*)(((uint64_t)_res) & ~1);
10175         FREE((void*)_res);
10176         CResult_SecretKeyErrorZ_free(_res_conv);
10177 }
10178
10179 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
10180         LDKPublicKey o_ref;
10181         CHECK((*env)->GetArrayLength(env, o) == 33);
10182         (*env)->GetByteArrayRegion(env, o, 0, 33, o_ref.compressed_form);
10183         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
10184         *ret_conv = CResult_PublicKeyErrorZ_ok(o_ref);
10185         return (uint64_t)ret_conv;
10186 }
10187
10188 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
10189         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
10190         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
10191         *ret_conv = CResult_PublicKeyErrorZ_err(e_conv);
10192         return (uint64_t)ret_conv;
10193 }
10194
10195 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10196         if ((_res & 1) != 0) return;
10197         LDKCResult_PublicKeyErrorZ _res_conv = *(LDKCResult_PublicKeyErrorZ*)(((uint64_t)_res) & ~1);
10198         FREE((void*)_res);
10199         CResult_PublicKeyErrorZ_free(_res_conv);
10200 }
10201
10202 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10203         LDKCResult_PublicKeyErrorZ* orig_conv = (LDKCResult_PublicKeyErrorZ*)(orig & ~1);
10204         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
10205         *ret_conv = CResult_PublicKeyErrorZ_clone(orig_conv);
10206         return (uint64_t)ret_conv;
10207 }
10208
10209 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10210         LDKTxCreationKeys o_conv;
10211         o_conv.inner = (void*)(o & (~1));
10212         o_conv.is_owned = (o & 1) || (o == 0);
10213         o_conv = TxCreationKeys_clone(&o_conv);
10214         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
10215         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_ok(o_conv);
10216         return (uint64_t)ret_conv;
10217 }
10218
10219 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10220         LDKDecodeError e_conv;
10221         e_conv.inner = (void*)(e & (~1));
10222         e_conv.is_owned = (e & 1) || (e == 0);
10223         e_conv = DecodeError_clone(&e_conv);
10224         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
10225         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_err(e_conv);
10226         return (uint64_t)ret_conv;
10227 }
10228
10229 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10230         if ((_res & 1) != 0) return;
10231         LDKCResult_TxCreationKeysDecodeErrorZ _res_conv = *(LDKCResult_TxCreationKeysDecodeErrorZ*)(((uint64_t)_res) & ~1);
10232         FREE((void*)_res);
10233         CResult_TxCreationKeysDecodeErrorZ_free(_res_conv);
10234 }
10235
10236 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10237         LDKCResult_TxCreationKeysDecodeErrorZ* orig_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(orig & ~1);
10238         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
10239         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(orig_conv);
10240         return (uint64_t)ret_conv;
10241 }
10242
10243 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10244         LDKChannelPublicKeys o_conv;
10245         o_conv.inner = (void*)(o & (~1));
10246         o_conv.is_owned = (o & 1) || (o == 0);
10247         o_conv = ChannelPublicKeys_clone(&o_conv);
10248         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
10249         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_ok(o_conv);
10250         return (uint64_t)ret_conv;
10251 }
10252
10253 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10254         LDKDecodeError e_conv;
10255         e_conv.inner = (void*)(e & (~1));
10256         e_conv.is_owned = (e & 1) || (e == 0);
10257         e_conv = DecodeError_clone(&e_conv);
10258         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
10259         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_err(e_conv);
10260         return (uint64_t)ret_conv;
10261 }
10262
10263 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10264         if ((_res & 1) != 0) return;
10265         LDKCResult_ChannelPublicKeysDecodeErrorZ _res_conv = *(LDKCResult_ChannelPublicKeysDecodeErrorZ*)(((uint64_t)_res) & ~1);
10266         FREE((void*)_res);
10267         CResult_ChannelPublicKeysDecodeErrorZ_free(_res_conv);
10268 }
10269
10270 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10271         LDKCResult_ChannelPublicKeysDecodeErrorZ* orig_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(orig & ~1);
10272         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
10273         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(orig_conv);
10274         return (uint64_t)ret_conv;
10275 }
10276
10277 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10278         LDKTxCreationKeys o_conv;
10279         o_conv.inner = (void*)(o & (~1));
10280         o_conv.is_owned = (o & 1) || (o == 0);
10281         o_conv = TxCreationKeys_clone(&o_conv);
10282         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
10283         *ret_conv = CResult_TxCreationKeysErrorZ_ok(o_conv);
10284         return (uint64_t)ret_conv;
10285 }
10286
10287 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
10288         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
10289         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
10290         *ret_conv = CResult_TxCreationKeysErrorZ_err(e_conv);
10291         return (uint64_t)ret_conv;
10292 }
10293
10294 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10295         if ((_res & 1) != 0) return;
10296         LDKCResult_TxCreationKeysErrorZ _res_conv = *(LDKCResult_TxCreationKeysErrorZ*)(((uint64_t)_res) & ~1);
10297         FREE((void*)_res);
10298         CResult_TxCreationKeysErrorZ_free(_res_conv);
10299 }
10300
10301 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10302         LDKCResult_TxCreationKeysErrorZ* orig_conv = (LDKCResult_TxCreationKeysErrorZ*)(orig & ~1);
10303         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
10304         *ret_conv = CResult_TxCreationKeysErrorZ_clone(orig_conv);
10305         return (uint64_t)ret_conv;
10306 }
10307
10308 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1some(JNIEnv *env, jclass clz, int32_t o) {
10309         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
10310         *ret_copy = COption_u32Z_some(o);
10311         uint64_t ret_ref = (uint64_t)ret_copy;
10312         return ret_ref;
10313 }
10314
10315 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1none(JNIEnv *env, jclass clz) {
10316         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
10317         *ret_copy = COption_u32Z_none();
10318         uint64_t ret_ref = (uint64_t)ret_copy;
10319         return ret_ref;
10320 }
10321
10322 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
10323         if ((_res & 1) != 0) return;
10324         LDKCOption_u32Z _res_conv = *(LDKCOption_u32Z*)(((uint64_t)_res) & ~1);
10325         FREE((void*)_res);
10326         COption_u32Z_free(_res_conv);
10327 }
10328
10329 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10330         LDKCOption_u32Z* orig_conv = (LDKCOption_u32Z*)orig;
10331         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
10332         *ret_copy = COption_u32Z_clone(orig_conv);
10333         uint64_t ret_ref = (uint64_t)ret_copy;
10334         return ret_ref;
10335 }
10336
10337 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10338         LDKHTLCOutputInCommitment o_conv;
10339         o_conv.inner = (void*)(o & (~1));
10340         o_conv.is_owned = (o & 1) || (o == 0);
10341         o_conv = HTLCOutputInCommitment_clone(&o_conv);
10342         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
10343         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(o_conv);
10344         return (uint64_t)ret_conv;
10345 }
10346
10347 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10348         LDKDecodeError e_conv;
10349         e_conv.inner = (void*)(e & (~1));
10350         e_conv.is_owned = (e & 1) || (e == 0);
10351         e_conv = DecodeError_clone(&e_conv);
10352         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
10353         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_err(e_conv);
10354         return (uint64_t)ret_conv;
10355 }
10356
10357 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10358         if ((_res & 1) != 0) return;
10359         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ _res_conv = *(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(((uint64_t)_res) & ~1);
10360         FREE((void*)_res);
10361         CResult_HTLCOutputInCommitmentDecodeErrorZ_free(_res_conv);
10362 }
10363
10364 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10365         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* orig_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(orig & ~1);
10366         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
10367         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(orig_conv);
10368         return (uint64_t)ret_conv;
10369 }
10370
10371 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10372         LDKCounterpartyChannelTransactionParameters o_conv;
10373         o_conv.inner = (void*)(o & (~1));
10374         o_conv.is_owned = (o & 1) || (o == 0);
10375         o_conv = CounterpartyChannelTransactionParameters_clone(&o_conv);
10376         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
10377         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(o_conv);
10378         return (uint64_t)ret_conv;
10379 }
10380
10381 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10382         LDKDecodeError e_conv;
10383         e_conv.inner = (void*)(e & (~1));
10384         e_conv.is_owned = (e & 1) || (e == 0);
10385         e_conv = DecodeError_clone(&e_conv);
10386         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
10387         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(e_conv);
10388         return (uint64_t)ret_conv;
10389 }
10390
10391 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10392         if ((_res & 1) != 0) return;
10393         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(((uint64_t)_res) & ~1);
10394         FREE((void*)_res);
10395         CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(_res_conv);
10396 }
10397
10398 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10399         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
10400         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
10401         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
10402         return (uint64_t)ret_conv;
10403 }
10404
10405 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10406         LDKChannelTransactionParameters o_conv;
10407         o_conv.inner = (void*)(o & (~1));
10408         o_conv.is_owned = (o & 1) || (o == 0);
10409         o_conv = ChannelTransactionParameters_clone(&o_conv);
10410         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
10411         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_ok(o_conv);
10412         return (uint64_t)ret_conv;
10413 }
10414
10415 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10416         LDKDecodeError e_conv;
10417         e_conv.inner = (void*)(e & (~1));
10418         e_conv.is_owned = (e & 1) || (e == 0);
10419         e_conv = DecodeError_clone(&e_conv);
10420         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
10421         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_err(e_conv);
10422         return (uint64_t)ret_conv;
10423 }
10424
10425 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10426         if ((_res & 1) != 0) return;
10427         LDKCResult_ChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(((uint64_t)_res) & ~1);
10428         FREE((void*)_res);
10429         CResult_ChannelTransactionParametersDecodeErrorZ_free(_res_conv);
10430 }
10431
10432 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10433         LDKCResult_ChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
10434         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
10435         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
10436         return (uint64_t)ret_conv;
10437 }
10438
10439 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1SignatureZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
10440         LDKCVec_SignatureZ _res_constr;
10441         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
10442         if (_res_constr.datalen > 0)
10443                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
10444         else
10445                 _res_constr.data = NULL;
10446         for (size_t i = 0; i < _res_constr.datalen; i++) {
10447                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
10448                 LDKSignature _res_conv_8_ref;
10449                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 64);
10450                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 64, _res_conv_8_ref.compact_form);
10451                 _res_constr.data[i] = _res_conv_8_ref;
10452         }
10453         CVec_SignatureZ_free(_res_constr);
10454 }
10455
10456 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10457         LDKHolderCommitmentTransaction o_conv;
10458         o_conv.inner = (void*)(o & (~1));
10459         o_conv.is_owned = (o & 1) || (o == 0);
10460         o_conv = HolderCommitmentTransaction_clone(&o_conv);
10461         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
10462         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_ok(o_conv);
10463         return (uint64_t)ret_conv;
10464 }
10465
10466 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10467         LDKDecodeError e_conv;
10468         e_conv.inner = (void*)(e & (~1));
10469         e_conv.is_owned = (e & 1) || (e == 0);
10470         e_conv = DecodeError_clone(&e_conv);
10471         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
10472         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_err(e_conv);
10473         return (uint64_t)ret_conv;
10474 }
10475
10476 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10477         if ((_res & 1) != 0) return;
10478         LDKCResult_HolderCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(((uint64_t)_res) & ~1);
10479         FREE((void*)_res);
10480         CResult_HolderCommitmentTransactionDecodeErrorZ_free(_res_conv);
10481 }
10482
10483 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10484         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(orig & ~1);
10485         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
10486         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(orig_conv);
10487         return (uint64_t)ret_conv;
10488 }
10489
10490 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10491         LDKBuiltCommitmentTransaction o_conv;
10492         o_conv.inner = (void*)(o & (~1));
10493         o_conv.is_owned = (o & 1) || (o == 0);
10494         o_conv = BuiltCommitmentTransaction_clone(&o_conv);
10495         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
10496         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(o_conv);
10497         return (uint64_t)ret_conv;
10498 }
10499
10500 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10501         LDKDecodeError e_conv;
10502         e_conv.inner = (void*)(e & (~1));
10503         e_conv.is_owned = (e & 1) || (e == 0);
10504         e_conv = DecodeError_clone(&e_conv);
10505         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
10506         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_err(e_conv);
10507         return (uint64_t)ret_conv;
10508 }
10509
10510 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10511         if ((_res & 1) != 0) return;
10512         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(((uint64_t)_res) & ~1);
10513         FREE((void*)_res);
10514         CResult_BuiltCommitmentTransactionDecodeErrorZ_free(_res_conv);
10515 }
10516
10517 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10518         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(orig & ~1);
10519         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
10520         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(orig_conv);
10521         return (uint64_t)ret_conv;
10522 }
10523
10524 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10525         LDKTrustedClosingTransaction o_conv;
10526         o_conv.inner = (void*)(o & (~1));
10527         o_conv.is_owned = (o & 1) || (o == 0);
10528         // Warning: we need a move here but no clone is available for LDKTrustedClosingTransaction
10529         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
10530         *ret_conv = CResult_TrustedClosingTransactionNoneZ_ok(o_conv);
10531         return (uint64_t)ret_conv;
10532 }
10533
10534 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1err(JNIEnv *env, jclass clz) {
10535         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
10536         *ret_conv = CResult_TrustedClosingTransactionNoneZ_err();
10537         return (uint64_t)ret_conv;
10538 }
10539
10540 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10541         if ((_res & 1) != 0) return;
10542         LDKCResult_TrustedClosingTransactionNoneZ _res_conv = *(LDKCResult_TrustedClosingTransactionNoneZ*)(((uint64_t)_res) & ~1);
10543         FREE((void*)_res);
10544         CResult_TrustedClosingTransactionNoneZ_free(_res_conv);
10545 }
10546
10547 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10548         LDKCommitmentTransaction o_conv;
10549         o_conv.inner = (void*)(o & (~1));
10550         o_conv.is_owned = (o & 1) || (o == 0);
10551         o_conv = CommitmentTransaction_clone(&o_conv);
10552         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
10553         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_ok(o_conv);
10554         return (uint64_t)ret_conv;
10555 }
10556
10557 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10558         LDKDecodeError e_conv;
10559         e_conv.inner = (void*)(e & (~1));
10560         e_conv.is_owned = (e & 1) || (e == 0);
10561         e_conv = DecodeError_clone(&e_conv);
10562         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
10563         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_err(e_conv);
10564         return (uint64_t)ret_conv;
10565 }
10566
10567 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10568         if ((_res & 1) != 0) return;
10569         LDKCResult_CommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_CommitmentTransactionDecodeErrorZ*)(((uint64_t)_res) & ~1);
10570         FREE((void*)_res);
10571         CResult_CommitmentTransactionDecodeErrorZ_free(_res_conv);
10572 }
10573
10574 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10575         LDKCResult_CommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(orig & ~1);
10576         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
10577         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(orig_conv);
10578         return (uint64_t)ret_conv;
10579 }
10580
10581 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10582         LDKTrustedCommitmentTransaction o_conv;
10583         o_conv.inner = (void*)(o & (~1));
10584         o_conv.is_owned = (o & 1) || (o == 0);
10585         // Warning: we need a move here but no clone is available for LDKTrustedCommitmentTransaction
10586         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
10587         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_ok(o_conv);
10588         return (uint64_t)ret_conv;
10589 }
10590
10591 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1err(JNIEnv *env, jclass clz) {
10592         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
10593         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_err();
10594         return (uint64_t)ret_conv;
10595 }
10596
10597 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10598         if ((_res & 1) != 0) return;
10599         LDKCResult_TrustedCommitmentTransactionNoneZ _res_conv = *(LDKCResult_TrustedCommitmentTransactionNoneZ*)(((uint64_t)_res) & ~1);
10600         FREE((void*)_res);
10601         CResult_TrustedCommitmentTransactionNoneZ_free(_res_conv);
10602 }
10603
10604 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1ok(JNIEnv *env, jclass clz, jobjectArray o) {
10605         LDKCVec_SignatureZ o_constr;
10606         o_constr.datalen = (*env)->GetArrayLength(env, o);
10607         if (o_constr.datalen > 0)
10608                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
10609         else
10610                 o_constr.data = NULL;
10611         for (size_t i = 0; i < o_constr.datalen; i++) {
10612                 int8_tArray o_conv_8 = (*env)->GetObjectArrayElement(env, o, i);
10613                 LDKSignature o_conv_8_ref;
10614                 CHECK((*env)->GetArrayLength(env, o_conv_8) == 64);
10615                 (*env)->GetByteArrayRegion(env, o_conv_8, 0, 64, o_conv_8_ref.compact_form);
10616                 o_constr.data[i] = o_conv_8_ref;
10617         }
10618         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
10619         *ret_conv = CResult_CVec_SignatureZNoneZ_ok(o_constr);
10620         return (uint64_t)ret_conv;
10621 }
10622
10623 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1err(JNIEnv *env, jclass clz) {
10624         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
10625         *ret_conv = CResult_CVec_SignatureZNoneZ_err();
10626         return (uint64_t)ret_conv;
10627 }
10628
10629 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10630         if ((_res & 1) != 0) return;
10631         LDKCResult_CVec_SignatureZNoneZ _res_conv = *(LDKCResult_CVec_SignatureZNoneZ*)(((uint64_t)_res) & ~1);
10632         FREE((void*)_res);
10633         CResult_CVec_SignatureZNoneZ_free(_res_conv);
10634 }
10635
10636 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10637         LDKCResult_CVec_SignatureZNoneZ* orig_conv = (LDKCResult_CVec_SignatureZNoneZ*)(orig & ~1);
10638         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
10639         *ret_conv = CResult_CVec_SignatureZNoneZ_clone(orig_conv);
10640         return (uint64_t)ret_conv;
10641 }
10642
10643 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10644         LDKShutdownScript o_conv;
10645         o_conv.inner = (void*)(o & (~1));
10646         o_conv.is_owned = (o & 1) || (o == 0);
10647         o_conv = ShutdownScript_clone(&o_conv);
10648         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
10649         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_ok(o_conv);
10650         return (uint64_t)ret_conv;
10651 }
10652
10653 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10654         LDKDecodeError e_conv;
10655         e_conv.inner = (void*)(e & (~1));
10656         e_conv.is_owned = (e & 1) || (e == 0);
10657         e_conv = DecodeError_clone(&e_conv);
10658         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
10659         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_err(e_conv);
10660         return (uint64_t)ret_conv;
10661 }
10662
10663 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10664         if ((_res & 1) != 0) return;
10665         LDKCResult_ShutdownScriptDecodeErrorZ _res_conv = *(LDKCResult_ShutdownScriptDecodeErrorZ*)(((uint64_t)_res) & ~1);
10666         FREE((void*)_res);
10667         CResult_ShutdownScriptDecodeErrorZ_free(_res_conv);
10668 }
10669
10670 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10671         LDKCResult_ShutdownScriptDecodeErrorZ* orig_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(orig & ~1);
10672         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
10673         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone(orig_conv);
10674         return (uint64_t)ret_conv;
10675 }
10676
10677 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10678         LDKShutdownScript o_conv;
10679         o_conv.inner = (void*)(o & (~1));
10680         o_conv.is_owned = (o & 1) || (o == 0);
10681         o_conv = ShutdownScript_clone(&o_conv);
10682         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
10683         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_ok(o_conv);
10684         return (uint64_t)ret_conv;
10685 }
10686
10687 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10688         LDKInvalidShutdownScript e_conv;
10689         e_conv.inner = (void*)(e & (~1));
10690         e_conv.is_owned = (e & 1) || (e == 0);
10691         // Warning: we need a move here but no clone is available for LDKInvalidShutdownScript
10692         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
10693         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_err(e_conv);
10694         return (uint64_t)ret_conv;
10695 }
10696
10697 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10698         if ((_res & 1) != 0) return;
10699         LDKCResult_ShutdownScriptInvalidShutdownScriptZ _res_conv = *(LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(((uint64_t)_res) & ~1);
10700         FREE((void*)_res);
10701         CResult_ShutdownScriptInvalidShutdownScriptZ_free(_res_conv);
10702 }
10703
10704 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1ok(JNIEnv *env, jclass clz) {
10705         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
10706         *ret_conv = CResult_NoneErrorZ_ok();
10707         return (uint64_t)ret_conv;
10708 }
10709
10710 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
10711         LDKIOError e_conv = LDKIOError_from_java(env, e);
10712         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
10713         *ret_conv = CResult_NoneErrorZ_err(e_conv);
10714         return (uint64_t)ret_conv;
10715 }
10716
10717 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10718         if ((_res & 1) != 0) return;
10719         LDKCResult_NoneErrorZ _res_conv = *(LDKCResult_NoneErrorZ*)(((uint64_t)_res) & ~1);
10720         FREE((void*)_res);
10721         CResult_NoneErrorZ_free(_res_conv);
10722 }
10723
10724 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10725         LDKCResult_NoneErrorZ* orig_conv = (LDKCResult_NoneErrorZ*)(orig & ~1);
10726         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
10727         *ret_conv = CResult_NoneErrorZ_clone(orig_conv);
10728         return (uint64_t)ret_conv;
10729 }
10730
10731 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10732         LDKRouteHop o_conv;
10733         o_conv.inner = (void*)(o & (~1));
10734         o_conv.is_owned = (o & 1) || (o == 0);
10735         o_conv = RouteHop_clone(&o_conv);
10736         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
10737         *ret_conv = CResult_RouteHopDecodeErrorZ_ok(o_conv);
10738         return (uint64_t)ret_conv;
10739 }
10740
10741 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10742         LDKDecodeError e_conv;
10743         e_conv.inner = (void*)(e & (~1));
10744         e_conv.is_owned = (e & 1) || (e == 0);
10745         e_conv = DecodeError_clone(&e_conv);
10746         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
10747         *ret_conv = CResult_RouteHopDecodeErrorZ_err(e_conv);
10748         return (uint64_t)ret_conv;
10749 }
10750
10751 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10752         if ((_res & 1) != 0) return;
10753         LDKCResult_RouteHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHopDecodeErrorZ*)(((uint64_t)_res) & ~1);
10754         FREE((void*)_res);
10755         CResult_RouteHopDecodeErrorZ_free(_res_conv);
10756 }
10757
10758 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10759         LDKCResult_RouteHopDecodeErrorZ* orig_conv = (LDKCResult_RouteHopDecodeErrorZ*)(orig & ~1);
10760         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
10761         *ret_conv = CResult_RouteHopDecodeErrorZ_clone(orig_conv);
10762         return (uint64_t)ret_conv;
10763 }
10764
10765 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHopZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
10766         LDKCVec_RouteHopZ _res_constr;
10767         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
10768         if (_res_constr.datalen > 0)
10769                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
10770         else
10771                 _res_constr.data = NULL;
10772         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
10773         for (size_t k = 0; k < _res_constr.datalen; k++) {
10774                 int64_t _res_conv_10 = _res_vals[k];
10775                 LDKRouteHop _res_conv_10_conv;
10776                 _res_conv_10_conv.inner = (void*)(_res_conv_10 & (~1));
10777                 _res_conv_10_conv.is_owned = (_res_conv_10 & 1) || (_res_conv_10 == 0);
10778                 _res_constr.data[k] = _res_conv_10_conv;
10779         }
10780         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
10781         CVec_RouteHopZ_free(_res_constr);
10782 }
10783
10784 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CVec_1RouteHopZZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
10785         LDKCVec_CVec_RouteHopZZ _res_constr;
10786         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
10787         if (_res_constr.datalen > 0)
10788                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
10789         else
10790                 _res_constr.data = NULL;
10791         for (size_t m = 0; m < _res_constr.datalen; m++) {
10792                 int64_tArray _res_conv_12 = (*env)->GetObjectArrayElement(env, _res, m);
10793                 LDKCVec_RouteHopZ _res_conv_12_constr;
10794                 _res_conv_12_constr.datalen = (*env)->GetArrayLength(env, _res_conv_12);
10795                 if (_res_conv_12_constr.datalen > 0)
10796                         _res_conv_12_constr.data = MALLOC(_res_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
10797                 else
10798                         _res_conv_12_constr.data = NULL;
10799                 int64_t* _res_conv_12_vals = (*env)->GetLongArrayElements (env, _res_conv_12, NULL);
10800                 for (size_t k = 0; k < _res_conv_12_constr.datalen; k++) {
10801                         int64_t _res_conv_12_conv_10 = _res_conv_12_vals[k];
10802                         LDKRouteHop _res_conv_12_conv_10_conv;
10803                         _res_conv_12_conv_10_conv.inner = (void*)(_res_conv_12_conv_10 & (~1));
10804                         _res_conv_12_conv_10_conv.is_owned = (_res_conv_12_conv_10 & 1) || (_res_conv_12_conv_10 == 0);
10805                         _res_conv_12_constr.data[k] = _res_conv_12_conv_10_conv;
10806                 }
10807                 (*env)->ReleaseLongArrayElements(env, _res_conv_12, _res_conv_12_vals, 0);
10808                 _res_constr.data[m] = _res_conv_12_constr;
10809         }
10810         CVec_CVec_RouteHopZZ_free(_res_constr);
10811 }
10812
10813 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10814         LDKRoute o_conv;
10815         o_conv.inner = (void*)(o & (~1));
10816         o_conv.is_owned = (o & 1) || (o == 0);
10817         o_conv = Route_clone(&o_conv);
10818         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
10819         *ret_conv = CResult_RouteDecodeErrorZ_ok(o_conv);
10820         return (uint64_t)ret_conv;
10821 }
10822
10823 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10824         LDKDecodeError e_conv;
10825         e_conv.inner = (void*)(e & (~1));
10826         e_conv.is_owned = (e & 1) || (e == 0);
10827         e_conv = DecodeError_clone(&e_conv);
10828         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
10829         *ret_conv = CResult_RouteDecodeErrorZ_err(e_conv);
10830         return (uint64_t)ret_conv;
10831 }
10832
10833 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10834         if ((_res & 1) != 0) return;
10835         LDKCResult_RouteDecodeErrorZ _res_conv = *(LDKCResult_RouteDecodeErrorZ*)(((uint64_t)_res) & ~1);
10836         FREE((void*)_res);
10837         CResult_RouteDecodeErrorZ_free(_res_conv);
10838 }
10839
10840 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10841         LDKCResult_RouteDecodeErrorZ* orig_conv = (LDKCResult_RouteDecodeErrorZ*)(orig & ~1);
10842         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
10843         *ret_conv = CResult_RouteDecodeErrorZ_clone(orig_conv);
10844         return (uint64_t)ret_conv;
10845 }
10846
10847 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1some(JNIEnv *env, jclass clz, int64_t o) {
10848         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
10849         *ret_copy = COption_u64Z_some(o);
10850         uint64_t ret_ref = (uint64_t)ret_copy;
10851         return ret_ref;
10852 }
10853
10854 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1none(JNIEnv *env, jclass clz) {
10855         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
10856         *ret_copy = COption_u64Z_none();
10857         uint64_t ret_ref = (uint64_t)ret_copy;
10858         return ret_ref;
10859 }
10860
10861 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
10862         if ((_res & 1) != 0) return;
10863         LDKCOption_u64Z _res_conv = *(LDKCOption_u64Z*)(((uint64_t)_res) & ~1);
10864         FREE((void*)_res);
10865         COption_u64Z_free(_res_conv);
10866 }
10867
10868 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10869         LDKCOption_u64Z* orig_conv = (LDKCOption_u64Z*)orig;
10870         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
10871         *ret_copy = COption_u64Z_clone(orig_conv);
10872         uint64_t ret_ref = (uint64_t)ret_copy;
10873         return ret_ref;
10874 }
10875
10876 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ChannelDetailsZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
10877         LDKCVec_ChannelDetailsZ _res_constr;
10878         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
10879         if (_res_constr.datalen > 0)
10880                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
10881         else
10882                 _res_constr.data = NULL;
10883         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
10884         for (size_t q = 0; q < _res_constr.datalen; q++) {
10885                 int64_t _res_conv_16 = _res_vals[q];
10886                 LDKChannelDetails _res_conv_16_conv;
10887                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
10888                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
10889                 _res_constr.data[q] = _res_conv_16_conv;
10890         }
10891         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
10892         CVec_ChannelDetailsZ_free(_res_constr);
10893 }
10894
10895 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHintZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
10896         LDKCVec_RouteHintZ _res_constr;
10897         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
10898         if (_res_constr.datalen > 0)
10899                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
10900         else
10901                 _res_constr.data = NULL;
10902         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
10903         for (size_t l = 0; l < _res_constr.datalen; l++) {
10904                 int64_t _res_conv_11 = _res_vals[l];
10905                 LDKRouteHint _res_conv_11_conv;
10906                 _res_conv_11_conv.inner = (void*)(_res_conv_11 & (~1));
10907                 _res_conv_11_conv.is_owned = (_res_conv_11 & 1) || (_res_conv_11 == 0);
10908                 _res_constr.data[l] = _res_conv_11_conv;
10909         }
10910         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
10911         CVec_RouteHintZ_free(_res_constr);
10912 }
10913
10914 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10915         LDKRoute o_conv;
10916         o_conv.inner = (void*)(o & (~1));
10917         o_conv.is_owned = (o & 1) || (o == 0);
10918         o_conv = Route_clone(&o_conv);
10919         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
10920         *ret_conv = CResult_RouteLightningErrorZ_ok(o_conv);
10921         return (uint64_t)ret_conv;
10922 }
10923
10924 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10925         LDKLightningError e_conv;
10926         e_conv.inner = (void*)(e & (~1));
10927         e_conv.is_owned = (e & 1) || (e == 0);
10928         e_conv = LightningError_clone(&e_conv);
10929         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
10930         *ret_conv = CResult_RouteLightningErrorZ_err(e_conv);
10931         return (uint64_t)ret_conv;
10932 }
10933
10934 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10935         if ((_res & 1) != 0) return;
10936         LDKCResult_RouteLightningErrorZ _res_conv = *(LDKCResult_RouteLightningErrorZ*)(((uint64_t)_res) & ~1);
10937         FREE((void*)_res);
10938         CResult_RouteLightningErrorZ_free(_res_conv);
10939 }
10940
10941 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10942         LDKCResult_RouteLightningErrorZ* orig_conv = (LDKCResult_RouteLightningErrorZ*)(orig & ~1);
10943         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
10944         *ret_conv = CResult_RouteLightningErrorZ_clone(orig_conv);
10945         return (uint64_t)ret_conv;
10946 }
10947
10948 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10949         LDKTxOut o_conv = *(LDKTxOut*)(((uint64_t)o) & ~1);
10950         o_conv = TxOut_clone((LDKTxOut*)(((uint64_t)o) & ~1));
10951         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
10952         *ret_conv = CResult_TxOutAccessErrorZ_ok(o_conv);
10953         return (uint64_t)ret_conv;
10954 }
10955
10956 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
10957         LDKAccessError e_conv = LDKAccessError_from_java(env, e);
10958         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
10959         *ret_conv = CResult_TxOutAccessErrorZ_err(e_conv);
10960         return (uint64_t)ret_conv;
10961 }
10962
10963 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10964         if ((_res & 1) != 0) return;
10965         LDKCResult_TxOutAccessErrorZ _res_conv = *(LDKCResult_TxOutAccessErrorZ*)(((uint64_t)_res) & ~1);
10966         FREE((void*)_res);
10967         CResult_TxOutAccessErrorZ_free(_res_conv);
10968 }
10969
10970 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10971         LDKCResult_TxOutAccessErrorZ* orig_conv = (LDKCResult_TxOutAccessErrorZ*)(orig & ~1);
10972         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
10973         *ret_conv = CResult_TxOutAccessErrorZ_clone(orig_conv);
10974         return (uint64_t)ret_conv;
10975 }
10976
10977 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10978         LDKC2Tuple_usizeTransactionZ* orig_conv = (LDKC2Tuple_usizeTransactionZ*)(orig & ~1);
10979         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
10980         *ret_conv = C2Tuple_usizeTransactionZ_clone(orig_conv);
10981         return ((uint64_t)ret_conv);
10982 }
10983
10984 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
10985         LDKTransaction b_ref;
10986         b_ref.datalen = (*env)->GetArrayLength(env, b);
10987         b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
10988         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
10989         b_ref.data_is_owned = true;
10990         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
10991         *ret_conv = C2Tuple_usizeTransactionZ_new(a, b_ref);
10992         return ((uint64_t)ret_conv);
10993 }
10994
10995 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10996         if ((_res & 1) != 0) return;
10997         LDKC2Tuple_usizeTransactionZ _res_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)_res) & ~1);
10998         FREE((void*)_res);
10999         C2Tuple_usizeTransactionZ_free(_res_conv);
11000 }
11001
11002 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1usizeTransactionZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
11003         LDKCVec_C2Tuple_usizeTransactionZZ _res_constr;
11004         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11005         if (_res_constr.datalen > 0)
11006                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
11007         else
11008                 _res_constr.data = NULL;
11009         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
11010         for (size_t c = 0; c < _res_constr.datalen; c++) {
11011                 int64_t _res_conv_28 = _res_vals[c];
11012                 LDKC2Tuple_usizeTransactionZ _res_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)_res_conv_28) & ~1);
11013                 FREE((void*)_res_conv_28);
11014                 _res_constr.data[c] = _res_conv_28_conv;
11015         }
11016         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
11017         CVec_C2Tuple_usizeTransactionZZ_free(_res_constr);
11018 }
11019
11020 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TxidZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
11021         LDKCVec_TxidZ _res_constr;
11022         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11023         if (_res_constr.datalen > 0)
11024                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
11025         else
11026                 _res_constr.data = NULL;
11027         for (size_t i = 0; i < _res_constr.datalen; i++) {
11028                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
11029                 LDKThirtyTwoBytes _res_conv_8_ref;
11030                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 32);
11031                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 32, _res_conv_8_ref.data);
11032                 _res_constr.data[i] = _res_conv_8_ref;
11033         }
11034         CVec_TxidZ_free(_res_constr);
11035 }
11036
11037 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1ok(JNIEnv *env, jclass clz) {
11038         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
11039         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_ok();
11040         return (uint64_t)ret_conv;
11041 }
11042
11043 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1err(JNIEnv *env, jclass clz, jclass e) {
11044         LDKChannelMonitorUpdateErr e_conv = LDKChannelMonitorUpdateErr_from_java(env, e);
11045         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
11046         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_err(e_conv);
11047         return (uint64_t)ret_conv;
11048 }
11049
11050 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11051         if ((_res & 1) != 0) return;
11052         LDKCResult_NoneChannelMonitorUpdateErrZ _res_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)_res) & ~1);
11053         FREE((void*)_res);
11054         CResult_NoneChannelMonitorUpdateErrZ_free(_res_conv);
11055 }
11056
11057 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11058         LDKCResult_NoneChannelMonitorUpdateErrZ* orig_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(orig & ~1);
11059         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
11060         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone(orig_conv);
11061         return (uint64_t)ret_conv;
11062 }
11063
11064 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1MonitorEventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
11065         LDKCVec_MonitorEventZ _res_constr;
11066         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11067         if (_res_constr.datalen > 0)
11068                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
11069         else
11070                 _res_constr.data = NULL;
11071         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
11072         for (size_t o = 0; o < _res_constr.datalen; o++) {
11073                 int64_t _res_conv_14 = _res_vals[o];
11074                 LDKMonitorEvent _res_conv_14_conv = *(LDKMonitorEvent*)(((uint64_t)_res_conv_14) & ~1);
11075                 FREE((void*)_res_conv_14);
11076                 _res_constr.data[o] = _res_conv_14_conv;
11077         }
11078         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
11079         CVec_MonitorEventZ_free(_res_constr);
11080 }
11081
11082 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1some(JNIEnv *env, jclass clz, int64_t o) {
11083         LDKC2Tuple_usizeTransactionZ o_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)o) & ~1);
11084         o_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)o) & ~1));
11085         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
11086         *ret_copy = COption_C2Tuple_usizeTransactionZZ_some(o_conv);
11087         uint64_t ret_ref = (uint64_t)ret_copy;
11088         return ret_ref;
11089 }
11090
11091 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1none(JNIEnv *env, jclass clz) {
11092         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
11093         *ret_copy = COption_C2Tuple_usizeTransactionZZ_none();
11094         uint64_t ret_ref = (uint64_t)ret_copy;
11095         return ret_ref;
11096 }
11097
11098 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11099         if ((_res & 1) != 0) return;
11100         LDKCOption_C2Tuple_usizeTransactionZZ _res_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(((uint64_t)_res) & ~1);
11101         FREE((void*)_res);
11102         COption_C2Tuple_usizeTransactionZZ_free(_res_conv);
11103 }
11104
11105 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11106         LDKCOption_C2Tuple_usizeTransactionZZ* orig_conv = (LDKCOption_C2Tuple_usizeTransactionZZ*)orig;
11107         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
11108         *ret_copy = COption_C2Tuple_usizeTransactionZZ_clone(orig_conv);
11109         uint64_t ret_ref = (uint64_t)ret_copy;
11110         return ret_ref;
11111 }
11112
11113 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1some(JNIEnv *env, jclass clz, int64_t o) {
11114         LDKNetworkUpdate o_conv = *(LDKNetworkUpdate*)(((uint64_t)o) & ~1);
11115         o_conv = NetworkUpdate_clone((LDKNetworkUpdate*)(((uint64_t)o) & ~1));
11116         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
11117         *ret_copy = COption_NetworkUpdateZ_some(o_conv);
11118         uint64_t ret_ref = (uint64_t)ret_copy;
11119         return ret_ref;
11120 }
11121
11122 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1none(JNIEnv *env, jclass clz) {
11123         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
11124         *ret_copy = COption_NetworkUpdateZ_none();
11125         uint64_t ret_ref = (uint64_t)ret_copy;
11126         return ret_ref;
11127 }
11128
11129 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11130         if ((_res & 1) != 0) return;
11131         LDKCOption_NetworkUpdateZ _res_conv = *(LDKCOption_NetworkUpdateZ*)(((uint64_t)_res) & ~1);
11132         FREE((void*)_res);
11133         COption_NetworkUpdateZ_free(_res_conv);
11134 }
11135
11136 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11137         LDKCOption_NetworkUpdateZ* orig_conv = (LDKCOption_NetworkUpdateZ*)orig;
11138         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
11139         *ret_copy = COption_NetworkUpdateZ_clone(orig_conv);
11140         uint64_t ret_ref = (uint64_t)ret_copy;
11141         return ret_ref;
11142 }
11143
11144 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1SpendableOutputDescriptorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
11145         LDKCVec_SpendableOutputDescriptorZ _res_constr;
11146         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11147         if (_res_constr.datalen > 0)
11148                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
11149         else
11150                 _res_constr.data = NULL;
11151         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
11152         for (size_t b = 0; b < _res_constr.datalen; b++) {
11153                 int64_t _res_conv_27 = _res_vals[b];
11154                 LDKSpendableOutputDescriptor _res_conv_27_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)_res_conv_27) & ~1);
11155                 FREE((void*)_res_conv_27);
11156                 _res_constr.data[b] = _res_conv_27_conv;
11157         }
11158         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
11159         CVec_SpendableOutputDescriptorZ_free(_res_constr);
11160 }
11161
11162 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1MessageSendEventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
11163         LDKCVec_MessageSendEventZ _res_constr;
11164         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11165         if (_res_constr.datalen > 0)
11166                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
11167         else
11168                 _res_constr.data = NULL;
11169         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
11170         for (size_t s = 0; s < _res_constr.datalen; s++) {
11171                 int64_t _res_conv_18 = _res_vals[s];
11172                 LDKMessageSendEvent _res_conv_18_conv = *(LDKMessageSendEvent*)(((uint64_t)_res_conv_18) & ~1);
11173                 FREE((void*)_res_conv_18);
11174                 _res_constr.data[s] = _res_conv_18_conv;
11175         }
11176         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
11177         CVec_MessageSendEventZ_free(_res_constr);
11178 }
11179
11180 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11181         LDKInitFeatures o_conv;
11182         o_conv.inner = (void*)(o & (~1));
11183         o_conv.is_owned = (o & 1) || (o == 0);
11184         o_conv = InitFeatures_clone(&o_conv);
11185         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
11186         *ret_conv = CResult_InitFeaturesDecodeErrorZ_ok(o_conv);
11187         return (uint64_t)ret_conv;
11188 }
11189
11190 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11191         LDKDecodeError e_conv;
11192         e_conv.inner = (void*)(e & (~1));
11193         e_conv.is_owned = (e & 1) || (e == 0);
11194         e_conv = DecodeError_clone(&e_conv);
11195         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
11196         *ret_conv = CResult_InitFeaturesDecodeErrorZ_err(e_conv);
11197         return (uint64_t)ret_conv;
11198 }
11199
11200 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11201         if ((_res & 1) != 0) return;
11202         LDKCResult_InitFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InitFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
11203         FREE((void*)_res);
11204         CResult_InitFeaturesDecodeErrorZ_free(_res_conv);
11205 }
11206
11207 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11208         LDKNodeFeatures o_conv;
11209         o_conv.inner = (void*)(o & (~1));
11210         o_conv.is_owned = (o & 1) || (o == 0);
11211         o_conv = NodeFeatures_clone(&o_conv);
11212         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
11213         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_ok(o_conv);
11214         return (uint64_t)ret_conv;
11215 }
11216
11217 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11218         LDKDecodeError e_conv;
11219         e_conv.inner = (void*)(e & (~1));
11220         e_conv.is_owned = (e & 1) || (e == 0);
11221         e_conv = DecodeError_clone(&e_conv);
11222         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
11223         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_err(e_conv);
11224         return (uint64_t)ret_conv;
11225 }
11226
11227 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11228         if ((_res & 1) != 0) return;
11229         LDKCResult_NodeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_NodeFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
11230         FREE((void*)_res);
11231         CResult_NodeFeaturesDecodeErrorZ_free(_res_conv);
11232 }
11233
11234 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11235         LDKChannelFeatures o_conv;
11236         o_conv.inner = (void*)(o & (~1));
11237         o_conv.is_owned = (o & 1) || (o == 0);
11238         o_conv = ChannelFeatures_clone(&o_conv);
11239         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
11240         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_ok(o_conv);
11241         return (uint64_t)ret_conv;
11242 }
11243
11244 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11245         LDKDecodeError e_conv;
11246         e_conv.inner = (void*)(e & (~1));
11247         e_conv.is_owned = (e & 1) || (e == 0);
11248         e_conv = DecodeError_clone(&e_conv);
11249         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
11250         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_err(e_conv);
11251         return (uint64_t)ret_conv;
11252 }
11253
11254 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11255         if ((_res & 1) != 0) return;
11256         LDKCResult_ChannelFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
11257         FREE((void*)_res);
11258         CResult_ChannelFeaturesDecodeErrorZ_free(_res_conv);
11259 }
11260
11261 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11262         LDKInvoiceFeatures o_conv;
11263         o_conv.inner = (void*)(o & (~1));
11264         o_conv.is_owned = (o & 1) || (o == 0);
11265         o_conv = InvoiceFeatures_clone(&o_conv);
11266         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
11267         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_ok(o_conv);
11268         return (uint64_t)ret_conv;
11269 }
11270
11271 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11272         LDKDecodeError e_conv;
11273         e_conv.inner = (void*)(e & (~1));
11274         e_conv.is_owned = (e & 1) || (e == 0);
11275         e_conv = DecodeError_clone(&e_conv);
11276         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
11277         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_err(e_conv);
11278         return (uint64_t)ret_conv;
11279 }
11280
11281 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11282         if ((_res & 1) != 0) return;
11283         LDKCResult_InvoiceFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InvoiceFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
11284         FREE((void*)_res);
11285         CResult_InvoiceFeaturesDecodeErrorZ_free(_res_conv);
11286 }
11287
11288 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11289         LDKDelayedPaymentOutputDescriptor o_conv;
11290         o_conv.inner = (void*)(o & (~1));
11291         o_conv.is_owned = (o & 1) || (o == 0);
11292         o_conv = DelayedPaymentOutputDescriptor_clone(&o_conv);
11293         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
11294         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
11295         return (uint64_t)ret_conv;
11296 }
11297
11298 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11299         LDKDecodeError e_conv;
11300         e_conv.inner = (void*)(e & (~1));
11301         e_conv.is_owned = (e & 1) || (e == 0);
11302         e_conv = DecodeError_clone(&e_conv);
11303         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
11304         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
11305         return (uint64_t)ret_conv;
11306 }
11307
11308 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11309         if ((_res & 1) != 0) return;
11310         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(((uint64_t)_res) & ~1);
11311         FREE((void*)_res);
11312         CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
11313 }
11314
11315 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11316         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(orig & ~1);
11317         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
11318         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
11319         return (uint64_t)ret_conv;
11320 }
11321
11322 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11323         LDKStaticPaymentOutputDescriptor o_conv;
11324         o_conv.inner = (void*)(o & (~1));
11325         o_conv.is_owned = (o & 1) || (o == 0);
11326         o_conv = StaticPaymentOutputDescriptor_clone(&o_conv);
11327         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
11328         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
11329         return (uint64_t)ret_conv;
11330 }
11331
11332 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11333         LDKDecodeError e_conv;
11334         e_conv.inner = (void*)(e & (~1));
11335         e_conv.is_owned = (e & 1) || (e == 0);
11336         e_conv = DecodeError_clone(&e_conv);
11337         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
11338         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
11339         return (uint64_t)ret_conv;
11340 }
11341
11342 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11343         if ((_res & 1) != 0) return;
11344         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(((uint64_t)_res) & ~1);
11345         FREE((void*)_res);
11346         CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
11347 }
11348
11349 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11350         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(orig & ~1);
11351         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
11352         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
11353         return (uint64_t)ret_conv;
11354 }
11355
11356 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11357         LDKSpendableOutputDescriptor o_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)o) & ~1);
11358         o_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uint64_t)o) & ~1));
11359         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
11360         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_ok(o_conv);
11361         return (uint64_t)ret_conv;
11362 }
11363
11364 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11365         LDKDecodeError e_conv;
11366         e_conv.inner = (void*)(e & (~1));
11367         e_conv.is_owned = (e & 1) || (e == 0);
11368         e_conv = DecodeError_clone(&e_conv);
11369         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
11370         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_err(e_conv);
11371         return (uint64_t)ret_conv;
11372 }
11373
11374 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11375         if ((_res & 1) != 0) return;
11376         LDKCResult_SpendableOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(((uint64_t)_res) & ~1);
11377         FREE((void*)_res);
11378         CResult_SpendableOutputDescriptorDecodeErrorZ_free(_res_conv);
11379 }
11380
11381 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11382         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(orig & ~1);
11383         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
11384         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(orig_conv);
11385         return (uint64_t)ret_conv;
11386 }
11387
11388 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1ok(JNIEnv *env, jclass clz) {
11389         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
11390         *ret_conv = CResult_NoneNoneZ_ok();
11391         return (uint64_t)ret_conv;
11392 }
11393
11394 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1err(JNIEnv *env, jclass clz) {
11395         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
11396         *ret_conv = CResult_NoneNoneZ_err();
11397         return (uint64_t)ret_conv;
11398 }
11399
11400 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11401         if ((_res & 1) != 0) return;
11402         LDKCResult_NoneNoneZ _res_conv = *(LDKCResult_NoneNoneZ*)(((uint64_t)_res) & ~1);
11403         FREE((void*)_res);
11404         CResult_NoneNoneZ_free(_res_conv);
11405 }
11406
11407 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11408         LDKCResult_NoneNoneZ* orig_conv = (LDKCResult_NoneNoneZ*)(orig & ~1);
11409         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
11410         *ret_conv = CResult_NoneNoneZ_clone(orig_conv);
11411         return (uint64_t)ret_conv;
11412 }
11413
11414 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11415         LDKC2Tuple_SignatureCVec_SignatureZZ* orig_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(orig & ~1);
11416         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
11417         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_clone(orig_conv);
11418         return ((uint64_t)ret_conv);
11419 }
11420
11421 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, jobjectArray b) {
11422         LDKSignature a_ref;
11423         CHECK((*env)->GetArrayLength(env, a) == 64);
11424         (*env)->GetByteArrayRegion(env, a, 0, 64, a_ref.compact_form);
11425         LDKCVec_SignatureZ b_constr;
11426         b_constr.datalen = (*env)->GetArrayLength(env, b);
11427         if (b_constr.datalen > 0)
11428                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
11429         else
11430                 b_constr.data = NULL;
11431         for (size_t i = 0; i < b_constr.datalen; i++) {
11432                 int8_tArray b_conv_8 = (*env)->GetObjectArrayElement(env, b, i);
11433                 LDKSignature b_conv_8_ref;
11434                 CHECK((*env)->GetArrayLength(env, b_conv_8) == 64);
11435                 (*env)->GetByteArrayRegion(env, b_conv_8, 0, 64, b_conv_8_ref.compact_form);
11436                 b_constr.data[i] = b_conv_8_ref;
11437         }
11438         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
11439         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_new(a_ref, b_constr);
11440         return ((uint64_t)ret_conv);
11441 }
11442
11443 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11444         if ((_res & 1) != 0) return;
11445         LDKC2Tuple_SignatureCVec_SignatureZZ _res_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(((uint64_t)_res) & ~1);
11446         FREE((void*)_res);
11447         C2Tuple_SignatureCVec_SignatureZZ_free(_res_conv);
11448 }
11449
11450 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11451         LDKC2Tuple_SignatureCVec_SignatureZZ o_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(((uint64_t)o) & ~1);
11452         o_conv = C2Tuple_SignatureCVec_SignatureZZ_clone((LDKC2Tuple_SignatureCVec_SignatureZZ*)(((uint64_t)o) & ~1));
11453         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
11454         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(o_conv);
11455         return (uint64_t)ret_conv;
11456 }
11457
11458 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1err(JNIEnv *env, jclass clz) {
11459         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
11460         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err();
11461         return (uint64_t)ret_conv;
11462 }
11463
11464 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11465         if ((_res & 1) != 0) return;
11466         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ _res_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)_res) & ~1);
11467         FREE((void*)_res);
11468         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(_res_conv);
11469 }
11470
11471 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11472         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* orig_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(orig & ~1);
11473         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
11474         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(orig_conv);
11475         return (uint64_t)ret_conv;
11476 }
11477
11478 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
11479         LDKSignature o_ref;
11480         CHECK((*env)->GetArrayLength(env, o) == 64);
11481         (*env)->GetByteArrayRegion(env, o, 0, 64, o_ref.compact_form);
11482         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
11483         *ret_conv = CResult_SignatureNoneZ_ok(o_ref);
11484         return (uint64_t)ret_conv;
11485 }
11486
11487 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1err(JNIEnv *env, jclass clz) {
11488         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
11489         *ret_conv = CResult_SignatureNoneZ_err();
11490         return (uint64_t)ret_conv;
11491 }
11492
11493 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11494         if ((_res & 1) != 0) return;
11495         LDKCResult_SignatureNoneZ _res_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)_res) & ~1);
11496         FREE((void*)_res);
11497         CResult_SignatureNoneZ_free(_res_conv);
11498 }
11499
11500 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11501         LDKCResult_SignatureNoneZ* orig_conv = (LDKCResult_SignatureNoneZ*)(orig & ~1);
11502         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
11503         *ret_conv = CResult_SignatureNoneZ_clone(orig_conv);
11504         return (uint64_t)ret_conv;
11505 }
11506
11507 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11508         LDKSign o_conv = *(LDKSign*)(((uint64_t)o) & ~1);
11509         if (o_conv.free == LDKSign_JCalls_free) {
11510                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
11511                 LDKSign_JCalls_cloned(&o_conv);
11512         }
11513         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
11514         *ret_conv = CResult_SignDecodeErrorZ_ok(o_conv);
11515         return (uint64_t)ret_conv;
11516 }
11517
11518 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11519         LDKDecodeError e_conv;
11520         e_conv.inner = (void*)(e & (~1));
11521         e_conv.is_owned = (e & 1) || (e == 0);
11522         e_conv = DecodeError_clone(&e_conv);
11523         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
11524         *ret_conv = CResult_SignDecodeErrorZ_err(e_conv);
11525         return (uint64_t)ret_conv;
11526 }
11527
11528 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11529         if ((_res & 1) != 0) return;
11530         LDKCResult_SignDecodeErrorZ _res_conv = *(LDKCResult_SignDecodeErrorZ*)(((uint64_t)_res) & ~1);
11531         FREE((void*)_res);
11532         CResult_SignDecodeErrorZ_free(_res_conv);
11533 }
11534
11535 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11536         LDKCResult_SignDecodeErrorZ* orig_conv = (LDKCResult_SignDecodeErrorZ*)(orig & ~1);
11537         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
11538         *ret_conv = CResult_SignDecodeErrorZ_clone(orig_conv);
11539         return (uint64_t)ret_conv;
11540 }
11541
11542 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u8Z_1free(JNIEnv *env, jclass clz, int8_tArray _res) {
11543         LDKCVec_u8Z _res_ref;
11544         _res_ref.datalen = (*env)->GetArrayLength(env, _res);
11545         _res_ref.data = MALLOC(_res_ref.datalen, "LDKCVec_u8Z Bytes");
11546         (*env)->GetByteArrayRegion(env, _res, 0, _res_ref.datalen, _res_ref.data);
11547         CVec_u8Z_free(_res_ref);
11548 }
11549
11550 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray arg) {
11551         LDKRecoverableSignature arg_ref;
11552         CHECK((*env)->GetArrayLength(env, arg) == 68);
11553         (*env)->GetByteArrayRegion(env, arg, 0, 68, arg_ref.serialized_form);
11554         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
11555         *ret_conv = CResult_RecoverableSignatureNoneZ_ok(arg_ref);
11556         return (uint64_t)ret_conv;
11557 }
11558
11559 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1err(JNIEnv *env, jclass clz) {
11560         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
11561         *ret_conv = CResult_RecoverableSignatureNoneZ_err();
11562         return (uint64_t)ret_conv;
11563 }
11564
11565 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11566         if ((_res & 1) != 0) return;
11567         LDKCResult_RecoverableSignatureNoneZ _res_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(((uint64_t)_res) & ~1);
11568         FREE((void*)_res);
11569         CResult_RecoverableSignatureNoneZ_free(_res_conv);
11570 }
11571
11572 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11573         LDKCResult_RecoverableSignatureNoneZ* orig_conv = (LDKCResult_RecoverableSignatureNoneZ*)(orig & ~1);
11574         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
11575         *ret_conv = CResult_RecoverableSignatureNoneZ_clone(orig_conv);
11576         return (uint64_t)ret_conv;
11577 }
11578
11579 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CVec_1u8ZZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
11580         LDKCVec_CVec_u8ZZ _res_constr;
11581         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11582         if (_res_constr.datalen > 0)
11583                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
11584         else
11585                 _res_constr.data = NULL;
11586         for (size_t i = 0; i < _res_constr.datalen; i++) {
11587                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
11588                 LDKCVec_u8Z _res_conv_8_ref;
11589                 _res_conv_8_ref.datalen = (*env)->GetArrayLength(env, _res_conv_8);
11590                 _res_conv_8_ref.data = MALLOC(_res_conv_8_ref.datalen, "LDKCVec_u8Z Bytes");
11591                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, _res_conv_8_ref.datalen, _res_conv_8_ref.data);
11592                 _res_constr.data[i] = _res_conv_8_ref;
11593         }
11594         CVec_CVec_u8ZZ_free(_res_constr);
11595 }
11596
11597 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1ok(JNIEnv *env, jclass clz, jobjectArray o) {
11598         LDKCVec_CVec_u8ZZ o_constr;
11599         o_constr.datalen = (*env)->GetArrayLength(env, o);
11600         if (o_constr.datalen > 0)
11601                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
11602         else
11603                 o_constr.data = NULL;
11604         for (size_t i = 0; i < o_constr.datalen; i++) {
11605                 int8_tArray o_conv_8 = (*env)->GetObjectArrayElement(env, o, i);
11606                 LDKCVec_u8Z o_conv_8_ref;
11607                 o_conv_8_ref.datalen = (*env)->GetArrayLength(env, o_conv_8);
11608                 o_conv_8_ref.data = MALLOC(o_conv_8_ref.datalen, "LDKCVec_u8Z Bytes");
11609                 (*env)->GetByteArrayRegion(env, o_conv_8, 0, o_conv_8_ref.datalen, o_conv_8_ref.data);
11610                 o_constr.data[i] = o_conv_8_ref;
11611         }
11612         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
11613         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_ok(o_constr);
11614         return (uint64_t)ret_conv;
11615 }
11616
11617 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1err(JNIEnv *env, jclass clz) {
11618         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
11619         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_err();
11620         return (uint64_t)ret_conv;
11621 }
11622
11623 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11624         if ((_res & 1) != 0) return;
11625         LDKCResult_CVec_CVec_u8ZZNoneZ _res_conv = *(LDKCResult_CVec_CVec_u8ZZNoneZ*)(((uint64_t)_res) & ~1);
11626         FREE((void*)_res);
11627         CResult_CVec_CVec_u8ZZNoneZ_free(_res_conv);
11628 }
11629
11630 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11631         LDKCResult_CVec_CVec_u8ZZNoneZ* orig_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(orig & ~1);
11632         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
11633         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(orig_conv);
11634         return (uint64_t)ret_conv;
11635 }
11636
11637 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11638         LDKInMemorySigner o_conv;
11639         o_conv.inner = (void*)(o & (~1));
11640         o_conv.is_owned = (o & 1) || (o == 0);
11641         o_conv = InMemorySigner_clone(&o_conv);
11642         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
11643         *ret_conv = CResult_InMemorySignerDecodeErrorZ_ok(o_conv);
11644         return (uint64_t)ret_conv;
11645 }
11646
11647 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11648         LDKDecodeError e_conv;
11649         e_conv.inner = (void*)(e & (~1));
11650         e_conv.is_owned = (e & 1) || (e == 0);
11651         e_conv = DecodeError_clone(&e_conv);
11652         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
11653         *ret_conv = CResult_InMemorySignerDecodeErrorZ_err(e_conv);
11654         return (uint64_t)ret_conv;
11655 }
11656
11657 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11658         if ((_res & 1) != 0) return;
11659         LDKCResult_InMemorySignerDecodeErrorZ _res_conv = *(LDKCResult_InMemorySignerDecodeErrorZ*)(((uint64_t)_res) & ~1);
11660         FREE((void*)_res);
11661         CResult_InMemorySignerDecodeErrorZ_free(_res_conv);
11662 }
11663
11664 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11665         LDKCResult_InMemorySignerDecodeErrorZ* orig_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(orig & ~1);
11666         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
11667         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(orig_conv);
11668         return (uint64_t)ret_conv;
11669 }
11670
11671 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TxOutZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
11672         LDKCVec_TxOutZ _res_constr;
11673         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11674         if (_res_constr.datalen > 0)
11675                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
11676         else
11677                 _res_constr.data = NULL;
11678         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
11679         for (size_t h = 0; h < _res_constr.datalen; h++) {
11680                 int64_t _res_conv_7 = _res_vals[h];
11681                 LDKTxOut _res_conv_7_conv = *(LDKTxOut*)(((uint64_t)_res_conv_7) & ~1);
11682                 FREE((void*)_res_conv_7);
11683                 _res_constr.data[h] = _res_conv_7_conv;
11684         }
11685         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
11686         CVec_TxOutZ_free(_res_constr);
11687 }
11688
11689 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
11690         LDKTransaction o_ref;
11691         o_ref.datalen = (*env)->GetArrayLength(env, o);
11692         o_ref.data = MALLOC(o_ref.datalen, "LDKTransaction Bytes");
11693         (*env)->GetByteArrayRegion(env, o, 0, o_ref.datalen, o_ref.data);
11694         o_ref.data_is_owned = true;
11695         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
11696         *ret_conv = CResult_TransactionNoneZ_ok(o_ref);
11697         return (uint64_t)ret_conv;
11698 }
11699
11700 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1err(JNIEnv *env, jclass clz) {
11701         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
11702         *ret_conv = CResult_TransactionNoneZ_err();
11703         return (uint64_t)ret_conv;
11704 }
11705
11706 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11707         if ((_res & 1) != 0) return;
11708         LDKCResult_TransactionNoneZ _res_conv = *(LDKCResult_TransactionNoneZ*)(((uint64_t)_res) & ~1);
11709         FREE((void*)_res);
11710         CResult_TransactionNoneZ_free(_res_conv);
11711 }
11712
11713 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11714         LDKCResult_TransactionNoneZ* orig_conv = (LDKCResult_TransactionNoneZ*)(orig & ~1);
11715         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
11716         *ret_conv = CResult_TransactionNoneZ_clone(orig_conv);
11717         return (uint64_t)ret_conv;
11718 }
11719
11720 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11721         LDKC2Tuple_BlockHashChannelMonitorZ* orig_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(orig & ~1);
11722         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
11723         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone(orig_conv);
11724         return ((uint64_t)ret_conv);
11725 }
11726
11727 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
11728         LDKThirtyTwoBytes a_ref;
11729         CHECK((*env)->GetArrayLength(env, a) == 32);
11730         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
11731         LDKChannelMonitor b_conv;
11732         b_conv.inner = (void*)(b & (~1));
11733         b_conv.is_owned = (b & 1) || (b == 0);
11734         b_conv = ChannelMonitor_clone(&b_conv);
11735         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
11736         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_new(a_ref, b_conv);
11737         return ((uint64_t)ret_conv);
11738 }
11739
11740 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11741         if ((_res & 1) != 0) return;
11742         LDKC2Tuple_BlockHashChannelMonitorZ _res_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)_res) & ~1);
11743         FREE((void*)_res);
11744         C2Tuple_BlockHashChannelMonitorZ_free(_res_conv);
11745 }
11746
11747 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1BlockHashChannelMonitorZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
11748         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ _res_constr;
11749         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11750         if (_res_constr.datalen > 0)
11751                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Elements");
11752         else
11753                 _res_constr.data = NULL;
11754         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
11755         for (size_t j = 0; j < _res_constr.datalen; j++) {
11756                 int64_t _res_conv_35 = _res_vals[j];
11757                 LDKC2Tuple_BlockHashChannelMonitorZ _res_conv_35_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)_res_conv_35) & ~1);
11758                 FREE((void*)_res_conv_35);
11759                 _res_constr.data[j] = _res_conv_35_conv;
11760         }
11761         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
11762         CVec_C2Tuple_BlockHashChannelMonitorZZ_free(_res_constr);
11763 }
11764
11765 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1ok(JNIEnv *env, jclass clz, int64_tArray o) {
11766         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ o_constr;
11767         o_constr.datalen = (*env)->GetArrayLength(env, o);
11768         if (o_constr.datalen > 0)
11769                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Elements");
11770         else
11771                 o_constr.data = NULL;
11772         int64_t* o_vals = (*env)->GetLongArrayElements (env, o, NULL);
11773         for (size_t j = 0; j < o_constr.datalen; j++) {
11774                 int64_t o_conv_35 = o_vals[j];
11775                 LDKC2Tuple_BlockHashChannelMonitorZ o_conv_35_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)o_conv_35) & ~1);
11776                 o_conv_35_conv = C2Tuple_BlockHashChannelMonitorZ_clone((LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)o_conv_35) & ~1));
11777                 o_constr.data[j] = o_conv_35_conv;
11778         }
11779         (*env)->ReleaseLongArrayElements(env, o, o_vals, 0);
11780         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
11781         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_ok(o_constr);
11782         return (uint64_t)ret_conv;
11783 }
11784
11785 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
11786         LDKIOError e_conv = LDKIOError_from_java(env, e);
11787         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
11788         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_err(e_conv);
11789         return (uint64_t)ret_conv;
11790 }
11791
11792 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11793         if ((_res & 1) != 0) return;
11794         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ _res_conv = *(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(((uint64_t)_res) & ~1);
11795         FREE((void*)_res);
11796         CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_free(_res_conv);
11797 }
11798
11799 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11800         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* orig_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(orig & ~1);
11801         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
11802         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone(orig_conv);
11803         return (uint64_t)ret_conv;
11804 }
11805
11806 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1some(JNIEnv *env, jclass clz, int16_t o) {
11807         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
11808         *ret_copy = COption_u16Z_some(o);
11809         uint64_t ret_ref = (uint64_t)ret_copy;
11810         return ret_ref;
11811 }
11812
11813 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1none(JNIEnv *env, jclass clz) {
11814         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
11815         *ret_copy = COption_u16Z_none();
11816         uint64_t ret_ref = (uint64_t)ret_copy;
11817         return ret_ref;
11818 }
11819
11820 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
11821         if ((_res & 1) != 0) return;
11822         LDKCOption_u16Z _res_conv = *(LDKCOption_u16Z*)(((uint64_t)_res) & ~1);
11823         FREE((void*)_res);
11824         COption_u16Z_free(_res_conv);
11825 }
11826
11827 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11828         LDKCOption_u16Z* orig_conv = (LDKCOption_u16Z*)orig;
11829         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
11830         *ret_copy = COption_u16Z_clone(orig_conv);
11831         uint64_t ret_ref = (uint64_t)ret_copy;
11832         return ret_ref;
11833 }
11834
11835 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1ok(JNIEnv *env, jclass clz) {
11836         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
11837         *ret_conv = CResult_NoneAPIErrorZ_ok();
11838         return (uint64_t)ret_conv;
11839 }
11840
11841 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11842         LDKAPIError e_conv = *(LDKAPIError*)(((uint64_t)e) & ~1);
11843         e_conv = APIError_clone((LDKAPIError*)(((uint64_t)e) & ~1));
11844         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
11845         *ret_conv = CResult_NoneAPIErrorZ_err(e_conv);
11846         return (uint64_t)ret_conv;
11847 }
11848
11849 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11850         if ((_res & 1) != 0) return;
11851         LDKCResult_NoneAPIErrorZ _res_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)_res) & ~1);
11852         FREE((void*)_res);
11853         CResult_NoneAPIErrorZ_free(_res_conv);
11854 }
11855
11856 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11857         LDKCResult_NoneAPIErrorZ* orig_conv = (LDKCResult_NoneAPIErrorZ*)(orig & ~1);
11858         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
11859         *ret_conv = CResult_NoneAPIErrorZ_clone(orig_conv);
11860         return (uint64_t)ret_conv;
11861 }
11862
11863 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CResult_1NoneAPIErrorZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
11864         LDKCVec_CResult_NoneAPIErrorZZ _res_constr;
11865         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11866         if (_res_constr.datalen > 0)
11867                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
11868         else
11869                 _res_constr.data = NULL;
11870         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
11871         for (size_t w = 0; w < _res_constr.datalen; w++) {
11872                 int64_t _res_conv_22 = _res_vals[w];
11873                 LDKCResult_NoneAPIErrorZ _res_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)_res_conv_22) & ~1);
11874                 FREE((void*)_res_conv_22);
11875                 _res_constr.data[w] = _res_conv_22_conv;
11876         }
11877         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
11878         CVec_CResult_NoneAPIErrorZZ_free(_res_constr);
11879 }
11880
11881 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1APIErrorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
11882         LDKCVec_APIErrorZ _res_constr;
11883         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11884         if (_res_constr.datalen > 0)
11885                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
11886         else
11887                 _res_constr.data = NULL;
11888         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
11889         for (size_t k = 0; k < _res_constr.datalen; k++) {
11890                 int64_t _res_conv_10 = _res_vals[k];
11891                 LDKAPIError _res_conv_10_conv = *(LDKAPIError*)(((uint64_t)_res_conv_10) & ~1);
11892                 FREE((void*)_res_conv_10);
11893                 _res_constr.data[k] = _res_conv_10_conv;
11894         }
11895         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
11896         CVec_APIErrorZ_free(_res_constr);
11897 }
11898
11899 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1ok(JNIEnv *env, jclass clz) {
11900         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
11901         *ret_conv = CResult_NonePaymentSendFailureZ_ok();
11902         return (uint64_t)ret_conv;
11903 }
11904
11905 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11906         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(((uint64_t)e) & ~1);
11907         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uint64_t)e) & ~1));
11908         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
11909         *ret_conv = CResult_NonePaymentSendFailureZ_err(e_conv);
11910         return (uint64_t)ret_conv;
11911 }
11912
11913 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11914         if ((_res & 1) != 0) return;
11915         LDKCResult_NonePaymentSendFailureZ _res_conv = *(LDKCResult_NonePaymentSendFailureZ*)(((uint64_t)_res) & ~1);
11916         FREE((void*)_res);
11917         CResult_NonePaymentSendFailureZ_free(_res_conv);
11918 }
11919
11920 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11921         LDKCResult_NonePaymentSendFailureZ* orig_conv = (LDKCResult_NonePaymentSendFailureZ*)(orig & ~1);
11922         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
11923         *ret_conv = CResult_NonePaymentSendFailureZ_clone(orig_conv);
11924         return (uint64_t)ret_conv;
11925 }
11926
11927 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentHashPaymentSendFailureZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
11928         LDKThirtyTwoBytes o_ref;
11929         CHECK((*env)->GetArrayLength(env, o) == 32);
11930         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
11931         LDKCResult_PaymentHashPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentHashPaymentSendFailureZ), "LDKCResult_PaymentHashPaymentSendFailureZ");
11932         *ret_conv = CResult_PaymentHashPaymentSendFailureZ_ok(o_ref);
11933         return (uint64_t)ret_conv;
11934 }
11935
11936 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentHashPaymentSendFailureZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11937         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(((uint64_t)e) & ~1);
11938         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uint64_t)e) & ~1));
11939         LDKCResult_PaymentHashPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentHashPaymentSendFailureZ), "LDKCResult_PaymentHashPaymentSendFailureZ");
11940         *ret_conv = CResult_PaymentHashPaymentSendFailureZ_err(e_conv);
11941         return (uint64_t)ret_conv;
11942 }
11943
11944 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentHashPaymentSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11945         if ((_res & 1) != 0) return;
11946         LDKCResult_PaymentHashPaymentSendFailureZ _res_conv = *(LDKCResult_PaymentHashPaymentSendFailureZ*)(((uint64_t)_res) & ~1);
11947         FREE((void*)_res);
11948         CResult_PaymentHashPaymentSendFailureZ_free(_res_conv);
11949 }
11950
11951 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentHashPaymentSendFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11952         LDKCResult_PaymentHashPaymentSendFailureZ* orig_conv = (LDKCResult_PaymentHashPaymentSendFailureZ*)(orig & ~1);
11953         LDKCResult_PaymentHashPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentHashPaymentSendFailureZ), "LDKCResult_PaymentHashPaymentSendFailureZ");
11954         *ret_conv = CResult_PaymentHashPaymentSendFailureZ_clone(orig_conv);
11955         return (uint64_t)ret_conv;
11956 }
11957
11958 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1NetAddressZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
11959         LDKCVec_NetAddressZ _res_constr;
11960         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11961         if (_res_constr.datalen > 0)
11962                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
11963         else
11964                 _res_constr.data = NULL;
11965         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
11966         for (size_t m = 0; m < _res_constr.datalen; m++) {
11967                 int64_t _res_conv_12 = _res_vals[m];
11968                 LDKNetAddress _res_conv_12_conv = *(LDKNetAddress*)(((uint64_t)_res_conv_12) & ~1);
11969                 FREE((void*)_res_conv_12);
11970                 _res_constr.data[m] = _res_conv_12_conv;
11971         }
11972         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
11973         CVec_NetAddressZ_free(_res_constr);
11974 }
11975
11976 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11977         LDKC2Tuple_PaymentHashPaymentSecretZ* orig_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(orig & ~1);
11978         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
11979         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone(orig_conv);
11980         return ((uint64_t)ret_conv);
11981 }
11982
11983 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int8_tArray b) {
11984         LDKThirtyTwoBytes a_ref;
11985         CHECK((*env)->GetArrayLength(env, a) == 32);
11986         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
11987         LDKThirtyTwoBytes b_ref;
11988         CHECK((*env)->GetArrayLength(env, b) == 32);
11989         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
11990         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
11991         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_new(a_ref, b_ref);
11992         return ((uint64_t)ret_conv);
11993 }
11994
11995 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11996         if ((_res & 1) != 0) return;
11997         LDKC2Tuple_PaymentHashPaymentSecretZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(((uint64_t)_res) & ~1);
11998         FREE((void*)_res);
11999         C2Tuple_PaymentHashPaymentSecretZ_free(_res_conv);
12000 }
12001
12002 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
12003         LDKThirtyTwoBytes o_ref;
12004         CHECK((*env)->GetArrayLength(env, o) == 32);
12005         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
12006         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
12007         *ret_conv = CResult_PaymentSecretAPIErrorZ_ok(o_ref);
12008         return (uint64_t)ret_conv;
12009 }
12010
12011 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12012         LDKAPIError e_conv = *(LDKAPIError*)(((uint64_t)e) & ~1);
12013         e_conv = APIError_clone((LDKAPIError*)(((uint64_t)e) & ~1));
12014         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
12015         *ret_conv = CResult_PaymentSecretAPIErrorZ_err(e_conv);
12016         return (uint64_t)ret_conv;
12017 }
12018
12019 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12020         if ((_res & 1) != 0) return;
12021         LDKCResult_PaymentSecretAPIErrorZ _res_conv = *(LDKCResult_PaymentSecretAPIErrorZ*)(((uint64_t)_res) & ~1);
12022         FREE((void*)_res);
12023         CResult_PaymentSecretAPIErrorZ_free(_res_conv);
12024 }
12025
12026 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12027         LDKCResult_PaymentSecretAPIErrorZ* orig_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(orig & ~1);
12028         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
12029         *ret_conv = CResult_PaymentSecretAPIErrorZ_clone(orig_conv);
12030         return (uint64_t)ret_conv;
12031 }
12032
12033 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ChannelMonitorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
12034         LDKCVec_ChannelMonitorZ _res_constr;
12035         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
12036         if (_res_constr.datalen > 0)
12037                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
12038         else
12039                 _res_constr.data = NULL;
12040         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
12041         for (size_t q = 0; q < _res_constr.datalen; q++) {
12042                 int64_t _res_conv_16 = _res_vals[q];
12043                 LDKChannelMonitor _res_conv_16_conv;
12044                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
12045                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
12046                 _res_constr.data[q] = _res_conv_16_conv;
12047         }
12048         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
12049         CVec_ChannelMonitorZ_free(_res_constr);
12050 }
12051
12052 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
12053         LDKThirtyTwoBytes a_ref;
12054         CHECK((*env)->GetArrayLength(env, a) == 32);
12055         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
12056         LDKChannelManager b_conv;
12057         b_conv.inner = (void*)(b & (~1));
12058         b_conv.is_owned = (b & 1) || (b == 0);
12059         // Warning: we need a move here but no clone is available for LDKChannelManager
12060         LDKC2Tuple_BlockHashChannelManagerZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
12061         *ret_conv = C2Tuple_BlockHashChannelManagerZ_new(a_ref, b_conv);
12062         return ((uint64_t)ret_conv);
12063 }
12064
12065 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12066         if ((_res & 1) != 0) return;
12067         LDKC2Tuple_BlockHashChannelManagerZ _res_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(((uint64_t)_res) & ~1);
12068         FREE((void*)_res);
12069         C2Tuple_BlockHashChannelManagerZ_free(_res_conv);
12070 }
12071
12072 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12073         LDKC2Tuple_BlockHashChannelManagerZ o_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(((uint64_t)o) & ~1);
12074         // Warning: we may need a move here but no clone is available for LDKC2Tuple_BlockHashChannelManagerZ
12075         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
12076         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(o_conv);
12077         return (uint64_t)ret_conv;
12078 }
12079
12080 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12081         LDKDecodeError e_conv;
12082         e_conv.inner = (void*)(e & (~1));
12083         e_conv.is_owned = (e & 1) || (e == 0);
12084         e_conv = DecodeError_clone(&e_conv);
12085         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
12086         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(e_conv);
12087         return (uint64_t)ret_conv;
12088 }
12089
12090 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12091         if ((_res & 1) != 0) return;
12092         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(((uint64_t)_res) & ~1);
12093         FREE((void*)_res);
12094         CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(_res_conv);
12095 }
12096
12097 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12098         LDKChannelConfig o_conv;
12099         o_conv.inner = (void*)(o & (~1));
12100         o_conv.is_owned = (o & 1) || (o == 0);
12101         o_conv = ChannelConfig_clone(&o_conv);
12102         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
12103         *ret_conv = CResult_ChannelConfigDecodeErrorZ_ok(o_conv);
12104         return (uint64_t)ret_conv;
12105 }
12106
12107 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12108         LDKDecodeError e_conv;
12109         e_conv.inner = (void*)(e & (~1));
12110         e_conv.is_owned = (e & 1) || (e == 0);
12111         e_conv = DecodeError_clone(&e_conv);
12112         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
12113         *ret_conv = CResult_ChannelConfigDecodeErrorZ_err(e_conv);
12114         return (uint64_t)ret_conv;
12115 }
12116
12117 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12118         if ((_res & 1) != 0) return;
12119         LDKCResult_ChannelConfigDecodeErrorZ _res_conv = *(LDKCResult_ChannelConfigDecodeErrorZ*)(((uint64_t)_res) & ~1);
12120         FREE((void*)_res);
12121         CResult_ChannelConfigDecodeErrorZ_free(_res_conv);
12122 }
12123
12124 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12125         LDKCResult_ChannelConfigDecodeErrorZ* orig_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(orig & ~1);
12126         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
12127         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(orig_conv);
12128         return (uint64_t)ret_conv;
12129 }
12130
12131 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12132         LDKOutPoint o_conv;
12133         o_conv.inner = (void*)(o & (~1));
12134         o_conv.is_owned = (o & 1) || (o == 0);
12135         o_conv = OutPoint_clone(&o_conv);
12136         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
12137         *ret_conv = CResult_OutPointDecodeErrorZ_ok(o_conv);
12138         return (uint64_t)ret_conv;
12139 }
12140
12141 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12142         LDKDecodeError e_conv;
12143         e_conv.inner = (void*)(e & (~1));
12144         e_conv.is_owned = (e & 1) || (e == 0);
12145         e_conv = DecodeError_clone(&e_conv);
12146         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
12147         *ret_conv = CResult_OutPointDecodeErrorZ_err(e_conv);
12148         return (uint64_t)ret_conv;
12149 }
12150
12151 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12152         if ((_res & 1) != 0) return;
12153         LDKCResult_OutPointDecodeErrorZ _res_conv = *(LDKCResult_OutPointDecodeErrorZ*)(((uint64_t)_res) & ~1);
12154         FREE((void*)_res);
12155         CResult_OutPointDecodeErrorZ_free(_res_conv);
12156 }
12157
12158 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12159         LDKCResult_OutPointDecodeErrorZ* orig_conv = (LDKCResult_OutPointDecodeErrorZ*)(orig & ~1);
12160         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
12161         *ret_conv = CResult_OutPointDecodeErrorZ_clone(orig_conv);
12162         return (uint64_t)ret_conv;
12163 }
12164
12165 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1some(JNIEnv *env, jclass clz, int64_t o) {
12166         LDKType o_conv = *(LDKType*)(((uint64_t)o) & ~1);
12167         if (o_conv.free == LDKType_JCalls_free) {
12168                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
12169                 LDKType_JCalls_cloned(&o_conv);
12170         }
12171         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
12172         *ret_copy = COption_TypeZ_some(o_conv);
12173         uint64_t ret_ref = (uint64_t)ret_copy;
12174         return ret_ref;
12175 }
12176
12177 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1none(JNIEnv *env, jclass clz) {
12178         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
12179         *ret_copy = COption_TypeZ_none();
12180         uint64_t ret_ref = (uint64_t)ret_copy;
12181         return ret_ref;
12182 }
12183
12184 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12185         if ((_res & 1) != 0) return;
12186         LDKCOption_TypeZ _res_conv = *(LDKCOption_TypeZ*)(((uint64_t)_res) & ~1);
12187         FREE((void*)_res);
12188         COption_TypeZ_free(_res_conv);
12189 }
12190
12191 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12192         LDKCOption_TypeZ* orig_conv = (LDKCOption_TypeZ*)orig;
12193         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
12194         *ret_copy = COption_TypeZ_clone(orig_conv);
12195         uint64_t ret_ref = (uint64_t)ret_copy;
12196         return ret_ref;
12197 }
12198
12199 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12200         LDKCOption_TypeZ o_conv = *(LDKCOption_TypeZ*)(((uint64_t)o) & ~1);
12201         o_conv = COption_TypeZ_clone((LDKCOption_TypeZ*)(((uint64_t)o) & ~1));
12202         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
12203         *ret_conv = CResult_COption_TypeZDecodeErrorZ_ok(o_conv);
12204         return (uint64_t)ret_conv;
12205 }
12206
12207 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12208         LDKDecodeError e_conv;
12209         e_conv.inner = (void*)(e & (~1));
12210         e_conv.is_owned = (e & 1) || (e == 0);
12211         e_conv = DecodeError_clone(&e_conv);
12212         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
12213         *ret_conv = CResult_COption_TypeZDecodeErrorZ_err(e_conv);
12214         return (uint64_t)ret_conv;
12215 }
12216
12217 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12218         if ((_res & 1) != 0) return;
12219         LDKCResult_COption_TypeZDecodeErrorZ _res_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(((uint64_t)_res) & ~1);
12220         FREE((void*)_res);
12221         CResult_COption_TypeZDecodeErrorZ_free(_res_conv);
12222 }
12223
12224 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12225         LDKCResult_COption_TypeZDecodeErrorZ* orig_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(orig & ~1);
12226         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
12227         *ret_conv = CResult_COption_TypeZDecodeErrorZ_clone(orig_conv);
12228         return (uint64_t)ret_conv;
12229 }
12230
12231 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixNoneZ_1ok(JNIEnv *env, jclass clz, jclass o) {
12232         LDKSiPrefix o_conv = LDKSiPrefix_from_java(env, o);
12233         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
12234         *ret_conv = CResult_SiPrefixNoneZ_ok(o_conv);
12235         return (uint64_t)ret_conv;
12236 }
12237
12238 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixNoneZ_1err(JNIEnv *env, jclass clz) {
12239         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
12240         *ret_conv = CResult_SiPrefixNoneZ_err();
12241         return (uint64_t)ret_conv;
12242 }
12243
12244 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12245         if ((_res & 1) != 0) return;
12246         LDKCResult_SiPrefixNoneZ _res_conv = *(LDKCResult_SiPrefixNoneZ*)(((uint64_t)_res) & ~1);
12247         FREE((void*)_res);
12248         CResult_SiPrefixNoneZ_free(_res_conv);
12249 }
12250
12251 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12252         LDKCResult_SiPrefixNoneZ* orig_conv = (LDKCResult_SiPrefixNoneZ*)(orig & ~1);
12253         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
12254         *ret_conv = CResult_SiPrefixNoneZ_clone(orig_conv);
12255         return (uint64_t)ret_conv;
12256 }
12257
12258 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12259         LDKInvoice o_conv;
12260         o_conv.inner = (void*)(o & (~1));
12261         o_conv.is_owned = (o & 1) || (o == 0);
12262         o_conv = Invoice_clone(&o_conv);
12263         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
12264         *ret_conv = CResult_InvoiceNoneZ_ok(o_conv);
12265         return (uint64_t)ret_conv;
12266 }
12267
12268 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceNoneZ_1err(JNIEnv *env, jclass clz) {
12269         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
12270         *ret_conv = CResult_InvoiceNoneZ_err();
12271         return (uint64_t)ret_conv;
12272 }
12273
12274 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12275         if ((_res & 1) != 0) return;
12276         LDKCResult_InvoiceNoneZ _res_conv = *(LDKCResult_InvoiceNoneZ*)(((uint64_t)_res) & ~1);
12277         FREE((void*)_res);
12278         CResult_InvoiceNoneZ_free(_res_conv);
12279 }
12280
12281 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12282         LDKCResult_InvoiceNoneZ* orig_conv = (LDKCResult_InvoiceNoneZ*)(orig & ~1);
12283         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
12284         *ret_conv = CResult_InvoiceNoneZ_clone(orig_conv);
12285         return (uint64_t)ret_conv;
12286 }
12287
12288 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12289         LDKSignedRawInvoice o_conv;
12290         o_conv.inner = (void*)(o & (~1));
12291         o_conv.is_owned = (o & 1) || (o == 0);
12292         o_conv = SignedRawInvoice_clone(&o_conv);
12293         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
12294         *ret_conv = CResult_SignedRawInvoiceNoneZ_ok(o_conv);
12295         return (uint64_t)ret_conv;
12296 }
12297
12298 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceNoneZ_1err(JNIEnv *env, jclass clz) {
12299         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
12300         *ret_conv = CResult_SignedRawInvoiceNoneZ_err();
12301         return (uint64_t)ret_conv;
12302 }
12303
12304 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12305         if ((_res & 1) != 0) return;
12306         LDKCResult_SignedRawInvoiceNoneZ _res_conv = *(LDKCResult_SignedRawInvoiceNoneZ*)(((uint64_t)_res) & ~1);
12307         FREE((void*)_res);
12308         CResult_SignedRawInvoiceNoneZ_free(_res_conv);
12309 }
12310
12311 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12312         LDKCResult_SignedRawInvoiceNoneZ* orig_conv = (LDKCResult_SignedRawInvoiceNoneZ*)(orig & ~1);
12313         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
12314         *ret_conv = CResult_SignedRawInvoiceNoneZ_clone(orig_conv);
12315         return (uint64_t)ret_conv;
12316 }
12317
12318 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12319         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* orig_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(orig & ~1);
12320         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
12321         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(orig_conv);
12322         return ((uint64_t)ret_conv);
12323 }
12324
12325 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) {
12326         LDKRawInvoice a_conv;
12327         a_conv.inner = (void*)(a & (~1));
12328         a_conv.is_owned = (a & 1) || (a == 0);
12329         a_conv = RawInvoice_clone(&a_conv);
12330         LDKThirtyTwoBytes b_ref;
12331         CHECK((*env)->GetArrayLength(env, b) == 32);
12332         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
12333         LDKInvoiceSignature c_conv;
12334         c_conv.inner = (void*)(c & (~1));
12335         c_conv.is_owned = (c & 1) || (c == 0);
12336         c_conv = InvoiceSignature_clone(&c_conv);
12337         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
12338         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_new(a_conv, b_ref, c_conv);
12339         return ((uint64_t)ret_conv);
12340 }
12341
12342 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12343         if ((_res & 1) != 0) return;
12344         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ _res_conv = *(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(((uint64_t)_res) & ~1);
12345         FREE((void*)_res);
12346         C3Tuple_RawInvoice_u832InvoiceSignatureZ_free(_res_conv);
12347 }
12348
12349 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12350         LDKPayeePubKey o_conv;
12351         o_conv.inner = (void*)(o & (~1));
12352         o_conv.is_owned = (o & 1) || (o == 0);
12353         o_conv = PayeePubKey_clone(&o_conv);
12354         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
12355         *ret_conv = CResult_PayeePubKeyErrorZ_ok(o_conv);
12356         return (uint64_t)ret_conv;
12357 }
12358
12359 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
12360         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
12361         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
12362         *ret_conv = CResult_PayeePubKeyErrorZ_err(e_conv);
12363         return (uint64_t)ret_conv;
12364 }
12365
12366 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12367         if ((_res & 1) != 0) return;
12368         LDKCResult_PayeePubKeyErrorZ _res_conv = *(LDKCResult_PayeePubKeyErrorZ*)(((uint64_t)_res) & ~1);
12369         FREE((void*)_res);
12370         CResult_PayeePubKeyErrorZ_free(_res_conv);
12371 }
12372
12373 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12374         LDKCResult_PayeePubKeyErrorZ* orig_conv = (LDKCResult_PayeePubKeyErrorZ*)(orig & ~1);
12375         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
12376         *ret_conv = CResult_PayeePubKeyErrorZ_clone(orig_conv);
12377         return (uint64_t)ret_conv;
12378 }
12379
12380 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PrivateRouteZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
12381         LDKCVec_PrivateRouteZ _res_constr;
12382         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
12383         if (_res_constr.datalen > 0)
12384                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPrivateRoute), "LDKCVec_PrivateRouteZ Elements");
12385         else
12386                 _res_constr.data = NULL;
12387         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
12388         for (size_t o = 0; o < _res_constr.datalen; o++) {
12389                 int64_t _res_conv_14 = _res_vals[o];
12390                 LDKPrivateRoute _res_conv_14_conv;
12391                 _res_conv_14_conv.inner = (void*)(_res_conv_14 & (~1));
12392                 _res_conv_14_conv.is_owned = (_res_conv_14 & 1) || (_res_conv_14 == 0);
12393                 _res_constr.data[o] = _res_conv_14_conv;
12394         }
12395         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
12396         CVec_PrivateRouteZ_free(_res_constr);
12397 }
12398
12399 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12400         LDKPositiveTimestamp o_conv;
12401         o_conv.inner = (void*)(o & (~1));
12402         o_conv.is_owned = (o & 1) || (o == 0);
12403         o_conv = PositiveTimestamp_clone(&o_conv);
12404         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
12405         *ret_conv = CResult_PositiveTimestampCreationErrorZ_ok(o_conv);
12406         return (uint64_t)ret_conv;
12407 }
12408
12409 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
12410         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
12411         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
12412         *ret_conv = CResult_PositiveTimestampCreationErrorZ_err(e_conv);
12413         return (uint64_t)ret_conv;
12414 }
12415
12416 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12417         if ((_res & 1) != 0) return;
12418         LDKCResult_PositiveTimestampCreationErrorZ _res_conv = *(LDKCResult_PositiveTimestampCreationErrorZ*)(((uint64_t)_res) & ~1);
12419         FREE((void*)_res);
12420         CResult_PositiveTimestampCreationErrorZ_free(_res_conv);
12421 }
12422
12423 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12424         LDKCResult_PositiveTimestampCreationErrorZ* orig_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(orig & ~1);
12425         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
12426         *ret_conv = CResult_PositiveTimestampCreationErrorZ_clone(orig_conv);
12427         return (uint64_t)ret_conv;
12428 }
12429
12430 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1ok(JNIEnv *env, jclass clz) {
12431         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
12432         *ret_conv = CResult_NoneSemanticErrorZ_ok();
12433         return (uint64_t)ret_conv;
12434 }
12435
12436 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
12437         LDKSemanticError e_conv = LDKSemanticError_from_java(env, e);
12438         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
12439         *ret_conv = CResult_NoneSemanticErrorZ_err(e_conv);
12440         return (uint64_t)ret_conv;
12441 }
12442
12443 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12444         if ((_res & 1) != 0) return;
12445         LDKCResult_NoneSemanticErrorZ _res_conv = *(LDKCResult_NoneSemanticErrorZ*)(((uint64_t)_res) & ~1);
12446         FREE((void*)_res);
12447         CResult_NoneSemanticErrorZ_free(_res_conv);
12448 }
12449
12450 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12451         LDKCResult_NoneSemanticErrorZ* orig_conv = (LDKCResult_NoneSemanticErrorZ*)(orig & ~1);
12452         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
12453         *ret_conv = CResult_NoneSemanticErrorZ_clone(orig_conv);
12454         return (uint64_t)ret_conv;
12455 }
12456
12457 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12458         LDKInvoice o_conv;
12459         o_conv.inner = (void*)(o & (~1));
12460         o_conv.is_owned = (o & 1) || (o == 0);
12461         o_conv = Invoice_clone(&o_conv);
12462         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
12463         *ret_conv = CResult_InvoiceSemanticErrorZ_ok(o_conv);
12464         return (uint64_t)ret_conv;
12465 }
12466
12467 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
12468         LDKSemanticError e_conv = LDKSemanticError_from_java(env, e);
12469         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
12470         *ret_conv = CResult_InvoiceSemanticErrorZ_err(e_conv);
12471         return (uint64_t)ret_conv;
12472 }
12473
12474 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12475         if ((_res & 1) != 0) return;
12476         LDKCResult_InvoiceSemanticErrorZ _res_conv = *(LDKCResult_InvoiceSemanticErrorZ*)(((uint64_t)_res) & ~1);
12477         FREE((void*)_res);
12478         CResult_InvoiceSemanticErrorZ_free(_res_conv);
12479 }
12480
12481 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12482         LDKCResult_InvoiceSemanticErrorZ* orig_conv = (LDKCResult_InvoiceSemanticErrorZ*)(orig & ~1);
12483         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
12484         *ret_conv = CResult_InvoiceSemanticErrorZ_clone(orig_conv);
12485         return (uint64_t)ret_conv;
12486 }
12487
12488 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12489         LDKDescription o_conv;
12490         o_conv.inner = (void*)(o & (~1));
12491         o_conv.is_owned = (o & 1) || (o == 0);
12492         o_conv = Description_clone(&o_conv);
12493         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
12494         *ret_conv = CResult_DescriptionCreationErrorZ_ok(o_conv);
12495         return (uint64_t)ret_conv;
12496 }
12497
12498 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
12499         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
12500         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
12501         *ret_conv = CResult_DescriptionCreationErrorZ_err(e_conv);
12502         return (uint64_t)ret_conv;
12503 }
12504
12505 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12506         if ((_res & 1) != 0) return;
12507         LDKCResult_DescriptionCreationErrorZ _res_conv = *(LDKCResult_DescriptionCreationErrorZ*)(((uint64_t)_res) & ~1);
12508         FREE((void*)_res);
12509         CResult_DescriptionCreationErrorZ_free(_res_conv);
12510 }
12511
12512 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12513         LDKCResult_DescriptionCreationErrorZ* orig_conv = (LDKCResult_DescriptionCreationErrorZ*)(orig & ~1);
12514         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
12515         *ret_conv = CResult_DescriptionCreationErrorZ_clone(orig_conv);
12516         return (uint64_t)ret_conv;
12517 }
12518
12519 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ExpiryTimeCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12520         LDKExpiryTime o_conv;
12521         o_conv.inner = (void*)(o & (~1));
12522         o_conv.is_owned = (o & 1) || (o == 0);
12523         o_conv = ExpiryTime_clone(&o_conv);
12524         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
12525         *ret_conv = CResult_ExpiryTimeCreationErrorZ_ok(o_conv);
12526         return (uint64_t)ret_conv;
12527 }
12528
12529 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ExpiryTimeCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
12530         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
12531         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
12532         *ret_conv = CResult_ExpiryTimeCreationErrorZ_err(e_conv);
12533         return (uint64_t)ret_conv;
12534 }
12535
12536 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ExpiryTimeCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12537         if ((_res & 1) != 0) return;
12538         LDKCResult_ExpiryTimeCreationErrorZ _res_conv = *(LDKCResult_ExpiryTimeCreationErrorZ*)(((uint64_t)_res) & ~1);
12539         FREE((void*)_res);
12540         CResult_ExpiryTimeCreationErrorZ_free(_res_conv);
12541 }
12542
12543 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ExpiryTimeCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12544         LDKCResult_ExpiryTimeCreationErrorZ* orig_conv = (LDKCResult_ExpiryTimeCreationErrorZ*)(orig & ~1);
12545         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
12546         *ret_conv = CResult_ExpiryTimeCreationErrorZ_clone(orig_conv);
12547         return (uint64_t)ret_conv;
12548 }
12549
12550 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12551         LDKPrivateRoute o_conv;
12552         o_conv.inner = (void*)(o & (~1));
12553         o_conv.is_owned = (o & 1) || (o == 0);
12554         o_conv = PrivateRoute_clone(&o_conv);
12555         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
12556         *ret_conv = CResult_PrivateRouteCreationErrorZ_ok(o_conv);
12557         return (uint64_t)ret_conv;
12558 }
12559
12560 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
12561         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
12562         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
12563         *ret_conv = CResult_PrivateRouteCreationErrorZ_err(e_conv);
12564         return (uint64_t)ret_conv;
12565 }
12566
12567 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12568         if ((_res & 1) != 0) return;
12569         LDKCResult_PrivateRouteCreationErrorZ _res_conv = *(LDKCResult_PrivateRouteCreationErrorZ*)(((uint64_t)_res) & ~1);
12570         FREE((void*)_res);
12571         CResult_PrivateRouteCreationErrorZ_free(_res_conv);
12572 }
12573
12574 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12575         LDKCResult_PrivateRouteCreationErrorZ* orig_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(orig & ~1);
12576         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
12577         *ret_conv = CResult_PrivateRouteCreationErrorZ_clone(orig_conv);
12578         return (uint64_t)ret_conv;
12579 }
12580
12581 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1ok(JNIEnv *env, jclass clz, jstring o) {
12582         LDKStr o_conv = java_to_owned_str(env, o);
12583         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
12584         *ret_conv = CResult_StringErrorZ_ok(o_conv);
12585         return (uint64_t)ret_conv;
12586 }
12587
12588 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
12589         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
12590         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
12591         *ret_conv = CResult_StringErrorZ_err(e_conv);
12592         return (uint64_t)ret_conv;
12593 }
12594
12595 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12596         if ((_res & 1) != 0) return;
12597         LDKCResult_StringErrorZ _res_conv = *(LDKCResult_StringErrorZ*)(((uint64_t)_res) & ~1);
12598         FREE((void*)_res);
12599         CResult_StringErrorZ_free(_res_conv);
12600 }
12601
12602 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12603         LDKChannelMonitorUpdate o_conv;
12604         o_conv.inner = (void*)(o & (~1));
12605         o_conv.is_owned = (o & 1) || (o == 0);
12606         o_conv = ChannelMonitorUpdate_clone(&o_conv);
12607         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
12608         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_ok(o_conv);
12609         return (uint64_t)ret_conv;
12610 }
12611
12612 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12613         LDKDecodeError e_conv;
12614         e_conv.inner = (void*)(e & (~1));
12615         e_conv.is_owned = (e & 1) || (e == 0);
12616         e_conv = DecodeError_clone(&e_conv);
12617         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
12618         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_err(e_conv);
12619         return (uint64_t)ret_conv;
12620 }
12621
12622 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12623         if ((_res & 1) != 0) return;
12624         LDKCResult_ChannelMonitorUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
12625         FREE((void*)_res);
12626         CResult_ChannelMonitorUpdateDecodeErrorZ_free(_res_conv);
12627 }
12628
12629 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12630         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(orig & ~1);
12631         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
12632         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(orig_conv);
12633         return (uint64_t)ret_conv;
12634 }
12635
12636 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12637         LDKHTLCUpdate o_conv;
12638         o_conv.inner = (void*)(o & (~1));
12639         o_conv.is_owned = (o & 1) || (o == 0);
12640         o_conv = HTLCUpdate_clone(&o_conv);
12641         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
12642         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_ok(o_conv);
12643         return (uint64_t)ret_conv;
12644 }
12645
12646 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12647         LDKDecodeError e_conv;
12648         e_conv.inner = (void*)(e & (~1));
12649         e_conv.is_owned = (e & 1) || (e == 0);
12650         e_conv = DecodeError_clone(&e_conv);
12651         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
12652         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_err(e_conv);
12653         return (uint64_t)ret_conv;
12654 }
12655
12656 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12657         if ((_res & 1) != 0) return;
12658         LDKCResult_HTLCUpdateDecodeErrorZ _res_conv = *(LDKCResult_HTLCUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
12659         FREE((void*)_res);
12660         CResult_HTLCUpdateDecodeErrorZ_free(_res_conv);
12661 }
12662
12663 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12664         LDKCResult_HTLCUpdateDecodeErrorZ* orig_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(orig & ~1);
12665         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
12666         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(orig_conv);
12667         return (uint64_t)ret_conv;
12668 }
12669
12670 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneMonitorUpdateErrorZ_1ok(JNIEnv *env, jclass clz) {
12671         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
12672         *ret_conv = CResult_NoneMonitorUpdateErrorZ_ok();
12673         return (uint64_t)ret_conv;
12674 }
12675
12676 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneMonitorUpdateErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12677         LDKMonitorUpdateError e_conv;
12678         e_conv.inner = (void*)(e & (~1));
12679         e_conv.is_owned = (e & 1) || (e == 0);
12680         e_conv = MonitorUpdateError_clone(&e_conv);
12681         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
12682         *ret_conv = CResult_NoneMonitorUpdateErrorZ_err(e_conv);
12683         return (uint64_t)ret_conv;
12684 }
12685
12686 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneMonitorUpdateErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12687         if ((_res & 1) != 0) return;
12688         LDKCResult_NoneMonitorUpdateErrorZ _res_conv = *(LDKCResult_NoneMonitorUpdateErrorZ*)(((uint64_t)_res) & ~1);
12689         FREE((void*)_res);
12690         CResult_NoneMonitorUpdateErrorZ_free(_res_conv);
12691 }
12692
12693 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneMonitorUpdateErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12694         LDKCResult_NoneMonitorUpdateErrorZ* orig_conv = (LDKCResult_NoneMonitorUpdateErrorZ*)(orig & ~1);
12695         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
12696         *ret_conv = CResult_NoneMonitorUpdateErrorZ_clone(orig_conv);
12697         return (uint64_t)ret_conv;
12698 }
12699
12700 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12701         LDKC2Tuple_OutPointScriptZ* orig_conv = (LDKC2Tuple_OutPointScriptZ*)(orig & ~1);
12702         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
12703         *ret_conv = C2Tuple_OutPointScriptZ_clone(orig_conv);
12704         return ((uint64_t)ret_conv);
12705 }
12706
12707 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
12708         LDKOutPoint a_conv;
12709         a_conv.inner = (void*)(a & (~1));
12710         a_conv.is_owned = (a & 1) || (a == 0);
12711         a_conv = OutPoint_clone(&a_conv);
12712         LDKCVec_u8Z b_ref;
12713         b_ref.datalen = (*env)->GetArrayLength(env, b);
12714         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
12715         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
12716         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
12717         *ret_conv = C2Tuple_OutPointScriptZ_new(a_conv, b_ref);
12718         return ((uint64_t)ret_conv);
12719 }
12720
12721 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12722         if ((_res & 1) != 0) return;
12723         LDKC2Tuple_OutPointScriptZ _res_conv = *(LDKC2Tuple_OutPointScriptZ*)(((uint64_t)_res) & ~1);
12724         FREE((void*)_res);
12725         C2Tuple_OutPointScriptZ_free(_res_conv);
12726 }
12727
12728 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12729         LDKC2Tuple_u32ScriptZ* orig_conv = (LDKC2Tuple_u32ScriptZ*)(orig & ~1);
12730         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
12731         *ret_conv = C2Tuple_u32ScriptZ_clone(orig_conv);
12732         return ((uint64_t)ret_conv);
12733 }
12734
12735 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1new(JNIEnv *env, jclass clz, int32_t a, int8_tArray b) {
12736         LDKCVec_u8Z b_ref;
12737         b_ref.datalen = (*env)->GetArrayLength(env, b);
12738         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
12739         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
12740         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
12741         *ret_conv = C2Tuple_u32ScriptZ_new(a, b_ref);
12742         return ((uint64_t)ret_conv);
12743 }
12744
12745 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12746         if ((_res & 1) != 0) return;
12747         LDKC2Tuple_u32ScriptZ _res_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)_res) & ~1);
12748         FREE((void*)_res);
12749         C2Tuple_u32ScriptZ_free(_res_conv);
12750 }
12751
12752 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1u32ScriptZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
12753         LDKCVec_C2Tuple_u32ScriptZZ _res_constr;
12754         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
12755         if (_res_constr.datalen > 0)
12756                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
12757         else
12758                 _res_constr.data = NULL;
12759         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
12760         for (size_t v = 0; v < _res_constr.datalen; v++) {
12761                 int64_t _res_conv_21 = _res_vals[v];
12762                 LDKC2Tuple_u32ScriptZ _res_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)_res_conv_21) & ~1);
12763                 FREE((void*)_res_conv_21);
12764                 _res_constr.data[v] = _res_conv_21_conv;
12765         }
12766         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
12767         CVec_C2Tuple_u32ScriptZZ_free(_res_constr);
12768 }
12769
12770 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12771         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(orig & ~1);
12772         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
12773         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(orig_conv);
12774         return ((uint64_t)ret_conv);
12775 }
12776
12777 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
12778         LDKThirtyTwoBytes a_ref;
12779         CHECK((*env)->GetArrayLength(env, a) == 32);
12780         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
12781         LDKCVec_C2Tuple_u32ScriptZZ b_constr;
12782         b_constr.datalen = (*env)->GetArrayLength(env, b);
12783         if (b_constr.datalen > 0)
12784                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
12785         else
12786                 b_constr.data = NULL;
12787         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
12788         for (size_t v = 0; v < b_constr.datalen; v++) {
12789                 int64_t b_conv_21 = b_vals[v];
12790                 LDKC2Tuple_u32ScriptZ b_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_21) & ~1);
12791                 b_conv_21_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_21) & ~1));
12792                 b_constr.data[v] = b_conv_21_conv;
12793         }
12794         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
12795         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
12796         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(a_ref, b_constr);
12797         return ((uint64_t)ret_conv);
12798 }
12799
12800 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12801         if ((_res & 1) != 0) return;
12802         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)_res) & ~1);
12803         FREE((void*)_res);
12804         C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(_res_conv);
12805 }
12806
12807 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
12808         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ _res_constr;
12809         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
12810         if (_res_constr.datalen > 0)
12811                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ Elements");
12812         else
12813                 _res_constr.data = NULL;
12814         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
12815         for (size_t o = 0; o < _res_constr.datalen; o++) {
12816                 int64_t _res_conv_40 = _res_vals[o];
12817                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv_40_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)_res_conv_40) & ~1);
12818                 FREE((void*)_res_conv_40);
12819                 _res_constr.data[o] = _res_conv_40_conv;
12820         }
12821         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
12822         CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(_res_constr);
12823 }
12824
12825 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1EventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
12826         LDKCVec_EventZ _res_constr;
12827         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
12828         if (_res_constr.datalen > 0)
12829                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKEvent), "LDKCVec_EventZ Elements");
12830         else
12831                 _res_constr.data = NULL;
12832         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
12833         for (size_t h = 0; h < _res_constr.datalen; h++) {
12834                 int64_t _res_conv_7 = _res_vals[h];
12835                 LDKEvent _res_conv_7_conv = *(LDKEvent*)(((uint64_t)_res_conv_7) & ~1);
12836                 FREE((void*)_res_conv_7);
12837                 _res_constr.data[h] = _res_conv_7_conv;
12838         }
12839         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
12840         CVec_EventZ_free(_res_constr);
12841 }
12842
12843 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TransactionZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
12844         LDKCVec_TransactionZ _res_constr;
12845         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
12846         if (_res_constr.datalen > 0)
12847                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTransaction), "LDKCVec_TransactionZ Elements");
12848         else
12849                 _res_constr.data = NULL;
12850         for (size_t i = 0; i < _res_constr.datalen; i++) {
12851                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
12852                 LDKTransaction _res_conv_8_ref;
12853                 _res_conv_8_ref.datalen = (*env)->GetArrayLength(env, _res_conv_8);
12854                 _res_conv_8_ref.data = MALLOC(_res_conv_8_ref.datalen, "LDKTransaction Bytes");
12855                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, _res_conv_8_ref.datalen, _res_conv_8_ref.data);
12856                 _res_conv_8_ref.data_is_owned = true;
12857                 _res_constr.data[i] = _res_conv_8_ref;
12858         }
12859         CVec_TransactionZ_free(_res_constr);
12860 }
12861
12862 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12863         LDKC2Tuple_u32TxOutZ* orig_conv = (LDKC2Tuple_u32TxOutZ*)(orig & ~1);
12864         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
12865         *ret_conv = C2Tuple_u32TxOutZ_clone(orig_conv);
12866         return ((uint64_t)ret_conv);
12867 }
12868
12869 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1new(JNIEnv *env, jclass clz, int32_t a, int64_t b) {
12870         LDKTxOut b_conv = *(LDKTxOut*)(((uint64_t)b) & ~1);
12871         b_conv = TxOut_clone((LDKTxOut*)(((uint64_t)b) & ~1));
12872         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
12873         *ret_conv = C2Tuple_u32TxOutZ_new(a, b_conv);
12874         return ((uint64_t)ret_conv);
12875 }
12876
12877 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12878         if ((_res & 1) != 0) return;
12879         LDKC2Tuple_u32TxOutZ _res_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)_res) & ~1);
12880         FREE((void*)_res);
12881         C2Tuple_u32TxOutZ_free(_res_conv);
12882 }
12883
12884 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1u32TxOutZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
12885         LDKCVec_C2Tuple_u32TxOutZZ _res_constr;
12886         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
12887         if (_res_constr.datalen > 0)
12888                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
12889         else
12890                 _res_constr.data = NULL;
12891         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
12892         for (size_t u = 0; u < _res_constr.datalen; u++) {
12893                 int64_t _res_conv_20 = _res_vals[u];
12894                 LDKC2Tuple_u32TxOutZ _res_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)_res_conv_20) & ~1);
12895                 FREE((void*)_res_conv_20);
12896                 _res_constr.data[u] = _res_conv_20_conv;
12897         }
12898         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
12899         CVec_C2Tuple_u32TxOutZZ_free(_res_constr);
12900 }
12901
12902 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12903         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(orig & ~1);
12904         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
12905         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(orig_conv);
12906         return ((uint64_t)ret_conv);
12907 }
12908
12909 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
12910         LDKThirtyTwoBytes a_ref;
12911         CHECK((*env)->GetArrayLength(env, a) == 32);
12912         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
12913         LDKCVec_C2Tuple_u32TxOutZZ b_constr;
12914         b_constr.datalen = (*env)->GetArrayLength(env, b);
12915         if (b_constr.datalen > 0)
12916                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
12917         else
12918                 b_constr.data = NULL;
12919         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
12920         for (size_t u = 0; u < b_constr.datalen; u++) {
12921                 int64_t b_conv_20 = b_vals[u];
12922                 LDKC2Tuple_u32TxOutZ b_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_20) & ~1);
12923                 b_conv_20_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_20) & ~1));
12924                 b_constr.data[u] = b_conv_20_conv;
12925         }
12926         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
12927         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
12928         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(a_ref, b_constr);
12929         return ((uint64_t)ret_conv);
12930 }
12931
12932 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12933         if ((_res & 1) != 0) return;
12934         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)_res) & ~1);
12935         FREE((void*)_res);
12936         C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(_res_conv);
12937 }
12938
12939 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
12940         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ _res_constr;
12941         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
12942         if (_res_constr.datalen > 0)
12943                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Elements");
12944         else
12945                 _res_constr.data = NULL;
12946         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
12947         for (size_t n = 0; n < _res_constr.datalen; n++) {
12948                 int64_t _res_conv_39 = _res_vals[n];
12949                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv_39_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)_res_conv_39) & ~1);
12950                 FREE((void*)_res_conv_39);
12951                 _res_constr.data[n] = _res_conv_39_conv;
12952         }
12953         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
12954         CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(_res_constr);
12955 }
12956
12957 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1BalanceZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
12958         LDKCVec_BalanceZ _res_constr;
12959         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
12960         if (_res_constr.datalen > 0)
12961                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKBalance), "LDKCVec_BalanceZ Elements");
12962         else
12963                 _res_constr.data = NULL;
12964         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
12965         for (size_t j = 0; j < _res_constr.datalen; j++) {
12966                 int64_t _res_conv_9 = _res_vals[j];
12967                 LDKBalance _res_conv_9_conv = *(LDKBalance*)(((uint64_t)_res_conv_9) & ~1);
12968                 FREE((void*)_res_conv_9);
12969                 _res_constr.data[j] = _res_conv_9_conv;
12970         }
12971         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
12972         CVec_BalanceZ_free(_res_constr);
12973 }
12974
12975 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12976         LDKC2Tuple_BlockHashChannelMonitorZ o_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)o) & ~1);
12977         o_conv = C2Tuple_BlockHashChannelMonitorZ_clone((LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)o) & ~1));
12978         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
12979         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(o_conv);
12980         return (uint64_t)ret_conv;
12981 }
12982
12983 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12984         LDKDecodeError e_conv;
12985         e_conv.inner = (void*)(e & (~1));
12986         e_conv.is_owned = (e & 1) || (e == 0);
12987         e_conv = DecodeError_clone(&e_conv);
12988         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
12989         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(e_conv);
12990         return (uint64_t)ret_conv;
12991 }
12992
12993 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12994         if ((_res & 1) != 0) return;
12995         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(((uint64_t)_res) & ~1);
12996         FREE((void*)_res);
12997         CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(_res_conv);
12998 }
12999
13000 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13001         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* orig_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(orig & ~1);
13002         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
13003         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone(orig_conv);
13004         return (uint64_t)ret_conv;
13005 }
13006
13007 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1ok(JNIEnv *env, jclass clz) {
13008         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
13009         *ret_conv = CResult_NoneLightningErrorZ_ok();
13010         return (uint64_t)ret_conv;
13011 }
13012
13013 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13014         LDKLightningError e_conv;
13015         e_conv.inner = (void*)(e & (~1));
13016         e_conv.is_owned = (e & 1) || (e == 0);
13017         e_conv = LightningError_clone(&e_conv);
13018         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
13019         *ret_conv = CResult_NoneLightningErrorZ_err(e_conv);
13020         return (uint64_t)ret_conv;
13021 }
13022
13023 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13024         if ((_res & 1) != 0) return;
13025         LDKCResult_NoneLightningErrorZ _res_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)_res) & ~1);
13026         FREE((void*)_res);
13027         CResult_NoneLightningErrorZ_free(_res_conv);
13028 }
13029
13030 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13031         LDKCResult_NoneLightningErrorZ* orig_conv = (LDKCResult_NoneLightningErrorZ*)(orig & ~1);
13032         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
13033         *ret_conv = CResult_NoneLightningErrorZ_clone(orig_conv);
13034         return (uint64_t)ret_conv;
13035 }
13036
13037 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13038         LDKC2Tuple_PublicKeyTypeZ* orig_conv = (LDKC2Tuple_PublicKeyTypeZ*)(orig & ~1);
13039         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
13040         *ret_conv = C2Tuple_PublicKeyTypeZ_clone(orig_conv);
13041         return ((uint64_t)ret_conv);
13042 }
13043
13044 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
13045         LDKPublicKey a_ref;
13046         CHECK((*env)->GetArrayLength(env, a) == 33);
13047         (*env)->GetByteArrayRegion(env, a, 0, 33, a_ref.compressed_form);
13048         LDKType b_conv = *(LDKType*)(((uint64_t)b) & ~1);
13049         if (b_conv.free == LDKType_JCalls_free) {
13050                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
13051                 LDKType_JCalls_cloned(&b_conv);
13052         }
13053         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
13054         *ret_conv = C2Tuple_PublicKeyTypeZ_new(a_ref, b_conv);
13055         return ((uint64_t)ret_conv);
13056 }
13057
13058 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13059         if ((_res & 1) != 0) return;
13060         LDKC2Tuple_PublicKeyTypeZ _res_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(((uint64_t)_res) & ~1);
13061         FREE((void*)_res);
13062         C2Tuple_PublicKeyTypeZ_free(_res_conv);
13063 }
13064
13065 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1PublicKeyTypeZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
13066         LDKCVec_C2Tuple_PublicKeyTypeZZ _res_constr;
13067         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
13068         if (_res_constr.datalen > 0)
13069                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ Elements");
13070         else
13071                 _res_constr.data = NULL;
13072         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
13073         for (size_t z = 0; z < _res_constr.datalen; z++) {
13074                 int64_t _res_conv_25 = _res_vals[z];
13075                 LDKC2Tuple_PublicKeyTypeZ _res_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(((uint64_t)_res_conv_25) & ~1);
13076                 FREE((void*)_res_conv_25);
13077                 _res_constr.data[z] = _res_conv_25_conv;
13078         }
13079         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
13080         CVec_C2Tuple_PublicKeyTypeZZ_free(_res_constr);
13081 }
13082
13083 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1ok(JNIEnv *env, jclass clz, jboolean o) {
13084         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
13085         *ret_conv = CResult_boolLightningErrorZ_ok(o);
13086         return (uint64_t)ret_conv;
13087 }
13088
13089 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13090         LDKLightningError e_conv;
13091         e_conv.inner = (void*)(e & (~1));
13092         e_conv.is_owned = (e & 1) || (e == 0);
13093         e_conv = LightningError_clone(&e_conv);
13094         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
13095         *ret_conv = CResult_boolLightningErrorZ_err(e_conv);
13096         return (uint64_t)ret_conv;
13097 }
13098
13099 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13100         if ((_res & 1) != 0) return;
13101         LDKCResult_boolLightningErrorZ _res_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)_res) & ~1);
13102         FREE((void*)_res);
13103         CResult_boolLightningErrorZ_free(_res_conv);
13104 }
13105
13106 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13107         LDKCResult_boolLightningErrorZ* orig_conv = (LDKCResult_boolLightningErrorZ*)(orig & ~1);
13108         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
13109         *ret_conv = CResult_boolLightningErrorZ_clone(orig_conv);
13110         return (uint64_t)ret_conv;
13111 }
13112
13113 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13114         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* orig_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(orig & ~1);
13115         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
13116         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(orig_conv);
13117         return ((uint64_t)ret_conv);
13118 }
13119
13120 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) {
13121         LDKChannelAnnouncement a_conv;
13122         a_conv.inner = (void*)(a & (~1));
13123         a_conv.is_owned = (a & 1) || (a == 0);
13124         a_conv = ChannelAnnouncement_clone(&a_conv);
13125         LDKChannelUpdate b_conv;
13126         b_conv.inner = (void*)(b & (~1));
13127         b_conv.is_owned = (b & 1) || (b == 0);
13128         b_conv = ChannelUpdate_clone(&b_conv);
13129         LDKChannelUpdate c_conv;
13130         c_conv.inner = (void*)(c & (~1));
13131         c_conv.is_owned = (c & 1) || (c == 0);
13132         c_conv = ChannelUpdate_clone(&c_conv);
13133         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
13134         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(a_conv, b_conv, c_conv);
13135         return ((uint64_t)ret_conv);
13136 }
13137
13138 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13139         if ((_res & 1) != 0) return;
13140         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)_res) & ~1);
13141         FREE((void*)_res);
13142         C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(_res_conv);
13143 }
13144
13145 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
13146         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ _res_constr;
13147         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
13148         if (_res_constr.datalen > 0)
13149                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
13150         else
13151                 _res_constr.data = NULL;
13152         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
13153         for (size_t h = 0; h < _res_constr.datalen; h++) {
13154                 int64_t _res_conv_59 = _res_vals[h];
13155                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv_59_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)_res_conv_59) & ~1);
13156                 FREE((void*)_res_conv_59);
13157                 _res_constr.data[h] = _res_conv_59_conv;
13158         }
13159         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
13160         CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(_res_constr);
13161 }
13162
13163 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1NodeAnnouncementZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
13164         LDKCVec_NodeAnnouncementZ _res_constr;
13165         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
13166         if (_res_constr.datalen > 0)
13167                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
13168         else
13169                 _res_constr.data = NULL;
13170         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
13171         for (size_t s = 0; s < _res_constr.datalen; s++) {
13172                 int64_t _res_conv_18 = _res_vals[s];
13173                 LDKNodeAnnouncement _res_conv_18_conv;
13174                 _res_conv_18_conv.inner = (void*)(_res_conv_18 & (~1));
13175                 _res_conv_18_conv.is_owned = (_res_conv_18 & 1) || (_res_conv_18 == 0);
13176                 _res_constr.data[s] = _res_conv_18_conv;
13177         }
13178         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
13179         CVec_NodeAnnouncementZ_free(_res_constr);
13180 }
13181
13182 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PublicKeyZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
13183         LDKCVec_PublicKeyZ _res_constr;
13184         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
13185         if (_res_constr.datalen > 0)
13186                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
13187         else
13188                 _res_constr.data = NULL;
13189         for (size_t i = 0; i < _res_constr.datalen; i++) {
13190                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
13191                 LDKPublicKey _res_conv_8_ref;
13192                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 33);
13193                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 33, _res_conv_8_ref.compressed_form);
13194                 _res_constr.data[i] = _res_conv_8_ref;
13195         }
13196         CVec_PublicKeyZ_free(_res_constr);
13197 }
13198
13199 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
13200         LDKCVec_u8Z o_ref;
13201         o_ref.datalen = (*env)->GetArrayLength(env, o);
13202         o_ref.data = MALLOC(o_ref.datalen, "LDKCVec_u8Z Bytes");
13203         (*env)->GetByteArrayRegion(env, o, 0, o_ref.datalen, o_ref.data);
13204         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
13205         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_ok(o_ref);
13206         return (uint64_t)ret_conv;
13207 }
13208
13209 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13210         LDKPeerHandleError e_conv;
13211         e_conv.inner = (void*)(e & (~1));
13212         e_conv.is_owned = (e & 1) || (e == 0);
13213         e_conv = PeerHandleError_clone(&e_conv);
13214         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
13215         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_err(e_conv);
13216         return (uint64_t)ret_conv;
13217 }
13218
13219 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13220         if ((_res & 1) != 0) return;
13221         LDKCResult_CVec_u8ZPeerHandleErrorZ _res_conv = *(LDKCResult_CVec_u8ZPeerHandleErrorZ*)(((uint64_t)_res) & ~1);
13222         FREE((void*)_res);
13223         CResult_CVec_u8ZPeerHandleErrorZ_free(_res_conv);
13224 }
13225
13226 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13227         LDKCResult_CVec_u8ZPeerHandleErrorZ* orig_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(orig & ~1);
13228         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
13229         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(orig_conv);
13230         return (uint64_t)ret_conv;
13231 }
13232
13233 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1ok(JNIEnv *env, jclass clz) {
13234         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
13235         *ret_conv = CResult_NonePeerHandleErrorZ_ok();
13236         return (uint64_t)ret_conv;
13237 }
13238
13239 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13240         LDKPeerHandleError e_conv;
13241         e_conv.inner = (void*)(e & (~1));
13242         e_conv.is_owned = (e & 1) || (e == 0);
13243         e_conv = PeerHandleError_clone(&e_conv);
13244         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
13245         *ret_conv = CResult_NonePeerHandleErrorZ_err(e_conv);
13246         return (uint64_t)ret_conv;
13247 }
13248
13249 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13250         if ((_res & 1) != 0) return;
13251         LDKCResult_NonePeerHandleErrorZ _res_conv = *(LDKCResult_NonePeerHandleErrorZ*)(((uint64_t)_res) & ~1);
13252         FREE((void*)_res);
13253         CResult_NonePeerHandleErrorZ_free(_res_conv);
13254 }
13255
13256 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13257         LDKCResult_NonePeerHandleErrorZ* orig_conv = (LDKCResult_NonePeerHandleErrorZ*)(orig & ~1);
13258         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
13259         *ret_conv = CResult_NonePeerHandleErrorZ_clone(orig_conv);
13260         return (uint64_t)ret_conv;
13261 }
13262
13263 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1ok(JNIEnv *env, jclass clz, jboolean o) {
13264         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
13265         *ret_conv = CResult_boolPeerHandleErrorZ_ok(o);
13266         return (uint64_t)ret_conv;
13267 }
13268
13269 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13270         LDKPeerHandleError e_conv;
13271         e_conv.inner = (void*)(e & (~1));
13272         e_conv.is_owned = (e & 1) || (e == 0);
13273         e_conv = PeerHandleError_clone(&e_conv);
13274         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
13275         *ret_conv = CResult_boolPeerHandleErrorZ_err(e_conv);
13276         return (uint64_t)ret_conv;
13277 }
13278
13279 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13280         if ((_res & 1) != 0) return;
13281         LDKCResult_boolPeerHandleErrorZ _res_conv = *(LDKCResult_boolPeerHandleErrorZ*)(((uint64_t)_res) & ~1);
13282         FREE((void*)_res);
13283         CResult_boolPeerHandleErrorZ_free(_res_conv);
13284 }
13285
13286 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13287         LDKCResult_boolPeerHandleErrorZ* orig_conv = (LDKCResult_boolPeerHandleErrorZ*)(orig & ~1);
13288         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
13289         *ret_conv = CResult_boolPeerHandleErrorZ_clone(orig_conv);
13290         return (uint64_t)ret_conv;
13291 }
13292
13293 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1AccessZ_1some(JNIEnv *env, jclass clz, int64_t o) {
13294         LDKAccess o_conv = *(LDKAccess*)(((uint64_t)o) & ~1);
13295         if (o_conv.free == LDKAccess_JCalls_free) {
13296                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
13297                 LDKAccess_JCalls_cloned(&o_conv);
13298         }
13299         LDKCOption_AccessZ *ret_copy = MALLOC(sizeof(LDKCOption_AccessZ), "LDKCOption_AccessZ");
13300         *ret_copy = COption_AccessZ_some(o_conv);
13301         uint64_t ret_ref = (uint64_t)ret_copy;
13302         return ret_ref;
13303 }
13304
13305 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1AccessZ_1none(JNIEnv *env, jclass clz) {
13306         LDKCOption_AccessZ *ret_copy = MALLOC(sizeof(LDKCOption_AccessZ), "LDKCOption_AccessZ");
13307         *ret_copy = COption_AccessZ_none();
13308         uint64_t ret_ref = (uint64_t)ret_copy;
13309         return ret_ref;
13310 }
13311
13312 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1AccessZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13313         if ((_res & 1) != 0) return;
13314         LDKCOption_AccessZ _res_conv = *(LDKCOption_AccessZ*)(((uint64_t)_res) & ~1);
13315         FREE((void*)_res);
13316         COption_AccessZ_free(_res_conv);
13317 }
13318
13319 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DirectionalChannelInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13320         LDKDirectionalChannelInfo o_conv;
13321         o_conv.inner = (void*)(o & (~1));
13322         o_conv.is_owned = (o & 1) || (o == 0);
13323         o_conv = DirectionalChannelInfo_clone(&o_conv);
13324         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
13325         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_ok(o_conv);
13326         return (uint64_t)ret_conv;
13327 }
13328
13329 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DirectionalChannelInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13330         LDKDecodeError e_conv;
13331         e_conv.inner = (void*)(e & (~1));
13332         e_conv.is_owned = (e & 1) || (e == 0);
13333         e_conv = DecodeError_clone(&e_conv);
13334         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
13335         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_err(e_conv);
13336         return (uint64_t)ret_conv;
13337 }
13338
13339 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1DirectionalChannelInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13340         if ((_res & 1) != 0) return;
13341         LDKCResult_DirectionalChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
13342         FREE((void*)_res);
13343         CResult_DirectionalChannelInfoDecodeErrorZ_free(_res_conv);
13344 }
13345
13346 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DirectionalChannelInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13347         LDKCResult_DirectionalChannelInfoDecodeErrorZ* orig_conv = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(orig & ~1);
13348         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
13349         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_clone(orig_conv);
13350         return (uint64_t)ret_conv;
13351 }
13352
13353 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13354         LDKChannelInfo o_conv;
13355         o_conv.inner = (void*)(o & (~1));
13356         o_conv.is_owned = (o & 1) || (o == 0);
13357         o_conv = ChannelInfo_clone(&o_conv);
13358         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
13359         *ret_conv = CResult_ChannelInfoDecodeErrorZ_ok(o_conv);
13360         return (uint64_t)ret_conv;
13361 }
13362
13363 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13364         LDKDecodeError e_conv;
13365         e_conv.inner = (void*)(e & (~1));
13366         e_conv.is_owned = (e & 1) || (e == 0);
13367         e_conv = DecodeError_clone(&e_conv);
13368         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
13369         *ret_conv = CResult_ChannelInfoDecodeErrorZ_err(e_conv);
13370         return (uint64_t)ret_conv;
13371 }
13372
13373 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13374         if ((_res & 1) != 0) return;
13375         LDKCResult_ChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
13376         FREE((void*)_res);
13377         CResult_ChannelInfoDecodeErrorZ_free(_res_conv);
13378 }
13379
13380 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13381         LDKCResult_ChannelInfoDecodeErrorZ* orig_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(orig & ~1);
13382         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
13383         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(orig_conv);
13384         return (uint64_t)ret_conv;
13385 }
13386
13387 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13388         LDKRoutingFees o_conv;
13389         o_conv.inner = (void*)(o & (~1));
13390         o_conv.is_owned = (o & 1) || (o == 0);
13391         o_conv = RoutingFees_clone(&o_conv);
13392         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
13393         *ret_conv = CResult_RoutingFeesDecodeErrorZ_ok(o_conv);
13394         return (uint64_t)ret_conv;
13395 }
13396
13397 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13398         LDKDecodeError e_conv;
13399         e_conv.inner = (void*)(e & (~1));
13400         e_conv.is_owned = (e & 1) || (e == 0);
13401         e_conv = DecodeError_clone(&e_conv);
13402         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
13403         *ret_conv = CResult_RoutingFeesDecodeErrorZ_err(e_conv);
13404         return (uint64_t)ret_conv;
13405 }
13406
13407 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13408         if ((_res & 1) != 0) return;
13409         LDKCResult_RoutingFeesDecodeErrorZ _res_conv = *(LDKCResult_RoutingFeesDecodeErrorZ*)(((uint64_t)_res) & ~1);
13410         FREE((void*)_res);
13411         CResult_RoutingFeesDecodeErrorZ_free(_res_conv);
13412 }
13413
13414 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13415         LDKCResult_RoutingFeesDecodeErrorZ* orig_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(orig & ~1);
13416         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
13417         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(orig_conv);
13418         return (uint64_t)ret_conv;
13419 }
13420
13421 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13422         LDKNodeAnnouncementInfo o_conv;
13423         o_conv.inner = (void*)(o & (~1));
13424         o_conv.is_owned = (o & 1) || (o == 0);
13425         o_conv = NodeAnnouncementInfo_clone(&o_conv);
13426         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
13427         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_ok(o_conv);
13428         return (uint64_t)ret_conv;
13429 }
13430
13431 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13432         LDKDecodeError e_conv;
13433         e_conv.inner = (void*)(e & (~1));
13434         e_conv.is_owned = (e & 1) || (e == 0);
13435         e_conv = DecodeError_clone(&e_conv);
13436         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
13437         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_err(e_conv);
13438         return (uint64_t)ret_conv;
13439 }
13440
13441 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13442         if ((_res & 1) != 0) return;
13443         LDKCResult_NodeAnnouncementInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
13444         FREE((void*)_res);
13445         CResult_NodeAnnouncementInfoDecodeErrorZ_free(_res_conv);
13446 }
13447
13448 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13449         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(orig & ~1);
13450         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
13451         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(orig_conv);
13452         return (uint64_t)ret_conv;
13453 }
13454
13455 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u64Z_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
13456         LDKCVec_u64Z _res_constr;
13457         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
13458         if (_res_constr.datalen > 0)
13459                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
13460         else
13461                 _res_constr.data = NULL;
13462         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
13463         for (size_t g = 0; g < _res_constr.datalen; g++) {
13464                 int64_t _res_conv_6 = _res_vals[g];
13465                 _res_constr.data[g] = _res_conv_6;
13466         }
13467         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
13468         CVec_u64Z_free(_res_constr);
13469 }
13470
13471 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13472         LDKNodeInfo o_conv;
13473         o_conv.inner = (void*)(o & (~1));
13474         o_conv.is_owned = (o & 1) || (o == 0);
13475         o_conv = NodeInfo_clone(&o_conv);
13476         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
13477         *ret_conv = CResult_NodeInfoDecodeErrorZ_ok(o_conv);
13478         return (uint64_t)ret_conv;
13479 }
13480
13481 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13482         LDKDecodeError e_conv;
13483         e_conv.inner = (void*)(e & (~1));
13484         e_conv.is_owned = (e & 1) || (e == 0);
13485         e_conv = DecodeError_clone(&e_conv);
13486         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
13487         *ret_conv = CResult_NodeInfoDecodeErrorZ_err(e_conv);
13488         return (uint64_t)ret_conv;
13489 }
13490
13491 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13492         if ((_res & 1) != 0) return;
13493         LDKCResult_NodeInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
13494         FREE((void*)_res);
13495         CResult_NodeInfoDecodeErrorZ_free(_res_conv);
13496 }
13497
13498 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13499         LDKCResult_NodeInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(orig & ~1);
13500         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
13501         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(orig_conv);
13502         return (uint64_t)ret_conv;
13503 }
13504
13505 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13506         LDKNetworkGraph o_conv;
13507         o_conv.inner = (void*)(o & (~1));
13508         o_conv.is_owned = (o & 1) || (o == 0);
13509         o_conv = NetworkGraph_clone(&o_conv);
13510         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
13511         *ret_conv = CResult_NetworkGraphDecodeErrorZ_ok(o_conv);
13512         return (uint64_t)ret_conv;
13513 }
13514
13515 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13516         LDKDecodeError e_conv;
13517         e_conv.inner = (void*)(e & (~1));
13518         e_conv.is_owned = (e & 1) || (e == 0);
13519         e_conv = DecodeError_clone(&e_conv);
13520         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
13521         *ret_conv = CResult_NetworkGraphDecodeErrorZ_err(e_conv);
13522         return (uint64_t)ret_conv;
13523 }
13524
13525 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13526         if ((_res & 1) != 0) return;
13527         LDKCResult_NetworkGraphDecodeErrorZ _res_conv = *(LDKCResult_NetworkGraphDecodeErrorZ*)(((uint64_t)_res) & ~1);
13528         FREE((void*)_res);
13529         CResult_NetworkGraphDecodeErrorZ_free(_res_conv);
13530 }
13531
13532 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13533         LDKCResult_NetworkGraphDecodeErrorZ* orig_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(orig & ~1);
13534         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
13535         *ret_conv = CResult_NetworkGraphDecodeErrorZ_clone(orig_conv);
13536         return (uint64_t)ret_conv;
13537 }
13538
13539 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressu8Z_1ok(JNIEnv *env, jclass clz, int64_t o) {
13540         LDKNetAddress o_conv = *(LDKNetAddress*)(((uint64_t)o) & ~1);
13541         o_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)o) & ~1));
13542         LDKCResult_NetAddressu8Z* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
13543         *ret_conv = CResult_NetAddressu8Z_ok(o_conv);
13544         return (uint64_t)ret_conv;
13545 }
13546
13547 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressu8Z_1err(JNIEnv *env, jclass clz, int8_t e) {
13548         LDKCResult_NetAddressu8Z* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
13549         *ret_conv = CResult_NetAddressu8Z_err(e);
13550         return (uint64_t)ret_conv;
13551 }
13552
13553 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressu8Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
13554         if ((_res & 1) != 0) return;
13555         LDKCResult_NetAddressu8Z _res_conv = *(LDKCResult_NetAddressu8Z*)(((uint64_t)_res) & ~1);
13556         FREE((void*)_res);
13557         CResult_NetAddressu8Z_free(_res_conv);
13558 }
13559
13560 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressu8Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13561         LDKCResult_NetAddressu8Z* orig_conv = (LDKCResult_NetAddressu8Z*)(orig & ~1);
13562         LDKCResult_NetAddressu8Z* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
13563         *ret_conv = CResult_NetAddressu8Z_clone(orig_conv);
13564         return (uint64_t)ret_conv;
13565 }
13566
13567 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CResult_1NetAddressu8ZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13568         LDKCResult_NetAddressu8Z o_conv = *(LDKCResult_NetAddressu8Z*)(((uint64_t)o) & ~1);
13569         o_conv = CResult_NetAddressu8Z_clone((LDKCResult_NetAddressu8Z*)(((uint64_t)o) & ~1));
13570         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
13571         *ret_conv = CResult_CResult_NetAddressu8ZDecodeErrorZ_ok(o_conv);
13572         return (uint64_t)ret_conv;
13573 }
13574
13575 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CResult_1NetAddressu8ZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13576         LDKDecodeError e_conv;
13577         e_conv.inner = (void*)(e & (~1));
13578         e_conv.is_owned = (e & 1) || (e == 0);
13579         e_conv = DecodeError_clone(&e_conv);
13580         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
13581         *ret_conv = CResult_CResult_NetAddressu8ZDecodeErrorZ_err(e_conv);
13582         return (uint64_t)ret_conv;
13583 }
13584
13585 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CResult_1NetAddressu8ZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13586         if ((_res & 1) != 0) return;
13587         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ _res_conv = *(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(((uint64_t)_res) & ~1);
13588         FREE((void*)_res);
13589         CResult_CResult_NetAddressu8ZDecodeErrorZ_free(_res_conv);
13590 }
13591
13592 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CResult_1NetAddressu8ZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13593         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* orig_conv = (LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(orig & ~1);
13594         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
13595         *ret_conv = CResult_CResult_NetAddressu8ZDecodeErrorZ_clone(orig_conv);
13596         return (uint64_t)ret_conv;
13597 }
13598
13599 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13600         LDKNetAddress o_conv = *(LDKNetAddress*)(((uint64_t)o) & ~1);
13601         o_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)o) & ~1));
13602         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
13603         *ret_conv = CResult_NetAddressDecodeErrorZ_ok(o_conv);
13604         return (uint64_t)ret_conv;
13605 }
13606
13607 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13608         LDKDecodeError e_conv;
13609         e_conv.inner = (void*)(e & (~1));
13610         e_conv.is_owned = (e & 1) || (e == 0);
13611         e_conv = DecodeError_clone(&e_conv);
13612         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
13613         *ret_conv = CResult_NetAddressDecodeErrorZ_err(e_conv);
13614         return (uint64_t)ret_conv;
13615 }
13616
13617 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13618         if ((_res & 1) != 0) return;
13619         LDKCResult_NetAddressDecodeErrorZ _res_conv = *(LDKCResult_NetAddressDecodeErrorZ*)(((uint64_t)_res) & ~1);
13620         FREE((void*)_res);
13621         CResult_NetAddressDecodeErrorZ_free(_res_conv);
13622 }
13623
13624 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13625         LDKCResult_NetAddressDecodeErrorZ* orig_conv = (LDKCResult_NetAddressDecodeErrorZ*)(orig & ~1);
13626         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
13627         *ret_conv = CResult_NetAddressDecodeErrorZ_clone(orig_conv);
13628         return (uint64_t)ret_conv;
13629 }
13630
13631 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateAddHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
13632         LDKCVec_UpdateAddHTLCZ _res_constr;
13633         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
13634         if (_res_constr.datalen > 0)
13635                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
13636         else
13637                 _res_constr.data = NULL;
13638         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
13639         for (size_t p = 0; p < _res_constr.datalen; p++) {
13640                 int64_t _res_conv_15 = _res_vals[p];
13641                 LDKUpdateAddHTLC _res_conv_15_conv;
13642                 _res_conv_15_conv.inner = (void*)(_res_conv_15 & (~1));
13643                 _res_conv_15_conv.is_owned = (_res_conv_15 & 1) || (_res_conv_15 == 0);
13644                 _res_constr.data[p] = _res_conv_15_conv;
13645         }
13646         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
13647         CVec_UpdateAddHTLCZ_free(_res_constr);
13648 }
13649
13650 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFulfillHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
13651         LDKCVec_UpdateFulfillHTLCZ _res_constr;
13652         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
13653         if (_res_constr.datalen > 0)
13654                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
13655         else
13656                 _res_constr.data = NULL;
13657         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
13658         for (size_t t = 0; t < _res_constr.datalen; t++) {
13659                 int64_t _res_conv_19 = _res_vals[t];
13660                 LDKUpdateFulfillHTLC _res_conv_19_conv;
13661                 _res_conv_19_conv.inner = (void*)(_res_conv_19 & (~1));
13662                 _res_conv_19_conv.is_owned = (_res_conv_19 & 1) || (_res_conv_19 == 0);
13663                 _res_constr.data[t] = _res_conv_19_conv;
13664         }
13665         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
13666         CVec_UpdateFulfillHTLCZ_free(_res_constr);
13667 }
13668
13669 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFailHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
13670         LDKCVec_UpdateFailHTLCZ _res_constr;
13671         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
13672         if (_res_constr.datalen > 0)
13673                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
13674         else
13675                 _res_constr.data = NULL;
13676         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
13677         for (size_t q = 0; q < _res_constr.datalen; q++) {
13678                 int64_t _res_conv_16 = _res_vals[q];
13679                 LDKUpdateFailHTLC _res_conv_16_conv;
13680                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
13681                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
13682                 _res_constr.data[q] = _res_conv_16_conv;
13683         }
13684         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
13685         CVec_UpdateFailHTLCZ_free(_res_constr);
13686 }
13687
13688 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFailMalformedHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
13689         LDKCVec_UpdateFailMalformedHTLCZ _res_constr;
13690         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
13691         if (_res_constr.datalen > 0)
13692                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
13693         else
13694                 _res_constr.data = NULL;
13695         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
13696         for (size_t z = 0; z < _res_constr.datalen; z++) {
13697                 int64_t _res_conv_25 = _res_vals[z];
13698                 LDKUpdateFailMalformedHTLC _res_conv_25_conv;
13699                 _res_conv_25_conv.inner = (void*)(_res_conv_25 & (~1));
13700                 _res_conv_25_conv.is_owned = (_res_conv_25 & 1) || (_res_conv_25 == 0);
13701                 _res_constr.data[z] = _res_conv_25_conv;
13702         }
13703         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
13704         CVec_UpdateFailMalformedHTLCZ_free(_res_constr);
13705 }
13706
13707 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13708         LDKAcceptChannel o_conv;
13709         o_conv.inner = (void*)(o & (~1));
13710         o_conv.is_owned = (o & 1) || (o == 0);
13711         o_conv = AcceptChannel_clone(&o_conv);
13712         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
13713         *ret_conv = CResult_AcceptChannelDecodeErrorZ_ok(o_conv);
13714         return (uint64_t)ret_conv;
13715 }
13716
13717 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13718         LDKDecodeError e_conv;
13719         e_conv.inner = (void*)(e & (~1));
13720         e_conv.is_owned = (e & 1) || (e == 0);
13721         e_conv = DecodeError_clone(&e_conv);
13722         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
13723         *ret_conv = CResult_AcceptChannelDecodeErrorZ_err(e_conv);
13724         return (uint64_t)ret_conv;
13725 }
13726
13727 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13728         if ((_res & 1) != 0) return;
13729         LDKCResult_AcceptChannelDecodeErrorZ _res_conv = *(LDKCResult_AcceptChannelDecodeErrorZ*)(((uint64_t)_res) & ~1);
13730         FREE((void*)_res);
13731         CResult_AcceptChannelDecodeErrorZ_free(_res_conv);
13732 }
13733
13734 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13735         LDKCResult_AcceptChannelDecodeErrorZ* orig_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(orig & ~1);
13736         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
13737         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(orig_conv);
13738         return (uint64_t)ret_conv;
13739 }
13740
13741 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13742         LDKAnnouncementSignatures o_conv;
13743         o_conv.inner = (void*)(o & (~1));
13744         o_conv.is_owned = (o & 1) || (o == 0);
13745         o_conv = AnnouncementSignatures_clone(&o_conv);
13746         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
13747         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_ok(o_conv);
13748         return (uint64_t)ret_conv;
13749 }
13750
13751 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13752         LDKDecodeError e_conv;
13753         e_conv.inner = (void*)(e & (~1));
13754         e_conv.is_owned = (e & 1) || (e == 0);
13755         e_conv = DecodeError_clone(&e_conv);
13756         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
13757         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_err(e_conv);
13758         return (uint64_t)ret_conv;
13759 }
13760
13761 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13762         if ((_res & 1) != 0) return;
13763         LDKCResult_AnnouncementSignaturesDecodeErrorZ _res_conv = *(LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
13764         FREE((void*)_res);
13765         CResult_AnnouncementSignaturesDecodeErrorZ_free(_res_conv);
13766 }
13767
13768 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13769         LDKCResult_AnnouncementSignaturesDecodeErrorZ* orig_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(orig & ~1);
13770         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
13771         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(orig_conv);
13772         return (uint64_t)ret_conv;
13773 }
13774
13775 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13776         LDKChannelReestablish o_conv;
13777         o_conv.inner = (void*)(o & (~1));
13778         o_conv.is_owned = (o & 1) || (o == 0);
13779         o_conv = ChannelReestablish_clone(&o_conv);
13780         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
13781         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_ok(o_conv);
13782         return (uint64_t)ret_conv;
13783 }
13784
13785 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13786         LDKDecodeError e_conv;
13787         e_conv.inner = (void*)(e & (~1));
13788         e_conv.is_owned = (e & 1) || (e == 0);
13789         e_conv = DecodeError_clone(&e_conv);
13790         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
13791         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_err(e_conv);
13792         return (uint64_t)ret_conv;
13793 }
13794
13795 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13796         if ((_res & 1) != 0) return;
13797         LDKCResult_ChannelReestablishDecodeErrorZ _res_conv = *(LDKCResult_ChannelReestablishDecodeErrorZ*)(((uint64_t)_res) & ~1);
13798         FREE((void*)_res);
13799         CResult_ChannelReestablishDecodeErrorZ_free(_res_conv);
13800 }
13801
13802 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13803         LDKCResult_ChannelReestablishDecodeErrorZ* orig_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(orig & ~1);
13804         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
13805         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(orig_conv);
13806         return (uint64_t)ret_conv;
13807 }
13808
13809 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13810         LDKClosingSigned o_conv;
13811         o_conv.inner = (void*)(o & (~1));
13812         o_conv.is_owned = (o & 1) || (o == 0);
13813         o_conv = ClosingSigned_clone(&o_conv);
13814         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
13815         *ret_conv = CResult_ClosingSignedDecodeErrorZ_ok(o_conv);
13816         return (uint64_t)ret_conv;
13817 }
13818
13819 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13820         LDKDecodeError e_conv;
13821         e_conv.inner = (void*)(e & (~1));
13822         e_conv.is_owned = (e & 1) || (e == 0);
13823         e_conv = DecodeError_clone(&e_conv);
13824         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
13825         *ret_conv = CResult_ClosingSignedDecodeErrorZ_err(e_conv);
13826         return (uint64_t)ret_conv;
13827 }
13828
13829 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13830         if ((_res & 1) != 0) return;
13831         LDKCResult_ClosingSignedDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedDecodeErrorZ*)(((uint64_t)_res) & ~1);
13832         FREE((void*)_res);
13833         CResult_ClosingSignedDecodeErrorZ_free(_res_conv);
13834 }
13835
13836 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13837         LDKCResult_ClosingSignedDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(orig & ~1);
13838         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
13839         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(orig_conv);
13840         return (uint64_t)ret_conv;
13841 }
13842
13843 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13844         LDKClosingSignedFeeRange o_conv;
13845         o_conv.inner = (void*)(o & (~1));
13846         o_conv.is_owned = (o & 1) || (o == 0);
13847         o_conv = ClosingSignedFeeRange_clone(&o_conv);
13848         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
13849         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_ok(o_conv);
13850         return (uint64_t)ret_conv;
13851 }
13852
13853 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13854         LDKDecodeError e_conv;
13855         e_conv.inner = (void*)(e & (~1));
13856         e_conv.is_owned = (e & 1) || (e == 0);
13857         e_conv = DecodeError_clone(&e_conv);
13858         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
13859         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_err(e_conv);
13860         return (uint64_t)ret_conv;
13861 }
13862
13863 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13864         if ((_res & 1) != 0) return;
13865         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(((uint64_t)_res) & ~1);
13866         FREE((void*)_res);
13867         CResult_ClosingSignedFeeRangeDecodeErrorZ_free(_res_conv);
13868 }
13869
13870 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13871         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(orig & ~1);
13872         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
13873         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(orig_conv);
13874         return (uint64_t)ret_conv;
13875 }
13876
13877 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13878         LDKCommitmentSigned o_conv;
13879         o_conv.inner = (void*)(o & (~1));
13880         o_conv.is_owned = (o & 1) || (o == 0);
13881         o_conv = CommitmentSigned_clone(&o_conv);
13882         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
13883         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_ok(o_conv);
13884         return (uint64_t)ret_conv;
13885 }
13886
13887 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13888         LDKDecodeError e_conv;
13889         e_conv.inner = (void*)(e & (~1));
13890         e_conv.is_owned = (e & 1) || (e == 0);
13891         e_conv = DecodeError_clone(&e_conv);
13892         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
13893         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_err(e_conv);
13894         return (uint64_t)ret_conv;
13895 }
13896
13897 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13898         if ((_res & 1) != 0) return;
13899         LDKCResult_CommitmentSignedDecodeErrorZ _res_conv = *(LDKCResult_CommitmentSignedDecodeErrorZ*)(((uint64_t)_res) & ~1);
13900         FREE((void*)_res);
13901         CResult_CommitmentSignedDecodeErrorZ_free(_res_conv);
13902 }
13903
13904 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13905         LDKCResult_CommitmentSignedDecodeErrorZ* orig_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(orig & ~1);
13906         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
13907         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(orig_conv);
13908         return (uint64_t)ret_conv;
13909 }
13910
13911 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13912         LDKFundingCreated o_conv;
13913         o_conv.inner = (void*)(o & (~1));
13914         o_conv.is_owned = (o & 1) || (o == 0);
13915         o_conv = FundingCreated_clone(&o_conv);
13916         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
13917         *ret_conv = CResult_FundingCreatedDecodeErrorZ_ok(o_conv);
13918         return (uint64_t)ret_conv;
13919 }
13920
13921 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13922         LDKDecodeError e_conv;
13923         e_conv.inner = (void*)(e & (~1));
13924         e_conv.is_owned = (e & 1) || (e == 0);
13925         e_conv = DecodeError_clone(&e_conv);
13926         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
13927         *ret_conv = CResult_FundingCreatedDecodeErrorZ_err(e_conv);
13928         return (uint64_t)ret_conv;
13929 }
13930
13931 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13932         if ((_res & 1) != 0) return;
13933         LDKCResult_FundingCreatedDecodeErrorZ _res_conv = *(LDKCResult_FundingCreatedDecodeErrorZ*)(((uint64_t)_res) & ~1);
13934         FREE((void*)_res);
13935         CResult_FundingCreatedDecodeErrorZ_free(_res_conv);
13936 }
13937
13938 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13939         LDKCResult_FundingCreatedDecodeErrorZ* orig_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(orig & ~1);
13940         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
13941         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(orig_conv);
13942         return (uint64_t)ret_conv;
13943 }
13944
13945 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13946         LDKFundingSigned o_conv;
13947         o_conv.inner = (void*)(o & (~1));
13948         o_conv.is_owned = (o & 1) || (o == 0);
13949         o_conv = FundingSigned_clone(&o_conv);
13950         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
13951         *ret_conv = CResult_FundingSignedDecodeErrorZ_ok(o_conv);
13952         return (uint64_t)ret_conv;
13953 }
13954
13955 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13956         LDKDecodeError e_conv;
13957         e_conv.inner = (void*)(e & (~1));
13958         e_conv.is_owned = (e & 1) || (e == 0);
13959         e_conv = DecodeError_clone(&e_conv);
13960         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
13961         *ret_conv = CResult_FundingSignedDecodeErrorZ_err(e_conv);
13962         return (uint64_t)ret_conv;
13963 }
13964
13965 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13966         if ((_res & 1) != 0) return;
13967         LDKCResult_FundingSignedDecodeErrorZ _res_conv = *(LDKCResult_FundingSignedDecodeErrorZ*)(((uint64_t)_res) & ~1);
13968         FREE((void*)_res);
13969         CResult_FundingSignedDecodeErrorZ_free(_res_conv);
13970 }
13971
13972 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13973         LDKCResult_FundingSignedDecodeErrorZ* orig_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(orig & ~1);
13974         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
13975         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(orig_conv);
13976         return (uint64_t)ret_conv;
13977 }
13978
13979 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13980         LDKFundingLocked o_conv;
13981         o_conv.inner = (void*)(o & (~1));
13982         o_conv.is_owned = (o & 1) || (o == 0);
13983         o_conv = FundingLocked_clone(&o_conv);
13984         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
13985         *ret_conv = CResult_FundingLockedDecodeErrorZ_ok(o_conv);
13986         return (uint64_t)ret_conv;
13987 }
13988
13989 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13990         LDKDecodeError e_conv;
13991         e_conv.inner = (void*)(e & (~1));
13992         e_conv.is_owned = (e & 1) || (e == 0);
13993         e_conv = DecodeError_clone(&e_conv);
13994         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
13995         *ret_conv = CResult_FundingLockedDecodeErrorZ_err(e_conv);
13996         return (uint64_t)ret_conv;
13997 }
13998
13999 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14000         if ((_res & 1) != 0) return;
14001         LDKCResult_FundingLockedDecodeErrorZ _res_conv = *(LDKCResult_FundingLockedDecodeErrorZ*)(((uint64_t)_res) & ~1);
14002         FREE((void*)_res);
14003         CResult_FundingLockedDecodeErrorZ_free(_res_conv);
14004 }
14005
14006 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14007         LDKCResult_FundingLockedDecodeErrorZ* orig_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(orig & ~1);
14008         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
14009         *ret_conv = CResult_FundingLockedDecodeErrorZ_clone(orig_conv);
14010         return (uint64_t)ret_conv;
14011 }
14012
14013 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14014         LDKInit o_conv;
14015         o_conv.inner = (void*)(o & (~1));
14016         o_conv.is_owned = (o & 1) || (o == 0);
14017         o_conv = Init_clone(&o_conv);
14018         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
14019         *ret_conv = CResult_InitDecodeErrorZ_ok(o_conv);
14020         return (uint64_t)ret_conv;
14021 }
14022
14023 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14024         LDKDecodeError e_conv;
14025         e_conv.inner = (void*)(e & (~1));
14026         e_conv.is_owned = (e & 1) || (e == 0);
14027         e_conv = DecodeError_clone(&e_conv);
14028         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
14029         *ret_conv = CResult_InitDecodeErrorZ_err(e_conv);
14030         return (uint64_t)ret_conv;
14031 }
14032
14033 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14034         if ((_res & 1) != 0) return;
14035         LDKCResult_InitDecodeErrorZ _res_conv = *(LDKCResult_InitDecodeErrorZ*)(((uint64_t)_res) & ~1);
14036         FREE((void*)_res);
14037         CResult_InitDecodeErrorZ_free(_res_conv);
14038 }
14039
14040 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14041         LDKCResult_InitDecodeErrorZ* orig_conv = (LDKCResult_InitDecodeErrorZ*)(orig & ~1);
14042         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
14043         *ret_conv = CResult_InitDecodeErrorZ_clone(orig_conv);
14044         return (uint64_t)ret_conv;
14045 }
14046
14047 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14048         LDKOpenChannel o_conv;
14049         o_conv.inner = (void*)(o & (~1));
14050         o_conv.is_owned = (o & 1) || (o == 0);
14051         o_conv = OpenChannel_clone(&o_conv);
14052         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
14053         *ret_conv = CResult_OpenChannelDecodeErrorZ_ok(o_conv);
14054         return (uint64_t)ret_conv;
14055 }
14056
14057 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14058         LDKDecodeError e_conv;
14059         e_conv.inner = (void*)(e & (~1));
14060         e_conv.is_owned = (e & 1) || (e == 0);
14061         e_conv = DecodeError_clone(&e_conv);
14062         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
14063         *ret_conv = CResult_OpenChannelDecodeErrorZ_err(e_conv);
14064         return (uint64_t)ret_conv;
14065 }
14066
14067 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14068         if ((_res & 1) != 0) return;
14069         LDKCResult_OpenChannelDecodeErrorZ _res_conv = *(LDKCResult_OpenChannelDecodeErrorZ*)(((uint64_t)_res) & ~1);
14070         FREE((void*)_res);
14071         CResult_OpenChannelDecodeErrorZ_free(_res_conv);
14072 }
14073
14074 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14075         LDKCResult_OpenChannelDecodeErrorZ* orig_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(orig & ~1);
14076         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
14077         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(orig_conv);
14078         return (uint64_t)ret_conv;
14079 }
14080
14081 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14082         LDKRevokeAndACK o_conv;
14083         o_conv.inner = (void*)(o & (~1));
14084         o_conv.is_owned = (o & 1) || (o == 0);
14085         o_conv = RevokeAndACK_clone(&o_conv);
14086         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
14087         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_ok(o_conv);
14088         return (uint64_t)ret_conv;
14089 }
14090
14091 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14092         LDKDecodeError e_conv;
14093         e_conv.inner = (void*)(e & (~1));
14094         e_conv.is_owned = (e & 1) || (e == 0);
14095         e_conv = DecodeError_clone(&e_conv);
14096         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
14097         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_err(e_conv);
14098         return (uint64_t)ret_conv;
14099 }
14100
14101 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14102         if ((_res & 1) != 0) return;
14103         LDKCResult_RevokeAndACKDecodeErrorZ _res_conv = *(LDKCResult_RevokeAndACKDecodeErrorZ*)(((uint64_t)_res) & ~1);
14104         FREE((void*)_res);
14105         CResult_RevokeAndACKDecodeErrorZ_free(_res_conv);
14106 }
14107
14108 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14109         LDKCResult_RevokeAndACKDecodeErrorZ* orig_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(orig & ~1);
14110         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
14111         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(orig_conv);
14112         return (uint64_t)ret_conv;
14113 }
14114
14115 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14116         LDKShutdown o_conv;
14117         o_conv.inner = (void*)(o & (~1));
14118         o_conv.is_owned = (o & 1) || (o == 0);
14119         o_conv = Shutdown_clone(&o_conv);
14120         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
14121         *ret_conv = CResult_ShutdownDecodeErrorZ_ok(o_conv);
14122         return (uint64_t)ret_conv;
14123 }
14124
14125 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14126         LDKDecodeError e_conv;
14127         e_conv.inner = (void*)(e & (~1));
14128         e_conv.is_owned = (e & 1) || (e == 0);
14129         e_conv = DecodeError_clone(&e_conv);
14130         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
14131         *ret_conv = CResult_ShutdownDecodeErrorZ_err(e_conv);
14132         return (uint64_t)ret_conv;
14133 }
14134
14135 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14136         if ((_res & 1) != 0) return;
14137         LDKCResult_ShutdownDecodeErrorZ _res_conv = *(LDKCResult_ShutdownDecodeErrorZ*)(((uint64_t)_res) & ~1);
14138         FREE((void*)_res);
14139         CResult_ShutdownDecodeErrorZ_free(_res_conv);
14140 }
14141
14142 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14143         LDKCResult_ShutdownDecodeErrorZ* orig_conv = (LDKCResult_ShutdownDecodeErrorZ*)(orig & ~1);
14144         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
14145         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(orig_conv);
14146         return (uint64_t)ret_conv;
14147 }
14148
14149 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14150         LDKUpdateFailHTLC o_conv;
14151         o_conv.inner = (void*)(o & (~1));
14152         o_conv.is_owned = (o & 1) || (o == 0);
14153         o_conv = UpdateFailHTLC_clone(&o_conv);
14154         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
14155         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_ok(o_conv);
14156         return (uint64_t)ret_conv;
14157 }
14158
14159 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14160         LDKDecodeError e_conv;
14161         e_conv.inner = (void*)(e & (~1));
14162         e_conv.is_owned = (e & 1) || (e == 0);
14163         e_conv = DecodeError_clone(&e_conv);
14164         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
14165         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_err(e_conv);
14166         return (uint64_t)ret_conv;
14167 }
14168
14169 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14170         if ((_res & 1) != 0) return;
14171         LDKCResult_UpdateFailHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
14172         FREE((void*)_res);
14173         CResult_UpdateFailHTLCDecodeErrorZ_free(_res_conv);
14174 }
14175
14176 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14177         LDKCResult_UpdateFailHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(orig & ~1);
14178         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
14179         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(orig_conv);
14180         return (uint64_t)ret_conv;
14181 }
14182
14183 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14184         LDKUpdateFailMalformedHTLC o_conv;
14185         o_conv.inner = (void*)(o & (~1));
14186         o_conv.is_owned = (o & 1) || (o == 0);
14187         o_conv = UpdateFailMalformedHTLC_clone(&o_conv);
14188         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
14189         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(o_conv);
14190         return (uint64_t)ret_conv;
14191 }
14192
14193 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14194         LDKDecodeError e_conv;
14195         e_conv.inner = (void*)(e & (~1));
14196         e_conv.is_owned = (e & 1) || (e == 0);
14197         e_conv = DecodeError_clone(&e_conv);
14198         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
14199         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(e_conv);
14200         return (uint64_t)ret_conv;
14201 }
14202
14203 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14204         if ((_res & 1) != 0) return;
14205         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
14206         FREE((void*)_res);
14207         CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(_res_conv);
14208 }
14209
14210 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14211         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(orig & ~1);
14212         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
14213         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(orig_conv);
14214         return (uint64_t)ret_conv;
14215 }
14216
14217 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14218         LDKUpdateFee o_conv;
14219         o_conv.inner = (void*)(o & (~1));
14220         o_conv.is_owned = (o & 1) || (o == 0);
14221         o_conv = UpdateFee_clone(&o_conv);
14222         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
14223         *ret_conv = CResult_UpdateFeeDecodeErrorZ_ok(o_conv);
14224         return (uint64_t)ret_conv;
14225 }
14226
14227 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14228         LDKDecodeError e_conv;
14229         e_conv.inner = (void*)(e & (~1));
14230         e_conv.is_owned = (e & 1) || (e == 0);
14231         e_conv = DecodeError_clone(&e_conv);
14232         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
14233         *ret_conv = CResult_UpdateFeeDecodeErrorZ_err(e_conv);
14234         return (uint64_t)ret_conv;
14235 }
14236
14237 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14238         if ((_res & 1) != 0) return;
14239         LDKCResult_UpdateFeeDecodeErrorZ _res_conv = *(LDKCResult_UpdateFeeDecodeErrorZ*)(((uint64_t)_res) & ~1);
14240         FREE((void*)_res);
14241         CResult_UpdateFeeDecodeErrorZ_free(_res_conv);
14242 }
14243
14244 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14245         LDKCResult_UpdateFeeDecodeErrorZ* orig_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(orig & ~1);
14246         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
14247         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(orig_conv);
14248         return (uint64_t)ret_conv;
14249 }
14250
14251 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14252         LDKUpdateFulfillHTLC o_conv;
14253         o_conv.inner = (void*)(o & (~1));
14254         o_conv.is_owned = (o & 1) || (o == 0);
14255         o_conv = UpdateFulfillHTLC_clone(&o_conv);
14256         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
14257         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_ok(o_conv);
14258         return (uint64_t)ret_conv;
14259 }
14260
14261 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14262         LDKDecodeError e_conv;
14263         e_conv.inner = (void*)(e & (~1));
14264         e_conv.is_owned = (e & 1) || (e == 0);
14265         e_conv = DecodeError_clone(&e_conv);
14266         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
14267         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_err(e_conv);
14268         return (uint64_t)ret_conv;
14269 }
14270
14271 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14272         if ((_res & 1) != 0) return;
14273         LDKCResult_UpdateFulfillHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
14274         FREE((void*)_res);
14275         CResult_UpdateFulfillHTLCDecodeErrorZ_free(_res_conv);
14276 }
14277
14278 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14279         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(orig & ~1);
14280         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
14281         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(orig_conv);
14282         return (uint64_t)ret_conv;
14283 }
14284
14285 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14286         LDKUpdateAddHTLC o_conv;
14287         o_conv.inner = (void*)(o & (~1));
14288         o_conv.is_owned = (o & 1) || (o == 0);
14289         o_conv = UpdateAddHTLC_clone(&o_conv);
14290         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
14291         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_ok(o_conv);
14292         return (uint64_t)ret_conv;
14293 }
14294
14295 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14296         LDKDecodeError e_conv;
14297         e_conv.inner = (void*)(e & (~1));
14298         e_conv.is_owned = (e & 1) || (e == 0);
14299         e_conv = DecodeError_clone(&e_conv);
14300         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
14301         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_err(e_conv);
14302         return (uint64_t)ret_conv;
14303 }
14304
14305 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14306         if ((_res & 1) != 0) return;
14307         LDKCResult_UpdateAddHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateAddHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
14308         FREE((void*)_res);
14309         CResult_UpdateAddHTLCDecodeErrorZ_free(_res_conv);
14310 }
14311
14312 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14313         LDKCResult_UpdateAddHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(orig & ~1);
14314         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
14315         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(orig_conv);
14316         return (uint64_t)ret_conv;
14317 }
14318
14319 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14320         LDKPing o_conv;
14321         o_conv.inner = (void*)(o & (~1));
14322         o_conv.is_owned = (o & 1) || (o == 0);
14323         o_conv = Ping_clone(&o_conv);
14324         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
14325         *ret_conv = CResult_PingDecodeErrorZ_ok(o_conv);
14326         return (uint64_t)ret_conv;
14327 }
14328
14329 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14330         LDKDecodeError e_conv;
14331         e_conv.inner = (void*)(e & (~1));
14332         e_conv.is_owned = (e & 1) || (e == 0);
14333         e_conv = DecodeError_clone(&e_conv);
14334         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
14335         *ret_conv = CResult_PingDecodeErrorZ_err(e_conv);
14336         return (uint64_t)ret_conv;
14337 }
14338
14339 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14340         if ((_res & 1) != 0) return;
14341         LDKCResult_PingDecodeErrorZ _res_conv = *(LDKCResult_PingDecodeErrorZ*)(((uint64_t)_res) & ~1);
14342         FREE((void*)_res);
14343         CResult_PingDecodeErrorZ_free(_res_conv);
14344 }
14345
14346 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14347         LDKCResult_PingDecodeErrorZ* orig_conv = (LDKCResult_PingDecodeErrorZ*)(orig & ~1);
14348         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
14349         *ret_conv = CResult_PingDecodeErrorZ_clone(orig_conv);
14350         return (uint64_t)ret_conv;
14351 }
14352
14353 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14354         LDKPong o_conv;
14355         o_conv.inner = (void*)(o & (~1));
14356         o_conv.is_owned = (o & 1) || (o == 0);
14357         o_conv = Pong_clone(&o_conv);
14358         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
14359         *ret_conv = CResult_PongDecodeErrorZ_ok(o_conv);
14360         return (uint64_t)ret_conv;
14361 }
14362
14363 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14364         LDKDecodeError e_conv;
14365         e_conv.inner = (void*)(e & (~1));
14366         e_conv.is_owned = (e & 1) || (e == 0);
14367         e_conv = DecodeError_clone(&e_conv);
14368         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
14369         *ret_conv = CResult_PongDecodeErrorZ_err(e_conv);
14370         return (uint64_t)ret_conv;
14371 }
14372
14373 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14374         if ((_res & 1) != 0) return;
14375         LDKCResult_PongDecodeErrorZ _res_conv = *(LDKCResult_PongDecodeErrorZ*)(((uint64_t)_res) & ~1);
14376         FREE((void*)_res);
14377         CResult_PongDecodeErrorZ_free(_res_conv);
14378 }
14379
14380 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14381         LDKCResult_PongDecodeErrorZ* orig_conv = (LDKCResult_PongDecodeErrorZ*)(orig & ~1);
14382         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
14383         *ret_conv = CResult_PongDecodeErrorZ_clone(orig_conv);
14384         return (uint64_t)ret_conv;
14385 }
14386
14387 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14388         LDKUnsignedChannelAnnouncement o_conv;
14389         o_conv.inner = (void*)(o & (~1));
14390         o_conv.is_owned = (o & 1) || (o == 0);
14391         o_conv = UnsignedChannelAnnouncement_clone(&o_conv);
14392         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
14393         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(o_conv);
14394         return (uint64_t)ret_conv;
14395 }
14396
14397 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14398         LDKDecodeError e_conv;
14399         e_conv.inner = (void*)(e & (~1));
14400         e_conv.is_owned = (e & 1) || (e == 0);
14401         e_conv = DecodeError_clone(&e_conv);
14402         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
14403         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(e_conv);
14404         return (uint64_t)ret_conv;
14405 }
14406
14407 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14408         if ((_res & 1) != 0) return;
14409         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
14410         FREE((void*)_res);
14411         CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(_res_conv);
14412 }
14413
14414 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14415         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(orig & ~1);
14416         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
14417         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(orig_conv);
14418         return (uint64_t)ret_conv;
14419 }
14420
14421 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14422         LDKChannelAnnouncement o_conv;
14423         o_conv.inner = (void*)(o & (~1));
14424         o_conv.is_owned = (o & 1) || (o == 0);
14425         o_conv = ChannelAnnouncement_clone(&o_conv);
14426         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
14427         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_ok(o_conv);
14428         return (uint64_t)ret_conv;
14429 }
14430
14431 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14432         LDKDecodeError e_conv;
14433         e_conv.inner = (void*)(e & (~1));
14434         e_conv.is_owned = (e & 1) || (e == 0);
14435         e_conv = DecodeError_clone(&e_conv);
14436         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
14437         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_err(e_conv);
14438         return (uint64_t)ret_conv;
14439 }
14440
14441 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14442         if ((_res & 1) != 0) return;
14443         LDKCResult_ChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_ChannelAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
14444         FREE((void*)_res);
14445         CResult_ChannelAnnouncementDecodeErrorZ_free(_res_conv);
14446 }
14447
14448 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14449         LDKCResult_ChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(orig & ~1);
14450         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
14451         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(orig_conv);
14452         return (uint64_t)ret_conv;
14453 }
14454
14455 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14456         LDKUnsignedChannelUpdate o_conv;
14457         o_conv.inner = (void*)(o & (~1));
14458         o_conv.is_owned = (o & 1) || (o == 0);
14459         o_conv = UnsignedChannelUpdate_clone(&o_conv);
14460         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
14461         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_ok(o_conv);
14462         return (uint64_t)ret_conv;
14463 }
14464
14465 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14466         LDKDecodeError e_conv;
14467         e_conv.inner = (void*)(e & (~1));
14468         e_conv.is_owned = (e & 1) || (e == 0);
14469         e_conv = DecodeError_clone(&e_conv);
14470         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
14471         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_err(e_conv);
14472         return (uint64_t)ret_conv;
14473 }
14474
14475 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14476         if ((_res & 1) != 0) return;
14477         LDKCResult_UnsignedChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
14478         FREE((void*)_res);
14479         CResult_UnsignedChannelUpdateDecodeErrorZ_free(_res_conv);
14480 }
14481
14482 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14483         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(orig & ~1);
14484         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
14485         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(orig_conv);
14486         return (uint64_t)ret_conv;
14487 }
14488
14489 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14490         LDKChannelUpdate o_conv;
14491         o_conv.inner = (void*)(o & (~1));
14492         o_conv.is_owned = (o & 1) || (o == 0);
14493         o_conv = ChannelUpdate_clone(&o_conv);
14494         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
14495         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_ok(o_conv);
14496         return (uint64_t)ret_conv;
14497 }
14498
14499 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14500         LDKDecodeError e_conv;
14501         e_conv.inner = (void*)(e & (~1));
14502         e_conv.is_owned = (e & 1) || (e == 0);
14503         e_conv = DecodeError_clone(&e_conv);
14504         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
14505         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_err(e_conv);
14506         return (uint64_t)ret_conv;
14507 }
14508
14509 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14510         if ((_res & 1) != 0) return;
14511         LDKCResult_ChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
14512         FREE((void*)_res);
14513         CResult_ChannelUpdateDecodeErrorZ_free(_res_conv);
14514 }
14515
14516 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14517         LDKCResult_ChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(orig & ~1);
14518         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
14519         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(orig_conv);
14520         return (uint64_t)ret_conv;
14521 }
14522
14523 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14524         LDKErrorMessage o_conv;
14525         o_conv.inner = (void*)(o & (~1));
14526         o_conv.is_owned = (o & 1) || (o == 0);
14527         o_conv = ErrorMessage_clone(&o_conv);
14528         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
14529         *ret_conv = CResult_ErrorMessageDecodeErrorZ_ok(o_conv);
14530         return (uint64_t)ret_conv;
14531 }
14532
14533 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14534         LDKDecodeError e_conv;
14535         e_conv.inner = (void*)(e & (~1));
14536         e_conv.is_owned = (e & 1) || (e == 0);
14537         e_conv = DecodeError_clone(&e_conv);
14538         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
14539         *ret_conv = CResult_ErrorMessageDecodeErrorZ_err(e_conv);
14540         return (uint64_t)ret_conv;
14541 }
14542
14543 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14544         if ((_res & 1) != 0) return;
14545         LDKCResult_ErrorMessageDecodeErrorZ _res_conv = *(LDKCResult_ErrorMessageDecodeErrorZ*)(((uint64_t)_res) & ~1);
14546         FREE((void*)_res);
14547         CResult_ErrorMessageDecodeErrorZ_free(_res_conv);
14548 }
14549
14550 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14551         LDKCResult_ErrorMessageDecodeErrorZ* orig_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(orig & ~1);
14552         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
14553         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(orig_conv);
14554         return (uint64_t)ret_conv;
14555 }
14556
14557 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14558         LDKUnsignedNodeAnnouncement o_conv;
14559         o_conv.inner = (void*)(o & (~1));
14560         o_conv.is_owned = (o & 1) || (o == 0);
14561         o_conv = UnsignedNodeAnnouncement_clone(&o_conv);
14562         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
14563         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(o_conv);
14564         return (uint64_t)ret_conv;
14565 }
14566
14567 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14568         LDKDecodeError e_conv;
14569         e_conv.inner = (void*)(e & (~1));
14570         e_conv.is_owned = (e & 1) || (e == 0);
14571         e_conv = DecodeError_clone(&e_conv);
14572         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
14573         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(e_conv);
14574         return (uint64_t)ret_conv;
14575 }
14576
14577 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14578         if ((_res & 1) != 0) return;
14579         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
14580         FREE((void*)_res);
14581         CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(_res_conv);
14582 }
14583
14584 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14585         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(orig & ~1);
14586         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
14587         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(orig_conv);
14588         return (uint64_t)ret_conv;
14589 }
14590
14591 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14592         LDKNodeAnnouncement o_conv;
14593         o_conv.inner = (void*)(o & (~1));
14594         o_conv.is_owned = (o & 1) || (o == 0);
14595         o_conv = NodeAnnouncement_clone(&o_conv);
14596         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
14597         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_ok(o_conv);
14598         return (uint64_t)ret_conv;
14599 }
14600
14601 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14602         LDKDecodeError e_conv;
14603         e_conv.inner = (void*)(e & (~1));
14604         e_conv.is_owned = (e & 1) || (e == 0);
14605         e_conv = DecodeError_clone(&e_conv);
14606         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
14607         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_err(e_conv);
14608         return (uint64_t)ret_conv;
14609 }
14610
14611 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14612         if ((_res & 1) != 0) return;
14613         LDKCResult_NodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
14614         FREE((void*)_res);
14615         CResult_NodeAnnouncementDecodeErrorZ_free(_res_conv);
14616 }
14617
14618 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14619         LDKCResult_NodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(orig & ~1);
14620         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
14621         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(orig_conv);
14622         return (uint64_t)ret_conv;
14623 }
14624
14625 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14626         LDKQueryShortChannelIds o_conv;
14627         o_conv.inner = (void*)(o & (~1));
14628         o_conv.is_owned = (o & 1) || (o == 0);
14629         o_conv = QueryShortChannelIds_clone(&o_conv);
14630         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
14631         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_ok(o_conv);
14632         return (uint64_t)ret_conv;
14633 }
14634
14635 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14636         LDKDecodeError e_conv;
14637         e_conv.inner = (void*)(e & (~1));
14638         e_conv.is_owned = (e & 1) || (e == 0);
14639         e_conv = DecodeError_clone(&e_conv);
14640         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
14641         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_err(e_conv);
14642         return (uint64_t)ret_conv;
14643 }
14644
14645 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14646         if ((_res & 1) != 0) return;
14647         LDKCResult_QueryShortChannelIdsDecodeErrorZ _res_conv = *(LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(((uint64_t)_res) & ~1);
14648         FREE((void*)_res);
14649         CResult_QueryShortChannelIdsDecodeErrorZ_free(_res_conv);
14650 }
14651
14652 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14653         LDKCResult_QueryShortChannelIdsDecodeErrorZ* orig_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(orig & ~1);
14654         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
14655         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(orig_conv);
14656         return (uint64_t)ret_conv;
14657 }
14658
14659 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14660         LDKReplyShortChannelIdsEnd o_conv;
14661         o_conv.inner = (void*)(o & (~1));
14662         o_conv.is_owned = (o & 1) || (o == 0);
14663         o_conv = ReplyShortChannelIdsEnd_clone(&o_conv);
14664         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
14665         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(o_conv);
14666         return (uint64_t)ret_conv;
14667 }
14668
14669 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14670         LDKDecodeError e_conv;
14671         e_conv.inner = (void*)(e & (~1));
14672         e_conv.is_owned = (e & 1) || (e == 0);
14673         e_conv = DecodeError_clone(&e_conv);
14674         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
14675         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(e_conv);
14676         return (uint64_t)ret_conv;
14677 }
14678
14679 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14680         if ((_res & 1) != 0) return;
14681         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ _res_conv = *(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(((uint64_t)_res) & ~1);
14682         FREE((void*)_res);
14683         CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(_res_conv);
14684 }
14685
14686 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14687         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* orig_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(orig & ~1);
14688         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
14689         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(orig_conv);
14690         return (uint64_t)ret_conv;
14691 }
14692
14693 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14694         LDKQueryChannelRange o_conv;
14695         o_conv.inner = (void*)(o & (~1));
14696         o_conv.is_owned = (o & 1) || (o == 0);
14697         o_conv = QueryChannelRange_clone(&o_conv);
14698         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
14699         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_ok(o_conv);
14700         return (uint64_t)ret_conv;
14701 }
14702
14703 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14704         LDKDecodeError e_conv;
14705         e_conv.inner = (void*)(e & (~1));
14706         e_conv.is_owned = (e & 1) || (e == 0);
14707         e_conv = DecodeError_clone(&e_conv);
14708         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
14709         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_err(e_conv);
14710         return (uint64_t)ret_conv;
14711 }
14712
14713 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14714         if ((_res & 1) != 0) return;
14715         LDKCResult_QueryChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_QueryChannelRangeDecodeErrorZ*)(((uint64_t)_res) & ~1);
14716         FREE((void*)_res);
14717         CResult_QueryChannelRangeDecodeErrorZ_free(_res_conv);
14718 }
14719
14720 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14721         LDKCResult_QueryChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(orig & ~1);
14722         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
14723         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(orig_conv);
14724         return (uint64_t)ret_conv;
14725 }
14726
14727 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14728         LDKReplyChannelRange o_conv;
14729         o_conv.inner = (void*)(o & (~1));
14730         o_conv.is_owned = (o & 1) || (o == 0);
14731         o_conv = ReplyChannelRange_clone(&o_conv);
14732         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
14733         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_ok(o_conv);
14734         return (uint64_t)ret_conv;
14735 }
14736
14737 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14738         LDKDecodeError e_conv;
14739         e_conv.inner = (void*)(e & (~1));
14740         e_conv.is_owned = (e & 1) || (e == 0);
14741         e_conv = DecodeError_clone(&e_conv);
14742         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
14743         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_err(e_conv);
14744         return (uint64_t)ret_conv;
14745 }
14746
14747 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14748         if ((_res & 1) != 0) return;
14749         LDKCResult_ReplyChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_ReplyChannelRangeDecodeErrorZ*)(((uint64_t)_res) & ~1);
14750         FREE((void*)_res);
14751         CResult_ReplyChannelRangeDecodeErrorZ_free(_res_conv);
14752 }
14753
14754 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14755         LDKCResult_ReplyChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(orig & ~1);
14756         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
14757         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(orig_conv);
14758         return (uint64_t)ret_conv;
14759 }
14760
14761 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14762         LDKGossipTimestampFilter o_conv;
14763         o_conv.inner = (void*)(o & (~1));
14764         o_conv.is_owned = (o & 1) || (o == 0);
14765         o_conv = GossipTimestampFilter_clone(&o_conv);
14766         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
14767         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_ok(o_conv);
14768         return (uint64_t)ret_conv;
14769 }
14770
14771 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14772         LDKDecodeError e_conv;
14773         e_conv.inner = (void*)(e & (~1));
14774         e_conv.is_owned = (e & 1) || (e == 0);
14775         e_conv = DecodeError_clone(&e_conv);
14776         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
14777         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_err(e_conv);
14778         return (uint64_t)ret_conv;
14779 }
14780
14781 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14782         if ((_res & 1) != 0) return;
14783         LDKCResult_GossipTimestampFilterDecodeErrorZ _res_conv = *(LDKCResult_GossipTimestampFilterDecodeErrorZ*)(((uint64_t)_res) & ~1);
14784         FREE((void*)_res);
14785         CResult_GossipTimestampFilterDecodeErrorZ_free(_res_conv);
14786 }
14787
14788 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14789         LDKCResult_GossipTimestampFilterDecodeErrorZ* orig_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(orig & ~1);
14790         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
14791         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(orig_conv);
14792         return (uint64_t)ret_conv;
14793 }
14794
14795 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14796         LDKInvoice o_conv;
14797         o_conv.inner = (void*)(o & (~1));
14798         o_conv.is_owned = (o & 1) || (o == 0);
14799         o_conv = Invoice_clone(&o_conv);
14800         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
14801         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_ok(o_conv);
14802         return (uint64_t)ret_conv;
14803 }
14804
14805 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14806         LDKSignOrCreationError e_conv = *(LDKSignOrCreationError*)(((uint64_t)e) & ~1);
14807         e_conv = SignOrCreationError_clone((LDKSignOrCreationError*)(((uint64_t)e) & ~1));
14808         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
14809         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_err(e_conv);
14810         return (uint64_t)ret_conv;
14811 }
14812
14813 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14814         if ((_res & 1) != 0) return;
14815         LDKCResult_InvoiceSignOrCreationErrorZ _res_conv = *(LDKCResult_InvoiceSignOrCreationErrorZ*)(((uint64_t)_res) & ~1);
14816         FREE((void*)_res);
14817         CResult_InvoiceSignOrCreationErrorZ_free(_res_conv);
14818 }
14819
14820 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14821         LDKCResult_InvoiceSignOrCreationErrorZ* orig_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(orig & ~1);
14822         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
14823         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone(orig_conv);
14824         return (uint64_t)ret_conv;
14825 }
14826
14827 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1FilterZ_1some(JNIEnv *env, jclass clz, int64_t o) {
14828         LDKFilter o_conv = *(LDKFilter*)(((uint64_t)o) & ~1);
14829         if (o_conv.free == LDKFilter_JCalls_free) {
14830                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14831                 LDKFilter_JCalls_cloned(&o_conv);
14832         }
14833         LDKCOption_FilterZ *ret_copy = MALLOC(sizeof(LDKCOption_FilterZ), "LDKCOption_FilterZ");
14834         *ret_copy = COption_FilterZ_some(o_conv);
14835         uint64_t ret_ref = (uint64_t)ret_copy;
14836         return ret_ref;
14837 }
14838
14839 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1FilterZ_1none(JNIEnv *env, jclass clz) {
14840         LDKCOption_FilterZ *ret_copy = MALLOC(sizeof(LDKCOption_FilterZ), "LDKCOption_FilterZ");
14841         *ret_copy = COption_FilterZ_none();
14842         uint64_t ret_ref = (uint64_t)ret_copy;
14843         return ret_ref;
14844 }
14845
14846 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1FilterZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14847         if ((_res & 1) != 0) return;
14848         LDKCOption_FilterZ _res_conv = *(LDKCOption_FilterZ*)(((uint64_t)_res) & ~1);
14849         FREE((void*)_res);
14850         COption_FilterZ_free(_res_conv);
14851 }
14852
14853 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
14854         if ((this_ptr & 1) != 0) return;
14855         LDKPaymentPurpose this_ptr_conv = *(LDKPaymentPurpose*)(((uint64_t)this_ptr) & ~1);
14856         FREE((void*)this_ptr);
14857         PaymentPurpose_free(this_ptr_conv);
14858 }
14859
14860 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14861         LDKPaymentPurpose* orig_conv = (LDKPaymentPurpose*)orig;
14862         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
14863         *ret_copy = PaymentPurpose_clone(orig_conv);
14864         uint64_t ret_ref = (uint64_t)ret_copy;
14865         return ret_ref;
14866 }
14867
14868 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1invoice_1payment(JNIEnv *env, jclass clz, int8_tArray payment_preimage, int8_tArray payment_secret, int64_t user_payment_id) {
14869         LDKThirtyTwoBytes payment_preimage_ref;
14870         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
14871         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
14872         LDKThirtyTwoBytes payment_secret_ref;
14873         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
14874         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
14875         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
14876         *ret_copy = PaymentPurpose_invoice_payment(payment_preimage_ref, payment_secret_ref, user_payment_id);
14877         uint64_t ret_ref = (uint64_t)ret_copy;
14878         return ret_ref;
14879 }
14880
14881 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1spontaneous_1payment(JNIEnv *env, jclass clz, int8_tArray a) {
14882         LDKThirtyTwoBytes a_ref;
14883         CHECK((*env)->GetArrayLength(env, a) == 32);
14884         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
14885         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
14886         *ret_copy = PaymentPurpose_spontaneous_payment(a_ref);
14887         uint64_t ret_ref = (uint64_t)ret_copy;
14888         return ret_ref;
14889 }
14890
14891 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosureReason_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
14892         if ((this_ptr & 1) != 0) return;
14893         LDKClosureReason this_ptr_conv = *(LDKClosureReason*)(((uint64_t)this_ptr) & ~1);
14894         FREE((void*)this_ptr);
14895         ClosureReason_free(this_ptr_conv);
14896 }
14897
14898 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14899         LDKClosureReason* orig_conv = (LDKClosureReason*)orig;
14900         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
14901         *ret_copy = ClosureReason_clone(orig_conv);
14902         uint64_t ret_ref = (uint64_t)ret_copy;
14903         return ret_ref;
14904 }
14905
14906 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1counterparty_1force_1closed(JNIEnv *env, jclass clz, jstring peer_msg) {
14907         LDKStr peer_msg_conv = java_to_owned_str(env, peer_msg);
14908         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
14909         *ret_copy = ClosureReason_counterparty_force_closed(peer_msg_conv);
14910         uint64_t ret_ref = (uint64_t)ret_copy;
14911         return ret_ref;
14912 }
14913
14914 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1holder_1force_1closed(JNIEnv *env, jclass clz) {
14915         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
14916         *ret_copy = ClosureReason_holder_force_closed();
14917         uint64_t ret_ref = (uint64_t)ret_copy;
14918         return ret_ref;
14919 }
14920
14921 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1cooperative_1closure(JNIEnv *env, jclass clz) {
14922         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
14923         *ret_copy = ClosureReason_cooperative_closure();
14924         uint64_t ret_ref = (uint64_t)ret_copy;
14925         return ret_ref;
14926 }
14927
14928 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1commitment_1tx_1confirmed(JNIEnv *env, jclass clz) {
14929         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
14930         *ret_copy = ClosureReason_commitment_tx_confirmed();
14931         uint64_t ret_ref = (uint64_t)ret_copy;
14932         return ret_ref;
14933 }
14934
14935 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1processing_1error(JNIEnv *env, jclass clz, jstring err) {
14936         LDKStr err_conv = java_to_owned_str(env, err);
14937         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
14938         *ret_copy = ClosureReason_processing_error(err_conv);
14939         uint64_t ret_ref = (uint64_t)ret_copy;
14940         return ret_ref;
14941 }
14942
14943 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1disconnected_1peer(JNIEnv *env, jclass clz) {
14944         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
14945         *ret_copy = ClosureReason_disconnected_peer();
14946         uint64_t ret_ref = (uint64_t)ret_copy;
14947         return ret_ref;
14948 }
14949
14950 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1outdated_1channel_1manager(JNIEnv *env, jclass clz) {
14951         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
14952         *ret_copy = ClosureReason_outdated_channel_manager();
14953         uint64_t ret_ref = (uint64_t)ret_copy;
14954         return ret_ref;
14955 }
14956
14957 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosureReason_1write(JNIEnv *env, jclass clz, int64_t obj) {
14958         LDKClosureReason* obj_conv = (LDKClosureReason*)obj;
14959         LDKCVec_u8Z ret_var = ClosureReason_write(obj_conv);
14960         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
14961         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
14962         CVec_u8Z_free(ret_var);
14963         return ret_arr;
14964 }
14965
14966 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Event_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
14967         if ((this_ptr & 1) != 0) return;
14968         LDKEvent this_ptr_conv = *(LDKEvent*)(((uint64_t)this_ptr) & ~1);
14969         FREE((void*)this_ptr);
14970         Event_free(this_ptr_conv);
14971 }
14972
14973 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14974         LDKEvent* orig_conv = (LDKEvent*)orig;
14975         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
14976         *ret_copy = Event_clone(orig_conv);
14977         uint64_t ret_ref = (uint64_t)ret_copy;
14978         return ret_ref;
14979 }
14980
14981 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1funding_1generation_1ready(JNIEnv *env, jclass clz, int8_tArray temporary_channel_id, int64_t channel_value_satoshis, int8_tArray output_script, int64_t user_channel_id) {
14982         LDKThirtyTwoBytes temporary_channel_id_ref;
14983         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
14984         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_ref.data);
14985         LDKCVec_u8Z output_script_ref;
14986         output_script_ref.datalen = (*env)->GetArrayLength(env, output_script);
14987         output_script_ref.data = MALLOC(output_script_ref.datalen, "LDKCVec_u8Z Bytes");
14988         (*env)->GetByteArrayRegion(env, output_script, 0, output_script_ref.datalen, output_script_ref.data);
14989         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
14990         *ret_copy = Event_funding_generation_ready(temporary_channel_id_ref, channel_value_satoshis, output_script_ref, user_channel_id);
14991         uint64_t ret_ref = (uint64_t)ret_copy;
14992         return ret_ref;
14993 }
14994
14995 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1payment_1received(JNIEnv *env, jclass clz, int8_tArray payment_hash, int64_t amt, int64_t purpose) {
14996         LDKThirtyTwoBytes payment_hash_ref;
14997         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
14998         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
14999         LDKPaymentPurpose purpose_conv = *(LDKPaymentPurpose*)(((uint64_t)purpose) & ~1);
15000         purpose_conv = PaymentPurpose_clone((LDKPaymentPurpose*)(((uint64_t)purpose) & ~1));
15001         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
15002         *ret_copy = Event_payment_received(payment_hash_ref, amt, purpose_conv);
15003         uint64_t ret_ref = (uint64_t)ret_copy;
15004         return ret_ref;
15005 }
15006
15007 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1payment_1sent(JNIEnv *env, jclass clz, int8_tArray payment_preimage) {
15008         LDKThirtyTwoBytes payment_preimage_ref;
15009         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
15010         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
15011         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
15012         *ret_copy = Event_payment_sent(payment_preimage_ref);
15013         uint64_t ret_ref = (uint64_t)ret_copy;
15014         return ret_ref;
15015 }
15016
15017 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1payment_1path_1failed(JNIEnv *env, jclass clz, int8_tArray payment_hash, jboolean rejected_by_dest, int64_t network_update, jboolean all_paths_failed, int64_tArray path) {
15018         LDKThirtyTwoBytes payment_hash_ref;
15019         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
15020         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
15021         LDKCOption_NetworkUpdateZ network_update_conv = *(LDKCOption_NetworkUpdateZ*)(((uint64_t)network_update) & ~1);
15022         network_update_conv = COption_NetworkUpdateZ_clone((LDKCOption_NetworkUpdateZ*)(((uint64_t)network_update) & ~1));
15023         LDKCVec_RouteHopZ path_constr;
15024         path_constr.datalen = (*env)->GetArrayLength(env, path);
15025         if (path_constr.datalen > 0)
15026                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
15027         else
15028                 path_constr.data = NULL;
15029         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
15030         for (size_t k = 0; k < path_constr.datalen; k++) {
15031                 int64_t path_conv_10 = path_vals[k];
15032                 LDKRouteHop path_conv_10_conv;
15033                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
15034                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
15035                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
15036                 path_constr.data[k] = path_conv_10_conv;
15037         }
15038         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
15039         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
15040         *ret_copy = Event_payment_path_failed(payment_hash_ref, rejected_by_dest, network_update_conv, all_paths_failed, path_constr);
15041         uint64_t ret_ref = (uint64_t)ret_copy;
15042         return ret_ref;
15043 }
15044
15045 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1pending_1htlcs_1forwardable(JNIEnv *env, jclass clz, int64_t time_forwardable) {
15046         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
15047         *ret_copy = Event_pending_htlcs_forwardable(time_forwardable);
15048         uint64_t ret_ref = (uint64_t)ret_copy;
15049         return ret_ref;
15050 }
15051
15052 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1spendable_1outputs(JNIEnv *env, jclass clz, int64_tArray outputs) {
15053         LDKCVec_SpendableOutputDescriptorZ outputs_constr;
15054         outputs_constr.datalen = (*env)->GetArrayLength(env, outputs);
15055         if (outputs_constr.datalen > 0)
15056                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
15057         else
15058                 outputs_constr.data = NULL;
15059         int64_t* outputs_vals = (*env)->GetLongArrayElements (env, outputs, NULL);
15060         for (size_t b = 0; b < outputs_constr.datalen; b++) {
15061                 int64_t outputs_conv_27 = outputs_vals[b];
15062                 LDKSpendableOutputDescriptor outputs_conv_27_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)outputs_conv_27) & ~1);
15063                 outputs_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uint64_t)outputs_conv_27) & ~1));
15064                 outputs_constr.data[b] = outputs_conv_27_conv;
15065         }
15066         (*env)->ReleaseLongArrayElements(env, outputs, outputs_vals, 0);
15067         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
15068         *ret_copy = Event_spendable_outputs(outputs_constr);
15069         uint64_t ret_ref = (uint64_t)ret_copy;
15070         return ret_ref;
15071 }
15072
15073 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1payment_1forwarded(JNIEnv *env, jclass clz, int64_t fee_earned_msat, jboolean claim_from_onchain_tx) {
15074         LDKCOption_u64Z fee_earned_msat_conv = *(LDKCOption_u64Z*)(((uint64_t)fee_earned_msat) & ~1);
15075         fee_earned_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)fee_earned_msat) & ~1));
15076         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
15077         *ret_copy = Event_payment_forwarded(fee_earned_msat_conv, claim_from_onchain_tx);
15078         uint64_t ret_ref = (uint64_t)ret_copy;
15079         return ret_ref;
15080 }
15081
15082 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1channel_1closed(JNIEnv *env, jclass clz, int8_tArray channel_id, int64_t reason) {
15083         LDKThirtyTwoBytes channel_id_ref;
15084         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
15085         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_ref.data);
15086         LDKClosureReason reason_conv = *(LDKClosureReason*)(((uint64_t)reason) & ~1);
15087         reason_conv = ClosureReason_clone((LDKClosureReason*)(((uint64_t)reason) & ~1));
15088         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
15089         *ret_copy = Event_channel_closed(channel_id_ref, reason_conv);
15090         uint64_t ret_ref = (uint64_t)ret_copy;
15091         return ret_ref;
15092 }
15093
15094 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Event_1write(JNIEnv *env, jclass clz, int64_t obj) {
15095         LDKEvent* obj_conv = (LDKEvent*)obj;
15096         LDKCVec_u8Z ret_var = Event_write(obj_conv);
15097         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
15098         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
15099         CVec_u8Z_free(ret_var);
15100         return ret_arr;
15101 }
15102
15103 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
15104         if ((this_ptr & 1) != 0) return;
15105         LDKMessageSendEvent this_ptr_conv = *(LDKMessageSendEvent*)(((uint64_t)this_ptr) & ~1);
15106         FREE((void*)this_ptr);
15107         MessageSendEvent_free(this_ptr_conv);
15108 }
15109
15110 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15111         LDKMessageSendEvent* orig_conv = (LDKMessageSendEvent*)orig;
15112         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
15113         *ret_copy = MessageSendEvent_clone(orig_conv);
15114         uint64_t ret_ref = (uint64_t)ret_copy;
15115         return ret_ref;
15116 }
15117
15118 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1accept_1channel(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
15119         LDKPublicKey node_id_ref;
15120         CHECK((*env)->GetArrayLength(env, node_id) == 33);
15121         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
15122         LDKAcceptChannel msg_conv;
15123         msg_conv.inner = (void*)(msg & (~1));
15124         msg_conv.is_owned = (msg & 1) || (msg == 0);
15125         msg_conv = AcceptChannel_clone(&msg_conv);
15126         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
15127         *ret_copy = MessageSendEvent_send_accept_channel(node_id_ref, msg_conv);
15128         uint64_t ret_ref = (uint64_t)ret_copy;
15129         return ret_ref;
15130 }
15131
15132 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1open_1channel(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
15133         LDKPublicKey node_id_ref;
15134         CHECK((*env)->GetArrayLength(env, node_id) == 33);
15135         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
15136         LDKOpenChannel msg_conv;
15137         msg_conv.inner = (void*)(msg & (~1));
15138         msg_conv.is_owned = (msg & 1) || (msg == 0);
15139         msg_conv = OpenChannel_clone(&msg_conv);
15140         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
15141         *ret_copy = MessageSendEvent_send_open_channel(node_id_ref, msg_conv);
15142         uint64_t ret_ref = (uint64_t)ret_copy;
15143         return ret_ref;
15144 }
15145
15146 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1funding_1created(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
15147         LDKPublicKey node_id_ref;
15148         CHECK((*env)->GetArrayLength(env, node_id) == 33);
15149         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
15150         LDKFundingCreated msg_conv;
15151         msg_conv.inner = (void*)(msg & (~1));
15152         msg_conv.is_owned = (msg & 1) || (msg == 0);
15153         msg_conv = FundingCreated_clone(&msg_conv);
15154         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
15155         *ret_copy = MessageSendEvent_send_funding_created(node_id_ref, msg_conv);
15156         uint64_t ret_ref = (uint64_t)ret_copy;
15157         return ret_ref;
15158 }
15159
15160 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1funding_1signed(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
15161         LDKPublicKey node_id_ref;
15162         CHECK((*env)->GetArrayLength(env, node_id) == 33);
15163         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
15164         LDKFundingSigned msg_conv;
15165         msg_conv.inner = (void*)(msg & (~1));
15166         msg_conv.is_owned = (msg & 1) || (msg == 0);
15167         msg_conv = FundingSigned_clone(&msg_conv);
15168         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
15169         *ret_copy = MessageSendEvent_send_funding_signed(node_id_ref, msg_conv);
15170         uint64_t ret_ref = (uint64_t)ret_copy;
15171         return ret_ref;
15172 }
15173
15174 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1funding_1locked(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
15175         LDKPublicKey node_id_ref;
15176         CHECK((*env)->GetArrayLength(env, node_id) == 33);
15177         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
15178         LDKFundingLocked msg_conv;
15179         msg_conv.inner = (void*)(msg & (~1));
15180         msg_conv.is_owned = (msg & 1) || (msg == 0);
15181         msg_conv = FundingLocked_clone(&msg_conv);
15182         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
15183         *ret_copy = MessageSendEvent_send_funding_locked(node_id_ref, msg_conv);
15184         uint64_t ret_ref = (uint64_t)ret_copy;
15185         return ret_ref;
15186 }
15187
15188 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1announcement_1signatures(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
15189         LDKPublicKey node_id_ref;
15190         CHECK((*env)->GetArrayLength(env, node_id) == 33);
15191         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
15192         LDKAnnouncementSignatures msg_conv;
15193         msg_conv.inner = (void*)(msg & (~1));
15194         msg_conv.is_owned = (msg & 1) || (msg == 0);
15195         msg_conv = AnnouncementSignatures_clone(&msg_conv);
15196         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
15197         *ret_copy = MessageSendEvent_send_announcement_signatures(node_id_ref, msg_conv);
15198         uint64_t ret_ref = (uint64_t)ret_copy;
15199         return ret_ref;
15200 }
15201
15202 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1update_1htlcs(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t updates) {
15203         LDKPublicKey node_id_ref;
15204         CHECK((*env)->GetArrayLength(env, node_id) == 33);
15205         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
15206         LDKCommitmentUpdate updates_conv;
15207         updates_conv.inner = (void*)(updates & (~1));
15208         updates_conv.is_owned = (updates & 1) || (updates == 0);
15209         updates_conv = CommitmentUpdate_clone(&updates_conv);
15210         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
15211         *ret_copy = MessageSendEvent_update_htlcs(node_id_ref, updates_conv);
15212         uint64_t ret_ref = (uint64_t)ret_copy;
15213         return ret_ref;
15214 }
15215
15216 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1revoke_1and_1ack(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
15217         LDKPublicKey node_id_ref;
15218         CHECK((*env)->GetArrayLength(env, node_id) == 33);
15219         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
15220         LDKRevokeAndACK msg_conv;
15221         msg_conv.inner = (void*)(msg & (~1));
15222         msg_conv.is_owned = (msg & 1) || (msg == 0);
15223         msg_conv = RevokeAndACK_clone(&msg_conv);
15224         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
15225         *ret_copy = MessageSendEvent_send_revoke_and_ack(node_id_ref, msg_conv);
15226         uint64_t ret_ref = (uint64_t)ret_copy;
15227         return ret_ref;
15228 }
15229
15230 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1closing_1signed(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
15231         LDKPublicKey node_id_ref;
15232         CHECK((*env)->GetArrayLength(env, node_id) == 33);
15233         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
15234         LDKClosingSigned msg_conv;
15235         msg_conv.inner = (void*)(msg & (~1));
15236         msg_conv.is_owned = (msg & 1) || (msg == 0);
15237         msg_conv = ClosingSigned_clone(&msg_conv);
15238         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
15239         *ret_copy = MessageSendEvent_send_closing_signed(node_id_ref, msg_conv);
15240         uint64_t ret_ref = (uint64_t)ret_copy;
15241         return ret_ref;
15242 }
15243
15244 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1shutdown(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
15245         LDKPublicKey node_id_ref;
15246         CHECK((*env)->GetArrayLength(env, node_id) == 33);
15247         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
15248         LDKShutdown msg_conv;
15249         msg_conv.inner = (void*)(msg & (~1));
15250         msg_conv.is_owned = (msg & 1) || (msg == 0);
15251         msg_conv = Shutdown_clone(&msg_conv);
15252         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
15253         *ret_copy = MessageSendEvent_send_shutdown(node_id_ref, msg_conv);
15254         uint64_t ret_ref = (uint64_t)ret_copy;
15255         return ret_ref;
15256 }
15257
15258 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1channel_1reestablish(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
15259         LDKPublicKey node_id_ref;
15260         CHECK((*env)->GetArrayLength(env, node_id) == 33);
15261         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
15262         LDKChannelReestablish msg_conv;
15263         msg_conv.inner = (void*)(msg & (~1));
15264         msg_conv.is_owned = (msg & 1) || (msg == 0);
15265         msg_conv = ChannelReestablish_clone(&msg_conv);
15266         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
15267         *ret_copy = MessageSendEvent_send_channel_reestablish(node_id_ref, msg_conv);
15268         uint64_t ret_ref = (uint64_t)ret_copy;
15269         return ret_ref;
15270 }
15271
15272 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1broadcast_1channel_1announcement(JNIEnv *env, jclass clz, int64_t msg, int64_t update_msg) {
15273         LDKChannelAnnouncement msg_conv;
15274         msg_conv.inner = (void*)(msg & (~1));
15275         msg_conv.is_owned = (msg & 1) || (msg == 0);
15276         msg_conv = ChannelAnnouncement_clone(&msg_conv);
15277         LDKChannelUpdate update_msg_conv;
15278         update_msg_conv.inner = (void*)(update_msg & (~1));
15279         update_msg_conv.is_owned = (update_msg & 1) || (update_msg == 0);
15280         update_msg_conv = ChannelUpdate_clone(&update_msg_conv);
15281         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
15282         *ret_copy = MessageSendEvent_broadcast_channel_announcement(msg_conv, update_msg_conv);
15283         uint64_t ret_ref = (uint64_t)ret_copy;
15284         return ret_ref;
15285 }
15286
15287 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1broadcast_1node_1announcement(JNIEnv *env, jclass clz, int64_t msg) {
15288         LDKNodeAnnouncement msg_conv;
15289         msg_conv.inner = (void*)(msg & (~1));
15290         msg_conv.is_owned = (msg & 1) || (msg == 0);
15291         msg_conv = NodeAnnouncement_clone(&msg_conv);
15292         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
15293         *ret_copy = MessageSendEvent_broadcast_node_announcement(msg_conv);
15294         uint64_t ret_ref = (uint64_t)ret_copy;
15295         return ret_ref;
15296 }
15297
15298 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1broadcast_1channel_1update(JNIEnv *env, jclass clz, int64_t msg) {
15299         LDKChannelUpdate msg_conv;
15300         msg_conv.inner = (void*)(msg & (~1));
15301         msg_conv.is_owned = (msg & 1) || (msg == 0);
15302         msg_conv = ChannelUpdate_clone(&msg_conv);
15303         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
15304         *ret_copy = MessageSendEvent_broadcast_channel_update(msg_conv);
15305         uint64_t ret_ref = (uint64_t)ret_copy;
15306         return ret_ref;
15307 }
15308
15309 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1channel_1update(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
15310         LDKPublicKey node_id_ref;
15311         CHECK((*env)->GetArrayLength(env, node_id) == 33);
15312         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
15313         LDKChannelUpdate msg_conv;
15314         msg_conv.inner = (void*)(msg & (~1));
15315         msg_conv.is_owned = (msg & 1) || (msg == 0);
15316         msg_conv = ChannelUpdate_clone(&msg_conv);
15317         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
15318         *ret_copy = MessageSendEvent_send_channel_update(node_id_ref, msg_conv);
15319         uint64_t ret_ref = (uint64_t)ret_copy;
15320         return ret_ref;
15321 }
15322
15323 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1handle_1error(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t action) {
15324         LDKPublicKey node_id_ref;
15325         CHECK((*env)->GetArrayLength(env, node_id) == 33);
15326         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
15327         LDKErrorAction action_conv = *(LDKErrorAction*)(((uint64_t)action) & ~1);
15328         action_conv = ErrorAction_clone((LDKErrorAction*)(((uint64_t)action) & ~1));
15329         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
15330         *ret_copy = MessageSendEvent_handle_error(node_id_ref, action_conv);
15331         uint64_t ret_ref = (uint64_t)ret_copy;
15332         return ret_ref;
15333 }
15334
15335 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1channel_1range_1query(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
15336         LDKPublicKey node_id_ref;
15337         CHECK((*env)->GetArrayLength(env, node_id) == 33);
15338         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
15339         LDKQueryChannelRange msg_conv;
15340         msg_conv.inner = (void*)(msg & (~1));
15341         msg_conv.is_owned = (msg & 1) || (msg == 0);
15342         msg_conv = QueryChannelRange_clone(&msg_conv);
15343         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
15344         *ret_copy = MessageSendEvent_send_channel_range_query(node_id_ref, msg_conv);
15345         uint64_t ret_ref = (uint64_t)ret_copy;
15346         return ret_ref;
15347 }
15348
15349 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1short_1ids_1query(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
15350         LDKPublicKey node_id_ref;
15351         CHECK((*env)->GetArrayLength(env, node_id) == 33);
15352         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
15353         LDKQueryShortChannelIds msg_conv;
15354         msg_conv.inner = (void*)(msg & (~1));
15355         msg_conv.is_owned = (msg & 1) || (msg == 0);
15356         msg_conv = QueryShortChannelIds_clone(&msg_conv);
15357         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
15358         *ret_copy = MessageSendEvent_send_short_ids_query(node_id_ref, msg_conv);
15359         uint64_t ret_ref = (uint64_t)ret_copy;
15360         return ret_ref;
15361 }
15362
15363 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1reply_1channel_1range(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
15364         LDKPublicKey node_id_ref;
15365         CHECK((*env)->GetArrayLength(env, node_id) == 33);
15366         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
15367         LDKReplyChannelRange msg_conv;
15368         msg_conv.inner = (void*)(msg & (~1));
15369         msg_conv.is_owned = (msg & 1) || (msg == 0);
15370         msg_conv = ReplyChannelRange_clone(&msg_conv);
15371         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
15372         *ret_copy = MessageSendEvent_send_reply_channel_range(node_id_ref, msg_conv);
15373         uint64_t ret_ref = (uint64_t)ret_copy;
15374         return ret_ref;
15375 }
15376
15377 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageSendEventsProvider_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
15378         if ((this_ptr & 1) != 0) return;
15379         LDKMessageSendEventsProvider this_ptr_conv = *(LDKMessageSendEventsProvider*)(((uint64_t)this_ptr) & ~1);
15380         FREE((void*)this_ptr);
15381         MessageSendEventsProvider_free(this_ptr_conv);
15382 }
15383
15384 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventsProvider_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
15385         if ((this_ptr & 1) != 0) return;
15386         LDKEventsProvider this_ptr_conv = *(LDKEventsProvider*)(((uint64_t)this_ptr) & ~1);
15387         FREE((void*)this_ptr);
15388         EventsProvider_free(this_ptr_conv);
15389 }
15390
15391 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
15392         if ((this_ptr & 1) != 0) return;
15393         LDKEventHandler this_ptr_conv = *(LDKEventHandler*)(((uint64_t)this_ptr) & ~1);
15394         FREE((void*)this_ptr);
15395         EventHandler_free(this_ptr_conv);
15396 }
15397
15398 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_APIError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
15399         if ((this_ptr & 1) != 0) return;
15400         LDKAPIError this_ptr_conv = *(LDKAPIError*)(((uint64_t)this_ptr) & ~1);
15401         FREE((void*)this_ptr);
15402         APIError_free(this_ptr_conv);
15403 }
15404
15405 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15406         LDKAPIError* orig_conv = (LDKAPIError*)orig;
15407         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
15408         *ret_copy = APIError_clone(orig_conv);
15409         uint64_t ret_ref = (uint64_t)ret_copy;
15410         return ret_ref;
15411 }
15412
15413 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1apimisuse_1error(JNIEnv *env, jclass clz, jstring err) {
15414         LDKStr err_conv = java_to_owned_str(env, err);
15415         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
15416         *ret_copy = APIError_apimisuse_error(err_conv);
15417         uint64_t ret_ref = (uint64_t)ret_copy;
15418         return ret_ref;
15419 }
15420
15421 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1fee_1rate_1too_1high(JNIEnv *env, jclass clz, jstring err, int32_t feerate) {
15422         LDKStr err_conv = java_to_owned_str(env, err);
15423         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
15424         *ret_copy = APIError_fee_rate_too_high(err_conv, feerate);
15425         uint64_t ret_ref = (uint64_t)ret_copy;
15426         return ret_ref;
15427 }
15428
15429 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1route_1error(JNIEnv *env, jclass clz, jstring err) {
15430         LDKStr err_conv = java_to_owned_str(env, err);
15431         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
15432         *ret_copy = APIError_route_error(err_conv);
15433         uint64_t ret_ref = (uint64_t)ret_copy;
15434         return ret_ref;
15435 }
15436
15437 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1channel_1unavailable(JNIEnv *env, jclass clz, jstring err) {
15438         LDKStr err_conv = java_to_owned_str(env, err);
15439         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
15440         *ret_copy = APIError_channel_unavailable(err_conv);
15441         uint64_t ret_ref = (uint64_t)ret_copy;
15442         return ret_ref;
15443 }
15444
15445 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1monitor_1update_1failed(JNIEnv *env, jclass clz) {
15446         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
15447         *ret_copy = APIError_monitor_update_failed();
15448         uint64_t ret_ref = (uint64_t)ret_copy;
15449         return ret_ref;
15450 }
15451
15452 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1incompatible_1shutdown_1script(JNIEnv *env, jclass clz, int64_t script) {
15453         LDKShutdownScript script_conv;
15454         script_conv.inner = (void*)(script & (~1));
15455         script_conv.is_owned = (script & 1) || (script == 0);
15456         script_conv = ShutdownScript_clone(&script_conv);
15457         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
15458         *ret_copy = APIError_incompatible_shutdown_script(script_conv);
15459         uint64_t ret_ref = (uint64_t)ret_copy;
15460         return ret_ref;
15461 }
15462
15463 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_sign(JNIEnv *env, jclass clz, int8_tArray msg, int8_tArray sk) {
15464         LDKu8slice msg_ref;
15465         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
15466         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
15467         unsigned char sk_arr[32];
15468         CHECK((*env)->GetArrayLength(env, sk) == 32);
15469         (*env)->GetByteArrayRegion(env, sk, 0, 32, sk_arr);
15470         unsigned char (*sk_ref)[32] = &sk_arr;
15471         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
15472         *ret_conv = sign(msg_ref, sk_ref);
15473         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
15474         return (uint64_t)ret_conv;
15475 }
15476
15477 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_recover_1pk(JNIEnv *env, jclass clz, int8_tArray msg, jstring sig) {
15478         LDKu8slice msg_ref;
15479         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
15480         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
15481         LDKStr sig_conv = java_to_owned_str(env, sig);
15482         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
15483         *ret_conv = recover_pk(msg_ref, sig_conv);
15484         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
15485         return (uint64_t)ret_conv;
15486 }
15487
15488 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_verify(JNIEnv *env, jclass clz, int8_tArray msg, jstring sig, int8_tArray pk) {
15489         LDKu8slice msg_ref;
15490         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
15491         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
15492         LDKStr sig_conv = java_to_owned_str(env, sig);
15493         LDKPublicKey pk_ref;
15494         CHECK((*env)->GetArrayLength(env, pk) == 33);
15495         (*env)->GetByteArrayRegion(env, pk, 0, 33, pk_ref.compressed_form);
15496         jboolean ret_val = verify(msg_ref, sig_conv, pk_ref);
15497         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
15498         return ret_val;
15499 }
15500
15501 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15502         LDKLevel* orig_conv = (LDKLevel*)(orig & ~1);
15503         jclass ret_conv = LDKLevel_to_java(env, Level_clone(orig_conv));
15504         return ret_conv;
15505 }
15506
15507 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1trace(JNIEnv *env, jclass clz) {
15508         jclass ret_conv = LDKLevel_to_java(env, Level_trace());
15509         return ret_conv;
15510 }
15511
15512 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1debug(JNIEnv *env, jclass clz) {
15513         jclass ret_conv = LDKLevel_to_java(env, Level_debug());
15514         return ret_conv;
15515 }
15516
15517 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1info(JNIEnv *env, jclass clz) {
15518         jclass ret_conv = LDKLevel_to_java(env, Level_info());
15519         return ret_conv;
15520 }
15521
15522 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1warn(JNIEnv *env, jclass clz) {
15523         jclass ret_conv = LDKLevel_to_java(env, Level_warn());
15524         return ret_conv;
15525 }
15526
15527 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1error(JNIEnv *env, jclass clz) {
15528         jclass ret_conv = LDKLevel_to_java(env, Level_error());
15529         return ret_conv;
15530 }
15531
15532 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Level_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
15533         LDKLevel* a_conv = (LDKLevel*)(a & ~1);
15534         LDKLevel* b_conv = (LDKLevel*)(b & ~1);
15535         jboolean ret_val = Level_eq(a_conv, b_conv);
15536         return ret_val;
15537 }
15538
15539 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Level_1hash(JNIEnv *env, jclass clz, int64_t o) {
15540         LDKLevel* o_conv = (LDKLevel*)(o & ~1);
15541         int64_t ret_val = Level_hash(o_conv);
15542         return ret_val;
15543 }
15544
15545 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1max(JNIEnv *env, jclass clz) {
15546         jclass ret_conv = LDKLevel_to_java(env, Level_max());
15547         return ret_conv;
15548 }
15549
15550 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Logger_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
15551         if ((this_ptr & 1) != 0) return;
15552         LDKLogger this_ptr_conv = *(LDKLogger*)(((uint64_t)this_ptr) & ~1);
15553         FREE((void*)this_ptr);
15554         Logger_free(this_ptr_conv);
15555 }
15556
15557 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
15558         LDKChannelHandshakeConfig this_obj_conv;
15559         this_obj_conv.inner = (void*)(this_obj & (~1));
15560         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15561         ChannelHandshakeConfig_free(this_obj_conv);
15562 }
15563
15564 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
15565         LDKChannelHandshakeConfig this_ptr_conv;
15566         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15567         this_ptr_conv.is_owned = false;
15568         int32_t ret_val = ChannelHandshakeConfig_get_minimum_depth(&this_ptr_conv);
15569         return ret_val;
15570 }
15571
15572 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
15573         LDKChannelHandshakeConfig this_ptr_conv;
15574         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15575         this_ptr_conv.is_owned = false;
15576         ChannelHandshakeConfig_set_minimum_depth(&this_ptr_conv, val);
15577 }
15578
15579 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1our_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
15580         LDKChannelHandshakeConfig this_ptr_conv;
15581         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15582         this_ptr_conv.is_owned = false;
15583         int16_t ret_val = ChannelHandshakeConfig_get_our_to_self_delay(&this_ptr_conv);
15584         return ret_val;
15585 }
15586
15587 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) {
15588         LDKChannelHandshakeConfig this_ptr_conv;
15589         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15590         this_ptr_conv.is_owned = false;
15591         ChannelHandshakeConfig_set_our_to_self_delay(&this_ptr_conv, val);
15592 }
15593
15594 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1our_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
15595         LDKChannelHandshakeConfig this_ptr_conv;
15596         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15597         this_ptr_conv.is_owned = false;
15598         int64_t ret_val = ChannelHandshakeConfig_get_our_htlc_minimum_msat(&this_ptr_conv);
15599         return ret_val;
15600 }
15601
15602 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) {
15603         LDKChannelHandshakeConfig this_ptr_conv;
15604         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15605         this_ptr_conv.is_owned = false;
15606         ChannelHandshakeConfig_set_our_htlc_minimum_msat(&this_ptr_conv, val);
15607 }
15608
15609 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) {
15610         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_new(minimum_depth_arg, our_to_self_delay_arg, our_htlc_minimum_msat_arg);
15611         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15612         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15613         uint64_t ret_ref = (uint64_t)ret_var.inner;
15614         if (ret_var.is_owned) {
15615                 ret_ref |= 1;
15616         }
15617         return ret_ref;
15618 }
15619
15620 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15621         LDKChannelHandshakeConfig orig_conv;
15622         orig_conv.inner = (void*)(orig & (~1));
15623         orig_conv.is_owned = false;
15624         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(&orig_conv);
15625         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15626         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15627         uint64_t ret_ref = (uint64_t)ret_var.inner;
15628         if (ret_var.is_owned) {
15629                 ret_ref |= 1;
15630         }
15631         return ret_ref;
15632 }
15633
15634 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1default(JNIEnv *env, jclass clz) {
15635         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_default();
15636         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15637         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15638         uint64_t ret_ref = (uint64_t)ret_var.inner;
15639         if (ret_var.is_owned) {
15640                 ret_ref |= 1;
15641         }
15642         return ret_ref;
15643 }
15644
15645 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
15646         LDKChannelHandshakeLimits this_obj_conv;
15647         this_obj_conv.inner = (void*)(this_obj & (~1));
15648         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15649         ChannelHandshakeLimits_free(this_obj_conv);
15650 }
15651
15652 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
15653         LDKChannelHandshakeLimits this_ptr_conv;
15654         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15655         this_ptr_conv.is_owned = false;
15656         int64_t ret_val = ChannelHandshakeLimits_get_min_funding_satoshis(&this_ptr_conv);
15657         return ret_val;
15658 }
15659
15660 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1min_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15661         LDKChannelHandshakeLimits this_ptr_conv;
15662         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15663         this_ptr_conv.is_owned = false;
15664         ChannelHandshakeLimits_set_min_funding_satoshis(&this_ptr_conv, val);
15665 }
15666
15667 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
15668         LDKChannelHandshakeLimits this_ptr_conv;
15669         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15670         this_ptr_conv.is_owned = false;
15671         int64_t ret_val = ChannelHandshakeLimits_get_max_htlc_minimum_msat(&this_ptr_conv);
15672         return ret_val;
15673 }
15674
15675 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) {
15676         LDKChannelHandshakeLimits this_ptr_conv;
15677         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15678         this_ptr_conv.is_owned = false;
15679         ChannelHandshakeLimits_set_max_htlc_minimum_msat(&this_ptr_conv, val);
15680 }
15681
15682 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) {
15683         LDKChannelHandshakeLimits this_ptr_conv;
15684         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15685         this_ptr_conv.is_owned = false;
15686         int64_t ret_val = ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(&this_ptr_conv);
15687         return ret_val;
15688 }
15689
15690 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) {
15691         LDKChannelHandshakeLimits this_ptr_conv;
15692         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15693         this_ptr_conv.is_owned = false;
15694         ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
15695 }
15696
15697 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
15698         LDKChannelHandshakeLimits this_ptr_conv;
15699         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15700         this_ptr_conv.is_owned = false;
15701         int64_t ret_val = ChannelHandshakeLimits_get_max_channel_reserve_satoshis(&this_ptr_conv);
15702         return ret_val;
15703 }
15704
15705 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) {
15706         LDKChannelHandshakeLimits this_ptr_conv;
15707         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15708         this_ptr_conv.is_owned = false;
15709         ChannelHandshakeLimits_set_max_channel_reserve_satoshis(&this_ptr_conv, val);
15710 }
15711
15712 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
15713         LDKChannelHandshakeLimits this_ptr_conv;
15714         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15715         this_ptr_conv.is_owned = false;
15716         int16_t ret_val = ChannelHandshakeLimits_get_min_max_accepted_htlcs(&this_ptr_conv);
15717         return ret_val;
15718 }
15719
15720 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) {
15721         LDKChannelHandshakeLimits this_ptr_conv;
15722         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15723         this_ptr_conv.is_owned = false;
15724         ChannelHandshakeLimits_set_min_max_accepted_htlcs(&this_ptr_conv, val);
15725 }
15726
15727 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
15728         LDKChannelHandshakeLimits this_ptr_conv;
15729         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15730         this_ptr_conv.is_owned = false;
15731         int32_t ret_val = ChannelHandshakeLimits_get_max_minimum_depth(&this_ptr_conv);
15732         return ret_val;
15733 }
15734
15735 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1max_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
15736         LDKChannelHandshakeLimits this_ptr_conv;
15737         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15738         this_ptr_conv.is_owned = false;
15739         ChannelHandshakeLimits_set_max_minimum_depth(&this_ptr_conv, val);
15740 }
15741
15742 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1force_1announced_1channel_1preference(JNIEnv *env, jclass clz, int64_t this_ptr) {
15743         LDKChannelHandshakeLimits this_ptr_conv;
15744         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15745         this_ptr_conv.is_owned = false;
15746         jboolean ret_val = ChannelHandshakeLimits_get_force_announced_channel_preference(&this_ptr_conv);
15747         return ret_val;
15748 }
15749
15750 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1force_1announced_1channel_1preference(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
15751         LDKChannelHandshakeLimits this_ptr_conv;
15752         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15753         this_ptr_conv.is_owned = false;
15754         ChannelHandshakeLimits_set_force_announced_channel_preference(&this_ptr_conv, val);
15755 }
15756
15757 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1their_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
15758         LDKChannelHandshakeLimits this_ptr_conv;
15759         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15760         this_ptr_conv.is_owned = false;
15761         int16_t ret_val = ChannelHandshakeLimits_get_their_to_self_delay(&this_ptr_conv);
15762         return ret_val;
15763 }
15764
15765 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) {
15766         LDKChannelHandshakeLimits this_ptr_conv;
15767         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15768         this_ptr_conv.is_owned = false;
15769         ChannelHandshakeLimits_set_their_to_self_delay(&this_ptr_conv, val);
15770 }
15771
15772 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) {
15773         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);
15774         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15775         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15776         uint64_t ret_ref = (uint64_t)ret_var.inner;
15777         if (ret_var.is_owned) {
15778                 ret_ref |= 1;
15779         }
15780         return ret_ref;
15781 }
15782
15783 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15784         LDKChannelHandshakeLimits orig_conv;
15785         orig_conv.inner = (void*)(orig & (~1));
15786         orig_conv.is_owned = false;
15787         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(&orig_conv);
15788         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15789         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15790         uint64_t ret_ref = (uint64_t)ret_var.inner;
15791         if (ret_var.is_owned) {
15792                 ret_ref |= 1;
15793         }
15794         return ret_ref;
15795 }
15796
15797 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1default(JNIEnv *env, jclass clz) {
15798         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_default();
15799         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15800         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15801         uint64_t ret_ref = (uint64_t)ret_var.inner;
15802         if (ret_var.is_owned) {
15803                 ret_ref |= 1;
15804         }
15805         return ret_ref;
15806 }
15807
15808 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
15809         LDKChannelConfig this_obj_conv;
15810         this_obj_conv.inner = (void*)(this_obj & (~1));
15811         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15812         ChannelConfig_free(this_obj_conv);
15813 }
15814
15815 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1forwarding_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
15816         LDKChannelConfig this_ptr_conv;
15817         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15818         this_ptr_conv.is_owned = false;
15819         int32_t ret_val = ChannelConfig_get_forwarding_fee_proportional_millionths(&this_ptr_conv);
15820         return ret_val;
15821 }
15822
15823 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1forwarding_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
15824         LDKChannelConfig this_ptr_conv;
15825         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15826         this_ptr_conv.is_owned = false;
15827         ChannelConfig_set_forwarding_fee_proportional_millionths(&this_ptr_conv, val);
15828 }
15829
15830 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1forwarding_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
15831         LDKChannelConfig this_ptr_conv;
15832         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15833         this_ptr_conv.is_owned = false;
15834         int32_t ret_val = ChannelConfig_get_forwarding_fee_base_msat(&this_ptr_conv);
15835         return ret_val;
15836 }
15837
15838 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1forwarding_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
15839         LDKChannelConfig this_ptr_conv;
15840         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15841         this_ptr_conv.is_owned = false;
15842         ChannelConfig_set_forwarding_fee_base_msat(&this_ptr_conv, val);
15843 }
15844
15845 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
15846         LDKChannelConfig this_ptr_conv;
15847         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15848         this_ptr_conv.is_owned = false;
15849         int16_t ret_val = ChannelConfig_get_cltv_expiry_delta(&this_ptr_conv);
15850         return ret_val;
15851 }
15852
15853 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
15854         LDKChannelConfig this_ptr_conv;
15855         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15856         this_ptr_conv.is_owned = false;
15857         ChannelConfig_set_cltv_expiry_delta(&this_ptr_conv, val);
15858 }
15859
15860 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1announced_1channel(JNIEnv *env, jclass clz, int64_t this_ptr) {
15861         LDKChannelConfig this_ptr_conv;
15862         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15863         this_ptr_conv.is_owned = false;
15864         jboolean ret_val = ChannelConfig_get_announced_channel(&this_ptr_conv);
15865         return ret_val;
15866 }
15867
15868 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1announced_1channel(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
15869         LDKChannelConfig this_ptr_conv;
15870         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15871         this_ptr_conv.is_owned = false;
15872         ChannelConfig_set_announced_channel(&this_ptr_conv, val);
15873 }
15874
15875 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1commit_1upfront_1shutdown_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
15876         LDKChannelConfig this_ptr_conv;
15877         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15878         this_ptr_conv.is_owned = false;
15879         jboolean ret_val = ChannelConfig_get_commit_upfront_shutdown_pubkey(&this_ptr_conv);
15880         return ret_val;
15881 }
15882
15883 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1commit_1upfront_1shutdown_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
15884         LDKChannelConfig this_ptr_conv;
15885         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15886         this_ptr_conv.is_owned = false;
15887         ChannelConfig_set_commit_upfront_shutdown_pubkey(&this_ptr_conv, val);
15888 }
15889
15890 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1max_1dust_1htlc_1exposure_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
15891         LDKChannelConfig this_ptr_conv;
15892         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15893         this_ptr_conv.is_owned = false;
15894         int64_t ret_val = ChannelConfig_get_max_dust_htlc_exposure_msat(&this_ptr_conv);
15895         return ret_val;
15896 }
15897
15898 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1max_1dust_1htlc_1exposure_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15899         LDKChannelConfig this_ptr_conv;
15900         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15901         this_ptr_conv.is_owned = false;
15902         ChannelConfig_set_max_dust_htlc_exposure_msat(&this_ptr_conv, val);
15903 }
15904
15905 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1force_1close_1avoidance_1max_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
15906         LDKChannelConfig this_ptr_conv;
15907         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15908         this_ptr_conv.is_owned = false;
15909         int64_t ret_val = ChannelConfig_get_force_close_avoidance_max_fee_satoshis(&this_ptr_conv);
15910         return ret_val;
15911 }
15912
15913 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1force_1close_1avoidance_1max_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15914         LDKChannelConfig this_ptr_conv;
15915         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15916         this_ptr_conv.is_owned = false;
15917         ChannelConfig_set_force_close_avoidance_max_fee_satoshis(&this_ptr_conv, val);
15918 }
15919
15920 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1new(JNIEnv *env, jclass clz, int32_t forwarding_fee_proportional_millionths_arg, int32_t forwarding_fee_base_msat_arg, int16_t cltv_expiry_delta_arg, jboolean announced_channel_arg, jboolean commit_upfront_shutdown_pubkey_arg, int64_t max_dust_htlc_exposure_msat_arg, int64_t force_close_avoidance_max_fee_satoshis_arg) {
15921         LDKChannelConfig ret_var = ChannelConfig_new(forwarding_fee_proportional_millionths_arg, forwarding_fee_base_msat_arg, cltv_expiry_delta_arg, announced_channel_arg, commit_upfront_shutdown_pubkey_arg, max_dust_htlc_exposure_msat_arg, force_close_avoidance_max_fee_satoshis_arg);
15922         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15923         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15924         uint64_t ret_ref = (uint64_t)ret_var.inner;
15925         if (ret_var.is_owned) {
15926                 ret_ref |= 1;
15927         }
15928         return ret_ref;
15929 }
15930
15931 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15932         LDKChannelConfig orig_conv;
15933         orig_conv.inner = (void*)(orig & (~1));
15934         orig_conv.is_owned = false;
15935         LDKChannelConfig ret_var = ChannelConfig_clone(&orig_conv);
15936         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15937         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15938         uint64_t ret_ref = (uint64_t)ret_var.inner;
15939         if (ret_var.is_owned) {
15940                 ret_ref |= 1;
15941         }
15942         return ret_ref;
15943 }
15944
15945 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1default(JNIEnv *env, jclass clz) {
15946         LDKChannelConfig ret_var = ChannelConfig_default();
15947         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15948         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15949         uint64_t ret_ref = (uint64_t)ret_var.inner;
15950         if (ret_var.is_owned) {
15951                 ret_ref |= 1;
15952         }
15953         return ret_ref;
15954 }
15955
15956 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1write(JNIEnv *env, jclass clz, int64_t obj) {
15957         LDKChannelConfig obj_conv;
15958         obj_conv.inner = (void*)(obj & (~1));
15959         obj_conv.is_owned = false;
15960         LDKCVec_u8Z ret_var = ChannelConfig_write(&obj_conv);
15961         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
15962         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
15963         CVec_u8Z_free(ret_var);
15964         return ret_arr;
15965 }
15966
15967 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
15968         LDKu8slice ser_ref;
15969         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
15970         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
15971         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
15972         *ret_conv = ChannelConfig_read(ser_ref);
15973         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
15974         return (uint64_t)ret_conv;
15975 }
15976
15977 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
15978         LDKUserConfig this_obj_conv;
15979         this_obj_conv.inner = (void*)(this_obj & (~1));
15980         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15981         UserConfig_free(this_obj_conv);
15982 }
15983
15984 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1own_1channel_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
15985         LDKUserConfig this_ptr_conv;
15986         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15987         this_ptr_conv.is_owned = false;
15988         LDKChannelHandshakeConfig ret_var = UserConfig_get_own_channel_config(&this_ptr_conv);
15989         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15990         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15991         uint64_t ret_ref = (uint64_t)ret_var.inner;
15992         if (ret_var.is_owned) {
15993                 ret_ref |= 1;
15994         }
15995         return ret_ref;
15996 }
15997
15998 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1own_1channel_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15999         LDKUserConfig this_ptr_conv;
16000         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16001         this_ptr_conv.is_owned = false;
16002         LDKChannelHandshakeConfig val_conv;
16003         val_conv.inner = (void*)(val & (~1));
16004         val_conv.is_owned = (val & 1) || (val == 0);
16005         val_conv = ChannelHandshakeConfig_clone(&val_conv);
16006         UserConfig_set_own_channel_config(&this_ptr_conv, val_conv);
16007 }
16008
16009 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1peer_1channel_1config_1limits(JNIEnv *env, jclass clz, int64_t this_ptr) {
16010         LDKUserConfig this_ptr_conv;
16011         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16012         this_ptr_conv.is_owned = false;
16013         LDKChannelHandshakeLimits ret_var = UserConfig_get_peer_channel_config_limits(&this_ptr_conv);
16014         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16015         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16016         uint64_t ret_ref = (uint64_t)ret_var.inner;
16017         if (ret_var.is_owned) {
16018                 ret_ref |= 1;
16019         }
16020         return ret_ref;
16021 }
16022
16023 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) {
16024         LDKUserConfig this_ptr_conv;
16025         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16026         this_ptr_conv.is_owned = false;
16027         LDKChannelHandshakeLimits val_conv;
16028         val_conv.inner = (void*)(val & (~1));
16029         val_conv.is_owned = (val & 1) || (val == 0);
16030         val_conv = ChannelHandshakeLimits_clone(&val_conv);
16031         UserConfig_set_peer_channel_config_limits(&this_ptr_conv, val_conv);
16032 }
16033
16034 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1channel_1options(JNIEnv *env, jclass clz, int64_t this_ptr) {
16035         LDKUserConfig this_ptr_conv;
16036         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16037         this_ptr_conv.is_owned = false;
16038         LDKChannelConfig ret_var = UserConfig_get_channel_options(&this_ptr_conv);
16039         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16040         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16041         uint64_t ret_ref = (uint64_t)ret_var.inner;
16042         if (ret_var.is_owned) {
16043                 ret_ref |= 1;
16044         }
16045         return ret_ref;
16046 }
16047
16048 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1channel_1options(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16049         LDKUserConfig this_ptr_conv;
16050         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16051         this_ptr_conv.is_owned = false;
16052         LDKChannelConfig val_conv;
16053         val_conv.inner = (void*)(val & (~1));
16054         val_conv.is_owned = (val & 1) || (val == 0);
16055         val_conv = ChannelConfig_clone(&val_conv);
16056         UserConfig_set_channel_options(&this_ptr_conv, val_conv);
16057 }
16058
16059 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1accept_1forwards_1to_1priv_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
16060         LDKUserConfig this_ptr_conv;
16061         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16062         this_ptr_conv.is_owned = false;
16063         jboolean ret_val = UserConfig_get_accept_forwards_to_priv_channels(&this_ptr_conv);
16064         return ret_val;
16065 }
16066
16067 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1accept_1forwards_1to_1priv_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
16068         LDKUserConfig this_ptr_conv;
16069         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16070         this_ptr_conv.is_owned = false;
16071         UserConfig_set_accept_forwards_to_priv_channels(&this_ptr_conv, val);
16072 }
16073
16074 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1new(JNIEnv *env, jclass clz, int64_t own_channel_config_arg, int64_t peer_channel_config_limits_arg, int64_t channel_options_arg, jboolean accept_forwards_to_priv_channels_arg) {
16075         LDKChannelHandshakeConfig own_channel_config_arg_conv;
16076         own_channel_config_arg_conv.inner = (void*)(own_channel_config_arg & (~1));
16077         own_channel_config_arg_conv.is_owned = (own_channel_config_arg & 1) || (own_channel_config_arg == 0);
16078         own_channel_config_arg_conv = ChannelHandshakeConfig_clone(&own_channel_config_arg_conv);
16079         LDKChannelHandshakeLimits peer_channel_config_limits_arg_conv;
16080         peer_channel_config_limits_arg_conv.inner = (void*)(peer_channel_config_limits_arg & (~1));
16081         peer_channel_config_limits_arg_conv.is_owned = (peer_channel_config_limits_arg & 1) || (peer_channel_config_limits_arg == 0);
16082         peer_channel_config_limits_arg_conv = ChannelHandshakeLimits_clone(&peer_channel_config_limits_arg_conv);
16083         LDKChannelConfig channel_options_arg_conv;
16084         channel_options_arg_conv.inner = (void*)(channel_options_arg & (~1));
16085         channel_options_arg_conv.is_owned = (channel_options_arg & 1) || (channel_options_arg == 0);
16086         channel_options_arg_conv = ChannelConfig_clone(&channel_options_arg_conv);
16087         LDKUserConfig ret_var = UserConfig_new(own_channel_config_arg_conv, peer_channel_config_limits_arg_conv, channel_options_arg_conv, accept_forwards_to_priv_channels_arg);
16088         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16089         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16090         uint64_t ret_ref = (uint64_t)ret_var.inner;
16091         if (ret_var.is_owned) {
16092                 ret_ref |= 1;
16093         }
16094         return ret_ref;
16095 }
16096
16097 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16098         LDKUserConfig orig_conv;
16099         orig_conv.inner = (void*)(orig & (~1));
16100         orig_conv.is_owned = false;
16101         LDKUserConfig ret_var = UserConfig_clone(&orig_conv);
16102         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16103         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16104         uint64_t ret_ref = (uint64_t)ret_var.inner;
16105         if (ret_var.is_owned) {
16106                 ret_ref |= 1;
16107         }
16108         return ret_ref;
16109 }
16110
16111 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1default(JNIEnv *env, jclass clz) {
16112         LDKUserConfig ret_var = UserConfig_default();
16113         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16114         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16115         uint64_t ret_ref = (uint64_t)ret_var.inner;
16116         if (ret_var.is_owned) {
16117                 ret_ref |= 1;
16118         }
16119         return ret_ref;
16120 }
16121
16122 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BestBlock_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
16123         LDKBestBlock this_obj_conv;
16124         this_obj_conv.inner = (void*)(this_obj & (~1));
16125         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16126         BestBlock_free(this_obj_conv);
16127 }
16128
16129 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16130         LDKBestBlock orig_conv;
16131         orig_conv.inner = (void*)(orig & (~1));
16132         orig_conv.is_owned = false;
16133         LDKBestBlock ret_var = BestBlock_clone(&orig_conv);
16134         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16135         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16136         uint64_t ret_ref = (uint64_t)ret_var.inner;
16137         if (ret_var.is_owned) {
16138                 ret_ref |= 1;
16139         }
16140         return ret_ref;
16141 }
16142
16143 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1from_1genesis(JNIEnv *env, jclass clz, jclass network) {
16144         LDKNetwork network_conv = LDKNetwork_from_java(env, network);
16145         LDKBestBlock ret_var = BestBlock_from_genesis(network_conv);
16146         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16147         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16148         uint64_t ret_ref = (uint64_t)ret_var.inner;
16149         if (ret_var.is_owned) {
16150                 ret_ref |= 1;
16151         }
16152         return ret_ref;
16153 }
16154
16155 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1new(JNIEnv *env, jclass clz, int8_tArray block_hash, int32_t height) {
16156         LDKThirtyTwoBytes block_hash_ref;
16157         CHECK((*env)->GetArrayLength(env, block_hash) == 32);
16158         (*env)->GetByteArrayRegion(env, block_hash, 0, 32, block_hash_ref.data);
16159         LDKBestBlock ret_var = BestBlock_new(block_hash_ref, height);
16160         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16161         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16162         uint64_t ret_ref = (uint64_t)ret_var.inner;
16163         if (ret_var.is_owned) {
16164                 ret_ref |= 1;
16165         }
16166         return ret_ref;
16167 }
16168
16169 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BestBlock_1block_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
16170         LDKBestBlock this_arg_conv;
16171         this_arg_conv.inner = (void*)(this_arg & (~1));
16172         this_arg_conv.is_owned = false;
16173         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
16174         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, BestBlock_block_hash(&this_arg_conv).data);
16175         return ret_arr;
16176 }
16177
16178 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1height(JNIEnv *env, jclass clz, int64_t this_arg) {
16179         LDKBestBlock this_arg_conv;
16180         this_arg_conv.inner = (void*)(this_arg & (~1));
16181         this_arg_conv.is_owned = false;
16182         int32_t ret_val = BestBlock_height(&this_arg_conv);
16183         return ret_val;
16184 }
16185
16186 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_AccessError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16187         LDKAccessError* orig_conv = (LDKAccessError*)(orig & ~1);
16188         jclass ret_conv = LDKAccessError_to_java(env, AccessError_clone(orig_conv));
16189         return ret_conv;
16190 }
16191
16192 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_AccessError_1unknown_1chain(JNIEnv *env, jclass clz) {
16193         jclass ret_conv = LDKAccessError_to_java(env, AccessError_unknown_chain());
16194         return ret_conv;
16195 }
16196
16197 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_AccessError_1unknown_1tx(JNIEnv *env, jclass clz) {
16198         jclass ret_conv = LDKAccessError_to_java(env, AccessError_unknown_tx());
16199         return ret_conv;
16200 }
16201
16202 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Access_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
16203         if ((this_ptr & 1) != 0) return;
16204         LDKAccess this_ptr_conv = *(LDKAccess*)(((uint64_t)this_ptr) & ~1);
16205         FREE((void*)this_ptr);
16206         Access_free(this_ptr_conv);
16207 }
16208
16209 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Listen_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
16210         if ((this_ptr & 1) != 0) return;
16211         LDKListen this_ptr_conv = *(LDKListen*)(((uint64_t)this_ptr) & ~1);
16212         FREE((void*)this_ptr);
16213         Listen_free(this_ptr_conv);
16214 }
16215
16216 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Confirm_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
16217         if ((this_ptr & 1) != 0) return;
16218         LDKConfirm this_ptr_conv = *(LDKConfirm*)(((uint64_t)this_ptr) & ~1);
16219         FREE((void*)this_ptr);
16220         Confirm_free(this_ptr_conv);
16221 }
16222
16223 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Watch_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
16224         if ((this_ptr & 1) != 0) return;
16225         LDKWatch this_ptr_conv = *(LDKWatch*)(((uint64_t)this_ptr) & ~1);
16226         FREE((void*)this_ptr);
16227         Watch_free(this_ptr_conv);
16228 }
16229
16230 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Filter_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
16231         if ((this_ptr & 1) != 0) return;
16232         LDKFilter this_ptr_conv = *(LDKFilter*)(((uint64_t)this_ptr) & ~1);
16233         FREE((void*)this_ptr);
16234         Filter_free(this_ptr_conv);
16235 }
16236
16237 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
16238         LDKWatchedOutput this_obj_conv;
16239         this_obj_conv.inner = (void*)(this_obj & (~1));
16240         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16241         WatchedOutput_free(this_obj_conv);
16242 }
16243
16244 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1block_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
16245         LDKWatchedOutput this_ptr_conv;
16246         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16247         this_ptr_conv.is_owned = false;
16248         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
16249         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, WatchedOutput_get_block_hash(&this_ptr_conv).data);
16250         return ret_arr;
16251 }
16252
16253 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1block_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
16254         LDKWatchedOutput this_ptr_conv;
16255         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16256         this_ptr_conv.is_owned = false;
16257         LDKThirtyTwoBytes val_ref;
16258         CHECK((*env)->GetArrayLength(env, val) == 32);
16259         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
16260         WatchedOutput_set_block_hash(&this_ptr_conv, val_ref);
16261 }
16262
16263 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
16264         LDKWatchedOutput this_ptr_conv;
16265         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16266         this_ptr_conv.is_owned = false;
16267         LDKOutPoint ret_var = WatchedOutput_get_outpoint(&this_ptr_conv);
16268         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16269         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16270         uint64_t ret_ref = (uint64_t)ret_var.inner;
16271         if (ret_var.is_owned) {
16272                 ret_ref |= 1;
16273         }
16274         return ret_ref;
16275 }
16276
16277 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16278         LDKWatchedOutput this_ptr_conv;
16279         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16280         this_ptr_conv.is_owned = false;
16281         LDKOutPoint val_conv;
16282         val_conv.inner = (void*)(val & (~1));
16283         val_conv.is_owned = (val & 1) || (val == 0);
16284         val_conv = OutPoint_clone(&val_conv);
16285         WatchedOutput_set_outpoint(&this_ptr_conv, val_conv);
16286 }
16287
16288 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1script_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
16289         LDKWatchedOutput this_ptr_conv;
16290         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16291         this_ptr_conv.is_owned = false;
16292         LDKu8slice ret_var = WatchedOutput_get_script_pubkey(&this_ptr_conv);
16293         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
16294         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
16295         return ret_arr;
16296 }
16297
16298 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1script_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
16299         LDKWatchedOutput this_ptr_conv;
16300         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16301         this_ptr_conv.is_owned = false;
16302         LDKCVec_u8Z val_ref;
16303         val_ref.datalen = (*env)->GetArrayLength(env, val);
16304         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
16305         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
16306         WatchedOutput_set_script_pubkey(&this_ptr_conv, val_ref);
16307 }
16308
16309 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) {
16310         LDKThirtyTwoBytes block_hash_arg_ref;
16311         CHECK((*env)->GetArrayLength(env, block_hash_arg) == 32);
16312         (*env)->GetByteArrayRegion(env, block_hash_arg, 0, 32, block_hash_arg_ref.data);
16313         LDKOutPoint outpoint_arg_conv;
16314         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
16315         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
16316         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
16317         LDKCVec_u8Z script_pubkey_arg_ref;
16318         script_pubkey_arg_ref.datalen = (*env)->GetArrayLength(env, script_pubkey_arg);
16319         script_pubkey_arg_ref.data = MALLOC(script_pubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
16320         (*env)->GetByteArrayRegion(env, script_pubkey_arg, 0, script_pubkey_arg_ref.datalen, script_pubkey_arg_ref.data);
16321         LDKWatchedOutput ret_var = WatchedOutput_new(block_hash_arg_ref, outpoint_arg_conv, script_pubkey_arg_ref);
16322         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16323         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16324         uint64_t ret_ref = (uint64_t)ret_var.inner;
16325         if (ret_var.is_owned) {
16326                 ret_ref |= 1;
16327         }
16328         return ret_ref;
16329 }
16330
16331 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16332         LDKWatchedOutput orig_conv;
16333         orig_conv.inner = (void*)(orig & (~1));
16334         orig_conv.is_owned = false;
16335         LDKWatchedOutput ret_var = WatchedOutput_clone(&orig_conv);
16336         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16337         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16338         uint64_t ret_ref = (uint64_t)ret_var.inner;
16339         if (ret_var.is_owned) {
16340                 ret_ref |= 1;
16341         }
16342         return ret_ref;
16343 }
16344
16345 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1hash(JNIEnv *env, jclass clz, int64_t o) {
16346         LDKWatchedOutput o_conv;
16347         o_conv.inner = (void*)(o & (~1));
16348         o_conv.is_owned = false;
16349         int64_t ret_val = WatchedOutput_hash(&o_conv);
16350         return ret_val;
16351 }
16352
16353 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BroadcasterInterface_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
16354         if ((this_ptr & 1) != 0) return;
16355         LDKBroadcasterInterface this_ptr_conv = *(LDKBroadcasterInterface*)(((uint64_t)this_ptr) & ~1);
16356         FREE((void*)this_ptr);
16357         BroadcasterInterface_free(this_ptr_conv);
16358 }
16359
16360 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16361         LDKConfirmationTarget* orig_conv = (LDKConfirmationTarget*)(orig & ~1);
16362         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_clone(orig_conv));
16363         return ret_conv;
16364 }
16365
16366 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1background(JNIEnv *env, jclass clz) {
16367         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_background());
16368         return ret_conv;
16369 }
16370
16371 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1normal(JNIEnv *env, jclass clz) {
16372         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_normal());
16373         return ret_conv;
16374 }
16375
16376 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1high_1priority(JNIEnv *env, jclass clz) {
16377         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_high_priority());
16378         return ret_conv;
16379 }
16380
16381 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
16382         LDKConfirmationTarget* a_conv = (LDKConfirmationTarget*)(a & ~1);
16383         LDKConfirmationTarget* b_conv = (LDKConfirmationTarget*)(b & ~1);
16384         jboolean ret_val = ConfirmationTarget_eq(a_conv, b_conv);
16385         return ret_val;
16386 }
16387
16388 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FeeEstimator_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
16389         if ((this_ptr & 1) != 0) return;
16390         LDKFeeEstimator this_ptr_conv = *(LDKFeeEstimator*)(((uint64_t)this_ptr) & ~1);
16391         FREE((void*)this_ptr);
16392         FeeEstimator_free(this_ptr_conv);
16393 }
16394
16395 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
16396         LDKChainMonitor this_obj_conv;
16397         this_obj_conv.inner = (void*)(this_obj & (~1));
16398         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16399         ChainMonitor_free(this_obj_conv);
16400 }
16401
16402 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) {
16403         LDKCOption_FilterZ chain_source_conv = *(LDKCOption_FilterZ*)(((uint64_t)chain_source) & ~1);
16404         // Warning: we may need a move here but no clone is available for LDKCOption_FilterZ
16405         if (chain_source_conv.tag == LDKCOption_FilterZ_Some) {
16406                 // Manually implement clone for Java trait instances
16407                 if (chain_source_conv.some.free == LDKFilter_JCalls_free) {
16408                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16409                         LDKFilter_JCalls_cloned(&chain_source_conv.some);
16410                 }
16411         }
16412         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
16413         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
16414                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16415                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
16416         }
16417         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
16418         if (logger_conv.free == LDKLogger_JCalls_free) {
16419                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16420                 LDKLogger_JCalls_cloned(&logger_conv);
16421         }
16422         LDKFeeEstimator feeest_conv = *(LDKFeeEstimator*)(((uint64_t)feeest) & ~1);
16423         if (feeest_conv.free == LDKFeeEstimator_JCalls_free) {
16424                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16425                 LDKFeeEstimator_JCalls_cloned(&feeest_conv);
16426         }
16427         LDKPersist persister_conv = *(LDKPersist*)(((uint64_t)persister) & ~1);
16428         if (persister_conv.free == LDKPersist_JCalls_free) {
16429                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16430                 LDKPersist_JCalls_cloned(&persister_conv);
16431         }
16432         LDKChainMonitor ret_var = ChainMonitor_new(chain_source_conv, broadcaster_conv, logger_conv, feeest_conv, persister_conv);
16433         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16434         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16435         uint64_t ret_ref = (uint64_t)ret_var.inner;
16436         if (ret_var.is_owned) {
16437                 ret_ref |= 1;
16438         }
16439         return ret_ref;
16440 }
16441
16442 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1get_1claimable_1balances(JNIEnv *env, jclass clz, int64_t this_arg, int64_tArray ignored_channels) {
16443         LDKChainMonitor this_arg_conv;
16444         this_arg_conv.inner = (void*)(this_arg & (~1));
16445         this_arg_conv.is_owned = false;
16446         LDKCVec_ChannelDetailsZ ignored_channels_constr;
16447         ignored_channels_constr.datalen = (*env)->GetArrayLength(env, ignored_channels);
16448         if (ignored_channels_constr.datalen > 0)
16449                 ignored_channels_constr.data = MALLOC(ignored_channels_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
16450         else
16451                 ignored_channels_constr.data = NULL;
16452         int64_t* ignored_channels_vals = (*env)->GetLongArrayElements (env, ignored_channels, NULL);
16453         for (size_t q = 0; q < ignored_channels_constr.datalen; q++) {
16454                 int64_t ignored_channels_conv_16 = ignored_channels_vals[q];
16455                 LDKChannelDetails ignored_channels_conv_16_conv;
16456                 ignored_channels_conv_16_conv.inner = (void*)(ignored_channels_conv_16 & (~1));
16457                 ignored_channels_conv_16_conv.is_owned = (ignored_channels_conv_16 & 1) || (ignored_channels_conv_16 == 0);
16458                 ignored_channels_conv_16_conv = ChannelDetails_clone(&ignored_channels_conv_16_conv);
16459                 ignored_channels_constr.data[q] = ignored_channels_conv_16_conv;
16460         }
16461         (*env)->ReleaseLongArrayElements(env, ignored_channels, ignored_channels_vals, 0);
16462         LDKCVec_BalanceZ ret_var = ChainMonitor_get_claimable_balances(&this_arg_conv, ignored_channels_constr);
16463         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
16464         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
16465         for (size_t j = 0; j < ret_var.datalen; j++) {
16466                 LDKBalance *ret_conv_9_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
16467                 *ret_conv_9_copy = Balance_clone(&ret_var.data[j]);
16468                 uint64_t ret_conv_9_ref = (uint64_t)ret_conv_9_copy;
16469                 ret_arr_ptr[j] = ret_conv_9_ref;
16470         }
16471         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
16472         FREE(ret_var.data);
16473         return ret_arr;
16474 }
16475
16476 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Listen(JNIEnv *env, jclass clz, int64_t this_arg) {
16477         LDKChainMonitor this_arg_conv;
16478         this_arg_conv.inner = (void*)(this_arg & (~1));
16479         this_arg_conv.is_owned = false;
16480         LDKListen* ret_ret =MALLOC(sizeof(LDKListen), "LDKListen");
16481         *ret_ret = ChainMonitor_as_Listen(&this_arg_conv);
16482         return (uint64_t)ret_ret;
16483 }
16484
16485 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Confirm(JNIEnv *env, jclass clz, int64_t this_arg) {
16486         LDKChainMonitor this_arg_conv;
16487         this_arg_conv.inner = (void*)(this_arg & (~1));
16488         this_arg_conv.is_owned = false;
16489         LDKConfirm* ret_ret =MALLOC(sizeof(LDKConfirm), "LDKConfirm");
16490         *ret_ret = ChainMonitor_as_Confirm(&this_arg_conv);
16491         return (uint64_t)ret_ret;
16492 }
16493
16494 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Watch(JNIEnv *env, jclass clz, int64_t this_arg) {
16495         LDKChainMonitor this_arg_conv;
16496         this_arg_conv.inner = (void*)(this_arg & (~1));
16497         this_arg_conv.is_owned = false;
16498         LDKWatch* ret_ret =MALLOC(sizeof(LDKWatch), "LDKWatch");
16499         *ret_ret = ChainMonitor_as_Watch(&this_arg_conv);
16500         return (uint64_t)ret_ret;
16501 }
16502
16503 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1EventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
16504         LDKChainMonitor this_arg_conv;
16505         this_arg_conv.inner = (void*)(this_arg & (~1));
16506         this_arg_conv.is_owned = false;
16507         LDKEventsProvider* ret_ret =MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
16508         *ret_ret = ChainMonitor_as_EventsProvider(&this_arg_conv);
16509         return (uint64_t)ret_ret;
16510 }
16511
16512 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
16513         LDKChannelMonitorUpdate this_obj_conv;
16514         this_obj_conv.inner = (void*)(this_obj & (~1));
16515         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16516         ChannelMonitorUpdate_free(this_obj_conv);
16517 }
16518
16519 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1get_1update_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
16520         LDKChannelMonitorUpdate this_ptr_conv;
16521         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16522         this_ptr_conv.is_owned = false;
16523         int64_t ret_val = ChannelMonitorUpdate_get_update_id(&this_ptr_conv);
16524         return ret_val;
16525 }
16526
16527 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1set_1update_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16528         LDKChannelMonitorUpdate this_ptr_conv;
16529         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16530         this_ptr_conv.is_owned = false;
16531         ChannelMonitorUpdate_set_update_id(&this_ptr_conv, val);
16532 }
16533
16534 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16535         LDKChannelMonitorUpdate orig_conv;
16536         orig_conv.inner = (void*)(orig & (~1));
16537         orig_conv.is_owned = false;
16538         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(&orig_conv);
16539         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16540         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16541         uint64_t ret_ref = (uint64_t)ret_var.inner;
16542         if (ret_var.is_owned) {
16543                 ret_ref |= 1;
16544         }
16545         return ret_ref;
16546 }
16547
16548 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
16549         LDKChannelMonitorUpdate obj_conv;
16550         obj_conv.inner = (void*)(obj & (~1));
16551         obj_conv.is_owned = false;
16552         LDKCVec_u8Z ret_var = ChannelMonitorUpdate_write(&obj_conv);
16553         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
16554         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
16555         CVec_u8Z_free(ret_var);
16556         return ret_arr;
16557 }
16558
16559 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
16560         LDKu8slice ser_ref;
16561         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
16562         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
16563         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
16564         *ret_conv = ChannelMonitorUpdate_read(ser_ref);
16565         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
16566         return (uint64_t)ret_conv;
16567 }
16568
16569 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateErr_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16570         LDKChannelMonitorUpdateErr* orig_conv = (LDKChannelMonitorUpdateErr*)(orig & ~1);
16571         jclass ret_conv = LDKChannelMonitorUpdateErr_to_java(env, ChannelMonitorUpdateErr_clone(orig_conv));
16572         return ret_conv;
16573 }
16574
16575 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateErr_1temporary_1failure(JNIEnv *env, jclass clz) {
16576         jclass ret_conv = LDKChannelMonitorUpdateErr_to_java(env, ChannelMonitorUpdateErr_temporary_failure());
16577         return ret_conv;
16578 }
16579
16580 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateErr_1permanent_1failure(JNIEnv *env, jclass clz) {
16581         jclass ret_conv = LDKChannelMonitorUpdateErr_to_java(env, ChannelMonitorUpdateErr_permanent_failure());
16582         return ret_conv;
16583 }
16584
16585 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorUpdateError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
16586         LDKMonitorUpdateError this_obj_conv;
16587         this_obj_conv.inner = (void*)(this_obj & (~1));
16588         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16589         MonitorUpdateError_free(this_obj_conv);
16590 }
16591
16592 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorUpdateError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16593         LDKMonitorUpdateError orig_conv;
16594         orig_conv.inner = (void*)(orig & (~1));
16595         orig_conv.is_owned = false;
16596         LDKMonitorUpdateError ret_var = MonitorUpdateError_clone(&orig_conv);
16597         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16598         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16599         uint64_t ret_ref = (uint64_t)ret_var.inner;
16600         if (ret_var.is_owned) {
16601                 ret_ref |= 1;
16602         }
16603         return ret_ref;
16604 }
16605
16606 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
16607         if ((this_ptr & 1) != 0) return;
16608         LDKMonitorEvent this_ptr_conv = *(LDKMonitorEvent*)(((uint64_t)this_ptr) & ~1);
16609         FREE((void*)this_ptr);
16610         MonitorEvent_free(this_ptr_conv);
16611 }
16612
16613 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16614         LDKMonitorEvent* orig_conv = (LDKMonitorEvent*)orig;
16615         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
16616         *ret_copy = MonitorEvent_clone(orig_conv);
16617         uint64_t ret_ref = (uint64_t)ret_copy;
16618         return ret_ref;
16619 }
16620
16621 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1htlcevent(JNIEnv *env, jclass clz, int64_t a) {
16622         LDKHTLCUpdate a_conv;
16623         a_conv.inner = (void*)(a & (~1));
16624         a_conv.is_owned = (a & 1) || (a == 0);
16625         a_conv = HTLCUpdate_clone(&a_conv);
16626         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
16627         *ret_copy = MonitorEvent_htlcevent(a_conv);
16628         uint64_t ret_ref = (uint64_t)ret_copy;
16629         return ret_ref;
16630 }
16631
16632 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1commitment_1tx_1confirmed(JNIEnv *env, jclass clz, int64_t a) {
16633         LDKOutPoint a_conv;
16634         a_conv.inner = (void*)(a & (~1));
16635         a_conv.is_owned = (a & 1) || (a == 0);
16636         a_conv = OutPoint_clone(&a_conv);
16637         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
16638         *ret_copy = MonitorEvent_commitment_tx_confirmed(a_conv);
16639         uint64_t ret_ref = (uint64_t)ret_copy;
16640         return ret_ref;
16641 }
16642
16643 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
16644         LDKHTLCUpdate this_obj_conv;
16645         this_obj_conv.inner = (void*)(this_obj & (~1));
16646         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16647         HTLCUpdate_free(this_obj_conv);
16648 }
16649
16650 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16651         LDKHTLCUpdate orig_conv;
16652         orig_conv.inner = (void*)(orig & (~1));
16653         orig_conv.is_owned = false;
16654         LDKHTLCUpdate ret_var = HTLCUpdate_clone(&orig_conv);
16655         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16656         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16657         uint64_t ret_ref = (uint64_t)ret_var.inner;
16658         if (ret_var.is_owned) {
16659                 ret_ref |= 1;
16660         }
16661         return ret_ref;
16662 }
16663
16664 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
16665         LDKHTLCUpdate obj_conv;
16666         obj_conv.inner = (void*)(obj & (~1));
16667         obj_conv.is_owned = false;
16668         LDKCVec_u8Z ret_var = HTLCUpdate_write(&obj_conv);
16669         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
16670         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
16671         CVec_u8Z_free(ret_var);
16672         return ret_arr;
16673 }
16674
16675 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
16676         LDKu8slice ser_ref;
16677         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
16678         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
16679         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
16680         *ret_conv = HTLCUpdate_read(ser_ref);
16681         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
16682         return (uint64_t)ret_conv;
16683 }
16684
16685 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Balance_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
16686         if ((this_ptr & 1) != 0) return;
16687         LDKBalance this_ptr_conv = *(LDKBalance*)(((uint64_t)this_ptr) & ~1);
16688         FREE((void*)this_ptr);
16689         Balance_free(this_ptr_conv);
16690 }
16691
16692 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16693         LDKBalance* orig_conv = (LDKBalance*)orig;
16694         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
16695         *ret_copy = Balance_clone(orig_conv);
16696         uint64_t ret_ref = (uint64_t)ret_copy;
16697         return ret_ref;
16698 }
16699
16700 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1claimable_1on_1channel_1close(JNIEnv *env, jclass clz, int64_t claimable_amount_satoshis) {
16701         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
16702         *ret_copy = Balance_claimable_on_channel_close(claimable_amount_satoshis);
16703         uint64_t ret_ref = (uint64_t)ret_copy;
16704         return ret_ref;
16705 }
16706
16707 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1claimable_1awaiting_1confirmations(JNIEnv *env, jclass clz, int64_t claimable_amount_satoshis, int32_t confirmation_height) {
16708         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
16709         *ret_copy = Balance_claimable_awaiting_confirmations(claimable_amount_satoshis, confirmation_height);
16710         uint64_t ret_ref = (uint64_t)ret_copy;
16711         return ret_ref;
16712 }
16713
16714 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1contentious_1claimable(JNIEnv *env, jclass clz, int64_t claimable_amount_satoshis, int32_t timeout_height) {
16715         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
16716         *ret_copy = Balance_contentious_claimable(claimable_amount_satoshis, timeout_height);
16717         uint64_t ret_ref = (uint64_t)ret_copy;
16718         return ret_ref;
16719 }
16720
16721 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1maybe_1claimable_1htlcawaiting_1timeout(JNIEnv *env, jclass clz, int64_t claimable_amount_satoshis, int32_t claimable_height) {
16722         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
16723         *ret_copy = Balance_maybe_claimable_htlcawaiting_timeout(claimable_amount_satoshis, claimable_height);
16724         uint64_t ret_ref = (uint64_t)ret_copy;
16725         return ret_ref;
16726 }
16727
16728 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Balance_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
16729         LDKBalance* a_conv = (LDKBalance*)a;
16730         LDKBalance* b_conv = (LDKBalance*)b;
16731         jboolean ret_val = Balance_eq(a_conv, b_conv);
16732         return ret_val;
16733 }
16734
16735 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
16736         LDKChannelMonitor this_obj_conv;
16737         this_obj_conv.inner = (void*)(this_obj & (~1));
16738         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16739         ChannelMonitor_free(this_obj_conv);
16740 }
16741
16742 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16743         LDKChannelMonitor orig_conv;
16744         orig_conv.inner = (void*)(orig & (~1));
16745         orig_conv.is_owned = false;
16746         LDKChannelMonitor ret_var = ChannelMonitor_clone(&orig_conv);
16747         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16748         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16749         uint64_t ret_ref = (uint64_t)ret_var.inner;
16750         if (ret_var.is_owned) {
16751                 ret_ref |= 1;
16752         }
16753         return ret_ref;
16754 }
16755
16756 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1write(JNIEnv *env, jclass clz, int64_t obj) {
16757         LDKChannelMonitor obj_conv;
16758         obj_conv.inner = (void*)(obj & (~1));
16759         obj_conv.is_owned = false;
16760         LDKCVec_u8Z ret_var = ChannelMonitor_write(&obj_conv);
16761         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
16762         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
16763         CVec_u8Z_free(ret_var);
16764         return ret_arr;
16765 }
16766
16767 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) {
16768         LDKChannelMonitor this_arg_conv;
16769         this_arg_conv.inner = (void*)(this_arg & (~1));
16770         this_arg_conv.is_owned = false;
16771         LDKChannelMonitorUpdate updates_conv;
16772         updates_conv.inner = (void*)(updates & (~1));
16773         updates_conv.is_owned = false;
16774         LDKBroadcasterInterface* broadcaster_conv = (LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
16775         LDKFeeEstimator* fee_estimator_conv = (LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
16776         LDKLogger* logger_conv = (LDKLogger*)(((uint64_t)logger) & ~1);
16777         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
16778         *ret_conv = ChannelMonitor_update_monitor(&this_arg_conv, &updates_conv, broadcaster_conv, fee_estimator_conv, logger_conv);
16779         return (uint64_t)ret_conv;
16780 }
16781
16782 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1latest_1update_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
16783         LDKChannelMonitor this_arg_conv;
16784         this_arg_conv.inner = (void*)(this_arg & (~1));
16785         this_arg_conv.is_owned = false;
16786         int64_t ret_val = ChannelMonitor_get_latest_update_id(&this_arg_conv);
16787         return ret_val;
16788 }
16789
16790 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_arg) {
16791         LDKChannelMonitor this_arg_conv;
16792         this_arg_conv.inner = (void*)(this_arg & (~1));
16793         this_arg_conv.is_owned = false;
16794         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
16795         *ret_conv = ChannelMonitor_get_funding_txo(&this_arg_conv);
16796         return ((uint64_t)ret_conv);
16797 }
16798
16799 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1outputs_1to_1watch(JNIEnv *env, jclass clz, int64_t this_arg) {
16800         LDKChannelMonitor this_arg_conv;
16801         this_arg_conv.inner = (void*)(this_arg & (~1));
16802         this_arg_conv.is_owned = false;
16803         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ ret_var = ChannelMonitor_get_outputs_to_watch(&this_arg_conv);
16804         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
16805         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
16806         for (size_t o = 0; o < ret_var.datalen; o++) {
16807                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv_40_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
16808                 *ret_conv_40_conv = ret_var.data[o];
16809                 ret_arr_ptr[o] = ((uint64_t)ret_conv_40_conv);
16810         }
16811         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
16812         FREE(ret_var.data);
16813         return ret_arr;
16814 }
16815
16816 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1load_1outputs_1to_1watch(JNIEnv *env, jclass clz, int64_t this_arg, int64_t filter) {
16817         LDKChannelMonitor this_arg_conv;
16818         this_arg_conv.inner = (void*)(this_arg & (~1));
16819         this_arg_conv.is_owned = false;
16820         LDKFilter* filter_conv = (LDKFilter*)(((uint64_t)filter) & ~1);
16821         ChannelMonitor_load_outputs_to_watch(&this_arg_conv, filter_conv);
16822 }
16823
16824 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1and_1clear_1pending_1monitor_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
16825         LDKChannelMonitor this_arg_conv;
16826         this_arg_conv.inner = (void*)(this_arg & (~1));
16827         this_arg_conv.is_owned = false;
16828         LDKCVec_MonitorEventZ ret_var = ChannelMonitor_get_and_clear_pending_monitor_events(&this_arg_conv);
16829         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
16830         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
16831         for (size_t o = 0; o < ret_var.datalen; o++) {
16832                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
16833                 *ret_conv_14_copy = MonitorEvent_clone(&ret_var.data[o]);
16834                 uint64_t ret_conv_14_ref = (uint64_t)ret_conv_14_copy;
16835                 ret_arr_ptr[o] = ret_conv_14_ref;
16836         }
16837         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
16838         FREE(ret_var.data);
16839         return ret_arr;
16840 }
16841
16842 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1and_1clear_1pending_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
16843         LDKChannelMonitor this_arg_conv;
16844         this_arg_conv.inner = (void*)(this_arg & (~1));
16845         this_arg_conv.is_owned = false;
16846         LDKCVec_EventZ ret_var = ChannelMonitor_get_and_clear_pending_events(&this_arg_conv);
16847         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
16848         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
16849         for (size_t h = 0; h < ret_var.datalen; h++) {
16850                 LDKEvent *ret_conv_7_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
16851                 *ret_conv_7_copy = Event_clone(&ret_var.data[h]);
16852                 uint64_t ret_conv_7_ref = (uint64_t)ret_conv_7_copy;
16853                 ret_arr_ptr[h] = ret_conv_7_ref;
16854         }
16855         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
16856         FREE(ret_var.data);
16857         return ret_arr;
16858 }
16859
16860 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) {
16861         LDKChannelMonitor this_arg_conv;
16862         this_arg_conv.inner = (void*)(this_arg & (~1));
16863         this_arg_conv.is_owned = false;
16864         LDKLogger* logger_conv = (LDKLogger*)(((uint64_t)logger) & ~1);
16865         LDKCVec_TransactionZ ret_var = ChannelMonitor_get_latest_holder_commitment_txn(&this_arg_conv, logger_conv);
16866         jobjectArray ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
16867         ;
16868         for (size_t i = 0; i < ret_var.datalen; i++) {
16869                 LDKTransaction ret_conv_8_var = ret_var.data[i];
16870                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, ret_conv_8_var.datalen);
16871                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, ret_conv_8_var.datalen, ret_conv_8_var.data);
16872                 Transaction_free(ret_conv_8_var);
16873                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
16874         }
16875         FREE(ret_var.data);
16876         return ret_arr;
16877 }
16878
16879 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) {
16880         LDKChannelMonitor this_arg_conv;
16881         this_arg_conv.inner = (void*)(this_arg & (~1));
16882         this_arg_conv.is_owned = false;
16883         unsigned char header_arr[80];
16884         CHECK((*env)->GetArrayLength(env, header) == 80);
16885         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
16886         unsigned char (*header_ref)[80] = &header_arr;
16887         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
16888         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
16889         if (txdata_constr.datalen > 0)
16890                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
16891         else
16892                 txdata_constr.data = NULL;
16893         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
16894         for (size_t c = 0; c < txdata_constr.datalen; c++) {
16895                 int64_t txdata_conv_28 = txdata_vals[c];
16896                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_28) & ~1);
16897                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_28) & ~1));
16898                 txdata_constr.data[c] = txdata_conv_28_conv;
16899         }
16900         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
16901         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
16902         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
16903                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16904                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
16905         }
16906         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
16907         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
16908                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16909                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
16910         }
16911         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
16912         if (logger_conv.free == LDKLogger_JCalls_free) {
16913                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16914                 LDKLogger_JCalls_cloned(&logger_conv);
16915         }
16916         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);
16917         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
16918         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
16919         for (size_t n = 0; n < ret_var.datalen; n++) {
16920                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
16921                 *ret_conv_39_conv = ret_var.data[n];
16922                 ret_arr_ptr[n] = ((uint64_t)ret_conv_39_conv);
16923         }
16924         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
16925         FREE(ret_var.data);
16926         return ret_arr;
16927 }
16928
16929 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) {
16930         LDKChannelMonitor this_arg_conv;
16931         this_arg_conv.inner = (void*)(this_arg & (~1));
16932         this_arg_conv.is_owned = false;
16933         unsigned char header_arr[80];
16934         CHECK((*env)->GetArrayLength(env, header) == 80);
16935         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
16936         unsigned char (*header_ref)[80] = &header_arr;
16937         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
16938         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
16939                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16940                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
16941         }
16942         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
16943         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
16944                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16945                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
16946         }
16947         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
16948         if (logger_conv.free == LDKLogger_JCalls_free) {
16949                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16950                 LDKLogger_JCalls_cloned(&logger_conv);
16951         }
16952         ChannelMonitor_block_disconnected(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
16953 }
16954
16955 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) {
16956         LDKChannelMonitor this_arg_conv;
16957         this_arg_conv.inner = (void*)(this_arg & (~1));
16958         this_arg_conv.is_owned = false;
16959         unsigned char header_arr[80];
16960         CHECK((*env)->GetArrayLength(env, header) == 80);
16961         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
16962         unsigned char (*header_ref)[80] = &header_arr;
16963         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
16964         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
16965         if (txdata_constr.datalen > 0)
16966                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
16967         else
16968                 txdata_constr.data = NULL;
16969         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
16970         for (size_t c = 0; c < txdata_constr.datalen; c++) {
16971                 int64_t txdata_conv_28 = txdata_vals[c];
16972                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_28) & ~1);
16973                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_28) & ~1));
16974                 txdata_constr.data[c] = txdata_conv_28_conv;
16975         }
16976         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
16977         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
16978         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
16979                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16980                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
16981         }
16982         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
16983         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
16984                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16985                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
16986         }
16987         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
16988         if (logger_conv.free == LDKLogger_JCalls_free) {
16989                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16990                 LDKLogger_JCalls_cloned(&logger_conv);
16991         }
16992         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);
16993         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
16994         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
16995         for (size_t n = 0; n < ret_var.datalen; n++) {
16996                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
16997                 *ret_conv_39_conv = ret_var.data[n];
16998                 ret_arr_ptr[n] = ((uint64_t)ret_conv_39_conv);
16999         }
17000         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
17001         FREE(ret_var.data);
17002         return ret_arr;
17003 }
17004
17005 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) {
17006         LDKChannelMonitor this_arg_conv;
17007         this_arg_conv.inner = (void*)(this_arg & (~1));
17008         this_arg_conv.is_owned = false;
17009         unsigned char txid_arr[32];
17010         CHECK((*env)->GetArrayLength(env, txid) == 32);
17011         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
17012         unsigned char (*txid_ref)[32] = &txid_arr;
17013         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
17014         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
17015                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
17016                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
17017         }
17018         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
17019         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
17020                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
17021                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
17022         }
17023         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
17024         if (logger_conv.free == LDKLogger_JCalls_free) {
17025                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
17026                 LDKLogger_JCalls_cloned(&logger_conv);
17027         }
17028         ChannelMonitor_transaction_unconfirmed(&this_arg_conv, txid_ref, broadcaster_conv, fee_estimator_conv, logger_conv);
17029 }
17030
17031 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) {
17032         LDKChannelMonitor this_arg_conv;
17033         this_arg_conv.inner = (void*)(this_arg & (~1));
17034         this_arg_conv.is_owned = false;
17035         unsigned char header_arr[80];
17036         CHECK((*env)->GetArrayLength(env, header) == 80);
17037         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
17038         unsigned char (*header_ref)[80] = &header_arr;
17039         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
17040         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
17041                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
17042                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
17043         }
17044         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
17045         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
17046                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
17047                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
17048         }
17049         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
17050         if (logger_conv.free == LDKLogger_JCalls_free) {
17051                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
17052                 LDKLogger_JCalls_cloned(&logger_conv);
17053         }
17054         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ ret_var = ChannelMonitor_best_block_updated(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
17055         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
17056         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
17057         for (size_t n = 0; n < ret_var.datalen; n++) {
17058                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
17059                 *ret_conv_39_conv = ret_var.data[n];
17060                 ret_arr_ptr[n] = ((uint64_t)ret_conv_39_conv);
17061         }
17062         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
17063         FREE(ret_var.data);
17064         return ret_arr;
17065 }
17066
17067 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1relevant_1txids(JNIEnv *env, jclass clz, int64_t this_arg) {
17068         LDKChannelMonitor this_arg_conv;
17069         this_arg_conv.inner = (void*)(this_arg & (~1));
17070         this_arg_conv.is_owned = false;
17071         LDKCVec_TxidZ ret_var = ChannelMonitor_get_relevant_txids(&this_arg_conv);
17072         jobjectArray ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
17073         ;
17074         for (size_t i = 0; i < ret_var.datalen; i++) {
17075                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 32);
17076                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 32, ret_var.data[i].data);
17077                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
17078         }
17079         FREE(ret_var.data);
17080         return ret_arr;
17081 }
17082
17083 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1current_1best_1block(JNIEnv *env, jclass clz, int64_t this_arg) {
17084         LDKChannelMonitor this_arg_conv;
17085         this_arg_conv.inner = (void*)(this_arg & (~1));
17086         this_arg_conv.is_owned = false;
17087         LDKBestBlock ret_var = ChannelMonitor_current_best_block(&this_arg_conv);
17088         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17089         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17090         uint64_t ret_ref = (uint64_t)ret_var.inner;
17091         if (ret_var.is_owned) {
17092                 ret_ref |= 1;
17093         }
17094         return ret_ref;
17095 }
17096
17097 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1claimable_1balances(JNIEnv *env, jclass clz, int64_t this_arg) {
17098         LDKChannelMonitor this_arg_conv;
17099         this_arg_conv.inner = (void*)(this_arg & (~1));
17100         this_arg_conv.is_owned = false;
17101         LDKCVec_BalanceZ ret_var = ChannelMonitor_get_claimable_balances(&this_arg_conv);
17102         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
17103         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
17104         for (size_t j = 0; j < ret_var.datalen; j++) {
17105                 LDKBalance *ret_conv_9_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
17106                 *ret_conv_9_copy = Balance_clone(&ret_var.data[j]);
17107                 uint64_t ret_conv_9_ref = (uint64_t)ret_conv_9_copy;
17108                 ret_arr_ptr[j] = ret_conv_9_ref;
17109         }
17110         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
17111         FREE(ret_var.data);
17112         return ret_arr;
17113 }
17114
17115 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Persist_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
17116         if ((this_ptr & 1) != 0) return;
17117         LDKPersist this_ptr_conv = *(LDKPersist*)(((uint64_t)this_ptr) & ~1);
17118         FREE((void*)this_ptr);
17119         Persist_free(this_ptr_conv);
17120 }
17121
17122 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
17123         LDKu8slice ser_ref;
17124         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17125         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17126         LDKKeysInterface* arg_conv = (LDKKeysInterface*)(((uint64_t)arg) & ~1);
17127         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
17128         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_read(ser_ref, arg_conv);
17129         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17130         return (uint64_t)ret_conv;
17131 }
17132
17133 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17134         LDKOutPoint this_obj_conv;
17135         this_obj_conv.inner = (void*)(this_obj & (~1));
17136         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17137         OutPoint_free(this_obj_conv);
17138 }
17139
17140 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1get_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
17141         LDKOutPoint this_ptr_conv;
17142         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17143         this_ptr_conv.is_owned = false;
17144         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
17145         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OutPoint_get_txid(&this_ptr_conv));
17146         return ret_arr;
17147 }
17148
17149 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1set_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17150         LDKOutPoint this_ptr_conv;
17151         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17152         this_ptr_conv.is_owned = false;
17153         LDKThirtyTwoBytes val_ref;
17154         CHECK((*env)->GetArrayLength(env, val) == 32);
17155         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
17156         OutPoint_set_txid(&this_ptr_conv, val_ref);
17157 }
17158
17159 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1get_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
17160         LDKOutPoint this_ptr_conv;
17161         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17162         this_ptr_conv.is_owned = false;
17163         int16_t ret_val = OutPoint_get_index(&this_ptr_conv);
17164         return ret_val;
17165 }
17166
17167 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1set_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
17168         LDKOutPoint this_ptr_conv;
17169         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17170         this_ptr_conv.is_owned = false;
17171         OutPoint_set_index(&this_ptr_conv, val);
17172 }
17173
17174 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1new(JNIEnv *env, jclass clz, int8_tArray txid_arg, int16_t index_arg) {
17175         LDKThirtyTwoBytes txid_arg_ref;
17176         CHECK((*env)->GetArrayLength(env, txid_arg) == 32);
17177         (*env)->GetByteArrayRegion(env, txid_arg, 0, 32, txid_arg_ref.data);
17178         LDKOutPoint ret_var = OutPoint_new(txid_arg_ref, index_arg);
17179         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17180         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17181         uint64_t ret_ref = (uint64_t)ret_var.inner;
17182         if (ret_var.is_owned) {
17183                 ret_ref |= 1;
17184         }
17185         return ret_ref;
17186 }
17187
17188 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17189         LDKOutPoint orig_conv;
17190         orig_conv.inner = (void*)(orig & (~1));
17191         orig_conv.is_owned = false;
17192         LDKOutPoint ret_var = OutPoint_clone(&orig_conv);
17193         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17194         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17195         uint64_t ret_ref = (uint64_t)ret_var.inner;
17196         if (ret_var.is_owned) {
17197                 ret_ref |= 1;
17198         }
17199         return ret_ref;
17200 }
17201
17202 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_OutPoint_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
17203         LDKOutPoint a_conv;
17204         a_conv.inner = (void*)(a & (~1));
17205         a_conv.is_owned = false;
17206         LDKOutPoint b_conv;
17207         b_conv.inner = (void*)(b & (~1));
17208         b_conv.is_owned = false;
17209         jboolean ret_val = OutPoint_eq(&a_conv, &b_conv);
17210         return ret_val;
17211 }
17212
17213 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1hash(JNIEnv *env, jclass clz, int64_t o) {
17214         LDKOutPoint o_conv;
17215         o_conv.inner = (void*)(o & (~1));
17216         o_conv.is_owned = false;
17217         int64_t ret_val = OutPoint_hash(&o_conv);
17218         return ret_val;
17219 }
17220
17221 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1to_1channel_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
17222         LDKOutPoint this_arg_conv;
17223         this_arg_conv.inner = (void*)(this_arg & (~1));
17224         this_arg_conv.is_owned = false;
17225         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
17226         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, OutPoint_to_channel_id(&this_arg_conv).data);
17227         return ret_arr;
17228 }
17229
17230 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1write(JNIEnv *env, jclass clz, int64_t obj) {
17231         LDKOutPoint obj_conv;
17232         obj_conv.inner = (void*)(obj & (~1));
17233         obj_conv.is_owned = false;
17234         LDKCVec_u8Z ret_var = OutPoint_write(&obj_conv);
17235         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17236         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17237         CVec_u8Z_free(ret_var);
17238         return ret_arr;
17239 }
17240
17241 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17242         LDKu8slice ser_ref;
17243         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17244         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17245         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
17246         *ret_conv = OutPoint_read(ser_ref);
17247         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17248         return (uint64_t)ret_conv;
17249 }
17250
17251 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17252         LDKDelayedPaymentOutputDescriptor this_obj_conv;
17253         this_obj_conv.inner = (void*)(this_obj & (~1));
17254         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17255         DelayedPaymentOutputDescriptor_free(this_obj_conv);
17256 }
17257
17258 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
17259         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
17260         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17261         this_ptr_conv.is_owned = false;
17262         LDKOutPoint ret_var = DelayedPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
17263         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17264         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17265         uint64_t ret_ref = (uint64_t)ret_var.inner;
17266         if (ret_var.is_owned) {
17267                 ret_ref |= 1;
17268         }
17269         return ret_ref;
17270 }
17271
17272 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17273         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
17274         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17275         this_ptr_conv.is_owned = false;
17276         LDKOutPoint val_conv;
17277         val_conv.inner = (void*)(val & (~1));
17278         val_conv.is_owned = (val & 1) || (val == 0);
17279         val_conv = OutPoint_clone(&val_conv);
17280         DelayedPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
17281 }
17282
17283 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
17284         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
17285         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17286         this_ptr_conv.is_owned = false;
17287         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
17288         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DelayedPaymentOutputDescriptor_get_per_commitment_point(&this_ptr_conv).compressed_form);
17289         return ret_arr;
17290 }
17291
17292 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17293         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
17294         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17295         this_ptr_conv.is_owned = false;
17296         LDKPublicKey val_ref;
17297         CHECK((*env)->GetArrayLength(env, val) == 33);
17298         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
17299         DelayedPaymentOutputDescriptor_set_per_commitment_point(&this_ptr_conv, val_ref);
17300 }
17301
17302 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
17303         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
17304         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17305         this_ptr_conv.is_owned = false;
17306         int16_t ret_val = DelayedPaymentOutputDescriptor_get_to_self_delay(&this_ptr_conv);
17307         return ret_val;
17308 }
17309
17310 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
17311         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
17312         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17313         this_ptr_conv.is_owned = false;
17314         DelayedPaymentOutputDescriptor_set_to_self_delay(&this_ptr_conv, val);
17315 }
17316
17317 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1output(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17318         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
17319         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17320         this_ptr_conv.is_owned = false;
17321         LDKTxOut val_conv = *(LDKTxOut*)(((uint64_t)val) & ~1);
17322         val_conv = TxOut_clone((LDKTxOut*)(((uint64_t)val) & ~1));
17323         DelayedPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
17324 }
17325
17326 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1revocation_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
17327         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
17328         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17329         this_ptr_conv.is_owned = false;
17330         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
17331         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DelayedPaymentOutputDescriptor_get_revocation_pubkey(&this_ptr_conv).compressed_form);
17332         return ret_arr;
17333 }
17334
17335 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1revocation_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17336         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
17337         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17338         this_ptr_conv.is_owned = false;
17339         LDKPublicKey val_ref;
17340         CHECK((*env)->GetArrayLength(env, val) == 33);
17341         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
17342         DelayedPaymentOutputDescriptor_set_revocation_pubkey(&this_ptr_conv, val_ref);
17343 }
17344
17345 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
17346         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
17347         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17348         this_ptr_conv.is_owned = false;
17349         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
17350         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *DelayedPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv));
17351         return ret_arr;
17352 }
17353
17354 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17355         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
17356         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17357         this_ptr_conv.is_owned = false;
17358         LDKThirtyTwoBytes val_ref;
17359         CHECK((*env)->GetArrayLength(env, val) == 32);
17360         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
17361         DelayedPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
17362 }
17363
17364 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
17365         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
17366         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17367         this_ptr_conv.is_owned = false;
17368         int64_t ret_val = DelayedPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
17369         return ret_val;
17370 }
17371
17372 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17373         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
17374         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17375         this_ptr_conv.is_owned = false;
17376         DelayedPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
17377 }
17378
17379 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) {
17380         LDKOutPoint outpoint_arg_conv;
17381         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
17382         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
17383         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
17384         LDKPublicKey per_commitment_point_arg_ref;
17385         CHECK((*env)->GetArrayLength(env, per_commitment_point_arg) == 33);
17386         (*env)->GetByteArrayRegion(env, per_commitment_point_arg, 0, 33, per_commitment_point_arg_ref.compressed_form);
17387         LDKTxOut output_arg_conv = *(LDKTxOut*)(((uint64_t)output_arg) & ~1);
17388         output_arg_conv = TxOut_clone((LDKTxOut*)(((uint64_t)output_arg) & ~1));
17389         LDKPublicKey revocation_pubkey_arg_ref;
17390         CHECK((*env)->GetArrayLength(env, revocation_pubkey_arg) == 33);
17391         (*env)->GetByteArrayRegion(env, revocation_pubkey_arg, 0, 33, revocation_pubkey_arg_ref.compressed_form);
17392         LDKThirtyTwoBytes channel_keys_id_arg_ref;
17393         CHECK((*env)->GetArrayLength(env, channel_keys_id_arg) == 32);
17394         (*env)->GetByteArrayRegion(env, channel_keys_id_arg, 0, 32, channel_keys_id_arg_ref.data);
17395         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);
17396         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17397         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17398         uint64_t ret_ref = (uint64_t)ret_var.inner;
17399         if (ret_var.is_owned) {
17400                 ret_ref |= 1;
17401         }
17402         return ret_ref;
17403 }
17404
17405 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17406         LDKDelayedPaymentOutputDescriptor orig_conv;
17407         orig_conv.inner = (void*)(orig & (~1));
17408         orig_conv.is_owned = false;
17409         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(&orig_conv);
17410         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17411         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17412         uint64_t ret_ref = (uint64_t)ret_var.inner;
17413         if (ret_var.is_owned) {
17414                 ret_ref |= 1;
17415         }
17416         return ret_ref;
17417 }
17418
17419 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
17420         LDKDelayedPaymentOutputDescriptor obj_conv;
17421         obj_conv.inner = (void*)(obj & (~1));
17422         obj_conv.is_owned = false;
17423         LDKCVec_u8Z ret_var = DelayedPaymentOutputDescriptor_write(&obj_conv);
17424         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17425         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17426         CVec_u8Z_free(ret_var);
17427         return ret_arr;
17428 }
17429
17430 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17431         LDKu8slice ser_ref;
17432         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17433         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17434         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
17435         *ret_conv = DelayedPaymentOutputDescriptor_read(ser_ref);
17436         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17437         return (uint64_t)ret_conv;
17438 }
17439
17440 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17441         LDKStaticPaymentOutputDescriptor this_obj_conv;
17442         this_obj_conv.inner = (void*)(this_obj & (~1));
17443         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17444         StaticPaymentOutputDescriptor_free(this_obj_conv);
17445 }
17446
17447 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
17448         LDKStaticPaymentOutputDescriptor this_ptr_conv;
17449         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17450         this_ptr_conv.is_owned = false;
17451         LDKOutPoint ret_var = StaticPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
17452         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17453         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17454         uint64_t ret_ref = (uint64_t)ret_var.inner;
17455         if (ret_var.is_owned) {
17456                 ret_ref |= 1;
17457         }
17458         return ret_ref;
17459 }
17460
17461 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17462         LDKStaticPaymentOutputDescriptor this_ptr_conv;
17463         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17464         this_ptr_conv.is_owned = false;
17465         LDKOutPoint val_conv;
17466         val_conv.inner = (void*)(val & (~1));
17467         val_conv.is_owned = (val & 1) || (val == 0);
17468         val_conv = OutPoint_clone(&val_conv);
17469         StaticPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
17470 }
17471
17472 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1output(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17473         LDKStaticPaymentOutputDescriptor this_ptr_conv;
17474         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17475         this_ptr_conv.is_owned = false;
17476         LDKTxOut val_conv = *(LDKTxOut*)(((uint64_t)val) & ~1);
17477         val_conv = TxOut_clone((LDKTxOut*)(((uint64_t)val) & ~1));
17478         StaticPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
17479 }
17480
17481 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
17482         LDKStaticPaymentOutputDescriptor this_ptr_conv;
17483         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17484         this_ptr_conv.is_owned = false;
17485         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
17486         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *StaticPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv));
17487         return ret_arr;
17488 }
17489
17490 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17491         LDKStaticPaymentOutputDescriptor this_ptr_conv;
17492         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17493         this_ptr_conv.is_owned = false;
17494         LDKThirtyTwoBytes val_ref;
17495         CHECK((*env)->GetArrayLength(env, val) == 32);
17496         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
17497         StaticPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
17498 }
17499
17500 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
17501         LDKStaticPaymentOutputDescriptor this_ptr_conv;
17502         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17503         this_ptr_conv.is_owned = false;
17504         int64_t ret_val = StaticPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
17505         return ret_val;
17506 }
17507
17508 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17509         LDKStaticPaymentOutputDescriptor this_ptr_conv;
17510         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17511         this_ptr_conv.is_owned = false;
17512         StaticPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
17513 }
17514
17515 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) {
17516         LDKOutPoint outpoint_arg_conv;
17517         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
17518         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
17519         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
17520         LDKTxOut output_arg_conv = *(LDKTxOut*)(((uint64_t)output_arg) & ~1);
17521         output_arg_conv = TxOut_clone((LDKTxOut*)(((uint64_t)output_arg) & ~1));
17522         LDKThirtyTwoBytes channel_keys_id_arg_ref;
17523         CHECK((*env)->GetArrayLength(env, channel_keys_id_arg) == 32);
17524         (*env)->GetByteArrayRegion(env, channel_keys_id_arg, 0, 32, channel_keys_id_arg_ref.data);
17525         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_new(outpoint_arg_conv, output_arg_conv, channel_keys_id_arg_ref, channel_value_satoshis_arg);
17526         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17527         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17528         uint64_t ret_ref = (uint64_t)ret_var.inner;
17529         if (ret_var.is_owned) {
17530                 ret_ref |= 1;
17531         }
17532         return ret_ref;
17533 }
17534
17535 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17536         LDKStaticPaymentOutputDescriptor orig_conv;
17537         orig_conv.inner = (void*)(orig & (~1));
17538         orig_conv.is_owned = false;
17539         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(&orig_conv);
17540         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17541         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17542         uint64_t ret_ref = (uint64_t)ret_var.inner;
17543         if (ret_var.is_owned) {
17544                 ret_ref |= 1;
17545         }
17546         return ret_ref;
17547 }
17548
17549 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
17550         LDKStaticPaymentOutputDescriptor obj_conv;
17551         obj_conv.inner = (void*)(obj & (~1));
17552         obj_conv.is_owned = false;
17553         LDKCVec_u8Z ret_var = StaticPaymentOutputDescriptor_write(&obj_conv);
17554         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17555         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17556         CVec_u8Z_free(ret_var);
17557         return ret_arr;
17558 }
17559
17560 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17561         LDKu8slice ser_ref;
17562         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17563         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17564         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
17565         *ret_conv = StaticPaymentOutputDescriptor_read(ser_ref);
17566         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17567         return (uint64_t)ret_conv;
17568 }
17569
17570 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
17571         if ((this_ptr & 1) != 0) return;
17572         LDKSpendableOutputDescriptor this_ptr_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)this_ptr) & ~1);
17573         FREE((void*)this_ptr);
17574         SpendableOutputDescriptor_free(this_ptr_conv);
17575 }
17576
17577 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17578         LDKSpendableOutputDescriptor* orig_conv = (LDKSpendableOutputDescriptor*)orig;
17579         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
17580         *ret_copy = SpendableOutputDescriptor_clone(orig_conv);
17581         uint64_t ret_ref = (uint64_t)ret_copy;
17582         return ret_ref;
17583 }
17584
17585 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1static_1output(JNIEnv *env, jclass clz, int64_t outpoint, int64_t output) {
17586         LDKOutPoint outpoint_conv;
17587         outpoint_conv.inner = (void*)(outpoint & (~1));
17588         outpoint_conv.is_owned = (outpoint & 1) || (outpoint == 0);
17589         outpoint_conv = OutPoint_clone(&outpoint_conv);
17590         LDKTxOut output_conv = *(LDKTxOut*)(((uint64_t)output) & ~1);
17591         output_conv = TxOut_clone((LDKTxOut*)(((uint64_t)output) & ~1));
17592         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
17593         *ret_copy = SpendableOutputDescriptor_static_output(outpoint_conv, output_conv);
17594         uint64_t ret_ref = (uint64_t)ret_copy;
17595         return ret_ref;
17596 }
17597
17598 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1delayed_1payment_1output(JNIEnv *env, jclass clz, int64_t a) {
17599         LDKDelayedPaymentOutputDescriptor a_conv;
17600         a_conv.inner = (void*)(a & (~1));
17601         a_conv.is_owned = (a & 1) || (a == 0);
17602         a_conv = DelayedPaymentOutputDescriptor_clone(&a_conv);
17603         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
17604         *ret_copy = SpendableOutputDescriptor_delayed_payment_output(a_conv);
17605         uint64_t ret_ref = (uint64_t)ret_copy;
17606         return ret_ref;
17607 }
17608
17609 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1static_1payment_1output(JNIEnv *env, jclass clz, int64_t a) {
17610         LDKStaticPaymentOutputDescriptor a_conv;
17611         a_conv.inner = (void*)(a & (~1));
17612         a_conv.is_owned = (a & 1) || (a == 0);
17613         a_conv = StaticPaymentOutputDescriptor_clone(&a_conv);
17614         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
17615         *ret_copy = SpendableOutputDescriptor_static_payment_output(a_conv);
17616         uint64_t ret_ref = (uint64_t)ret_copy;
17617         return ret_ref;
17618 }
17619
17620 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
17621         LDKSpendableOutputDescriptor* obj_conv = (LDKSpendableOutputDescriptor*)obj;
17622         LDKCVec_u8Z ret_var = SpendableOutputDescriptor_write(obj_conv);
17623         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17624         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17625         CVec_u8Z_free(ret_var);
17626         return ret_arr;
17627 }
17628
17629 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17630         LDKu8slice ser_ref;
17631         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17632         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17633         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
17634         *ret_conv = SpendableOutputDescriptor_read(ser_ref);
17635         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17636         return (uint64_t)ret_conv;
17637 }
17638
17639 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BaseSign_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
17640         if ((this_ptr & 1) != 0) return;
17641         LDKBaseSign this_ptr_conv = *(LDKBaseSign*)(((uint64_t)this_ptr) & ~1);
17642         FREE((void*)this_ptr);
17643         BaseSign_free(this_ptr_conv);
17644 }
17645
17646 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sign_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17647         LDKSign* orig_conv = (LDKSign*)(((uint64_t)orig) & ~1);
17648         LDKSign* ret_ret =MALLOC(sizeof(LDKSign), "LDKSign");
17649         *ret_ret = Sign_clone(orig_conv);
17650         return (uint64_t)ret_ret;
17651 }
17652
17653 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Sign_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
17654         if ((this_ptr & 1) != 0) return;
17655         LDKSign this_ptr_conv = *(LDKSign*)(((uint64_t)this_ptr) & ~1);
17656         FREE((void*)this_ptr);
17657         Sign_free(this_ptr_conv);
17658 }
17659
17660 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_KeysInterface_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
17661         if ((this_ptr & 1) != 0) return;
17662         LDKKeysInterface this_ptr_conv = *(LDKKeysInterface*)(((uint64_t)this_ptr) & ~1);
17663         FREE((void*)this_ptr);
17664         KeysInterface_free(this_ptr_conv);
17665 }
17666
17667 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17668         LDKInMemorySigner this_obj_conv;
17669         this_obj_conv.inner = (void*)(this_obj & (~1));
17670         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17671         InMemorySigner_free(this_obj_conv);
17672 }
17673
17674 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1funding_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
17675         LDKInMemorySigner this_ptr_conv;
17676         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17677         this_ptr_conv.is_owned = false;
17678         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
17679         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_funding_key(&this_ptr_conv));
17680         return ret_arr;
17681 }
17682
17683 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1funding_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17684         LDKInMemorySigner this_ptr_conv;
17685         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17686         this_ptr_conv.is_owned = false;
17687         LDKSecretKey val_ref;
17688         CHECK((*env)->GetArrayLength(env, val) == 32);
17689         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
17690         InMemorySigner_set_funding_key(&this_ptr_conv, val_ref);
17691 }
17692
17693 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1revocation_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
17694         LDKInMemorySigner this_ptr_conv;
17695         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17696         this_ptr_conv.is_owned = false;
17697         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
17698         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_revocation_base_key(&this_ptr_conv));
17699         return ret_arr;
17700 }
17701
17702 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1revocation_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17703         LDKInMemorySigner this_ptr_conv;
17704         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17705         this_ptr_conv.is_owned = false;
17706         LDKSecretKey val_ref;
17707         CHECK((*env)->GetArrayLength(env, val) == 32);
17708         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
17709         InMemorySigner_set_revocation_base_key(&this_ptr_conv, val_ref);
17710 }
17711
17712 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
17713         LDKInMemorySigner this_ptr_conv;
17714         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17715         this_ptr_conv.is_owned = false;
17716         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
17717         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_payment_key(&this_ptr_conv));
17718         return ret_arr;
17719 }
17720
17721 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17722         LDKInMemorySigner this_ptr_conv;
17723         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17724         this_ptr_conv.is_owned = false;
17725         LDKSecretKey val_ref;
17726         CHECK((*env)->GetArrayLength(env, val) == 32);
17727         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
17728         InMemorySigner_set_payment_key(&this_ptr_conv, val_ref);
17729 }
17730
17731 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1delayed_1payment_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
17732         LDKInMemorySigner this_ptr_conv;
17733         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17734         this_ptr_conv.is_owned = false;
17735         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
17736         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_delayed_payment_base_key(&this_ptr_conv));
17737         return ret_arr;
17738 }
17739
17740 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) {
17741         LDKInMemorySigner this_ptr_conv;
17742         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17743         this_ptr_conv.is_owned = false;
17744         LDKSecretKey val_ref;
17745         CHECK((*env)->GetArrayLength(env, val) == 32);
17746         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
17747         InMemorySigner_set_delayed_payment_base_key(&this_ptr_conv, val_ref);
17748 }
17749
17750 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1htlc_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
17751         LDKInMemorySigner this_ptr_conv;
17752         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17753         this_ptr_conv.is_owned = false;
17754         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
17755         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_htlc_base_key(&this_ptr_conv));
17756         return ret_arr;
17757 }
17758
17759 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1htlc_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17760         LDKInMemorySigner this_ptr_conv;
17761         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17762         this_ptr_conv.is_owned = false;
17763         LDKSecretKey val_ref;
17764         CHECK((*env)->GetArrayLength(env, val) == 32);
17765         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
17766         InMemorySigner_set_htlc_base_key(&this_ptr_conv, val_ref);
17767 }
17768
17769 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1commitment_1seed(JNIEnv *env, jclass clz, int64_t this_ptr) {
17770         LDKInMemorySigner this_ptr_conv;
17771         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17772         this_ptr_conv.is_owned = false;
17773         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
17774         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_commitment_seed(&this_ptr_conv));
17775         return ret_arr;
17776 }
17777
17778 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1commitment_1seed(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17779         LDKInMemorySigner this_ptr_conv;
17780         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17781         this_ptr_conv.is_owned = false;
17782         LDKThirtyTwoBytes val_ref;
17783         CHECK((*env)->GetArrayLength(env, val) == 32);
17784         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
17785         InMemorySigner_set_commitment_seed(&this_ptr_conv, val_ref);
17786 }
17787
17788 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17789         LDKInMemorySigner orig_conv;
17790         orig_conv.inner = (void*)(orig & (~1));
17791         orig_conv.is_owned = false;
17792         LDKInMemorySigner ret_var = InMemorySigner_clone(&orig_conv);
17793         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17794         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17795         uint64_t ret_ref = (uint64_t)ret_var.inner;
17796         if (ret_var.is_owned) {
17797                 ret_ref |= 1;
17798         }
17799         return ret_ref;
17800 }
17801
17802 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) {
17803         LDKSecretKey funding_key_ref;
17804         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
17805         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_ref.bytes);
17806         LDKSecretKey revocation_base_key_ref;
17807         CHECK((*env)->GetArrayLength(env, revocation_base_key) == 32);
17808         (*env)->GetByteArrayRegion(env, revocation_base_key, 0, 32, revocation_base_key_ref.bytes);
17809         LDKSecretKey payment_key_ref;
17810         CHECK((*env)->GetArrayLength(env, payment_key) == 32);
17811         (*env)->GetByteArrayRegion(env, payment_key, 0, 32, payment_key_ref.bytes);
17812         LDKSecretKey delayed_payment_base_key_ref;
17813         CHECK((*env)->GetArrayLength(env, delayed_payment_base_key) == 32);
17814         (*env)->GetByteArrayRegion(env, delayed_payment_base_key, 0, 32, delayed_payment_base_key_ref.bytes);
17815         LDKSecretKey htlc_base_key_ref;
17816         CHECK((*env)->GetArrayLength(env, htlc_base_key) == 32);
17817         (*env)->GetByteArrayRegion(env, htlc_base_key, 0, 32, htlc_base_key_ref.bytes);
17818         LDKThirtyTwoBytes commitment_seed_ref;
17819         CHECK((*env)->GetArrayLength(env, commitment_seed) == 32);
17820         (*env)->GetByteArrayRegion(env, commitment_seed, 0, 32, commitment_seed_ref.data);
17821         LDKThirtyTwoBytes channel_keys_id_ref;
17822         CHECK((*env)->GetArrayLength(env, channel_keys_id) == 32);
17823         (*env)->GetByteArrayRegion(env, channel_keys_id, 0, 32, channel_keys_id_ref.data);
17824         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);
17825         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17826         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17827         uint64_t ret_ref = (uint64_t)ret_var.inner;
17828         if (ret_var.is_owned) {
17829                 ret_ref |= 1;
17830         }
17831         return ret_ref;
17832 }
17833
17834 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1counterparty_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
17835         LDKInMemorySigner this_arg_conv;
17836         this_arg_conv.inner = (void*)(this_arg & (~1));
17837         this_arg_conv.is_owned = false;
17838         LDKChannelPublicKeys ret_var = InMemorySigner_counterparty_pubkeys(&this_arg_conv);
17839         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17840         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17841         uint64_t ret_ref = (uint64_t)ret_var.inner;
17842         if (ret_var.is_owned) {
17843                 ret_ref |= 1;
17844         }
17845         return ret_ref;
17846 }
17847
17848 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1counterparty_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
17849         LDKInMemorySigner this_arg_conv;
17850         this_arg_conv.inner = (void*)(this_arg & (~1));
17851         this_arg_conv.is_owned = false;
17852         int16_t ret_val = InMemorySigner_counterparty_selected_contest_delay(&this_arg_conv);
17853         return ret_val;
17854 }
17855
17856 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1holder_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
17857         LDKInMemorySigner this_arg_conv;
17858         this_arg_conv.inner = (void*)(this_arg & (~1));
17859         this_arg_conv.is_owned = false;
17860         int16_t ret_val = InMemorySigner_holder_selected_contest_delay(&this_arg_conv);
17861         return ret_val;
17862 }
17863
17864 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_arg) {
17865         LDKInMemorySigner this_arg_conv;
17866         this_arg_conv.inner = (void*)(this_arg & (~1));
17867         this_arg_conv.is_owned = false;
17868         jboolean ret_val = InMemorySigner_is_outbound(&this_arg_conv);
17869         return ret_val;
17870 }
17871
17872 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_arg) {
17873         LDKInMemorySigner this_arg_conv;
17874         this_arg_conv.inner = (void*)(this_arg & (~1));
17875         this_arg_conv.is_owned = false;
17876         LDKOutPoint ret_var = InMemorySigner_funding_outpoint(&this_arg_conv);
17877         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17878         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17879         uint64_t ret_ref = (uint64_t)ret_var.inner;
17880         if (ret_var.is_owned) {
17881                 ret_ref |= 1;
17882         }
17883         return ret_ref;
17884 }
17885
17886 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1channel_1parameters(JNIEnv *env, jclass clz, int64_t this_arg) {
17887         LDKInMemorySigner this_arg_conv;
17888         this_arg_conv.inner = (void*)(this_arg & (~1));
17889         this_arg_conv.is_owned = false;
17890         LDKChannelTransactionParameters ret_var = InMemorySigner_get_channel_parameters(&this_arg_conv);
17891         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17892         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17893         uint64_t ret_ref = (uint64_t)ret_var.inner;
17894         if (ret_var.is_owned) {
17895                 ret_ref |= 1;
17896         }
17897         return ret_ref;
17898 }
17899
17900 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) {
17901         LDKInMemorySigner this_arg_conv;
17902         this_arg_conv.inner = (void*)(this_arg & (~1));
17903         this_arg_conv.is_owned = false;
17904         LDKTransaction spend_tx_ref;
17905         spend_tx_ref.datalen = (*env)->GetArrayLength(env, spend_tx);
17906         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
17907         (*env)->GetByteArrayRegion(env, spend_tx, 0, spend_tx_ref.datalen, spend_tx_ref.data);
17908         spend_tx_ref.data_is_owned = true;
17909         LDKStaticPaymentOutputDescriptor descriptor_conv;
17910         descriptor_conv.inner = (void*)(descriptor & (~1));
17911         descriptor_conv.is_owned = false;
17912         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
17913         *ret_conv = InMemorySigner_sign_counterparty_payment_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
17914         return (uint64_t)ret_conv;
17915 }
17916
17917 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) {
17918         LDKInMemorySigner this_arg_conv;
17919         this_arg_conv.inner = (void*)(this_arg & (~1));
17920         this_arg_conv.is_owned = false;
17921         LDKTransaction spend_tx_ref;
17922         spend_tx_ref.datalen = (*env)->GetArrayLength(env, spend_tx);
17923         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
17924         (*env)->GetByteArrayRegion(env, spend_tx, 0, spend_tx_ref.datalen, spend_tx_ref.data);
17925         spend_tx_ref.data_is_owned = true;
17926         LDKDelayedPaymentOutputDescriptor descriptor_conv;
17927         descriptor_conv.inner = (void*)(descriptor & (~1));
17928         descriptor_conv.is_owned = false;
17929         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
17930         *ret_conv = InMemorySigner_sign_dynamic_p2wsh_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
17931         return (uint64_t)ret_conv;
17932 }
17933
17934 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1as_1BaseSign(JNIEnv *env, jclass clz, int64_t this_arg) {
17935         LDKInMemorySigner this_arg_conv;
17936         this_arg_conv.inner = (void*)(this_arg & (~1));
17937         this_arg_conv.is_owned = false;
17938         LDKBaseSign* ret_ret =MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
17939         *ret_ret = InMemorySigner_as_BaseSign(&this_arg_conv);
17940         return (uint64_t)ret_ret;
17941 }
17942
17943 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1as_1Sign(JNIEnv *env, jclass clz, int64_t this_arg) {
17944         LDKInMemorySigner this_arg_conv;
17945         this_arg_conv.inner = (void*)(this_arg & (~1));
17946         this_arg_conv.is_owned = false;
17947         LDKSign* ret_ret =MALLOC(sizeof(LDKSign), "LDKSign");
17948         *ret_ret = InMemorySigner_as_Sign(&this_arg_conv);
17949         return (uint64_t)ret_ret;
17950 }
17951
17952 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1write(JNIEnv *env, jclass clz, int64_t obj) {
17953         LDKInMemorySigner obj_conv;
17954         obj_conv.inner = (void*)(obj & (~1));
17955         obj_conv.is_owned = false;
17956         LDKCVec_u8Z ret_var = InMemorySigner_write(&obj_conv);
17957         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17958         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17959         CVec_u8Z_free(ret_var);
17960         return ret_arr;
17961 }
17962
17963 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17964         LDKu8slice ser_ref;
17965         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17966         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17967         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
17968         *ret_conv = InMemorySigner_read(ser_ref);
17969         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17970         return (uint64_t)ret_conv;
17971 }
17972
17973 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_KeysManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17974         LDKKeysManager this_obj_conv;
17975         this_obj_conv.inner = (void*)(this_obj & (~1));
17976         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17977         KeysManager_free(this_obj_conv);
17978 }
17979
17980 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) {
17981         unsigned char seed_arr[32];
17982         CHECK((*env)->GetArrayLength(env, seed) == 32);
17983         (*env)->GetByteArrayRegion(env, seed, 0, 32, seed_arr);
17984         unsigned char (*seed_ref)[32] = &seed_arr;
17985         LDKKeysManager ret_var = KeysManager_new(seed_ref, starting_time_secs, starting_time_nanos);
17986         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17987         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17988         uint64_t ret_ref = (uint64_t)ret_var.inner;
17989         if (ret_var.is_owned) {
17990                 ret_ref |= 1;
17991         }
17992         return ret_ref;
17993 }
17994
17995 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) {
17996         LDKKeysManager this_arg_conv;
17997         this_arg_conv.inner = (void*)(this_arg & (~1));
17998         this_arg_conv.is_owned = false;
17999         unsigned char params_arr[32];
18000         CHECK((*env)->GetArrayLength(env, params) == 32);
18001         (*env)->GetByteArrayRegion(env, params, 0, 32, params_arr);
18002         unsigned char (*params_ref)[32] = &params_arr;
18003         LDKInMemorySigner ret_var = KeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
18004         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18005         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18006         uint64_t ret_ref = (uint64_t)ret_var.inner;
18007         if (ret_var.is_owned) {
18008                 ret_ref |= 1;
18009         }
18010         return ret_ref;
18011 }
18012
18013 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) {
18014         LDKKeysManager this_arg_conv;
18015         this_arg_conv.inner = (void*)(this_arg & (~1));
18016         this_arg_conv.is_owned = false;
18017         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
18018         descriptors_constr.datalen = (*env)->GetArrayLength(env, descriptors);
18019         if (descriptors_constr.datalen > 0)
18020                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
18021         else
18022                 descriptors_constr.data = NULL;
18023         int64_t* descriptors_vals = (*env)->GetLongArrayElements (env, descriptors, NULL);
18024         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
18025                 int64_t descriptors_conv_27 = descriptors_vals[b];
18026                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)descriptors_conv_27) & ~1);
18027                 descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uint64_t)descriptors_conv_27) & ~1));
18028                 descriptors_constr.data[b] = descriptors_conv_27_conv;
18029         }
18030         (*env)->ReleaseLongArrayElements(env, descriptors, descriptors_vals, 0);
18031         LDKCVec_TxOutZ outputs_constr;
18032         outputs_constr.datalen = (*env)->GetArrayLength(env, outputs);
18033         if (outputs_constr.datalen > 0)
18034                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
18035         else
18036                 outputs_constr.data = NULL;
18037         int64_t* outputs_vals = (*env)->GetLongArrayElements (env, outputs, NULL);
18038         for (size_t h = 0; h < outputs_constr.datalen; h++) {
18039                 int64_t outputs_conv_7 = outputs_vals[h];
18040                 LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(((uint64_t)outputs_conv_7) & ~1);
18041                 outputs_conv_7_conv = TxOut_clone((LDKTxOut*)(((uint64_t)outputs_conv_7) & ~1));
18042                 outputs_constr.data[h] = outputs_conv_7_conv;
18043         }
18044         (*env)->ReleaseLongArrayElements(env, outputs, outputs_vals, 0);
18045         LDKCVec_u8Z change_destination_script_ref;
18046         change_destination_script_ref.datalen = (*env)->GetArrayLength(env, change_destination_script);
18047         change_destination_script_ref.data = MALLOC(change_destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
18048         (*env)->GetByteArrayRegion(env, change_destination_script, 0, change_destination_script_ref.datalen, change_destination_script_ref.data);
18049         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
18050         *ret_conv = KeysManager_spend_spendable_outputs(&this_arg_conv, descriptors_constr, outputs_constr, change_destination_script_ref, feerate_sat_per_1000_weight);
18051         return (uint64_t)ret_conv;
18052 }
18053
18054 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysManager_1as_1KeysInterface(JNIEnv *env, jclass clz, int64_t this_arg) {
18055         LDKKeysManager this_arg_conv;
18056         this_arg_conv.inner = (void*)(this_arg & (~1));
18057         this_arg_conv.is_owned = false;
18058         LDKKeysInterface* ret_ret =MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
18059         *ret_ret = KeysManager_as_KeysInterface(&this_arg_conv);
18060         return (uint64_t)ret_ret;
18061 }
18062
18063 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18064         LDKChannelManager this_obj_conv;
18065         this_obj_conv.inner = (void*)(this_obj & (~1));
18066         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18067         ChannelManager_free(this_obj_conv);
18068 }
18069
18070 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18071         LDKChainParameters this_obj_conv;
18072         this_obj_conv.inner = (void*)(this_obj & (~1));
18073         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18074         ChainParameters_free(this_obj_conv);
18075 }
18076
18077 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChainParameters_1get_1network(JNIEnv *env, jclass clz, int64_t this_ptr) {
18078         LDKChainParameters this_ptr_conv;
18079         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18080         this_ptr_conv.is_owned = false;
18081         jclass ret_conv = LDKNetwork_to_java(env, ChainParameters_get_network(&this_ptr_conv));
18082         return ret_conv;
18083 }
18084
18085 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1set_1network(JNIEnv *env, jclass clz, int64_t this_ptr, jclass val) {
18086         LDKChainParameters this_ptr_conv;
18087         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18088         this_ptr_conv.is_owned = false;
18089         LDKNetwork val_conv = LDKNetwork_from_java(env, val);
18090         ChainParameters_set_network(&this_ptr_conv, val_conv);
18091 }
18092
18093 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1get_1best_1block(JNIEnv *env, jclass clz, int64_t this_ptr) {
18094         LDKChainParameters this_ptr_conv;
18095         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18096         this_ptr_conv.is_owned = false;
18097         LDKBestBlock ret_var = ChainParameters_get_best_block(&this_ptr_conv);
18098         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18099         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18100         uint64_t ret_ref = (uint64_t)ret_var.inner;
18101         if (ret_var.is_owned) {
18102                 ret_ref |= 1;
18103         }
18104         return ret_ref;
18105 }
18106
18107 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1set_1best_1block(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18108         LDKChainParameters this_ptr_conv;
18109         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18110         this_ptr_conv.is_owned = false;
18111         LDKBestBlock val_conv;
18112         val_conv.inner = (void*)(val & (~1));
18113         val_conv.is_owned = (val & 1) || (val == 0);
18114         val_conv = BestBlock_clone(&val_conv);
18115         ChainParameters_set_best_block(&this_ptr_conv, val_conv);
18116 }
18117
18118 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1new(JNIEnv *env, jclass clz, jclass network_arg, int64_t best_block_arg) {
18119         LDKNetwork network_arg_conv = LDKNetwork_from_java(env, network_arg);
18120         LDKBestBlock best_block_arg_conv;
18121         best_block_arg_conv.inner = (void*)(best_block_arg & (~1));
18122         best_block_arg_conv.is_owned = (best_block_arg & 1) || (best_block_arg == 0);
18123         best_block_arg_conv = BestBlock_clone(&best_block_arg_conv);
18124         LDKChainParameters ret_var = ChainParameters_new(network_arg_conv, best_block_arg_conv);
18125         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18126         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18127         uint64_t ret_ref = (uint64_t)ret_var.inner;
18128         if (ret_var.is_owned) {
18129                 ret_ref |= 1;
18130         }
18131         return ret_ref;
18132 }
18133
18134 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18135         LDKChainParameters orig_conv;
18136         orig_conv.inner = (void*)(orig & (~1));
18137         orig_conv.is_owned = false;
18138         LDKChainParameters ret_var = ChainParameters_clone(&orig_conv);
18139         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18140         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18141         uint64_t ret_ref = (uint64_t)ret_var.inner;
18142         if (ret_var.is_owned) {
18143                 ret_ref |= 1;
18144         }
18145         return ret_ref;
18146 }
18147
18148 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18149         LDKCounterpartyForwardingInfo this_obj_conv;
18150         this_obj_conv.inner = (void*)(this_obj & (~1));
18151         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18152         CounterpartyForwardingInfo_free(this_obj_conv);
18153 }
18154
18155 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1get_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
18156         LDKCounterpartyForwardingInfo this_ptr_conv;
18157         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18158         this_ptr_conv.is_owned = false;
18159         int32_t ret_val = CounterpartyForwardingInfo_get_fee_base_msat(&this_ptr_conv);
18160         return ret_val;
18161 }
18162
18163 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1set_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
18164         LDKCounterpartyForwardingInfo this_ptr_conv;
18165         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18166         this_ptr_conv.is_owned = false;
18167         CounterpartyForwardingInfo_set_fee_base_msat(&this_ptr_conv, val);
18168 }
18169
18170 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1get_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
18171         LDKCounterpartyForwardingInfo this_ptr_conv;
18172         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18173         this_ptr_conv.is_owned = false;
18174         int32_t ret_val = CounterpartyForwardingInfo_get_fee_proportional_millionths(&this_ptr_conv);
18175         return ret_val;
18176 }
18177
18178 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1set_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
18179         LDKCounterpartyForwardingInfo this_ptr_conv;
18180         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18181         this_ptr_conv.is_owned = false;
18182         CounterpartyForwardingInfo_set_fee_proportional_millionths(&this_ptr_conv, val);
18183 }
18184
18185 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
18186         LDKCounterpartyForwardingInfo this_ptr_conv;
18187         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18188         this_ptr_conv.is_owned = false;
18189         int16_t ret_val = CounterpartyForwardingInfo_get_cltv_expiry_delta(&this_ptr_conv);
18190         return ret_val;
18191 }
18192
18193 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
18194         LDKCounterpartyForwardingInfo this_ptr_conv;
18195         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18196         this_ptr_conv.is_owned = false;
18197         CounterpartyForwardingInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
18198 }
18199
18200 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1new(JNIEnv *env, jclass clz, int32_t fee_base_msat_arg, int32_t fee_proportional_millionths_arg, int16_t cltv_expiry_delta_arg) {
18201         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_new(fee_base_msat_arg, fee_proportional_millionths_arg, cltv_expiry_delta_arg);
18202         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18203         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18204         uint64_t ret_ref = (uint64_t)ret_var.inner;
18205         if (ret_var.is_owned) {
18206                 ret_ref |= 1;
18207         }
18208         return ret_ref;
18209 }
18210
18211 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18212         LDKCounterpartyForwardingInfo orig_conv;
18213         orig_conv.inner = (void*)(orig & (~1));
18214         orig_conv.is_owned = false;
18215         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_clone(&orig_conv);
18216         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18217         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18218         uint64_t ret_ref = (uint64_t)ret_var.inner;
18219         if (ret_var.is_owned) {
18220                 ret_ref |= 1;
18221         }
18222         return ret_ref;
18223 }
18224
18225 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18226         LDKChannelCounterparty this_obj_conv;
18227         this_obj_conv.inner = (void*)(this_obj & (~1));
18228         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18229         ChannelCounterparty_free(this_obj_conv);
18230 }
18231
18232 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18233         LDKChannelCounterparty this_ptr_conv;
18234         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18235         this_ptr_conv.is_owned = false;
18236         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
18237         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelCounterparty_get_node_id(&this_ptr_conv).compressed_form);
18238         return ret_arr;
18239 }
18240
18241 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18242         LDKChannelCounterparty this_ptr_conv;
18243         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18244         this_ptr_conv.is_owned = false;
18245         LDKPublicKey val_ref;
18246         CHECK((*env)->GetArrayLength(env, val) == 33);
18247         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
18248         ChannelCounterparty_set_node_id(&this_ptr_conv, val_ref);
18249 }
18250
18251 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
18252         LDKChannelCounterparty this_ptr_conv;
18253         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18254         this_ptr_conv.is_owned = false;
18255         LDKInitFeatures ret_var = ChannelCounterparty_get_features(&this_ptr_conv);
18256         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18257         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18258         uint64_t ret_ref = (uint64_t)ret_var.inner;
18259         if (ret_var.is_owned) {
18260                 ret_ref |= 1;
18261         }
18262         return ret_ref;
18263 }
18264
18265 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18266         LDKChannelCounterparty this_ptr_conv;
18267         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18268         this_ptr_conv.is_owned = false;
18269         LDKInitFeatures val_conv;
18270         val_conv.inner = (void*)(val & (~1));
18271         val_conv.is_owned = (val & 1) || (val == 0);
18272         val_conv = InitFeatures_clone(&val_conv);
18273         ChannelCounterparty_set_features(&this_ptr_conv, val_conv);
18274 }
18275
18276 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr) {
18277         LDKChannelCounterparty this_ptr_conv;
18278         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18279         this_ptr_conv.is_owned = false;
18280         int64_t ret_val = ChannelCounterparty_get_unspendable_punishment_reserve(&this_ptr_conv);
18281         return ret_val;
18282 }
18283
18284 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18285         LDKChannelCounterparty this_ptr_conv;
18286         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18287         this_ptr_conv.is_owned = false;
18288         ChannelCounterparty_set_unspendable_punishment_reserve(&this_ptr_conv, val);
18289 }
18290
18291 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1forwarding_1info(JNIEnv *env, jclass clz, int64_t this_ptr) {
18292         LDKChannelCounterparty this_ptr_conv;
18293         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18294         this_ptr_conv.is_owned = false;
18295         LDKCounterpartyForwardingInfo ret_var = ChannelCounterparty_get_forwarding_info(&this_ptr_conv);
18296         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18297         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18298         uint64_t ret_ref = (uint64_t)ret_var.inner;
18299         if (ret_var.is_owned) {
18300                 ret_ref |= 1;
18301         }
18302         return ret_ref;
18303 }
18304
18305 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1forwarding_1info(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18306         LDKChannelCounterparty this_ptr_conv;
18307         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18308         this_ptr_conv.is_owned = false;
18309         LDKCounterpartyForwardingInfo val_conv;
18310         val_conv.inner = (void*)(val & (~1));
18311         val_conv.is_owned = (val & 1) || (val == 0);
18312         val_conv = CounterpartyForwardingInfo_clone(&val_conv);
18313         ChannelCounterparty_set_forwarding_info(&this_ptr_conv, val_conv);
18314 }
18315
18316 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1new(JNIEnv *env, jclass clz, int8_tArray node_id_arg, int64_t features_arg, int64_t unspendable_punishment_reserve_arg, int64_t forwarding_info_arg) {
18317         LDKPublicKey node_id_arg_ref;
18318         CHECK((*env)->GetArrayLength(env, node_id_arg) == 33);
18319         (*env)->GetByteArrayRegion(env, node_id_arg, 0, 33, node_id_arg_ref.compressed_form);
18320         LDKInitFeatures features_arg_conv;
18321         features_arg_conv.inner = (void*)(features_arg & (~1));
18322         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
18323         features_arg_conv = InitFeatures_clone(&features_arg_conv);
18324         LDKCounterpartyForwardingInfo forwarding_info_arg_conv;
18325         forwarding_info_arg_conv.inner = (void*)(forwarding_info_arg & (~1));
18326         forwarding_info_arg_conv.is_owned = (forwarding_info_arg & 1) || (forwarding_info_arg == 0);
18327         forwarding_info_arg_conv = CounterpartyForwardingInfo_clone(&forwarding_info_arg_conv);
18328         LDKChannelCounterparty ret_var = ChannelCounterparty_new(node_id_arg_ref, features_arg_conv, unspendable_punishment_reserve_arg, forwarding_info_arg_conv);
18329         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18330         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18331         uint64_t ret_ref = (uint64_t)ret_var.inner;
18332         if (ret_var.is_owned) {
18333                 ret_ref |= 1;
18334         }
18335         return ret_ref;
18336 }
18337
18338 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18339         LDKChannelCounterparty orig_conv;
18340         orig_conv.inner = (void*)(orig & (~1));
18341         orig_conv.is_owned = false;
18342         LDKChannelCounterparty ret_var = ChannelCounterparty_clone(&orig_conv);
18343         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18344         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18345         uint64_t ret_ref = (uint64_t)ret_var.inner;
18346         if (ret_var.is_owned) {
18347                 ret_ref |= 1;
18348         }
18349         return ret_ref;
18350 }
18351
18352 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18353         LDKChannelDetails this_obj_conv;
18354         this_obj_conv.inner = (void*)(this_obj & (~1));
18355         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18356         ChannelDetails_free(this_obj_conv);
18357 }
18358
18359 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18360         LDKChannelDetails this_ptr_conv;
18361         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18362         this_ptr_conv.is_owned = false;
18363         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18364         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ChannelDetails_get_channel_id(&this_ptr_conv));
18365         return ret_arr;
18366 }
18367
18368 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18369         LDKChannelDetails this_ptr_conv;
18370         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18371         this_ptr_conv.is_owned = false;
18372         LDKThirtyTwoBytes val_ref;
18373         CHECK((*env)->GetArrayLength(env, val) == 32);
18374         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18375         ChannelDetails_set_channel_id(&this_ptr_conv, val_ref);
18376 }
18377
18378 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1counterparty(JNIEnv *env, jclass clz, int64_t this_ptr) {
18379         LDKChannelDetails this_ptr_conv;
18380         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18381         this_ptr_conv.is_owned = false;
18382         LDKChannelCounterparty ret_var = ChannelDetails_get_counterparty(&this_ptr_conv);
18383         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18384         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18385         uint64_t ret_ref = (uint64_t)ret_var.inner;
18386         if (ret_var.is_owned) {
18387                 ret_ref |= 1;
18388         }
18389         return ret_ref;
18390 }
18391
18392 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1counterparty(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18393         LDKChannelDetails this_ptr_conv;
18394         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18395         this_ptr_conv.is_owned = false;
18396         LDKChannelCounterparty val_conv;
18397         val_conv.inner = (void*)(val & (~1));
18398         val_conv.is_owned = (val & 1) || (val == 0);
18399         val_conv = ChannelCounterparty_clone(&val_conv);
18400         ChannelDetails_set_counterparty(&this_ptr_conv, val_conv);
18401 }
18402
18403 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_ptr) {
18404         LDKChannelDetails this_ptr_conv;
18405         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18406         this_ptr_conv.is_owned = false;
18407         LDKOutPoint ret_var = ChannelDetails_get_funding_txo(&this_ptr_conv);
18408         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18409         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18410         uint64_t ret_ref = (uint64_t)ret_var.inner;
18411         if (ret_var.is_owned) {
18412                 ret_ref |= 1;
18413         }
18414         return ret_ref;
18415 }
18416
18417 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18418         LDKChannelDetails this_ptr_conv;
18419         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18420         this_ptr_conv.is_owned = false;
18421         LDKOutPoint val_conv;
18422         val_conv.inner = (void*)(val & (~1));
18423         val_conv.is_owned = (val & 1) || (val == 0);
18424         val_conv = OutPoint_clone(&val_conv);
18425         ChannelDetails_set_funding_txo(&this_ptr_conv, val_conv);
18426 }
18427
18428 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18429         LDKChannelDetails this_ptr_conv;
18430         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18431         this_ptr_conv.is_owned = false;
18432         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
18433         *ret_copy = ChannelDetails_get_short_channel_id(&this_ptr_conv);
18434         uint64_t ret_ref = (uint64_t)ret_copy;
18435         return ret_ref;
18436 }
18437
18438 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18439         LDKChannelDetails this_ptr_conv;
18440         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18441         this_ptr_conv.is_owned = false;
18442         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
18443         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1));
18444         ChannelDetails_set_short_channel_id(&this_ptr_conv, val_conv);
18445 }
18446
18447 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
18448         LDKChannelDetails this_ptr_conv;
18449         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18450         this_ptr_conv.is_owned = false;
18451         int64_t ret_val = ChannelDetails_get_channel_value_satoshis(&this_ptr_conv);
18452         return ret_val;
18453 }
18454
18455 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18456         LDKChannelDetails this_ptr_conv;
18457         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18458         this_ptr_conv.is_owned = false;
18459         ChannelDetails_set_channel_value_satoshis(&this_ptr_conv, val);
18460 }
18461
18462 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr) {
18463         LDKChannelDetails this_ptr_conv;
18464         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18465         this_ptr_conv.is_owned = false;
18466         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
18467         *ret_copy = ChannelDetails_get_unspendable_punishment_reserve(&this_ptr_conv);
18468         uint64_t ret_ref = (uint64_t)ret_copy;
18469         return ret_ref;
18470 }
18471
18472 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18473         LDKChannelDetails this_ptr_conv;
18474         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18475         this_ptr_conv.is_owned = false;
18476         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
18477         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1));
18478         ChannelDetails_set_unspendable_punishment_reserve(&this_ptr_conv, val_conv);
18479 }
18480
18481 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1user_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18482         LDKChannelDetails this_ptr_conv;
18483         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18484         this_ptr_conv.is_owned = false;
18485         int64_t ret_val = ChannelDetails_get_user_id(&this_ptr_conv);
18486         return ret_val;
18487 }
18488
18489 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1user_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18490         LDKChannelDetails this_ptr_conv;
18491         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18492         this_ptr_conv.is_owned = false;
18493         ChannelDetails_set_user_id(&this_ptr_conv, val);
18494 }
18495
18496 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1outbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
18497         LDKChannelDetails this_ptr_conv;
18498         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18499         this_ptr_conv.is_owned = false;
18500         int64_t ret_val = ChannelDetails_get_outbound_capacity_msat(&this_ptr_conv);
18501         return ret_val;
18502 }
18503
18504 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1outbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18505         LDKChannelDetails this_ptr_conv;
18506         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18507         this_ptr_conv.is_owned = false;
18508         ChannelDetails_set_outbound_capacity_msat(&this_ptr_conv, val);
18509 }
18510
18511 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
18512         LDKChannelDetails this_ptr_conv;
18513         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18514         this_ptr_conv.is_owned = false;
18515         int64_t ret_val = ChannelDetails_get_inbound_capacity_msat(&this_ptr_conv);
18516         return ret_val;
18517 }
18518
18519 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1inbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18520         LDKChannelDetails this_ptr_conv;
18521         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18522         this_ptr_conv.is_owned = false;
18523         ChannelDetails_set_inbound_capacity_msat(&this_ptr_conv, val);
18524 }
18525
18526 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1confirmations_1required(JNIEnv *env, jclass clz, int64_t this_ptr) {
18527         LDKChannelDetails this_ptr_conv;
18528         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18529         this_ptr_conv.is_owned = false;
18530         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
18531         *ret_copy = ChannelDetails_get_confirmations_required(&this_ptr_conv);
18532         uint64_t ret_ref = (uint64_t)ret_copy;
18533         return ret_ref;
18534 }
18535
18536 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1confirmations_1required(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18537         LDKChannelDetails this_ptr_conv;
18538         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18539         this_ptr_conv.is_owned = false;
18540         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(((uint64_t)val) & ~1);
18541         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uint64_t)val) & ~1));
18542         ChannelDetails_set_confirmations_required(&this_ptr_conv, val_conv);
18543 }
18544
18545 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1force_1close_1spend_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
18546         LDKChannelDetails this_ptr_conv;
18547         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18548         this_ptr_conv.is_owned = false;
18549         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
18550         *ret_copy = ChannelDetails_get_force_close_spend_delay(&this_ptr_conv);
18551         uint64_t ret_ref = (uint64_t)ret_copy;
18552         return ret_ref;
18553 }
18554
18555 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1force_1close_1spend_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18556         LDKChannelDetails this_ptr_conv;
18557         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18558         this_ptr_conv.is_owned = false;
18559         LDKCOption_u16Z val_conv = *(LDKCOption_u16Z*)(((uint64_t)val) & ~1);
18560         val_conv = COption_u16Z_clone((LDKCOption_u16Z*)(((uint64_t)val) & ~1));
18561         ChannelDetails_set_force_close_spend_delay(&this_ptr_conv, val_conv);
18562 }
18563
18564 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_ptr) {
18565         LDKChannelDetails this_ptr_conv;
18566         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18567         this_ptr_conv.is_owned = false;
18568         jboolean ret_val = ChannelDetails_get_is_outbound(&this_ptr_conv);
18569         return ret_val;
18570 }
18571
18572 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
18573         LDKChannelDetails this_ptr_conv;
18574         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18575         this_ptr_conv.is_owned = false;
18576         ChannelDetails_set_is_outbound(&this_ptr_conv, val);
18577 }
18578
18579 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1funding_1locked(JNIEnv *env, jclass clz, int64_t this_ptr) {
18580         LDKChannelDetails this_ptr_conv;
18581         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18582         this_ptr_conv.is_owned = false;
18583         jboolean ret_val = ChannelDetails_get_is_funding_locked(&this_ptr_conv);
18584         return ret_val;
18585 }
18586
18587 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1funding_1locked(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
18588         LDKChannelDetails this_ptr_conv;
18589         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18590         this_ptr_conv.is_owned = false;
18591         ChannelDetails_set_is_funding_locked(&this_ptr_conv, val);
18592 }
18593
18594 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1usable(JNIEnv *env, jclass clz, int64_t this_ptr) {
18595         LDKChannelDetails this_ptr_conv;
18596         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18597         this_ptr_conv.is_owned = false;
18598         jboolean ret_val = ChannelDetails_get_is_usable(&this_ptr_conv);
18599         return ret_val;
18600 }
18601
18602 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1usable(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
18603         LDKChannelDetails this_ptr_conv;
18604         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18605         this_ptr_conv.is_owned = false;
18606         ChannelDetails_set_is_usable(&this_ptr_conv, val);
18607 }
18608
18609 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1public(JNIEnv *env, jclass clz, int64_t this_ptr) {
18610         LDKChannelDetails this_ptr_conv;
18611         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18612         this_ptr_conv.is_owned = false;
18613         jboolean ret_val = ChannelDetails_get_is_public(&this_ptr_conv);
18614         return ret_val;
18615 }
18616
18617 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1public(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
18618         LDKChannelDetails this_ptr_conv;
18619         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18620         this_ptr_conv.is_owned = false;
18621         ChannelDetails_set_is_public(&this_ptr_conv, val);
18622 }
18623
18624 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int64_t counterparty_arg, int64_t funding_txo_arg, int64_t short_channel_id_arg, int64_t channel_value_satoshis_arg, int64_t unspendable_punishment_reserve_arg, int64_t user_id_arg, int64_t outbound_capacity_msat_arg, int64_t inbound_capacity_msat_arg, int64_t confirmations_required_arg, int64_t force_close_spend_delay_arg, jboolean is_outbound_arg, jboolean is_funding_locked_arg, jboolean is_usable_arg, jboolean is_public_arg) {
18625         LDKThirtyTwoBytes channel_id_arg_ref;
18626         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
18627         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
18628         LDKChannelCounterparty counterparty_arg_conv;
18629         counterparty_arg_conv.inner = (void*)(counterparty_arg & (~1));
18630         counterparty_arg_conv.is_owned = (counterparty_arg & 1) || (counterparty_arg == 0);
18631         counterparty_arg_conv = ChannelCounterparty_clone(&counterparty_arg_conv);
18632         LDKOutPoint funding_txo_arg_conv;
18633         funding_txo_arg_conv.inner = (void*)(funding_txo_arg & (~1));
18634         funding_txo_arg_conv.is_owned = (funding_txo_arg & 1) || (funding_txo_arg == 0);
18635         funding_txo_arg_conv = OutPoint_clone(&funding_txo_arg_conv);
18636         LDKCOption_u64Z short_channel_id_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)short_channel_id_arg) & ~1);
18637         short_channel_id_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)short_channel_id_arg) & ~1));
18638         LDKCOption_u64Z unspendable_punishment_reserve_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)unspendable_punishment_reserve_arg) & ~1);
18639         LDKCOption_u32Z confirmations_required_arg_conv = *(LDKCOption_u32Z*)(((uint64_t)confirmations_required_arg) & ~1);
18640         confirmations_required_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uint64_t)confirmations_required_arg) & ~1));
18641         LDKCOption_u16Z force_close_spend_delay_arg_conv = *(LDKCOption_u16Z*)(((uint64_t)force_close_spend_delay_arg) & ~1);
18642         force_close_spend_delay_arg_conv = COption_u16Z_clone((LDKCOption_u16Z*)(((uint64_t)force_close_spend_delay_arg) & ~1));
18643         LDKChannelDetails ret_var = ChannelDetails_new(channel_id_arg_ref, counterparty_arg_conv, funding_txo_arg_conv, short_channel_id_arg_conv, channel_value_satoshis_arg, unspendable_punishment_reserve_arg_conv, user_id_arg, outbound_capacity_msat_arg, inbound_capacity_msat_arg, confirmations_required_arg_conv, force_close_spend_delay_arg_conv, is_outbound_arg, is_funding_locked_arg, is_usable_arg, is_public_arg);
18644         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18645         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18646         uint64_t ret_ref = (uint64_t)ret_var.inner;
18647         if (ret_var.is_owned) {
18648                 ret_ref |= 1;
18649         }
18650         return ret_ref;
18651 }
18652
18653 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18654         LDKChannelDetails orig_conv;
18655         orig_conv.inner = (void*)(orig & (~1));
18656         orig_conv.is_owned = false;
18657         LDKChannelDetails ret_var = ChannelDetails_clone(&orig_conv);
18658         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18659         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18660         uint64_t ret_ref = (uint64_t)ret_var.inner;
18661         if (ret_var.is_owned) {
18662                 ret_ref |= 1;
18663         }
18664         return ret_ref;
18665 }
18666
18667 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
18668         if ((this_ptr & 1) != 0) return;
18669         LDKPaymentSendFailure this_ptr_conv = *(LDKPaymentSendFailure*)(((uint64_t)this_ptr) & ~1);
18670         FREE((void*)this_ptr);
18671         PaymentSendFailure_free(this_ptr_conv);
18672 }
18673
18674 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18675         LDKPaymentSendFailure* orig_conv = (LDKPaymentSendFailure*)orig;
18676         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
18677         *ret_copy = PaymentSendFailure_clone(orig_conv);
18678         uint64_t ret_ref = (uint64_t)ret_copy;
18679         return ret_ref;
18680 }
18681
18682 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1parameter_1error(JNIEnv *env, jclass clz, int64_t a) {
18683         LDKAPIError a_conv = *(LDKAPIError*)(((uint64_t)a) & ~1);
18684         a_conv = APIError_clone((LDKAPIError*)(((uint64_t)a) & ~1));
18685         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
18686         *ret_copy = PaymentSendFailure_parameter_error(a_conv);
18687         uint64_t ret_ref = (uint64_t)ret_copy;
18688         return ret_ref;
18689 }
18690
18691 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1path_1parameter_1error(JNIEnv *env, jclass clz, int64_tArray a) {
18692         LDKCVec_CResult_NoneAPIErrorZZ a_constr;
18693         a_constr.datalen = (*env)->GetArrayLength(env, a);
18694         if (a_constr.datalen > 0)
18695                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
18696         else
18697                 a_constr.data = NULL;
18698         int64_t* a_vals = (*env)->GetLongArrayElements (env, a, NULL);
18699         for (size_t w = 0; w < a_constr.datalen; w++) {
18700                 int64_t a_conv_22 = a_vals[w];
18701                 LDKCResult_NoneAPIErrorZ a_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)a_conv_22) & ~1);
18702                 a_conv_22_conv = CResult_NoneAPIErrorZ_clone((LDKCResult_NoneAPIErrorZ*)(((uint64_t)a_conv_22) & ~1));
18703                 a_constr.data[w] = a_conv_22_conv;
18704         }
18705         (*env)->ReleaseLongArrayElements(env, a, a_vals, 0);
18706         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
18707         *ret_copy = PaymentSendFailure_path_parameter_error(a_constr);
18708         uint64_t ret_ref = (uint64_t)ret_copy;
18709         return ret_ref;
18710 }
18711
18712 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1all_1failed_1retry_1safe(JNIEnv *env, jclass clz, int64_tArray a) {
18713         LDKCVec_APIErrorZ a_constr;
18714         a_constr.datalen = (*env)->GetArrayLength(env, a);
18715         if (a_constr.datalen > 0)
18716                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
18717         else
18718                 a_constr.data = NULL;
18719         int64_t* a_vals = (*env)->GetLongArrayElements (env, a, NULL);
18720         for (size_t k = 0; k < a_constr.datalen; k++) {
18721                 int64_t a_conv_10 = a_vals[k];
18722                 LDKAPIError a_conv_10_conv = *(LDKAPIError*)(((uint64_t)a_conv_10) & ~1);
18723                 a_conv_10_conv = APIError_clone((LDKAPIError*)(((uint64_t)a_conv_10) & ~1));
18724                 a_constr.data[k] = a_conv_10_conv;
18725         }
18726         (*env)->ReleaseLongArrayElements(env, a, a_vals, 0);
18727         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
18728         *ret_copy = PaymentSendFailure_all_failed_retry_safe(a_constr);
18729         uint64_t ret_ref = (uint64_t)ret_copy;
18730         return ret_ref;
18731 }
18732
18733 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1partial_1failure(JNIEnv *env, jclass clz, int64_tArray a) {
18734         LDKCVec_CResult_NoneAPIErrorZZ a_constr;
18735         a_constr.datalen = (*env)->GetArrayLength(env, a);
18736         if (a_constr.datalen > 0)
18737                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
18738         else
18739                 a_constr.data = NULL;
18740         int64_t* a_vals = (*env)->GetLongArrayElements (env, a, NULL);
18741         for (size_t w = 0; w < a_constr.datalen; w++) {
18742                 int64_t a_conv_22 = a_vals[w];
18743                 LDKCResult_NoneAPIErrorZ a_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)a_conv_22) & ~1);
18744                 a_conv_22_conv = CResult_NoneAPIErrorZ_clone((LDKCResult_NoneAPIErrorZ*)(((uint64_t)a_conv_22) & ~1));
18745                 a_constr.data[w] = a_conv_22_conv;
18746         }
18747         (*env)->ReleaseLongArrayElements(env, a, a_vals, 0);
18748         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
18749         *ret_copy = PaymentSendFailure_partial_failure(a_constr);
18750         uint64_t ret_ref = (uint64_t)ret_copy;
18751         return ret_ref;
18752 }
18753
18754 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) {
18755         LDKFeeEstimator fee_est_conv = *(LDKFeeEstimator*)(((uint64_t)fee_est) & ~1);
18756         if (fee_est_conv.free == LDKFeeEstimator_JCalls_free) {
18757                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
18758                 LDKFeeEstimator_JCalls_cloned(&fee_est_conv);
18759         }
18760         LDKWatch chain_monitor_conv = *(LDKWatch*)(((uint64_t)chain_monitor) & ~1);
18761         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
18762                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
18763                 LDKWatch_JCalls_cloned(&chain_monitor_conv);
18764         }
18765         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)tx_broadcaster) & ~1);
18766         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
18767                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
18768                 LDKBroadcasterInterface_JCalls_cloned(&tx_broadcaster_conv);
18769         }
18770         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
18771         if (logger_conv.free == LDKLogger_JCalls_free) {
18772                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
18773                 LDKLogger_JCalls_cloned(&logger_conv);
18774         }
18775         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
18776         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
18777                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
18778                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
18779         }
18780         LDKUserConfig config_conv;
18781         config_conv.inner = (void*)(config & (~1));
18782         config_conv.is_owned = (config & 1) || (config == 0);
18783         config_conv = UserConfig_clone(&config_conv);
18784         LDKChainParameters params_conv;
18785         params_conv.inner = (void*)(params & (~1));
18786         params_conv.is_owned = (params & 1) || (params == 0);
18787         params_conv = ChainParameters_clone(&params_conv);
18788         LDKChannelManager ret_var = ChannelManager_new(fee_est_conv, chain_monitor_conv, tx_broadcaster_conv, logger_conv, keys_manager_conv, config_conv, params_conv);
18789         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18790         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18791         uint64_t ret_ref = (uint64_t)ret_var.inner;
18792         if (ret_var.is_owned) {
18793                 ret_ref |= 1;
18794         }
18795         return ret_ref;
18796 }
18797
18798 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1current_1default_1configuration(JNIEnv *env, jclass clz, int64_t this_arg) {
18799         LDKChannelManager this_arg_conv;
18800         this_arg_conv.inner = (void*)(this_arg & (~1));
18801         this_arg_conv.is_owned = false;
18802         LDKUserConfig ret_var = ChannelManager_get_current_default_configuration(&this_arg_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 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) {
18813         LDKChannelManager this_arg_conv;
18814         this_arg_conv.inner = (void*)(this_arg & (~1));
18815         this_arg_conv.is_owned = false;
18816         LDKPublicKey their_network_key_ref;
18817         CHECK((*env)->GetArrayLength(env, their_network_key) == 33);
18818         (*env)->GetByteArrayRegion(env, their_network_key, 0, 33, their_network_key_ref.compressed_form);
18819         LDKUserConfig override_config_conv;
18820         override_config_conv.inner = (void*)(override_config & (~1));
18821         override_config_conv.is_owned = (override_config & 1) || (override_config == 0);
18822         override_config_conv = UserConfig_clone(&override_config_conv);
18823         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
18824         *ret_conv = ChannelManager_create_channel(&this_arg_conv, their_network_key_ref, channel_value_satoshis, push_msat, user_id, override_config_conv);
18825         return (uint64_t)ret_conv;
18826 }
18827
18828 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
18829         LDKChannelManager this_arg_conv;
18830         this_arg_conv.inner = (void*)(this_arg & (~1));
18831         this_arg_conv.is_owned = false;
18832         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_channels(&this_arg_conv);
18833         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
18834         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
18835         for (size_t q = 0; q < ret_var.datalen; q++) {
18836                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
18837                 CHECK((((uint64_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18838                 CHECK((((uint64_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18839                 uint64_t ret_conv_16_ref = (uint64_t)ret_conv_16_var.inner;
18840                 if (ret_conv_16_var.is_owned) {
18841                         ret_conv_16_ref |= 1;
18842                 }
18843                 ret_arr_ptr[q] = ret_conv_16_ref;
18844         }
18845         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
18846         FREE(ret_var.data);
18847         return ret_arr;
18848 }
18849
18850 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1usable_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
18851         LDKChannelManager this_arg_conv;
18852         this_arg_conv.inner = (void*)(this_arg & (~1));
18853         this_arg_conv.is_owned = false;
18854         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_usable_channels(&this_arg_conv);
18855         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
18856         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
18857         for (size_t q = 0; q < ret_var.datalen; q++) {
18858                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
18859                 CHECK((((uint64_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18860                 CHECK((((uint64_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18861                 uint64_t ret_conv_16_ref = (uint64_t)ret_conv_16_var.inner;
18862                 if (ret_conv_16_var.is_owned) {
18863                         ret_conv_16_ref |= 1;
18864                 }
18865                 ret_arr_ptr[q] = ret_conv_16_ref;
18866         }
18867         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
18868         FREE(ret_var.data);
18869         return ret_arr;
18870 }
18871
18872 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1close_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray channel_id) {
18873         LDKChannelManager this_arg_conv;
18874         this_arg_conv.inner = (void*)(this_arg & (~1));
18875         this_arg_conv.is_owned = false;
18876         unsigned char channel_id_arr[32];
18877         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
18878         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
18879         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
18880         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
18881         *ret_conv = ChannelManager_close_channel(&this_arg_conv, channel_id_ref);
18882         return (uint64_t)ret_conv;
18883 }
18884
18885 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1close_1channel_1with_1target_1feerate(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray channel_id, int32_t target_feerate_sats_per_1000_weight) {
18886         LDKChannelManager this_arg_conv;
18887         this_arg_conv.inner = (void*)(this_arg & (~1));
18888         this_arg_conv.is_owned = false;
18889         unsigned char channel_id_arr[32];
18890         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
18891         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
18892         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
18893         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
18894         *ret_conv = ChannelManager_close_channel_with_target_feerate(&this_arg_conv, channel_id_ref, target_feerate_sats_per_1000_weight);
18895         return (uint64_t)ret_conv;
18896 }
18897
18898 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) {
18899         LDKChannelManager this_arg_conv;
18900         this_arg_conv.inner = (void*)(this_arg & (~1));
18901         this_arg_conv.is_owned = false;
18902         unsigned char channel_id_arr[32];
18903         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
18904         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
18905         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
18906         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
18907         *ret_conv = ChannelManager_force_close_channel(&this_arg_conv, channel_id_ref);
18908         return (uint64_t)ret_conv;
18909 }
18910
18911 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1force_1close_1all_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
18912         LDKChannelManager this_arg_conv;
18913         this_arg_conv.inner = (void*)(this_arg & (~1));
18914         this_arg_conv.is_owned = false;
18915         ChannelManager_force_close_all_channels(&this_arg_conv);
18916 }
18917
18918 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) {
18919         LDKChannelManager this_arg_conv;
18920         this_arg_conv.inner = (void*)(this_arg & (~1));
18921         this_arg_conv.is_owned = false;
18922         LDKRoute route_conv;
18923         route_conv.inner = (void*)(route & (~1));
18924         route_conv.is_owned = false;
18925         LDKThirtyTwoBytes payment_hash_ref;
18926         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
18927         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
18928         LDKThirtyTwoBytes payment_secret_ref;
18929         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
18930         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
18931         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
18932         *ret_conv = ChannelManager_send_payment(&this_arg_conv, &route_conv, payment_hash_ref, payment_secret_ref);
18933         return (uint64_t)ret_conv;
18934 }
18935
18936 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1send_1spontaneous_1payment(JNIEnv *env, jclass clz, int64_t this_arg, int64_t route, int8_tArray payment_preimage) {
18937         LDKChannelManager this_arg_conv;
18938         this_arg_conv.inner = (void*)(this_arg & (~1));
18939         this_arg_conv.is_owned = false;
18940         LDKRoute route_conv;
18941         route_conv.inner = (void*)(route & (~1));
18942         route_conv.is_owned = false;
18943         LDKThirtyTwoBytes payment_preimage_ref;
18944         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
18945         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
18946         LDKCResult_PaymentHashPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentHashPaymentSendFailureZ), "LDKCResult_PaymentHashPaymentSendFailureZ");
18947         *ret_conv = ChannelManager_send_spontaneous_payment(&this_arg_conv, &route_conv, payment_preimage_ref);
18948         return (uint64_t)ret_conv;
18949 }
18950
18951 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) {
18952         LDKChannelManager this_arg_conv;
18953         this_arg_conv.inner = (void*)(this_arg & (~1));
18954         this_arg_conv.is_owned = false;
18955         unsigned char temporary_channel_id_arr[32];
18956         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
18957         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_arr);
18958         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
18959         LDKTransaction funding_transaction_ref;
18960         funding_transaction_ref.datalen = (*env)->GetArrayLength(env, funding_transaction);
18961         funding_transaction_ref.data = MALLOC(funding_transaction_ref.datalen, "LDKTransaction Bytes");
18962         (*env)->GetByteArrayRegion(env, funding_transaction, 0, funding_transaction_ref.datalen, funding_transaction_ref.data);
18963         funding_transaction_ref.data_is_owned = true;
18964         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
18965         *ret_conv = ChannelManager_funding_transaction_generated(&this_arg_conv, temporary_channel_id_ref, funding_transaction_ref);
18966         return (uint64_t)ret_conv;
18967 }
18968
18969 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) {
18970         LDKChannelManager this_arg_conv;
18971         this_arg_conv.inner = (void*)(this_arg & (~1));
18972         this_arg_conv.is_owned = false;
18973         LDKThreeBytes rgb_ref;
18974         CHECK((*env)->GetArrayLength(env, rgb) == 3);
18975         (*env)->GetByteArrayRegion(env, rgb, 0, 3, rgb_ref.data);
18976         LDKThirtyTwoBytes alias_ref;
18977         CHECK((*env)->GetArrayLength(env, alias) == 32);
18978         (*env)->GetByteArrayRegion(env, alias, 0, 32, alias_ref.data);
18979         LDKCVec_NetAddressZ addresses_constr;
18980         addresses_constr.datalen = (*env)->GetArrayLength(env, addresses);
18981         if (addresses_constr.datalen > 0)
18982                 addresses_constr.data = MALLOC(addresses_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
18983         else
18984                 addresses_constr.data = NULL;
18985         int64_t* addresses_vals = (*env)->GetLongArrayElements (env, addresses, NULL);
18986         for (size_t m = 0; m < addresses_constr.datalen; m++) {
18987                 int64_t addresses_conv_12 = addresses_vals[m];
18988                 LDKNetAddress addresses_conv_12_conv = *(LDKNetAddress*)(((uint64_t)addresses_conv_12) & ~1);
18989                 addresses_constr.data[m] = addresses_conv_12_conv;
18990         }
18991         (*env)->ReleaseLongArrayElements(env, addresses, addresses_vals, 0);
18992         ChannelManager_broadcast_node_announcement(&this_arg_conv, rgb_ref, alias_ref, addresses_constr);
18993 }
18994
18995 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1process_1pending_1htlc_1forwards(JNIEnv *env, jclass clz, int64_t this_arg) {
18996         LDKChannelManager this_arg_conv;
18997         this_arg_conv.inner = (void*)(this_arg & (~1));
18998         this_arg_conv.is_owned = false;
18999         ChannelManager_process_pending_htlc_forwards(&this_arg_conv);
19000 }
19001
19002 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1timer_1tick_1occurred(JNIEnv *env, jclass clz, int64_t this_arg) {
19003         LDKChannelManager this_arg_conv;
19004         this_arg_conv.inner = (void*)(this_arg & (~1));
19005         this_arg_conv.is_owned = false;
19006         ChannelManager_timer_tick_occurred(&this_arg_conv);
19007 }
19008
19009 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelManager_1fail_1htlc_1backwards(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_hash) {
19010         LDKChannelManager this_arg_conv;
19011         this_arg_conv.inner = (void*)(this_arg & (~1));
19012         this_arg_conv.is_owned = false;
19013         unsigned char payment_hash_arr[32];
19014         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
19015         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_arr);
19016         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
19017         jboolean ret_val = ChannelManager_fail_htlc_backwards(&this_arg_conv, payment_hash_ref);
19018         return ret_val;
19019 }
19020
19021 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelManager_1claim_1funds(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_preimage) {
19022         LDKChannelManager this_arg_conv;
19023         this_arg_conv.inner = (void*)(this_arg & (~1));
19024         this_arg_conv.is_owned = false;
19025         LDKThirtyTwoBytes payment_preimage_ref;
19026         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
19027         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
19028         jboolean ret_val = ChannelManager_claim_funds(&this_arg_conv, payment_preimage_ref);
19029         return ret_val;
19030 }
19031
19032 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1our_1node_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
19033         LDKChannelManager this_arg_conv;
19034         this_arg_conv.inner = (void*)(this_arg & (~1));
19035         this_arg_conv.is_owned = false;
19036         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
19037         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelManager_get_our_node_id(&this_arg_conv).compressed_form);
19038         return ret_arr;
19039 }
19040
19041 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) {
19042         LDKChannelManager this_arg_conv;
19043         this_arg_conv.inner = (void*)(this_arg & (~1));
19044         this_arg_conv.is_owned = false;
19045         LDKOutPoint funding_txo_conv;
19046         funding_txo_conv.inner = (void*)(funding_txo & (~1));
19047         funding_txo_conv.is_owned = false;
19048         ChannelManager_channel_monitor_updated(&this_arg_conv, &funding_txo_conv, highest_applied_update_id);
19049 }
19050
19051 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) {
19052         LDKChannelManager this_arg_conv;
19053         this_arg_conv.inner = (void*)(this_arg & (~1));
19054         this_arg_conv.is_owned = false;
19055         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(((uint64_t)min_value_msat) & ~1);
19056         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)min_value_msat) & ~1));
19057         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
19058         *ret_conv = ChannelManager_create_inbound_payment(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs, user_payment_id);
19059         return ((uint64_t)ret_conv);
19060 }
19061
19062 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) {
19063         LDKChannelManager this_arg_conv;
19064         this_arg_conv.inner = (void*)(this_arg & (~1));
19065         this_arg_conv.is_owned = false;
19066         LDKThirtyTwoBytes payment_hash_ref;
19067         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
19068         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
19069         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(((uint64_t)min_value_msat) & ~1);
19070         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)min_value_msat) & ~1));
19071         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
19072         *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);
19073         return (uint64_t)ret_conv;
19074 }
19075
19076 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
19077         LDKChannelManager this_arg_conv;
19078         this_arg_conv.inner = (void*)(this_arg & (~1));
19079         this_arg_conv.is_owned = false;
19080         LDKMessageSendEventsProvider* ret_ret =MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
19081         *ret_ret = ChannelManager_as_MessageSendEventsProvider(&this_arg_conv);
19082         return (uint64_t)ret_ret;
19083 }
19084
19085 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1EventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
19086         LDKChannelManager this_arg_conv;
19087         this_arg_conv.inner = (void*)(this_arg & (~1));
19088         this_arg_conv.is_owned = false;
19089         LDKEventsProvider* ret_ret =MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
19090         *ret_ret = ChannelManager_as_EventsProvider(&this_arg_conv);
19091         return (uint64_t)ret_ret;
19092 }
19093
19094 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Listen(JNIEnv *env, jclass clz, int64_t this_arg) {
19095         LDKChannelManager this_arg_conv;
19096         this_arg_conv.inner = (void*)(this_arg & (~1));
19097         this_arg_conv.is_owned = false;
19098         LDKListen* ret_ret =MALLOC(sizeof(LDKListen), "LDKListen");
19099         *ret_ret = ChannelManager_as_Listen(&this_arg_conv);
19100         return (uint64_t)ret_ret;
19101 }
19102
19103 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Confirm(JNIEnv *env, jclass clz, int64_t this_arg) {
19104         LDKChannelManager this_arg_conv;
19105         this_arg_conv.inner = (void*)(this_arg & (~1));
19106         this_arg_conv.is_owned = false;
19107         LDKConfirm* ret_ret =MALLOC(sizeof(LDKConfirm), "LDKConfirm");
19108         *ret_ret = ChannelManager_as_Confirm(&this_arg_conv);
19109         return (uint64_t)ret_ret;
19110 }
19111
19112 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) {
19113         LDKChannelManager this_arg_conv;
19114         this_arg_conv.inner = (void*)(this_arg & (~1));
19115         this_arg_conv.is_owned = false;
19116         jboolean ret_val = ChannelManager_await_persistable_update_timeout(&this_arg_conv, max_wait);
19117         return ret_val;
19118 }
19119
19120 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1await_1persistable_1update(JNIEnv *env, jclass clz, int64_t this_arg) {
19121         LDKChannelManager this_arg_conv;
19122         this_arg_conv.inner = (void*)(this_arg & (~1));
19123         this_arg_conv.is_owned = false;
19124         ChannelManager_await_persistable_update(&this_arg_conv);
19125 }
19126
19127 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1current_1best_1block(JNIEnv *env, jclass clz, int64_t this_arg) {
19128         LDKChannelManager this_arg_conv;
19129         this_arg_conv.inner = (void*)(this_arg & (~1));
19130         this_arg_conv.is_owned = false;
19131         LDKBestBlock ret_var = ChannelManager_current_best_block(&this_arg_conv);
19132         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19133         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19134         uint64_t ret_ref = (uint64_t)ret_var.inner;
19135         if (ret_var.is_owned) {
19136                 ret_ref |= 1;
19137         }
19138         return ret_ref;
19139 }
19140
19141 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1ChannelMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
19142         LDKChannelManager this_arg_conv;
19143         this_arg_conv.inner = (void*)(this_arg & (~1));
19144         this_arg_conv.is_owned = false;
19145         LDKChannelMessageHandler* ret_ret =MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
19146         *ret_ret = ChannelManager_as_ChannelMessageHandler(&this_arg_conv);
19147         return (uint64_t)ret_ret;
19148 }
19149
19150 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1write(JNIEnv *env, jclass clz, int64_t obj) {
19151         LDKChannelManager obj_conv;
19152         obj_conv.inner = (void*)(obj & (~1));
19153         obj_conv.is_owned = false;
19154         LDKCVec_u8Z ret_var = ChannelManager_write(&obj_conv);
19155         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
19156         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
19157         CVec_u8Z_free(ret_var);
19158         return ret_arr;
19159 }
19160
19161 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19162         LDKChannelManagerReadArgs this_obj_conv;
19163         this_obj_conv.inner = (void*)(this_obj & (~1));
19164         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19165         ChannelManagerReadArgs_free(this_obj_conv);
19166 }
19167
19168 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1keys_1manager(JNIEnv *env, jclass clz, int64_t this_ptr) {
19169         LDKChannelManagerReadArgs this_ptr_conv;
19170         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19171         this_ptr_conv.is_owned = false;
19172         uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_keys_manager(&this_ptr_conv);
19173         return ret_ret;
19174 }
19175
19176 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1keys_1manager(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19177         LDKChannelManagerReadArgs this_ptr_conv;
19178         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19179         this_ptr_conv.is_owned = false;
19180         LDKKeysInterface val_conv = *(LDKKeysInterface*)(((uint64_t)val) & ~1);
19181         if (val_conv.free == LDKKeysInterface_JCalls_free) {
19182                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
19183                 LDKKeysInterface_JCalls_cloned(&val_conv);
19184         }
19185         ChannelManagerReadArgs_set_keys_manager(&this_ptr_conv, val_conv);
19186 }
19187
19188 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1fee_1estimator(JNIEnv *env, jclass clz, int64_t this_ptr) {
19189         LDKChannelManagerReadArgs this_ptr_conv;
19190         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19191         this_ptr_conv.is_owned = false;
19192         uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_fee_estimator(&this_ptr_conv);
19193         return ret_ret;
19194 }
19195
19196 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1fee_1estimator(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19197         LDKChannelManagerReadArgs this_ptr_conv;
19198         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19199         this_ptr_conv.is_owned = false;
19200         LDKFeeEstimator val_conv = *(LDKFeeEstimator*)(((uint64_t)val) & ~1);
19201         if (val_conv.free == LDKFeeEstimator_JCalls_free) {
19202                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
19203                 LDKFeeEstimator_JCalls_cloned(&val_conv);
19204         }
19205         ChannelManagerReadArgs_set_fee_estimator(&this_ptr_conv, val_conv);
19206 }
19207
19208 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1chain_1monitor(JNIEnv *env, jclass clz, int64_t this_ptr) {
19209         LDKChannelManagerReadArgs this_ptr_conv;
19210         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19211         this_ptr_conv.is_owned = false;
19212         uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_chain_monitor(&this_ptr_conv);
19213         return ret_ret;
19214 }
19215
19216 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1chain_1monitor(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19217         LDKChannelManagerReadArgs this_ptr_conv;
19218         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19219         this_ptr_conv.is_owned = false;
19220         LDKWatch val_conv = *(LDKWatch*)(((uint64_t)val) & ~1);
19221         if (val_conv.free == LDKWatch_JCalls_free) {
19222                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
19223                 LDKWatch_JCalls_cloned(&val_conv);
19224         }
19225         ChannelManagerReadArgs_set_chain_monitor(&this_ptr_conv, val_conv);
19226 }
19227
19228 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1tx_1broadcaster(JNIEnv *env, jclass clz, int64_t this_ptr) {
19229         LDKChannelManagerReadArgs this_ptr_conv;
19230         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19231         this_ptr_conv.is_owned = false;
19232         uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_tx_broadcaster(&this_ptr_conv);
19233         return ret_ret;
19234 }
19235
19236 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1tx_1broadcaster(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19237         LDKChannelManagerReadArgs this_ptr_conv;
19238         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19239         this_ptr_conv.is_owned = false;
19240         LDKBroadcasterInterface val_conv = *(LDKBroadcasterInterface*)(((uint64_t)val) & ~1);
19241         if (val_conv.free == LDKBroadcasterInterface_JCalls_free) {
19242                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
19243                 LDKBroadcasterInterface_JCalls_cloned(&val_conv);
19244         }
19245         ChannelManagerReadArgs_set_tx_broadcaster(&this_ptr_conv, val_conv);
19246 }
19247
19248 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1logger(JNIEnv *env, jclass clz, int64_t this_ptr) {
19249         LDKChannelManagerReadArgs this_ptr_conv;
19250         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19251         this_ptr_conv.is_owned = false;
19252         uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_logger(&this_ptr_conv);
19253         return ret_ret;
19254 }
19255
19256 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1logger(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19257         LDKChannelManagerReadArgs this_ptr_conv;
19258         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19259         this_ptr_conv.is_owned = false;
19260         LDKLogger val_conv = *(LDKLogger*)(((uint64_t)val) & ~1);
19261         if (val_conv.free == LDKLogger_JCalls_free) {
19262                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
19263                 LDKLogger_JCalls_cloned(&val_conv);
19264         }
19265         ChannelManagerReadArgs_set_logger(&this_ptr_conv, val_conv);
19266 }
19267
19268 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1default_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
19269         LDKChannelManagerReadArgs this_ptr_conv;
19270         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19271         this_ptr_conv.is_owned = false;
19272         LDKUserConfig ret_var = ChannelManagerReadArgs_get_default_config(&this_ptr_conv);
19273         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19274         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19275         uint64_t ret_ref = (uint64_t)ret_var.inner;
19276         if (ret_var.is_owned) {
19277                 ret_ref |= 1;
19278         }
19279         return ret_ref;
19280 }
19281
19282 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1default_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19283         LDKChannelManagerReadArgs this_ptr_conv;
19284         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19285         this_ptr_conv.is_owned = false;
19286         LDKUserConfig val_conv;
19287         val_conv.inner = (void*)(val & (~1));
19288         val_conv.is_owned = (val & 1) || (val == 0);
19289         val_conv = UserConfig_clone(&val_conv);
19290         ChannelManagerReadArgs_set_default_config(&this_ptr_conv, val_conv);
19291 }
19292
19293 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) {
19294         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
19295         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
19296                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
19297                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
19298         }
19299         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
19300         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
19301                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
19302                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
19303         }
19304         LDKWatch chain_monitor_conv = *(LDKWatch*)(((uint64_t)chain_monitor) & ~1);
19305         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
19306                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
19307                 LDKWatch_JCalls_cloned(&chain_monitor_conv);
19308         }
19309         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)tx_broadcaster) & ~1);
19310         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
19311                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
19312                 LDKBroadcasterInterface_JCalls_cloned(&tx_broadcaster_conv);
19313         }
19314         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
19315         if (logger_conv.free == LDKLogger_JCalls_free) {
19316                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
19317                 LDKLogger_JCalls_cloned(&logger_conv);
19318         }
19319         LDKUserConfig default_config_conv;
19320         default_config_conv.inner = (void*)(default_config & (~1));
19321         default_config_conv.is_owned = (default_config & 1) || (default_config == 0);
19322         default_config_conv = UserConfig_clone(&default_config_conv);
19323         LDKCVec_ChannelMonitorZ channel_monitors_constr;
19324         channel_monitors_constr.datalen = (*env)->GetArrayLength(env, channel_monitors);
19325         if (channel_monitors_constr.datalen > 0)
19326                 channel_monitors_constr.data = MALLOC(channel_monitors_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
19327         else
19328                 channel_monitors_constr.data = NULL;
19329         int64_t* channel_monitors_vals = (*env)->GetLongArrayElements (env, channel_monitors, NULL);
19330         for (size_t q = 0; q < channel_monitors_constr.datalen; q++) {
19331                 int64_t channel_monitors_conv_16 = channel_monitors_vals[q];
19332                 LDKChannelMonitor channel_monitors_conv_16_conv;
19333                 channel_monitors_conv_16_conv.inner = (void*)(channel_monitors_conv_16 & (~1));
19334                 channel_monitors_conv_16_conv.is_owned = (channel_monitors_conv_16 & 1) || (channel_monitors_conv_16 == 0);
19335                 channel_monitors_constr.data[q] = channel_monitors_conv_16_conv;
19336         }
19337         (*env)->ReleaseLongArrayElements(env, channel_monitors, channel_monitors_vals, 0);
19338         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);
19339         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19340         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19341         uint64_t ret_ref = (uint64_t)ret_var.inner;
19342         if (ret_var.is_owned) {
19343                 ret_ref |= 1;
19344         }
19345         return ret_ref;
19346 }
19347
19348 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
19349         LDKu8slice ser_ref;
19350         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
19351         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
19352         LDKChannelManagerReadArgs arg_conv;
19353         arg_conv.inner = (void*)(arg & (~1));
19354         arg_conv.is_owned = (arg & 1) || (arg == 0);
19355         // Warning: we need a move here but no clone is available for LDKChannelManagerReadArgs
19356         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
19357         *ret_conv = C2Tuple_BlockHashChannelManagerZ_read(ser_ref, arg_conv);
19358         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
19359         return (uint64_t)ret_conv;
19360 }
19361
19362 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DecodeError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19363         LDKDecodeError this_obj_conv;
19364         this_obj_conv.inner = (void*)(this_obj & (~1));
19365         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19366         DecodeError_free(this_obj_conv);
19367 }
19368
19369 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19370         LDKDecodeError orig_conv;
19371         orig_conv.inner = (void*)(orig & (~1));
19372         orig_conv.is_owned = false;
19373         LDKDecodeError ret_var = DecodeError_clone(&orig_conv);
19374         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19375         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19376         uint64_t ret_ref = (uint64_t)ret_var.inner;
19377         if (ret_var.is_owned) {
19378                 ret_ref |= 1;
19379         }
19380         return ret_ref;
19381 }
19382
19383 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19384         LDKInit this_obj_conv;
19385         this_obj_conv.inner = (void*)(this_obj & (~1));
19386         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19387         Init_free(this_obj_conv);
19388 }
19389
19390 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
19391         LDKInit this_ptr_conv;
19392         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19393         this_ptr_conv.is_owned = false;
19394         LDKInitFeatures ret_var = Init_get_features(&this_ptr_conv);
19395         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19396         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19397         uint64_t ret_ref = (uint64_t)ret_var.inner;
19398         if (ret_var.is_owned) {
19399                 ret_ref |= 1;
19400         }
19401         return ret_ref;
19402 }
19403
19404 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19405         LDKInit this_ptr_conv;
19406         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19407         this_ptr_conv.is_owned = false;
19408         LDKInitFeatures val_conv;
19409         val_conv.inner = (void*)(val & (~1));
19410         val_conv.is_owned = (val & 1) || (val == 0);
19411         val_conv = InitFeatures_clone(&val_conv);
19412         Init_set_features(&this_ptr_conv, val_conv);
19413 }
19414
19415 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1new(JNIEnv *env, jclass clz, int64_t features_arg) {
19416         LDKInitFeatures features_arg_conv;
19417         features_arg_conv.inner = (void*)(features_arg & (~1));
19418         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
19419         features_arg_conv = InitFeatures_clone(&features_arg_conv);
19420         LDKInit ret_var = Init_new(features_arg_conv);
19421         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19422         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19423         uint64_t ret_ref = (uint64_t)ret_var.inner;
19424         if (ret_var.is_owned) {
19425                 ret_ref |= 1;
19426         }
19427         return ret_ref;
19428 }
19429
19430 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19431         LDKInit orig_conv;
19432         orig_conv.inner = (void*)(orig & (~1));
19433         orig_conv.is_owned = false;
19434         LDKInit ret_var = Init_clone(&orig_conv);
19435         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19436         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19437         uint64_t ret_ref = (uint64_t)ret_var.inner;
19438         if (ret_var.is_owned) {
19439                 ret_ref |= 1;
19440         }
19441         return ret_ref;
19442 }
19443
19444 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19445         LDKErrorMessage this_obj_conv;
19446         this_obj_conv.inner = (void*)(this_obj & (~1));
19447         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19448         ErrorMessage_free(this_obj_conv);
19449 }
19450
19451 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
19452         LDKErrorMessage this_ptr_conv;
19453         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19454         this_ptr_conv.is_owned = false;
19455         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
19456         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ErrorMessage_get_channel_id(&this_ptr_conv));
19457         return ret_arr;
19458 }
19459
19460 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19461         LDKErrorMessage this_ptr_conv;
19462         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19463         this_ptr_conv.is_owned = false;
19464         LDKThirtyTwoBytes val_ref;
19465         CHECK((*env)->GetArrayLength(env, val) == 32);
19466         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
19467         ErrorMessage_set_channel_id(&this_ptr_conv, val_ref);
19468 }
19469
19470 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1get_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
19471         LDKErrorMessage this_ptr_conv;
19472         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19473         this_ptr_conv.is_owned = false;
19474         LDKStr ret_str = ErrorMessage_get_data(&this_ptr_conv);
19475         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
19476         Str_free(ret_str);
19477         return ret_conv;
19478 }
19479
19480 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1set_1data(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
19481         LDKErrorMessage this_ptr_conv;
19482         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19483         this_ptr_conv.is_owned = false;
19484         LDKStr val_conv = java_to_owned_str(env, val);
19485         ErrorMessage_set_data(&this_ptr_conv, val_conv);
19486 }
19487
19488 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, jstring data_arg) {
19489         LDKThirtyTwoBytes channel_id_arg_ref;
19490         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
19491         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
19492         LDKStr data_arg_conv = java_to_owned_str(env, data_arg);
19493         LDKErrorMessage ret_var = ErrorMessage_new(channel_id_arg_ref, data_arg_conv);
19494         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19495         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19496         uint64_t ret_ref = (uint64_t)ret_var.inner;
19497         if (ret_var.is_owned) {
19498                 ret_ref |= 1;
19499         }
19500         return ret_ref;
19501 }
19502
19503 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19504         LDKErrorMessage orig_conv;
19505         orig_conv.inner = (void*)(orig & (~1));
19506         orig_conv.is_owned = false;
19507         LDKErrorMessage ret_var = ErrorMessage_clone(&orig_conv);
19508         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19509         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19510         uint64_t ret_ref = (uint64_t)ret_var.inner;
19511         if (ret_var.is_owned) {
19512                 ret_ref |= 1;
19513         }
19514         return ret_ref;
19515 }
19516
19517 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19518         LDKPing this_obj_conv;
19519         this_obj_conv.inner = (void*)(this_obj & (~1));
19520         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19521         Ping_free(this_obj_conv);
19522 }
19523
19524 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Ping_1get_1ponglen(JNIEnv *env, jclass clz, int64_t this_ptr) {
19525         LDKPing this_ptr_conv;
19526         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19527         this_ptr_conv.is_owned = false;
19528         int16_t ret_val = Ping_get_ponglen(&this_ptr_conv);
19529         return ret_val;
19530 }
19531
19532 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1set_1ponglen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
19533         LDKPing this_ptr_conv;
19534         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19535         this_ptr_conv.is_owned = false;
19536         Ping_set_ponglen(&this_ptr_conv, val);
19537 }
19538
19539 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Ping_1get_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr) {
19540         LDKPing this_ptr_conv;
19541         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19542         this_ptr_conv.is_owned = false;
19543         int16_t ret_val = Ping_get_byteslen(&this_ptr_conv);
19544         return ret_val;
19545 }
19546
19547 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1set_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
19548         LDKPing this_ptr_conv;
19549         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19550         this_ptr_conv.is_owned = false;
19551         Ping_set_byteslen(&this_ptr_conv, val);
19552 }
19553
19554 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1new(JNIEnv *env, jclass clz, int16_t ponglen_arg, int16_t byteslen_arg) {
19555         LDKPing ret_var = Ping_new(ponglen_arg, byteslen_arg);
19556         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19557         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19558         uint64_t ret_ref = (uint64_t)ret_var.inner;
19559         if (ret_var.is_owned) {
19560                 ret_ref |= 1;
19561         }
19562         return ret_ref;
19563 }
19564
19565 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19566         LDKPing orig_conv;
19567         orig_conv.inner = (void*)(orig & (~1));
19568         orig_conv.is_owned = false;
19569         LDKPing ret_var = Ping_clone(&orig_conv);
19570         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19571         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19572         uint64_t ret_ref = (uint64_t)ret_var.inner;
19573         if (ret_var.is_owned) {
19574                 ret_ref |= 1;
19575         }
19576         return ret_ref;
19577 }
19578
19579 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Pong_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19580         LDKPong this_obj_conv;
19581         this_obj_conv.inner = (void*)(this_obj & (~1));
19582         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19583         Pong_free(this_obj_conv);
19584 }
19585
19586 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Pong_1get_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr) {
19587         LDKPong this_ptr_conv;
19588         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19589         this_ptr_conv.is_owned = false;
19590         int16_t ret_val = Pong_get_byteslen(&this_ptr_conv);
19591         return ret_val;
19592 }
19593
19594 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Pong_1set_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
19595         LDKPong this_ptr_conv;
19596         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19597         this_ptr_conv.is_owned = false;
19598         Pong_set_byteslen(&this_ptr_conv, val);
19599 }
19600
19601 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1new(JNIEnv *env, jclass clz, int16_t byteslen_arg) {
19602         LDKPong ret_var = Pong_new(byteslen_arg);
19603         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19604         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19605         uint64_t ret_ref = (uint64_t)ret_var.inner;
19606         if (ret_var.is_owned) {
19607                 ret_ref |= 1;
19608         }
19609         return ret_ref;
19610 }
19611
19612 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19613         LDKPong orig_conv;
19614         orig_conv.inner = (void*)(orig & (~1));
19615         orig_conv.is_owned = false;
19616         LDKPong ret_var = Pong_clone(&orig_conv);
19617         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19618         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19619         uint64_t ret_ref = (uint64_t)ret_var.inner;
19620         if (ret_var.is_owned) {
19621                 ret_ref |= 1;
19622         }
19623         return ret_ref;
19624 }
19625
19626 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19627         LDKOpenChannel this_obj_conv;
19628         this_obj_conv.inner = (void*)(this_obj & (~1));
19629         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19630         OpenChannel_free(this_obj_conv);
19631 }
19632
19633 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
19634         LDKOpenChannel this_ptr_conv;
19635         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19636         this_ptr_conv.is_owned = false;
19637         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
19638         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OpenChannel_get_chain_hash(&this_ptr_conv));
19639         return ret_arr;
19640 }
19641
19642 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19643         LDKOpenChannel this_ptr_conv;
19644         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19645         this_ptr_conv.is_owned = false;
19646         LDKThirtyTwoBytes val_ref;
19647         CHECK((*env)->GetArrayLength(env, val) == 32);
19648         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
19649         OpenChannel_set_chain_hash(&this_ptr_conv, val_ref);
19650 }
19651
19652 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
19653         LDKOpenChannel this_ptr_conv;
19654         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19655         this_ptr_conv.is_owned = false;
19656         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
19657         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OpenChannel_get_temporary_channel_id(&this_ptr_conv));
19658         return ret_arr;
19659 }
19660
19661 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19662         LDKOpenChannel this_ptr_conv;
19663         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19664         this_ptr_conv.is_owned = false;
19665         LDKThirtyTwoBytes val_ref;
19666         CHECK((*env)->GetArrayLength(env, val) == 32);
19667         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
19668         OpenChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
19669 }
19670
19671 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
19672         LDKOpenChannel this_ptr_conv;
19673         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19674         this_ptr_conv.is_owned = false;
19675         int64_t ret_val = OpenChannel_get_funding_satoshis(&this_ptr_conv);
19676         return ret_val;
19677 }
19678
19679 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19680         LDKOpenChannel this_ptr_conv;
19681         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19682         this_ptr_conv.is_owned = false;
19683         OpenChannel_set_funding_satoshis(&this_ptr_conv, val);
19684 }
19685
19686 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1push_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
19687         LDKOpenChannel this_ptr_conv;
19688         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19689         this_ptr_conv.is_owned = false;
19690         int64_t ret_val = OpenChannel_get_push_msat(&this_ptr_conv);
19691         return ret_val;
19692 }
19693
19694 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1push_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19695         LDKOpenChannel this_ptr_conv;
19696         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19697         this_ptr_conv.is_owned = false;
19698         OpenChannel_set_push_msat(&this_ptr_conv, val);
19699 }
19700
19701 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
19702         LDKOpenChannel this_ptr_conv;
19703         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19704         this_ptr_conv.is_owned = false;
19705         int64_t ret_val = OpenChannel_get_dust_limit_satoshis(&this_ptr_conv);
19706         return ret_val;
19707 }
19708
19709 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19710         LDKOpenChannel this_ptr_conv;
19711         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19712         this_ptr_conv.is_owned = false;
19713         OpenChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
19714 }
19715
19716 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) {
19717         LDKOpenChannel this_ptr_conv;
19718         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19719         this_ptr_conv.is_owned = false;
19720         int64_t ret_val = OpenChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
19721         return ret_val;
19722 }
19723
19724 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) {
19725         LDKOpenChannel this_ptr_conv;
19726         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19727         this_ptr_conv.is_owned = false;
19728         OpenChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
19729 }
19730
19731 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
19732         LDKOpenChannel this_ptr_conv;
19733         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19734         this_ptr_conv.is_owned = false;
19735         int64_t ret_val = OpenChannel_get_channel_reserve_satoshis(&this_ptr_conv);
19736         return ret_val;
19737 }
19738
19739 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19740         LDKOpenChannel this_ptr_conv;
19741         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19742         this_ptr_conv.is_owned = false;
19743         OpenChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
19744 }
19745
19746 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
19747         LDKOpenChannel this_ptr_conv;
19748         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19749         this_ptr_conv.is_owned = false;
19750         int64_t ret_val = OpenChannel_get_htlc_minimum_msat(&this_ptr_conv);
19751         return ret_val;
19752 }
19753
19754 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19755         LDKOpenChannel this_ptr_conv;
19756         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19757         this_ptr_conv.is_owned = false;
19758         OpenChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
19759 }
19760
19761 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr) {
19762         LDKOpenChannel this_ptr_conv;
19763         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19764         this_ptr_conv.is_owned = false;
19765         int32_t ret_val = OpenChannel_get_feerate_per_kw(&this_ptr_conv);
19766         return ret_val;
19767 }
19768
19769 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
19770         LDKOpenChannel this_ptr_conv;
19771         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19772         this_ptr_conv.is_owned = false;
19773         OpenChannel_set_feerate_per_kw(&this_ptr_conv, val);
19774 }
19775
19776 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
19777         LDKOpenChannel this_ptr_conv;
19778         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19779         this_ptr_conv.is_owned = false;
19780         int16_t ret_val = OpenChannel_get_to_self_delay(&this_ptr_conv);
19781         return ret_val;
19782 }
19783
19784 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
19785         LDKOpenChannel this_ptr_conv;
19786         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19787         this_ptr_conv.is_owned = false;
19788         OpenChannel_set_to_self_delay(&this_ptr_conv, val);
19789 }
19790
19791 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
19792         LDKOpenChannel this_ptr_conv;
19793         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19794         this_ptr_conv.is_owned = false;
19795         int16_t ret_val = OpenChannel_get_max_accepted_htlcs(&this_ptr_conv);
19796         return ret_val;
19797 }
19798
19799 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
19800         LDKOpenChannel this_ptr_conv;
19801         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19802         this_ptr_conv.is_owned = false;
19803         OpenChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
19804 }
19805
19806 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
19807         LDKOpenChannel this_ptr_conv;
19808         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19809         this_ptr_conv.is_owned = false;
19810         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
19811         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_funding_pubkey(&this_ptr_conv).compressed_form);
19812         return ret_arr;
19813 }
19814
19815 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19816         LDKOpenChannel this_ptr_conv;
19817         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19818         this_ptr_conv.is_owned = false;
19819         LDKPublicKey val_ref;
19820         CHECK((*env)->GetArrayLength(env, val) == 33);
19821         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
19822         OpenChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
19823 }
19824
19825 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
19826         LDKOpenChannel this_ptr_conv;
19827         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19828         this_ptr_conv.is_owned = false;
19829         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
19830         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form);
19831         return ret_arr;
19832 }
19833
19834 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19835         LDKOpenChannel this_ptr_conv;
19836         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19837         this_ptr_conv.is_owned = false;
19838         LDKPublicKey val_ref;
19839         CHECK((*env)->GetArrayLength(env, val) == 33);
19840         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
19841         OpenChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
19842 }
19843
19844 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
19845         LDKOpenChannel this_ptr_conv;
19846         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19847         this_ptr_conv.is_owned = false;
19848         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
19849         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_payment_point(&this_ptr_conv).compressed_form);
19850         return ret_arr;
19851 }
19852
19853 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19854         LDKOpenChannel this_ptr_conv;
19855         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19856         this_ptr_conv.is_owned = false;
19857         LDKPublicKey val_ref;
19858         CHECK((*env)->GetArrayLength(env, val) == 33);
19859         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
19860         OpenChannel_set_payment_point(&this_ptr_conv, val_ref);
19861 }
19862
19863 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
19864         LDKOpenChannel this_ptr_conv;
19865         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19866         this_ptr_conv.is_owned = false;
19867         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
19868         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
19869         return ret_arr;
19870 }
19871
19872 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19873         LDKOpenChannel this_ptr_conv;
19874         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19875         this_ptr_conv.is_owned = false;
19876         LDKPublicKey val_ref;
19877         CHECK((*env)->GetArrayLength(env, val) == 33);
19878         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
19879         OpenChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
19880 }
19881
19882 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
19883         LDKOpenChannel this_ptr_conv;
19884         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19885         this_ptr_conv.is_owned = false;
19886         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
19887         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form);
19888         return ret_arr;
19889 }
19890
19891 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19892         LDKOpenChannel this_ptr_conv;
19893         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19894         this_ptr_conv.is_owned = false;
19895         LDKPublicKey val_ref;
19896         CHECK((*env)->GetArrayLength(env, val) == 33);
19897         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
19898         OpenChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
19899 }
19900
19901 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1first_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
19902         LDKOpenChannel this_ptr_conv;
19903         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19904         this_ptr_conv.is_owned = false;
19905         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
19906         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form);
19907         return ret_arr;
19908 }
19909
19910 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) {
19911         LDKOpenChannel this_ptr_conv;
19912         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19913         this_ptr_conv.is_owned = false;
19914         LDKPublicKey val_ref;
19915         CHECK((*env)->GetArrayLength(env, val) == 33);
19916         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
19917         OpenChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
19918 }
19919
19920 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1flags(JNIEnv *env, jclass clz, int64_t this_ptr) {
19921         LDKOpenChannel this_ptr_conv;
19922         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19923         this_ptr_conv.is_owned = false;
19924         int8_t ret_val = OpenChannel_get_channel_flags(&this_ptr_conv);
19925         return ret_val;
19926 }
19927
19928 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1flags(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
19929         LDKOpenChannel this_ptr_conv;
19930         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19931         this_ptr_conv.is_owned = false;
19932         OpenChannel_set_channel_flags(&this_ptr_conv, val);
19933 }
19934
19935 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19936         LDKOpenChannel orig_conv;
19937         orig_conv.inner = (void*)(orig & (~1));
19938         orig_conv.is_owned = false;
19939         LDKOpenChannel ret_var = OpenChannel_clone(&orig_conv);
19940         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19941         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19942         uint64_t ret_ref = (uint64_t)ret_var.inner;
19943         if (ret_var.is_owned) {
19944                 ret_ref |= 1;
19945         }
19946         return ret_ref;
19947 }
19948
19949 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19950         LDKAcceptChannel this_obj_conv;
19951         this_obj_conv.inner = (void*)(this_obj & (~1));
19952         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19953         AcceptChannel_free(this_obj_conv);
19954 }
19955
19956 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
19957         LDKAcceptChannel this_ptr_conv;
19958         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19959         this_ptr_conv.is_owned = false;
19960         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
19961         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *AcceptChannel_get_temporary_channel_id(&this_ptr_conv));
19962         return ret_arr;
19963 }
19964
19965 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19966         LDKAcceptChannel this_ptr_conv;
19967         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19968         this_ptr_conv.is_owned = false;
19969         LDKThirtyTwoBytes val_ref;
19970         CHECK((*env)->GetArrayLength(env, val) == 32);
19971         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
19972         AcceptChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
19973 }
19974
19975 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
19976         LDKAcceptChannel this_ptr_conv;
19977         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19978         this_ptr_conv.is_owned = false;
19979         int64_t ret_val = AcceptChannel_get_dust_limit_satoshis(&this_ptr_conv);
19980         return ret_val;
19981 }
19982
19983 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19984         LDKAcceptChannel this_ptr_conv;
19985         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19986         this_ptr_conv.is_owned = false;
19987         AcceptChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
19988 }
19989
19990 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) {
19991         LDKAcceptChannel this_ptr_conv;
19992         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19993         this_ptr_conv.is_owned = false;
19994         int64_t ret_val = AcceptChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
19995         return ret_val;
19996 }
19997
19998 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) {
19999         LDKAcceptChannel this_ptr_conv;
20000         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20001         this_ptr_conv.is_owned = false;
20002         AcceptChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
20003 }
20004
20005 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
20006         LDKAcceptChannel this_ptr_conv;
20007         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20008         this_ptr_conv.is_owned = false;
20009         int64_t ret_val = AcceptChannel_get_channel_reserve_satoshis(&this_ptr_conv);
20010         return ret_val;
20011 }
20012
20013 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20014         LDKAcceptChannel this_ptr_conv;
20015         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20016         this_ptr_conv.is_owned = false;
20017         AcceptChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
20018 }
20019
20020 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
20021         LDKAcceptChannel this_ptr_conv;
20022         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20023         this_ptr_conv.is_owned = false;
20024         int64_t ret_val = AcceptChannel_get_htlc_minimum_msat(&this_ptr_conv);
20025         return ret_val;
20026 }
20027
20028 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20029         LDKAcceptChannel this_ptr_conv;
20030         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20031         this_ptr_conv.is_owned = false;
20032         AcceptChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
20033 }
20034
20035 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
20036         LDKAcceptChannel this_ptr_conv;
20037         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20038         this_ptr_conv.is_owned = false;
20039         int32_t ret_val = AcceptChannel_get_minimum_depth(&this_ptr_conv);
20040         return ret_val;
20041 }
20042
20043 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
20044         LDKAcceptChannel this_ptr_conv;
20045         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20046         this_ptr_conv.is_owned = false;
20047         AcceptChannel_set_minimum_depth(&this_ptr_conv, val);
20048 }
20049
20050 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
20051         LDKAcceptChannel this_ptr_conv;
20052         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20053         this_ptr_conv.is_owned = false;
20054         int16_t ret_val = AcceptChannel_get_to_self_delay(&this_ptr_conv);
20055         return ret_val;
20056 }
20057
20058 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
20059         LDKAcceptChannel this_ptr_conv;
20060         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20061         this_ptr_conv.is_owned = false;
20062         AcceptChannel_set_to_self_delay(&this_ptr_conv, val);
20063 }
20064
20065 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
20066         LDKAcceptChannel this_ptr_conv;
20067         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20068         this_ptr_conv.is_owned = false;
20069         int16_t ret_val = AcceptChannel_get_max_accepted_htlcs(&this_ptr_conv);
20070         return ret_val;
20071 }
20072
20073 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
20074         LDKAcceptChannel this_ptr_conv;
20075         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20076         this_ptr_conv.is_owned = false;
20077         AcceptChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
20078 }
20079
20080 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
20081         LDKAcceptChannel this_ptr_conv;
20082         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20083         this_ptr_conv.is_owned = false;
20084         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
20085         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_funding_pubkey(&this_ptr_conv).compressed_form);
20086         return ret_arr;
20087 }
20088
20089 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20090         LDKAcceptChannel this_ptr_conv;
20091         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20092         this_ptr_conv.is_owned = false;
20093         LDKPublicKey val_ref;
20094         CHECK((*env)->GetArrayLength(env, val) == 33);
20095         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
20096         AcceptChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
20097 }
20098
20099 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
20100         LDKAcceptChannel this_ptr_conv;
20101         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20102         this_ptr_conv.is_owned = false;
20103         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
20104         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form);
20105         return ret_arr;
20106 }
20107
20108 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20109         LDKAcceptChannel this_ptr_conv;
20110         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20111         this_ptr_conv.is_owned = false;
20112         LDKPublicKey val_ref;
20113         CHECK((*env)->GetArrayLength(env, val) == 33);
20114         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
20115         AcceptChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
20116 }
20117
20118 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
20119         LDKAcceptChannel this_ptr_conv;
20120         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20121         this_ptr_conv.is_owned = false;
20122         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
20123         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_payment_point(&this_ptr_conv).compressed_form);
20124         return ret_arr;
20125 }
20126
20127 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20128         LDKAcceptChannel this_ptr_conv;
20129         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20130         this_ptr_conv.is_owned = false;
20131         LDKPublicKey val_ref;
20132         CHECK((*env)->GetArrayLength(env, val) == 33);
20133         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
20134         AcceptChannel_set_payment_point(&this_ptr_conv, val_ref);
20135 }
20136
20137 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
20138         LDKAcceptChannel this_ptr_conv;
20139         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20140         this_ptr_conv.is_owned = false;
20141         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
20142         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
20143         return ret_arr;
20144 }
20145
20146 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20147         LDKAcceptChannel this_ptr_conv;
20148         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20149         this_ptr_conv.is_owned = false;
20150         LDKPublicKey val_ref;
20151         CHECK((*env)->GetArrayLength(env, val) == 33);
20152         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
20153         AcceptChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
20154 }
20155
20156 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
20157         LDKAcceptChannel this_ptr_conv;
20158         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20159         this_ptr_conv.is_owned = false;
20160         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
20161         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form);
20162         return ret_arr;
20163 }
20164
20165 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20166         LDKAcceptChannel this_ptr_conv;
20167         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20168         this_ptr_conv.is_owned = false;
20169         LDKPublicKey val_ref;
20170         CHECK((*env)->GetArrayLength(env, val) == 33);
20171         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
20172         AcceptChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
20173 }
20174
20175 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1first_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
20176         LDKAcceptChannel this_ptr_conv;
20177         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20178         this_ptr_conv.is_owned = false;
20179         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
20180         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form);
20181         return ret_arr;
20182 }
20183
20184 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) {
20185         LDKAcceptChannel this_ptr_conv;
20186         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20187         this_ptr_conv.is_owned = false;
20188         LDKPublicKey val_ref;
20189         CHECK((*env)->GetArrayLength(env, val) == 33);
20190         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
20191         AcceptChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
20192 }
20193
20194 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20195         LDKAcceptChannel orig_conv;
20196         orig_conv.inner = (void*)(orig & (~1));
20197         orig_conv.is_owned = false;
20198         LDKAcceptChannel ret_var = AcceptChannel_clone(&orig_conv);
20199         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20200         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20201         uint64_t ret_ref = (uint64_t)ret_var.inner;
20202         if (ret_var.is_owned) {
20203                 ret_ref |= 1;
20204         }
20205         return ret_ref;
20206 }
20207
20208 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20209         LDKFundingCreated this_obj_conv;
20210         this_obj_conv.inner = (void*)(this_obj & (~1));
20211         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20212         FundingCreated_free(this_obj_conv);
20213 }
20214
20215 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
20216         LDKFundingCreated this_ptr_conv;
20217         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20218         this_ptr_conv.is_owned = false;
20219         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
20220         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingCreated_get_temporary_channel_id(&this_ptr_conv));
20221         return ret_arr;
20222 }
20223
20224 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20225         LDKFundingCreated this_ptr_conv;
20226         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20227         this_ptr_conv.is_owned = false;
20228         LDKThirtyTwoBytes val_ref;
20229         CHECK((*env)->GetArrayLength(env, val) == 32);
20230         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
20231         FundingCreated_set_temporary_channel_id(&this_ptr_conv, val_ref);
20232 }
20233
20234 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1funding_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
20235         LDKFundingCreated this_ptr_conv;
20236         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20237         this_ptr_conv.is_owned = false;
20238         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
20239         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingCreated_get_funding_txid(&this_ptr_conv));
20240         return ret_arr;
20241 }
20242
20243 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1funding_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20244         LDKFundingCreated this_ptr_conv;
20245         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20246         this_ptr_conv.is_owned = false;
20247         LDKThirtyTwoBytes val_ref;
20248         CHECK((*env)->GetArrayLength(env, val) == 32);
20249         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
20250         FundingCreated_set_funding_txid(&this_ptr_conv, val_ref);
20251 }
20252
20253 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1funding_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
20254         LDKFundingCreated this_ptr_conv;
20255         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20256         this_ptr_conv.is_owned = false;
20257         int16_t ret_val = FundingCreated_get_funding_output_index(&this_ptr_conv);
20258         return ret_val;
20259 }
20260
20261 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1funding_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
20262         LDKFundingCreated this_ptr_conv;
20263         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20264         this_ptr_conv.is_owned = false;
20265         FundingCreated_set_funding_output_index(&this_ptr_conv, val);
20266 }
20267
20268 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
20269         LDKFundingCreated this_ptr_conv;
20270         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20271         this_ptr_conv.is_owned = false;
20272         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
20273         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, FundingCreated_get_signature(&this_ptr_conv).compact_form);
20274         return ret_arr;
20275 }
20276
20277 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20278         LDKFundingCreated this_ptr_conv;
20279         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20280         this_ptr_conv.is_owned = false;
20281         LDKSignature val_ref;
20282         CHECK((*env)->GetArrayLength(env, val) == 64);
20283         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
20284         FundingCreated_set_signature(&this_ptr_conv, val_ref);
20285 }
20286
20287 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) {
20288         LDKThirtyTwoBytes temporary_channel_id_arg_ref;
20289         CHECK((*env)->GetArrayLength(env, temporary_channel_id_arg) == 32);
20290         (*env)->GetByteArrayRegion(env, temporary_channel_id_arg, 0, 32, temporary_channel_id_arg_ref.data);
20291         LDKThirtyTwoBytes funding_txid_arg_ref;
20292         CHECK((*env)->GetArrayLength(env, funding_txid_arg) == 32);
20293         (*env)->GetByteArrayRegion(env, funding_txid_arg, 0, 32, funding_txid_arg_ref.data);
20294         LDKSignature signature_arg_ref;
20295         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
20296         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
20297         LDKFundingCreated ret_var = FundingCreated_new(temporary_channel_id_arg_ref, funding_txid_arg_ref, funding_output_index_arg, signature_arg_ref);
20298         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20299         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20300         uint64_t ret_ref = (uint64_t)ret_var.inner;
20301         if (ret_var.is_owned) {
20302                 ret_ref |= 1;
20303         }
20304         return ret_ref;
20305 }
20306
20307 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20308         LDKFundingCreated orig_conv;
20309         orig_conv.inner = (void*)(orig & (~1));
20310         orig_conv.is_owned = false;
20311         LDKFundingCreated ret_var = FundingCreated_clone(&orig_conv);
20312         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20313         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20314         uint64_t ret_ref = (uint64_t)ret_var.inner;
20315         if (ret_var.is_owned) {
20316                 ret_ref |= 1;
20317         }
20318         return ret_ref;
20319 }
20320
20321 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20322         LDKFundingSigned this_obj_conv;
20323         this_obj_conv.inner = (void*)(this_obj & (~1));
20324         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20325         FundingSigned_free(this_obj_conv);
20326 }
20327
20328 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
20329         LDKFundingSigned this_ptr_conv;
20330         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20331         this_ptr_conv.is_owned = false;
20332         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
20333         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingSigned_get_channel_id(&this_ptr_conv));
20334         return ret_arr;
20335 }
20336
20337 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20338         LDKFundingSigned this_ptr_conv;
20339         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20340         this_ptr_conv.is_owned = false;
20341         LDKThirtyTwoBytes val_ref;
20342         CHECK((*env)->GetArrayLength(env, val) == 32);
20343         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
20344         FundingSigned_set_channel_id(&this_ptr_conv, val_ref);
20345 }
20346
20347 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
20348         LDKFundingSigned this_ptr_conv;
20349         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20350         this_ptr_conv.is_owned = false;
20351         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
20352         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, FundingSigned_get_signature(&this_ptr_conv).compact_form);
20353         return ret_arr;
20354 }
20355
20356 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20357         LDKFundingSigned this_ptr_conv;
20358         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20359         this_ptr_conv.is_owned = false;
20360         LDKSignature val_ref;
20361         CHECK((*env)->GetArrayLength(env, val) == 64);
20362         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
20363         FundingSigned_set_signature(&this_ptr_conv, val_ref);
20364 }
20365
20366 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray signature_arg) {
20367         LDKThirtyTwoBytes channel_id_arg_ref;
20368         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
20369         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
20370         LDKSignature signature_arg_ref;
20371         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
20372         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
20373         LDKFundingSigned ret_var = FundingSigned_new(channel_id_arg_ref, signature_arg_ref);
20374         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20375         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20376         uint64_t ret_ref = (uint64_t)ret_var.inner;
20377         if (ret_var.is_owned) {
20378                 ret_ref |= 1;
20379         }
20380         return ret_ref;
20381 }
20382
20383 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20384         LDKFundingSigned orig_conv;
20385         orig_conv.inner = (void*)(orig & (~1));
20386         orig_conv.is_owned = false;
20387         LDKFundingSigned ret_var = FundingSigned_clone(&orig_conv);
20388         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20389         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20390         uint64_t ret_ref = (uint64_t)ret_var.inner;
20391         if (ret_var.is_owned) {
20392                 ret_ref |= 1;
20393         }
20394         return ret_ref;
20395 }
20396
20397 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingLocked_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20398         LDKFundingLocked this_obj_conv;
20399         this_obj_conv.inner = (void*)(this_obj & (~1));
20400         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20401         FundingLocked_free(this_obj_conv);
20402 }
20403
20404 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingLocked_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
20405         LDKFundingLocked this_ptr_conv;
20406         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20407         this_ptr_conv.is_owned = false;
20408         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
20409         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingLocked_get_channel_id(&this_ptr_conv));
20410         return ret_arr;
20411 }
20412
20413 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingLocked_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20414         LDKFundingLocked this_ptr_conv;
20415         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20416         this_ptr_conv.is_owned = false;
20417         LDKThirtyTwoBytes val_ref;
20418         CHECK((*env)->GetArrayLength(env, val) == 32);
20419         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
20420         FundingLocked_set_channel_id(&this_ptr_conv, val_ref);
20421 }
20422
20423 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingLocked_1get_1next_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
20424         LDKFundingLocked this_ptr_conv;
20425         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20426         this_ptr_conv.is_owned = false;
20427         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
20428         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, FundingLocked_get_next_per_commitment_point(&this_ptr_conv).compressed_form);
20429         return ret_arr;
20430 }
20431
20432 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) {
20433         LDKFundingLocked this_ptr_conv;
20434         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20435         this_ptr_conv.is_owned = false;
20436         LDKPublicKey val_ref;
20437         CHECK((*env)->GetArrayLength(env, val) == 33);
20438         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
20439         FundingLocked_set_next_per_commitment_point(&this_ptr_conv, val_ref);
20440 }
20441
20442 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) {
20443         LDKThirtyTwoBytes channel_id_arg_ref;
20444         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
20445         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
20446         LDKPublicKey next_per_commitment_point_arg_ref;
20447         CHECK((*env)->GetArrayLength(env, next_per_commitment_point_arg) == 33);
20448         (*env)->GetByteArrayRegion(env, next_per_commitment_point_arg, 0, 33, next_per_commitment_point_arg_ref.compressed_form);
20449         LDKFundingLocked ret_var = FundingLocked_new(channel_id_arg_ref, next_per_commitment_point_arg_ref);
20450         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20451         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20452         uint64_t ret_ref = (uint64_t)ret_var.inner;
20453         if (ret_var.is_owned) {
20454                 ret_ref |= 1;
20455         }
20456         return ret_ref;
20457 }
20458
20459 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingLocked_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20460         LDKFundingLocked orig_conv;
20461         orig_conv.inner = (void*)(orig & (~1));
20462         orig_conv.is_owned = false;
20463         LDKFundingLocked ret_var = FundingLocked_clone(&orig_conv);
20464         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20465         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20466         uint64_t ret_ref = (uint64_t)ret_var.inner;
20467         if (ret_var.is_owned) {
20468                 ret_ref |= 1;
20469         }
20470         return ret_ref;
20471 }
20472
20473 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20474         LDKShutdown this_obj_conv;
20475         this_obj_conv.inner = (void*)(this_obj & (~1));
20476         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20477         Shutdown_free(this_obj_conv);
20478 }
20479
20480 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
20481         LDKShutdown this_ptr_conv;
20482         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20483         this_ptr_conv.is_owned = false;
20484         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
20485         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *Shutdown_get_channel_id(&this_ptr_conv));
20486         return ret_arr;
20487 }
20488
20489 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20490         LDKShutdown this_ptr_conv;
20491         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20492         this_ptr_conv.is_owned = false;
20493         LDKThirtyTwoBytes val_ref;
20494         CHECK((*env)->GetArrayLength(env, val) == 32);
20495         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
20496         Shutdown_set_channel_id(&this_ptr_conv, val_ref);
20497 }
20498
20499 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1get_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
20500         LDKShutdown this_ptr_conv;
20501         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20502         this_ptr_conv.is_owned = false;
20503         LDKu8slice ret_var = Shutdown_get_scriptpubkey(&this_ptr_conv);
20504         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20505         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20506         return ret_arr;
20507 }
20508
20509 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1set_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20510         LDKShutdown this_ptr_conv;
20511         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20512         this_ptr_conv.is_owned = false;
20513         LDKCVec_u8Z val_ref;
20514         val_ref.datalen = (*env)->GetArrayLength(env, val);
20515         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
20516         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
20517         Shutdown_set_scriptpubkey(&this_ptr_conv, val_ref);
20518 }
20519
20520 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray scriptpubkey_arg) {
20521         LDKThirtyTwoBytes channel_id_arg_ref;
20522         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
20523         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
20524         LDKCVec_u8Z scriptpubkey_arg_ref;
20525         scriptpubkey_arg_ref.datalen = (*env)->GetArrayLength(env, scriptpubkey_arg);
20526         scriptpubkey_arg_ref.data = MALLOC(scriptpubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
20527         (*env)->GetByteArrayRegion(env, scriptpubkey_arg, 0, scriptpubkey_arg_ref.datalen, scriptpubkey_arg_ref.data);
20528         LDKShutdown ret_var = Shutdown_new(channel_id_arg_ref, scriptpubkey_arg_ref);
20529         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20530         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20531         uint64_t ret_ref = (uint64_t)ret_var.inner;
20532         if (ret_var.is_owned) {
20533                 ret_ref |= 1;
20534         }
20535         return ret_ref;
20536 }
20537
20538 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20539         LDKShutdown orig_conv;
20540         orig_conv.inner = (void*)(orig & (~1));
20541         orig_conv.is_owned = false;
20542         LDKShutdown ret_var = Shutdown_clone(&orig_conv);
20543         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20544         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20545         uint64_t ret_ref = (uint64_t)ret_var.inner;
20546         if (ret_var.is_owned) {
20547                 ret_ref |= 1;
20548         }
20549         return ret_ref;
20550 }
20551
20552 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20553         LDKClosingSignedFeeRange this_obj_conv;
20554         this_obj_conv.inner = (void*)(this_obj & (~1));
20555         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20556         ClosingSignedFeeRange_free(this_obj_conv);
20557 }
20558
20559 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1get_1min_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
20560         LDKClosingSignedFeeRange this_ptr_conv;
20561         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20562         this_ptr_conv.is_owned = false;
20563         int64_t ret_val = ClosingSignedFeeRange_get_min_fee_satoshis(&this_ptr_conv);
20564         return ret_val;
20565 }
20566
20567 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1set_1min_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20568         LDKClosingSignedFeeRange this_ptr_conv;
20569         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20570         this_ptr_conv.is_owned = false;
20571         ClosingSignedFeeRange_set_min_fee_satoshis(&this_ptr_conv, val);
20572 }
20573
20574 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1get_1max_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
20575         LDKClosingSignedFeeRange this_ptr_conv;
20576         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20577         this_ptr_conv.is_owned = false;
20578         int64_t ret_val = ClosingSignedFeeRange_get_max_fee_satoshis(&this_ptr_conv);
20579         return ret_val;
20580 }
20581
20582 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1set_1max_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20583         LDKClosingSignedFeeRange this_ptr_conv;
20584         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20585         this_ptr_conv.is_owned = false;
20586         ClosingSignedFeeRange_set_max_fee_satoshis(&this_ptr_conv, val);
20587 }
20588
20589 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1new(JNIEnv *env, jclass clz, int64_t min_fee_satoshis_arg, int64_t max_fee_satoshis_arg) {
20590         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_new(min_fee_satoshis_arg, max_fee_satoshis_arg);
20591         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20592         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20593         uint64_t ret_ref = (uint64_t)ret_var.inner;
20594         if (ret_var.is_owned) {
20595                 ret_ref |= 1;
20596         }
20597         return ret_ref;
20598 }
20599
20600 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20601         LDKClosingSignedFeeRange orig_conv;
20602         orig_conv.inner = (void*)(orig & (~1));
20603         orig_conv.is_owned = false;
20604         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_clone(&orig_conv);
20605         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20606         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20607         uint64_t ret_ref = (uint64_t)ret_var.inner;
20608         if (ret_var.is_owned) {
20609                 ret_ref |= 1;
20610         }
20611         return ret_ref;
20612 }
20613
20614 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20615         LDKClosingSigned this_obj_conv;
20616         this_obj_conv.inner = (void*)(this_obj & (~1));
20617         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20618         ClosingSigned_free(this_obj_conv);
20619 }
20620
20621 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
20622         LDKClosingSigned this_ptr_conv;
20623         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20624         this_ptr_conv.is_owned = false;
20625         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
20626         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ClosingSigned_get_channel_id(&this_ptr_conv));
20627         return ret_arr;
20628 }
20629
20630 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20631         LDKClosingSigned this_ptr_conv;
20632         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20633         this_ptr_conv.is_owned = false;
20634         LDKThirtyTwoBytes val_ref;
20635         CHECK((*env)->GetArrayLength(env, val) == 32);
20636         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
20637         ClosingSigned_set_channel_id(&this_ptr_conv, val_ref);
20638 }
20639
20640 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
20641         LDKClosingSigned this_ptr_conv;
20642         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20643         this_ptr_conv.is_owned = false;
20644         int64_t ret_val = ClosingSigned_get_fee_satoshis(&this_ptr_conv);
20645         return ret_val;
20646 }
20647
20648 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20649         LDKClosingSigned this_ptr_conv;
20650         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20651         this_ptr_conv.is_owned = false;
20652         ClosingSigned_set_fee_satoshis(&this_ptr_conv, val);
20653 }
20654
20655 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
20656         LDKClosingSigned this_ptr_conv;
20657         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20658         this_ptr_conv.is_owned = false;
20659         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
20660         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ClosingSigned_get_signature(&this_ptr_conv).compact_form);
20661         return ret_arr;
20662 }
20663
20664 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20665         LDKClosingSigned this_ptr_conv;
20666         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20667         this_ptr_conv.is_owned = false;
20668         LDKSignature val_ref;
20669         CHECK((*env)->GetArrayLength(env, val) == 64);
20670         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
20671         ClosingSigned_set_signature(&this_ptr_conv, val_ref);
20672 }
20673
20674 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1fee_1range(JNIEnv *env, jclass clz, int64_t this_ptr) {
20675         LDKClosingSigned this_ptr_conv;
20676         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20677         this_ptr_conv.is_owned = false;
20678         LDKClosingSignedFeeRange ret_var = ClosingSigned_get_fee_range(&this_ptr_conv);
20679         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20680         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20681         uint64_t ret_ref = (uint64_t)ret_var.inner;
20682         if (ret_var.is_owned) {
20683                 ret_ref |= 1;
20684         }
20685         return ret_ref;
20686 }
20687
20688 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1fee_1range(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20689         LDKClosingSigned this_ptr_conv;
20690         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20691         this_ptr_conv.is_owned = false;
20692         LDKClosingSignedFeeRange val_conv;
20693         val_conv.inner = (void*)(val & (~1));
20694         val_conv.is_owned = (val & 1) || (val == 0);
20695         val_conv = ClosingSignedFeeRange_clone(&val_conv);
20696         ClosingSigned_set_fee_range(&this_ptr_conv, val_conv);
20697 }
20698
20699 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int64_t fee_satoshis_arg, int8_tArray signature_arg, int64_t fee_range_arg) {
20700         LDKThirtyTwoBytes channel_id_arg_ref;
20701         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
20702         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
20703         LDKSignature signature_arg_ref;
20704         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
20705         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
20706         LDKClosingSignedFeeRange fee_range_arg_conv;
20707         fee_range_arg_conv.inner = (void*)(fee_range_arg & (~1));
20708         fee_range_arg_conv.is_owned = (fee_range_arg & 1) || (fee_range_arg == 0);
20709         fee_range_arg_conv = ClosingSignedFeeRange_clone(&fee_range_arg_conv);
20710         LDKClosingSigned ret_var = ClosingSigned_new(channel_id_arg_ref, fee_satoshis_arg, signature_arg_ref, fee_range_arg_conv);
20711         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20712         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20713         uint64_t ret_ref = (uint64_t)ret_var.inner;
20714         if (ret_var.is_owned) {
20715                 ret_ref |= 1;
20716         }
20717         return ret_ref;
20718 }
20719
20720 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20721         LDKClosingSigned orig_conv;
20722         orig_conv.inner = (void*)(orig & (~1));
20723         orig_conv.is_owned = false;
20724         LDKClosingSigned ret_var = ClosingSigned_clone(&orig_conv);
20725         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20726         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20727         uint64_t ret_ref = (uint64_t)ret_var.inner;
20728         if (ret_var.is_owned) {
20729                 ret_ref |= 1;
20730         }
20731         return ret_ref;
20732 }
20733
20734 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20735         LDKUpdateAddHTLC this_obj_conv;
20736         this_obj_conv.inner = (void*)(this_obj & (~1));
20737         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20738         UpdateAddHTLC_free(this_obj_conv);
20739 }
20740
20741 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
20742         LDKUpdateAddHTLC this_ptr_conv;
20743         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20744         this_ptr_conv.is_owned = false;
20745         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
20746         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateAddHTLC_get_channel_id(&this_ptr_conv));
20747         return ret_arr;
20748 }
20749
20750 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20751         LDKUpdateAddHTLC this_ptr_conv;
20752         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20753         this_ptr_conv.is_owned = false;
20754         LDKThirtyTwoBytes val_ref;
20755         CHECK((*env)->GetArrayLength(env, val) == 32);
20756         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
20757         UpdateAddHTLC_set_channel_id(&this_ptr_conv, val_ref);
20758 }
20759
20760 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
20761         LDKUpdateAddHTLC this_ptr_conv;
20762         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20763         this_ptr_conv.is_owned = false;
20764         int64_t ret_val = UpdateAddHTLC_get_htlc_id(&this_ptr_conv);
20765         return ret_val;
20766 }
20767
20768 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20769         LDKUpdateAddHTLC this_ptr_conv;
20770         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20771         this_ptr_conv.is_owned = false;
20772         UpdateAddHTLC_set_htlc_id(&this_ptr_conv, val);
20773 }
20774
20775 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
20776         LDKUpdateAddHTLC this_ptr_conv;
20777         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20778         this_ptr_conv.is_owned = false;
20779         int64_t ret_val = UpdateAddHTLC_get_amount_msat(&this_ptr_conv);
20780         return ret_val;
20781 }
20782
20783 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20784         LDKUpdateAddHTLC this_ptr_conv;
20785         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20786         this_ptr_conv.is_owned = false;
20787         UpdateAddHTLC_set_amount_msat(&this_ptr_conv, val);
20788 }
20789
20790 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
20791         LDKUpdateAddHTLC this_ptr_conv;
20792         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20793         this_ptr_conv.is_owned = false;
20794         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
20795         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateAddHTLC_get_payment_hash(&this_ptr_conv));
20796         return ret_arr;
20797 }
20798
20799 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20800         LDKUpdateAddHTLC this_ptr_conv;
20801         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20802         this_ptr_conv.is_owned = false;
20803         LDKThirtyTwoBytes val_ref;
20804         CHECK((*env)->GetArrayLength(env, val) == 32);
20805         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
20806         UpdateAddHTLC_set_payment_hash(&this_ptr_conv, val_ref);
20807 }
20808
20809 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr) {
20810         LDKUpdateAddHTLC this_ptr_conv;
20811         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20812         this_ptr_conv.is_owned = false;
20813         int32_t ret_val = UpdateAddHTLC_get_cltv_expiry(&this_ptr_conv);
20814         return ret_val;
20815 }
20816
20817 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
20818         LDKUpdateAddHTLC this_ptr_conv;
20819         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20820         this_ptr_conv.is_owned = false;
20821         UpdateAddHTLC_set_cltv_expiry(&this_ptr_conv, val);
20822 }
20823
20824 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20825         LDKUpdateAddHTLC orig_conv;
20826         orig_conv.inner = (void*)(orig & (~1));
20827         orig_conv.is_owned = false;
20828         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(&orig_conv);
20829         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20830         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20831         uint64_t ret_ref = (uint64_t)ret_var.inner;
20832         if (ret_var.is_owned) {
20833                 ret_ref |= 1;
20834         }
20835         return ret_ref;
20836 }
20837
20838 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20839         LDKUpdateFulfillHTLC this_obj_conv;
20840         this_obj_conv.inner = (void*)(this_obj & (~1));
20841         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20842         UpdateFulfillHTLC_free(this_obj_conv);
20843 }
20844
20845 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
20846         LDKUpdateFulfillHTLC this_ptr_conv;
20847         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20848         this_ptr_conv.is_owned = false;
20849         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
20850         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFulfillHTLC_get_channel_id(&this_ptr_conv));
20851         return ret_arr;
20852 }
20853
20854 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20855         LDKUpdateFulfillHTLC this_ptr_conv;
20856         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20857         this_ptr_conv.is_owned = false;
20858         LDKThirtyTwoBytes val_ref;
20859         CHECK((*env)->GetArrayLength(env, val) == 32);
20860         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
20861         UpdateFulfillHTLC_set_channel_id(&this_ptr_conv, val_ref);
20862 }
20863
20864 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
20865         LDKUpdateFulfillHTLC this_ptr_conv;
20866         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20867         this_ptr_conv.is_owned = false;
20868         int64_t ret_val = UpdateFulfillHTLC_get_htlc_id(&this_ptr_conv);
20869         return ret_val;
20870 }
20871
20872 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20873         LDKUpdateFulfillHTLC this_ptr_conv;
20874         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20875         this_ptr_conv.is_owned = false;
20876         UpdateFulfillHTLC_set_htlc_id(&this_ptr_conv, val);
20877 }
20878
20879 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1payment_1preimage(JNIEnv *env, jclass clz, int64_t this_ptr) {
20880         LDKUpdateFulfillHTLC this_ptr_conv;
20881         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20882         this_ptr_conv.is_owned = false;
20883         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
20884         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFulfillHTLC_get_payment_preimage(&this_ptr_conv));
20885         return ret_arr;
20886 }
20887
20888 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1payment_1preimage(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20889         LDKUpdateFulfillHTLC this_ptr_conv;
20890         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20891         this_ptr_conv.is_owned = false;
20892         LDKThirtyTwoBytes val_ref;
20893         CHECK((*env)->GetArrayLength(env, val) == 32);
20894         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
20895         UpdateFulfillHTLC_set_payment_preimage(&this_ptr_conv, val_ref);
20896 }
20897
20898 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) {
20899         LDKThirtyTwoBytes channel_id_arg_ref;
20900         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
20901         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
20902         LDKThirtyTwoBytes payment_preimage_arg_ref;
20903         CHECK((*env)->GetArrayLength(env, payment_preimage_arg) == 32);
20904         (*env)->GetByteArrayRegion(env, payment_preimage_arg, 0, 32, payment_preimage_arg_ref.data);
20905         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_new(channel_id_arg_ref, htlc_id_arg, payment_preimage_arg_ref);
20906         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20907         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20908         uint64_t ret_ref = (uint64_t)ret_var.inner;
20909         if (ret_var.is_owned) {
20910                 ret_ref |= 1;
20911         }
20912         return ret_ref;
20913 }
20914
20915 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20916         LDKUpdateFulfillHTLC orig_conv;
20917         orig_conv.inner = (void*)(orig & (~1));
20918         orig_conv.is_owned = false;
20919         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(&orig_conv);
20920         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20921         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20922         uint64_t ret_ref = (uint64_t)ret_var.inner;
20923         if (ret_var.is_owned) {
20924                 ret_ref |= 1;
20925         }
20926         return ret_ref;
20927 }
20928
20929 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20930         LDKUpdateFailHTLC this_obj_conv;
20931         this_obj_conv.inner = (void*)(this_obj & (~1));
20932         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20933         UpdateFailHTLC_free(this_obj_conv);
20934 }
20935
20936 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
20937         LDKUpdateFailHTLC this_ptr_conv;
20938         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20939         this_ptr_conv.is_owned = false;
20940         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
20941         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFailHTLC_get_channel_id(&this_ptr_conv));
20942         return ret_arr;
20943 }
20944
20945 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20946         LDKUpdateFailHTLC this_ptr_conv;
20947         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20948         this_ptr_conv.is_owned = false;
20949         LDKThirtyTwoBytes val_ref;
20950         CHECK((*env)->GetArrayLength(env, val) == 32);
20951         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
20952         UpdateFailHTLC_set_channel_id(&this_ptr_conv, val_ref);
20953 }
20954
20955 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
20956         LDKUpdateFailHTLC this_ptr_conv;
20957         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20958         this_ptr_conv.is_owned = false;
20959         int64_t ret_val = UpdateFailHTLC_get_htlc_id(&this_ptr_conv);
20960         return ret_val;
20961 }
20962
20963 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20964         LDKUpdateFailHTLC this_ptr_conv;
20965         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20966         this_ptr_conv.is_owned = false;
20967         UpdateFailHTLC_set_htlc_id(&this_ptr_conv, val);
20968 }
20969
20970 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20971         LDKUpdateFailHTLC orig_conv;
20972         orig_conv.inner = (void*)(orig & (~1));
20973         orig_conv.is_owned = false;
20974         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(&orig_conv);
20975         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20976         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20977         uint64_t ret_ref = (uint64_t)ret_var.inner;
20978         if (ret_var.is_owned) {
20979                 ret_ref |= 1;
20980         }
20981         return ret_ref;
20982 }
20983
20984 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20985         LDKUpdateFailMalformedHTLC this_obj_conv;
20986         this_obj_conv.inner = (void*)(this_obj & (~1));
20987         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20988         UpdateFailMalformedHTLC_free(this_obj_conv);
20989 }
20990
20991 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
20992         LDKUpdateFailMalformedHTLC this_ptr_conv;
20993         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20994         this_ptr_conv.is_owned = false;
20995         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
20996         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFailMalformedHTLC_get_channel_id(&this_ptr_conv));
20997         return ret_arr;
20998 }
20999
21000 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21001         LDKUpdateFailMalformedHTLC this_ptr_conv;
21002         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21003         this_ptr_conv.is_owned = false;
21004         LDKThirtyTwoBytes val_ref;
21005         CHECK((*env)->GetArrayLength(env, val) == 32);
21006         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
21007         UpdateFailMalformedHTLC_set_channel_id(&this_ptr_conv, val_ref);
21008 }
21009
21010 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
21011         LDKUpdateFailMalformedHTLC this_ptr_conv;
21012         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21013         this_ptr_conv.is_owned = false;
21014         int64_t ret_val = UpdateFailMalformedHTLC_get_htlc_id(&this_ptr_conv);
21015         return ret_val;
21016 }
21017
21018 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
21019         LDKUpdateFailMalformedHTLC this_ptr_conv;
21020         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21021         this_ptr_conv.is_owned = false;
21022         UpdateFailMalformedHTLC_set_htlc_id(&this_ptr_conv, val);
21023 }
21024
21025 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1failure_1code(JNIEnv *env, jclass clz, int64_t this_ptr) {
21026         LDKUpdateFailMalformedHTLC this_ptr_conv;
21027         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21028         this_ptr_conv.is_owned = false;
21029         int16_t ret_val = UpdateFailMalformedHTLC_get_failure_code(&this_ptr_conv);
21030         return ret_val;
21031 }
21032
21033 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1failure_1code(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
21034         LDKUpdateFailMalformedHTLC this_ptr_conv;
21035         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21036         this_ptr_conv.is_owned = false;
21037         UpdateFailMalformedHTLC_set_failure_code(&this_ptr_conv, val);
21038 }
21039
21040 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21041         LDKUpdateFailMalformedHTLC orig_conv;
21042         orig_conv.inner = (void*)(orig & (~1));
21043         orig_conv.is_owned = false;
21044         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(&orig_conv);
21045         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21046         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21047         uint64_t ret_ref = (uint64_t)ret_var.inner;
21048         if (ret_var.is_owned) {
21049                 ret_ref |= 1;
21050         }
21051         return ret_ref;
21052 }
21053
21054 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
21055         LDKCommitmentSigned this_obj_conv;
21056         this_obj_conv.inner = (void*)(this_obj & (~1));
21057         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21058         CommitmentSigned_free(this_obj_conv);
21059 }
21060
21061 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
21062         LDKCommitmentSigned this_ptr_conv;
21063         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21064         this_ptr_conv.is_owned = false;
21065         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
21066         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *CommitmentSigned_get_channel_id(&this_ptr_conv));
21067         return ret_arr;
21068 }
21069
21070 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21071         LDKCommitmentSigned this_ptr_conv;
21072         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21073         this_ptr_conv.is_owned = false;
21074         LDKThirtyTwoBytes val_ref;
21075         CHECK((*env)->GetArrayLength(env, val) == 32);
21076         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
21077         CommitmentSigned_set_channel_id(&this_ptr_conv, val_ref);
21078 }
21079
21080 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
21081         LDKCommitmentSigned this_ptr_conv;
21082         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21083         this_ptr_conv.is_owned = false;
21084         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
21085         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, CommitmentSigned_get_signature(&this_ptr_conv).compact_form);
21086         return ret_arr;
21087 }
21088
21089 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21090         LDKCommitmentSigned this_ptr_conv;
21091         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21092         this_ptr_conv.is_owned = false;
21093         LDKSignature val_ref;
21094         CHECK((*env)->GetArrayLength(env, val) == 64);
21095         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
21096         CommitmentSigned_set_signature(&this_ptr_conv, val_ref);
21097 }
21098
21099 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1htlc_1signatures(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
21100         LDKCommitmentSigned this_ptr_conv;
21101         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21102         this_ptr_conv.is_owned = false;
21103         LDKCVec_SignatureZ val_constr;
21104         val_constr.datalen = (*env)->GetArrayLength(env, val);
21105         if (val_constr.datalen > 0)
21106                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
21107         else
21108                 val_constr.data = NULL;
21109         for (size_t i = 0; i < val_constr.datalen; i++) {
21110                 int8_tArray val_conv_8 = (*env)->GetObjectArrayElement(env, val, i);
21111                 LDKSignature val_conv_8_ref;
21112                 CHECK((*env)->GetArrayLength(env, val_conv_8) == 64);
21113                 (*env)->GetByteArrayRegion(env, val_conv_8, 0, 64, val_conv_8_ref.compact_form);
21114                 val_constr.data[i] = val_conv_8_ref;
21115         }
21116         CommitmentSigned_set_htlc_signatures(&this_ptr_conv, val_constr);
21117 }
21118
21119 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) {
21120         LDKThirtyTwoBytes channel_id_arg_ref;
21121         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
21122         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
21123         LDKSignature signature_arg_ref;
21124         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
21125         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
21126         LDKCVec_SignatureZ htlc_signatures_arg_constr;
21127         htlc_signatures_arg_constr.datalen = (*env)->GetArrayLength(env, htlc_signatures_arg);
21128         if (htlc_signatures_arg_constr.datalen > 0)
21129                 htlc_signatures_arg_constr.data = MALLOC(htlc_signatures_arg_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
21130         else
21131                 htlc_signatures_arg_constr.data = NULL;
21132         for (size_t i = 0; i < htlc_signatures_arg_constr.datalen; i++) {
21133                 int8_tArray htlc_signatures_arg_conv_8 = (*env)->GetObjectArrayElement(env, htlc_signatures_arg, i);
21134                 LDKSignature htlc_signatures_arg_conv_8_ref;
21135                 CHECK((*env)->GetArrayLength(env, htlc_signatures_arg_conv_8) == 64);
21136                 (*env)->GetByteArrayRegion(env, htlc_signatures_arg_conv_8, 0, 64, htlc_signatures_arg_conv_8_ref.compact_form);
21137                 htlc_signatures_arg_constr.data[i] = htlc_signatures_arg_conv_8_ref;
21138         }
21139         LDKCommitmentSigned ret_var = CommitmentSigned_new(channel_id_arg_ref, signature_arg_ref, htlc_signatures_arg_constr);
21140         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21141         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21142         uint64_t ret_ref = (uint64_t)ret_var.inner;
21143         if (ret_var.is_owned) {
21144                 ret_ref |= 1;
21145         }
21146         return ret_ref;
21147 }
21148
21149 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21150         LDKCommitmentSigned orig_conv;
21151         orig_conv.inner = (void*)(orig & (~1));
21152         orig_conv.is_owned = false;
21153         LDKCommitmentSigned ret_var = CommitmentSigned_clone(&orig_conv);
21154         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21155         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21156         uint64_t ret_ref = (uint64_t)ret_var.inner;
21157         if (ret_var.is_owned) {
21158                 ret_ref |= 1;
21159         }
21160         return ret_ref;
21161 }
21162
21163 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
21164         LDKRevokeAndACK this_obj_conv;
21165         this_obj_conv.inner = (void*)(this_obj & (~1));
21166         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21167         RevokeAndACK_free(this_obj_conv);
21168 }
21169
21170 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
21171         LDKRevokeAndACK this_ptr_conv;
21172         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21173         this_ptr_conv.is_owned = false;
21174         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
21175         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *RevokeAndACK_get_channel_id(&this_ptr_conv));
21176         return ret_arr;
21177 }
21178
21179 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21180         LDKRevokeAndACK this_ptr_conv;
21181         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21182         this_ptr_conv.is_owned = false;
21183         LDKThirtyTwoBytes val_ref;
21184         CHECK((*env)->GetArrayLength(env, val) == 32);
21185         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
21186         RevokeAndACK_set_channel_id(&this_ptr_conv, val_ref);
21187 }
21188
21189 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr) {
21190         LDKRevokeAndACK this_ptr_conv;
21191         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21192         this_ptr_conv.is_owned = false;
21193         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
21194         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *RevokeAndACK_get_per_commitment_secret(&this_ptr_conv));
21195         return ret_arr;
21196 }
21197
21198 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1set_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21199         LDKRevokeAndACK this_ptr_conv;
21200         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21201         this_ptr_conv.is_owned = false;
21202         LDKThirtyTwoBytes val_ref;
21203         CHECK((*env)->GetArrayLength(env, val) == 32);
21204         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
21205         RevokeAndACK_set_per_commitment_secret(&this_ptr_conv, val_ref);
21206 }
21207
21208 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1next_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
21209         LDKRevokeAndACK this_ptr_conv;
21210         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21211         this_ptr_conv.is_owned = false;
21212         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
21213         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RevokeAndACK_get_next_per_commitment_point(&this_ptr_conv).compressed_form);
21214         return ret_arr;
21215 }
21216
21217 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) {
21218         LDKRevokeAndACK this_ptr_conv;
21219         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21220         this_ptr_conv.is_owned = false;
21221         LDKPublicKey val_ref;
21222         CHECK((*env)->GetArrayLength(env, val) == 33);
21223         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
21224         RevokeAndACK_set_next_per_commitment_point(&this_ptr_conv, val_ref);
21225 }
21226
21227 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) {
21228         LDKThirtyTwoBytes channel_id_arg_ref;
21229         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
21230         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
21231         LDKThirtyTwoBytes per_commitment_secret_arg_ref;
21232         CHECK((*env)->GetArrayLength(env, per_commitment_secret_arg) == 32);
21233         (*env)->GetByteArrayRegion(env, per_commitment_secret_arg, 0, 32, per_commitment_secret_arg_ref.data);
21234         LDKPublicKey next_per_commitment_point_arg_ref;
21235         CHECK((*env)->GetArrayLength(env, next_per_commitment_point_arg) == 33);
21236         (*env)->GetByteArrayRegion(env, next_per_commitment_point_arg, 0, 33, next_per_commitment_point_arg_ref.compressed_form);
21237         LDKRevokeAndACK ret_var = RevokeAndACK_new(channel_id_arg_ref, per_commitment_secret_arg_ref, next_per_commitment_point_arg_ref);
21238         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21239         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21240         uint64_t ret_ref = (uint64_t)ret_var.inner;
21241         if (ret_var.is_owned) {
21242                 ret_ref |= 1;
21243         }
21244         return ret_ref;
21245 }
21246
21247 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21248         LDKRevokeAndACK orig_conv;
21249         orig_conv.inner = (void*)(orig & (~1));
21250         orig_conv.is_owned = false;
21251         LDKRevokeAndACK ret_var = RevokeAndACK_clone(&orig_conv);
21252         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21253         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21254         uint64_t ret_ref = (uint64_t)ret_var.inner;
21255         if (ret_var.is_owned) {
21256                 ret_ref |= 1;
21257         }
21258         return ret_ref;
21259 }
21260
21261 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
21262         LDKUpdateFee this_obj_conv;
21263         this_obj_conv.inner = (void*)(this_obj & (~1));
21264         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21265         UpdateFee_free(this_obj_conv);
21266 }
21267
21268 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFee_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
21269         LDKUpdateFee this_ptr_conv;
21270         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21271         this_ptr_conv.is_owned = false;
21272         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
21273         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFee_get_channel_id(&this_ptr_conv));
21274         return ret_arr;
21275 }
21276
21277 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21278         LDKUpdateFee this_ptr_conv;
21279         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21280         this_ptr_conv.is_owned = false;
21281         LDKThirtyTwoBytes val_ref;
21282         CHECK((*env)->GetArrayLength(env, val) == 32);
21283         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
21284         UpdateFee_set_channel_id(&this_ptr_conv, val_ref);
21285 }
21286
21287 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1get_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr) {
21288         LDKUpdateFee this_ptr_conv;
21289         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21290         this_ptr_conv.is_owned = false;
21291         int32_t ret_val = UpdateFee_get_feerate_per_kw(&this_ptr_conv);
21292         return ret_val;
21293 }
21294
21295 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1set_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
21296         LDKUpdateFee this_ptr_conv;
21297         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21298         this_ptr_conv.is_owned = false;
21299         UpdateFee_set_feerate_per_kw(&this_ptr_conv, val);
21300 }
21301
21302 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) {
21303         LDKThirtyTwoBytes channel_id_arg_ref;
21304         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
21305         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
21306         LDKUpdateFee ret_var = UpdateFee_new(channel_id_arg_ref, feerate_per_kw_arg);
21307         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21308         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21309         uint64_t ret_ref = (uint64_t)ret_var.inner;
21310         if (ret_var.is_owned) {
21311                 ret_ref |= 1;
21312         }
21313         return ret_ref;
21314 }
21315
21316 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21317         LDKUpdateFee orig_conv;
21318         orig_conv.inner = (void*)(orig & (~1));
21319         orig_conv.is_owned = false;
21320         LDKUpdateFee ret_var = UpdateFee_clone(&orig_conv);
21321         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21322         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21323         uint64_t ret_ref = (uint64_t)ret_var.inner;
21324         if (ret_var.is_owned) {
21325                 ret_ref |= 1;
21326         }
21327         return ret_ref;
21328 }
21329
21330 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
21331         LDKDataLossProtect this_obj_conv;
21332         this_obj_conv.inner = (void*)(this_obj & (~1));
21333         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21334         DataLossProtect_free(this_obj_conv);
21335 }
21336
21337 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1get_1your_1last_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr) {
21338         LDKDataLossProtect this_ptr_conv;
21339         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21340         this_ptr_conv.is_owned = false;
21341         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
21342         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *DataLossProtect_get_your_last_per_commitment_secret(&this_ptr_conv));
21343         return ret_arr;
21344 }
21345
21346 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) {
21347         LDKDataLossProtect this_ptr_conv;
21348         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21349         this_ptr_conv.is_owned = false;
21350         LDKThirtyTwoBytes val_ref;
21351         CHECK((*env)->GetArrayLength(env, val) == 32);
21352         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
21353         DataLossProtect_set_your_last_per_commitment_secret(&this_ptr_conv, val_ref);
21354 }
21355
21356 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1get_1my_1current_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
21357         LDKDataLossProtect this_ptr_conv;
21358         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21359         this_ptr_conv.is_owned = false;
21360         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
21361         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DataLossProtect_get_my_current_per_commitment_point(&this_ptr_conv).compressed_form);
21362         return ret_arr;
21363 }
21364
21365 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) {
21366         LDKDataLossProtect this_ptr_conv;
21367         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21368         this_ptr_conv.is_owned = false;
21369         LDKPublicKey val_ref;
21370         CHECK((*env)->GetArrayLength(env, val) == 33);
21371         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
21372         DataLossProtect_set_my_current_per_commitment_point(&this_ptr_conv, val_ref);
21373 }
21374
21375 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) {
21376         LDKThirtyTwoBytes your_last_per_commitment_secret_arg_ref;
21377         CHECK((*env)->GetArrayLength(env, your_last_per_commitment_secret_arg) == 32);
21378         (*env)->GetByteArrayRegion(env, your_last_per_commitment_secret_arg, 0, 32, your_last_per_commitment_secret_arg_ref.data);
21379         LDKPublicKey my_current_per_commitment_point_arg_ref;
21380         CHECK((*env)->GetArrayLength(env, my_current_per_commitment_point_arg) == 33);
21381         (*env)->GetByteArrayRegion(env, my_current_per_commitment_point_arg, 0, 33, my_current_per_commitment_point_arg_ref.compressed_form);
21382         LDKDataLossProtect ret_var = DataLossProtect_new(your_last_per_commitment_secret_arg_ref, my_current_per_commitment_point_arg_ref);
21383         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21384         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21385         uint64_t ret_ref = (uint64_t)ret_var.inner;
21386         if (ret_var.is_owned) {
21387                 ret_ref |= 1;
21388         }
21389         return ret_ref;
21390 }
21391
21392 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21393         LDKDataLossProtect orig_conv;
21394         orig_conv.inner = (void*)(orig & (~1));
21395         orig_conv.is_owned = false;
21396         LDKDataLossProtect ret_var = DataLossProtect_clone(&orig_conv);
21397         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21398         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21399         uint64_t ret_ref = (uint64_t)ret_var.inner;
21400         if (ret_var.is_owned) {
21401                 ret_ref |= 1;
21402         }
21403         return ret_ref;
21404 }
21405
21406 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
21407         LDKChannelReestablish this_obj_conv;
21408         this_obj_conv.inner = (void*)(this_obj & (~1));
21409         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21410         ChannelReestablish_free(this_obj_conv);
21411 }
21412
21413 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
21414         LDKChannelReestablish this_ptr_conv;
21415         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21416         this_ptr_conv.is_owned = false;
21417         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
21418         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ChannelReestablish_get_channel_id(&this_ptr_conv));
21419         return ret_arr;
21420 }
21421
21422 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21423         LDKChannelReestablish this_ptr_conv;
21424         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21425         this_ptr_conv.is_owned = false;
21426         LDKThirtyTwoBytes val_ref;
21427         CHECK((*env)->GetArrayLength(env, val) == 32);
21428         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
21429         ChannelReestablish_set_channel_id(&this_ptr_conv, val_ref);
21430 }
21431
21432 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1next_1local_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_ptr) {
21433         LDKChannelReestablish this_ptr_conv;
21434         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21435         this_ptr_conv.is_owned = false;
21436         int64_t ret_val = ChannelReestablish_get_next_local_commitment_number(&this_ptr_conv);
21437         return ret_val;
21438 }
21439
21440 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) {
21441         LDKChannelReestablish this_ptr_conv;
21442         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21443         this_ptr_conv.is_owned = false;
21444         ChannelReestablish_set_next_local_commitment_number(&this_ptr_conv, val);
21445 }
21446
21447 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1next_1remote_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_ptr) {
21448         LDKChannelReestablish this_ptr_conv;
21449         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21450         this_ptr_conv.is_owned = false;
21451         int64_t ret_val = ChannelReestablish_get_next_remote_commitment_number(&this_ptr_conv);
21452         return ret_val;
21453 }
21454
21455 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) {
21456         LDKChannelReestablish this_ptr_conv;
21457         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21458         this_ptr_conv.is_owned = false;
21459         ChannelReestablish_set_next_remote_commitment_number(&this_ptr_conv, val);
21460 }
21461
21462 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21463         LDKChannelReestablish orig_conv;
21464         orig_conv.inner = (void*)(orig & (~1));
21465         orig_conv.is_owned = false;
21466         LDKChannelReestablish ret_var = ChannelReestablish_clone(&orig_conv);
21467         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21468         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21469         uint64_t ret_ref = (uint64_t)ret_var.inner;
21470         if (ret_var.is_owned) {
21471                 ret_ref |= 1;
21472         }
21473         return ret_ref;
21474 }
21475
21476 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
21477         LDKAnnouncementSignatures this_obj_conv;
21478         this_obj_conv.inner = (void*)(this_obj & (~1));
21479         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21480         AnnouncementSignatures_free(this_obj_conv);
21481 }
21482
21483 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
21484         LDKAnnouncementSignatures this_ptr_conv;
21485         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21486         this_ptr_conv.is_owned = false;
21487         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
21488         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *AnnouncementSignatures_get_channel_id(&this_ptr_conv));
21489         return ret_arr;
21490 }
21491
21492 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21493         LDKAnnouncementSignatures this_ptr_conv;
21494         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21495         this_ptr_conv.is_owned = false;
21496         LDKThirtyTwoBytes val_ref;
21497         CHECK((*env)->GetArrayLength(env, val) == 32);
21498         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
21499         AnnouncementSignatures_set_channel_id(&this_ptr_conv, val_ref);
21500 }
21501
21502 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
21503         LDKAnnouncementSignatures this_ptr_conv;
21504         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21505         this_ptr_conv.is_owned = false;
21506         int64_t ret_val = AnnouncementSignatures_get_short_channel_id(&this_ptr_conv);
21507         return ret_val;
21508 }
21509
21510 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
21511         LDKAnnouncementSignatures this_ptr_conv;
21512         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21513         this_ptr_conv.is_owned = false;
21514         AnnouncementSignatures_set_short_channel_id(&this_ptr_conv, val);
21515 }
21516
21517 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1node_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
21518         LDKAnnouncementSignatures this_ptr_conv;
21519         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21520         this_ptr_conv.is_owned = false;
21521         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
21522         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, AnnouncementSignatures_get_node_signature(&this_ptr_conv).compact_form);
21523         return ret_arr;
21524 }
21525
21526 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1node_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21527         LDKAnnouncementSignatures this_ptr_conv;
21528         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21529         this_ptr_conv.is_owned = false;
21530         LDKSignature val_ref;
21531         CHECK((*env)->GetArrayLength(env, val) == 64);
21532         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
21533         AnnouncementSignatures_set_node_signature(&this_ptr_conv, val_ref);
21534 }
21535
21536 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1bitcoin_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
21537         LDKAnnouncementSignatures this_ptr_conv;
21538         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21539         this_ptr_conv.is_owned = false;
21540         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
21541         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, AnnouncementSignatures_get_bitcoin_signature(&this_ptr_conv).compact_form);
21542         return ret_arr;
21543 }
21544
21545 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1bitcoin_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21546         LDKAnnouncementSignatures this_ptr_conv;
21547         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21548         this_ptr_conv.is_owned = false;
21549         LDKSignature val_ref;
21550         CHECK((*env)->GetArrayLength(env, val) == 64);
21551         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
21552         AnnouncementSignatures_set_bitcoin_signature(&this_ptr_conv, val_ref);
21553 }
21554
21555 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) {
21556         LDKThirtyTwoBytes channel_id_arg_ref;
21557         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
21558         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
21559         LDKSignature node_signature_arg_ref;
21560         CHECK((*env)->GetArrayLength(env, node_signature_arg) == 64);
21561         (*env)->GetByteArrayRegion(env, node_signature_arg, 0, 64, node_signature_arg_ref.compact_form);
21562         LDKSignature bitcoin_signature_arg_ref;
21563         CHECK((*env)->GetArrayLength(env, bitcoin_signature_arg) == 64);
21564         (*env)->GetByteArrayRegion(env, bitcoin_signature_arg, 0, 64, bitcoin_signature_arg_ref.compact_form);
21565         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_new(channel_id_arg_ref, short_channel_id_arg, node_signature_arg_ref, bitcoin_signature_arg_ref);
21566         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21567         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21568         uint64_t ret_ref = (uint64_t)ret_var.inner;
21569         if (ret_var.is_owned) {
21570                 ret_ref |= 1;
21571         }
21572         return ret_ref;
21573 }
21574
21575 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21576         LDKAnnouncementSignatures orig_conv;
21577         orig_conv.inner = (void*)(orig & (~1));
21578         orig_conv.is_owned = false;
21579         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(&orig_conv);
21580         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21581         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21582         uint64_t ret_ref = (uint64_t)ret_var.inner;
21583         if (ret_var.is_owned) {
21584                 ret_ref |= 1;
21585         }
21586         return ret_ref;
21587 }
21588
21589 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetAddress_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
21590         if ((this_ptr & 1) != 0) return;
21591         LDKNetAddress this_ptr_conv = *(LDKNetAddress*)(((uint64_t)this_ptr) & ~1);
21592         FREE((void*)this_ptr);
21593         NetAddress_free(this_ptr_conv);
21594 }
21595
21596 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21597         LDKNetAddress* orig_conv = (LDKNetAddress*)orig;
21598         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
21599         *ret_copy = NetAddress_clone(orig_conv);
21600         uint64_t ret_ref = (uint64_t)ret_copy;
21601         return ret_ref;
21602 }
21603
21604 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1ipv4(JNIEnv *env, jclass clz, int8_tArray addr, int16_t port) {
21605         LDKFourBytes addr_ref;
21606         CHECK((*env)->GetArrayLength(env, addr) == 4);
21607         (*env)->GetByteArrayRegion(env, addr, 0, 4, addr_ref.data);
21608         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
21609         *ret_copy = NetAddress_ipv4(addr_ref, port);
21610         uint64_t ret_ref = (uint64_t)ret_copy;
21611         return ret_ref;
21612 }
21613
21614 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1ipv6(JNIEnv *env, jclass clz, int8_tArray addr, int16_t port) {
21615         LDKSixteenBytes addr_ref;
21616         CHECK((*env)->GetArrayLength(env, addr) == 16);
21617         (*env)->GetByteArrayRegion(env, addr, 0, 16, addr_ref.data);
21618         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
21619         *ret_copy = NetAddress_ipv6(addr_ref, port);
21620         uint64_t ret_ref = (uint64_t)ret_copy;
21621         return ret_ref;
21622 }
21623
21624 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1onion_1v2(JNIEnv *env, jclass clz, int8_tArray addr, int16_t port) {
21625         LDKTenBytes addr_ref;
21626         CHECK((*env)->GetArrayLength(env, addr) == 10);
21627         (*env)->GetByteArrayRegion(env, addr, 0, 10, addr_ref.data);
21628         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
21629         *ret_copy = NetAddress_onion_v2(addr_ref, port);
21630         uint64_t ret_ref = (uint64_t)ret_copy;
21631         return ret_ref;
21632 }
21633
21634 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1onion_1v3(JNIEnv *env, jclass clz, int8_tArray ed25519_pubkey, int16_t checksum, int8_t version, int16_t port) {
21635         LDKThirtyTwoBytes ed25519_pubkey_ref;
21636         CHECK((*env)->GetArrayLength(env, ed25519_pubkey) == 32);
21637         (*env)->GetByteArrayRegion(env, ed25519_pubkey, 0, 32, ed25519_pubkey_ref.data);
21638         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
21639         *ret_copy = NetAddress_onion_v3(ed25519_pubkey_ref, checksum, version, port);
21640         uint64_t ret_ref = (uint64_t)ret_copy;
21641         return ret_ref;
21642 }
21643
21644 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetAddress_1write(JNIEnv *env, jclass clz, int64_t obj) {
21645         LDKNetAddress* obj_conv = (LDKNetAddress*)obj;
21646         LDKCVec_u8Z ret_var = NetAddress_write(obj_conv);
21647         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21648         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21649         CVec_u8Z_free(ret_var);
21650         return ret_arr;
21651 }
21652
21653 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Result_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21654         LDKu8slice ser_ref;
21655         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21656         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21657         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
21658         *ret_conv = Result_read(ser_ref);
21659         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21660         return (uint64_t)ret_conv;
21661 }
21662
21663 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21664         LDKu8slice ser_ref;
21665         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21666         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21667         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
21668         *ret_conv = NetAddress_read(ser_ref);
21669         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21670         return (uint64_t)ret_conv;
21671 }
21672
21673 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
21674         LDKUnsignedNodeAnnouncement this_obj_conv;
21675         this_obj_conv.inner = (void*)(this_obj & (~1));
21676         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21677         UnsignedNodeAnnouncement_free(this_obj_conv);
21678 }
21679
21680 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
21681         LDKUnsignedNodeAnnouncement this_ptr_conv;
21682         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21683         this_ptr_conv.is_owned = false;
21684         LDKNodeFeatures ret_var = UnsignedNodeAnnouncement_get_features(&this_ptr_conv);
21685         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21686         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21687         uint64_t ret_ref = (uint64_t)ret_var.inner;
21688         if (ret_var.is_owned) {
21689                 ret_ref |= 1;
21690         }
21691         return ret_ref;
21692 }
21693
21694 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
21695         LDKUnsignedNodeAnnouncement this_ptr_conv;
21696         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21697         this_ptr_conv.is_owned = false;
21698         LDKNodeFeatures val_conv;
21699         val_conv.inner = (void*)(val & (~1));
21700         val_conv.is_owned = (val & 1) || (val == 0);
21701         val_conv = NodeFeatures_clone(&val_conv);
21702         UnsignedNodeAnnouncement_set_features(&this_ptr_conv, val_conv);
21703 }
21704
21705 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
21706         LDKUnsignedNodeAnnouncement this_ptr_conv;
21707         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21708         this_ptr_conv.is_owned = false;
21709         int32_t ret_val = UnsignedNodeAnnouncement_get_timestamp(&this_ptr_conv);
21710         return ret_val;
21711 }
21712
21713 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
21714         LDKUnsignedNodeAnnouncement this_ptr_conv;
21715         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21716         this_ptr_conv.is_owned = false;
21717         UnsignedNodeAnnouncement_set_timestamp(&this_ptr_conv, val);
21718 }
21719
21720 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
21721         LDKUnsignedNodeAnnouncement this_ptr_conv;
21722         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21723         this_ptr_conv.is_owned = false;
21724         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
21725         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedNodeAnnouncement_get_node_id(&this_ptr_conv).compressed_form);
21726         return ret_arr;
21727 }
21728
21729 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21730         LDKUnsignedNodeAnnouncement this_ptr_conv;
21731         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21732         this_ptr_conv.is_owned = false;
21733         LDKPublicKey val_ref;
21734         CHECK((*env)->GetArrayLength(env, val) == 33);
21735         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
21736         UnsignedNodeAnnouncement_set_node_id(&this_ptr_conv, val_ref);
21737 }
21738
21739 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr) {
21740         LDKUnsignedNodeAnnouncement this_ptr_conv;
21741         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21742         this_ptr_conv.is_owned = false;
21743         int8_tArray ret_arr = (*env)->NewByteArray(env, 3);
21744         (*env)->SetByteArrayRegion(env, ret_arr, 0, 3, *UnsignedNodeAnnouncement_get_rgb(&this_ptr_conv));
21745         return ret_arr;
21746 }
21747
21748 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21749         LDKUnsignedNodeAnnouncement this_ptr_conv;
21750         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21751         this_ptr_conv.is_owned = false;
21752         LDKThreeBytes val_ref;
21753         CHECK((*env)->GetArrayLength(env, val) == 3);
21754         (*env)->GetByteArrayRegion(env, val, 0, 3, val_ref.data);
21755         UnsignedNodeAnnouncement_set_rgb(&this_ptr_conv, val_ref);
21756 }
21757
21758 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
21759         LDKUnsignedNodeAnnouncement this_ptr_conv;
21760         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21761         this_ptr_conv.is_owned = false;
21762         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
21763         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedNodeAnnouncement_get_alias(&this_ptr_conv));
21764         return ret_arr;
21765 }
21766
21767 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21768         LDKUnsignedNodeAnnouncement this_ptr_conv;
21769         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21770         this_ptr_conv.is_owned = false;
21771         LDKThirtyTwoBytes val_ref;
21772         CHECK((*env)->GetArrayLength(env, val) == 32);
21773         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
21774         UnsignedNodeAnnouncement_set_alias(&this_ptr_conv, val_ref);
21775 }
21776
21777 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1addresses(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
21778         LDKUnsignedNodeAnnouncement this_ptr_conv;
21779         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21780         this_ptr_conv.is_owned = false;
21781         LDKCVec_NetAddressZ val_constr;
21782         val_constr.datalen = (*env)->GetArrayLength(env, val);
21783         if (val_constr.datalen > 0)
21784                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
21785         else
21786                 val_constr.data = NULL;
21787         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
21788         for (size_t m = 0; m < val_constr.datalen; m++) {
21789                 int64_t val_conv_12 = val_vals[m];
21790                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(((uint64_t)val_conv_12) & ~1);
21791                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)val_conv_12) & ~1));
21792                 val_constr.data[m] = val_conv_12_conv;
21793         }
21794         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
21795         UnsignedNodeAnnouncement_set_addresses(&this_ptr_conv, val_constr);
21796 }
21797
21798 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21799         LDKUnsignedNodeAnnouncement orig_conv;
21800         orig_conv.inner = (void*)(orig & (~1));
21801         orig_conv.is_owned = false;
21802         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(&orig_conv);
21803         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21804         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21805         uint64_t ret_ref = (uint64_t)ret_var.inner;
21806         if (ret_var.is_owned) {
21807                 ret_ref |= 1;
21808         }
21809         return ret_ref;
21810 }
21811
21812 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
21813         LDKNodeAnnouncement this_obj_conv;
21814         this_obj_conv.inner = (void*)(this_obj & (~1));
21815         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21816         NodeAnnouncement_free(this_obj_conv);
21817 }
21818
21819 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
21820         LDKNodeAnnouncement this_ptr_conv;
21821         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21822         this_ptr_conv.is_owned = false;
21823         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
21824         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, NodeAnnouncement_get_signature(&this_ptr_conv).compact_form);
21825         return ret_arr;
21826 }
21827
21828 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21829         LDKNodeAnnouncement this_ptr_conv;
21830         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21831         this_ptr_conv.is_owned = false;
21832         LDKSignature val_ref;
21833         CHECK((*env)->GetArrayLength(env, val) == 64);
21834         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
21835         NodeAnnouncement_set_signature(&this_ptr_conv, val_ref);
21836 }
21837
21838 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
21839         LDKNodeAnnouncement this_ptr_conv;
21840         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21841         this_ptr_conv.is_owned = false;
21842         LDKUnsignedNodeAnnouncement ret_var = NodeAnnouncement_get_contents(&this_ptr_conv);
21843         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21844         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21845         uint64_t ret_ref = (uint64_t)ret_var.inner;
21846         if (ret_var.is_owned) {
21847                 ret_ref |= 1;
21848         }
21849         return ret_ref;
21850 }
21851
21852 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
21853         LDKNodeAnnouncement this_ptr_conv;
21854         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21855         this_ptr_conv.is_owned = false;
21856         LDKUnsignedNodeAnnouncement val_conv;
21857         val_conv.inner = (void*)(val & (~1));
21858         val_conv.is_owned = (val & 1) || (val == 0);
21859         val_conv = UnsignedNodeAnnouncement_clone(&val_conv);
21860         NodeAnnouncement_set_contents(&this_ptr_conv, val_conv);
21861 }
21862
21863 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1new(JNIEnv *env, jclass clz, int8_tArray signature_arg, int64_t contents_arg) {
21864         LDKSignature signature_arg_ref;
21865         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
21866         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
21867         LDKUnsignedNodeAnnouncement contents_arg_conv;
21868         contents_arg_conv.inner = (void*)(contents_arg & (~1));
21869         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
21870         contents_arg_conv = UnsignedNodeAnnouncement_clone(&contents_arg_conv);
21871         LDKNodeAnnouncement ret_var = NodeAnnouncement_new(signature_arg_ref, contents_arg_conv);
21872         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21873         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21874         uint64_t ret_ref = (uint64_t)ret_var.inner;
21875         if (ret_var.is_owned) {
21876                 ret_ref |= 1;
21877         }
21878         return ret_ref;
21879 }
21880
21881 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21882         LDKNodeAnnouncement orig_conv;
21883         orig_conv.inner = (void*)(orig & (~1));
21884         orig_conv.is_owned = false;
21885         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(&orig_conv);
21886         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21887         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21888         uint64_t ret_ref = (uint64_t)ret_var.inner;
21889         if (ret_var.is_owned) {
21890                 ret_ref |= 1;
21891         }
21892         return ret_ref;
21893 }
21894
21895 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
21896         LDKUnsignedChannelAnnouncement this_obj_conv;
21897         this_obj_conv.inner = (void*)(this_obj & (~1));
21898         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21899         UnsignedChannelAnnouncement_free(this_obj_conv);
21900 }
21901
21902 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
21903         LDKUnsignedChannelAnnouncement this_ptr_conv;
21904         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21905         this_ptr_conv.is_owned = false;
21906         LDKChannelFeatures ret_var = UnsignedChannelAnnouncement_get_features(&this_ptr_conv);
21907         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21908         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21909         uint64_t ret_ref = (uint64_t)ret_var.inner;
21910         if (ret_var.is_owned) {
21911                 ret_ref |= 1;
21912         }
21913         return ret_ref;
21914 }
21915
21916 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
21917         LDKUnsignedChannelAnnouncement this_ptr_conv;
21918         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21919         this_ptr_conv.is_owned = false;
21920         LDKChannelFeatures val_conv;
21921         val_conv.inner = (void*)(val & (~1));
21922         val_conv.is_owned = (val & 1) || (val == 0);
21923         val_conv = ChannelFeatures_clone(&val_conv);
21924         UnsignedChannelAnnouncement_set_features(&this_ptr_conv, val_conv);
21925 }
21926
21927 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
21928         LDKUnsignedChannelAnnouncement this_ptr_conv;
21929         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21930         this_ptr_conv.is_owned = false;
21931         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
21932         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedChannelAnnouncement_get_chain_hash(&this_ptr_conv));
21933         return ret_arr;
21934 }
21935
21936 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21937         LDKUnsignedChannelAnnouncement this_ptr_conv;
21938         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21939         this_ptr_conv.is_owned = false;
21940         LDKThirtyTwoBytes val_ref;
21941         CHECK((*env)->GetArrayLength(env, val) == 32);
21942         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
21943         UnsignedChannelAnnouncement_set_chain_hash(&this_ptr_conv, val_ref);
21944 }
21945
21946 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
21947         LDKUnsignedChannelAnnouncement this_ptr_conv;
21948         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21949         this_ptr_conv.is_owned = false;
21950         int64_t ret_val = UnsignedChannelAnnouncement_get_short_channel_id(&this_ptr_conv);
21951         return ret_val;
21952 }
21953
21954 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
21955         LDKUnsignedChannelAnnouncement this_ptr_conv;
21956         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21957         this_ptr_conv.is_owned = false;
21958         UnsignedChannelAnnouncement_set_short_channel_id(&this_ptr_conv, val);
21959 }
21960
21961 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1node_1id_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
21962         LDKUnsignedChannelAnnouncement this_ptr_conv;
21963         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21964         this_ptr_conv.is_owned = false;
21965         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
21966         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_node_id_1(&this_ptr_conv).compressed_form);
21967         return ret_arr;
21968 }
21969
21970 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1node_1id_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21971         LDKUnsignedChannelAnnouncement this_ptr_conv;
21972         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21973         this_ptr_conv.is_owned = false;
21974         LDKPublicKey val_ref;
21975         CHECK((*env)->GetArrayLength(env, val) == 33);
21976         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
21977         UnsignedChannelAnnouncement_set_node_id_1(&this_ptr_conv, val_ref);
21978 }
21979
21980 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1node_1id_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
21981         LDKUnsignedChannelAnnouncement this_ptr_conv;
21982         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21983         this_ptr_conv.is_owned = false;
21984         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
21985         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_node_id_2(&this_ptr_conv).compressed_form);
21986         return ret_arr;
21987 }
21988
21989 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1node_1id_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21990         LDKUnsignedChannelAnnouncement this_ptr_conv;
21991         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21992         this_ptr_conv.is_owned = false;
21993         LDKPublicKey val_ref;
21994         CHECK((*env)->GetArrayLength(env, val) == 33);
21995         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
21996         UnsignedChannelAnnouncement_set_node_id_2(&this_ptr_conv, val_ref);
21997 }
21998
21999 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1bitcoin_1key_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
22000         LDKUnsignedChannelAnnouncement this_ptr_conv;
22001         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22002         this_ptr_conv.is_owned = false;
22003         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
22004         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_bitcoin_key_1(&this_ptr_conv).compressed_form);
22005         return ret_arr;
22006 }
22007
22008 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1bitcoin_1key_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22009         LDKUnsignedChannelAnnouncement this_ptr_conv;
22010         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22011         this_ptr_conv.is_owned = false;
22012         LDKPublicKey val_ref;
22013         CHECK((*env)->GetArrayLength(env, val) == 33);
22014         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
22015         UnsignedChannelAnnouncement_set_bitcoin_key_1(&this_ptr_conv, val_ref);
22016 }
22017
22018 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1bitcoin_1key_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
22019         LDKUnsignedChannelAnnouncement this_ptr_conv;
22020         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22021         this_ptr_conv.is_owned = false;
22022         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
22023         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_bitcoin_key_2(&this_ptr_conv).compressed_form);
22024         return ret_arr;
22025 }
22026
22027 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1bitcoin_1key_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22028         LDKUnsignedChannelAnnouncement this_ptr_conv;
22029         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22030         this_ptr_conv.is_owned = false;
22031         LDKPublicKey val_ref;
22032         CHECK((*env)->GetArrayLength(env, val) == 33);
22033         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
22034         UnsignedChannelAnnouncement_set_bitcoin_key_2(&this_ptr_conv, val_ref);
22035 }
22036
22037 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22038         LDKUnsignedChannelAnnouncement orig_conv;
22039         orig_conv.inner = (void*)(orig & (~1));
22040         orig_conv.is_owned = false;
22041         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(&orig_conv);
22042         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22043         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22044         uint64_t ret_ref = (uint64_t)ret_var.inner;
22045         if (ret_var.is_owned) {
22046                 ret_ref |= 1;
22047         }
22048         return ret_ref;
22049 }
22050
22051 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22052         LDKChannelAnnouncement this_obj_conv;
22053         this_obj_conv.inner = (void*)(this_obj & (~1));
22054         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22055         ChannelAnnouncement_free(this_obj_conv);
22056 }
22057
22058 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1node_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
22059         LDKChannelAnnouncement this_ptr_conv;
22060         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22061         this_ptr_conv.is_owned = false;
22062         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
22063         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_node_signature_1(&this_ptr_conv).compact_form);
22064         return ret_arr;
22065 }
22066
22067 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1node_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22068         LDKChannelAnnouncement this_ptr_conv;
22069         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22070         this_ptr_conv.is_owned = false;
22071         LDKSignature val_ref;
22072         CHECK((*env)->GetArrayLength(env, val) == 64);
22073         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
22074         ChannelAnnouncement_set_node_signature_1(&this_ptr_conv, val_ref);
22075 }
22076
22077 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1node_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
22078         LDKChannelAnnouncement this_ptr_conv;
22079         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22080         this_ptr_conv.is_owned = false;
22081         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
22082         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_node_signature_2(&this_ptr_conv).compact_form);
22083         return ret_arr;
22084 }
22085
22086 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1node_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22087         LDKChannelAnnouncement this_ptr_conv;
22088         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22089         this_ptr_conv.is_owned = false;
22090         LDKSignature val_ref;
22091         CHECK((*env)->GetArrayLength(env, val) == 64);
22092         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
22093         ChannelAnnouncement_set_node_signature_2(&this_ptr_conv, val_ref);
22094 }
22095
22096 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1bitcoin_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
22097         LDKChannelAnnouncement this_ptr_conv;
22098         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22099         this_ptr_conv.is_owned = false;
22100         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
22101         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_bitcoin_signature_1(&this_ptr_conv).compact_form);
22102         return ret_arr;
22103 }
22104
22105 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1bitcoin_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22106         LDKChannelAnnouncement this_ptr_conv;
22107         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22108         this_ptr_conv.is_owned = false;
22109         LDKSignature val_ref;
22110         CHECK((*env)->GetArrayLength(env, val) == 64);
22111         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
22112         ChannelAnnouncement_set_bitcoin_signature_1(&this_ptr_conv, val_ref);
22113 }
22114
22115 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1bitcoin_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
22116         LDKChannelAnnouncement this_ptr_conv;
22117         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22118         this_ptr_conv.is_owned = false;
22119         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
22120         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_bitcoin_signature_2(&this_ptr_conv).compact_form);
22121         return ret_arr;
22122 }
22123
22124 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1bitcoin_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22125         LDKChannelAnnouncement this_ptr_conv;
22126         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22127         this_ptr_conv.is_owned = false;
22128         LDKSignature val_ref;
22129         CHECK((*env)->GetArrayLength(env, val) == 64);
22130         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
22131         ChannelAnnouncement_set_bitcoin_signature_2(&this_ptr_conv, val_ref);
22132 }
22133
22134 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
22135         LDKChannelAnnouncement this_ptr_conv;
22136         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22137         this_ptr_conv.is_owned = false;
22138         LDKUnsignedChannelAnnouncement ret_var = ChannelAnnouncement_get_contents(&this_ptr_conv);
22139         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22140         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22141         uint64_t ret_ref = (uint64_t)ret_var.inner;
22142         if (ret_var.is_owned) {
22143                 ret_ref |= 1;
22144         }
22145         return ret_ref;
22146 }
22147
22148 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
22149         LDKChannelAnnouncement this_ptr_conv;
22150         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22151         this_ptr_conv.is_owned = false;
22152         LDKUnsignedChannelAnnouncement val_conv;
22153         val_conv.inner = (void*)(val & (~1));
22154         val_conv.is_owned = (val & 1) || (val == 0);
22155         val_conv = UnsignedChannelAnnouncement_clone(&val_conv);
22156         ChannelAnnouncement_set_contents(&this_ptr_conv, val_conv);
22157 }
22158
22159 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) {
22160         LDKSignature node_signature_1_arg_ref;
22161         CHECK((*env)->GetArrayLength(env, node_signature_1_arg) == 64);
22162         (*env)->GetByteArrayRegion(env, node_signature_1_arg, 0, 64, node_signature_1_arg_ref.compact_form);
22163         LDKSignature node_signature_2_arg_ref;
22164         CHECK((*env)->GetArrayLength(env, node_signature_2_arg) == 64);
22165         (*env)->GetByteArrayRegion(env, node_signature_2_arg, 0, 64, node_signature_2_arg_ref.compact_form);
22166         LDKSignature bitcoin_signature_1_arg_ref;
22167         CHECK((*env)->GetArrayLength(env, bitcoin_signature_1_arg) == 64);
22168         (*env)->GetByteArrayRegion(env, bitcoin_signature_1_arg, 0, 64, bitcoin_signature_1_arg_ref.compact_form);
22169         LDKSignature bitcoin_signature_2_arg_ref;
22170         CHECK((*env)->GetArrayLength(env, bitcoin_signature_2_arg) == 64);
22171         (*env)->GetByteArrayRegion(env, bitcoin_signature_2_arg, 0, 64, bitcoin_signature_2_arg_ref.compact_form);
22172         LDKUnsignedChannelAnnouncement contents_arg_conv;
22173         contents_arg_conv.inner = (void*)(contents_arg & (~1));
22174         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
22175         contents_arg_conv = UnsignedChannelAnnouncement_clone(&contents_arg_conv);
22176         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);
22177         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22178         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22179         uint64_t ret_ref = (uint64_t)ret_var.inner;
22180         if (ret_var.is_owned) {
22181                 ret_ref |= 1;
22182         }
22183         return ret_ref;
22184 }
22185
22186 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22187         LDKChannelAnnouncement orig_conv;
22188         orig_conv.inner = (void*)(orig & (~1));
22189         orig_conv.is_owned = false;
22190         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(&orig_conv);
22191         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22192         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22193         uint64_t ret_ref = (uint64_t)ret_var.inner;
22194         if (ret_var.is_owned) {
22195                 ret_ref |= 1;
22196         }
22197         return ret_ref;
22198 }
22199
22200 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22201         LDKUnsignedChannelUpdate this_obj_conv;
22202         this_obj_conv.inner = (void*)(this_obj & (~1));
22203         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22204         UnsignedChannelUpdate_free(this_obj_conv);
22205 }
22206
22207 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
22208         LDKUnsignedChannelUpdate this_ptr_conv;
22209         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22210         this_ptr_conv.is_owned = false;
22211         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
22212         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedChannelUpdate_get_chain_hash(&this_ptr_conv));
22213         return ret_arr;
22214 }
22215
22216 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22217         LDKUnsignedChannelUpdate this_ptr_conv;
22218         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22219         this_ptr_conv.is_owned = false;
22220         LDKThirtyTwoBytes val_ref;
22221         CHECK((*env)->GetArrayLength(env, val) == 32);
22222         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
22223         UnsignedChannelUpdate_set_chain_hash(&this_ptr_conv, val_ref);
22224 }
22225
22226 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
22227         LDKUnsignedChannelUpdate this_ptr_conv;
22228         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22229         this_ptr_conv.is_owned = false;
22230         int64_t ret_val = UnsignedChannelUpdate_get_short_channel_id(&this_ptr_conv);
22231         return ret_val;
22232 }
22233
22234 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
22235         LDKUnsignedChannelUpdate this_ptr_conv;
22236         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22237         this_ptr_conv.is_owned = false;
22238         UnsignedChannelUpdate_set_short_channel_id(&this_ptr_conv, val);
22239 }
22240
22241 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
22242         LDKUnsignedChannelUpdate this_ptr_conv;
22243         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22244         this_ptr_conv.is_owned = false;
22245         int32_t ret_val = UnsignedChannelUpdate_get_timestamp(&this_ptr_conv);
22246         return ret_val;
22247 }
22248
22249 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
22250         LDKUnsignedChannelUpdate this_ptr_conv;
22251         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22252         this_ptr_conv.is_owned = false;
22253         UnsignedChannelUpdate_set_timestamp(&this_ptr_conv, val);
22254 }
22255
22256 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1flags(JNIEnv *env, jclass clz, int64_t this_ptr) {
22257         LDKUnsignedChannelUpdate this_ptr_conv;
22258         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22259         this_ptr_conv.is_owned = false;
22260         int8_t ret_val = UnsignedChannelUpdate_get_flags(&this_ptr_conv);
22261         return ret_val;
22262 }
22263
22264 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1flags(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
22265         LDKUnsignedChannelUpdate this_ptr_conv;
22266         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22267         this_ptr_conv.is_owned = false;
22268         UnsignedChannelUpdate_set_flags(&this_ptr_conv, val);
22269 }
22270
22271 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
22272         LDKUnsignedChannelUpdate this_ptr_conv;
22273         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22274         this_ptr_conv.is_owned = false;
22275         int16_t ret_val = UnsignedChannelUpdate_get_cltv_expiry_delta(&this_ptr_conv);
22276         return ret_val;
22277 }
22278
22279 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
22280         LDKUnsignedChannelUpdate this_ptr_conv;
22281         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22282         this_ptr_conv.is_owned = false;
22283         UnsignedChannelUpdate_set_cltv_expiry_delta(&this_ptr_conv, val);
22284 }
22285
22286 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
22287         LDKUnsignedChannelUpdate this_ptr_conv;
22288         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22289         this_ptr_conv.is_owned = false;
22290         int64_t ret_val = UnsignedChannelUpdate_get_htlc_minimum_msat(&this_ptr_conv);
22291         return ret_val;
22292 }
22293
22294 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
22295         LDKUnsignedChannelUpdate this_ptr_conv;
22296         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22297         this_ptr_conv.is_owned = false;
22298         UnsignedChannelUpdate_set_htlc_minimum_msat(&this_ptr_conv, val);
22299 }
22300
22301 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
22302         LDKUnsignedChannelUpdate this_ptr_conv;
22303         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22304         this_ptr_conv.is_owned = false;
22305         int32_t ret_val = UnsignedChannelUpdate_get_fee_base_msat(&this_ptr_conv);
22306         return ret_val;
22307 }
22308
22309 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
22310         LDKUnsignedChannelUpdate this_ptr_conv;
22311         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22312         this_ptr_conv.is_owned = false;
22313         UnsignedChannelUpdate_set_fee_base_msat(&this_ptr_conv, val);
22314 }
22315
22316 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
22317         LDKUnsignedChannelUpdate this_ptr_conv;
22318         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22319         this_ptr_conv.is_owned = false;
22320         int32_t ret_val = UnsignedChannelUpdate_get_fee_proportional_millionths(&this_ptr_conv);
22321         return ret_val;
22322 }
22323
22324 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
22325         LDKUnsignedChannelUpdate this_ptr_conv;
22326         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22327         this_ptr_conv.is_owned = false;
22328         UnsignedChannelUpdate_set_fee_proportional_millionths(&this_ptr_conv, val);
22329 }
22330
22331 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22332         LDKUnsignedChannelUpdate orig_conv;
22333         orig_conv.inner = (void*)(orig & (~1));
22334         orig_conv.is_owned = false;
22335         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(&orig_conv);
22336         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22337         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22338         uint64_t ret_ref = (uint64_t)ret_var.inner;
22339         if (ret_var.is_owned) {
22340                 ret_ref |= 1;
22341         }
22342         return ret_ref;
22343 }
22344
22345 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22346         LDKChannelUpdate this_obj_conv;
22347         this_obj_conv.inner = (void*)(this_obj & (~1));
22348         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22349         ChannelUpdate_free(this_obj_conv);
22350 }
22351
22352 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
22353         LDKChannelUpdate this_ptr_conv;
22354         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22355         this_ptr_conv.is_owned = false;
22356         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
22357         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelUpdate_get_signature(&this_ptr_conv).compact_form);
22358         return ret_arr;
22359 }
22360
22361 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22362         LDKChannelUpdate this_ptr_conv;
22363         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22364         this_ptr_conv.is_owned = false;
22365         LDKSignature val_ref;
22366         CHECK((*env)->GetArrayLength(env, val) == 64);
22367         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
22368         ChannelUpdate_set_signature(&this_ptr_conv, val_ref);
22369 }
22370
22371 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
22372         LDKChannelUpdate this_ptr_conv;
22373         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22374         this_ptr_conv.is_owned = false;
22375         LDKUnsignedChannelUpdate ret_var = ChannelUpdate_get_contents(&this_ptr_conv);
22376         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22377         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22378         uint64_t ret_ref = (uint64_t)ret_var.inner;
22379         if (ret_var.is_owned) {
22380                 ret_ref |= 1;
22381         }
22382         return ret_ref;
22383 }
22384
22385 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
22386         LDKChannelUpdate this_ptr_conv;
22387         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22388         this_ptr_conv.is_owned = false;
22389         LDKUnsignedChannelUpdate val_conv;
22390         val_conv.inner = (void*)(val & (~1));
22391         val_conv.is_owned = (val & 1) || (val == 0);
22392         val_conv = UnsignedChannelUpdate_clone(&val_conv);
22393         ChannelUpdate_set_contents(&this_ptr_conv, val_conv);
22394 }
22395
22396 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1new(JNIEnv *env, jclass clz, int8_tArray signature_arg, int64_t contents_arg) {
22397         LDKSignature signature_arg_ref;
22398         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
22399         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
22400         LDKUnsignedChannelUpdate contents_arg_conv;
22401         contents_arg_conv.inner = (void*)(contents_arg & (~1));
22402         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
22403         contents_arg_conv = UnsignedChannelUpdate_clone(&contents_arg_conv);
22404         LDKChannelUpdate ret_var = ChannelUpdate_new(signature_arg_ref, contents_arg_conv);
22405         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22406         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22407         uint64_t ret_ref = (uint64_t)ret_var.inner;
22408         if (ret_var.is_owned) {
22409                 ret_ref |= 1;
22410         }
22411         return ret_ref;
22412 }
22413
22414 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22415         LDKChannelUpdate orig_conv;
22416         orig_conv.inner = (void*)(orig & (~1));
22417         orig_conv.is_owned = false;
22418         LDKChannelUpdate ret_var = ChannelUpdate_clone(&orig_conv);
22419         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22420         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22421         uint64_t ret_ref = (uint64_t)ret_var.inner;
22422         if (ret_var.is_owned) {
22423                 ret_ref |= 1;
22424         }
22425         return ret_ref;
22426 }
22427
22428 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22429         LDKQueryChannelRange 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         QueryChannelRange_free(this_obj_conv);
22433 }
22434
22435 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
22436         LDKQueryChannelRange this_ptr_conv;
22437         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22438         this_ptr_conv.is_owned = false;
22439         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
22440         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *QueryChannelRange_get_chain_hash(&this_ptr_conv));
22441         return ret_arr;
22442 }
22443
22444 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22445         LDKQueryChannelRange this_ptr_conv;
22446         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22447         this_ptr_conv.is_owned = false;
22448         LDKThirtyTwoBytes val_ref;
22449         CHECK((*env)->GetArrayLength(env, val) == 32);
22450         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
22451         QueryChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
22452 }
22453
22454 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr) {
22455         LDKQueryChannelRange this_ptr_conv;
22456         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22457         this_ptr_conv.is_owned = false;
22458         int32_t ret_val = QueryChannelRange_get_first_blocknum(&this_ptr_conv);
22459         return ret_val;
22460 }
22461
22462 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
22463         LDKQueryChannelRange this_ptr_conv;
22464         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22465         this_ptr_conv.is_owned = false;
22466         QueryChannelRange_set_first_blocknum(&this_ptr_conv, val);
22467 }
22468
22469 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr) {
22470         LDKQueryChannelRange this_ptr_conv;
22471         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22472         this_ptr_conv.is_owned = false;
22473         int32_t ret_val = QueryChannelRange_get_number_of_blocks(&this_ptr_conv);
22474         return ret_val;
22475 }
22476
22477 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
22478         LDKQueryChannelRange this_ptr_conv;
22479         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22480         this_ptr_conv.is_owned = false;
22481         QueryChannelRange_set_number_of_blocks(&this_ptr_conv, val);
22482 }
22483
22484 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) {
22485         LDKThirtyTwoBytes chain_hash_arg_ref;
22486         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
22487         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
22488         LDKQueryChannelRange ret_var = QueryChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg);
22489         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22490         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22491         uint64_t ret_ref = (uint64_t)ret_var.inner;
22492         if (ret_var.is_owned) {
22493                 ret_ref |= 1;
22494         }
22495         return ret_ref;
22496 }
22497
22498 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22499         LDKQueryChannelRange orig_conv;
22500         orig_conv.inner = (void*)(orig & (~1));
22501         orig_conv.is_owned = false;
22502         LDKQueryChannelRange ret_var = QueryChannelRange_clone(&orig_conv);
22503         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22504         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22505         uint64_t ret_ref = (uint64_t)ret_var.inner;
22506         if (ret_var.is_owned) {
22507                 ret_ref |= 1;
22508         }
22509         return ret_ref;
22510 }
22511
22512 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22513         LDKReplyChannelRange this_obj_conv;
22514         this_obj_conv.inner = (void*)(this_obj & (~1));
22515         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22516         ReplyChannelRange_free(this_obj_conv);
22517 }
22518
22519 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
22520         LDKReplyChannelRange this_ptr_conv;
22521         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22522         this_ptr_conv.is_owned = false;
22523         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
22524         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ReplyChannelRange_get_chain_hash(&this_ptr_conv));
22525         return ret_arr;
22526 }
22527
22528 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22529         LDKReplyChannelRange this_ptr_conv;
22530         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22531         this_ptr_conv.is_owned = false;
22532         LDKThirtyTwoBytes val_ref;
22533         CHECK((*env)->GetArrayLength(env, val) == 32);
22534         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
22535         ReplyChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
22536 }
22537
22538 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr) {
22539         LDKReplyChannelRange this_ptr_conv;
22540         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22541         this_ptr_conv.is_owned = false;
22542         int32_t ret_val = ReplyChannelRange_get_first_blocknum(&this_ptr_conv);
22543         return ret_val;
22544 }
22545
22546 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
22547         LDKReplyChannelRange this_ptr_conv;
22548         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22549         this_ptr_conv.is_owned = false;
22550         ReplyChannelRange_set_first_blocknum(&this_ptr_conv, val);
22551 }
22552
22553 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr) {
22554         LDKReplyChannelRange this_ptr_conv;
22555         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22556         this_ptr_conv.is_owned = false;
22557         int32_t ret_val = ReplyChannelRange_get_number_of_blocks(&this_ptr_conv);
22558         return ret_val;
22559 }
22560
22561 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
22562         LDKReplyChannelRange this_ptr_conv;
22563         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22564         this_ptr_conv.is_owned = false;
22565         ReplyChannelRange_set_number_of_blocks(&this_ptr_conv, val);
22566 }
22567
22568 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1sync_1complete(JNIEnv *env, jclass clz, int64_t this_ptr) {
22569         LDKReplyChannelRange this_ptr_conv;
22570         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22571         this_ptr_conv.is_owned = false;
22572         jboolean ret_val = ReplyChannelRange_get_sync_complete(&this_ptr_conv);
22573         return ret_val;
22574 }
22575
22576 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1sync_1complete(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
22577         LDKReplyChannelRange this_ptr_conv;
22578         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22579         this_ptr_conv.is_owned = false;
22580         ReplyChannelRange_set_sync_complete(&this_ptr_conv, val);
22581 }
22582
22583 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
22584         LDKReplyChannelRange this_ptr_conv;
22585         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22586         this_ptr_conv.is_owned = false;
22587         LDKCVec_u64Z val_constr;
22588         val_constr.datalen = (*env)->GetArrayLength(env, val);
22589         if (val_constr.datalen > 0)
22590                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
22591         else
22592                 val_constr.data = NULL;
22593         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
22594         for (size_t g = 0; g < val_constr.datalen; g++) {
22595                 int64_t val_conv_6 = val_vals[g];
22596                 val_constr.data[g] = val_conv_6;
22597         }
22598         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
22599         ReplyChannelRange_set_short_channel_ids(&this_ptr_conv, val_constr);
22600 }
22601
22602 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) {
22603         LDKThirtyTwoBytes chain_hash_arg_ref;
22604         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
22605         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
22606         LDKCVec_u64Z short_channel_ids_arg_constr;
22607         short_channel_ids_arg_constr.datalen = (*env)->GetArrayLength(env, short_channel_ids_arg);
22608         if (short_channel_ids_arg_constr.datalen > 0)
22609                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
22610         else
22611                 short_channel_ids_arg_constr.data = NULL;
22612         int64_t* short_channel_ids_arg_vals = (*env)->GetLongArrayElements (env, short_channel_ids_arg, NULL);
22613         for (size_t g = 0; g < short_channel_ids_arg_constr.datalen; g++) {
22614                 int64_t short_channel_ids_arg_conv_6 = short_channel_ids_arg_vals[g];
22615                 short_channel_ids_arg_constr.data[g] = short_channel_ids_arg_conv_6;
22616         }
22617         (*env)->ReleaseLongArrayElements(env, short_channel_ids_arg, short_channel_ids_arg_vals, 0);
22618         LDKReplyChannelRange ret_var = ReplyChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg, sync_complete_arg, short_channel_ids_arg_constr);
22619         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22620         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22621         uint64_t ret_ref = (uint64_t)ret_var.inner;
22622         if (ret_var.is_owned) {
22623                 ret_ref |= 1;
22624         }
22625         return ret_ref;
22626 }
22627
22628 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22629         LDKReplyChannelRange orig_conv;
22630         orig_conv.inner = (void*)(orig & (~1));
22631         orig_conv.is_owned = false;
22632         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(&orig_conv);
22633         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22634         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22635         uint64_t ret_ref = (uint64_t)ret_var.inner;
22636         if (ret_var.is_owned) {
22637                 ret_ref |= 1;
22638         }
22639         return ret_ref;
22640 }
22641
22642 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22643         LDKQueryShortChannelIds this_obj_conv;
22644         this_obj_conv.inner = (void*)(this_obj & (~1));
22645         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22646         QueryShortChannelIds_free(this_obj_conv);
22647 }
22648
22649 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
22650         LDKQueryShortChannelIds this_ptr_conv;
22651         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22652         this_ptr_conv.is_owned = false;
22653         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
22654         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *QueryShortChannelIds_get_chain_hash(&this_ptr_conv));
22655         return ret_arr;
22656 }
22657
22658 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22659         LDKQueryShortChannelIds this_ptr_conv;
22660         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22661         this_ptr_conv.is_owned = false;
22662         LDKThirtyTwoBytes val_ref;
22663         CHECK((*env)->GetArrayLength(env, val) == 32);
22664         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
22665         QueryShortChannelIds_set_chain_hash(&this_ptr_conv, val_ref);
22666 }
22667
22668 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1set_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
22669         LDKQueryShortChannelIds this_ptr_conv;
22670         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22671         this_ptr_conv.is_owned = false;
22672         LDKCVec_u64Z val_constr;
22673         val_constr.datalen = (*env)->GetArrayLength(env, val);
22674         if (val_constr.datalen > 0)
22675                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
22676         else
22677                 val_constr.data = NULL;
22678         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
22679         for (size_t g = 0; g < val_constr.datalen; g++) {
22680                 int64_t val_conv_6 = val_vals[g];
22681                 val_constr.data[g] = val_conv_6;
22682         }
22683         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
22684         QueryShortChannelIds_set_short_channel_ids(&this_ptr_conv, val_constr);
22685 }
22686
22687 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) {
22688         LDKThirtyTwoBytes chain_hash_arg_ref;
22689         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
22690         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
22691         LDKCVec_u64Z short_channel_ids_arg_constr;
22692         short_channel_ids_arg_constr.datalen = (*env)->GetArrayLength(env, short_channel_ids_arg);
22693         if (short_channel_ids_arg_constr.datalen > 0)
22694                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
22695         else
22696                 short_channel_ids_arg_constr.data = NULL;
22697         int64_t* short_channel_ids_arg_vals = (*env)->GetLongArrayElements (env, short_channel_ids_arg, NULL);
22698         for (size_t g = 0; g < short_channel_ids_arg_constr.datalen; g++) {
22699                 int64_t short_channel_ids_arg_conv_6 = short_channel_ids_arg_vals[g];
22700                 short_channel_ids_arg_constr.data[g] = short_channel_ids_arg_conv_6;
22701         }
22702         (*env)->ReleaseLongArrayElements(env, short_channel_ids_arg, short_channel_ids_arg_vals, 0);
22703         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_new(chain_hash_arg_ref, short_channel_ids_arg_constr);
22704         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22705         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22706         uint64_t ret_ref = (uint64_t)ret_var.inner;
22707         if (ret_var.is_owned) {
22708                 ret_ref |= 1;
22709         }
22710         return ret_ref;
22711 }
22712
22713 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22714         LDKQueryShortChannelIds orig_conv;
22715         orig_conv.inner = (void*)(orig & (~1));
22716         orig_conv.is_owned = false;
22717         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(&orig_conv);
22718         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22719         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22720         uint64_t ret_ref = (uint64_t)ret_var.inner;
22721         if (ret_var.is_owned) {
22722                 ret_ref |= 1;
22723         }
22724         return ret_ref;
22725 }
22726
22727 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22728         LDKReplyShortChannelIdsEnd this_obj_conv;
22729         this_obj_conv.inner = (void*)(this_obj & (~1));
22730         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22731         ReplyShortChannelIdsEnd_free(this_obj_conv);
22732 }
22733
22734 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
22735         LDKReplyShortChannelIdsEnd this_ptr_conv;
22736         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22737         this_ptr_conv.is_owned = false;
22738         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
22739         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ReplyShortChannelIdsEnd_get_chain_hash(&this_ptr_conv));
22740         return ret_arr;
22741 }
22742
22743 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22744         LDKReplyShortChannelIdsEnd this_ptr_conv;
22745         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22746         this_ptr_conv.is_owned = false;
22747         LDKThirtyTwoBytes val_ref;
22748         CHECK((*env)->GetArrayLength(env, val) == 32);
22749         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
22750         ReplyShortChannelIdsEnd_set_chain_hash(&this_ptr_conv, val_ref);
22751 }
22752
22753 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1get_1full_1information(JNIEnv *env, jclass clz, int64_t this_ptr) {
22754         LDKReplyShortChannelIdsEnd this_ptr_conv;
22755         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22756         this_ptr_conv.is_owned = false;
22757         jboolean ret_val = ReplyShortChannelIdsEnd_get_full_information(&this_ptr_conv);
22758         return ret_val;
22759 }
22760
22761 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1set_1full_1information(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
22762         LDKReplyShortChannelIdsEnd this_ptr_conv;
22763         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22764         this_ptr_conv.is_owned = false;
22765         ReplyShortChannelIdsEnd_set_full_information(&this_ptr_conv, val);
22766 }
22767
22768 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1new(JNIEnv *env, jclass clz, int8_tArray chain_hash_arg, jboolean full_information_arg) {
22769         LDKThirtyTwoBytes chain_hash_arg_ref;
22770         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
22771         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
22772         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_new(chain_hash_arg_ref, full_information_arg);
22773         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22774         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22775         uint64_t ret_ref = (uint64_t)ret_var.inner;
22776         if (ret_var.is_owned) {
22777                 ret_ref |= 1;
22778         }
22779         return ret_ref;
22780 }
22781
22782 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22783         LDKReplyShortChannelIdsEnd orig_conv;
22784         orig_conv.inner = (void*)(orig & (~1));
22785         orig_conv.is_owned = false;
22786         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(&orig_conv);
22787         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22788         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22789         uint64_t ret_ref = (uint64_t)ret_var.inner;
22790         if (ret_var.is_owned) {
22791                 ret_ref |= 1;
22792         }
22793         return ret_ref;
22794 }
22795
22796 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22797         LDKGossipTimestampFilter this_obj_conv;
22798         this_obj_conv.inner = (void*)(this_obj & (~1));
22799         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22800         GossipTimestampFilter_free(this_obj_conv);
22801 }
22802
22803 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
22804         LDKGossipTimestampFilter this_ptr_conv;
22805         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22806         this_ptr_conv.is_owned = false;
22807         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
22808         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *GossipTimestampFilter_get_chain_hash(&this_ptr_conv));
22809         return ret_arr;
22810 }
22811
22812 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22813         LDKGossipTimestampFilter this_ptr_conv;
22814         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22815         this_ptr_conv.is_owned = false;
22816         LDKThirtyTwoBytes val_ref;
22817         CHECK((*env)->GetArrayLength(env, val) == 32);
22818         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
22819         GossipTimestampFilter_set_chain_hash(&this_ptr_conv, val_ref);
22820 }
22821
22822 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1first_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
22823         LDKGossipTimestampFilter this_ptr_conv;
22824         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22825         this_ptr_conv.is_owned = false;
22826         int32_t ret_val = GossipTimestampFilter_get_first_timestamp(&this_ptr_conv);
22827         return ret_val;
22828 }
22829
22830 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1first_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
22831         LDKGossipTimestampFilter this_ptr_conv;
22832         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22833         this_ptr_conv.is_owned = false;
22834         GossipTimestampFilter_set_first_timestamp(&this_ptr_conv, val);
22835 }
22836
22837 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1timestamp_1range(JNIEnv *env, jclass clz, int64_t this_ptr) {
22838         LDKGossipTimestampFilter this_ptr_conv;
22839         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22840         this_ptr_conv.is_owned = false;
22841         int32_t ret_val = GossipTimestampFilter_get_timestamp_range(&this_ptr_conv);
22842         return ret_val;
22843 }
22844
22845 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1timestamp_1range(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
22846         LDKGossipTimestampFilter this_ptr_conv;
22847         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22848         this_ptr_conv.is_owned = false;
22849         GossipTimestampFilter_set_timestamp_range(&this_ptr_conv, val);
22850 }
22851
22852 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) {
22853         LDKThirtyTwoBytes chain_hash_arg_ref;
22854         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
22855         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
22856         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_new(chain_hash_arg_ref, first_timestamp_arg, timestamp_range_arg);
22857         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22858         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22859         uint64_t ret_ref = (uint64_t)ret_var.inner;
22860         if (ret_var.is_owned) {
22861                 ret_ref |= 1;
22862         }
22863         return ret_ref;
22864 }
22865
22866 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22867         LDKGossipTimestampFilter orig_conv;
22868         orig_conv.inner = (void*)(orig & (~1));
22869         orig_conv.is_owned = false;
22870         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(&orig_conv);
22871         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22872         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22873         uint64_t ret_ref = (uint64_t)ret_var.inner;
22874         if (ret_var.is_owned) {
22875                 ret_ref |= 1;
22876         }
22877         return ret_ref;
22878 }
22879
22880 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorAction_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
22881         if ((this_ptr & 1) != 0) return;
22882         LDKErrorAction this_ptr_conv = *(LDKErrorAction*)(((uint64_t)this_ptr) & ~1);
22883         FREE((void*)this_ptr);
22884         ErrorAction_free(this_ptr_conv);
22885 }
22886
22887 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22888         LDKErrorAction* orig_conv = (LDKErrorAction*)orig;
22889         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
22890         *ret_copy = ErrorAction_clone(orig_conv);
22891         uint64_t ret_ref = (uint64_t)ret_copy;
22892         return ret_ref;
22893 }
22894
22895 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1disconnect_1peer(JNIEnv *env, jclass clz, int64_t msg) {
22896         LDKErrorMessage msg_conv;
22897         msg_conv.inner = (void*)(msg & (~1));
22898         msg_conv.is_owned = (msg & 1) || (msg == 0);
22899         msg_conv = ErrorMessage_clone(&msg_conv);
22900         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
22901         *ret_copy = ErrorAction_disconnect_peer(msg_conv);
22902         uint64_t ret_ref = (uint64_t)ret_copy;
22903         return ret_ref;
22904 }
22905
22906 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1ignore_1error(JNIEnv *env, jclass clz) {
22907         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
22908         *ret_copy = ErrorAction_ignore_error();
22909         uint64_t ret_ref = (uint64_t)ret_copy;
22910         return ret_ref;
22911 }
22912
22913 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1ignore_1and_1log(JNIEnv *env, jclass clz, jclass a) {
22914         LDKLevel a_conv = LDKLevel_from_java(env, a);
22915         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
22916         *ret_copy = ErrorAction_ignore_and_log(a_conv);
22917         uint64_t ret_ref = (uint64_t)ret_copy;
22918         return ret_ref;
22919 }
22920
22921 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1send_1error_1message(JNIEnv *env, jclass clz, int64_t msg) {
22922         LDKErrorMessage msg_conv;
22923         msg_conv.inner = (void*)(msg & (~1));
22924         msg_conv.is_owned = (msg & 1) || (msg == 0);
22925         msg_conv = ErrorMessage_clone(&msg_conv);
22926         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
22927         *ret_copy = ErrorAction_send_error_message(msg_conv);
22928         uint64_t ret_ref = (uint64_t)ret_copy;
22929         return ret_ref;
22930 }
22931
22932 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22933         LDKLightningError this_obj_conv;
22934         this_obj_conv.inner = (void*)(this_obj & (~1));
22935         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22936         LightningError_free(this_obj_conv);
22937 }
22938
22939 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_LightningError_1get_1err(JNIEnv *env, jclass clz, int64_t this_ptr) {
22940         LDKLightningError this_ptr_conv;
22941         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22942         this_ptr_conv.is_owned = false;
22943         LDKStr ret_str = LightningError_get_err(&this_ptr_conv);
22944         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
22945         Str_free(ret_str);
22946         return ret_conv;
22947 }
22948
22949 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1set_1err(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
22950         LDKLightningError this_ptr_conv;
22951         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22952         this_ptr_conv.is_owned = false;
22953         LDKStr val_conv = java_to_owned_str(env, val);
22954         LightningError_set_err(&this_ptr_conv, val_conv);
22955 }
22956
22957 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1get_1action(JNIEnv *env, jclass clz, int64_t this_ptr) {
22958         LDKLightningError this_ptr_conv;
22959         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22960         this_ptr_conv.is_owned = false;
22961         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
22962         *ret_copy = LightningError_get_action(&this_ptr_conv);
22963         uint64_t ret_ref = (uint64_t)ret_copy;
22964         return ret_ref;
22965 }
22966
22967 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1set_1action(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
22968         LDKLightningError this_ptr_conv;
22969         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22970         this_ptr_conv.is_owned = false;
22971         LDKErrorAction val_conv = *(LDKErrorAction*)(((uint64_t)val) & ~1);
22972         val_conv = ErrorAction_clone((LDKErrorAction*)(((uint64_t)val) & ~1));
22973         LightningError_set_action(&this_ptr_conv, val_conv);
22974 }
22975
22976 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1new(JNIEnv *env, jclass clz, jstring err_arg, int64_t action_arg) {
22977         LDKStr err_arg_conv = java_to_owned_str(env, err_arg);
22978         LDKErrorAction action_arg_conv = *(LDKErrorAction*)(((uint64_t)action_arg) & ~1);
22979         action_arg_conv = ErrorAction_clone((LDKErrorAction*)(((uint64_t)action_arg) & ~1));
22980         LDKLightningError ret_var = LightningError_new(err_arg_conv, action_arg_conv);
22981         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22982         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22983         uint64_t ret_ref = (uint64_t)ret_var.inner;
22984         if (ret_var.is_owned) {
22985                 ret_ref |= 1;
22986         }
22987         return ret_ref;
22988 }
22989
22990 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22991         LDKLightningError orig_conv;
22992         orig_conv.inner = (void*)(orig & (~1));
22993         orig_conv.is_owned = false;
22994         LDKLightningError ret_var = LightningError_clone(&orig_conv);
22995         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22996         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22997         uint64_t ret_ref = (uint64_t)ret_var.inner;
22998         if (ret_var.is_owned) {
22999                 ret_ref |= 1;
23000         }
23001         return ret_ref;
23002 }
23003
23004 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23005         LDKCommitmentUpdate this_obj_conv;
23006         this_obj_conv.inner = (void*)(this_obj & (~1));
23007         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23008         CommitmentUpdate_free(this_obj_conv);
23009 }
23010
23011 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1add_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
23012         LDKCommitmentUpdate this_ptr_conv;
23013         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23014         this_ptr_conv.is_owned = false;
23015         LDKCVec_UpdateAddHTLCZ ret_var = CommitmentUpdate_get_update_add_htlcs(&this_ptr_conv);
23016         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
23017         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
23018         for (size_t p = 0; p < ret_var.datalen; p++) {
23019                 LDKUpdateAddHTLC ret_conv_15_var = ret_var.data[p];
23020                 CHECK((((uint64_t)ret_conv_15_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23021                 CHECK((((uint64_t)&ret_conv_15_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23022                 uint64_t ret_conv_15_ref = (uint64_t)ret_conv_15_var.inner;
23023                 if (ret_conv_15_var.is_owned) {
23024                         ret_conv_15_ref |= 1;
23025                 }
23026                 ret_arr_ptr[p] = ret_conv_15_ref;
23027         }
23028         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
23029         FREE(ret_var.data);
23030         return ret_arr;
23031 }
23032
23033 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1add_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
23034         LDKCommitmentUpdate this_ptr_conv;
23035         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23036         this_ptr_conv.is_owned = false;
23037         LDKCVec_UpdateAddHTLCZ val_constr;
23038         val_constr.datalen = (*env)->GetArrayLength(env, val);
23039         if (val_constr.datalen > 0)
23040                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
23041         else
23042                 val_constr.data = NULL;
23043         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
23044         for (size_t p = 0; p < val_constr.datalen; p++) {
23045                 int64_t val_conv_15 = val_vals[p];
23046                 LDKUpdateAddHTLC val_conv_15_conv;
23047                 val_conv_15_conv.inner = (void*)(val_conv_15 & (~1));
23048                 val_conv_15_conv.is_owned = (val_conv_15 & 1) || (val_conv_15 == 0);
23049                 val_conv_15_conv = UpdateAddHTLC_clone(&val_conv_15_conv);
23050                 val_constr.data[p] = val_conv_15_conv;
23051         }
23052         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
23053         CommitmentUpdate_set_update_add_htlcs(&this_ptr_conv, val_constr);
23054 }
23055
23056 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fulfill_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
23057         LDKCommitmentUpdate this_ptr_conv;
23058         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23059         this_ptr_conv.is_owned = false;
23060         LDKCVec_UpdateFulfillHTLCZ ret_var = CommitmentUpdate_get_update_fulfill_htlcs(&this_ptr_conv);
23061         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
23062         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
23063         for (size_t t = 0; t < ret_var.datalen; t++) {
23064                 LDKUpdateFulfillHTLC ret_conv_19_var = ret_var.data[t];
23065                 CHECK((((uint64_t)ret_conv_19_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23066                 CHECK((((uint64_t)&ret_conv_19_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23067                 uint64_t ret_conv_19_ref = (uint64_t)ret_conv_19_var.inner;
23068                 if (ret_conv_19_var.is_owned) {
23069                         ret_conv_19_ref |= 1;
23070                 }
23071                 ret_arr_ptr[t] = ret_conv_19_ref;
23072         }
23073         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
23074         FREE(ret_var.data);
23075         return ret_arr;
23076 }
23077
23078 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fulfill_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
23079         LDKCommitmentUpdate this_ptr_conv;
23080         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23081         this_ptr_conv.is_owned = false;
23082         LDKCVec_UpdateFulfillHTLCZ val_constr;
23083         val_constr.datalen = (*env)->GetArrayLength(env, val);
23084         if (val_constr.datalen > 0)
23085                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
23086         else
23087                 val_constr.data = NULL;
23088         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
23089         for (size_t t = 0; t < val_constr.datalen; t++) {
23090                 int64_t val_conv_19 = val_vals[t];
23091                 LDKUpdateFulfillHTLC val_conv_19_conv;
23092                 val_conv_19_conv.inner = (void*)(val_conv_19 & (~1));
23093                 val_conv_19_conv.is_owned = (val_conv_19 & 1) || (val_conv_19 == 0);
23094                 val_conv_19_conv = UpdateFulfillHTLC_clone(&val_conv_19_conv);
23095                 val_constr.data[t] = val_conv_19_conv;
23096         }
23097         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
23098         CommitmentUpdate_set_update_fulfill_htlcs(&this_ptr_conv, val_constr);
23099 }
23100
23101 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fail_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
23102         LDKCommitmentUpdate this_ptr_conv;
23103         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23104         this_ptr_conv.is_owned = false;
23105         LDKCVec_UpdateFailHTLCZ ret_var = CommitmentUpdate_get_update_fail_htlcs(&this_ptr_conv);
23106         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
23107         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
23108         for (size_t q = 0; q < ret_var.datalen; q++) {
23109                 LDKUpdateFailHTLC ret_conv_16_var = ret_var.data[q];
23110                 CHECK((((uint64_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23111                 CHECK((((uint64_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23112                 uint64_t ret_conv_16_ref = (uint64_t)ret_conv_16_var.inner;
23113                 if (ret_conv_16_var.is_owned) {
23114                         ret_conv_16_ref |= 1;
23115                 }
23116                 ret_arr_ptr[q] = ret_conv_16_ref;
23117         }
23118         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
23119         FREE(ret_var.data);
23120         return ret_arr;
23121 }
23122
23123 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fail_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
23124         LDKCommitmentUpdate this_ptr_conv;
23125         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23126         this_ptr_conv.is_owned = false;
23127         LDKCVec_UpdateFailHTLCZ val_constr;
23128         val_constr.datalen = (*env)->GetArrayLength(env, val);
23129         if (val_constr.datalen > 0)
23130                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
23131         else
23132                 val_constr.data = NULL;
23133         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
23134         for (size_t q = 0; q < val_constr.datalen; q++) {
23135                 int64_t val_conv_16 = val_vals[q];
23136                 LDKUpdateFailHTLC val_conv_16_conv;
23137                 val_conv_16_conv.inner = (void*)(val_conv_16 & (~1));
23138                 val_conv_16_conv.is_owned = (val_conv_16 & 1) || (val_conv_16 == 0);
23139                 val_conv_16_conv = UpdateFailHTLC_clone(&val_conv_16_conv);
23140                 val_constr.data[q] = val_conv_16_conv;
23141         }
23142         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
23143         CommitmentUpdate_set_update_fail_htlcs(&this_ptr_conv, val_constr);
23144 }
23145
23146 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fail_1malformed_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
23147         LDKCommitmentUpdate this_ptr_conv;
23148         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23149         this_ptr_conv.is_owned = false;
23150         LDKCVec_UpdateFailMalformedHTLCZ ret_var = CommitmentUpdate_get_update_fail_malformed_htlcs(&this_ptr_conv);
23151         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
23152         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
23153         for (size_t z = 0; z < ret_var.datalen; z++) {
23154                 LDKUpdateFailMalformedHTLC ret_conv_25_var = ret_var.data[z];
23155                 CHECK((((uint64_t)ret_conv_25_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23156                 CHECK((((uint64_t)&ret_conv_25_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23157                 uint64_t ret_conv_25_ref = (uint64_t)ret_conv_25_var.inner;
23158                 if (ret_conv_25_var.is_owned) {
23159                         ret_conv_25_ref |= 1;
23160                 }
23161                 ret_arr_ptr[z] = ret_conv_25_ref;
23162         }
23163         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
23164         FREE(ret_var.data);
23165         return ret_arr;
23166 }
23167
23168 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) {
23169         LDKCommitmentUpdate this_ptr_conv;
23170         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23171         this_ptr_conv.is_owned = false;
23172         LDKCVec_UpdateFailMalformedHTLCZ val_constr;
23173         val_constr.datalen = (*env)->GetArrayLength(env, val);
23174         if (val_constr.datalen > 0)
23175                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
23176         else
23177                 val_constr.data = NULL;
23178         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
23179         for (size_t z = 0; z < val_constr.datalen; z++) {
23180                 int64_t val_conv_25 = val_vals[z];
23181                 LDKUpdateFailMalformedHTLC val_conv_25_conv;
23182                 val_conv_25_conv.inner = (void*)(val_conv_25 & (~1));
23183                 val_conv_25_conv.is_owned = (val_conv_25 & 1) || (val_conv_25 == 0);
23184                 val_conv_25_conv = UpdateFailMalformedHTLC_clone(&val_conv_25_conv);
23185                 val_constr.data[z] = val_conv_25_conv;
23186         }
23187         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
23188         CommitmentUpdate_set_update_fail_malformed_htlcs(&this_ptr_conv, val_constr);
23189 }
23190
23191 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fee(JNIEnv *env, jclass clz, int64_t this_ptr) {
23192         LDKCommitmentUpdate this_ptr_conv;
23193         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23194         this_ptr_conv.is_owned = false;
23195         LDKUpdateFee ret_var = CommitmentUpdate_get_update_fee(&this_ptr_conv);
23196         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23197         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23198         uint64_t ret_ref = (uint64_t)ret_var.inner;
23199         if (ret_var.is_owned) {
23200                 ret_ref |= 1;
23201         }
23202         return ret_ref;
23203 }
23204
23205 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fee(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23206         LDKCommitmentUpdate this_ptr_conv;
23207         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23208         this_ptr_conv.is_owned = false;
23209         LDKUpdateFee val_conv;
23210         val_conv.inner = (void*)(val & (~1));
23211         val_conv.is_owned = (val & 1) || (val == 0);
23212         val_conv = UpdateFee_clone(&val_conv);
23213         CommitmentUpdate_set_update_fee(&this_ptr_conv, val_conv);
23214 }
23215
23216 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1commitment_1signed(JNIEnv *env, jclass clz, int64_t this_ptr) {
23217         LDKCommitmentUpdate this_ptr_conv;
23218         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23219         this_ptr_conv.is_owned = false;
23220         LDKCommitmentSigned ret_var = CommitmentUpdate_get_commitment_signed(&this_ptr_conv);
23221         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23222         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23223         uint64_t ret_ref = (uint64_t)ret_var.inner;
23224         if (ret_var.is_owned) {
23225                 ret_ref |= 1;
23226         }
23227         return ret_ref;
23228 }
23229
23230 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1commitment_1signed(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23231         LDKCommitmentUpdate this_ptr_conv;
23232         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23233         this_ptr_conv.is_owned = false;
23234         LDKCommitmentSigned val_conv;
23235         val_conv.inner = (void*)(val & (~1));
23236         val_conv.is_owned = (val & 1) || (val == 0);
23237         val_conv = CommitmentSigned_clone(&val_conv);
23238         CommitmentUpdate_set_commitment_signed(&this_ptr_conv, val_conv);
23239 }
23240
23241 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) {
23242         LDKCVec_UpdateAddHTLCZ update_add_htlcs_arg_constr;
23243         update_add_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_add_htlcs_arg);
23244         if (update_add_htlcs_arg_constr.datalen > 0)
23245                 update_add_htlcs_arg_constr.data = MALLOC(update_add_htlcs_arg_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
23246         else
23247                 update_add_htlcs_arg_constr.data = NULL;
23248         int64_t* update_add_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_add_htlcs_arg, NULL);
23249         for (size_t p = 0; p < update_add_htlcs_arg_constr.datalen; p++) {
23250                 int64_t update_add_htlcs_arg_conv_15 = update_add_htlcs_arg_vals[p];
23251                 LDKUpdateAddHTLC update_add_htlcs_arg_conv_15_conv;
23252                 update_add_htlcs_arg_conv_15_conv.inner = (void*)(update_add_htlcs_arg_conv_15 & (~1));
23253                 update_add_htlcs_arg_conv_15_conv.is_owned = (update_add_htlcs_arg_conv_15 & 1) || (update_add_htlcs_arg_conv_15 == 0);
23254                 update_add_htlcs_arg_conv_15_conv = UpdateAddHTLC_clone(&update_add_htlcs_arg_conv_15_conv);
23255                 update_add_htlcs_arg_constr.data[p] = update_add_htlcs_arg_conv_15_conv;
23256         }
23257         (*env)->ReleaseLongArrayElements(env, update_add_htlcs_arg, update_add_htlcs_arg_vals, 0);
23258         LDKCVec_UpdateFulfillHTLCZ update_fulfill_htlcs_arg_constr;
23259         update_fulfill_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fulfill_htlcs_arg);
23260         if (update_fulfill_htlcs_arg_constr.datalen > 0)
23261                 update_fulfill_htlcs_arg_constr.data = MALLOC(update_fulfill_htlcs_arg_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
23262         else
23263                 update_fulfill_htlcs_arg_constr.data = NULL;
23264         int64_t* update_fulfill_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fulfill_htlcs_arg, NULL);
23265         for (size_t t = 0; t < update_fulfill_htlcs_arg_constr.datalen; t++) {
23266                 int64_t update_fulfill_htlcs_arg_conv_19 = update_fulfill_htlcs_arg_vals[t];
23267                 LDKUpdateFulfillHTLC update_fulfill_htlcs_arg_conv_19_conv;
23268                 update_fulfill_htlcs_arg_conv_19_conv.inner = (void*)(update_fulfill_htlcs_arg_conv_19 & (~1));
23269                 update_fulfill_htlcs_arg_conv_19_conv.is_owned = (update_fulfill_htlcs_arg_conv_19 & 1) || (update_fulfill_htlcs_arg_conv_19 == 0);
23270                 update_fulfill_htlcs_arg_conv_19_conv = UpdateFulfillHTLC_clone(&update_fulfill_htlcs_arg_conv_19_conv);
23271                 update_fulfill_htlcs_arg_constr.data[t] = update_fulfill_htlcs_arg_conv_19_conv;
23272         }
23273         (*env)->ReleaseLongArrayElements(env, update_fulfill_htlcs_arg, update_fulfill_htlcs_arg_vals, 0);
23274         LDKCVec_UpdateFailHTLCZ update_fail_htlcs_arg_constr;
23275         update_fail_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fail_htlcs_arg);
23276         if (update_fail_htlcs_arg_constr.datalen > 0)
23277                 update_fail_htlcs_arg_constr.data = MALLOC(update_fail_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
23278         else
23279                 update_fail_htlcs_arg_constr.data = NULL;
23280         int64_t* update_fail_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fail_htlcs_arg, NULL);
23281         for (size_t q = 0; q < update_fail_htlcs_arg_constr.datalen; q++) {
23282                 int64_t update_fail_htlcs_arg_conv_16 = update_fail_htlcs_arg_vals[q];
23283                 LDKUpdateFailHTLC update_fail_htlcs_arg_conv_16_conv;
23284                 update_fail_htlcs_arg_conv_16_conv.inner = (void*)(update_fail_htlcs_arg_conv_16 & (~1));
23285                 update_fail_htlcs_arg_conv_16_conv.is_owned = (update_fail_htlcs_arg_conv_16 & 1) || (update_fail_htlcs_arg_conv_16 == 0);
23286                 update_fail_htlcs_arg_conv_16_conv = UpdateFailHTLC_clone(&update_fail_htlcs_arg_conv_16_conv);
23287                 update_fail_htlcs_arg_constr.data[q] = update_fail_htlcs_arg_conv_16_conv;
23288         }
23289         (*env)->ReleaseLongArrayElements(env, update_fail_htlcs_arg, update_fail_htlcs_arg_vals, 0);
23290         LDKCVec_UpdateFailMalformedHTLCZ update_fail_malformed_htlcs_arg_constr;
23291         update_fail_malformed_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fail_malformed_htlcs_arg);
23292         if (update_fail_malformed_htlcs_arg_constr.datalen > 0)
23293                 update_fail_malformed_htlcs_arg_constr.data = MALLOC(update_fail_malformed_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
23294         else
23295                 update_fail_malformed_htlcs_arg_constr.data = NULL;
23296         int64_t* update_fail_malformed_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fail_malformed_htlcs_arg, NULL);
23297         for (size_t z = 0; z < update_fail_malformed_htlcs_arg_constr.datalen; z++) {
23298                 int64_t update_fail_malformed_htlcs_arg_conv_25 = update_fail_malformed_htlcs_arg_vals[z];
23299                 LDKUpdateFailMalformedHTLC update_fail_malformed_htlcs_arg_conv_25_conv;
23300                 update_fail_malformed_htlcs_arg_conv_25_conv.inner = (void*)(update_fail_malformed_htlcs_arg_conv_25 & (~1));
23301                 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);
23302                 update_fail_malformed_htlcs_arg_conv_25_conv = UpdateFailMalformedHTLC_clone(&update_fail_malformed_htlcs_arg_conv_25_conv);
23303                 update_fail_malformed_htlcs_arg_constr.data[z] = update_fail_malformed_htlcs_arg_conv_25_conv;
23304         }
23305         (*env)->ReleaseLongArrayElements(env, update_fail_malformed_htlcs_arg, update_fail_malformed_htlcs_arg_vals, 0);
23306         LDKUpdateFee update_fee_arg_conv;
23307         update_fee_arg_conv.inner = (void*)(update_fee_arg & (~1));
23308         update_fee_arg_conv.is_owned = (update_fee_arg & 1) || (update_fee_arg == 0);
23309         update_fee_arg_conv = UpdateFee_clone(&update_fee_arg_conv);
23310         LDKCommitmentSigned commitment_signed_arg_conv;
23311         commitment_signed_arg_conv.inner = (void*)(commitment_signed_arg & (~1));
23312         commitment_signed_arg_conv.is_owned = (commitment_signed_arg & 1) || (commitment_signed_arg == 0);
23313         commitment_signed_arg_conv = CommitmentSigned_clone(&commitment_signed_arg_conv);
23314         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);
23315         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23316         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23317         uint64_t ret_ref = (uint64_t)ret_var.inner;
23318         if (ret_var.is_owned) {
23319                 ret_ref |= 1;
23320         }
23321         return ret_ref;
23322 }
23323
23324 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23325         LDKCommitmentUpdate orig_conv;
23326         orig_conv.inner = (void*)(orig & (~1));
23327         orig_conv.is_owned = false;
23328         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(&orig_conv);
23329         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23330         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23331         uint64_t ret_ref = (uint64_t)ret_var.inner;
23332         if (ret_var.is_owned) {
23333                 ret_ref |= 1;
23334         }
23335         return ret_ref;
23336 }
23337
23338 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
23339         if ((this_ptr & 1) != 0) return;
23340         LDKChannelMessageHandler this_ptr_conv = *(LDKChannelMessageHandler*)(((uint64_t)this_ptr) & ~1);
23341         FREE((void*)this_ptr);
23342         ChannelMessageHandler_free(this_ptr_conv);
23343 }
23344
23345 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
23346         if ((this_ptr & 1) != 0) return;
23347         LDKRoutingMessageHandler this_ptr_conv = *(LDKRoutingMessageHandler*)(((uint64_t)this_ptr) & ~1);
23348         FREE((void*)this_ptr);
23349         RoutingMessageHandler_free(this_ptr_conv);
23350 }
23351
23352 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1write(JNIEnv *env, jclass clz, int64_t obj) {
23353         LDKAcceptChannel obj_conv;
23354         obj_conv.inner = (void*)(obj & (~1));
23355         obj_conv.is_owned = false;
23356         LDKCVec_u8Z ret_var = AcceptChannel_write(&obj_conv);
23357         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23358         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23359         CVec_u8Z_free(ret_var);
23360         return ret_arr;
23361 }
23362
23363 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23364         LDKu8slice ser_ref;
23365         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23366         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23367         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
23368         *ret_conv = AcceptChannel_read(ser_ref);
23369         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23370         return (uint64_t)ret_conv;
23371 }
23372
23373 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
23374         LDKAnnouncementSignatures obj_conv;
23375         obj_conv.inner = (void*)(obj & (~1));
23376         obj_conv.is_owned = false;
23377         LDKCVec_u8Z ret_var = AnnouncementSignatures_write(&obj_conv);
23378         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23379         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23380         CVec_u8Z_free(ret_var);
23381         return ret_arr;
23382 }
23383
23384 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23385         LDKu8slice ser_ref;
23386         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23387         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23388         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
23389         *ret_conv = AnnouncementSignatures_read(ser_ref);
23390         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23391         return (uint64_t)ret_conv;
23392 }
23393
23394 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1write(JNIEnv *env, jclass clz, int64_t obj) {
23395         LDKChannelReestablish obj_conv;
23396         obj_conv.inner = (void*)(obj & (~1));
23397         obj_conv.is_owned = false;
23398         LDKCVec_u8Z ret_var = ChannelReestablish_write(&obj_conv);
23399         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23400         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23401         CVec_u8Z_free(ret_var);
23402         return ret_arr;
23403 }
23404
23405 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23406         LDKu8slice ser_ref;
23407         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23408         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23409         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
23410         *ret_conv = ChannelReestablish_read(ser_ref);
23411         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23412         return (uint64_t)ret_conv;
23413 }
23414
23415 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
23416         LDKClosingSigned obj_conv;
23417         obj_conv.inner = (void*)(obj & (~1));
23418         obj_conv.is_owned = false;
23419         LDKCVec_u8Z ret_var = ClosingSigned_write(&obj_conv);
23420         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23421         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23422         CVec_u8Z_free(ret_var);
23423         return ret_arr;
23424 }
23425
23426 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23427         LDKu8slice ser_ref;
23428         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23429         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23430         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
23431         *ret_conv = ClosingSigned_read(ser_ref);
23432         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23433         return (uint64_t)ret_conv;
23434 }
23435
23436 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
23437         LDKClosingSignedFeeRange obj_conv;
23438         obj_conv.inner = (void*)(obj & (~1));
23439         obj_conv.is_owned = false;
23440         LDKCVec_u8Z ret_var = ClosingSignedFeeRange_write(&obj_conv);
23441         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23442         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23443         CVec_u8Z_free(ret_var);
23444         return ret_arr;
23445 }
23446
23447 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23448         LDKu8slice ser_ref;
23449         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23450         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23451         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
23452         *ret_conv = ClosingSignedFeeRange_read(ser_ref);
23453         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23454         return (uint64_t)ret_conv;
23455 }
23456
23457 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
23458         LDKCommitmentSigned obj_conv;
23459         obj_conv.inner = (void*)(obj & (~1));
23460         obj_conv.is_owned = false;
23461         LDKCVec_u8Z ret_var = CommitmentSigned_write(&obj_conv);
23462         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23463         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23464         CVec_u8Z_free(ret_var);
23465         return ret_arr;
23466 }
23467
23468 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23469         LDKu8slice ser_ref;
23470         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23471         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23472         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
23473         *ret_conv = CommitmentSigned_read(ser_ref);
23474         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23475         return (uint64_t)ret_conv;
23476 }
23477
23478 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1write(JNIEnv *env, jclass clz, int64_t obj) {
23479         LDKFundingCreated obj_conv;
23480         obj_conv.inner = (void*)(obj & (~1));
23481         obj_conv.is_owned = false;
23482         LDKCVec_u8Z ret_var = FundingCreated_write(&obj_conv);
23483         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23484         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23485         CVec_u8Z_free(ret_var);
23486         return ret_arr;
23487 }
23488
23489 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23490         LDKu8slice ser_ref;
23491         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23492         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23493         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
23494         *ret_conv = FundingCreated_read(ser_ref);
23495         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23496         return (uint64_t)ret_conv;
23497 }
23498
23499 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
23500         LDKFundingSigned obj_conv;
23501         obj_conv.inner = (void*)(obj & (~1));
23502         obj_conv.is_owned = false;
23503         LDKCVec_u8Z ret_var = FundingSigned_write(&obj_conv);
23504         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23505         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23506         CVec_u8Z_free(ret_var);
23507         return ret_arr;
23508 }
23509
23510 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23511         LDKu8slice ser_ref;
23512         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23513         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23514         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
23515         *ret_conv = FundingSigned_read(ser_ref);
23516         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23517         return (uint64_t)ret_conv;
23518 }
23519
23520 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingLocked_1write(JNIEnv *env, jclass clz, int64_t obj) {
23521         LDKFundingLocked obj_conv;
23522         obj_conv.inner = (void*)(obj & (~1));
23523         obj_conv.is_owned = false;
23524         LDKCVec_u8Z ret_var = FundingLocked_write(&obj_conv);
23525         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23526         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23527         CVec_u8Z_free(ret_var);
23528         return ret_arr;
23529 }
23530
23531 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingLocked_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23532         LDKu8slice ser_ref;
23533         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23534         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23535         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
23536         *ret_conv = FundingLocked_read(ser_ref);
23537         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23538         return (uint64_t)ret_conv;
23539 }
23540
23541 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Init_1write(JNIEnv *env, jclass clz, int64_t obj) {
23542         LDKInit obj_conv;
23543         obj_conv.inner = (void*)(obj & (~1));
23544         obj_conv.is_owned = false;
23545         LDKCVec_u8Z ret_var = Init_write(&obj_conv);
23546         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23547         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23548         CVec_u8Z_free(ret_var);
23549         return ret_arr;
23550 }
23551
23552 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23553         LDKu8slice ser_ref;
23554         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23555         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23556         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
23557         *ret_conv = Init_read(ser_ref);
23558         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23559         return (uint64_t)ret_conv;
23560 }
23561
23562 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1write(JNIEnv *env, jclass clz, int64_t obj) {
23563         LDKOpenChannel obj_conv;
23564         obj_conv.inner = (void*)(obj & (~1));
23565         obj_conv.is_owned = false;
23566         LDKCVec_u8Z ret_var = OpenChannel_write(&obj_conv);
23567         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23568         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23569         CVec_u8Z_free(ret_var);
23570         return ret_arr;
23571 }
23572
23573 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23574         LDKu8slice ser_ref;
23575         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23576         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23577         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
23578         *ret_conv = OpenChannel_read(ser_ref);
23579         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23580         return (uint64_t)ret_conv;
23581 }
23582
23583 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1write(JNIEnv *env, jclass clz, int64_t obj) {
23584         LDKRevokeAndACK obj_conv;
23585         obj_conv.inner = (void*)(obj & (~1));
23586         obj_conv.is_owned = false;
23587         LDKCVec_u8Z ret_var = RevokeAndACK_write(&obj_conv);
23588         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23589         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23590         CVec_u8Z_free(ret_var);
23591         return ret_arr;
23592 }
23593
23594 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23595         LDKu8slice ser_ref;
23596         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23597         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23598         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
23599         *ret_conv = RevokeAndACK_read(ser_ref);
23600         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23601         return (uint64_t)ret_conv;
23602 }
23603
23604 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1write(JNIEnv *env, jclass clz, int64_t obj) {
23605         LDKShutdown obj_conv;
23606         obj_conv.inner = (void*)(obj & (~1));
23607         obj_conv.is_owned = false;
23608         LDKCVec_u8Z ret_var = Shutdown_write(&obj_conv);
23609         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23610         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23611         CVec_u8Z_free(ret_var);
23612         return ret_arr;
23613 }
23614
23615 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23616         LDKu8slice ser_ref;
23617         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23618         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23619         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
23620         *ret_conv = Shutdown_read(ser_ref);
23621         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23622         return (uint64_t)ret_conv;
23623 }
23624
23625 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
23626         LDKUpdateFailHTLC obj_conv;
23627         obj_conv.inner = (void*)(obj & (~1));
23628         obj_conv.is_owned = false;
23629         LDKCVec_u8Z ret_var = UpdateFailHTLC_write(&obj_conv);
23630         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23631         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23632         CVec_u8Z_free(ret_var);
23633         return ret_arr;
23634 }
23635
23636 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23637         LDKu8slice ser_ref;
23638         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23639         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23640         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
23641         *ret_conv = UpdateFailHTLC_read(ser_ref);
23642         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23643         return (uint64_t)ret_conv;
23644 }
23645
23646 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
23647         LDKUpdateFailMalformedHTLC obj_conv;
23648         obj_conv.inner = (void*)(obj & (~1));
23649         obj_conv.is_owned = false;
23650         LDKCVec_u8Z ret_var = UpdateFailMalformedHTLC_write(&obj_conv);
23651         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23652         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23653         CVec_u8Z_free(ret_var);
23654         return ret_arr;
23655 }
23656
23657 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23658         LDKu8slice ser_ref;
23659         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23660         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23661         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
23662         *ret_conv = UpdateFailMalformedHTLC_read(ser_ref);
23663         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23664         return (uint64_t)ret_conv;
23665 }
23666
23667 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFee_1write(JNIEnv *env, jclass clz, int64_t obj) {
23668         LDKUpdateFee obj_conv;
23669         obj_conv.inner = (void*)(obj & (~1));
23670         obj_conv.is_owned = false;
23671         LDKCVec_u8Z ret_var = UpdateFee_write(&obj_conv);
23672         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23673         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23674         CVec_u8Z_free(ret_var);
23675         return ret_arr;
23676 }
23677
23678 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23679         LDKu8slice ser_ref;
23680         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23681         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23682         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
23683         *ret_conv = UpdateFee_read(ser_ref);
23684         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23685         return (uint64_t)ret_conv;
23686 }
23687
23688 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
23689         LDKUpdateFulfillHTLC obj_conv;
23690         obj_conv.inner = (void*)(obj & (~1));
23691         obj_conv.is_owned = false;
23692         LDKCVec_u8Z ret_var = UpdateFulfillHTLC_write(&obj_conv);
23693         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23694         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23695         CVec_u8Z_free(ret_var);
23696         return ret_arr;
23697 }
23698
23699 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23700         LDKu8slice ser_ref;
23701         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23702         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23703         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
23704         *ret_conv = UpdateFulfillHTLC_read(ser_ref);
23705         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23706         return (uint64_t)ret_conv;
23707 }
23708
23709 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
23710         LDKUpdateAddHTLC obj_conv;
23711         obj_conv.inner = (void*)(obj & (~1));
23712         obj_conv.is_owned = false;
23713         LDKCVec_u8Z ret_var = UpdateAddHTLC_write(&obj_conv);
23714         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23715         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23716         CVec_u8Z_free(ret_var);
23717         return ret_arr;
23718 }
23719
23720 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23721         LDKu8slice ser_ref;
23722         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23723         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23724         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
23725         *ret_conv = UpdateAddHTLC_read(ser_ref);
23726         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23727         return (uint64_t)ret_conv;
23728 }
23729
23730 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Ping_1write(JNIEnv *env, jclass clz, int64_t obj) {
23731         LDKPing obj_conv;
23732         obj_conv.inner = (void*)(obj & (~1));
23733         obj_conv.is_owned = false;
23734         LDKCVec_u8Z ret_var = Ping_write(&obj_conv);
23735         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23736         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23737         CVec_u8Z_free(ret_var);
23738         return ret_arr;
23739 }
23740
23741 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23742         LDKu8slice ser_ref;
23743         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23744         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23745         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
23746         *ret_conv = Ping_read(ser_ref);
23747         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23748         return (uint64_t)ret_conv;
23749 }
23750
23751 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Pong_1write(JNIEnv *env, jclass clz, int64_t obj) {
23752         LDKPong obj_conv;
23753         obj_conv.inner = (void*)(obj & (~1));
23754         obj_conv.is_owned = false;
23755         LDKCVec_u8Z ret_var = Pong_write(&obj_conv);
23756         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23757         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23758         CVec_u8Z_free(ret_var);
23759         return ret_arr;
23760 }
23761
23762 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23763         LDKu8slice ser_ref;
23764         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23765         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23766         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
23767         *ret_conv = Pong_read(ser_ref);
23768         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23769         return (uint64_t)ret_conv;
23770 }
23771
23772 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
23773         LDKUnsignedChannelAnnouncement obj_conv;
23774         obj_conv.inner = (void*)(obj & (~1));
23775         obj_conv.is_owned = false;
23776         LDKCVec_u8Z ret_var = UnsignedChannelAnnouncement_write(&obj_conv);
23777         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23778         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23779         CVec_u8Z_free(ret_var);
23780         return ret_arr;
23781 }
23782
23783 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23784         LDKu8slice ser_ref;
23785         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23786         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23787         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
23788         *ret_conv = UnsignedChannelAnnouncement_read(ser_ref);
23789         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23790         return (uint64_t)ret_conv;
23791 }
23792
23793 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
23794         LDKChannelAnnouncement obj_conv;
23795         obj_conv.inner = (void*)(obj & (~1));
23796         obj_conv.is_owned = false;
23797         LDKCVec_u8Z ret_var = ChannelAnnouncement_write(&obj_conv);
23798         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23799         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23800         CVec_u8Z_free(ret_var);
23801         return ret_arr;
23802 }
23803
23804 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23805         LDKu8slice ser_ref;
23806         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23807         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23808         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
23809         *ret_conv = ChannelAnnouncement_read(ser_ref);
23810         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23811         return (uint64_t)ret_conv;
23812 }
23813
23814 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
23815         LDKUnsignedChannelUpdate obj_conv;
23816         obj_conv.inner = (void*)(obj & (~1));
23817         obj_conv.is_owned = false;
23818         LDKCVec_u8Z ret_var = UnsignedChannelUpdate_write(&obj_conv);
23819         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23820         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23821         CVec_u8Z_free(ret_var);
23822         return ret_arr;
23823 }
23824
23825 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23826         LDKu8slice ser_ref;
23827         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23828         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23829         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
23830         *ret_conv = UnsignedChannelUpdate_read(ser_ref);
23831         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23832         return (uint64_t)ret_conv;
23833 }
23834
23835 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
23836         LDKChannelUpdate obj_conv;
23837         obj_conv.inner = (void*)(obj & (~1));
23838         obj_conv.is_owned = false;
23839         LDKCVec_u8Z ret_var = ChannelUpdate_write(&obj_conv);
23840         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23841         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23842         CVec_u8Z_free(ret_var);
23843         return ret_arr;
23844 }
23845
23846 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23847         LDKu8slice ser_ref;
23848         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23849         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23850         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
23851         *ret_conv = ChannelUpdate_read(ser_ref);
23852         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23853         return (uint64_t)ret_conv;
23854 }
23855
23856 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1write(JNIEnv *env, jclass clz, int64_t obj) {
23857         LDKErrorMessage obj_conv;
23858         obj_conv.inner = (void*)(obj & (~1));
23859         obj_conv.is_owned = false;
23860         LDKCVec_u8Z ret_var = ErrorMessage_write(&obj_conv);
23861         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23862         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23863         CVec_u8Z_free(ret_var);
23864         return ret_arr;
23865 }
23866
23867 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23868         LDKu8slice ser_ref;
23869         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23870         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23871         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
23872         *ret_conv = ErrorMessage_read(ser_ref);
23873         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23874         return (uint64_t)ret_conv;
23875 }
23876
23877 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
23878         LDKUnsignedNodeAnnouncement obj_conv;
23879         obj_conv.inner = (void*)(obj & (~1));
23880         obj_conv.is_owned = false;
23881         LDKCVec_u8Z ret_var = UnsignedNodeAnnouncement_write(&obj_conv);
23882         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23883         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23884         CVec_u8Z_free(ret_var);
23885         return ret_arr;
23886 }
23887
23888 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23889         LDKu8slice ser_ref;
23890         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23891         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23892         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
23893         *ret_conv = UnsignedNodeAnnouncement_read(ser_ref);
23894         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23895         return (uint64_t)ret_conv;
23896 }
23897
23898 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
23899         LDKNodeAnnouncement obj_conv;
23900         obj_conv.inner = (void*)(obj & (~1));
23901         obj_conv.is_owned = false;
23902         LDKCVec_u8Z ret_var = NodeAnnouncement_write(&obj_conv);
23903         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23904         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23905         CVec_u8Z_free(ret_var);
23906         return ret_arr;
23907 }
23908
23909 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23910         LDKu8slice ser_ref;
23911         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23912         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23913         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
23914         *ret_conv = NodeAnnouncement_read(ser_ref);
23915         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23916         return (uint64_t)ret_conv;
23917 }
23918
23919 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23920         LDKu8slice ser_ref;
23921         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23922         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23923         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
23924         *ret_conv = QueryShortChannelIds_read(ser_ref);
23925         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23926         return (uint64_t)ret_conv;
23927 }
23928
23929 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1write(JNIEnv *env, jclass clz, int64_t obj) {
23930         LDKQueryShortChannelIds obj_conv;
23931         obj_conv.inner = (void*)(obj & (~1));
23932         obj_conv.is_owned = false;
23933         LDKCVec_u8Z ret_var = QueryShortChannelIds_write(&obj_conv);
23934         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23935         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23936         CVec_u8Z_free(ret_var);
23937         return ret_arr;
23938 }
23939
23940 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1write(JNIEnv *env, jclass clz, int64_t obj) {
23941         LDKReplyShortChannelIdsEnd obj_conv;
23942         obj_conv.inner = (void*)(obj & (~1));
23943         obj_conv.is_owned = false;
23944         LDKCVec_u8Z ret_var = ReplyShortChannelIdsEnd_write(&obj_conv);
23945         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23946         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23947         CVec_u8Z_free(ret_var);
23948         return ret_arr;
23949 }
23950
23951 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23952         LDKu8slice ser_ref;
23953         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23954         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23955         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
23956         *ret_conv = ReplyShortChannelIdsEnd_read(ser_ref);
23957         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23958         return (uint64_t)ret_conv;
23959 }
23960
23961 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1end_1blocknum(JNIEnv *env, jclass clz, int64_t this_arg) {
23962         LDKQueryChannelRange this_arg_conv;
23963         this_arg_conv.inner = (void*)(this_arg & (~1));
23964         this_arg_conv.is_owned = false;
23965         int32_t ret_val = QueryChannelRange_end_blocknum(&this_arg_conv);
23966         return ret_val;
23967 }
23968
23969 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
23970         LDKQueryChannelRange obj_conv;
23971         obj_conv.inner = (void*)(obj & (~1));
23972         obj_conv.is_owned = false;
23973         LDKCVec_u8Z ret_var = QueryChannelRange_write(&obj_conv);
23974         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23975         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23976         CVec_u8Z_free(ret_var);
23977         return ret_arr;
23978 }
23979
23980 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23981         LDKu8slice ser_ref;
23982         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23983         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23984         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
23985         *ret_conv = QueryChannelRange_read(ser_ref);
23986         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23987         return (uint64_t)ret_conv;
23988 }
23989
23990 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23991         LDKu8slice ser_ref;
23992         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23993         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23994         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
23995         *ret_conv = ReplyChannelRange_read(ser_ref);
23996         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23997         return (uint64_t)ret_conv;
23998 }
23999
24000 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
24001         LDKReplyChannelRange obj_conv;
24002         obj_conv.inner = (void*)(obj & (~1));
24003         obj_conv.is_owned = false;
24004         LDKCVec_u8Z ret_var = ReplyChannelRange_write(&obj_conv);
24005         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24006         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24007         CVec_u8Z_free(ret_var);
24008         return ret_arr;
24009 }
24010
24011 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1write(JNIEnv *env, jclass clz, int64_t obj) {
24012         LDKGossipTimestampFilter obj_conv;
24013         obj_conv.inner = (void*)(obj & (~1));
24014         obj_conv.is_owned = false;
24015         LDKCVec_u8Z ret_var = GossipTimestampFilter_write(&obj_conv);
24016         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24017         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24018         CVec_u8Z_free(ret_var);
24019         return ret_arr;
24020 }
24021
24022 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24023         LDKu8slice ser_ref;
24024         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24025         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24026         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
24027         *ret_conv = GossipTimestampFilter_read(ser_ref);
24028         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24029         return (uint64_t)ret_conv;
24030 }
24031
24032 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CustomMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
24033         if ((this_ptr & 1) != 0) return;
24034         LDKCustomMessageHandler this_ptr_conv = *(LDKCustomMessageHandler*)(((uint64_t)this_ptr) & ~1);
24035         FREE((void*)this_ptr);
24036         CustomMessageHandler_free(this_ptr_conv);
24037 }
24038
24039 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24040         LDKIgnoringMessageHandler this_obj_conv;
24041         this_obj_conv.inner = (void*)(this_obj & (~1));
24042         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24043         IgnoringMessageHandler_free(this_obj_conv);
24044 }
24045
24046 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1new(JNIEnv *env, jclass clz) {
24047         LDKIgnoringMessageHandler ret_var = IgnoringMessageHandler_new();
24048         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24049         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24050         uint64_t ret_ref = (uint64_t)ret_var.inner;
24051         if (ret_var.is_owned) {
24052                 ret_ref |= 1;
24053         }
24054         return ret_ref;
24055 }
24056
24057 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
24058         LDKIgnoringMessageHandler this_arg_conv;
24059         this_arg_conv.inner = (void*)(this_arg & (~1));
24060         this_arg_conv.is_owned = false;
24061         LDKMessageSendEventsProvider* ret_ret =MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
24062         *ret_ret = IgnoringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
24063         return (uint64_t)ret_ret;
24064 }
24065
24066 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1RoutingMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
24067         LDKIgnoringMessageHandler this_arg_conv;
24068         this_arg_conv.inner = (void*)(this_arg & (~1));
24069         this_arg_conv.is_owned = false;
24070         LDKRoutingMessageHandler* ret_ret =MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
24071         *ret_ret = IgnoringMessageHandler_as_RoutingMessageHandler(&this_arg_conv);
24072         return (uint64_t)ret_ret;
24073 }
24074
24075 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1CustomMessageReader(JNIEnv *env, jclass clz, int64_t this_arg) {
24076         LDKIgnoringMessageHandler this_arg_conv;
24077         this_arg_conv.inner = (void*)(this_arg & (~1));
24078         this_arg_conv.is_owned = false;
24079         LDKCustomMessageReader* ret_ret =MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader");
24080         *ret_ret = IgnoringMessageHandler_as_CustomMessageReader(&this_arg_conv);
24081         return (uint64_t)ret_ret;
24082 }
24083
24084 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1CustomMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
24085         LDKIgnoringMessageHandler this_arg_conv;
24086         this_arg_conv.inner = (void*)(this_arg & (~1));
24087         this_arg_conv.is_owned = false;
24088         LDKCustomMessageHandler* ret_ret =MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler");
24089         *ret_ret = IgnoringMessageHandler_as_CustomMessageHandler(&this_arg_conv);
24090         return (uint64_t)ret_ret;
24091 }
24092
24093 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24094         LDKErroringMessageHandler this_obj_conv;
24095         this_obj_conv.inner = (void*)(this_obj & (~1));
24096         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24097         ErroringMessageHandler_free(this_obj_conv);
24098 }
24099
24100 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1new(JNIEnv *env, jclass clz) {
24101         LDKErroringMessageHandler ret_var = ErroringMessageHandler_new();
24102         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24103         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24104         uint64_t ret_ref = (uint64_t)ret_var.inner;
24105         if (ret_var.is_owned) {
24106                 ret_ref |= 1;
24107         }
24108         return ret_ref;
24109 }
24110
24111 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
24112         LDKErroringMessageHandler this_arg_conv;
24113         this_arg_conv.inner = (void*)(this_arg & (~1));
24114         this_arg_conv.is_owned = false;
24115         LDKMessageSendEventsProvider* ret_ret =MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
24116         *ret_ret = ErroringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
24117         return (uint64_t)ret_ret;
24118 }
24119
24120 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1as_1ChannelMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
24121         LDKErroringMessageHandler this_arg_conv;
24122         this_arg_conv.inner = (void*)(this_arg & (~1));
24123         this_arg_conv.is_owned = false;
24124         LDKChannelMessageHandler* ret_ret =MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
24125         *ret_ret = ErroringMessageHandler_as_ChannelMessageHandler(&this_arg_conv);
24126         return (uint64_t)ret_ret;
24127 }
24128
24129 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24130         LDKMessageHandler this_obj_conv;
24131         this_obj_conv.inner = (void*)(this_obj & (~1));
24132         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24133         MessageHandler_free(this_obj_conv);
24134 }
24135
24136 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1chan_1handler(JNIEnv *env, jclass clz, int64_t this_ptr) {
24137         LDKMessageHandler this_ptr_conv;
24138         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24139         this_ptr_conv.is_owned = false;
24140         uint64_t ret_ret = (uint64_t)MessageHandler_get_chan_handler(&this_ptr_conv);
24141         return ret_ret;
24142 }
24143
24144 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1chan_1handler(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24145         LDKMessageHandler this_ptr_conv;
24146         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24147         this_ptr_conv.is_owned = false;
24148         LDKChannelMessageHandler val_conv = *(LDKChannelMessageHandler*)(((uint64_t)val) & ~1);
24149         if (val_conv.free == LDKChannelMessageHandler_JCalls_free) {
24150                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24151                 LDKChannelMessageHandler_JCalls_cloned(&val_conv);
24152         }
24153         MessageHandler_set_chan_handler(&this_ptr_conv, val_conv);
24154 }
24155
24156 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1route_1handler(JNIEnv *env, jclass clz, int64_t this_ptr) {
24157         LDKMessageHandler this_ptr_conv;
24158         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24159         this_ptr_conv.is_owned = false;
24160         uint64_t ret_ret = (uint64_t)MessageHandler_get_route_handler(&this_ptr_conv);
24161         return ret_ret;
24162 }
24163
24164 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1route_1handler(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24165         LDKMessageHandler this_ptr_conv;
24166         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24167         this_ptr_conv.is_owned = false;
24168         LDKRoutingMessageHandler val_conv = *(LDKRoutingMessageHandler*)(((uint64_t)val) & ~1);
24169         if (val_conv.free == LDKRoutingMessageHandler_JCalls_free) {
24170                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24171                 LDKRoutingMessageHandler_JCalls_cloned(&val_conv);
24172         }
24173         MessageHandler_set_route_handler(&this_ptr_conv, val_conv);
24174 }
24175
24176 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) {
24177         LDKChannelMessageHandler chan_handler_arg_conv = *(LDKChannelMessageHandler*)(((uint64_t)chan_handler_arg) & ~1);
24178         if (chan_handler_arg_conv.free == LDKChannelMessageHandler_JCalls_free) {
24179                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24180                 LDKChannelMessageHandler_JCalls_cloned(&chan_handler_arg_conv);
24181         }
24182         LDKRoutingMessageHandler route_handler_arg_conv = *(LDKRoutingMessageHandler*)(((uint64_t)route_handler_arg) & ~1);
24183         if (route_handler_arg_conv.free == LDKRoutingMessageHandler_JCalls_free) {
24184                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24185                 LDKRoutingMessageHandler_JCalls_cloned(&route_handler_arg_conv);
24186         }
24187         LDKMessageHandler ret_var = MessageHandler_new(chan_handler_arg_conv, route_handler_arg_conv);
24188         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24189         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24190         uint64_t ret_ref = (uint64_t)ret_var.inner;
24191         if (ret_var.is_owned) {
24192                 ret_ref |= 1;
24193         }
24194         return ret_ref;
24195 }
24196
24197 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24198         LDKSocketDescriptor* orig_conv = (LDKSocketDescriptor*)(((uint64_t)orig) & ~1);
24199         LDKSocketDescriptor* ret_ret =MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
24200         *ret_ret = SocketDescriptor_clone(orig_conv);
24201         return (uint64_t)ret_ret;
24202 }
24203
24204 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
24205         if ((this_ptr & 1) != 0) return;
24206         LDKSocketDescriptor this_ptr_conv = *(LDKSocketDescriptor*)(((uint64_t)this_ptr) & ~1);
24207         FREE((void*)this_ptr);
24208         SocketDescriptor_free(this_ptr_conv);
24209 }
24210
24211 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24212         LDKPeerHandleError this_obj_conv;
24213         this_obj_conv.inner = (void*)(this_obj & (~1));
24214         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24215         PeerHandleError_free(this_obj_conv);
24216 }
24217
24218 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1get_1no_1connection_1possible(JNIEnv *env, jclass clz, int64_t this_ptr) {
24219         LDKPeerHandleError this_ptr_conv;
24220         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24221         this_ptr_conv.is_owned = false;
24222         jboolean ret_val = PeerHandleError_get_no_connection_possible(&this_ptr_conv);
24223         return ret_val;
24224 }
24225
24226 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1set_1no_1connection_1possible(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
24227         LDKPeerHandleError this_ptr_conv;
24228         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24229         this_ptr_conv.is_owned = false;
24230         PeerHandleError_set_no_connection_possible(&this_ptr_conv, val);
24231 }
24232
24233 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1new(JNIEnv *env, jclass clz, jboolean no_connection_possible_arg) {
24234         LDKPeerHandleError ret_var = PeerHandleError_new(no_connection_possible_arg);
24235         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24236         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24237         uint64_t ret_ref = (uint64_t)ret_var.inner;
24238         if (ret_var.is_owned) {
24239                 ret_ref |= 1;
24240         }
24241         return ret_ref;
24242 }
24243
24244 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24245         LDKPeerHandleError orig_conv;
24246         orig_conv.inner = (void*)(orig & (~1));
24247         orig_conv.is_owned = false;
24248         LDKPeerHandleError ret_var = PeerHandleError_clone(&orig_conv);
24249         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24250         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24251         uint64_t ret_ref = (uint64_t)ret_var.inner;
24252         if (ret_var.is_owned) {
24253                 ret_ref |= 1;
24254         }
24255         return ret_ref;
24256 }
24257
24258 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24259         LDKPeerManager this_obj_conv;
24260         this_obj_conv.inner = (void*)(this_obj & (~1));
24261         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24262         PeerManager_free(this_obj_conv);
24263 }
24264
24265 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerManager_1new(JNIEnv *env, jclass clz, int64_t message_handler, int8_tArray our_node_secret, int8_tArray ephemeral_random_data, int64_t logger, int64_t custom_message_handler) {
24266         LDKMessageHandler message_handler_conv;
24267         message_handler_conv.inner = (void*)(message_handler & (~1));
24268         message_handler_conv.is_owned = (message_handler & 1) || (message_handler == 0);
24269         // Warning: we need a move here but no clone is available for LDKMessageHandler
24270         LDKSecretKey our_node_secret_ref;
24271         CHECK((*env)->GetArrayLength(env, our_node_secret) == 32);
24272         (*env)->GetByteArrayRegion(env, our_node_secret, 0, 32, our_node_secret_ref.bytes);
24273         unsigned char ephemeral_random_data_arr[32];
24274         CHECK((*env)->GetArrayLength(env, ephemeral_random_data) == 32);
24275         (*env)->GetByteArrayRegion(env, ephemeral_random_data, 0, 32, ephemeral_random_data_arr);
24276         unsigned char (*ephemeral_random_data_ref)[32] = &ephemeral_random_data_arr;
24277         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
24278         if (logger_conv.free == LDKLogger_JCalls_free) {
24279                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24280                 LDKLogger_JCalls_cloned(&logger_conv);
24281         }
24282         LDKCustomMessageHandler custom_message_handler_conv = *(LDKCustomMessageHandler*)(((uint64_t)custom_message_handler) & ~1);
24283         if (custom_message_handler_conv.free == LDKCustomMessageHandler_JCalls_free) {
24284                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24285                 LDKCustomMessageHandler_JCalls_cloned(&custom_message_handler_conv);
24286         }
24287         LDKPeerManager ret_var = PeerManager_new(message_handler_conv, our_node_secret_ref, ephemeral_random_data_ref, logger_conv, custom_message_handler_conv);
24288         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24289         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24290         uint64_t ret_ref = (uint64_t)ret_var.inner;
24291         if (ret_var.is_owned) {
24292                 ret_ref |= 1;
24293         }
24294         return ret_ref;
24295 }
24296
24297 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_PeerManager_1get_1peer_1node_1ids(JNIEnv *env, jclass clz, int64_t this_arg) {
24298         LDKPeerManager this_arg_conv;
24299         this_arg_conv.inner = (void*)(this_arg & (~1));
24300         this_arg_conv.is_owned = false;
24301         LDKCVec_PublicKeyZ ret_var = PeerManager_get_peer_node_ids(&this_arg_conv);
24302         jobjectArray ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
24303         ;
24304         for (size_t i = 0; i < ret_var.datalen; i++) {
24305                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 33);
24306                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 33, ret_var.data[i].compressed_form);
24307                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
24308         }
24309         FREE(ret_var.data);
24310         return ret_arr;
24311 }
24312
24313 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) {
24314         LDKPeerManager this_arg_conv;
24315         this_arg_conv.inner = (void*)(this_arg & (~1));
24316         this_arg_conv.is_owned = false;
24317         LDKPublicKey their_node_id_ref;
24318         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
24319         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
24320         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
24321         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
24322                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24323                 LDKSocketDescriptor_JCalls_cloned(&descriptor_conv);
24324         }
24325         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
24326         *ret_conv = PeerManager_new_outbound_connection(&this_arg_conv, their_node_id_ref, descriptor_conv);
24327         return (uint64_t)ret_conv;
24328 }
24329
24330 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerManager_1new_1inbound_1connection(JNIEnv *env, jclass clz, int64_t this_arg, int64_t descriptor) {
24331         LDKPeerManager this_arg_conv;
24332         this_arg_conv.inner = (void*)(this_arg & (~1));
24333         this_arg_conv.is_owned = false;
24334         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
24335         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
24336                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24337                 LDKSocketDescriptor_JCalls_cloned(&descriptor_conv);
24338         }
24339         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
24340         *ret_conv = PeerManager_new_inbound_connection(&this_arg_conv, descriptor_conv);
24341         return (uint64_t)ret_conv;
24342 }
24343
24344 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) {
24345         LDKPeerManager this_arg_conv;
24346         this_arg_conv.inner = (void*)(this_arg & (~1));
24347         this_arg_conv.is_owned = false;
24348         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
24349         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
24350         *ret_conv = PeerManager_write_buffer_space_avail(&this_arg_conv, descriptor_conv);
24351         return (uint64_t)ret_conv;
24352 }
24353
24354 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) {
24355         LDKPeerManager this_arg_conv;
24356         this_arg_conv.inner = (void*)(this_arg & (~1));
24357         this_arg_conv.is_owned = false;
24358         LDKSocketDescriptor* peer_descriptor_conv = (LDKSocketDescriptor*)(((uint64_t)peer_descriptor) & ~1);
24359         LDKu8slice data_ref;
24360         data_ref.datalen = (*env)->GetArrayLength(env, data);
24361         data_ref.data = (*env)->GetByteArrayElements (env, data, NULL);
24362         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
24363         *ret_conv = PeerManager_read_event(&this_arg_conv, peer_descriptor_conv, data_ref);
24364         (*env)->ReleaseByteArrayElements(env, data, (int8_t*)data_ref.data, 0);
24365         return (uint64_t)ret_conv;
24366 }
24367
24368 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1process_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
24369         LDKPeerManager this_arg_conv;
24370         this_arg_conv.inner = (void*)(this_arg & (~1));
24371         this_arg_conv.is_owned = false;
24372         PeerManager_process_events(&this_arg_conv);
24373 }
24374
24375 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1socket_1disconnected(JNIEnv *env, jclass clz, int64_t this_arg, int64_t descriptor) {
24376         LDKPeerManager this_arg_conv;
24377         this_arg_conv.inner = (void*)(this_arg & (~1));
24378         this_arg_conv.is_owned = false;
24379         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
24380         PeerManager_socket_disconnected(&this_arg_conv, descriptor_conv);
24381 }
24382
24383 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) {
24384         LDKPeerManager this_arg_conv;
24385         this_arg_conv.inner = (void*)(this_arg & (~1));
24386         this_arg_conv.is_owned = false;
24387         LDKPublicKey node_id_ref;
24388         CHECK((*env)->GetArrayLength(env, node_id) == 33);
24389         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
24390         PeerManager_disconnect_by_node_id(&this_arg_conv, node_id_ref, no_connection_possible);
24391 }
24392
24393 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1timer_1tick_1occurred(JNIEnv *env, jclass clz, int64_t this_arg) {
24394         LDKPeerManager this_arg_conv;
24395         this_arg_conv.inner = (void*)(this_arg & (~1));
24396         this_arg_conv.is_owned = false;
24397         PeerManager_timer_tick_occurred(&this_arg_conv);
24398 }
24399
24400 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_build_1commitment_1secret(JNIEnv *env, jclass clz, int8_tArray commitment_seed, int64_t idx) {
24401         unsigned char commitment_seed_arr[32];
24402         CHECK((*env)->GetArrayLength(env, commitment_seed) == 32);
24403         (*env)->GetByteArrayRegion(env, commitment_seed, 0, 32, commitment_seed_arr);
24404         unsigned char (*commitment_seed_ref)[32] = &commitment_seed_arr;
24405         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
24406         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, build_commitment_secret(commitment_seed_ref, idx).data);
24407         return ret_arr;
24408 }
24409
24410 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_build_1closing_1transaction(JNIEnv *env, jclass clz, int64_t to_holder_value_sat, int64_t to_counterparty_value_sat, int8_tArray to_holder_script, int8_tArray to_counterparty_script, int64_t funding_outpoint) {
24411         LDKCVec_u8Z to_holder_script_ref;
24412         to_holder_script_ref.datalen = (*env)->GetArrayLength(env, to_holder_script);
24413         to_holder_script_ref.data = MALLOC(to_holder_script_ref.datalen, "LDKCVec_u8Z Bytes");
24414         (*env)->GetByteArrayRegion(env, to_holder_script, 0, to_holder_script_ref.datalen, to_holder_script_ref.data);
24415         LDKCVec_u8Z to_counterparty_script_ref;
24416         to_counterparty_script_ref.datalen = (*env)->GetArrayLength(env, to_counterparty_script);
24417         to_counterparty_script_ref.data = MALLOC(to_counterparty_script_ref.datalen, "LDKCVec_u8Z Bytes");
24418         (*env)->GetByteArrayRegion(env, to_counterparty_script, 0, to_counterparty_script_ref.datalen, to_counterparty_script_ref.data);
24419         LDKOutPoint funding_outpoint_conv;
24420         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
24421         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
24422         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
24423         LDKTransaction ret_var = build_closing_transaction(to_holder_value_sat, to_counterparty_value_sat, to_holder_script_ref, to_counterparty_script_ref, funding_outpoint_conv);
24424         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24425         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24426         Transaction_free(ret_var);
24427         return ret_arr;
24428 }
24429
24430 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) {
24431         LDKPublicKey per_commitment_point_ref;
24432         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
24433         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
24434         unsigned char base_secret_arr[32];
24435         CHECK((*env)->GetArrayLength(env, base_secret) == 32);
24436         (*env)->GetByteArrayRegion(env, base_secret, 0, 32, base_secret_arr);
24437         unsigned char (*base_secret_ref)[32] = &base_secret_arr;
24438         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
24439         *ret_conv = derive_private_key(per_commitment_point_ref, base_secret_ref);
24440         return (uint64_t)ret_conv;
24441 }
24442
24443 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) {
24444         LDKPublicKey per_commitment_point_ref;
24445         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
24446         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
24447         LDKPublicKey base_point_ref;
24448         CHECK((*env)->GetArrayLength(env, base_point) == 33);
24449         (*env)->GetByteArrayRegion(env, base_point, 0, 33, base_point_ref.compressed_form);
24450         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
24451         *ret_conv = derive_public_key(per_commitment_point_ref, base_point_ref);
24452         return (uint64_t)ret_conv;
24453 }
24454
24455 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) {
24456         unsigned char per_commitment_secret_arr[32];
24457         CHECK((*env)->GetArrayLength(env, per_commitment_secret) == 32);
24458         (*env)->GetByteArrayRegion(env, per_commitment_secret, 0, 32, per_commitment_secret_arr);
24459         unsigned char (*per_commitment_secret_ref)[32] = &per_commitment_secret_arr;
24460         unsigned char countersignatory_revocation_base_secret_arr[32];
24461         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base_secret) == 32);
24462         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base_secret, 0, 32, countersignatory_revocation_base_secret_arr);
24463         unsigned char (*countersignatory_revocation_base_secret_ref)[32] = &countersignatory_revocation_base_secret_arr;
24464         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
24465         *ret_conv = derive_private_revocation_key(per_commitment_secret_ref, countersignatory_revocation_base_secret_ref);
24466         return (uint64_t)ret_conv;
24467 }
24468
24469 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) {
24470         LDKPublicKey per_commitment_point_ref;
24471         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
24472         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
24473         LDKPublicKey countersignatory_revocation_base_point_ref;
24474         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base_point) == 33);
24475         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base_point, 0, 33, countersignatory_revocation_base_point_ref.compressed_form);
24476         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
24477         *ret_conv = derive_public_revocation_key(per_commitment_point_ref, countersignatory_revocation_base_point_ref);
24478         return (uint64_t)ret_conv;
24479 }
24480
24481 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24482         LDKTxCreationKeys this_obj_conv;
24483         this_obj_conv.inner = (void*)(this_obj & (~1));
24484         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24485         TxCreationKeys_free(this_obj_conv);
24486 }
24487
24488 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
24489         LDKTxCreationKeys this_ptr_conv;
24490         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24491         this_ptr_conv.is_owned = false;
24492         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
24493         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_per_commitment_point(&this_ptr_conv).compressed_form);
24494         return ret_arr;
24495 }
24496
24497 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
24498         LDKTxCreationKeys this_ptr_conv;
24499         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24500         this_ptr_conv.is_owned = false;
24501         LDKPublicKey val_ref;
24502         CHECK((*env)->GetArrayLength(env, val) == 33);
24503         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
24504         TxCreationKeys_set_per_commitment_point(&this_ptr_conv, val_ref);
24505 }
24506
24507 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1revocation_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
24508         LDKTxCreationKeys this_ptr_conv;
24509         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24510         this_ptr_conv.is_owned = false;
24511         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
24512         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_revocation_key(&this_ptr_conv).compressed_form);
24513         return ret_arr;
24514 }
24515
24516 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1revocation_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
24517         LDKTxCreationKeys this_ptr_conv;
24518         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24519         this_ptr_conv.is_owned = false;
24520         LDKPublicKey val_ref;
24521         CHECK((*env)->GetArrayLength(env, val) == 33);
24522         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
24523         TxCreationKeys_set_revocation_key(&this_ptr_conv, val_ref);
24524 }
24525
24526 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1broadcaster_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
24527         LDKTxCreationKeys this_ptr_conv;
24528         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24529         this_ptr_conv.is_owned = false;
24530         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
24531         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_broadcaster_htlc_key(&this_ptr_conv).compressed_form);
24532         return ret_arr;
24533 }
24534
24535 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1broadcaster_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
24536         LDKTxCreationKeys this_ptr_conv;
24537         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24538         this_ptr_conv.is_owned = false;
24539         LDKPublicKey val_ref;
24540         CHECK((*env)->GetArrayLength(env, val) == 33);
24541         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
24542         TxCreationKeys_set_broadcaster_htlc_key(&this_ptr_conv, val_ref);
24543 }
24544
24545 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1countersignatory_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
24546         LDKTxCreationKeys this_ptr_conv;
24547         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24548         this_ptr_conv.is_owned = false;
24549         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
24550         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_countersignatory_htlc_key(&this_ptr_conv).compressed_form);
24551         return ret_arr;
24552 }
24553
24554 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1countersignatory_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
24555         LDKTxCreationKeys this_ptr_conv;
24556         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24557         this_ptr_conv.is_owned = false;
24558         LDKPublicKey val_ref;
24559         CHECK((*env)->GetArrayLength(env, val) == 33);
24560         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
24561         TxCreationKeys_set_countersignatory_htlc_key(&this_ptr_conv, val_ref);
24562 }
24563
24564 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1broadcaster_1delayed_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
24565         LDKTxCreationKeys this_ptr_conv;
24566         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24567         this_ptr_conv.is_owned = false;
24568         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
24569         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_broadcaster_delayed_payment_key(&this_ptr_conv).compressed_form);
24570         return ret_arr;
24571 }
24572
24573 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) {
24574         LDKTxCreationKeys this_ptr_conv;
24575         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24576         this_ptr_conv.is_owned = false;
24577         LDKPublicKey val_ref;
24578         CHECK((*env)->GetArrayLength(env, val) == 33);
24579         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
24580         TxCreationKeys_set_broadcaster_delayed_payment_key(&this_ptr_conv, val_ref);
24581 }
24582
24583 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) {
24584         LDKPublicKey per_commitment_point_arg_ref;
24585         CHECK((*env)->GetArrayLength(env, per_commitment_point_arg) == 33);
24586         (*env)->GetByteArrayRegion(env, per_commitment_point_arg, 0, 33, per_commitment_point_arg_ref.compressed_form);
24587         LDKPublicKey revocation_key_arg_ref;
24588         CHECK((*env)->GetArrayLength(env, revocation_key_arg) == 33);
24589         (*env)->GetByteArrayRegion(env, revocation_key_arg, 0, 33, revocation_key_arg_ref.compressed_form);
24590         LDKPublicKey broadcaster_htlc_key_arg_ref;
24591         CHECK((*env)->GetArrayLength(env, broadcaster_htlc_key_arg) == 33);
24592         (*env)->GetByteArrayRegion(env, broadcaster_htlc_key_arg, 0, 33, broadcaster_htlc_key_arg_ref.compressed_form);
24593         LDKPublicKey countersignatory_htlc_key_arg_ref;
24594         CHECK((*env)->GetArrayLength(env, countersignatory_htlc_key_arg) == 33);
24595         (*env)->GetByteArrayRegion(env, countersignatory_htlc_key_arg, 0, 33, countersignatory_htlc_key_arg_ref.compressed_form);
24596         LDKPublicKey broadcaster_delayed_payment_key_arg_ref;
24597         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key_arg) == 33);
24598         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key_arg, 0, 33, broadcaster_delayed_payment_key_arg_ref.compressed_form);
24599         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);
24600         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24601         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24602         uint64_t ret_ref = (uint64_t)ret_var.inner;
24603         if (ret_var.is_owned) {
24604                 ret_ref |= 1;
24605         }
24606         return ret_ref;
24607 }
24608
24609 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24610         LDKTxCreationKeys orig_conv;
24611         orig_conv.inner = (void*)(orig & (~1));
24612         orig_conv.is_owned = false;
24613         LDKTxCreationKeys ret_var = TxCreationKeys_clone(&orig_conv);
24614         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24615         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24616         uint64_t ret_ref = (uint64_t)ret_var.inner;
24617         if (ret_var.is_owned) {
24618                 ret_ref |= 1;
24619         }
24620         return ret_ref;
24621 }
24622
24623 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1write(JNIEnv *env, jclass clz, int64_t obj) {
24624         LDKTxCreationKeys obj_conv;
24625         obj_conv.inner = (void*)(obj & (~1));
24626         obj_conv.is_owned = false;
24627         LDKCVec_u8Z ret_var = TxCreationKeys_write(&obj_conv);
24628         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24629         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24630         CVec_u8Z_free(ret_var);
24631         return ret_arr;
24632 }
24633
24634 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24635         LDKu8slice ser_ref;
24636         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24637         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24638         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
24639         *ret_conv = TxCreationKeys_read(ser_ref);
24640         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24641         return (uint64_t)ret_conv;
24642 }
24643
24644 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24645         LDKChannelPublicKeys this_obj_conv;
24646         this_obj_conv.inner = (void*)(this_obj & (~1));
24647         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24648         ChannelPublicKeys_free(this_obj_conv);
24649 }
24650
24651 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
24652         LDKChannelPublicKeys this_ptr_conv;
24653         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24654         this_ptr_conv.is_owned = false;
24655         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
24656         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_funding_pubkey(&this_ptr_conv).compressed_form);
24657         return ret_arr;
24658 }
24659
24660 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
24661         LDKChannelPublicKeys this_ptr_conv;
24662         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24663         this_ptr_conv.is_owned = false;
24664         LDKPublicKey val_ref;
24665         CHECK((*env)->GetArrayLength(env, val) == 33);
24666         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
24667         ChannelPublicKeys_set_funding_pubkey(&this_ptr_conv, val_ref);
24668 }
24669
24670 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
24671         LDKChannelPublicKeys this_ptr_conv;
24672         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24673         this_ptr_conv.is_owned = false;
24674         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
24675         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_revocation_basepoint(&this_ptr_conv).compressed_form);
24676         return ret_arr;
24677 }
24678
24679 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
24680         LDKChannelPublicKeys this_ptr_conv;
24681         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24682         this_ptr_conv.is_owned = false;
24683         LDKPublicKey val_ref;
24684         CHECK((*env)->GetArrayLength(env, val) == 33);
24685         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
24686         ChannelPublicKeys_set_revocation_basepoint(&this_ptr_conv, val_ref);
24687 }
24688
24689 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
24690         LDKChannelPublicKeys this_ptr_conv;
24691         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24692         this_ptr_conv.is_owned = false;
24693         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
24694         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_payment_point(&this_ptr_conv).compressed_form);
24695         return ret_arr;
24696 }
24697
24698 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
24699         LDKChannelPublicKeys this_ptr_conv;
24700         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24701         this_ptr_conv.is_owned = false;
24702         LDKPublicKey val_ref;
24703         CHECK((*env)->GetArrayLength(env, val) == 33);
24704         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
24705         ChannelPublicKeys_set_payment_point(&this_ptr_conv, val_ref);
24706 }
24707
24708 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
24709         LDKChannelPublicKeys this_ptr_conv;
24710         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24711         this_ptr_conv.is_owned = false;
24712         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
24713         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
24714         return ret_arr;
24715 }
24716
24717 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
24718         LDKChannelPublicKeys this_ptr_conv;
24719         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24720         this_ptr_conv.is_owned = false;
24721         LDKPublicKey val_ref;
24722         CHECK((*env)->GetArrayLength(env, val) == 33);
24723         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
24724         ChannelPublicKeys_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
24725 }
24726
24727 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
24728         LDKChannelPublicKeys this_ptr_conv;
24729         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24730         this_ptr_conv.is_owned = false;
24731         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
24732         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_htlc_basepoint(&this_ptr_conv).compressed_form);
24733         return ret_arr;
24734 }
24735
24736 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
24737         LDKChannelPublicKeys this_ptr_conv;
24738         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24739         this_ptr_conv.is_owned = false;
24740         LDKPublicKey val_ref;
24741         CHECK((*env)->GetArrayLength(env, val) == 33);
24742         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
24743         ChannelPublicKeys_set_htlc_basepoint(&this_ptr_conv, val_ref);
24744 }
24745
24746 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) {
24747         LDKPublicKey funding_pubkey_arg_ref;
24748         CHECK((*env)->GetArrayLength(env, funding_pubkey_arg) == 33);
24749         (*env)->GetByteArrayRegion(env, funding_pubkey_arg, 0, 33, funding_pubkey_arg_ref.compressed_form);
24750         LDKPublicKey revocation_basepoint_arg_ref;
24751         CHECK((*env)->GetArrayLength(env, revocation_basepoint_arg) == 33);
24752         (*env)->GetByteArrayRegion(env, revocation_basepoint_arg, 0, 33, revocation_basepoint_arg_ref.compressed_form);
24753         LDKPublicKey payment_point_arg_ref;
24754         CHECK((*env)->GetArrayLength(env, payment_point_arg) == 33);
24755         (*env)->GetByteArrayRegion(env, payment_point_arg, 0, 33, payment_point_arg_ref.compressed_form);
24756         LDKPublicKey delayed_payment_basepoint_arg_ref;
24757         CHECK((*env)->GetArrayLength(env, delayed_payment_basepoint_arg) == 33);
24758         (*env)->GetByteArrayRegion(env, delayed_payment_basepoint_arg, 0, 33, delayed_payment_basepoint_arg_ref.compressed_form);
24759         LDKPublicKey htlc_basepoint_arg_ref;
24760         CHECK((*env)->GetArrayLength(env, htlc_basepoint_arg) == 33);
24761         (*env)->GetByteArrayRegion(env, htlc_basepoint_arg, 0, 33, htlc_basepoint_arg_ref.compressed_form);
24762         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);
24763         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24764         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24765         uint64_t ret_ref = (uint64_t)ret_var.inner;
24766         if (ret_var.is_owned) {
24767                 ret_ref |= 1;
24768         }
24769         return ret_ref;
24770 }
24771
24772 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24773         LDKChannelPublicKeys orig_conv;
24774         orig_conv.inner = (void*)(orig & (~1));
24775         orig_conv.is_owned = false;
24776         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(&orig_conv);
24777         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24778         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24779         uint64_t ret_ref = (uint64_t)ret_var.inner;
24780         if (ret_var.is_owned) {
24781                 ret_ref |= 1;
24782         }
24783         return ret_ref;
24784 }
24785
24786 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1write(JNIEnv *env, jclass clz, int64_t obj) {
24787         LDKChannelPublicKeys obj_conv;
24788         obj_conv.inner = (void*)(obj & (~1));
24789         obj_conv.is_owned = false;
24790         LDKCVec_u8Z ret_var = ChannelPublicKeys_write(&obj_conv);
24791         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24792         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24793         CVec_u8Z_free(ret_var);
24794         return ret_arr;
24795 }
24796
24797 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24798         LDKu8slice ser_ref;
24799         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24800         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24801         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
24802         *ret_conv = ChannelPublicKeys_read(ser_ref);
24803         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24804         return (uint64_t)ret_conv;
24805 }
24806
24807 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_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) {
24808         LDKPublicKey per_commitment_point_ref;
24809         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
24810         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
24811         LDKPublicKey broadcaster_delayed_payment_base_ref;
24812         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_base) == 33);
24813         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_base, 0, 33, broadcaster_delayed_payment_base_ref.compressed_form);
24814         LDKPublicKey broadcaster_htlc_base_ref;
24815         CHECK((*env)->GetArrayLength(env, broadcaster_htlc_base) == 33);
24816         (*env)->GetByteArrayRegion(env, broadcaster_htlc_base, 0, 33, broadcaster_htlc_base_ref.compressed_form);
24817         LDKPublicKey countersignatory_revocation_base_ref;
24818         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base) == 33);
24819         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base, 0, 33, countersignatory_revocation_base_ref.compressed_form);
24820         LDKPublicKey countersignatory_htlc_base_ref;
24821         CHECK((*env)->GetArrayLength(env, countersignatory_htlc_base) == 33);
24822         (*env)->GetByteArrayRegion(env, countersignatory_htlc_base, 0, 33, countersignatory_htlc_base_ref.compressed_form);
24823         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
24824         *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);
24825         return (uint64_t)ret_conv;
24826 }
24827
24828 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) {
24829         LDKPublicKey per_commitment_point_ref;
24830         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
24831         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
24832         LDKChannelPublicKeys broadcaster_keys_conv;
24833         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
24834         broadcaster_keys_conv.is_owned = false;
24835         LDKChannelPublicKeys countersignatory_keys_conv;
24836         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
24837         countersignatory_keys_conv.is_owned = false;
24838         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
24839         *ret_conv = TxCreationKeys_from_channel_static_keys(per_commitment_point_ref, &broadcaster_keys_conv, &countersignatory_keys_conv);
24840         return (uint64_t)ret_conv;
24841 }
24842
24843 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) {
24844         LDKPublicKey revocation_key_ref;
24845         CHECK((*env)->GetArrayLength(env, revocation_key) == 33);
24846         (*env)->GetByteArrayRegion(env, revocation_key, 0, 33, revocation_key_ref.compressed_form);
24847         LDKPublicKey broadcaster_delayed_payment_key_ref;
24848         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key) == 33);
24849         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key, 0, 33, broadcaster_delayed_payment_key_ref.compressed_form);
24850         LDKCVec_u8Z ret_var = get_revokeable_redeemscript(revocation_key_ref, contest_delay, broadcaster_delayed_payment_key_ref);
24851         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24852         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24853         CVec_u8Z_free(ret_var);
24854         return ret_arr;
24855 }
24856
24857 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24858         LDKHTLCOutputInCommitment this_obj_conv;
24859         this_obj_conv.inner = (void*)(this_obj & (~1));
24860         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24861         HTLCOutputInCommitment_free(this_obj_conv);
24862 }
24863
24864 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1offered(JNIEnv *env, jclass clz, int64_t this_ptr) {
24865         LDKHTLCOutputInCommitment this_ptr_conv;
24866         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24867         this_ptr_conv.is_owned = false;
24868         jboolean ret_val = HTLCOutputInCommitment_get_offered(&this_ptr_conv);
24869         return ret_val;
24870 }
24871
24872 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1offered(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
24873         LDKHTLCOutputInCommitment this_ptr_conv;
24874         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24875         this_ptr_conv.is_owned = false;
24876         HTLCOutputInCommitment_set_offered(&this_ptr_conv, val);
24877 }
24878
24879 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
24880         LDKHTLCOutputInCommitment this_ptr_conv;
24881         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24882         this_ptr_conv.is_owned = false;
24883         int64_t ret_val = HTLCOutputInCommitment_get_amount_msat(&this_ptr_conv);
24884         return ret_val;
24885 }
24886
24887 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24888         LDKHTLCOutputInCommitment this_ptr_conv;
24889         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24890         this_ptr_conv.is_owned = false;
24891         HTLCOutputInCommitment_set_amount_msat(&this_ptr_conv, val);
24892 }
24893
24894 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr) {
24895         LDKHTLCOutputInCommitment this_ptr_conv;
24896         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24897         this_ptr_conv.is_owned = false;
24898         int32_t ret_val = HTLCOutputInCommitment_get_cltv_expiry(&this_ptr_conv);
24899         return ret_val;
24900 }
24901
24902 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
24903         LDKHTLCOutputInCommitment this_ptr_conv;
24904         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24905         this_ptr_conv.is_owned = false;
24906         HTLCOutputInCommitment_set_cltv_expiry(&this_ptr_conv, val);
24907 }
24908
24909 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
24910         LDKHTLCOutputInCommitment this_ptr_conv;
24911         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24912         this_ptr_conv.is_owned = false;
24913         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
24914         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *HTLCOutputInCommitment_get_payment_hash(&this_ptr_conv));
24915         return ret_arr;
24916 }
24917
24918 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
24919         LDKHTLCOutputInCommitment this_ptr_conv;
24920         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24921         this_ptr_conv.is_owned = false;
24922         LDKThirtyTwoBytes val_ref;
24923         CHECK((*env)->GetArrayLength(env, val) == 32);
24924         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
24925         HTLCOutputInCommitment_set_payment_hash(&this_ptr_conv, val_ref);
24926 }
24927
24928 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1transaction_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
24929         LDKHTLCOutputInCommitment this_ptr_conv;
24930         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24931         this_ptr_conv.is_owned = false;
24932         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
24933         *ret_copy = HTLCOutputInCommitment_get_transaction_output_index(&this_ptr_conv);
24934         uint64_t ret_ref = (uint64_t)ret_copy;
24935         return ret_ref;
24936 }
24937
24938 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1transaction_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24939         LDKHTLCOutputInCommitment this_ptr_conv;
24940         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24941         this_ptr_conv.is_owned = false;
24942         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(((uint64_t)val) & ~1);
24943         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uint64_t)val) & ~1));
24944         HTLCOutputInCommitment_set_transaction_output_index(&this_ptr_conv, val_conv);
24945 }
24946
24947 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) {
24948         LDKThirtyTwoBytes payment_hash_arg_ref;
24949         CHECK((*env)->GetArrayLength(env, payment_hash_arg) == 32);
24950         (*env)->GetByteArrayRegion(env, payment_hash_arg, 0, 32, payment_hash_arg_ref.data);
24951         LDKCOption_u32Z transaction_output_index_arg_conv = *(LDKCOption_u32Z*)(((uint64_t)transaction_output_index_arg) & ~1);
24952         transaction_output_index_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uint64_t)transaction_output_index_arg) & ~1));
24953         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_new(offered_arg, amount_msat_arg, cltv_expiry_arg, payment_hash_arg_ref, transaction_output_index_arg_conv);
24954         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24955         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24956         uint64_t ret_ref = (uint64_t)ret_var.inner;
24957         if (ret_var.is_owned) {
24958                 ret_ref |= 1;
24959         }
24960         return ret_ref;
24961 }
24962
24963 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24964         LDKHTLCOutputInCommitment orig_conv;
24965         orig_conv.inner = (void*)(orig & (~1));
24966         orig_conv.is_owned = false;
24967         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(&orig_conv);
24968         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24969         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24970         uint64_t ret_ref = (uint64_t)ret_var.inner;
24971         if (ret_var.is_owned) {
24972                 ret_ref |= 1;
24973         }
24974         return ret_ref;
24975 }
24976
24977 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1write(JNIEnv *env, jclass clz, int64_t obj) {
24978         LDKHTLCOutputInCommitment obj_conv;
24979         obj_conv.inner = (void*)(obj & (~1));
24980         obj_conv.is_owned = false;
24981         LDKCVec_u8Z ret_var = HTLCOutputInCommitment_write(&obj_conv);
24982         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24983         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24984         CVec_u8Z_free(ret_var);
24985         return ret_arr;
24986 }
24987
24988 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24989         LDKu8slice ser_ref;
24990         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24991         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24992         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
24993         *ret_conv = HTLCOutputInCommitment_read(ser_ref);
24994         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24995         return (uint64_t)ret_conv;
24996 }
24997
24998 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_get_1htlc_1redeemscript(JNIEnv *env, jclass clz, int64_t htlc, int64_t keys) {
24999         LDKHTLCOutputInCommitment htlc_conv;
25000         htlc_conv.inner = (void*)(htlc & (~1));
25001         htlc_conv.is_owned = false;
25002         LDKTxCreationKeys keys_conv;
25003         keys_conv.inner = (void*)(keys & (~1));
25004         keys_conv.is_owned = false;
25005         LDKCVec_u8Z ret_var = get_htlc_redeemscript(&htlc_conv, &keys_conv);
25006         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
25007         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
25008         CVec_u8Z_free(ret_var);
25009         return ret_arr;
25010 }
25011
25012 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_make_1funding_1redeemscript(JNIEnv *env, jclass clz, int8_tArray broadcaster, int8_tArray countersignatory) {
25013         LDKPublicKey broadcaster_ref;
25014         CHECK((*env)->GetArrayLength(env, broadcaster) == 33);
25015         (*env)->GetByteArrayRegion(env, broadcaster, 0, 33, broadcaster_ref.compressed_form);
25016         LDKPublicKey countersignatory_ref;
25017         CHECK((*env)->GetArrayLength(env, countersignatory) == 33);
25018         (*env)->GetByteArrayRegion(env, countersignatory, 0, 33, countersignatory_ref.compressed_form);
25019         LDKCVec_u8Z ret_var = make_funding_redeemscript(broadcaster_ref, countersignatory_ref);
25020         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
25021         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
25022         CVec_u8Z_free(ret_var);
25023         return ret_arr;
25024 }
25025
25026 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) {
25027         unsigned char commitment_txid_arr[32];
25028         CHECK((*env)->GetArrayLength(env, commitment_txid) == 32);
25029         (*env)->GetByteArrayRegion(env, commitment_txid, 0, 32, commitment_txid_arr);
25030         unsigned char (*commitment_txid_ref)[32] = &commitment_txid_arr;
25031         LDKHTLCOutputInCommitment htlc_conv;
25032         htlc_conv.inner = (void*)(htlc & (~1));
25033         htlc_conv.is_owned = false;
25034         LDKPublicKey broadcaster_delayed_payment_key_ref;
25035         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key) == 33);
25036         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key, 0, 33, broadcaster_delayed_payment_key_ref.compressed_form);
25037         LDKPublicKey revocation_key_ref;
25038         CHECK((*env)->GetArrayLength(env, revocation_key) == 33);
25039         (*env)->GetByteArrayRegion(env, revocation_key, 0, 33, revocation_key_ref.compressed_form);
25040         LDKTransaction ret_var = build_htlc_transaction(commitment_txid_ref, feerate_per_kw, contest_delay, &htlc_conv, broadcaster_delayed_payment_key_ref, revocation_key_ref);
25041         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
25042         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
25043         Transaction_free(ret_var);
25044         return ret_arr;
25045 }
25046
25047 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25048         LDKChannelTransactionParameters this_obj_conv;
25049         this_obj_conv.inner = (void*)(this_obj & (~1));
25050         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25051         ChannelTransactionParameters_free(this_obj_conv);
25052 }
25053
25054 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1holder_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr) {
25055         LDKChannelTransactionParameters this_ptr_conv;
25056         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25057         this_ptr_conv.is_owned = false;
25058         LDKChannelPublicKeys ret_var = ChannelTransactionParameters_get_holder_pubkeys(&this_ptr_conv);
25059         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25060         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25061         uint64_t ret_ref = (uint64_t)ret_var.inner;
25062         if (ret_var.is_owned) {
25063                 ret_ref |= 1;
25064         }
25065         return ret_ref;
25066 }
25067
25068 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1holder_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25069         LDKChannelTransactionParameters this_ptr_conv;
25070         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25071         this_ptr_conv.is_owned = false;
25072         LDKChannelPublicKeys val_conv;
25073         val_conv.inner = (void*)(val & (~1));
25074         val_conv.is_owned = (val & 1) || (val == 0);
25075         val_conv = ChannelPublicKeys_clone(&val_conv);
25076         ChannelTransactionParameters_set_holder_pubkeys(&this_ptr_conv, val_conv);
25077 }
25078
25079 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1holder_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
25080         LDKChannelTransactionParameters this_ptr_conv;
25081         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25082         this_ptr_conv.is_owned = false;
25083         int16_t ret_val = ChannelTransactionParameters_get_holder_selected_contest_delay(&this_ptr_conv);
25084         return ret_val;
25085 }
25086
25087 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) {
25088         LDKChannelTransactionParameters this_ptr_conv;
25089         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25090         this_ptr_conv.is_owned = false;
25091         ChannelTransactionParameters_set_holder_selected_contest_delay(&this_ptr_conv, val);
25092 }
25093
25094 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1is_1outbound_1from_1holder(JNIEnv *env, jclass clz, int64_t this_ptr) {
25095         LDKChannelTransactionParameters this_ptr_conv;
25096         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25097         this_ptr_conv.is_owned = false;
25098         jboolean ret_val = ChannelTransactionParameters_get_is_outbound_from_holder(&this_ptr_conv);
25099         return ret_val;
25100 }
25101
25102 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1is_1outbound_1from_1holder(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
25103         LDKChannelTransactionParameters this_ptr_conv;
25104         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25105         this_ptr_conv.is_owned = false;
25106         ChannelTransactionParameters_set_is_outbound_from_holder(&this_ptr_conv, val);
25107 }
25108
25109 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1counterparty_1parameters(JNIEnv *env, jclass clz, int64_t this_ptr) {
25110         LDKChannelTransactionParameters this_ptr_conv;
25111         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25112         this_ptr_conv.is_owned = false;
25113         LDKCounterpartyChannelTransactionParameters ret_var = ChannelTransactionParameters_get_counterparty_parameters(&this_ptr_conv);
25114         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25115         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25116         uint64_t ret_ref = (uint64_t)ret_var.inner;
25117         if (ret_var.is_owned) {
25118                 ret_ref |= 1;
25119         }
25120         return ret_ref;
25121 }
25122
25123 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1counterparty_1parameters(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25124         LDKChannelTransactionParameters this_ptr_conv;
25125         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25126         this_ptr_conv.is_owned = false;
25127         LDKCounterpartyChannelTransactionParameters val_conv;
25128         val_conv.inner = (void*)(val & (~1));
25129         val_conv.is_owned = (val & 1) || (val == 0);
25130         val_conv = CounterpartyChannelTransactionParameters_clone(&val_conv);
25131         ChannelTransactionParameters_set_counterparty_parameters(&this_ptr_conv, val_conv);
25132 }
25133
25134 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
25135         LDKChannelTransactionParameters this_ptr_conv;
25136         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25137         this_ptr_conv.is_owned = false;
25138         LDKOutPoint ret_var = ChannelTransactionParameters_get_funding_outpoint(&this_ptr_conv);
25139         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25140         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25141         uint64_t ret_ref = (uint64_t)ret_var.inner;
25142         if (ret_var.is_owned) {
25143                 ret_ref |= 1;
25144         }
25145         return ret_ref;
25146 }
25147
25148 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25149         LDKChannelTransactionParameters this_ptr_conv;
25150         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25151         this_ptr_conv.is_owned = false;
25152         LDKOutPoint val_conv;
25153         val_conv.inner = (void*)(val & (~1));
25154         val_conv.is_owned = (val & 1) || (val == 0);
25155         val_conv = OutPoint_clone(&val_conv);
25156         ChannelTransactionParameters_set_funding_outpoint(&this_ptr_conv, val_conv);
25157 }
25158
25159 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) {
25160         LDKChannelPublicKeys holder_pubkeys_arg_conv;
25161         holder_pubkeys_arg_conv.inner = (void*)(holder_pubkeys_arg & (~1));
25162         holder_pubkeys_arg_conv.is_owned = (holder_pubkeys_arg & 1) || (holder_pubkeys_arg == 0);
25163         holder_pubkeys_arg_conv = ChannelPublicKeys_clone(&holder_pubkeys_arg_conv);
25164         LDKCounterpartyChannelTransactionParameters counterparty_parameters_arg_conv;
25165         counterparty_parameters_arg_conv.inner = (void*)(counterparty_parameters_arg & (~1));
25166         counterparty_parameters_arg_conv.is_owned = (counterparty_parameters_arg & 1) || (counterparty_parameters_arg == 0);
25167         counterparty_parameters_arg_conv = CounterpartyChannelTransactionParameters_clone(&counterparty_parameters_arg_conv);
25168         LDKOutPoint funding_outpoint_arg_conv;
25169         funding_outpoint_arg_conv.inner = (void*)(funding_outpoint_arg & (~1));
25170         funding_outpoint_arg_conv.is_owned = (funding_outpoint_arg & 1) || (funding_outpoint_arg == 0);
25171         funding_outpoint_arg_conv = OutPoint_clone(&funding_outpoint_arg_conv);
25172         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);
25173         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25174         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25175         uint64_t ret_ref = (uint64_t)ret_var.inner;
25176         if (ret_var.is_owned) {
25177                 ret_ref |= 1;
25178         }
25179         return ret_ref;
25180 }
25181
25182 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25183         LDKChannelTransactionParameters orig_conv;
25184         orig_conv.inner = (void*)(orig & (~1));
25185         orig_conv.is_owned = false;
25186         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(&orig_conv);
25187         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25188         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25189         uint64_t ret_ref = (uint64_t)ret_var.inner;
25190         if (ret_var.is_owned) {
25191                 ret_ref |= 1;
25192         }
25193         return ret_ref;
25194 }
25195
25196 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25197         LDKCounterpartyChannelTransactionParameters this_obj_conv;
25198         this_obj_conv.inner = (void*)(this_obj & (~1));
25199         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25200         CounterpartyChannelTransactionParameters_free(this_obj_conv);
25201 }
25202
25203 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1get_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr) {
25204         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
25205         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25206         this_ptr_conv.is_owned = false;
25207         LDKChannelPublicKeys ret_var = CounterpartyChannelTransactionParameters_get_pubkeys(&this_ptr_conv);
25208         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25209         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25210         uint64_t ret_ref = (uint64_t)ret_var.inner;
25211         if (ret_var.is_owned) {
25212                 ret_ref |= 1;
25213         }
25214         return ret_ref;
25215 }
25216
25217 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1set_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25218         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
25219         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25220         this_ptr_conv.is_owned = false;
25221         LDKChannelPublicKeys val_conv;
25222         val_conv.inner = (void*)(val & (~1));
25223         val_conv.is_owned = (val & 1) || (val == 0);
25224         val_conv = ChannelPublicKeys_clone(&val_conv);
25225         CounterpartyChannelTransactionParameters_set_pubkeys(&this_ptr_conv, val_conv);
25226 }
25227
25228 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1get_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
25229         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
25230         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25231         this_ptr_conv.is_owned = false;
25232         int16_t ret_val = CounterpartyChannelTransactionParameters_get_selected_contest_delay(&this_ptr_conv);
25233         return ret_val;
25234 }
25235
25236 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1set_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
25237         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
25238         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25239         this_ptr_conv.is_owned = false;
25240         CounterpartyChannelTransactionParameters_set_selected_contest_delay(&this_ptr_conv, val);
25241 }
25242
25243 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) {
25244         LDKChannelPublicKeys pubkeys_arg_conv;
25245         pubkeys_arg_conv.inner = (void*)(pubkeys_arg & (~1));
25246         pubkeys_arg_conv.is_owned = (pubkeys_arg & 1) || (pubkeys_arg == 0);
25247         pubkeys_arg_conv = ChannelPublicKeys_clone(&pubkeys_arg_conv);
25248         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_new(pubkeys_arg_conv, selected_contest_delay_arg);
25249         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25250         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25251         uint64_t ret_ref = (uint64_t)ret_var.inner;
25252         if (ret_var.is_owned) {
25253                 ret_ref |= 1;
25254         }
25255         return ret_ref;
25256 }
25257
25258 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25259         LDKCounterpartyChannelTransactionParameters orig_conv;
25260         orig_conv.inner = (void*)(orig & (~1));
25261         orig_conv.is_owned = false;
25262         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(&orig_conv);
25263         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25264         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25265         uint64_t ret_ref = (uint64_t)ret_var.inner;
25266         if (ret_var.is_owned) {
25267                 ret_ref |= 1;
25268         }
25269         return ret_ref;
25270 }
25271
25272 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1is_1populated(JNIEnv *env, jclass clz, int64_t this_arg) {
25273         LDKChannelTransactionParameters this_arg_conv;
25274         this_arg_conv.inner = (void*)(this_arg & (~1));
25275         this_arg_conv.is_owned = false;
25276         jboolean ret_val = ChannelTransactionParameters_is_populated(&this_arg_conv);
25277         return ret_val;
25278 }
25279
25280 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1as_1holder_1broadcastable(JNIEnv *env, jclass clz, int64_t this_arg) {
25281         LDKChannelTransactionParameters this_arg_conv;
25282         this_arg_conv.inner = (void*)(this_arg & (~1));
25283         this_arg_conv.is_owned = false;
25284         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_holder_broadcastable(&this_arg_conv);
25285         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25286         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25287         uint64_t ret_ref = (uint64_t)ret_var.inner;
25288         if (ret_var.is_owned) {
25289                 ret_ref |= 1;
25290         }
25291         return ret_ref;
25292 }
25293
25294 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1as_1counterparty_1broadcastable(JNIEnv *env, jclass clz, int64_t this_arg) {
25295         LDKChannelTransactionParameters this_arg_conv;
25296         this_arg_conv.inner = (void*)(this_arg & (~1));
25297         this_arg_conv.is_owned = false;
25298         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_counterparty_broadcastable(&this_arg_conv);
25299         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25300         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25301         uint64_t ret_ref = (uint64_t)ret_var.inner;
25302         if (ret_var.is_owned) {
25303                 ret_ref |= 1;
25304         }
25305         return ret_ref;
25306 }
25307
25308 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
25309         LDKCounterpartyChannelTransactionParameters obj_conv;
25310         obj_conv.inner = (void*)(obj & (~1));
25311         obj_conv.is_owned = false;
25312         LDKCVec_u8Z ret_var = CounterpartyChannelTransactionParameters_write(&obj_conv);
25313         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
25314         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
25315         CVec_u8Z_free(ret_var);
25316         return ret_arr;
25317 }
25318
25319 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
25320         LDKu8slice ser_ref;
25321         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
25322         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
25323         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
25324         *ret_conv = CounterpartyChannelTransactionParameters_read(ser_ref);
25325         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
25326         return (uint64_t)ret_conv;
25327 }
25328
25329 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
25330         LDKChannelTransactionParameters obj_conv;
25331         obj_conv.inner = (void*)(obj & (~1));
25332         obj_conv.is_owned = false;
25333         LDKCVec_u8Z ret_var = ChannelTransactionParameters_write(&obj_conv);
25334         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
25335         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
25336         CVec_u8Z_free(ret_var);
25337         return ret_arr;
25338 }
25339
25340 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
25341         LDKu8slice ser_ref;
25342         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
25343         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
25344         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
25345         *ret_conv = ChannelTransactionParameters_read(ser_ref);
25346         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
25347         return (uint64_t)ret_conv;
25348 }
25349
25350 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25351         LDKDirectedChannelTransactionParameters this_obj_conv;
25352         this_obj_conv.inner = (void*)(this_obj & (~1));
25353         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25354         DirectedChannelTransactionParameters_free(this_obj_conv);
25355 }
25356
25357 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1broadcaster_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
25358         LDKDirectedChannelTransactionParameters this_arg_conv;
25359         this_arg_conv.inner = (void*)(this_arg & (~1));
25360         this_arg_conv.is_owned = false;
25361         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_broadcaster_pubkeys(&this_arg_conv);
25362         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25363         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25364         uint64_t ret_ref = (uint64_t)ret_var.inner;
25365         if (ret_var.is_owned) {
25366                 ret_ref |= 1;
25367         }
25368         return ret_ref;
25369 }
25370
25371 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1countersignatory_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
25372         LDKDirectedChannelTransactionParameters this_arg_conv;
25373         this_arg_conv.inner = (void*)(this_arg & (~1));
25374         this_arg_conv.is_owned = false;
25375         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_countersignatory_pubkeys(&this_arg_conv);
25376         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25377         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25378         uint64_t ret_ref = (uint64_t)ret_var.inner;
25379         if (ret_var.is_owned) {
25380                 ret_ref |= 1;
25381         }
25382         return ret_ref;
25383 }
25384
25385 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
25386         LDKDirectedChannelTransactionParameters this_arg_conv;
25387         this_arg_conv.inner = (void*)(this_arg & (~1));
25388         this_arg_conv.is_owned = false;
25389         int16_t ret_val = DirectedChannelTransactionParameters_contest_delay(&this_arg_conv);
25390         return ret_val;
25391 }
25392
25393 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_arg) {
25394         LDKDirectedChannelTransactionParameters this_arg_conv;
25395         this_arg_conv.inner = (void*)(this_arg & (~1));
25396         this_arg_conv.is_owned = false;
25397         jboolean ret_val = DirectedChannelTransactionParameters_is_outbound(&this_arg_conv);
25398         return ret_val;
25399 }
25400
25401 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_arg) {
25402         LDKDirectedChannelTransactionParameters this_arg_conv;
25403         this_arg_conv.inner = (void*)(this_arg & (~1));
25404         this_arg_conv.is_owned = false;
25405         LDKOutPoint ret_var = DirectedChannelTransactionParameters_funding_outpoint(&this_arg_conv);
25406         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25407         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25408         uint64_t ret_ref = (uint64_t)ret_var.inner;
25409         if (ret_var.is_owned) {
25410                 ret_ref |= 1;
25411         }
25412         return ret_ref;
25413 }
25414
25415 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25416         LDKHolderCommitmentTransaction this_obj_conv;
25417         this_obj_conv.inner = (void*)(this_obj & (~1));
25418         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25419         HolderCommitmentTransaction_free(this_obj_conv);
25420 }
25421
25422 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1get_1counterparty_1sig(JNIEnv *env, jclass clz, int64_t this_ptr) {
25423         LDKHolderCommitmentTransaction this_ptr_conv;
25424         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25425         this_ptr_conv.is_owned = false;
25426         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
25427         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, HolderCommitmentTransaction_get_counterparty_sig(&this_ptr_conv).compact_form);
25428         return ret_arr;
25429 }
25430
25431 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1counterparty_1sig(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
25432         LDKHolderCommitmentTransaction this_ptr_conv;
25433         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25434         this_ptr_conv.is_owned = false;
25435         LDKSignature val_ref;
25436         CHECK((*env)->GetArrayLength(env, val) == 64);
25437         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
25438         HolderCommitmentTransaction_set_counterparty_sig(&this_ptr_conv, val_ref);
25439 }
25440
25441 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1counterparty_1htlc_1sigs(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
25442         LDKHolderCommitmentTransaction this_ptr_conv;
25443         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25444         this_ptr_conv.is_owned = false;
25445         LDKCVec_SignatureZ val_constr;
25446         val_constr.datalen = (*env)->GetArrayLength(env, val);
25447         if (val_constr.datalen > 0)
25448                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
25449         else
25450                 val_constr.data = NULL;
25451         for (size_t i = 0; i < val_constr.datalen; i++) {
25452                 int8_tArray val_conv_8 = (*env)->GetObjectArrayElement(env, val, i);
25453                 LDKSignature val_conv_8_ref;
25454                 CHECK((*env)->GetArrayLength(env, val_conv_8) == 64);
25455                 (*env)->GetByteArrayRegion(env, val_conv_8, 0, 64, val_conv_8_ref.compact_form);
25456                 val_constr.data[i] = val_conv_8_ref;
25457         }
25458         HolderCommitmentTransaction_set_counterparty_htlc_sigs(&this_ptr_conv, val_constr);
25459 }
25460
25461 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25462         LDKHolderCommitmentTransaction orig_conv;
25463         orig_conv.inner = (void*)(orig & (~1));
25464         orig_conv.is_owned = false;
25465         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(&orig_conv);
25466         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25467         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25468         uint64_t ret_ref = (uint64_t)ret_var.inner;
25469         if (ret_var.is_owned) {
25470                 ret_ref |= 1;
25471         }
25472         return ret_ref;
25473 }
25474
25475 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
25476         LDKHolderCommitmentTransaction obj_conv;
25477         obj_conv.inner = (void*)(obj & (~1));
25478         obj_conv.is_owned = false;
25479         LDKCVec_u8Z ret_var = HolderCommitmentTransaction_write(&obj_conv);
25480         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
25481         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
25482         CVec_u8Z_free(ret_var);
25483         return ret_arr;
25484 }
25485
25486 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
25487         LDKu8slice ser_ref;
25488         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
25489         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
25490         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
25491         *ret_conv = HolderCommitmentTransaction_read(ser_ref);
25492         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
25493         return (uint64_t)ret_conv;
25494 }
25495
25496 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) {
25497         LDKCommitmentTransaction commitment_tx_conv;
25498         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
25499         commitment_tx_conv.is_owned = (commitment_tx & 1) || (commitment_tx == 0);
25500         commitment_tx_conv = CommitmentTransaction_clone(&commitment_tx_conv);
25501         LDKSignature counterparty_sig_ref;
25502         CHECK((*env)->GetArrayLength(env, counterparty_sig) == 64);
25503         (*env)->GetByteArrayRegion(env, counterparty_sig, 0, 64, counterparty_sig_ref.compact_form);
25504         LDKCVec_SignatureZ counterparty_htlc_sigs_constr;
25505         counterparty_htlc_sigs_constr.datalen = (*env)->GetArrayLength(env, counterparty_htlc_sigs);
25506         if (counterparty_htlc_sigs_constr.datalen > 0)
25507                 counterparty_htlc_sigs_constr.data = MALLOC(counterparty_htlc_sigs_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
25508         else
25509                 counterparty_htlc_sigs_constr.data = NULL;
25510         for (size_t i = 0; i < counterparty_htlc_sigs_constr.datalen; i++) {
25511                 int8_tArray counterparty_htlc_sigs_conv_8 = (*env)->GetObjectArrayElement(env, counterparty_htlc_sigs, i);
25512                 LDKSignature counterparty_htlc_sigs_conv_8_ref;
25513                 CHECK((*env)->GetArrayLength(env, counterparty_htlc_sigs_conv_8) == 64);
25514                 (*env)->GetByteArrayRegion(env, counterparty_htlc_sigs_conv_8, 0, 64, counterparty_htlc_sigs_conv_8_ref.compact_form);
25515                 counterparty_htlc_sigs_constr.data[i] = counterparty_htlc_sigs_conv_8_ref;
25516         }
25517         LDKPublicKey holder_funding_key_ref;
25518         CHECK((*env)->GetArrayLength(env, holder_funding_key) == 33);
25519         (*env)->GetByteArrayRegion(env, holder_funding_key, 0, 33, holder_funding_key_ref.compressed_form);
25520         LDKPublicKey counterparty_funding_key_ref;
25521         CHECK((*env)->GetArrayLength(env, counterparty_funding_key) == 33);
25522         (*env)->GetByteArrayRegion(env, counterparty_funding_key, 0, 33, counterparty_funding_key_ref.compressed_form);
25523         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_new(commitment_tx_conv, counterparty_sig_ref, counterparty_htlc_sigs_constr, holder_funding_key_ref, counterparty_funding_key_ref);
25524         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25525         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25526         uint64_t ret_ref = (uint64_t)ret_var.inner;
25527         if (ret_var.is_owned) {
25528                 ret_ref |= 1;
25529         }
25530         return ret_ref;
25531 }
25532
25533 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25534         LDKBuiltCommitmentTransaction this_obj_conv;
25535         this_obj_conv.inner = (void*)(this_obj & (~1));
25536         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25537         BuiltCommitmentTransaction_free(this_obj_conv);
25538 }
25539
25540 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1get_1transaction(JNIEnv *env, jclass clz, int64_t this_ptr) {
25541         LDKBuiltCommitmentTransaction this_ptr_conv;
25542         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25543         this_ptr_conv.is_owned = false;
25544         LDKTransaction ret_var = BuiltCommitmentTransaction_get_transaction(&this_ptr_conv);
25545         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
25546         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
25547         Transaction_free(ret_var);
25548         return ret_arr;
25549 }
25550
25551 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1set_1transaction(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
25552         LDKBuiltCommitmentTransaction this_ptr_conv;
25553         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25554         this_ptr_conv.is_owned = false;
25555         LDKTransaction val_ref;
25556         val_ref.datalen = (*env)->GetArrayLength(env, val);
25557         val_ref.data = MALLOC(val_ref.datalen, "LDKTransaction Bytes");
25558         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
25559         val_ref.data_is_owned = true;
25560         BuiltCommitmentTransaction_set_transaction(&this_ptr_conv, val_ref);
25561 }
25562
25563 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1get_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
25564         LDKBuiltCommitmentTransaction this_ptr_conv;
25565         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25566         this_ptr_conv.is_owned = false;
25567         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
25568         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *BuiltCommitmentTransaction_get_txid(&this_ptr_conv));
25569         return ret_arr;
25570 }
25571
25572 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1set_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
25573         LDKBuiltCommitmentTransaction this_ptr_conv;
25574         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25575         this_ptr_conv.is_owned = false;
25576         LDKThirtyTwoBytes val_ref;
25577         CHECK((*env)->GetArrayLength(env, val) == 32);
25578         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
25579         BuiltCommitmentTransaction_set_txid(&this_ptr_conv, val_ref);
25580 }
25581
25582 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1new(JNIEnv *env, jclass clz, int8_tArray transaction_arg, int8_tArray txid_arg) {
25583         LDKTransaction transaction_arg_ref;
25584         transaction_arg_ref.datalen = (*env)->GetArrayLength(env, transaction_arg);
25585         transaction_arg_ref.data = MALLOC(transaction_arg_ref.datalen, "LDKTransaction Bytes");
25586         (*env)->GetByteArrayRegion(env, transaction_arg, 0, transaction_arg_ref.datalen, transaction_arg_ref.data);
25587         transaction_arg_ref.data_is_owned = true;
25588         LDKThirtyTwoBytes txid_arg_ref;
25589         CHECK((*env)->GetArrayLength(env, txid_arg) == 32);
25590         (*env)->GetByteArrayRegion(env, txid_arg, 0, 32, txid_arg_ref.data);
25591         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_new(transaction_arg_ref, txid_arg_ref);
25592         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25593         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25594         uint64_t ret_ref = (uint64_t)ret_var.inner;
25595         if (ret_var.is_owned) {
25596                 ret_ref |= 1;
25597         }
25598         return ret_ref;
25599 }
25600
25601 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25602         LDKBuiltCommitmentTransaction orig_conv;
25603         orig_conv.inner = (void*)(orig & (~1));
25604         orig_conv.is_owned = false;
25605         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(&orig_conv);
25606         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25607         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25608         uint64_t ret_ref = (uint64_t)ret_var.inner;
25609         if (ret_var.is_owned) {
25610                 ret_ref |= 1;
25611         }
25612         return ret_ref;
25613 }
25614
25615 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
25616         LDKBuiltCommitmentTransaction obj_conv;
25617         obj_conv.inner = (void*)(obj & (~1));
25618         obj_conv.is_owned = false;
25619         LDKCVec_u8Z ret_var = BuiltCommitmentTransaction_write(&obj_conv);
25620         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
25621         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
25622         CVec_u8Z_free(ret_var);
25623         return ret_arr;
25624 }
25625
25626 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
25627         LDKu8slice ser_ref;
25628         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
25629         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
25630         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
25631         *ret_conv = BuiltCommitmentTransaction_read(ser_ref);
25632         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
25633         return (uint64_t)ret_conv;
25634 }
25635
25636 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) {
25637         LDKBuiltCommitmentTransaction this_arg_conv;
25638         this_arg_conv.inner = (void*)(this_arg & (~1));
25639         this_arg_conv.is_owned = false;
25640         LDKu8slice funding_redeemscript_ref;
25641         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
25642         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
25643         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
25644         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, BuiltCommitmentTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data);
25645         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
25646         return ret_arr;
25647 }
25648
25649 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) {
25650         LDKBuiltCommitmentTransaction this_arg_conv;
25651         this_arg_conv.inner = (void*)(this_arg & (~1));
25652         this_arg_conv.is_owned = false;
25653         unsigned char funding_key_arr[32];
25654         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
25655         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_arr);
25656         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
25657         LDKu8slice funding_redeemscript_ref;
25658         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
25659         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
25660         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
25661         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, BuiltCommitmentTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form);
25662         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
25663         return ret_arr;
25664 }
25665
25666 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25667         LDKClosingTransaction this_obj_conv;
25668         this_obj_conv.inner = (void*)(this_obj & (~1));
25669         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25670         ClosingTransaction_free(this_obj_conv);
25671 }
25672
25673 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1new(JNIEnv *env, jclass clz, int64_t to_holder_value_sat, int64_t to_counterparty_value_sat, int8_tArray to_holder_script, int8_tArray to_counterparty_script, int64_t funding_outpoint) {
25674         LDKCVec_u8Z to_holder_script_ref;
25675         to_holder_script_ref.datalen = (*env)->GetArrayLength(env, to_holder_script);
25676         to_holder_script_ref.data = MALLOC(to_holder_script_ref.datalen, "LDKCVec_u8Z Bytes");
25677         (*env)->GetByteArrayRegion(env, to_holder_script, 0, to_holder_script_ref.datalen, to_holder_script_ref.data);
25678         LDKCVec_u8Z to_counterparty_script_ref;
25679         to_counterparty_script_ref.datalen = (*env)->GetArrayLength(env, to_counterparty_script);
25680         to_counterparty_script_ref.data = MALLOC(to_counterparty_script_ref.datalen, "LDKCVec_u8Z Bytes");
25681         (*env)->GetByteArrayRegion(env, to_counterparty_script, 0, to_counterparty_script_ref.datalen, to_counterparty_script_ref.data);
25682         LDKOutPoint funding_outpoint_conv;
25683         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
25684         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
25685         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
25686         LDKClosingTransaction ret_var = ClosingTransaction_new(to_holder_value_sat, to_counterparty_value_sat, to_holder_script_ref, to_counterparty_script_ref, funding_outpoint_conv);
25687         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25688         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25689         uint64_t ret_ref = (uint64_t)ret_var.inner;
25690         if (ret_var.is_owned) {
25691                 ret_ref |= 1;
25692         }
25693         return ret_ref;
25694 }
25695
25696 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1trust(JNIEnv *env, jclass clz, int64_t this_arg) {
25697         LDKClosingTransaction this_arg_conv;
25698         this_arg_conv.inner = (void*)(this_arg & (~1));
25699         this_arg_conv.is_owned = false;
25700         LDKTrustedClosingTransaction ret_var = ClosingTransaction_trust(&this_arg_conv);
25701         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25702         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25703         uint64_t ret_ref = (uint64_t)ret_var.inner;
25704         if (ret_var.is_owned) {
25705                 ret_ref |= 1;
25706         }
25707         return ret_ref;
25708 }
25709
25710 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1verify(JNIEnv *env, jclass clz, int64_t this_arg, int64_t funding_outpoint) {
25711         LDKClosingTransaction this_arg_conv;
25712         this_arg_conv.inner = (void*)(this_arg & (~1));
25713         this_arg_conv.is_owned = false;
25714         LDKOutPoint funding_outpoint_conv;
25715         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
25716         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
25717         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
25718         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
25719         *ret_conv = ClosingTransaction_verify(&this_arg_conv, funding_outpoint_conv);
25720         return (uint64_t)ret_conv;
25721 }
25722
25723 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1holder_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
25724         LDKClosingTransaction this_arg_conv;
25725         this_arg_conv.inner = (void*)(this_arg & (~1));
25726         this_arg_conv.is_owned = false;
25727         int64_t ret_val = ClosingTransaction_to_holder_value_sat(&this_arg_conv);
25728         return ret_val;
25729 }
25730
25731 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1counterparty_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
25732         LDKClosingTransaction this_arg_conv;
25733         this_arg_conv.inner = (void*)(this_arg & (~1));
25734         this_arg_conv.is_owned = false;
25735         int64_t ret_val = ClosingTransaction_to_counterparty_value_sat(&this_arg_conv);
25736         return ret_val;
25737 }
25738
25739 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1holder_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
25740         LDKClosingTransaction this_arg_conv;
25741         this_arg_conv.inner = (void*)(this_arg & (~1));
25742         this_arg_conv.is_owned = false;
25743         LDKu8slice ret_var = ClosingTransaction_to_holder_script(&this_arg_conv);
25744         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
25745         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
25746         return ret_arr;
25747 }
25748
25749 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1counterparty_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
25750         LDKClosingTransaction this_arg_conv;
25751         this_arg_conv.inner = (void*)(this_arg & (~1));
25752         this_arg_conv.is_owned = false;
25753         LDKu8slice ret_var = ClosingTransaction_to_counterparty_script(&this_arg_conv);
25754         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
25755         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
25756         return ret_arr;
25757 }
25758
25759 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TrustedClosingTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25760         LDKTrustedClosingTransaction this_obj_conv;
25761         this_obj_conv.inner = (void*)(this_obj & (~1));
25762         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25763         TrustedClosingTransaction_free(this_obj_conv);
25764 }
25765
25766 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TrustedClosingTransaction_1built_1transaction(JNIEnv *env, jclass clz, int64_t this_arg) {
25767         LDKTrustedClosingTransaction this_arg_conv;
25768         this_arg_conv.inner = (void*)(this_arg & (~1));
25769         this_arg_conv.is_owned = false;
25770         LDKTransaction ret_var = TrustedClosingTransaction_built_transaction(&this_arg_conv);
25771         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
25772         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
25773         Transaction_free(ret_var);
25774         return ret_arr;
25775 }
25776
25777 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TrustedClosingTransaction_1get_1sighash_1all(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray funding_redeemscript, int64_t channel_value_satoshis) {
25778         LDKTrustedClosingTransaction this_arg_conv;
25779         this_arg_conv.inner = (void*)(this_arg & (~1));
25780         this_arg_conv.is_owned = false;
25781         LDKu8slice funding_redeemscript_ref;
25782         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
25783         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
25784         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
25785         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, TrustedClosingTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data);
25786         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
25787         return ret_arr;
25788 }
25789
25790 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TrustedClosingTransaction_1sign(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray funding_key, int8_tArray funding_redeemscript, int64_t channel_value_satoshis) {
25791         LDKTrustedClosingTransaction this_arg_conv;
25792         this_arg_conv.inner = (void*)(this_arg & (~1));
25793         this_arg_conv.is_owned = false;
25794         unsigned char funding_key_arr[32];
25795         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
25796         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_arr);
25797         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
25798         LDKu8slice funding_redeemscript_ref;
25799         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
25800         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
25801         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
25802         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, TrustedClosingTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form);
25803         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
25804         return ret_arr;
25805 }
25806
25807 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25808         LDKCommitmentTransaction this_obj_conv;
25809         this_obj_conv.inner = (void*)(this_obj & (~1));
25810         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25811         CommitmentTransaction_free(this_obj_conv);
25812 }
25813
25814 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25815         LDKCommitmentTransaction orig_conv;
25816         orig_conv.inner = (void*)(orig & (~1));
25817         orig_conv.is_owned = false;
25818         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(&orig_conv);
25819         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25820         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25821         uint64_t ret_ref = (uint64_t)ret_var.inner;
25822         if (ret_var.is_owned) {
25823                 ret_ref |= 1;
25824         }
25825         return ret_ref;
25826 }
25827
25828 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
25829         LDKCommitmentTransaction obj_conv;
25830         obj_conv.inner = (void*)(obj & (~1));
25831         obj_conv.is_owned = false;
25832         LDKCVec_u8Z ret_var = CommitmentTransaction_write(&obj_conv);
25833         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
25834         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
25835         CVec_u8Z_free(ret_var);
25836         return ret_arr;
25837 }
25838
25839 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
25840         LDKu8slice ser_ref;
25841         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
25842         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
25843         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
25844         *ret_conv = CommitmentTransaction_read(ser_ref);
25845         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
25846         return (uint64_t)ret_conv;
25847 }
25848
25849 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_arg) {
25850         LDKCommitmentTransaction this_arg_conv;
25851         this_arg_conv.inner = (void*)(this_arg & (~1));
25852         this_arg_conv.is_owned = false;
25853         int64_t ret_val = CommitmentTransaction_commitment_number(&this_arg_conv);
25854         return ret_val;
25855 }
25856
25857 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1to_1broadcaster_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
25858         LDKCommitmentTransaction this_arg_conv;
25859         this_arg_conv.inner = (void*)(this_arg & (~1));
25860         this_arg_conv.is_owned = false;
25861         int64_t ret_val = CommitmentTransaction_to_broadcaster_value_sat(&this_arg_conv);
25862         return ret_val;
25863 }
25864
25865 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1to_1countersignatory_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
25866         LDKCommitmentTransaction this_arg_conv;
25867         this_arg_conv.inner = (void*)(this_arg & (~1));
25868         this_arg_conv.is_owned = false;
25869         int64_t ret_val = CommitmentTransaction_to_countersignatory_value_sat(&this_arg_conv);
25870         return ret_val;
25871 }
25872
25873 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_arg) {
25874         LDKCommitmentTransaction this_arg_conv;
25875         this_arg_conv.inner = (void*)(this_arg & (~1));
25876         this_arg_conv.is_owned = false;
25877         int32_t ret_val = CommitmentTransaction_feerate_per_kw(&this_arg_conv);
25878         return ret_val;
25879 }
25880
25881 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1trust(JNIEnv *env, jclass clz, int64_t this_arg) {
25882         LDKCommitmentTransaction this_arg_conv;
25883         this_arg_conv.inner = (void*)(this_arg & (~1));
25884         this_arg_conv.is_owned = false;
25885         LDKTrustedCommitmentTransaction ret_var = CommitmentTransaction_trust(&this_arg_conv);
25886         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25887         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25888         uint64_t ret_ref = (uint64_t)ret_var.inner;
25889         if (ret_var.is_owned) {
25890                 ret_ref |= 1;
25891         }
25892         return ret_ref;
25893 }
25894
25895 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) {
25896         LDKCommitmentTransaction this_arg_conv;
25897         this_arg_conv.inner = (void*)(this_arg & (~1));
25898         this_arg_conv.is_owned = false;
25899         LDKDirectedChannelTransactionParameters channel_parameters_conv;
25900         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
25901         channel_parameters_conv.is_owned = false;
25902         LDKChannelPublicKeys broadcaster_keys_conv;
25903         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
25904         broadcaster_keys_conv.is_owned = false;
25905         LDKChannelPublicKeys countersignatory_keys_conv;
25906         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
25907         countersignatory_keys_conv.is_owned = false;
25908         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
25909         *ret_conv = CommitmentTransaction_verify(&this_arg_conv, &channel_parameters_conv, &broadcaster_keys_conv, &countersignatory_keys_conv);
25910         return (uint64_t)ret_conv;
25911 }
25912
25913 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25914         LDKTrustedCommitmentTransaction this_obj_conv;
25915         this_obj_conv.inner = (void*)(this_obj & (~1));
25916         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25917         TrustedCommitmentTransaction_free(this_obj_conv);
25918 }
25919
25920 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1txid(JNIEnv *env, jclass clz, int64_t this_arg) {
25921         LDKTrustedCommitmentTransaction this_arg_conv;
25922         this_arg_conv.inner = (void*)(this_arg & (~1));
25923         this_arg_conv.is_owned = false;
25924         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
25925         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, TrustedCommitmentTransaction_txid(&this_arg_conv).data);
25926         return ret_arr;
25927 }
25928
25929 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1built_1transaction(JNIEnv *env, jclass clz, int64_t this_arg) {
25930         LDKTrustedCommitmentTransaction this_arg_conv;
25931         this_arg_conv.inner = (void*)(this_arg & (~1));
25932         this_arg_conv.is_owned = false;
25933         LDKBuiltCommitmentTransaction ret_var = TrustedCommitmentTransaction_built_transaction(&this_arg_conv);
25934         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25935         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25936         uint64_t ret_ref = (uint64_t)ret_var.inner;
25937         if (ret_var.is_owned) {
25938                 ret_ref |= 1;
25939         }
25940         return ret_ref;
25941 }
25942
25943 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1keys(JNIEnv *env, jclass clz, int64_t this_arg) {
25944         LDKTrustedCommitmentTransaction this_arg_conv;
25945         this_arg_conv.inner = (void*)(this_arg & (~1));
25946         this_arg_conv.is_owned = false;
25947         LDKTxCreationKeys ret_var = TrustedCommitmentTransaction_keys(&this_arg_conv);
25948         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25949         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25950         uint64_t ret_ref = (uint64_t)ret_var.inner;
25951         if (ret_var.is_owned) {
25952                 ret_ref |= 1;
25953         }
25954         return ret_ref;
25955 }
25956
25957 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) {
25958         LDKTrustedCommitmentTransaction this_arg_conv;
25959         this_arg_conv.inner = (void*)(this_arg & (~1));
25960         this_arg_conv.is_owned = false;
25961         unsigned char htlc_base_key_arr[32];
25962         CHECK((*env)->GetArrayLength(env, htlc_base_key) == 32);
25963         (*env)->GetByteArrayRegion(env, htlc_base_key, 0, 32, htlc_base_key_arr);
25964         unsigned char (*htlc_base_key_ref)[32] = &htlc_base_key_arr;
25965         LDKDirectedChannelTransactionParameters channel_parameters_conv;
25966         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
25967         channel_parameters_conv.is_owned = false;
25968         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
25969         *ret_conv = TrustedCommitmentTransaction_get_htlc_sigs(&this_arg_conv, htlc_base_key_ref, &channel_parameters_conv);
25970         return (uint64_t)ret_conv;
25971 }
25972
25973 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) {
25974         LDKPublicKey broadcaster_payment_basepoint_ref;
25975         CHECK((*env)->GetArrayLength(env, broadcaster_payment_basepoint) == 33);
25976         (*env)->GetByteArrayRegion(env, broadcaster_payment_basepoint, 0, 33, broadcaster_payment_basepoint_ref.compressed_form);
25977         LDKPublicKey countersignatory_payment_basepoint_ref;
25978         CHECK((*env)->GetArrayLength(env, countersignatory_payment_basepoint) == 33);
25979         (*env)->GetByteArrayRegion(env, countersignatory_payment_basepoint, 0, 33, countersignatory_payment_basepoint_ref.compressed_form);
25980         int64_t ret_val = get_commitment_transaction_number_obscure_factor(broadcaster_payment_basepoint_ref, countersignatory_payment_basepoint_ref, outbound_from_broadcaster);
25981         return ret_val;
25982 }
25983
25984 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
25985         LDKInitFeatures a_conv;
25986         a_conv.inner = (void*)(a & (~1));
25987         a_conv.is_owned = false;
25988         LDKInitFeatures b_conv;
25989         b_conv.inner = (void*)(b & (~1));
25990         b_conv.is_owned = false;
25991         jboolean ret_val = InitFeatures_eq(&a_conv, &b_conv);
25992         return ret_val;
25993 }
25994
25995 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
25996         LDKNodeFeatures a_conv;
25997         a_conv.inner = (void*)(a & (~1));
25998         a_conv.is_owned = false;
25999         LDKNodeFeatures b_conv;
26000         b_conv.inner = (void*)(b & (~1));
26001         b_conv.is_owned = false;
26002         jboolean ret_val = NodeFeatures_eq(&a_conv, &b_conv);
26003         return ret_val;
26004 }
26005
26006 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
26007         LDKChannelFeatures a_conv;
26008         a_conv.inner = (void*)(a & (~1));
26009         a_conv.is_owned = false;
26010         LDKChannelFeatures b_conv;
26011         b_conv.inner = (void*)(b & (~1));
26012         b_conv.is_owned = false;
26013         jboolean ret_val = ChannelFeatures_eq(&a_conv, &b_conv);
26014         return ret_val;
26015 }
26016
26017 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
26018         LDKInvoiceFeatures a_conv;
26019         a_conv.inner = (void*)(a & (~1));
26020         a_conv.is_owned = false;
26021         LDKInvoiceFeatures b_conv;
26022         b_conv.inner = (void*)(b & (~1));
26023         b_conv.is_owned = false;
26024         jboolean ret_val = InvoiceFeatures_eq(&a_conv, &b_conv);
26025         return ret_val;
26026 }
26027
26028 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26029         LDKInitFeatures orig_conv;
26030         orig_conv.inner = (void*)(orig & (~1));
26031         orig_conv.is_owned = false;
26032         LDKInitFeatures ret_var = InitFeatures_clone(&orig_conv);
26033         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26034         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26035         uint64_t ret_ref = (uint64_t)ret_var.inner;
26036         if (ret_var.is_owned) {
26037                 ret_ref |= 1;
26038         }
26039         return ret_ref;
26040 }
26041
26042 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26043         LDKNodeFeatures orig_conv;
26044         orig_conv.inner = (void*)(orig & (~1));
26045         orig_conv.is_owned = false;
26046         LDKNodeFeatures ret_var = NodeFeatures_clone(&orig_conv);
26047         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26048         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26049         uint64_t ret_ref = (uint64_t)ret_var.inner;
26050         if (ret_var.is_owned) {
26051                 ret_ref |= 1;
26052         }
26053         return ret_ref;
26054 }
26055
26056 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26057         LDKChannelFeatures orig_conv;
26058         orig_conv.inner = (void*)(orig & (~1));
26059         orig_conv.is_owned = false;
26060         LDKChannelFeatures ret_var = ChannelFeatures_clone(&orig_conv);
26061         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26062         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26063         uint64_t ret_ref = (uint64_t)ret_var.inner;
26064         if (ret_var.is_owned) {
26065                 ret_ref |= 1;
26066         }
26067         return ret_ref;
26068 }
26069
26070 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26071         LDKInvoiceFeatures orig_conv;
26072         orig_conv.inner = (void*)(orig & (~1));
26073         orig_conv.is_owned = false;
26074         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(&orig_conv);
26075         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26076         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26077         uint64_t ret_ref = (uint64_t)ret_var.inner;
26078         if (ret_var.is_owned) {
26079                 ret_ref |= 1;
26080         }
26081         return ret_ref;
26082 }
26083
26084 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26085         LDKInitFeatures this_obj_conv;
26086         this_obj_conv.inner = (void*)(this_obj & (~1));
26087         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26088         InitFeatures_free(this_obj_conv);
26089 }
26090
26091 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26092         LDKNodeFeatures this_obj_conv;
26093         this_obj_conv.inner = (void*)(this_obj & (~1));
26094         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26095         NodeFeatures_free(this_obj_conv);
26096 }
26097
26098 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26099         LDKChannelFeatures this_obj_conv;
26100         this_obj_conv.inner = (void*)(this_obj & (~1));
26101         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26102         ChannelFeatures_free(this_obj_conv);
26103 }
26104
26105 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26106         LDKInvoiceFeatures this_obj_conv;
26107         this_obj_conv.inner = (void*)(this_obj & (~1));
26108         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26109         InvoiceFeatures_free(this_obj_conv);
26110 }
26111
26112 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1empty(JNIEnv *env, jclass clz) {
26113         LDKInitFeatures ret_var = InitFeatures_empty();
26114         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26115         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26116         uint64_t ret_ref = (uint64_t)ret_var.inner;
26117         if (ret_var.is_owned) {
26118                 ret_ref |= 1;
26119         }
26120         return ret_ref;
26121 }
26122
26123 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1known(JNIEnv *env, jclass clz) {
26124         LDKInitFeatures ret_var = InitFeatures_known();
26125         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26126         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26127         uint64_t ret_ref = (uint64_t)ret_var.inner;
26128         if (ret_var.is_owned) {
26129                 ret_ref |= 1;
26130         }
26131         return ret_ref;
26132 }
26133
26134 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
26135         LDKInitFeatures this_arg_conv;
26136         this_arg_conv.inner = (void*)(this_arg & (~1));
26137         this_arg_conv.is_owned = false;
26138         jboolean ret_val = InitFeatures_requires_unknown_bits(&this_arg_conv);
26139         return ret_val;
26140 }
26141
26142 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1empty(JNIEnv *env, jclass clz) {
26143         LDKNodeFeatures ret_var = NodeFeatures_empty();
26144         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26145         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26146         uint64_t ret_ref = (uint64_t)ret_var.inner;
26147         if (ret_var.is_owned) {
26148                 ret_ref |= 1;
26149         }
26150         return ret_ref;
26151 }
26152
26153 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1known(JNIEnv *env, jclass clz) {
26154         LDKNodeFeatures ret_var = NodeFeatures_known();
26155         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26156         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26157         uint64_t ret_ref = (uint64_t)ret_var.inner;
26158         if (ret_var.is_owned) {
26159                 ret_ref |= 1;
26160         }
26161         return ret_ref;
26162 }
26163
26164 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
26165         LDKNodeFeatures this_arg_conv;
26166         this_arg_conv.inner = (void*)(this_arg & (~1));
26167         this_arg_conv.is_owned = false;
26168         jboolean ret_val = NodeFeatures_requires_unknown_bits(&this_arg_conv);
26169         return ret_val;
26170 }
26171
26172 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1empty(JNIEnv *env, jclass clz) {
26173         LDKChannelFeatures ret_var = ChannelFeatures_empty();
26174         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26175         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26176         uint64_t ret_ref = (uint64_t)ret_var.inner;
26177         if (ret_var.is_owned) {
26178                 ret_ref |= 1;
26179         }
26180         return ret_ref;
26181 }
26182
26183 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1known(JNIEnv *env, jclass clz) {
26184         LDKChannelFeatures ret_var = ChannelFeatures_known();
26185         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26186         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26187         uint64_t ret_ref = (uint64_t)ret_var.inner;
26188         if (ret_var.is_owned) {
26189                 ret_ref |= 1;
26190         }
26191         return ret_ref;
26192 }
26193
26194 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
26195         LDKChannelFeatures this_arg_conv;
26196         this_arg_conv.inner = (void*)(this_arg & (~1));
26197         this_arg_conv.is_owned = false;
26198         jboolean ret_val = ChannelFeatures_requires_unknown_bits(&this_arg_conv);
26199         return ret_val;
26200 }
26201
26202 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1empty(JNIEnv *env, jclass clz) {
26203         LDKInvoiceFeatures ret_var = InvoiceFeatures_empty();
26204         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26205         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26206         uint64_t ret_ref = (uint64_t)ret_var.inner;
26207         if (ret_var.is_owned) {
26208                 ret_ref |= 1;
26209         }
26210         return ret_ref;
26211 }
26212
26213 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1known(JNIEnv *env, jclass clz) {
26214         LDKInvoiceFeatures ret_var = InvoiceFeatures_known();
26215         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26216         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26217         uint64_t ret_ref = (uint64_t)ret_var.inner;
26218         if (ret_var.is_owned) {
26219                 ret_ref |= 1;
26220         }
26221         return ret_ref;
26222 }
26223
26224 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
26225         LDKInvoiceFeatures this_arg_conv;
26226         this_arg_conv.inner = (void*)(this_arg & (~1));
26227         this_arg_conv.is_owned = false;
26228         jboolean ret_val = InvoiceFeatures_requires_unknown_bits(&this_arg_conv);
26229         return ret_val;
26230 }
26231
26232 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
26233         LDKInitFeatures this_arg_conv;
26234         this_arg_conv.inner = (void*)(this_arg & (~1));
26235         this_arg_conv.is_owned = false;
26236         jboolean ret_val = InitFeatures_supports_payment_secret(&this_arg_conv);
26237         return ret_val;
26238 }
26239
26240 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
26241         LDKNodeFeatures this_arg_conv;
26242         this_arg_conv.inner = (void*)(this_arg & (~1));
26243         this_arg_conv.is_owned = false;
26244         jboolean ret_val = NodeFeatures_supports_payment_secret(&this_arg_conv);
26245         return ret_val;
26246 }
26247
26248 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1supports_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
26249         LDKInvoiceFeatures this_arg_conv;
26250         this_arg_conv.inner = (void*)(this_arg & (~1));
26251         this_arg_conv.is_owned = false;
26252         jboolean ret_val = InvoiceFeatures_supports_payment_secret(&this_arg_conv);
26253         return ret_val;
26254 }
26255
26256 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InitFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
26257         LDKInitFeatures obj_conv;
26258         obj_conv.inner = (void*)(obj & (~1));
26259         obj_conv.is_owned = false;
26260         LDKCVec_u8Z ret_var = InitFeatures_write(&obj_conv);
26261         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26262         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26263         CVec_u8Z_free(ret_var);
26264         return ret_arr;
26265 }
26266
26267 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
26268         LDKNodeFeatures obj_conv;
26269         obj_conv.inner = (void*)(obj & (~1));
26270         obj_conv.is_owned = false;
26271         LDKCVec_u8Z ret_var = NodeFeatures_write(&obj_conv);
26272         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26273         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26274         CVec_u8Z_free(ret_var);
26275         return ret_arr;
26276 }
26277
26278 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
26279         LDKChannelFeatures obj_conv;
26280         obj_conv.inner = (void*)(obj & (~1));
26281         obj_conv.is_owned = false;
26282         LDKCVec_u8Z ret_var = ChannelFeatures_write(&obj_conv);
26283         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26284         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26285         CVec_u8Z_free(ret_var);
26286         return ret_arr;
26287 }
26288
26289 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
26290         LDKInvoiceFeatures obj_conv;
26291         obj_conv.inner = (void*)(obj & (~1));
26292         obj_conv.is_owned = false;
26293         LDKCVec_u8Z ret_var = InvoiceFeatures_write(&obj_conv);
26294         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26295         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26296         CVec_u8Z_free(ret_var);
26297         return ret_arr;
26298 }
26299
26300 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
26301         LDKu8slice ser_ref;
26302         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
26303         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
26304         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
26305         *ret_conv = InitFeatures_read(ser_ref);
26306         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
26307         return (uint64_t)ret_conv;
26308 }
26309
26310 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
26311         LDKu8slice ser_ref;
26312         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
26313         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
26314         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
26315         *ret_conv = NodeFeatures_read(ser_ref);
26316         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
26317         return (uint64_t)ret_conv;
26318 }
26319
26320 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
26321         LDKu8slice ser_ref;
26322         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
26323         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
26324         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
26325         *ret_conv = ChannelFeatures_read(ser_ref);
26326         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
26327         return (uint64_t)ret_conv;
26328 }
26329
26330 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
26331         LDKu8slice ser_ref;
26332         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
26333         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
26334         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
26335         *ret_conv = InvoiceFeatures_read(ser_ref);
26336         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
26337         return (uint64_t)ret_conv;
26338 }
26339
26340 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26341         LDKShutdownScript this_obj_conv;
26342         this_obj_conv.inner = (void*)(this_obj & (~1));
26343         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26344         ShutdownScript_free(this_obj_conv);
26345 }
26346
26347 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26348         LDKShutdownScript orig_conv;
26349         orig_conv.inner = (void*)(orig & (~1));
26350         orig_conv.is_owned = false;
26351         LDKShutdownScript ret_var = ShutdownScript_clone(&orig_conv);
26352         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26353         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26354         uint64_t ret_ref = (uint64_t)ret_var.inner;
26355         if (ret_var.is_owned) {
26356                 ret_ref |= 1;
26357         }
26358         return ret_ref;
26359 }
26360
26361 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26362         LDKInvalidShutdownScript this_obj_conv;
26363         this_obj_conv.inner = (void*)(this_obj & (~1));
26364         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26365         InvalidShutdownScript_free(this_obj_conv);
26366 }
26367
26368 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1get_1script(JNIEnv *env, jclass clz, int64_t this_ptr) {
26369         LDKInvalidShutdownScript this_ptr_conv;
26370         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26371         this_ptr_conv.is_owned = false;
26372         LDKu8slice ret_var = InvalidShutdownScript_get_script(&this_ptr_conv);
26373         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26374         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26375         return ret_arr;
26376 }
26377
26378 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1set_1script(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
26379         LDKInvalidShutdownScript this_ptr_conv;
26380         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26381         this_ptr_conv.is_owned = false;
26382         LDKCVec_u8Z val_ref;
26383         val_ref.datalen = (*env)->GetArrayLength(env, val);
26384         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
26385         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
26386         InvalidShutdownScript_set_script(&this_ptr_conv, val_ref);
26387 }
26388
26389 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1new(JNIEnv *env, jclass clz, int8_tArray script_arg) {
26390         LDKCVec_u8Z script_arg_ref;
26391         script_arg_ref.datalen = (*env)->GetArrayLength(env, script_arg);
26392         script_arg_ref.data = MALLOC(script_arg_ref.datalen, "LDKCVec_u8Z Bytes");
26393         (*env)->GetByteArrayRegion(env, script_arg, 0, script_arg_ref.datalen, script_arg_ref.data);
26394         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_new(script_arg_ref);
26395         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26396         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26397         uint64_t ret_ref = (uint64_t)ret_var.inner;
26398         if (ret_var.is_owned) {
26399                 ret_ref |= 1;
26400         }
26401         return ret_ref;
26402 }
26403
26404 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1write(JNIEnv *env, jclass clz, int64_t obj) {
26405         LDKShutdownScript obj_conv;
26406         obj_conv.inner = (void*)(obj & (~1));
26407         obj_conv.is_owned = false;
26408         LDKCVec_u8Z ret_var = ShutdownScript_write(&obj_conv);
26409         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26410         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26411         CVec_u8Z_free(ret_var);
26412         return ret_arr;
26413 }
26414
26415 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
26416         LDKu8slice ser_ref;
26417         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
26418         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
26419         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
26420         *ret_conv = ShutdownScript_read(ser_ref);
26421         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
26422         return (uint64_t)ret_conv;
26423 }
26424
26425 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1new_1p2pkh(JNIEnv *env, jclass clz, int8_tArray pubkey_hash) {
26426         unsigned char pubkey_hash_arr[20];
26427         CHECK((*env)->GetArrayLength(env, pubkey_hash) == 20);
26428         (*env)->GetByteArrayRegion(env, pubkey_hash, 0, 20, pubkey_hash_arr);
26429         unsigned char (*pubkey_hash_ref)[20] = &pubkey_hash_arr;
26430         LDKShutdownScript ret_var = ShutdownScript_new_p2pkh(pubkey_hash_ref);
26431         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26432         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26433         uint64_t ret_ref = (uint64_t)ret_var.inner;
26434         if (ret_var.is_owned) {
26435                 ret_ref |= 1;
26436         }
26437         return ret_ref;
26438 }
26439
26440 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1new_1p2sh(JNIEnv *env, jclass clz, int8_tArray script_hash) {
26441         unsigned char script_hash_arr[20];
26442         CHECK((*env)->GetArrayLength(env, script_hash) == 20);
26443         (*env)->GetByteArrayRegion(env, script_hash, 0, 20, script_hash_arr);
26444         unsigned char (*script_hash_ref)[20] = &script_hash_arr;
26445         LDKShutdownScript ret_var = ShutdownScript_new_p2sh(script_hash_ref);
26446         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26447         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26448         uint64_t ret_ref = (uint64_t)ret_var.inner;
26449         if (ret_var.is_owned) {
26450                 ret_ref |= 1;
26451         }
26452         return ret_ref;
26453 }
26454
26455 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1new_1p2wpkh(JNIEnv *env, jclass clz, int8_tArray pubkey_hash) {
26456         unsigned char pubkey_hash_arr[20];
26457         CHECK((*env)->GetArrayLength(env, pubkey_hash) == 20);
26458         (*env)->GetByteArrayRegion(env, pubkey_hash, 0, 20, pubkey_hash_arr);
26459         unsigned char (*pubkey_hash_ref)[20] = &pubkey_hash_arr;
26460         LDKShutdownScript ret_var = ShutdownScript_new_p2wpkh(pubkey_hash_ref);
26461         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26462         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26463         uint64_t ret_ref = (uint64_t)ret_var.inner;
26464         if (ret_var.is_owned) {
26465                 ret_ref |= 1;
26466         }
26467         return ret_ref;
26468 }
26469
26470 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1new_1p2wsh(JNIEnv *env, jclass clz, int8_tArray script_hash) {
26471         unsigned char script_hash_arr[32];
26472         CHECK((*env)->GetArrayLength(env, script_hash) == 32);
26473         (*env)->GetByteArrayRegion(env, script_hash, 0, 32, script_hash_arr);
26474         unsigned char (*script_hash_ref)[32] = &script_hash_arr;
26475         LDKShutdownScript ret_var = ShutdownScript_new_p2wsh(script_hash_ref);
26476         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26477         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26478         uint64_t ret_ref = (uint64_t)ret_var.inner;
26479         if (ret_var.is_owned) {
26480                 ret_ref |= 1;
26481         }
26482         return ret_ref;
26483 }
26484
26485 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1new_1witness_1program(JNIEnv *env, jclass clz, int8_t version, int8_tArray program) {
26486         LDKu8slice program_ref;
26487         program_ref.datalen = (*env)->GetArrayLength(env, program);
26488         program_ref.data = (*env)->GetByteArrayElements (env, program, NULL);
26489         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
26490         *ret_conv = ShutdownScript_new_witness_program(version, program_ref);
26491         (*env)->ReleaseByteArrayElements(env, program, (int8_t*)program_ref.data, 0);
26492         return (uint64_t)ret_conv;
26493 }
26494
26495 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1into_1inner(JNIEnv *env, jclass clz, int64_t this_arg) {
26496         LDKShutdownScript this_arg_conv;
26497         this_arg_conv.inner = (void*)(this_arg & (~1));
26498         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
26499         this_arg_conv = ShutdownScript_clone(&this_arg_conv);
26500         LDKCVec_u8Z ret_var = ShutdownScript_into_inner(this_arg_conv);
26501         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26502         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26503         CVec_u8Z_free(ret_var);
26504         return ret_arr;
26505 }
26506
26507 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1as_1legacy_1pubkey(JNIEnv *env, jclass clz, int64_t this_arg) {
26508         LDKShutdownScript this_arg_conv;
26509         this_arg_conv.inner = (void*)(this_arg & (~1));
26510         this_arg_conv.is_owned = false;
26511         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
26512         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ShutdownScript_as_legacy_pubkey(&this_arg_conv).compressed_form);
26513         return ret_arr;
26514 }
26515
26516 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1is_1compatible(JNIEnv *env, jclass clz, int64_t this_arg, int64_t features) {
26517         LDKShutdownScript this_arg_conv;
26518         this_arg_conv.inner = (void*)(this_arg & (~1));
26519         this_arg_conv.is_owned = false;
26520         LDKInitFeatures features_conv;
26521         features_conv.inner = (void*)(features & (~1));
26522         features_conv.is_owned = false;
26523         jboolean ret_val = ShutdownScript_is_compatible(&this_arg_conv, &features_conv);
26524         return ret_val;
26525 }
26526
26527 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CustomMessageReader_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
26528         if ((this_ptr & 1) != 0) return;
26529         LDKCustomMessageReader this_ptr_conv = *(LDKCustomMessageReader*)(((uint64_t)this_ptr) & ~1);
26530         FREE((void*)this_ptr);
26531         CustomMessageReader_free(this_ptr_conv);
26532 }
26533
26534 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Type_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26535         LDKType* orig_conv = (LDKType*)(((uint64_t)orig) & ~1);
26536         LDKType* ret_ret =MALLOC(sizeof(LDKType), "LDKType");
26537         *ret_ret = Type_clone(orig_conv);
26538         return (uint64_t)ret_ret;
26539 }
26540
26541 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Type_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
26542         if ((this_ptr & 1) != 0) return;
26543         LDKType this_ptr_conv = *(LDKType*)(((uint64_t)this_ptr) & ~1);
26544         FREE((void*)this_ptr);
26545         Type_free(this_ptr_conv);
26546 }
26547
26548 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26549         LDKRouteHop this_obj_conv;
26550         this_obj_conv.inner = (void*)(this_obj & (~1));
26551         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26552         RouteHop_free(this_obj_conv);
26553 }
26554
26555 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
26556         LDKRouteHop this_ptr_conv;
26557         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26558         this_ptr_conv.is_owned = false;
26559         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
26560         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RouteHop_get_pubkey(&this_ptr_conv).compressed_form);
26561         return ret_arr;
26562 }
26563
26564 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
26565         LDKRouteHop this_ptr_conv;
26566         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26567         this_ptr_conv.is_owned = false;
26568         LDKPublicKey val_ref;
26569         CHECK((*env)->GetArrayLength(env, val) == 33);
26570         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
26571         RouteHop_set_pubkey(&this_ptr_conv, val_ref);
26572 }
26573
26574 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1node_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
26575         LDKRouteHop this_ptr_conv;
26576         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26577         this_ptr_conv.is_owned = false;
26578         LDKNodeFeatures ret_var = RouteHop_get_node_features(&this_ptr_conv);
26579         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26580         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26581         uint64_t ret_ref = (uint64_t)ret_var.inner;
26582         if (ret_var.is_owned) {
26583                 ret_ref |= 1;
26584         }
26585         return ret_ref;
26586 }
26587
26588 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1node_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
26589         LDKRouteHop this_ptr_conv;
26590         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26591         this_ptr_conv.is_owned = false;
26592         LDKNodeFeatures val_conv;
26593         val_conv.inner = (void*)(val & (~1));
26594         val_conv.is_owned = (val & 1) || (val == 0);
26595         val_conv = NodeFeatures_clone(&val_conv);
26596         RouteHop_set_node_features(&this_ptr_conv, val_conv);
26597 }
26598
26599 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
26600         LDKRouteHop this_ptr_conv;
26601         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26602         this_ptr_conv.is_owned = false;
26603         int64_t ret_val = RouteHop_get_short_channel_id(&this_ptr_conv);
26604         return ret_val;
26605 }
26606
26607 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
26608         LDKRouteHop this_ptr_conv;
26609         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26610         this_ptr_conv.is_owned = false;
26611         RouteHop_set_short_channel_id(&this_ptr_conv, val);
26612 }
26613
26614 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1channel_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
26615         LDKRouteHop this_ptr_conv;
26616         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26617         this_ptr_conv.is_owned = false;
26618         LDKChannelFeatures ret_var = RouteHop_get_channel_features(&this_ptr_conv);
26619         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26620         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26621         uint64_t ret_ref = (uint64_t)ret_var.inner;
26622         if (ret_var.is_owned) {
26623                 ret_ref |= 1;
26624         }
26625         return ret_ref;
26626 }
26627
26628 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1channel_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
26629         LDKRouteHop this_ptr_conv;
26630         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26631         this_ptr_conv.is_owned = false;
26632         LDKChannelFeatures val_conv;
26633         val_conv.inner = (void*)(val & (~1));
26634         val_conv.is_owned = (val & 1) || (val == 0);
26635         val_conv = ChannelFeatures_clone(&val_conv);
26636         RouteHop_set_channel_features(&this_ptr_conv, val_conv);
26637 }
26638
26639 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1fee_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
26640         LDKRouteHop this_ptr_conv;
26641         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26642         this_ptr_conv.is_owned = false;
26643         int64_t ret_val = RouteHop_get_fee_msat(&this_ptr_conv);
26644         return ret_val;
26645 }
26646
26647 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1fee_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
26648         LDKRouteHop this_ptr_conv;
26649         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26650         this_ptr_conv.is_owned = false;
26651         RouteHop_set_fee_msat(&this_ptr_conv, val);
26652 }
26653
26654 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
26655         LDKRouteHop this_ptr_conv;
26656         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26657         this_ptr_conv.is_owned = false;
26658         int32_t ret_val = RouteHop_get_cltv_expiry_delta(&this_ptr_conv);
26659         return ret_val;
26660 }
26661
26662 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
26663         LDKRouteHop this_ptr_conv;
26664         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26665         this_ptr_conv.is_owned = false;
26666         RouteHop_set_cltv_expiry_delta(&this_ptr_conv, val);
26667 }
26668
26669 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) {
26670         LDKPublicKey pubkey_arg_ref;
26671         CHECK((*env)->GetArrayLength(env, pubkey_arg) == 33);
26672         (*env)->GetByteArrayRegion(env, pubkey_arg, 0, 33, pubkey_arg_ref.compressed_form);
26673         LDKNodeFeatures node_features_arg_conv;
26674         node_features_arg_conv.inner = (void*)(node_features_arg & (~1));
26675         node_features_arg_conv.is_owned = (node_features_arg & 1) || (node_features_arg == 0);
26676         node_features_arg_conv = NodeFeatures_clone(&node_features_arg_conv);
26677         LDKChannelFeatures channel_features_arg_conv;
26678         channel_features_arg_conv.inner = (void*)(channel_features_arg & (~1));
26679         channel_features_arg_conv.is_owned = (channel_features_arg & 1) || (channel_features_arg == 0);
26680         channel_features_arg_conv = ChannelFeatures_clone(&channel_features_arg_conv);
26681         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);
26682         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26683         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26684         uint64_t ret_ref = (uint64_t)ret_var.inner;
26685         if (ret_var.is_owned) {
26686                 ret_ref |= 1;
26687         }
26688         return ret_ref;
26689 }
26690
26691 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26692         LDKRouteHop orig_conv;
26693         orig_conv.inner = (void*)(orig & (~1));
26694         orig_conv.is_owned = false;
26695         LDKRouteHop ret_var = RouteHop_clone(&orig_conv);
26696         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26697         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26698         uint64_t ret_ref = (uint64_t)ret_var.inner;
26699         if (ret_var.is_owned) {
26700                 ret_ref |= 1;
26701         }
26702         return ret_ref;
26703 }
26704
26705 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1hash(JNIEnv *env, jclass clz, int64_t o) {
26706         LDKRouteHop o_conv;
26707         o_conv.inner = (void*)(o & (~1));
26708         o_conv.is_owned = false;
26709         int64_t ret_val = RouteHop_hash(&o_conv);
26710         return ret_val;
26711 }
26712
26713 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHop_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
26714         LDKRouteHop a_conv;
26715         a_conv.inner = (void*)(a & (~1));
26716         a_conv.is_owned = false;
26717         LDKRouteHop b_conv;
26718         b_conv.inner = (void*)(b & (~1));
26719         b_conv.is_owned = false;
26720         jboolean ret_val = RouteHop_eq(&a_conv, &b_conv);
26721         return ret_val;
26722 }
26723
26724 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHop_1write(JNIEnv *env, jclass clz, int64_t obj) {
26725         LDKRouteHop obj_conv;
26726         obj_conv.inner = (void*)(obj & (~1));
26727         obj_conv.is_owned = false;
26728         LDKCVec_u8Z ret_var = RouteHop_write(&obj_conv);
26729         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26730         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26731         CVec_u8Z_free(ret_var);
26732         return ret_arr;
26733 }
26734
26735 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
26736         LDKu8slice ser_ref;
26737         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
26738         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
26739         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
26740         *ret_conv = RouteHop_read(ser_ref);
26741         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
26742         return (uint64_t)ret_conv;
26743 }
26744
26745 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26746         LDKRoute this_obj_conv;
26747         this_obj_conv.inner = (void*)(this_obj & (~1));
26748         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26749         Route_free(this_obj_conv);
26750 }
26751
26752 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_Route_1get_1paths(JNIEnv *env, jclass clz, int64_t this_ptr) {
26753         LDKRoute this_ptr_conv;
26754         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26755         this_ptr_conv.is_owned = false;
26756         LDKCVec_CVec_RouteHopZZ ret_var = Route_get_paths(&this_ptr_conv);
26757         jobjectArray ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_J_clz, NULL);
26758         ;
26759         for (size_t m = 0; m < ret_var.datalen; m++) {
26760                 LDKCVec_RouteHopZ ret_conv_12_var = ret_var.data[m];
26761                 int64_tArray ret_conv_12_arr = (*env)->NewLongArray(env, ret_conv_12_var.datalen);
26762                 int64_t *ret_conv_12_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_conv_12_arr, NULL);
26763                 for (size_t k = 0; k < ret_conv_12_var.datalen; k++) {
26764                         LDKRouteHop ret_conv_12_conv_10_var = ret_conv_12_var.data[k];
26765                         CHECK((((uint64_t)ret_conv_12_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26766                         CHECK((((uint64_t)&ret_conv_12_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26767                         uint64_t ret_conv_12_conv_10_ref = (uint64_t)ret_conv_12_conv_10_var.inner;
26768                         if (ret_conv_12_conv_10_var.is_owned) {
26769                                 ret_conv_12_conv_10_ref |= 1;
26770                         }
26771                         ret_conv_12_arr_ptr[k] = ret_conv_12_conv_10_ref;
26772                 }
26773                 (*env)->ReleasePrimitiveArrayCritical(env, ret_conv_12_arr, ret_conv_12_arr_ptr, 0);
26774                 FREE(ret_conv_12_var.data);
26775                 (*env)->SetObjectArrayElement(env, ret_arr, m, ret_conv_12_arr);
26776         }
26777         FREE(ret_var.data);
26778         return ret_arr;
26779 }
26780
26781 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1set_1paths(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
26782         LDKRoute this_ptr_conv;
26783         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26784         this_ptr_conv.is_owned = false;
26785         LDKCVec_CVec_RouteHopZZ val_constr;
26786         val_constr.datalen = (*env)->GetArrayLength(env, val);
26787         if (val_constr.datalen > 0)
26788                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
26789         else
26790                 val_constr.data = NULL;
26791         for (size_t m = 0; m < val_constr.datalen; m++) {
26792                 int64_tArray val_conv_12 = (*env)->GetObjectArrayElement(env, val, m);
26793                 LDKCVec_RouteHopZ val_conv_12_constr;
26794                 val_conv_12_constr.datalen = (*env)->GetArrayLength(env, val_conv_12);
26795                 if (val_conv_12_constr.datalen > 0)
26796                         val_conv_12_constr.data = MALLOC(val_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
26797                 else
26798                         val_conv_12_constr.data = NULL;
26799                 int64_t* val_conv_12_vals = (*env)->GetLongArrayElements (env, val_conv_12, NULL);
26800                 for (size_t k = 0; k < val_conv_12_constr.datalen; k++) {
26801                         int64_t val_conv_12_conv_10 = val_conv_12_vals[k];
26802                         LDKRouteHop val_conv_12_conv_10_conv;
26803                         val_conv_12_conv_10_conv.inner = (void*)(val_conv_12_conv_10 & (~1));
26804                         val_conv_12_conv_10_conv.is_owned = (val_conv_12_conv_10 & 1) || (val_conv_12_conv_10 == 0);
26805                         val_conv_12_conv_10_conv = RouteHop_clone(&val_conv_12_conv_10_conv);
26806                         val_conv_12_constr.data[k] = val_conv_12_conv_10_conv;
26807                 }
26808                 (*env)->ReleaseLongArrayElements(env, val_conv_12, val_conv_12_vals, 0);
26809                 val_constr.data[m] = val_conv_12_constr;
26810         }
26811         Route_set_paths(&this_ptr_conv, val_constr);
26812 }
26813
26814 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1new(JNIEnv *env, jclass clz, jobjectArray paths_arg) {
26815         LDKCVec_CVec_RouteHopZZ paths_arg_constr;
26816         paths_arg_constr.datalen = (*env)->GetArrayLength(env, paths_arg);
26817         if (paths_arg_constr.datalen > 0)
26818                 paths_arg_constr.data = MALLOC(paths_arg_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
26819         else
26820                 paths_arg_constr.data = NULL;
26821         for (size_t m = 0; m < paths_arg_constr.datalen; m++) {
26822                 int64_tArray paths_arg_conv_12 = (*env)->GetObjectArrayElement(env, paths_arg, m);
26823                 LDKCVec_RouteHopZ paths_arg_conv_12_constr;
26824                 paths_arg_conv_12_constr.datalen = (*env)->GetArrayLength(env, paths_arg_conv_12);
26825                 if (paths_arg_conv_12_constr.datalen > 0)
26826                         paths_arg_conv_12_constr.data = MALLOC(paths_arg_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
26827                 else
26828                         paths_arg_conv_12_constr.data = NULL;
26829                 int64_t* paths_arg_conv_12_vals = (*env)->GetLongArrayElements (env, paths_arg_conv_12, NULL);
26830                 for (size_t k = 0; k < paths_arg_conv_12_constr.datalen; k++) {
26831                         int64_t paths_arg_conv_12_conv_10 = paths_arg_conv_12_vals[k];
26832                         LDKRouteHop paths_arg_conv_12_conv_10_conv;
26833                         paths_arg_conv_12_conv_10_conv.inner = (void*)(paths_arg_conv_12_conv_10 & (~1));
26834                         paths_arg_conv_12_conv_10_conv.is_owned = (paths_arg_conv_12_conv_10 & 1) || (paths_arg_conv_12_conv_10 == 0);
26835                         paths_arg_conv_12_conv_10_conv = RouteHop_clone(&paths_arg_conv_12_conv_10_conv);
26836                         paths_arg_conv_12_constr.data[k] = paths_arg_conv_12_conv_10_conv;
26837                 }
26838                 (*env)->ReleaseLongArrayElements(env, paths_arg_conv_12, paths_arg_conv_12_vals, 0);
26839                 paths_arg_constr.data[m] = paths_arg_conv_12_constr;
26840         }
26841         LDKRoute ret_var = Route_new(paths_arg_constr);
26842         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26843         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26844         uint64_t ret_ref = (uint64_t)ret_var.inner;
26845         if (ret_var.is_owned) {
26846                 ret_ref |= 1;
26847         }
26848         return ret_ref;
26849 }
26850
26851 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26852         LDKRoute orig_conv;
26853         orig_conv.inner = (void*)(orig & (~1));
26854         orig_conv.is_owned = false;
26855         LDKRoute ret_var = Route_clone(&orig_conv);
26856         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26857         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26858         uint64_t ret_ref = (uint64_t)ret_var.inner;
26859         if (ret_var.is_owned) {
26860                 ret_ref |= 1;
26861         }
26862         return ret_ref;
26863 }
26864
26865 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1hash(JNIEnv *env, jclass clz, int64_t o) {
26866         LDKRoute o_conv;
26867         o_conv.inner = (void*)(o & (~1));
26868         o_conv.is_owned = false;
26869         int64_t ret_val = Route_hash(&o_conv);
26870         return ret_val;
26871 }
26872
26873 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Route_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
26874         LDKRoute a_conv;
26875         a_conv.inner = (void*)(a & (~1));
26876         a_conv.is_owned = false;
26877         LDKRoute b_conv;
26878         b_conv.inner = (void*)(b & (~1));
26879         b_conv.is_owned = false;
26880         jboolean ret_val = Route_eq(&a_conv, &b_conv);
26881         return ret_val;
26882 }
26883
26884 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1get_1total_1fees(JNIEnv *env, jclass clz, int64_t this_arg) {
26885         LDKRoute this_arg_conv;
26886         this_arg_conv.inner = (void*)(this_arg & (~1));
26887         this_arg_conv.is_owned = false;
26888         int64_t ret_val = Route_get_total_fees(&this_arg_conv);
26889         return ret_val;
26890 }
26891
26892 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1get_1total_1amount(JNIEnv *env, jclass clz, int64_t this_arg) {
26893         LDKRoute this_arg_conv;
26894         this_arg_conv.inner = (void*)(this_arg & (~1));
26895         this_arg_conv.is_owned = false;
26896         int64_t ret_val = Route_get_total_amount(&this_arg_conv);
26897         return ret_val;
26898 }
26899
26900 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Route_1write(JNIEnv *env, jclass clz, int64_t obj) {
26901         LDKRoute obj_conv;
26902         obj_conv.inner = (void*)(obj & (~1));
26903         obj_conv.is_owned = false;
26904         LDKCVec_u8Z ret_var = Route_write(&obj_conv);
26905         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26906         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26907         CVec_u8Z_free(ret_var);
26908         return ret_arr;
26909 }
26910
26911 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
26912         LDKu8slice ser_ref;
26913         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
26914         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
26915         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
26916         *ret_conv = Route_read(ser_ref);
26917         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
26918         return (uint64_t)ret_conv;
26919 }
26920
26921 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26922         LDKRouteHint this_obj_conv;
26923         this_obj_conv.inner = (void*)(this_obj & (~1));
26924         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26925         RouteHint_free(this_obj_conv);
26926 }
26927
26928 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26929         LDKRouteHint orig_conv;
26930         orig_conv.inner = (void*)(orig & (~1));
26931         orig_conv.is_owned = false;
26932         LDKRouteHint ret_var = RouteHint_clone(&orig_conv);
26933         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26934         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26935         uint64_t ret_ref = (uint64_t)ret_var.inner;
26936         if (ret_var.is_owned) {
26937                 ret_ref |= 1;
26938         }
26939         return ret_ref;
26940 }
26941
26942 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1hash(JNIEnv *env, jclass clz, int64_t o) {
26943         LDKRouteHint o_conv;
26944         o_conv.inner = (void*)(o & (~1));
26945         o_conv.is_owned = false;
26946         int64_t ret_val = RouteHint_hash(&o_conv);
26947         return ret_val;
26948 }
26949
26950 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHint_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
26951         LDKRouteHint a_conv;
26952         a_conv.inner = (void*)(a & (~1));
26953         a_conv.is_owned = false;
26954         LDKRouteHint b_conv;
26955         b_conv.inner = (void*)(b & (~1));
26956         b_conv.is_owned = false;
26957         jboolean ret_val = RouteHint_eq(&a_conv, &b_conv);
26958         return ret_val;
26959 }
26960
26961 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26962         LDKRouteHintHop this_obj_conv;
26963         this_obj_conv.inner = (void*)(this_obj & (~1));
26964         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26965         RouteHintHop_free(this_obj_conv);
26966 }
26967
26968 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1src_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
26969         LDKRouteHintHop this_ptr_conv;
26970         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26971         this_ptr_conv.is_owned = false;
26972         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
26973         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RouteHintHop_get_src_node_id(&this_ptr_conv).compressed_form);
26974         return ret_arr;
26975 }
26976
26977 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1src_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
26978         LDKRouteHintHop this_ptr_conv;
26979         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26980         this_ptr_conv.is_owned = false;
26981         LDKPublicKey val_ref;
26982         CHECK((*env)->GetArrayLength(env, val) == 33);
26983         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
26984         RouteHintHop_set_src_node_id(&this_ptr_conv, val_ref);
26985 }
26986
26987 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
26988         LDKRouteHintHop this_ptr_conv;
26989         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26990         this_ptr_conv.is_owned = false;
26991         int64_t ret_val = RouteHintHop_get_short_channel_id(&this_ptr_conv);
26992         return ret_val;
26993 }
26994
26995 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
26996         LDKRouteHintHop this_ptr_conv;
26997         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26998         this_ptr_conv.is_owned = false;
26999         RouteHintHop_set_short_channel_id(&this_ptr_conv, val);
27000 }
27001
27002 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
27003         LDKRouteHintHop this_ptr_conv;
27004         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27005         this_ptr_conv.is_owned = false;
27006         LDKRoutingFees ret_var = RouteHintHop_get_fees(&this_ptr_conv);
27007         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27008         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27009         uint64_t ret_ref = (uint64_t)ret_var.inner;
27010         if (ret_var.is_owned) {
27011                 ret_ref |= 1;
27012         }
27013         return ret_ref;
27014 }
27015
27016 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1fees(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27017         LDKRouteHintHop this_ptr_conv;
27018         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27019         this_ptr_conv.is_owned = false;
27020         LDKRoutingFees val_conv;
27021         val_conv.inner = (void*)(val & (~1));
27022         val_conv.is_owned = (val & 1) || (val == 0);
27023         val_conv = RoutingFees_clone(&val_conv);
27024         RouteHintHop_set_fees(&this_ptr_conv, val_conv);
27025 }
27026
27027 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
27028         LDKRouteHintHop this_ptr_conv;
27029         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27030         this_ptr_conv.is_owned = false;
27031         int16_t ret_val = RouteHintHop_get_cltv_expiry_delta(&this_ptr_conv);
27032         return ret_val;
27033 }
27034
27035 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
27036         LDKRouteHintHop this_ptr_conv;
27037         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27038         this_ptr_conv.is_owned = false;
27039         RouteHintHop_set_cltv_expiry_delta(&this_ptr_conv, val);
27040 }
27041
27042 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
27043         LDKRouteHintHop this_ptr_conv;
27044         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27045         this_ptr_conv.is_owned = false;
27046         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
27047         *ret_copy = RouteHintHop_get_htlc_minimum_msat(&this_ptr_conv);
27048         uint64_t ret_ref = (uint64_t)ret_copy;
27049         return ret_ref;
27050 }
27051
27052 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27053         LDKRouteHintHop this_ptr_conv;
27054         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27055         this_ptr_conv.is_owned = false;
27056         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
27057         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1));
27058         RouteHintHop_set_htlc_minimum_msat(&this_ptr_conv, val_conv);
27059 }
27060
27061 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
27062         LDKRouteHintHop this_ptr_conv;
27063         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27064         this_ptr_conv.is_owned = false;
27065         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
27066         *ret_copy = RouteHintHop_get_htlc_maximum_msat(&this_ptr_conv);
27067         uint64_t ret_ref = (uint64_t)ret_copy;
27068         return ret_ref;
27069 }
27070
27071 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27072         LDKRouteHintHop this_ptr_conv;
27073         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27074         this_ptr_conv.is_owned = false;
27075         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
27076         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1));
27077         RouteHintHop_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
27078 }
27079
27080 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) {
27081         LDKPublicKey src_node_id_arg_ref;
27082         CHECK((*env)->GetArrayLength(env, src_node_id_arg) == 33);
27083         (*env)->GetByteArrayRegion(env, src_node_id_arg, 0, 33, src_node_id_arg_ref.compressed_form);
27084         LDKRoutingFees fees_arg_conv;
27085         fees_arg_conv.inner = (void*)(fees_arg & (~1));
27086         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
27087         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
27088         LDKCOption_u64Z htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)htlc_minimum_msat_arg) & ~1);
27089         htlc_minimum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)htlc_minimum_msat_arg) & ~1));
27090         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)htlc_maximum_msat_arg) & ~1);
27091         htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)htlc_maximum_msat_arg) & ~1));
27092         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);
27093         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27094         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27095         uint64_t ret_ref = (uint64_t)ret_var.inner;
27096         if (ret_var.is_owned) {
27097                 ret_ref |= 1;
27098         }
27099         return ret_ref;
27100 }
27101
27102 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27103         LDKRouteHintHop orig_conv;
27104         orig_conv.inner = (void*)(orig & (~1));
27105         orig_conv.is_owned = false;
27106         LDKRouteHintHop ret_var = RouteHintHop_clone(&orig_conv);
27107         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27108         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27109         uint64_t ret_ref = (uint64_t)ret_var.inner;
27110         if (ret_var.is_owned) {
27111                 ret_ref |= 1;
27112         }
27113         return ret_ref;
27114 }
27115
27116 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1hash(JNIEnv *env, jclass clz, int64_t o) {
27117         LDKRouteHintHop o_conv;
27118         o_conv.inner = (void*)(o & (~1));
27119         o_conv.is_owned = false;
27120         int64_t ret_val = RouteHintHop_hash(&o_conv);
27121         return ret_val;
27122 }
27123
27124 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
27125         LDKRouteHintHop a_conv;
27126         a_conv.inner = (void*)(a & (~1));
27127         a_conv.is_owned = false;
27128         LDKRouteHintHop b_conv;
27129         b_conv.inner = (void*)(b & (~1));
27130         b_conv.is_owned = false;
27131         jboolean ret_val = RouteHintHop_eq(&a_conv, &b_conv);
27132         return ret_val;
27133 }
27134
27135 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_get_1keysend_1route(JNIEnv *env, jclass clz, int8_tArray our_node_id, int64_t network, int8_tArray payee, int64_tArray first_hops, int64_tArray last_hops, int64_t final_value_msat, int32_t final_cltv, int64_t logger) {
27136         LDKPublicKey our_node_id_ref;
27137         CHECK((*env)->GetArrayLength(env, our_node_id) == 33);
27138         (*env)->GetByteArrayRegion(env, our_node_id, 0, 33, our_node_id_ref.compressed_form);
27139         LDKNetworkGraph network_conv;
27140         network_conv.inner = (void*)(network & (~1));
27141         network_conv.is_owned = false;
27142         LDKPublicKey payee_ref;
27143         CHECK((*env)->GetArrayLength(env, payee) == 33);
27144         (*env)->GetByteArrayRegion(env, payee, 0, 33, payee_ref.compressed_form);
27145         LDKCVec_ChannelDetailsZ first_hops_constr;
27146         LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
27147         if (first_hops != NULL) {
27148                 first_hops_constr.datalen = (*env)->GetArrayLength(env, first_hops);
27149                 if (first_hops_constr.datalen > 0)
27150                         first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
27151                 else
27152                         first_hops_constr.data = NULL;
27153                 int64_t* first_hops_vals = (*env)->GetLongArrayElements (env, first_hops, NULL);
27154                 for (size_t q = 0; q < first_hops_constr.datalen; q++) {
27155                         int64_t first_hops_conv_16 = first_hops_vals[q];
27156                         LDKChannelDetails first_hops_conv_16_conv;
27157                         first_hops_conv_16_conv.inner = (void*)(first_hops_conv_16 & (~1));
27158                         first_hops_conv_16_conv.is_owned = (first_hops_conv_16 & 1) || (first_hops_conv_16 == 0);
27159                         first_hops_constr.data[q] = first_hops_conv_16_conv;
27160                 }
27161                 (*env)->ReleaseLongArrayElements(env, first_hops, first_hops_vals, 0);
27162                 first_hops_ptr = &first_hops_constr;
27163         }
27164         LDKCVec_RouteHintZ last_hops_constr;
27165         last_hops_constr.datalen = (*env)->GetArrayLength(env, last_hops);
27166         if (last_hops_constr.datalen > 0)
27167                 last_hops_constr.data = MALLOC(last_hops_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
27168         else
27169                 last_hops_constr.data = NULL;
27170         int64_t* last_hops_vals = (*env)->GetLongArrayElements (env, last_hops, NULL);
27171         for (size_t l = 0; l < last_hops_constr.datalen; l++) {
27172                 int64_t last_hops_conv_11 = last_hops_vals[l];
27173                 LDKRouteHint last_hops_conv_11_conv;
27174                 last_hops_conv_11_conv.inner = (void*)(last_hops_conv_11 & (~1));
27175                 last_hops_conv_11_conv.is_owned = (last_hops_conv_11 & 1) || (last_hops_conv_11 == 0);
27176                 last_hops_conv_11_conv = RouteHint_clone(&last_hops_conv_11_conv);
27177                 last_hops_constr.data[l] = last_hops_conv_11_conv;
27178         }
27179         (*env)->ReleaseLongArrayElements(env, last_hops, last_hops_vals, 0);
27180         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
27181         if (logger_conv.free == LDKLogger_JCalls_free) {
27182                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27183                 LDKLogger_JCalls_cloned(&logger_conv);
27184         }
27185         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
27186         *ret_conv = get_keysend_route(our_node_id_ref, &network_conv, payee_ref, first_hops_ptr, last_hops_constr, final_value_msat, final_cltv, logger_conv);
27187         if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
27188         return (uint64_t)ret_conv;
27189 }
27190
27191 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) {
27192         LDKPublicKey our_node_id_ref;
27193         CHECK((*env)->GetArrayLength(env, our_node_id) == 33);
27194         (*env)->GetByteArrayRegion(env, our_node_id, 0, 33, our_node_id_ref.compressed_form);
27195         LDKNetworkGraph network_conv;
27196         network_conv.inner = (void*)(network & (~1));
27197         network_conv.is_owned = false;
27198         LDKPublicKey payee_ref;
27199         CHECK((*env)->GetArrayLength(env, payee) == 33);
27200         (*env)->GetByteArrayRegion(env, payee, 0, 33, payee_ref.compressed_form);
27201         LDKInvoiceFeatures payee_features_conv;
27202         payee_features_conv.inner = (void*)(payee_features & (~1));
27203         payee_features_conv.is_owned = (payee_features & 1) || (payee_features == 0);
27204         payee_features_conv = InvoiceFeatures_clone(&payee_features_conv);
27205         LDKCVec_ChannelDetailsZ first_hops_constr;
27206         LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
27207         if (first_hops != NULL) {
27208                 first_hops_constr.datalen = (*env)->GetArrayLength(env, first_hops);
27209                 if (first_hops_constr.datalen > 0)
27210                         first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
27211                 else
27212                         first_hops_constr.data = NULL;
27213                 int64_t* first_hops_vals = (*env)->GetLongArrayElements (env, first_hops, NULL);
27214                 for (size_t q = 0; q < first_hops_constr.datalen; q++) {
27215                         int64_t first_hops_conv_16 = first_hops_vals[q];
27216                         LDKChannelDetails first_hops_conv_16_conv;
27217                         first_hops_conv_16_conv.inner = (void*)(first_hops_conv_16 & (~1));
27218                         first_hops_conv_16_conv.is_owned = (first_hops_conv_16 & 1) || (first_hops_conv_16 == 0);
27219                         first_hops_constr.data[q] = first_hops_conv_16_conv;
27220                 }
27221                 (*env)->ReleaseLongArrayElements(env, first_hops, first_hops_vals, 0);
27222                 first_hops_ptr = &first_hops_constr;
27223         }
27224         LDKCVec_RouteHintZ last_hops_constr;
27225         last_hops_constr.datalen = (*env)->GetArrayLength(env, last_hops);
27226         if (last_hops_constr.datalen > 0)
27227                 last_hops_constr.data = MALLOC(last_hops_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
27228         else
27229                 last_hops_constr.data = NULL;
27230         int64_t* last_hops_vals = (*env)->GetLongArrayElements (env, last_hops, NULL);
27231         for (size_t l = 0; l < last_hops_constr.datalen; l++) {
27232                 int64_t last_hops_conv_11 = last_hops_vals[l];
27233                 LDKRouteHint last_hops_conv_11_conv;
27234                 last_hops_conv_11_conv.inner = (void*)(last_hops_conv_11 & (~1));
27235                 last_hops_conv_11_conv.is_owned = (last_hops_conv_11 & 1) || (last_hops_conv_11 == 0);
27236                 last_hops_conv_11_conv = RouteHint_clone(&last_hops_conv_11_conv);
27237                 last_hops_constr.data[l] = last_hops_conv_11_conv;
27238         }
27239         (*env)->ReleaseLongArrayElements(env, last_hops, last_hops_vals, 0);
27240         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
27241         if (logger_conv.free == LDKLogger_JCalls_free) {
27242                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27243                 LDKLogger_JCalls_cloned(&logger_conv);
27244         }
27245         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
27246         *ret_conv = get_route(our_node_id_ref, &network_conv, payee_ref, payee_features_conv, first_hops_ptr, last_hops_constr, final_value_msat, final_cltv, logger_conv);
27247         if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
27248         return (uint64_t)ret_conv;
27249 }
27250
27251 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27252         LDKNetworkGraph this_obj_conv;
27253         this_obj_conv.inner = (void*)(this_obj & (~1));
27254         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27255         NetworkGraph_free(this_obj_conv);
27256 }
27257
27258 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27259         LDKNetworkGraph orig_conv;
27260         orig_conv.inner = (void*)(orig & (~1));
27261         orig_conv.is_owned = false;
27262         LDKNetworkGraph ret_var = NetworkGraph_clone(&orig_conv);
27263         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27264         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27265         uint64_t ret_ref = (uint64_t)ret_var.inner;
27266         if (ret_var.is_owned) {
27267                 ret_ref |= 1;
27268         }
27269         return ret_ref;
27270 }
27271
27272 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReadOnlyNetworkGraph_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27273         LDKReadOnlyNetworkGraph this_obj_conv;
27274         this_obj_conv.inner = (void*)(this_obj & (~1));
27275         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27276         ReadOnlyNetworkGraph_free(this_obj_conv);
27277 }
27278
27279 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
27280         if ((this_ptr & 1) != 0) return;
27281         LDKNetworkUpdate this_ptr_conv = *(LDKNetworkUpdate*)(((uint64_t)this_ptr) & ~1);
27282         FREE((void*)this_ptr);
27283         NetworkUpdate_free(this_ptr_conv);
27284 }
27285
27286 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27287         LDKNetworkUpdate* orig_conv = (LDKNetworkUpdate*)orig;
27288         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
27289         *ret_copy = NetworkUpdate_clone(orig_conv);
27290         uint64_t ret_ref = (uint64_t)ret_copy;
27291         return ret_ref;
27292 }
27293
27294 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1channel_1update_1message(JNIEnv *env, jclass clz, int64_t msg) {
27295         LDKChannelUpdate msg_conv;
27296         msg_conv.inner = (void*)(msg & (~1));
27297         msg_conv.is_owned = (msg & 1) || (msg == 0);
27298         msg_conv = ChannelUpdate_clone(&msg_conv);
27299         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
27300         *ret_copy = NetworkUpdate_channel_update_message(msg_conv);
27301         uint64_t ret_ref = (uint64_t)ret_copy;
27302         return ret_ref;
27303 }
27304
27305 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1channel_1closed(JNIEnv *env, jclass clz, int64_t short_channel_id, jboolean is_permanent) {
27306         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
27307         *ret_copy = NetworkUpdate_channel_closed(short_channel_id, is_permanent);
27308         uint64_t ret_ref = (uint64_t)ret_copy;
27309         return ret_ref;
27310 }
27311
27312 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1node_1failure(JNIEnv *env, jclass clz, int8_tArray node_id, jboolean is_permanent) {
27313         LDKPublicKey node_id_ref;
27314         CHECK((*env)->GetArrayLength(env, node_id) == 33);
27315         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
27316         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
27317         *ret_copy = NetworkUpdate_node_failure(node_id_ref, is_permanent);
27318         uint64_t ret_ref = (uint64_t)ret_copy;
27319         return ret_ref;
27320 }
27321
27322 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
27323         LDKNetworkUpdate* obj_conv = (LDKNetworkUpdate*)obj;
27324         LDKCVec_u8Z ret_var = NetworkUpdate_write(obj_conv);
27325         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
27326         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
27327         CVec_u8Z_free(ret_var);
27328         return ret_arr;
27329 }
27330
27331 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1as_1EventHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
27332         LDKNetGraphMsgHandler this_arg_conv;
27333         this_arg_conv.inner = (void*)(this_arg & (~1));
27334         this_arg_conv.is_owned = false;
27335         LDKEventHandler* ret_ret =MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
27336         *ret_ret = NetGraphMsgHandler_as_EventHandler(&this_arg_conv);
27337         return (uint64_t)ret_ret;
27338 }
27339
27340 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27341         LDKNetGraphMsgHandler this_obj_conv;
27342         this_obj_conv.inner = (void*)(this_obj & (~1));
27343         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27344         NetGraphMsgHandler_free(this_obj_conv);
27345 }
27346
27347 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1get_1network_1graph(JNIEnv *env, jclass clz, int64_t this_ptr) {
27348         LDKNetGraphMsgHandler this_ptr_conv;
27349         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27350         this_ptr_conv.is_owned = false;
27351         LDKNetworkGraph ret_var = NetGraphMsgHandler_get_network_graph(&this_ptr_conv);
27352         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27353         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27354         uint64_t ret_ref = (uint64_t)ret_var.inner;
27355         if (ret_var.is_owned) {
27356                 ret_ref |= 1;
27357         }
27358         return ret_ref;
27359 }
27360
27361 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1set_1network_1graph(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27362         LDKNetGraphMsgHandler this_ptr_conv;
27363         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27364         this_ptr_conv.is_owned = false;
27365         LDKNetworkGraph val_conv;
27366         val_conv.inner = (void*)(val & (~1));
27367         val_conv.is_owned = (val & 1) || (val == 0);
27368         val_conv = NetworkGraph_clone(&val_conv);
27369         NetGraphMsgHandler_set_network_graph(&this_ptr_conv, val_conv);
27370 }
27371
27372 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1new(JNIEnv *env, jclass clz, int64_t network_graph, int64_t chain_access, int64_t logger) {
27373         LDKNetworkGraph network_graph_conv;
27374         network_graph_conv.inner = (void*)(network_graph & (~1));
27375         network_graph_conv.is_owned = (network_graph & 1) || (network_graph == 0);
27376         network_graph_conv = NetworkGraph_clone(&network_graph_conv);
27377         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(((uint64_t)chain_access) & ~1);
27378         // Warning: we may need a move here but no clone is available for LDKCOption_AccessZ
27379         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
27380                 // Manually implement clone for Java trait instances
27381                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
27382                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27383                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
27384                 }
27385         }
27386         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
27387         if (logger_conv.free == LDKLogger_JCalls_free) {
27388                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27389                 LDKLogger_JCalls_cloned(&logger_conv);
27390         }
27391         LDKNetGraphMsgHandler ret_var = NetGraphMsgHandler_new(network_graph_conv, chain_access_conv, logger_conv);
27392         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27393         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27394         uint64_t ret_ref = (uint64_t)ret_var.inner;
27395         if (ret_var.is_owned) {
27396                 ret_ref |= 1;
27397         }
27398         return ret_ref;
27399 }
27400
27401 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1add_1chain_1access(JNIEnv *env, jclass clz, int64_t this_arg, int64_t chain_access) {
27402         LDKNetGraphMsgHandler this_arg_conv;
27403         this_arg_conv.inner = (void*)(this_arg & (~1));
27404         this_arg_conv.is_owned = false;
27405         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(((uint64_t)chain_access) & ~1);
27406         // Warning: we may need a move here but no clone is available for LDKCOption_AccessZ
27407         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
27408                 // Manually implement clone for Java trait instances
27409                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
27410                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27411                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
27412                 }
27413         }
27414         NetGraphMsgHandler_add_chain_access(&this_arg_conv, chain_access_conv);
27415 }
27416
27417 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1as_1RoutingMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
27418         LDKNetGraphMsgHandler this_arg_conv;
27419         this_arg_conv.inner = (void*)(this_arg & (~1));
27420         this_arg_conv.is_owned = false;
27421         LDKRoutingMessageHandler* ret_ret =MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
27422         *ret_ret = NetGraphMsgHandler_as_RoutingMessageHandler(&this_arg_conv);
27423         return (uint64_t)ret_ret;
27424 }
27425
27426 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
27427         LDKNetGraphMsgHandler this_arg_conv;
27428         this_arg_conv.inner = (void*)(this_arg & (~1));
27429         this_arg_conv.is_owned = false;
27430         LDKMessageSendEventsProvider* ret_ret =MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
27431         *ret_ret = NetGraphMsgHandler_as_MessageSendEventsProvider(&this_arg_conv);
27432         return (uint64_t)ret_ret;
27433 }
27434
27435 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27436         LDKDirectionalChannelInfo this_obj_conv;
27437         this_obj_conv.inner = (void*)(this_obj & (~1));
27438         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27439         DirectionalChannelInfo_free(this_obj_conv);
27440 }
27441
27442 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr) {
27443         LDKDirectionalChannelInfo this_ptr_conv;
27444         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27445         this_ptr_conv.is_owned = false;
27446         int32_t ret_val = DirectionalChannelInfo_get_last_update(&this_ptr_conv);
27447         return ret_val;
27448 }
27449
27450 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
27451         LDKDirectionalChannelInfo this_ptr_conv;
27452         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27453         this_ptr_conv.is_owned = false;
27454         DirectionalChannelInfo_set_last_update(&this_ptr_conv, val);
27455 }
27456
27457 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1enabled(JNIEnv *env, jclass clz, int64_t this_ptr) {
27458         LDKDirectionalChannelInfo this_ptr_conv;
27459         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27460         this_ptr_conv.is_owned = false;
27461         jboolean ret_val = DirectionalChannelInfo_get_enabled(&this_ptr_conv);
27462         return ret_val;
27463 }
27464
27465 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1enabled(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
27466         LDKDirectionalChannelInfo this_ptr_conv;
27467         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27468         this_ptr_conv.is_owned = false;
27469         DirectionalChannelInfo_set_enabled(&this_ptr_conv, val);
27470 }
27471
27472 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
27473         LDKDirectionalChannelInfo this_ptr_conv;
27474         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27475         this_ptr_conv.is_owned = false;
27476         int16_t ret_val = DirectionalChannelInfo_get_cltv_expiry_delta(&this_ptr_conv);
27477         return ret_val;
27478 }
27479
27480 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
27481         LDKDirectionalChannelInfo this_ptr_conv;
27482         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27483         this_ptr_conv.is_owned = false;
27484         DirectionalChannelInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
27485 }
27486
27487 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
27488         LDKDirectionalChannelInfo this_ptr_conv;
27489         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27490         this_ptr_conv.is_owned = false;
27491         int64_t ret_val = DirectionalChannelInfo_get_htlc_minimum_msat(&this_ptr_conv);
27492         return ret_val;
27493 }
27494
27495 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27496         LDKDirectionalChannelInfo this_ptr_conv;
27497         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27498         this_ptr_conv.is_owned = false;
27499         DirectionalChannelInfo_set_htlc_minimum_msat(&this_ptr_conv, val);
27500 }
27501
27502 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
27503         LDKDirectionalChannelInfo this_ptr_conv;
27504         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27505         this_ptr_conv.is_owned = false;
27506         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
27507         *ret_copy = DirectionalChannelInfo_get_htlc_maximum_msat(&this_ptr_conv);
27508         uint64_t ret_ref = (uint64_t)ret_copy;
27509         return ret_ref;
27510 }
27511
27512 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27513         LDKDirectionalChannelInfo this_ptr_conv;
27514         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27515         this_ptr_conv.is_owned = false;
27516         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
27517         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1));
27518         DirectionalChannelInfo_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
27519 }
27520
27521 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
27522         LDKDirectionalChannelInfo this_ptr_conv;
27523         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27524         this_ptr_conv.is_owned = false;
27525         LDKRoutingFees ret_var = DirectionalChannelInfo_get_fees(&this_ptr_conv);
27526         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27527         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27528         uint64_t ret_ref = (uint64_t)ret_var.inner;
27529         if (ret_var.is_owned) {
27530                 ret_ref |= 1;
27531         }
27532         return ret_ref;
27533 }
27534
27535 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1fees(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27536         LDKDirectionalChannelInfo this_ptr_conv;
27537         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27538         this_ptr_conv.is_owned = false;
27539         LDKRoutingFees val_conv;
27540         val_conv.inner = (void*)(val & (~1));
27541         val_conv.is_owned = (val & 1) || (val == 0);
27542         val_conv = RoutingFees_clone(&val_conv);
27543         DirectionalChannelInfo_set_fees(&this_ptr_conv, val_conv);
27544 }
27545
27546 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1last_1update_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
27547         LDKDirectionalChannelInfo this_ptr_conv;
27548         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27549         this_ptr_conv.is_owned = false;
27550         LDKChannelUpdate ret_var = DirectionalChannelInfo_get_last_update_message(&this_ptr_conv);
27551         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27552         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27553         uint64_t ret_ref = (uint64_t)ret_var.inner;
27554         if (ret_var.is_owned) {
27555                 ret_ref |= 1;
27556         }
27557         return ret_ref;
27558 }
27559
27560 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1last_1update_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27561         LDKDirectionalChannelInfo this_ptr_conv;
27562         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27563         this_ptr_conv.is_owned = false;
27564         LDKChannelUpdate val_conv;
27565         val_conv.inner = (void*)(val & (~1));
27566         val_conv.is_owned = (val & 1) || (val == 0);
27567         val_conv = ChannelUpdate_clone(&val_conv);
27568         DirectionalChannelInfo_set_last_update_message(&this_ptr_conv, val_conv);
27569 }
27570
27571 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) {
27572         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)htlc_maximum_msat_arg) & ~1);
27573         htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)htlc_maximum_msat_arg) & ~1));
27574         LDKRoutingFees fees_arg_conv;
27575         fees_arg_conv.inner = (void*)(fees_arg & (~1));
27576         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
27577         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
27578         LDKChannelUpdate last_update_message_arg_conv;
27579         last_update_message_arg_conv.inner = (void*)(last_update_message_arg & (~1));
27580         last_update_message_arg_conv.is_owned = (last_update_message_arg & 1) || (last_update_message_arg == 0);
27581         last_update_message_arg_conv = ChannelUpdate_clone(&last_update_message_arg_conv);
27582         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);
27583         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27584         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27585         uint64_t ret_ref = (uint64_t)ret_var.inner;
27586         if (ret_var.is_owned) {
27587                 ret_ref |= 1;
27588         }
27589         return ret_ref;
27590 }
27591
27592 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27593         LDKDirectionalChannelInfo orig_conv;
27594         orig_conv.inner = (void*)(orig & (~1));
27595         orig_conv.is_owned = false;
27596         LDKDirectionalChannelInfo ret_var = DirectionalChannelInfo_clone(&orig_conv);
27597         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27598         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27599         uint64_t ret_ref = (uint64_t)ret_var.inner;
27600         if (ret_var.is_owned) {
27601                 ret_ref |= 1;
27602         }
27603         return ret_ref;
27604 }
27605
27606 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
27607         LDKDirectionalChannelInfo obj_conv;
27608         obj_conv.inner = (void*)(obj & (~1));
27609         obj_conv.is_owned = false;
27610         LDKCVec_u8Z ret_var = DirectionalChannelInfo_write(&obj_conv);
27611         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
27612         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
27613         CVec_u8Z_free(ret_var);
27614         return ret_arr;
27615 }
27616
27617 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
27618         LDKu8slice ser_ref;
27619         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
27620         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
27621         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
27622         *ret_conv = DirectionalChannelInfo_read(ser_ref);
27623         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
27624         return (uint64_t)ret_conv;
27625 }
27626
27627 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27628         LDKChannelInfo this_obj_conv;
27629         this_obj_conv.inner = (void*)(this_obj & (~1));
27630         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27631         ChannelInfo_free(this_obj_conv);
27632 }
27633
27634 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
27635         LDKChannelInfo this_ptr_conv;
27636         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27637         this_ptr_conv.is_owned = false;
27638         LDKChannelFeatures ret_var = ChannelInfo_get_features(&this_ptr_conv);
27639         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27640         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27641         uint64_t ret_ref = (uint64_t)ret_var.inner;
27642         if (ret_var.is_owned) {
27643                 ret_ref |= 1;
27644         }
27645         return ret_ref;
27646 }
27647
27648 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27649         LDKChannelInfo this_ptr_conv;
27650         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27651         this_ptr_conv.is_owned = false;
27652         LDKChannelFeatures val_conv;
27653         val_conv.inner = (void*)(val & (~1));
27654         val_conv.is_owned = (val & 1) || (val == 0);
27655         val_conv = ChannelFeatures_clone(&val_conv);
27656         ChannelInfo_set_features(&this_ptr_conv, val_conv);
27657 }
27658
27659 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1node_1one(JNIEnv *env, jclass clz, int64_t this_ptr) {
27660         LDKChannelInfo this_ptr_conv;
27661         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27662         this_ptr_conv.is_owned = false;
27663         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
27664         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelInfo_get_node_one(&this_ptr_conv).compressed_form);
27665         return ret_arr;
27666 }
27667
27668 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1node_1one(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
27669         LDKChannelInfo this_ptr_conv;
27670         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27671         this_ptr_conv.is_owned = false;
27672         LDKPublicKey val_ref;
27673         CHECK((*env)->GetArrayLength(env, val) == 33);
27674         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
27675         ChannelInfo_set_node_one(&this_ptr_conv, val_ref);
27676 }
27677
27678 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1one_1to_1two(JNIEnv *env, jclass clz, int64_t this_ptr) {
27679         LDKChannelInfo this_ptr_conv;
27680         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27681         this_ptr_conv.is_owned = false;
27682         LDKDirectionalChannelInfo ret_var = ChannelInfo_get_one_to_two(&this_ptr_conv);
27683         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27684         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27685         uint64_t ret_ref = (uint64_t)ret_var.inner;
27686         if (ret_var.is_owned) {
27687                 ret_ref |= 1;
27688         }
27689         return ret_ref;
27690 }
27691
27692 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1one_1to_1two(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27693         LDKChannelInfo this_ptr_conv;
27694         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27695         this_ptr_conv.is_owned = false;
27696         LDKDirectionalChannelInfo val_conv;
27697         val_conv.inner = (void*)(val & (~1));
27698         val_conv.is_owned = (val & 1) || (val == 0);
27699         val_conv = DirectionalChannelInfo_clone(&val_conv);
27700         ChannelInfo_set_one_to_two(&this_ptr_conv, val_conv);
27701 }
27702
27703 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1node_1two(JNIEnv *env, jclass clz, int64_t this_ptr) {
27704         LDKChannelInfo this_ptr_conv;
27705         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27706         this_ptr_conv.is_owned = false;
27707         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
27708         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelInfo_get_node_two(&this_ptr_conv).compressed_form);
27709         return ret_arr;
27710 }
27711
27712 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1node_1two(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
27713         LDKChannelInfo this_ptr_conv;
27714         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27715         this_ptr_conv.is_owned = false;
27716         LDKPublicKey val_ref;
27717         CHECK((*env)->GetArrayLength(env, val) == 33);
27718         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
27719         ChannelInfo_set_node_two(&this_ptr_conv, val_ref);
27720 }
27721
27722 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1two_1to_1one(JNIEnv *env, jclass clz, int64_t this_ptr) {
27723         LDKChannelInfo this_ptr_conv;
27724         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27725         this_ptr_conv.is_owned = false;
27726         LDKDirectionalChannelInfo ret_var = ChannelInfo_get_two_to_one(&this_ptr_conv);
27727         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27728         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27729         uint64_t ret_ref = (uint64_t)ret_var.inner;
27730         if (ret_var.is_owned) {
27731                 ret_ref |= 1;
27732         }
27733         return ret_ref;
27734 }
27735
27736 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1two_1to_1one(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27737         LDKChannelInfo this_ptr_conv;
27738         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27739         this_ptr_conv.is_owned = false;
27740         LDKDirectionalChannelInfo val_conv;
27741         val_conv.inner = (void*)(val & (~1));
27742         val_conv.is_owned = (val & 1) || (val == 0);
27743         val_conv = DirectionalChannelInfo_clone(&val_conv);
27744         ChannelInfo_set_two_to_one(&this_ptr_conv, val_conv);
27745 }
27746
27747 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1capacity_1sats(JNIEnv *env, jclass clz, int64_t this_ptr) {
27748         LDKChannelInfo this_ptr_conv;
27749         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27750         this_ptr_conv.is_owned = false;
27751         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
27752         *ret_copy = ChannelInfo_get_capacity_sats(&this_ptr_conv);
27753         uint64_t ret_ref = (uint64_t)ret_copy;
27754         return ret_ref;
27755 }
27756
27757 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1capacity_1sats(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27758         LDKChannelInfo this_ptr_conv;
27759         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27760         this_ptr_conv.is_owned = false;
27761         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
27762         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1));
27763         ChannelInfo_set_capacity_sats(&this_ptr_conv, val_conv);
27764 }
27765
27766 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
27767         LDKChannelInfo this_ptr_conv;
27768         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27769         this_ptr_conv.is_owned = false;
27770         LDKChannelAnnouncement ret_var = ChannelInfo_get_announcement_message(&this_ptr_conv);
27771         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27772         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27773         uint64_t ret_ref = (uint64_t)ret_var.inner;
27774         if (ret_var.is_owned) {
27775                 ret_ref |= 1;
27776         }
27777         return ret_ref;
27778 }
27779
27780 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27781         LDKChannelInfo this_ptr_conv;
27782         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27783         this_ptr_conv.is_owned = false;
27784         LDKChannelAnnouncement val_conv;
27785         val_conv.inner = (void*)(val & (~1));
27786         val_conv.is_owned = (val & 1) || (val == 0);
27787         val_conv = ChannelAnnouncement_clone(&val_conv);
27788         ChannelInfo_set_announcement_message(&this_ptr_conv, val_conv);
27789 }
27790
27791 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) {
27792         LDKChannelFeatures features_arg_conv;
27793         features_arg_conv.inner = (void*)(features_arg & (~1));
27794         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
27795         features_arg_conv = ChannelFeatures_clone(&features_arg_conv);
27796         LDKPublicKey node_one_arg_ref;
27797         CHECK((*env)->GetArrayLength(env, node_one_arg) == 33);
27798         (*env)->GetByteArrayRegion(env, node_one_arg, 0, 33, node_one_arg_ref.compressed_form);
27799         LDKDirectionalChannelInfo one_to_two_arg_conv;
27800         one_to_two_arg_conv.inner = (void*)(one_to_two_arg & (~1));
27801         one_to_two_arg_conv.is_owned = (one_to_two_arg & 1) || (one_to_two_arg == 0);
27802         one_to_two_arg_conv = DirectionalChannelInfo_clone(&one_to_two_arg_conv);
27803         LDKPublicKey node_two_arg_ref;
27804         CHECK((*env)->GetArrayLength(env, node_two_arg) == 33);
27805         (*env)->GetByteArrayRegion(env, node_two_arg, 0, 33, node_two_arg_ref.compressed_form);
27806         LDKDirectionalChannelInfo two_to_one_arg_conv;
27807         two_to_one_arg_conv.inner = (void*)(two_to_one_arg & (~1));
27808         two_to_one_arg_conv.is_owned = (two_to_one_arg & 1) || (two_to_one_arg == 0);
27809         two_to_one_arg_conv = DirectionalChannelInfo_clone(&two_to_one_arg_conv);
27810         LDKCOption_u64Z capacity_sats_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)capacity_sats_arg) & ~1);
27811         capacity_sats_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)capacity_sats_arg) & ~1));
27812         LDKChannelAnnouncement announcement_message_arg_conv;
27813         announcement_message_arg_conv.inner = (void*)(announcement_message_arg & (~1));
27814         announcement_message_arg_conv.is_owned = (announcement_message_arg & 1) || (announcement_message_arg == 0);
27815         announcement_message_arg_conv = ChannelAnnouncement_clone(&announcement_message_arg_conv);
27816         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);
27817         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27818         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27819         uint64_t ret_ref = (uint64_t)ret_var.inner;
27820         if (ret_var.is_owned) {
27821                 ret_ref |= 1;
27822         }
27823         return ret_ref;
27824 }
27825
27826 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27827         LDKChannelInfo orig_conv;
27828         orig_conv.inner = (void*)(orig & (~1));
27829         orig_conv.is_owned = false;
27830         LDKChannelInfo ret_var = ChannelInfo_clone(&orig_conv);
27831         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27832         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27833         uint64_t ret_ref = (uint64_t)ret_var.inner;
27834         if (ret_var.is_owned) {
27835                 ret_ref |= 1;
27836         }
27837         return ret_ref;
27838 }
27839
27840 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
27841         LDKChannelInfo obj_conv;
27842         obj_conv.inner = (void*)(obj & (~1));
27843         obj_conv.is_owned = false;
27844         LDKCVec_u8Z ret_var = ChannelInfo_write(&obj_conv);
27845         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
27846         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
27847         CVec_u8Z_free(ret_var);
27848         return ret_arr;
27849 }
27850
27851 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
27852         LDKu8slice ser_ref;
27853         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
27854         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
27855         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
27856         *ret_conv = ChannelInfo_read(ser_ref);
27857         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
27858         return (uint64_t)ret_conv;
27859 }
27860
27861 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27862         LDKRoutingFees this_obj_conv;
27863         this_obj_conv.inner = (void*)(this_obj & (~1));
27864         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27865         RoutingFees_free(this_obj_conv);
27866 }
27867
27868 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1get_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
27869         LDKRoutingFees this_ptr_conv;
27870         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27871         this_ptr_conv.is_owned = false;
27872         int32_t ret_val = RoutingFees_get_base_msat(&this_ptr_conv);
27873         return ret_val;
27874 }
27875
27876 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1set_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
27877         LDKRoutingFees this_ptr_conv;
27878         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27879         this_ptr_conv.is_owned = false;
27880         RoutingFees_set_base_msat(&this_ptr_conv, val);
27881 }
27882
27883 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1get_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
27884         LDKRoutingFees this_ptr_conv;
27885         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27886         this_ptr_conv.is_owned = false;
27887         int32_t ret_val = RoutingFees_get_proportional_millionths(&this_ptr_conv);
27888         return ret_val;
27889 }
27890
27891 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1set_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
27892         LDKRoutingFees this_ptr_conv;
27893         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27894         this_ptr_conv.is_owned = false;
27895         RoutingFees_set_proportional_millionths(&this_ptr_conv, val);
27896 }
27897
27898 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) {
27899         LDKRoutingFees ret_var = RoutingFees_new(base_msat_arg, proportional_millionths_arg);
27900         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27901         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27902         uint64_t ret_ref = (uint64_t)ret_var.inner;
27903         if (ret_var.is_owned) {
27904                 ret_ref |= 1;
27905         }
27906         return ret_ref;
27907 }
27908
27909 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RoutingFees_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
27910         LDKRoutingFees a_conv;
27911         a_conv.inner = (void*)(a & (~1));
27912         a_conv.is_owned = false;
27913         LDKRoutingFees b_conv;
27914         b_conv.inner = (void*)(b & (~1));
27915         b_conv.is_owned = false;
27916         jboolean ret_val = RoutingFees_eq(&a_conv, &b_conv);
27917         return ret_val;
27918 }
27919
27920 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27921         LDKRoutingFees orig_conv;
27922         orig_conv.inner = (void*)(orig & (~1));
27923         orig_conv.is_owned = false;
27924         LDKRoutingFees ret_var = RoutingFees_clone(&orig_conv);
27925         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27926         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27927         uint64_t ret_ref = (uint64_t)ret_var.inner;
27928         if (ret_var.is_owned) {
27929                 ret_ref |= 1;
27930         }
27931         return ret_ref;
27932 }
27933
27934 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1hash(JNIEnv *env, jclass clz, int64_t o) {
27935         LDKRoutingFees o_conv;
27936         o_conv.inner = (void*)(o & (~1));
27937         o_conv.is_owned = false;
27938         int64_t ret_val = RoutingFees_hash(&o_conv);
27939         return ret_val;
27940 }
27941
27942 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RoutingFees_1write(JNIEnv *env, jclass clz, int64_t obj) {
27943         LDKRoutingFees obj_conv;
27944         obj_conv.inner = (void*)(obj & (~1));
27945         obj_conv.is_owned = false;
27946         LDKCVec_u8Z ret_var = RoutingFees_write(&obj_conv);
27947         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
27948         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
27949         CVec_u8Z_free(ret_var);
27950         return ret_arr;
27951 }
27952
27953 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
27954         LDKu8slice ser_ref;
27955         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
27956         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
27957         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
27958         *ret_conv = RoutingFees_read(ser_ref);
27959         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
27960         return (uint64_t)ret_conv;
27961 }
27962
27963 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27964         LDKNodeAnnouncementInfo this_obj_conv;
27965         this_obj_conv.inner = (void*)(this_obj & (~1));
27966         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27967         NodeAnnouncementInfo_free(this_obj_conv);
27968 }
27969
27970 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
27971         LDKNodeAnnouncementInfo this_ptr_conv;
27972         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27973         this_ptr_conv.is_owned = false;
27974         LDKNodeFeatures ret_var = NodeAnnouncementInfo_get_features(&this_ptr_conv);
27975         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27976         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27977         uint64_t ret_ref = (uint64_t)ret_var.inner;
27978         if (ret_var.is_owned) {
27979                 ret_ref |= 1;
27980         }
27981         return ret_ref;
27982 }
27983
27984 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27985         LDKNodeAnnouncementInfo this_ptr_conv;
27986         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27987         this_ptr_conv.is_owned = false;
27988         LDKNodeFeatures val_conv;
27989         val_conv.inner = (void*)(val & (~1));
27990         val_conv.is_owned = (val & 1) || (val == 0);
27991         val_conv = NodeFeatures_clone(&val_conv);
27992         NodeAnnouncementInfo_set_features(&this_ptr_conv, val_conv);
27993 }
27994
27995 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr) {
27996         LDKNodeAnnouncementInfo this_ptr_conv;
27997         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27998         this_ptr_conv.is_owned = false;
27999         int32_t ret_val = NodeAnnouncementInfo_get_last_update(&this_ptr_conv);
28000         return ret_val;
28001 }
28002
28003 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
28004         LDKNodeAnnouncementInfo this_ptr_conv;
28005         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28006         this_ptr_conv.is_owned = false;
28007         NodeAnnouncementInfo_set_last_update(&this_ptr_conv, val);
28008 }
28009
28010 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr) {
28011         LDKNodeAnnouncementInfo this_ptr_conv;
28012         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28013         this_ptr_conv.is_owned = false;
28014         int8_tArray ret_arr = (*env)->NewByteArray(env, 3);
28015         (*env)->SetByteArrayRegion(env, ret_arr, 0, 3, *NodeAnnouncementInfo_get_rgb(&this_ptr_conv));
28016         return ret_arr;
28017 }
28018
28019 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28020         LDKNodeAnnouncementInfo this_ptr_conv;
28021         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28022         this_ptr_conv.is_owned = false;
28023         LDKThreeBytes val_ref;
28024         CHECK((*env)->GetArrayLength(env, val) == 3);
28025         (*env)->GetByteArrayRegion(env, val, 0, 3, val_ref.data);
28026         NodeAnnouncementInfo_set_rgb(&this_ptr_conv, val_ref);
28027 }
28028
28029 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
28030         LDKNodeAnnouncementInfo this_ptr_conv;
28031         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28032         this_ptr_conv.is_owned = false;
28033         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
28034         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *NodeAnnouncementInfo_get_alias(&this_ptr_conv));
28035         return ret_arr;
28036 }
28037
28038 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28039         LDKNodeAnnouncementInfo this_ptr_conv;
28040         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28041         this_ptr_conv.is_owned = false;
28042         LDKThirtyTwoBytes val_ref;
28043         CHECK((*env)->GetArrayLength(env, val) == 32);
28044         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
28045         NodeAnnouncementInfo_set_alias(&this_ptr_conv, val_ref);
28046 }
28047
28048 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1addresses(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
28049         LDKNodeAnnouncementInfo this_ptr_conv;
28050         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28051         this_ptr_conv.is_owned = false;
28052         LDKCVec_NetAddressZ val_constr;
28053         val_constr.datalen = (*env)->GetArrayLength(env, val);
28054         if (val_constr.datalen > 0)
28055                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
28056         else
28057                 val_constr.data = NULL;
28058         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
28059         for (size_t m = 0; m < val_constr.datalen; m++) {
28060                 int64_t val_conv_12 = val_vals[m];
28061                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(((uint64_t)val_conv_12) & ~1);
28062                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)val_conv_12) & ~1));
28063                 val_constr.data[m] = val_conv_12_conv;
28064         }
28065         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
28066         NodeAnnouncementInfo_set_addresses(&this_ptr_conv, val_constr);
28067 }
28068
28069 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
28070         LDKNodeAnnouncementInfo this_ptr_conv;
28071         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28072         this_ptr_conv.is_owned = false;
28073         LDKNodeAnnouncement ret_var = NodeAnnouncementInfo_get_announcement_message(&this_ptr_conv);
28074         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28075         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28076         uint64_t ret_ref = (uint64_t)ret_var.inner;
28077         if (ret_var.is_owned) {
28078                 ret_ref |= 1;
28079         }
28080         return ret_ref;
28081 }
28082
28083 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28084         LDKNodeAnnouncementInfo this_ptr_conv;
28085         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28086         this_ptr_conv.is_owned = false;
28087         LDKNodeAnnouncement val_conv;
28088         val_conv.inner = (void*)(val & (~1));
28089         val_conv.is_owned = (val & 1) || (val == 0);
28090         val_conv = NodeAnnouncement_clone(&val_conv);
28091         NodeAnnouncementInfo_set_announcement_message(&this_ptr_conv, val_conv);
28092 }
28093
28094 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) {
28095         LDKNodeFeatures features_arg_conv;
28096         features_arg_conv.inner = (void*)(features_arg & (~1));
28097         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
28098         features_arg_conv = NodeFeatures_clone(&features_arg_conv);
28099         LDKThreeBytes rgb_arg_ref;
28100         CHECK((*env)->GetArrayLength(env, rgb_arg) == 3);
28101         (*env)->GetByteArrayRegion(env, rgb_arg, 0, 3, rgb_arg_ref.data);
28102         LDKThirtyTwoBytes alias_arg_ref;
28103         CHECK((*env)->GetArrayLength(env, alias_arg) == 32);
28104         (*env)->GetByteArrayRegion(env, alias_arg, 0, 32, alias_arg_ref.data);
28105         LDKCVec_NetAddressZ addresses_arg_constr;
28106         addresses_arg_constr.datalen = (*env)->GetArrayLength(env, addresses_arg);
28107         if (addresses_arg_constr.datalen > 0)
28108                 addresses_arg_constr.data = MALLOC(addresses_arg_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
28109         else
28110                 addresses_arg_constr.data = NULL;
28111         int64_t* addresses_arg_vals = (*env)->GetLongArrayElements (env, addresses_arg, NULL);
28112         for (size_t m = 0; m < addresses_arg_constr.datalen; m++) {
28113                 int64_t addresses_arg_conv_12 = addresses_arg_vals[m];
28114                 LDKNetAddress addresses_arg_conv_12_conv = *(LDKNetAddress*)(((uint64_t)addresses_arg_conv_12) & ~1);
28115                 addresses_arg_constr.data[m] = addresses_arg_conv_12_conv;
28116         }
28117         (*env)->ReleaseLongArrayElements(env, addresses_arg, addresses_arg_vals, 0);
28118         LDKNodeAnnouncement announcement_message_arg_conv;
28119         announcement_message_arg_conv.inner = (void*)(announcement_message_arg & (~1));
28120         announcement_message_arg_conv.is_owned = (announcement_message_arg & 1) || (announcement_message_arg == 0);
28121         announcement_message_arg_conv = NodeAnnouncement_clone(&announcement_message_arg_conv);
28122         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_new(features_arg_conv, last_update_arg, rgb_arg_ref, alias_arg_ref, addresses_arg_constr, announcement_message_arg_conv);
28123         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28124         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28125         uint64_t ret_ref = (uint64_t)ret_var.inner;
28126         if (ret_var.is_owned) {
28127                 ret_ref |= 1;
28128         }
28129         return ret_ref;
28130 }
28131
28132 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28133         LDKNodeAnnouncementInfo orig_conv;
28134         orig_conv.inner = (void*)(orig & (~1));
28135         orig_conv.is_owned = false;
28136         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(&orig_conv);
28137         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28138         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28139         uint64_t ret_ref = (uint64_t)ret_var.inner;
28140         if (ret_var.is_owned) {
28141                 ret_ref |= 1;
28142         }
28143         return ret_ref;
28144 }
28145
28146 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
28147         LDKNodeAnnouncementInfo obj_conv;
28148         obj_conv.inner = (void*)(obj & (~1));
28149         obj_conv.is_owned = false;
28150         LDKCVec_u8Z ret_var = NodeAnnouncementInfo_write(&obj_conv);
28151         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
28152         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
28153         CVec_u8Z_free(ret_var);
28154         return ret_arr;
28155 }
28156
28157 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
28158         LDKu8slice ser_ref;
28159         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
28160         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
28161         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
28162         *ret_conv = NodeAnnouncementInfo_read(ser_ref);
28163         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
28164         return (uint64_t)ret_conv;
28165 }
28166
28167 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28168         LDKNodeInfo this_obj_conv;
28169         this_obj_conv.inner = (void*)(this_obj & (~1));
28170         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28171         NodeInfo_free(this_obj_conv);
28172 }
28173
28174 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
28175         LDKNodeInfo this_ptr_conv;
28176         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28177         this_ptr_conv.is_owned = false;
28178         LDKCVec_u64Z val_constr;
28179         val_constr.datalen = (*env)->GetArrayLength(env, val);
28180         if (val_constr.datalen > 0)
28181                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
28182         else
28183                 val_constr.data = NULL;
28184         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
28185         for (size_t g = 0; g < val_constr.datalen; g++) {
28186                 int64_t val_conv_6 = val_vals[g];
28187                 val_constr.data[g] = val_conv_6;
28188         }
28189         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
28190         NodeInfo_set_channels(&this_ptr_conv, val_constr);
28191 }
28192
28193 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1lowest_1inbound_1channel_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
28194         LDKNodeInfo this_ptr_conv;
28195         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28196         this_ptr_conv.is_owned = false;
28197         LDKRoutingFees ret_var = NodeInfo_get_lowest_inbound_channel_fees(&this_ptr_conv);
28198         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28199         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28200         uint64_t ret_ref = (uint64_t)ret_var.inner;
28201         if (ret_var.is_owned) {
28202                 ret_ref |= 1;
28203         }
28204         return ret_ref;
28205 }
28206
28207 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) {
28208         LDKNodeInfo this_ptr_conv;
28209         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28210         this_ptr_conv.is_owned = false;
28211         LDKRoutingFees val_conv;
28212         val_conv.inner = (void*)(val & (~1));
28213         val_conv.is_owned = (val & 1) || (val == 0);
28214         val_conv = RoutingFees_clone(&val_conv);
28215         NodeInfo_set_lowest_inbound_channel_fees(&this_ptr_conv, val_conv);
28216 }
28217
28218 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1announcement_1info(JNIEnv *env, jclass clz, int64_t this_ptr) {
28219         LDKNodeInfo this_ptr_conv;
28220         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28221         this_ptr_conv.is_owned = false;
28222         LDKNodeAnnouncementInfo ret_var = NodeInfo_get_announcement_info(&this_ptr_conv);
28223         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28224         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28225         uint64_t ret_ref = (uint64_t)ret_var.inner;
28226         if (ret_var.is_owned) {
28227                 ret_ref |= 1;
28228         }
28229         return ret_ref;
28230 }
28231
28232 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1announcement_1info(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28233         LDKNodeInfo this_ptr_conv;
28234         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28235         this_ptr_conv.is_owned = false;
28236         LDKNodeAnnouncementInfo val_conv;
28237         val_conv.inner = (void*)(val & (~1));
28238         val_conv.is_owned = (val & 1) || (val == 0);
28239         val_conv = NodeAnnouncementInfo_clone(&val_conv);
28240         NodeInfo_set_announcement_info(&this_ptr_conv, val_conv);
28241 }
28242
28243 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) {
28244         LDKCVec_u64Z channels_arg_constr;
28245         channels_arg_constr.datalen = (*env)->GetArrayLength(env, channels_arg);
28246         if (channels_arg_constr.datalen > 0)
28247                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
28248         else
28249                 channels_arg_constr.data = NULL;
28250         int64_t* channels_arg_vals = (*env)->GetLongArrayElements (env, channels_arg, NULL);
28251         for (size_t g = 0; g < channels_arg_constr.datalen; g++) {
28252                 int64_t channels_arg_conv_6 = channels_arg_vals[g];
28253                 channels_arg_constr.data[g] = channels_arg_conv_6;
28254         }
28255         (*env)->ReleaseLongArrayElements(env, channels_arg, channels_arg_vals, 0);
28256         LDKRoutingFees lowest_inbound_channel_fees_arg_conv;
28257         lowest_inbound_channel_fees_arg_conv.inner = (void*)(lowest_inbound_channel_fees_arg & (~1));
28258         lowest_inbound_channel_fees_arg_conv.is_owned = (lowest_inbound_channel_fees_arg & 1) || (lowest_inbound_channel_fees_arg == 0);
28259         lowest_inbound_channel_fees_arg_conv = RoutingFees_clone(&lowest_inbound_channel_fees_arg_conv);
28260         LDKNodeAnnouncementInfo announcement_info_arg_conv;
28261         announcement_info_arg_conv.inner = (void*)(announcement_info_arg & (~1));
28262         announcement_info_arg_conv.is_owned = (announcement_info_arg & 1) || (announcement_info_arg == 0);
28263         announcement_info_arg_conv = NodeAnnouncementInfo_clone(&announcement_info_arg_conv);
28264         LDKNodeInfo ret_var = NodeInfo_new(channels_arg_constr, lowest_inbound_channel_fees_arg_conv, announcement_info_arg_conv);
28265         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28266         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28267         uint64_t ret_ref = (uint64_t)ret_var.inner;
28268         if (ret_var.is_owned) {
28269                 ret_ref |= 1;
28270         }
28271         return ret_ref;
28272 }
28273
28274 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28275         LDKNodeInfo orig_conv;
28276         orig_conv.inner = (void*)(orig & (~1));
28277         orig_conv.is_owned = false;
28278         LDKNodeInfo ret_var = NodeInfo_clone(&orig_conv);
28279         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28280         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28281         uint64_t ret_ref = (uint64_t)ret_var.inner;
28282         if (ret_var.is_owned) {
28283                 ret_ref |= 1;
28284         }
28285         return ret_ref;
28286 }
28287
28288 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
28289         LDKNodeInfo obj_conv;
28290         obj_conv.inner = (void*)(obj & (~1));
28291         obj_conv.is_owned = false;
28292         LDKCVec_u8Z ret_var = NodeInfo_write(&obj_conv);
28293         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
28294         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
28295         CVec_u8Z_free(ret_var);
28296         return ret_arr;
28297 }
28298
28299 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
28300         LDKu8slice ser_ref;
28301         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
28302         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
28303         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
28304         *ret_conv = NodeInfo_read(ser_ref);
28305         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
28306         return (uint64_t)ret_conv;
28307 }
28308
28309 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1write(JNIEnv *env, jclass clz, int64_t obj) {
28310         LDKNetworkGraph obj_conv;
28311         obj_conv.inner = (void*)(obj & (~1));
28312         obj_conv.is_owned = false;
28313         LDKCVec_u8Z ret_var = NetworkGraph_write(&obj_conv);
28314         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
28315         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
28316         CVec_u8Z_free(ret_var);
28317         return ret_arr;
28318 }
28319
28320 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
28321         LDKu8slice ser_ref;
28322         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
28323         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
28324         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
28325         *ret_conv = NetworkGraph_read(ser_ref);
28326         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
28327         return (uint64_t)ret_conv;
28328 }
28329
28330 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1new(JNIEnv *env, jclass clz, int8_tArray genesis_hash) {
28331         LDKThirtyTwoBytes genesis_hash_ref;
28332         CHECK((*env)->GetArrayLength(env, genesis_hash) == 32);
28333         (*env)->GetByteArrayRegion(env, genesis_hash, 0, 32, genesis_hash_ref.data);
28334         LDKNetworkGraph ret_var = NetworkGraph_new(genesis_hash_ref);
28335         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28336         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28337         uint64_t ret_ref = (uint64_t)ret_var.inner;
28338         if (ret_var.is_owned) {
28339                 ret_ref |= 1;
28340         }
28341         return ret_ref;
28342 }
28343
28344 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1read_1only(JNIEnv *env, jclass clz, int64_t this_arg) {
28345         LDKNetworkGraph this_arg_conv;
28346         this_arg_conv.inner = (void*)(this_arg & (~1));
28347         this_arg_conv.is_owned = false;
28348         LDKReadOnlyNetworkGraph ret_var = NetworkGraph_read_only(&this_arg_conv);
28349         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28350         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28351         uint64_t ret_ref = (uint64_t)ret_var.inner;
28352         if (ret_var.is_owned) {
28353                 ret_ref |= 1;
28354         }
28355         return ret_ref;
28356 }
28357
28358 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) {
28359         LDKNetworkGraph this_arg_conv;
28360         this_arg_conv.inner = (void*)(this_arg & (~1));
28361         this_arg_conv.is_owned = false;
28362         LDKNodeAnnouncement msg_conv;
28363         msg_conv.inner = (void*)(msg & (~1));
28364         msg_conv.is_owned = false;
28365         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
28366         *ret_conv = NetworkGraph_update_node_from_announcement(&this_arg_conv, &msg_conv);
28367         return (uint64_t)ret_conv;
28368 }
28369
28370 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) {
28371         LDKNetworkGraph this_arg_conv;
28372         this_arg_conv.inner = (void*)(this_arg & (~1));
28373         this_arg_conv.is_owned = false;
28374         LDKUnsignedNodeAnnouncement msg_conv;
28375         msg_conv.inner = (void*)(msg & (~1));
28376         msg_conv.is_owned = false;
28377         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
28378         *ret_conv = NetworkGraph_update_node_from_unsigned_announcement(&this_arg_conv, &msg_conv);
28379         return (uint64_t)ret_conv;
28380 }
28381
28382 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) {
28383         LDKNetworkGraph this_arg_conv;
28384         this_arg_conv.inner = (void*)(this_arg & (~1));
28385         this_arg_conv.is_owned = false;
28386         LDKChannelAnnouncement msg_conv;
28387         msg_conv.inner = (void*)(msg & (~1));
28388         msg_conv.is_owned = false;
28389         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(((uint64_t)chain_access) & ~1);
28390         // Warning: we may need a move here but no clone is available for LDKCOption_AccessZ
28391         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
28392                 // Manually implement clone for Java trait instances
28393                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
28394                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
28395                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
28396                 }
28397         }
28398         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
28399         *ret_conv = NetworkGraph_update_channel_from_announcement(&this_arg_conv, &msg_conv, chain_access_conv);
28400         return (uint64_t)ret_conv;
28401 }
28402
28403 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) {
28404         LDKNetworkGraph this_arg_conv;
28405         this_arg_conv.inner = (void*)(this_arg & (~1));
28406         this_arg_conv.is_owned = false;
28407         LDKUnsignedChannelAnnouncement msg_conv;
28408         msg_conv.inner = (void*)(msg & (~1));
28409         msg_conv.is_owned = false;
28410         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(((uint64_t)chain_access) & ~1);
28411         // Warning: we may need a move here but no clone is available for LDKCOption_AccessZ
28412         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
28413                 // Manually implement clone for Java trait instances
28414                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
28415                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
28416                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
28417                 }
28418         }
28419         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
28420         *ret_conv = NetworkGraph_update_channel_from_unsigned_announcement(&this_arg_conv, &msg_conv, chain_access_conv);
28421         return (uint64_t)ret_conv;
28422 }
28423
28424 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) {
28425         LDKNetworkGraph this_arg_conv;
28426         this_arg_conv.inner = (void*)(this_arg & (~1));
28427         this_arg_conv.is_owned = false;
28428         NetworkGraph_close_channel_from_update(&this_arg_conv, short_channel_id, is_permanent);
28429 }
28430
28431 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1fail_1node(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray _node_id, jboolean is_permanent) {
28432         LDKNetworkGraph this_arg_conv;
28433         this_arg_conv.inner = (void*)(this_arg & (~1));
28434         this_arg_conv.is_owned = false;
28435         LDKPublicKey _node_id_ref;
28436         CHECK((*env)->GetArrayLength(env, _node_id) == 33);
28437         (*env)->GetByteArrayRegion(env, _node_id, 0, 33, _node_id_ref.compressed_form);
28438         NetworkGraph_fail_node(&this_arg_conv, _node_id_ref, is_permanent);
28439 }
28440
28441 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1update_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
28442         LDKNetworkGraph this_arg_conv;
28443         this_arg_conv.inner = (void*)(this_arg & (~1));
28444         this_arg_conv.is_owned = false;
28445         LDKChannelUpdate msg_conv;
28446         msg_conv.inner = (void*)(msg & (~1));
28447         msg_conv.is_owned = false;
28448         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
28449         *ret_conv = NetworkGraph_update_channel(&this_arg_conv, &msg_conv);
28450         return (uint64_t)ret_conv;
28451 }
28452
28453 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1update_1channel_1unsigned(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
28454         LDKNetworkGraph this_arg_conv;
28455         this_arg_conv.inner = (void*)(this_arg & (~1));
28456         this_arg_conv.is_owned = false;
28457         LDKUnsignedChannelUpdate msg_conv;
28458         msg_conv.inner = (void*)(msg & (~1));
28459         msg_conv.is_owned = false;
28460         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
28461         *ret_conv = NetworkGraph_update_channel_unsigned(&this_arg_conv, &msg_conv);
28462         return (uint64_t)ret_conv;
28463 }
28464
28465 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28466         LDKFilesystemPersister this_obj_conv;
28467         this_obj_conv.inner = (void*)(this_obj & (~1));
28468         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28469         FilesystemPersister_free(this_obj_conv);
28470 }
28471
28472 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1new(JNIEnv *env, jclass clz, jstring path_to_channel_data) {
28473         LDKStr path_to_channel_data_conv = java_to_owned_str(env, path_to_channel_data);
28474         LDKFilesystemPersister ret_var = FilesystemPersister_new(path_to_channel_data_conv);
28475         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28476         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28477         uint64_t ret_ref = (uint64_t)ret_var.inner;
28478         if (ret_var.is_owned) {
28479                 ret_ref |= 1;
28480         }
28481         return ret_ref;
28482 }
28483
28484 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1get_1data_1dir(JNIEnv *env, jclass clz, int64_t this_arg) {
28485         LDKFilesystemPersister this_arg_conv;
28486         this_arg_conv.inner = (void*)(this_arg & (~1));
28487         this_arg_conv.is_owned = false;
28488         LDKStr ret_str = FilesystemPersister_get_data_dir(&this_arg_conv);
28489         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
28490         Str_free(ret_str);
28491         return ret_conv;
28492 }
28493
28494 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1persist_1manager(JNIEnv *env, jclass clz, jstring data_dir, int64_t manager) {
28495         LDKStr data_dir_conv = java_to_owned_str(env, data_dir);
28496         LDKChannelManager manager_conv;
28497         manager_conv.inner = (void*)(manager & (~1));
28498         manager_conv.is_owned = false;
28499         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
28500         *ret_conv = FilesystemPersister_persist_manager(data_dir_conv, &manager_conv);
28501         return (uint64_t)ret_conv;
28502 }
28503
28504 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1read_1channelmonitors(JNIEnv *env, jclass clz, int64_t this_arg, int64_t keys_manager) {
28505         LDKFilesystemPersister this_arg_conv;
28506         this_arg_conv.inner = (void*)(this_arg & (~1));
28507         this_arg_conv.is_owned = false;
28508         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
28509         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
28510                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
28511                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
28512         }
28513         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
28514         *ret_conv = FilesystemPersister_read_channelmonitors(&this_arg_conv, keys_manager_conv);
28515         return (uint64_t)ret_conv;
28516 }
28517
28518 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1as_1Persist(JNIEnv *env, jclass clz, int64_t this_arg) {
28519         LDKFilesystemPersister this_arg_conv;
28520         this_arg_conv.inner = (void*)(this_arg & (~1));
28521         this_arg_conv.is_owned = false;
28522         LDKPersist* ret_ret =MALLOC(sizeof(LDKPersist), "LDKPersist");
28523         *ret_ret = FilesystemPersister_as_Persist(&this_arg_conv);
28524         return (uint64_t)ret_ret;
28525 }
28526
28527 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28528         LDKBackgroundProcessor this_obj_conv;
28529         this_obj_conv.inner = (void*)(this_obj & (~1));
28530         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28531         BackgroundProcessor_free(this_obj_conv);
28532 }
28533
28534 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerPersister_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
28535         if ((this_ptr & 1) != 0) return;
28536         LDKChannelManagerPersister this_ptr_conv = *(LDKChannelManagerPersister*)(((uint64_t)this_ptr) & ~1);
28537         FREE((void*)this_ptr);
28538         ChannelManagerPersister_free(this_ptr_conv);
28539 }
28540
28541 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1start(JNIEnv *env, jclass clz, int64_t persister, int64_t event_handler, int64_t chain_monitor, int64_t channel_manager, int64_t net_graph_msg_handler, int64_t peer_manager, int64_t logger) {
28542         LDKChannelManagerPersister persister_conv = *(LDKChannelManagerPersister*)(((uint64_t)persister) & ~1);
28543         if (persister_conv.free == LDKChannelManagerPersister_JCalls_free) {
28544                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
28545                 LDKChannelManagerPersister_JCalls_cloned(&persister_conv);
28546         }
28547         LDKEventHandler event_handler_conv = *(LDKEventHandler*)(((uint64_t)event_handler) & ~1);
28548         if (event_handler_conv.free == LDKEventHandler_JCalls_free) {
28549                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
28550                 LDKEventHandler_JCalls_cloned(&event_handler_conv);
28551         }
28552         LDKChainMonitor chain_monitor_conv;
28553         chain_monitor_conv.inner = (void*)(chain_monitor & (~1));
28554         chain_monitor_conv.is_owned = false;
28555         LDKChannelManager channel_manager_conv;
28556         channel_manager_conv.inner = (void*)(channel_manager & (~1));
28557         channel_manager_conv.is_owned = false;
28558         LDKNetGraphMsgHandler net_graph_msg_handler_conv;
28559         net_graph_msg_handler_conv.inner = (void*)(net_graph_msg_handler & (~1));
28560         net_graph_msg_handler_conv.is_owned = (net_graph_msg_handler & 1) || (net_graph_msg_handler == 0);
28561         LDKPeerManager peer_manager_conv;
28562         peer_manager_conv.inner = (void*)(peer_manager & (~1));
28563         peer_manager_conv.is_owned = false;
28564         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
28565         if (logger_conv.free == LDKLogger_JCalls_free) {
28566                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
28567                 LDKLogger_JCalls_cloned(&logger_conv);
28568         }
28569         LDKBackgroundProcessor ret_var = BackgroundProcessor_start(persister_conv, event_handler_conv, &chain_monitor_conv, &channel_manager_conv, net_graph_msg_handler_conv, &peer_manager_conv, logger_conv);
28570         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28571         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28572         uint64_t ret_ref = (uint64_t)ret_var.inner;
28573         if (ret_var.is_owned) {
28574                 ret_ref |= 1;
28575         }
28576         return ret_ref;
28577 }
28578
28579 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1join(JNIEnv *env, jclass clz, int64_t this_arg) {
28580         LDKBackgroundProcessor this_arg_conv;
28581         this_arg_conv.inner = (void*)(this_arg & (~1));
28582         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
28583         // Warning: we need a move here but no clone is available for LDKBackgroundProcessor
28584         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
28585         *ret_conv = BackgroundProcessor_join(this_arg_conv);
28586         return (uint64_t)ret_conv;
28587 }
28588
28589 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1stop(JNIEnv *env, jclass clz, int64_t this_arg) {
28590         LDKBackgroundProcessor this_arg_conv;
28591         this_arg_conv.inner = (void*)(this_arg & (~1));
28592         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
28593         // Warning: we need a move here but no clone is available for LDKBackgroundProcessor
28594         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
28595         *ret_conv = BackgroundProcessor_stop(this_arg_conv);
28596         return (uint64_t)ret_conv;
28597 }
28598
28599 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_check_1platform(JNIEnv *env, jclass clz) {
28600         check_platform();
28601 }
28602
28603 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Invoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28604         LDKInvoice this_obj_conv;
28605         this_obj_conv.inner = (void*)(this_obj & (~1));
28606         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28607         Invoice_free(this_obj_conv);
28608 }
28609
28610 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Invoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
28611         LDKInvoice a_conv;
28612         a_conv.inner = (void*)(a & (~1));
28613         a_conv.is_owned = false;
28614         LDKInvoice b_conv;
28615         b_conv.inner = (void*)(b & (~1));
28616         b_conv.is_owned = false;
28617         jboolean ret_val = Invoice_eq(&a_conv, &b_conv);
28618         return ret_val;
28619 }
28620
28621 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28622         LDKInvoice orig_conv;
28623         orig_conv.inner = (void*)(orig & (~1));
28624         orig_conv.is_owned = false;
28625         LDKInvoice ret_var = Invoice_clone(&orig_conv);
28626         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28627         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28628         uint64_t ret_ref = (uint64_t)ret_var.inner;
28629         if (ret_var.is_owned) {
28630                 ret_ref |= 1;
28631         }
28632         return ret_ref;
28633 }
28634
28635 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28636         LDKSignedRawInvoice this_obj_conv;
28637         this_obj_conv.inner = (void*)(this_obj & (~1));
28638         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28639         SignedRawInvoice_free(this_obj_conv);
28640 }
28641
28642 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
28643         LDKSignedRawInvoice a_conv;
28644         a_conv.inner = (void*)(a & (~1));
28645         a_conv.is_owned = false;
28646         LDKSignedRawInvoice b_conv;
28647         b_conv.inner = (void*)(b & (~1));
28648         b_conv.is_owned = false;
28649         jboolean ret_val = SignedRawInvoice_eq(&a_conv, &b_conv);
28650         return ret_val;
28651 }
28652
28653 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28654         LDKSignedRawInvoice orig_conv;
28655         orig_conv.inner = (void*)(orig & (~1));
28656         orig_conv.is_owned = false;
28657         LDKSignedRawInvoice ret_var = SignedRawInvoice_clone(&orig_conv);
28658         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28659         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28660         uint64_t ret_ref = (uint64_t)ret_var.inner;
28661         if (ret_var.is_owned) {
28662                 ret_ref |= 1;
28663         }
28664         return ret_ref;
28665 }
28666
28667 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawInvoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28668         LDKRawInvoice this_obj_conv;
28669         this_obj_conv.inner = (void*)(this_obj & (~1));
28670         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28671         RawInvoice_free(this_obj_conv);
28672 }
28673
28674 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1get_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
28675         LDKRawInvoice this_ptr_conv;
28676         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28677         this_ptr_conv.is_owned = false;
28678         LDKRawDataPart ret_var = RawInvoice_get_data(&this_ptr_conv);
28679         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28680         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28681         uint64_t ret_ref = (uint64_t)ret_var.inner;
28682         if (ret_var.is_owned) {
28683                 ret_ref |= 1;
28684         }
28685         return ret_ref;
28686 }
28687
28688 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawInvoice_1set_1data(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28689         LDKRawInvoice this_ptr_conv;
28690         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28691         this_ptr_conv.is_owned = false;
28692         LDKRawDataPart val_conv;
28693         val_conv.inner = (void*)(val & (~1));
28694         val_conv.is_owned = (val & 1) || (val == 0);
28695         val_conv = RawDataPart_clone(&val_conv);
28696         RawInvoice_set_data(&this_ptr_conv, val_conv);
28697 }
28698
28699 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RawInvoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
28700         LDKRawInvoice a_conv;
28701         a_conv.inner = (void*)(a & (~1));
28702         a_conv.is_owned = false;
28703         LDKRawInvoice b_conv;
28704         b_conv.inner = (void*)(b & (~1));
28705         b_conv.is_owned = false;
28706         jboolean ret_val = RawInvoice_eq(&a_conv, &b_conv);
28707         return ret_val;
28708 }
28709
28710 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28711         LDKRawInvoice orig_conv;
28712         orig_conv.inner = (void*)(orig & (~1));
28713         orig_conv.is_owned = false;
28714         LDKRawInvoice ret_var = RawInvoice_clone(&orig_conv);
28715         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28716         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28717         uint64_t ret_ref = (uint64_t)ret_var.inner;
28718         if (ret_var.is_owned) {
28719                 ret_ref |= 1;
28720         }
28721         return ret_ref;
28722 }
28723
28724 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawDataPart_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28725         LDKRawDataPart this_obj_conv;
28726         this_obj_conv.inner = (void*)(this_obj & (~1));
28727         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28728         RawDataPart_free(this_obj_conv);
28729 }
28730
28731 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
28732         LDKRawDataPart this_ptr_conv;
28733         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28734         this_ptr_conv.is_owned = false;
28735         LDKPositiveTimestamp ret_var = RawDataPart_get_timestamp(&this_ptr_conv);
28736         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28737         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28738         uint64_t ret_ref = (uint64_t)ret_var.inner;
28739         if (ret_var.is_owned) {
28740                 ret_ref |= 1;
28741         }
28742         return ret_ref;
28743 }
28744
28745 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawDataPart_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28746         LDKRawDataPart this_ptr_conv;
28747         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28748         this_ptr_conv.is_owned = false;
28749         LDKPositiveTimestamp val_conv;
28750         val_conv.inner = (void*)(val & (~1));
28751         val_conv.is_owned = (val & 1) || (val == 0);
28752         val_conv = PositiveTimestamp_clone(&val_conv);
28753         RawDataPart_set_timestamp(&this_ptr_conv, val_conv);
28754 }
28755
28756 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RawDataPart_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
28757         LDKRawDataPart a_conv;
28758         a_conv.inner = (void*)(a & (~1));
28759         a_conv.is_owned = false;
28760         LDKRawDataPart b_conv;
28761         b_conv.inner = (void*)(b & (~1));
28762         b_conv.is_owned = false;
28763         jboolean ret_val = RawDataPart_eq(&a_conv, &b_conv);
28764         return ret_val;
28765 }
28766
28767 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28768         LDKRawDataPart orig_conv;
28769         orig_conv.inner = (void*)(orig & (~1));
28770         orig_conv.is_owned = false;
28771         LDKRawDataPart ret_var = RawDataPart_clone(&orig_conv);
28772         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28773         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28774         uint64_t ret_ref = (uint64_t)ret_var.inner;
28775         if (ret_var.is_owned) {
28776                 ret_ref |= 1;
28777         }
28778         return ret_ref;
28779 }
28780
28781 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28782         LDKPositiveTimestamp this_obj_conv;
28783         this_obj_conv.inner = (void*)(this_obj & (~1));
28784         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28785         PositiveTimestamp_free(this_obj_conv);
28786 }
28787
28788 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
28789         LDKPositiveTimestamp a_conv;
28790         a_conv.inner = (void*)(a & (~1));
28791         a_conv.is_owned = false;
28792         LDKPositiveTimestamp b_conv;
28793         b_conv.inner = (void*)(b & (~1));
28794         b_conv.is_owned = false;
28795         jboolean ret_val = PositiveTimestamp_eq(&a_conv, &b_conv);
28796         return ret_val;
28797 }
28798
28799 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28800         LDKPositiveTimestamp orig_conv;
28801         orig_conv.inner = (void*)(orig & (~1));
28802         orig_conv.is_owned = false;
28803         LDKPositiveTimestamp ret_var = PositiveTimestamp_clone(&orig_conv);
28804         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28805         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28806         uint64_t ret_ref = (uint64_t)ret_var.inner;
28807         if (ret_var.is_owned) {
28808                 ret_ref |= 1;
28809         }
28810         return ret_ref;
28811 }
28812
28813 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28814         LDKSiPrefix* orig_conv = (LDKSiPrefix*)(orig & ~1);
28815         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_clone(orig_conv));
28816         return ret_conv;
28817 }
28818
28819 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1milli(JNIEnv *env, jclass clz) {
28820         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_milli());
28821         return ret_conv;
28822 }
28823
28824 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1micro(JNIEnv *env, jclass clz) {
28825         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_micro());
28826         return ret_conv;
28827 }
28828
28829 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1nano(JNIEnv *env, jclass clz) {
28830         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_nano());
28831         return ret_conv;
28832 }
28833
28834 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1pico(JNIEnv *env, jclass clz) {
28835         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_pico());
28836         return ret_conv;
28837 }
28838
28839 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SiPrefix_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
28840         LDKSiPrefix* a_conv = (LDKSiPrefix*)(a & ~1);
28841         LDKSiPrefix* b_conv = (LDKSiPrefix*)(b & ~1);
28842         jboolean ret_val = SiPrefix_eq(a_conv, b_conv);
28843         return ret_val;
28844 }
28845
28846 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SiPrefix_1multiplier(JNIEnv *env, jclass clz, int64_t this_arg) {
28847         LDKSiPrefix* this_arg_conv = (LDKSiPrefix*)(this_arg & ~1);
28848         int64_t ret_val = SiPrefix_multiplier(this_arg_conv);
28849         return ret_val;
28850 }
28851
28852 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28853         LDKCurrency* orig_conv = (LDKCurrency*)(orig & ~1);
28854         jclass ret_conv = LDKCurrency_to_java(env, Currency_clone(orig_conv));
28855         return ret_conv;
28856 }
28857
28858 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1bitcoin(JNIEnv *env, jclass clz) {
28859         jclass ret_conv = LDKCurrency_to_java(env, Currency_bitcoin());
28860         return ret_conv;
28861 }
28862
28863 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1bitcoin_1testnet(JNIEnv *env, jclass clz) {
28864         jclass ret_conv = LDKCurrency_to_java(env, Currency_bitcoin_testnet());
28865         return ret_conv;
28866 }
28867
28868 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1regtest(JNIEnv *env, jclass clz) {
28869         jclass ret_conv = LDKCurrency_to_java(env, Currency_regtest());
28870         return ret_conv;
28871 }
28872
28873 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1simnet(JNIEnv *env, jclass clz) {
28874         jclass ret_conv = LDKCurrency_to_java(env, Currency_simnet());
28875         return ret_conv;
28876 }
28877
28878 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1signet(JNIEnv *env, jclass clz) {
28879         jclass ret_conv = LDKCurrency_to_java(env, Currency_signet());
28880         return ret_conv;
28881 }
28882
28883 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Currency_1hash(JNIEnv *env, jclass clz, int64_t o) {
28884         LDKCurrency* o_conv = (LDKCurrency*)(o & ~1);
28885         int64_t ret_val = Currency_hash(o_conv);
28886         return ret_val;
28887 }
28888
28889 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Currency_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
28890         LDKCurrency* a_conv = (LDKCurrency*)(a & ~1);
28891         LDKCurrency* b_conv = (LDKCurrency*)(b & ~1);
28892         jboolean ret_val = Currency_eq(a_conv, b_conv);
28893         return ret_val;
28894 }
28895
28896 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Sha256_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28897         LDKSha256 this_obj_conv;
28898         this_obj_conv.inner = (void*)(this_obj & (~1));
28899         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28900         Sha256_free(this_obj_conv);
28901 }
28902
28903 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sha256_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28904         LDKSha256 orig_conv;
28905         orig_conv.inner = (void*)(orig & (~1));
28906         orig_conv.is_owned = false;
28907         LDKSha256 ret_var = Sha256_clone(&orig_conv);
28908         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28909         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28910         uint64_t ret_ref = (uint64_t)ret_var.inner;
28911         if (ret_var.is_owned) {
28912                 ret_ref |= 1;
28913         }
28914         return ret_ref;
28915 }
28916
28917 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sha256_1hash(JNIEnv *env, jclass clz, int64_t o) {
28918         LDKSha256 o_conv;
28919         o_conv.inner = (void*)(o & (~1));
28920         o_conv.is_owned = false;
28921         int64_t ret_val = Sha256_hash(&o_conv);
28922         return ret_val;
28923 }
28924
28925 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Sha256_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
28926         LDKSha256 a_conv;
28927         a_conv.inner = (void*)(a & (~1));
28928         a_conv.is_owned = false;
28929         LDKSha256 b_conv;
28930         b_conv.inner = (void*)(b & (~1));
28931         b_conv.is_owned = false;
28932         jboolean ret_val = Sha256_eq(&a_conv, &b_conv);
28933         return ret_val;
28934 }
28935
28936 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Description_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28937         LDKDescription this_obj_conv;
28938         this_obj_conv.inner = (void*)(this_obj & (~1));
28939         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28940         Description_free(this_obj_conv);
28941 }
28942
28943 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28944         LDKDescription orig_conv;
28945         orig_conv.inner = (void*)(orig & (~1));
28946         orig_conv.is_owned = false;
28947         LDKDescription ret_var = Description_clone(&orig_conv);
28948         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28949         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28950         uint64_t ret_ref = (uint64_t)ret_var.inner;
28951         if (ret_var.is_owned) {
28952                 ret_ref |= 1;
28953         }
28954         return ret_ref;
28955 }
28956
28957 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1hash(JNIEnv *env, jclass clz, int64_t o) {
28958         LDKDescription o_conv;
28959         o_conv.inner = (void*)(o & (~1));
28960         o_conv.is_owned = false;
28961         int64_t ret_val = Description_hash(&o_conv);
28962         return ret_val;
28963 }
28964
28965 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Description_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
28966         LDKDescription a_conv;
28967         a_conv.inner = (void*)(a & (~1));
28968         a_conv.is_owned = false;
28969         LDKDescription b_conv;
28970         b_conv.inner = (void*)(b & (~1));
28971         b_conv.is_owned = false;
28972         jboolean ret_val = Description_eq(&a_conv, &b_conv);
28973         return ret_val;
28974 }
28975
28976 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28977         LDKPayeePubKey this_obj_conv;
28978         this_obj_conv.inner = (void*)(this_obj & (~1));
28979         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28980         PayeePubKey_free(this_obj_conv);
28981 }
28982
28983 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28984         LDKPayeePubKey orig_conv;
28985         orig_conv.inner = (void*)(orig & (~1));
28986         orig_conv.is_owned = false;
28987         LDKPayeePubKey ret_var = PayeePubKey_clone(&orig_conv);
28988         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28989         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28990         uint64_t ret_ref = (uint64_t)ret_var.inner;
28991         if (ret_var.is_owned) {
28992                 ret_ref |= 1;
28993         }
28994         return ret_ref;
28995 }
28996
28997 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1hash(JNIEnv *env, jclass clz, int64_t o) {
28998         LDKPayeePubKey o_conv;
28999         o_conv.inner = (void*)(o & (~1));
29000         o_conv.is_owned = false;
29001         int64_t ret_val = PayeePubKey_hash(&o_conv);
29002         return ret_val;
29003 }
29004
29005 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
29006         LDKPayeePubKey a_conv;
29007         a_conv.inner = (void*)(a & (~1));
29008         a_conv.is_owned = false;
29009         LDKPayeePubKey b_conv;
29010         b_conv.inner = (void*)(b & (~1));
29011         b_conv.is_owned = false;
29012         jboolean ret_val = PayeePubKey_eq(&a_conv, &b_conv);
29013         return ret_val;
29014 }
29015
29016 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29017         LDKExpiryTime this_obj_conv;
29018         this_obj_conv.inner = (void*)(this_obj & (~1));
29019         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29020         ExpiryTime_free(this_obj_conv);
29021 }
29022
29023 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29024         LDKExpiryTime orig_conv;
29025         orig_conv.inner = (void*)(orig & (~1));
29026         orig_conv.is_owned = false;
29027         LDKExpiryTime ret_var = ExpiryTime_clone(&orig_conv);
29028         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29029         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29030         uint64_t ret_ref = (uint64_t)ret_var.inner;
29031         if (ret_var.is_owned) {
29032                 ret_ref |= 1;
29033         }
29034         return ret_ref;
29035 }
29036
29037 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1hash(JNIEnv *env, jclass clz, int64_t o) {
29038         LDKExpiryTime o_conv;
29039         o_conv.inner = (void*)(o & (~1));
29040         o_conv.is_owned = false;
29041         int64_t ret_val = ExpiryTime_hash(&o_conv);
29042         return ret_val;
29043 }
29044
29045 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
29046         LDKExpiryTime a_conv;
29047         a_conv.inner = (void*)(a & (~1));
29048         a_conv.is_owned = false;
29049         LDKExpiryTime b_conv;
29050         b_conv.inner = (void*)(b & (~1));
29051         b_conv.is_owned = false;
29052         jboolean ret_val = ExpiryTime_eq(&a_conv, &b_conv);
29053         return ret_val;
29054 }
29055
29056 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29057         LDKMinFinalCltvExpiry this_obj_conv;
29058         this_obj_conv.inner = (void*)(this_obj & (~1));
29059         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29060         MinFinalCltvExpiry_free(this_obj_conv);
29061 }
29062
29063 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29064         LDKMinFinalCltvExpiry orig_conv;
29065         orig_conv.inner = (void*)(orig & (~1));
29066         orig_conv.is_owned = false;
29067         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_clone(&orig_conv);
29068         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29069         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29070         uint64_t ret_ref = (uint64_t)ret_var.inner;
29071         if (ret_var.is_owned) {
29072                 ret_ref |= 1;
29073         }
29074         return ret_ref;
29075 }
29076
29077 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1hash(JNIEnv *env, jclass clz, int64_t o) {
29078         LDKMinFinalCltvExpiry o_conv;
29079         o_conv.inner = (void*)(o & (~1));
29080         o_conv.is_owned = false;
29081         int64_t ret_val = MinFinalCltvExpiry_hash(&o_conv);
29082         return ret_val;
29083 }
29084
29085 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
29086         LDKMinFinalCltvExpiry a_conv;
29087         a_conv.inner = (void*)(a & (~1));
29088         a_conv.is_owned = false;
29089         LDKMinFinalCltvExpiry b_conv;
29090         b_conv.inner = (void*)(b & (~1));
29091         b_conv.is_owned = false;
29092         jboolean ret_val = MinFinalCltvExpiry_eq(&a_conv, &b_conv);
29093         return ret_val;
29094 }
29095
29096 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Fallback_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
29097         if ((this_ptr & 1) != 0) return;
29098         LDKFallback this_ptr_conv = *(LDKFallback*)(((uint64_t)this_ptr) & ~1);
29099         FREE((void*)this_ptr);
29100         Fallback_free(this_ptr_conv);
29101 }
29102
29103 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29104         LDKFallback* orig_conv = (LDKFallback*)orig;
29105         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
29106         *ret_copy = Fallback_clone(orig_conv);
29107         uint64_t ret_ref = (uint64_t)ret_copy;
29108         return ret_ref;
29109 }
29110
29111 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1seg_1wit_1program(JNIEnv *env, jclass clz, int8_t version, int8_tArray program) {
29112         
29113         LDKCVec_u8Z program_ref;
29114         program_ref.datalen = (*env)->GetArrayLength(env, program);
29115         program_ref.data = MALLOC(program_ref.datalen, "LDKCVec_u8Z Bytes");
29116         (*env)->GetByteArrayRegion(env, program, 0, program_ref.datalen, program_ref.data);
29117         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
29118         *ret_copy = Fallback_seg_wit_program((LDKu5){ ._0 = version }, program_ref);
29119         uint64_t ret_ref = (uint64_t)ret_copy;
29120         return ret_ref;
29121 }
29122
29123 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1pub_1key_1hash(JNIEnv *env, jclass clz, int8_tArray a) {
29124         LDKTwentyBytes a_ref;
29125         CHECK((*env)->GetArrayLength(env, a) == 20);
29126         (*env)->GetByteArrayRegion(env, a, 0, 20, a_ref.data);
29127         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
29128         *ret_copy = Fallback_pub_key_hash(a_ref);
29129         uint64_t ret_ref = (uint64_t)ret_copy;
29130         return ret_ref;
29131 }
29132
29133 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1script_1hash(JNIEnv *env, jclass clz, int8_tArray a) {
29134         LDKTwentyBytes a_ref;
29135         CHECK((*env)->GetArrayLength(env, a) == 20);
29136         (*env)->GetByteArrayRegion(env, a, 0, 20, a_ref.data);
29137         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
29138         *ret_copy = Fallback_script_hash(a_ref);
29139         uint64_t ret_ref = (uint64_t)ret_copy;
29140         return ret_ref;
29141 }
29142
29143 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1hash(JNIEnv *env, jclass clz, int64_t o) {
29144         LDKFallback* o_conv = (LDKFallback*)o;
29145         int64_t ret_val = Fallback_hash(o_conv);
29146         return ret_val;
29147 }
29148
29149 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Fallback_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
29150         LDKFallback* a_conv = (LDKFallback*)a;
29151         LDKFallback* b_conv = (LDKFallback*)b;
29152         jboolean ret_val = Fallback_eq(a_conv, b_conv);
29153         return ret_val;
29154 }
29155
29156 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29157         LDKInvoiceSignature this_obj_conv;
29158         this_obj_conv.inner = (void*)(this_obj & (~1));
29159         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29160         InvoiceSignature_free(this_obj_conv);
29161 }
29162
29163 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29164         LDKInvoiceSignature orig_conv;
29165         orig_conv.inner = (void*)(orig & (~1));
29166         orig_conv.is_owned = false;
29167         LDKInvoiceSignature ret_var = InvoiceSignature_clone(&orig_conv);
29168         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29169         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29170         uint64_t ret_ref = (uint64_t)ret_var.inner;
29171         if (ret_var.is_owned) {
29172                 ret_ref |= 1;
29173         }
29174         return ret_ref;
29175 }
29176
29177 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
29178         LDKInvoiceSignature a_conv;
29179         a_conv.inner = (void*)(a & (~1));
29180         a_conv.is_owned = false;
29181         LDKInvoiceSignature b_conv;
29182         b_conv.inner = (void*)(b & (~1));
29183         b_conv.is_owned = false;
29184         jboolean ret_val = InvoiceSignature_eq(&a_conv, &b_conv);
29185         return ret_val;
29186 }
29187
29188 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29189         LDKPrivateRoute this_obj_conv;
29190         this_obj_conv.inner = (void*)(this_obj & (~1));
29191         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29192         PrivateRoute_free(this_obj_conv);
29193 }
29194
29195 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29196         LDKPrivateRoute orig_conv;
29197         orig_conv.inner = (void*)(orig & (~1));
29198         orig_conv.is_owned = false;
29199         LDKPrivateRoute ret_var = PrivateRoute_clone(&orig_conv);
29200         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29201         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29202         uint64_t ret_ref = (uint64_t)ret_var.inner;
29203         if (ret_var.is_owned) {
29204                 ret_ref |= 1;
29205         }
29206         return ret_ref;
29207 }
29208
29209 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1hash(JNIEnv *env, jclass clz, int64_t o) {
29210         LDKPrivateRoute o_conv;
29211         o_conv.inner = (void*)(o & (~1));
29212         o_conv.is_owned = false;
29213         int64_t ret_val = PrivateRoute_hash(&o_conv);
29214         return ret_val;
29215 }
29216
29217 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
29218         LDKPrivateRoute a_conv;
29219         a_conv.inner = (void*)(a & (~1));
29220         a_conv.is_owned = false;
29221         LDKPrivateRoute b_conv;
29222         b_conv.inner = (void*)(b & (~1));
29223         b_conv.is_owned = false;
29224         jboolean ret_val = PrivateRoute_eq(&a_conv, &b_conv);
29225         return ret_val;
29226 }
29227
29228 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1into_1parts(JNIEnv *env, jclass clz, int64_t this_arg) {
29229         LDKSignedRawInvoice this_arg_conv;
29230         this_arg_conv.inner = (void*)(this_arg & (~1));
29231         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
29232         this_arg_conv = SignedRawInvoice_clone(&this_arg_conv);
29233         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
29234         *ret_conv = SignedRawInvoice_into_parts(this_arg_conv);
29235         return ((uint64_t)ret_conv);
29236 }
29237
29238 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1raw_1invoice(JNIEnv *env, jclass clz, int64_t this_arg) {
29239         LDKSignedRawInvoice this_arg_conv;
29240         this_arg_conv.inner = (void*)(this_arg & (~1));
29241         this_arg_conv.is_owned = false;
29242         LDKRawInvoice ret_var = SignedRawInvoice_raw_invoice(&this_arg_conv);
29243         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29244         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29245         uint64_t ret_ref = (uint64_t)ret_var.inner;
29246         if (ret_var.is_owned) {
29247                 ret_ref |= 1;
29248         }
29249         return ret_ref;
29250 }
29251
29252 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
29253         LDKSignedRawInvoice this_arg_conv;
29254         this_arg_conv.inner = (void*)(this_arg & (~1));
29255         this_arg_conv.is_owned = false;
29256         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
29257         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *SignedRawInvoice_hash(&this_arg_conv));
29258         return ret_arr;
29259 }
29260
29261 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
29262         LDKSignedRawInvoice this_arg_conv;
29263         this_arg_conv.inner = (void*)(this_arg & (~1));
29264         this_arg_conv.is_owned = false;
29265         LDKInvoiceSignature ret_var = SignedRawInvoice_signature(&this_arg_conv);
29266         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29267         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29268         uint64_t ret_ref = (uint64_t)ret_var.inner;
29269         if (ret_var.is_owned) {
29270                 ret_ref |= 1;
29271         }
29272         return ret_ref;
29273 }
29274
29275 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1recover_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
29276         LDKSignedRawInvoice this_arg_conv;
29277         this_arg_conv.inner = (void*)(this_arg & (~1));
29278         this_arg_conv.is_owned = false;
29279         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
29280         *ret_conv = SignedRawInvoice_recover_payee_pub_key(&this_arg_conv);
29281         return (uint64_t)ret_conv;
29282 }
29283
29284 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1check_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
29285         LDKSignedRawInvoice this_arg_conv;
29286         this_arg_conv.inner = (void*)(this_arg & (~1));
29287         this_arg_conv.is_owned = false;
29288         jboolean ret_val = SignedRawInvoice_check_signature(&this_arg_conv);
29289         return ret_val;
29290 }
29291
29292 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
29293         LDKRawInvoice this_arg_conv;
29294         this_arg_conv.inner = (void*)(this_arg & (~1));
29295         this_arg_conv.is_owned = false;
29296         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
29297         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, RawInvoice_hash(&this_arg_conv).data);
29298         return ret_arr;
29299 }
29300
29301 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
29302         LDKRawInvoice this_arg_conv;
29303         this_arg_conv.inner = (void*)(this_arg & (~1));
29304         this_arg_conv.is_owned = false;
29305         LDKSha256 ret_var = RawInvoice_payment_hash(&this_arg_conv);
29306         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29307         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29308         uint64_t ret_ref = (uint64_t)ret_var.inner;
29309         if (ret_var.is_owned) {
29310                 ret_ref |= 1;
29311         }
29312         return ret_ref;
29313 }
29314
29315 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1description(JNIEnv *env, jclass clz, int64_t this_arg) {
29316         LDKRawInvoice this_arg_conv;
29317         this_arg_conv.inner = (void*)(this_arg & (~1));
29318         this_arg_conv.is_owned = false;
29319         LDKDescription ret_var = RawInvoice_description(&this_arg_conv);
29320         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29321         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29322         uint64_t ret_ref = (uint64_t)ret_var.inner;
29323         if (ret_var.is_owned) {
29324                 ret_ref |= 1;
29325         }
29326         return ret_ref;
29327 }
29328
29329 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
29330         LDKRawInvoice this_arg_conv;
29331         this_arg_conv.inner = (void*)(this_arg & (~1));
29332         this_arg_conv.is_owned = false;
29333         LDKPayeePubKey ret_var = RawInvoice_payee_pub_key(&this_arg_conv);
29334         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29335         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29336         uint64_t ret_ref = (uint64_t)ret_var.inner;
29337         if (ret_var.is_owned) {
29338                 ret_ref |= 1;
29339         }
29340         return ret_ref;
29341 }
29342
29343 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1description_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
29344         LDKRawInvoice this_arg_conv;
29345         this_arg_conv.inner = (void*)(this_arg & (~1));
29346         this_arg_conv.is_owned = false;
29347         LDKSha256 ret_var = RawInvoice_description_hash(&this_arg_conv);
29348         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29349         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29350         uint64_t ret_ref = (uint64_t)ret_var.inner;
29351         if (ret_var.is_owned) {
29352                 ret_ref |= 1;
29353         }
29354         return ret_ref;
29355 }
29356
29357 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
29358         LDKRawInvoice this_arg_conv;
29359         this_arg_conv.inner = (void*)(this_arg & (~1));
29360         this_arg_conv.is_owned = false;
29361         LDKExpiryTime ret_var = RawInvoice_expiry_time(&this_arg_conv);
29362         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29363         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29364         uint64_t ret_ref = (uint64_t)ret_var.inner;
29365         if (ret_var.is_owned) {
29366                 ret_ref |= 1;
29367         }
29368         return ret_ref;
29369 }
29370
29371 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1min_1final_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_arg) {
29372         LDKRawInvoice this_arg_conv;
29373         this_arg_conv.inner = (void*)(this_arg & (~1));
29374         this_arg_conv.is_owned = false;
29375         LDKMinFinalCltvExpiry ret_var = RawInvoice_min_final_cltv_expiry(&this_arg_conv);
29376         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29377         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29378         uint64_t ret_ref = (uint64_t)ret_var.inner;
29379         if (ret_var.is_owned) {
29380                 ret_ref |= 1;
29381         }
29382         return ret_ref;
29383 }
29384
29385 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
29386         LDKRawInvoice this_arg_conv;
29387         this_arg_conv.inner = (void*)(this_arg & (~1));
29388         this_arg_conv.is_owned = false;
29389         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
29390         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, RawInvoice_payment_secret(&this_arg_conv).data);
29391         return ret_arr;
29392 }
29393
29394 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
29395         LDKRawInvoice this_arg_conv;
29396         this_arg_conv.inner = (void*)(this_arg & (~1));
29397         this_arg_conv.is_owned = false;
29398         LDKInvoiceFeatures ret_var = RawInvoice_features(&this_arg_conv);
29399         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29400         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29401         uint64_t ret_ref = (uint64_t)ret_var.inner;
29402         if (ret_var.is_owned) {
29403                 ret_ref |= 1;
29404         }
29405         return ret_ref;
29406 }
29407
29408 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1private_1routes(JNIEnv *env, jclass clz, int64_t this_arg) {
29409         LDKRawInvoice this_arg_conv;
29410         this_arg_conv.inner = (void*)(this_arg & (~1));
29411         this_arg_conv.is_owned = false;
29412         LDKCVec_PrivateRouteZ ret_var = RawInvoice_private_routes(&this_arg_conv);
29413         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
29414         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
29415         for (size_t o = 0; o < ret_var.datalen; o++) {
29416                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
29417                 CHECK((((uint64_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29418                 CHECK((((uint64_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29419                 uint64_t ret_conv_14_ref = (uint64_t)ret_conv_14_var.inner;
29420                 if (ret_conv_14_var.is_owned) {
29421                         ret_conv_14_ref |= 1;
29422                 }
29423                 ret_arr_ptr[o] = ret_conv_14_ref;
29424         }
29425         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
29426         FREE(ret_var.data);
29427         return ret_arr;
29428 }
29429
29430 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1amount_1pico_1btc(JNIEnv *env, jclass clz, int64_t this_arg) {
29431         LDKRawInvoice this_arg_conv;
29432         this_arg_conv.inner = (void*)(this_arg & (~1));
29433         this_arg_conv.is_owned = false;
29434         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
29435         *ret_copy = RawInvoice_amount_pico_btc(&this_arg_conv);
29436         uint64_t ret_ref = (uint64_t)ret_copy;
29437         return ret_ref;
29438 }
29439
29440 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_RawInvoice_1currency(JNIEnv *env, jclass clz, int64_t this_arg) {
29441         LDKRawInvoice this_arg_conv;
29442         this_arg_conv.inner = (void*)(this_arg & (~1));
29443         this_arg_conv.is_owned = false;
29444         jclass ret_conv = LDKCurrency_to_java(env, RawInvoice_currency(&this_arg_conv));
29445         return ret_conv;
29446 }
29447
29448 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1from_1unix_1timestamp(JNIEnv *env, jclass clz, int64_t unix_seconds) {
29449         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
29450         *ret_conv = PositiveTimestamp_from_unix_timestamp(unix_seconds);
29451         return (uint64_t)ret_conv;
29452 }
29453
29454 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1from_1system_1time(JNIEnv *env, jclass clz, int64_t time) {
29455         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
29456         *ret_conv = PositiveTimestamp_from_system_time(time);
29457         return (uint64_t)ret_conv;
29458 }
29459
29460 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1as_1unix_1timestamp(JNIEnv *env, jclass clz, int64_t this_arg) {
29461         LDKPositiveTimestamp this_arg_conv;
29462         this_arg_conv.inner = (void*)(this_arg & (~1));
29463         this_arg_conv.is_owned = false;
29464         int64_t ret_val = PositiveTimestamp_as_unix_timestamp(&this_arg_conv);
29465         return ret_val;
29466 }
29467
29468 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1as_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
29469         LDKPositiveTimestamp this_arg_conv;
29470         this_arg_conv.inner = (void*)(this_arg & (~1));
29471         this_arg_conv.is_owned = false;
29472         int64_t ret_val = PositiveTimestamp_as_time(&this_arg_conv);
29473         return ret_val;
29474 }
29475
29476 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1into_1signed_1raw(JNIEnv *env, jclass clz, int64_t this_arg) {
29477         LDKInvoice this_arg_conv;
29478         this_arg_conv.inner = (void*)(this_arg & (~1));
29479         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
29480         this_arg_conv = Invoice_clone(&this_arg_conv);
29481         LDKSignedRawInvoice ret_var = Invoice_into_signed_raw(this_arg_conv);
29482         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29483         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29484         uint64_t ret_ref = (uint64_t)ret_var.inner;
29485         if (ret_var.is_owned) {
29486                 ret_ref |= 1;
29487         }
29488         return ret_ref;
29489 }
29490
29491 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1check_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
29492         LDKInvoice this_arg_conv;
29493         this_arg_conv.inner = (void*)(this_arg & (~1));
29494         this_arg_conv.is_owned = false;
29495         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
29496         *ret_conv = Invoice_check_signature(&this_arg_conv);
29497         return (uint64_t)ret_conv;
29498 }
29499
29500 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1from_1signed(JNIEnv *env, jclass clz, int64_t signed_invoice) {
29501         LDKSignedRawInvoice signed_invoice_conv;
29502         signed_invoice_conv.inner = (void*)(signed_invoice & (~1));
29503         signed_invoice_conv.is_owned = (signed_invoice & 1) || (signed_invoice == 0);
29504         signed_invoice_conv = SignedRawInvoice_clone(&signed_invoice_conv);
29505         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
29506         *ret_conv = Invoice_from_signed(signed_invoice_conv);
29507         return (uint64_t)ret_conv;
29508 }
29509
29510 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1timestamp(JNIEnv *env, jclass clz, int64_t this_arg) {
29511         LDKInvoice this_arg_conv;
29512         this_arg_conv.inner = (void*)(this_arg & (~1));
29513         this_arg_conv.is_owned = false;
29514         int64_t ret_val = Invoice_timestamp(&this_arg_conv);
29515         return ret_val;
29516 }
29517
29518 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
29519         LDKInvoice this_arg_conv;
29520         this_arg_conv.inner = (void*)(this_arg & (~1));
29521         this_arg_conv.is_owned = false;
29522         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
29523         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *Invoice_payment_hash(&this_arg_conv));
29524         return ret_arr;
29525 }
29526
29527 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
29528         LDKInvoice this_arg_conv;
29529         this_arg_conv.inner = (void*)(this_arg & (~1));
29530         this_arg_conv.is_owned = false;
29531         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
29532         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, Invoice_payee_pub_key(&this_arg_conv).compressed_form);
29533         return ret_arr;
29534 }
29535
29536 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
29537         LDKInvoice this_arg_conv;
29538         this_arg_conv.inner = (void*)(this_arg & (~1));
29539         this_arg_conv.is_owned = false;
29540         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
29541         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, Invoice_payment_secret(&this_arg_conv).data);
29542         return ret_arr;
29543 }
29544
29545 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
29546         LDKInvoice this_arg_conv;
29547         this_arg_conv.inner = (void*)(this_arg & (~1));
29548         this_arg_conv.is_owned = false;
29549         LDKInvoiceFeatures ret_var = Invoice_features(&this_arg_conv);
29550         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29551         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29552         uint64_t ret_ref = (uint64_t)ret_var.inner;
29553         if (ret_var.is_owned) {
29554                 ret_ref |= 1;
29555         }
29556         return ret_ref;
29557 }
29558
29559 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1recover_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
29560         LDKInvoice this_arg_conv;
29561         this_arg_conv.inner = (void*)(this_arg & (~1));
29562         this_arg_conv.is_owned = false;
29563         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
29564         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, Invoice_recover_payee_pub_key(&this_arg_conv).compressed_form);
29565         return ret_arr;
29566 }
29567
29568 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
29569         LDKInvoice this_arg_conv;
29570         this_arg_conv.inner = (void*)(this_arg & (~1));
29571         this_arg_conv.is_owned = false;
29572         int64_t ret_val = Invoice_expiry_time(&this_arg_conv);
29573         return ret_val;
29574 }
29575
29576 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1min_1final_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_arg) {
29577         LDKInvoice this_arg_conv;
29578         this_arg_conv.inner = (void*)(this_arg & (~1));
29579         this_arg_conv.is_owned = false;
29580         int64_t ret_val = Invoice_min_final_cltv_expiry(&this_arg_conv);
29581         return ret_val;
29582 }
29583
29584 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1private_1routes(JNIEnv *env, jclass clz, int64_t this_arg) {
29585         LDKInvoice this_arg_conv;
29586         this_arg_conv.inner = (void*)(this_arg & (~1));
29587         this_arg_conv.is_owned = false;
29588         LDKCVec_PrivateRouteZ ret_var = Invoice_private_routes(&this_arg_conv);
29589         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
29590         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
29591         for (size_t o = 0; o < ret_var.datalen; o++) {
29592                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
29593                 CHECK((((uint64_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29594                 CHECK((((uint64_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29595                 uint64_t ret_conv_14_ref = (uint64_t)ret_conv_14_var.inner;
29596                 if (ret_conv_14_var.is_owned) {
29597                         ret_conv_14_ref |= 1;
29598                 }
29599                 ret_arr_ptr[o] = ret_conv_14_ref;
29600         }
29601         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
29602         FREE(ret_var.data);
29603         return ret_arr;
29604 }
29605
29606 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1route_1hints(JNIEnv *env, jclass clz, int64_t this_arg) {
29607         LDKInvoice this_arg_conv;
29608         this_arg_conv.inner = (void*)(this_arg & (~1));
29609         this_arg_conv.is_owned = false;
29610         LDKCVec_RouteHintZ ret_var = Invoice_route_hints(&this_arg_conv);
29611         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
29612         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
29613         for (size_t l = 0; l < ret_var.datalen; l++) {
29614                 LDKRouteHint ret_conv_11_var = ret_var.data[l];
29615                 CHECK((((uint64_t)ret_conv_11_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29616                 CHECK((((uint64_t)&ret_conv_11_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29617                 uint64_t ret_conv_11_ref = (uint64_t)ret_conv_11_var.inner;
29618                 if (ret_conv_11_var.is_owned) {
29619                         ret_conv_11_ref |= 1;
29620                 }
29621                 ret_arr_ptr[l] = ret_conv_11_ref;
29622         }
29623         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
29624         FREE(ret_var.data);
29625         return ret_arr;
29626 }
29627
29628 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Invoice_1currency(JNIEnv *env, jclass clz, int64_t this_arg) {
29629         LDKInvoice this_arg_conv;
29630         this_arg_conv.inner = (void*)(this_arg & (~1));
29631         this_arg_conv.is_owned = false;
29632         jclass ret_conv = LDKCurrency_to_java(env, Invoice_currency(&this_arg_conv));
29633         return ret_conv;
29634 }
29635
29636 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1amount_1pico_1btc(JNIEnv *env, jclass clz, int64_t this_arg) {
29637         LDKInvoice this_arg_conv;
29638         this_arg_conv.inner = (void*)(this_arg & (~1));
29639         this_arg_conv.is_owned = false;
29640         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
29641         *ret_copy = Invoice_amount_pico_btc(&this_arg_conv);
29642         uint64_t ret_ref = (uint64_t)ret_copy;
29643         return ret_ref;
29644 }
29645
29646 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1new(JNIEnv *env, jclass clz, jstring description) {
29647         LDKStr description_conv = java_to_owned_str(env, description);
29648         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
29649         *ret_conv = Description_new(description_conv);
29650         return (uint64_t)ret_conv;
29651 }
29652
29653 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Description_1into_1inner(JNIEnv *env, jclass clz, int64_t this_arg) {
29654         LDKDescription this_arg_conv;
29655         this_arg_conv.inner = (void*)(this_arg & (~1));
29656         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
29657         this_arg_conv = Description_clone(&this_arg_conv);
29658         LDKStr ret_str = Description_into_inner(this_arg_conv);
29659         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
29660         Str_free(ret_str);
29661         return ret_conv;
29662 }
29663
29664 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1from_1seconds(JNIEnv *env, jclass clz, int64_t seconds) {
29665         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
29666         *ret_conv = ExpiryTime_from_seconds(seconds);
29667         return (uint64_t)ret_conv;
29668 }
29669
29670 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1from_1duration(JNIEnv *env, jclass clz, int64_t duration) {
29671         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
29672         *ret_conv = ExpiryTime_from_duration(duration);
29673         return (uint64_t)ret_conv;
29674 }
29675
29676 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1as_1seconds(JNIEnv *env, jclass clz, int64_t this_arg) {
29677         LDKExpiryTime this_arg_conv;
29678         this_arg_conv.inner = (void*)(this_arg & (~1));
29679         this_arg_conv.is_owned = false;
29680         int64_t ret_val = ExpiryTime_as_seconds(&this_arg_conv);
29681         return ret_val;
29682 }
29683
29684 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1as_1duration(JNIEnv *env, jclass clz, int64_t this_arg) {
29685         LDKExpiryTime this_arg_conv;
29686         this_arg_conv.inner = (void*)(this_arg & (~1));
29687         this_arg_conv.is_owned = false;
29688         int64_t ret_val = ExpiryTime_as_duration(&this_arg_conv);
29689         return ret_val;
29690 }
29691
29692 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1new(JNIEnv *env, jclass clz, int64_t hops) {
29693         LDKRouteHint hops_conv;
29694         hops_conv.inner = (void*)(hops & (~1));
29695         hops_conv.is_owned = (hops & 1) || (hops == 0);
29696         hops_conv = RouteHint_clone(&hops_conv);
29697         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
29698         *ret_conv = PrivateRoute_new(hops_conv);
29699         return (uint64_t)ret_conv;
29700 }
29701
29702 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1into_1inner(JNIEnv *env, jclass clz, int64_t this_arg) {
29703         LDKPrivateRoute this_arg_conv;
29704         this_arg_conv.inner = (void*)(this_arg & (~1));
29705         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
29706         this_arg_conv = PrivateRoute_clone(&this_arg_conv);
29707         LDKRouteHint ret_var = PrivateRoute_into_inner(this_arg_conv);
29708         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29709         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29710         uint64_t ret_ref = (uint64_t)ret_var.inner;
29711         if (ret_var.is_owned) {
29712                 ret_ref |= 1;
29713         }
29714         return ret_ref;
29715 }
29716
29717 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29718         LDKCreationError* orig_conv = (LDKCreationError*)(orig & ~1);
29719         jclass ret_conv = LDKCreationError_to_java(env, CreationError_clone(orig_conv));
29720         return ret_conv;
29721 }
29722
29723 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1description_1too_1long(JNIEnv *env, jclass clz) {
29724         jclass ret_conv = LDKCreationError_to_java(env, CreationError_description_too_long());
29725         return ret_conv;
29726 }
29727
29728 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1route_1too_1long(JNIEnv *env, jclass clz) {
29729         jclass ret_conv = LDKCreationError_to_java(env, CreationError_route_too_long());
29730         return ret_conv;
29731 }
29732
29733 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1timestamp_1out_1of_1bounds(JNIEnv *env, jclass clz) {
29734         jclass ret_conv = LDKCreationError_to_java(env, CreationError_timestamp_out_of_bounds());
29735         return ret_conv;
29736 }
29737
29738 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1expiry_1time_1out_1of_1bounds(JNIEnv *env, jclass clz) {
29739         jclass ret_conv = LDKCreationError_to_java(env, CreationError_expiry_time_out_of_bounds());
29740         return ret_conv;
29741 }
29742
29743 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CreationError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
29744         LDKCreationError* a_conv = (LDKCreationError*)(a & ~1);
29745         LDKCreationError* b_conv = (LDKCreationError*)(b & ~1);
29746         jboolean ret_val = CreationError_eq(a_conv, b_conv);
29747         return ret_val;
29748 }
29749
29750 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_CreationError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
29751         LDKCreationError* o_conv = (LDKCreationError*)(o & ~1);
29752         LDKStr ret_str = CreationError_to_str(o_conv);
29753         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
29754         Str_free(ret_str);
29755         return ret_conv;
29756 }
29757
29758 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29759         LDKSemanticError* orig_conv = (LDKSemanticError*)(orig & ~1);
29760         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_clone(orig_conv));
29761         return ret_conv;
29762 }
29763
29764 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1no_1payment_1hash(JNIEnv *env, jclass clz) {
29765         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_no_payment_hash());
29766         return ret_conv;
29767 }
29768
29769 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1multiple_1payment_1hashes(JNIEnv *env, jclass clz) {
29770         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_multiple_payment_hashes());
29771         return ret_conv;
29772 }
29773
29774 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1no_1description(JNIEnv *env, jclass clz) {
29775         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_no_description());
29776         return ret_conv;
29777 }
29778
29779 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1multiple_1descriptions(JNIEnv *env, jclass clz) {
29780         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_multiple_descriptions());
29781         return ret_conv;
29782 }
29783
29784 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1no_1payment_1secret(JNIEnv *env, jclass clz) {
29785         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_no_payment_secret());
29786         return ret_conv;
29787 }
29788
29789 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1multiple_1payment_1secrets(JNIEnv *env, jclass clz) {
29790         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_multiple_payment_secrets());
29791         return ret_conv;
29792 }
29793
29794 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1invalid_1features(JNIEnv *env, jclass clz) {
29795         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_invalid_features());
29796         return ret_conv;
29797 }
29798
29799 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1invalid_1recovery_1id(JNIEnv *env, jclass clz) {
29800         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_invalid_recovery_id());
29801         return ret_conv;
29802 }
29803
29804 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1invalid_1signature(JNIEnv *env, jclass clz) {
29805         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_invalid_signature());
29806         return ret_conv;
29807 }
29808
29809 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1imprecise_1amount(JNIEnv *env, jclass clz) {
29810         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_imprecise_amount());
29811         return ret_conv;
29812 }
29813
29814 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SemanticError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
29815         LDKSemanticError* a_conv = (LDKSemanticError*)(a & ~1);
29816         LDKSemanticError* b_conv = (LDKSemanticError*)(b & ~1);
29817         jboolean ret_val = SemanticError_eq(a_conv, b_conv);
29818         return ret_val;
29819 }
29820
29821 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SemanticError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
29822         LDKSemanticError* o_conv = (LDKSemanticError*)(o & ~1);
29823         LDKStr ret_str = SemanticError_to_str(o_conv);
29824         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
29825         Str_free(ret_str);
29826         return ret_conv;
29827 }
29828
29829 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
29830         if ((this_ptr & 1) != 0) return;
29831         LDKSignOrCreationError this_ptr_conv = *(LDKSignOrCreationError*)(((uint64_t)this_ptr) & ~1);
29832         FREE((void*)this_ptr);
29833         SignOrCreationError_free(this_ptr_conv);
29834 }
29835
29836 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29837         LDKSignOrCreationError* orig_conv = (LDKSignOrCreationError*)orig;
29838         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
29839         *ret_copy = SignOrCreationError_clone(orig_conv);
29840         uint64_t ret_ref = (uint64_t)ret_copy;
29841         return ret_ref;
29842 }
29843
29844 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1sign_1error(JNIEnv *env, jclass clz) {
29845         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
29846         *ret_copy = SignOrCreationError_sign_error();
29847         uint64_t ret_ref = (uint64_t)ret_copy;
29848         return ret_ref;
29849 }
29850
29851 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1creation_1error(JNIEnv *env, jclass clz, jclass a) {
29852         LDKCreationError a_conv = LDKCreationError_from_java(env, a);
29853         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
29854         *ret_copy = SignOrCreationError_creation_error(a_conv);
29855         uint64_t ret_ref = (uint64_t)ret_copy;
29856         return ret_ref;
29857 }
29858
29859 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
29860         LDKSignOrCreationError* a_conv = (LDKSignOrCreationError*)a;
29861         LDKSignOrCreationError* b_conv = (LDKSignOrCreationError*)b;
29862         jboolean ret_val = SignOrCreationError_eq(a_conv, b_conv);
29863         return ret_val;
29864 }
29865
29866 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
29867         LDKSignOrCreationError* o_conv = (LDKSignOrCreationError*)o;
29868         LDKStr ret_str = SignOrCreationError_to_str(o_conv);
29869         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
29870         Str_free(ret_str);
29871         return ret_conv;
29872 }
29873
29874 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) {
29875         LDKChannelManager channelmanager_conv;
29876         channelmanager_conv.inner = (void*)(channelmanager & (~1));
29877         channelmanager_conv.is_owned = false;
29878         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
29879         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
29880                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29881                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
29882         }
29883         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
29884         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(((uint64_t)amt_msat) & ~1);
29885         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)amt_msat) & ~1));
29886         LDKStr description_conv = java_to_owned_str(env, description);
29887         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
29888         *ret_conv = create_invoice_from_channelmanager(&channelmanager_conv, keys_manager_conv, network_conv, amt_msat_conv, description_conv);
29889         return (uint64_t)ret_conv;
29890 }
29891
29892 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SiPrefix_1from_1str(JNIEnv *env, jclass clz, jstring s) {
29893         LDKStr s_conv = java_to_owned_str(env, s);
29894         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
29895         *ret_conv = SiPrefix_from_str(s_conv);
29896         return (uint64_t)ret_conv;
29897 }
29898
29899 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1from_1str(JNIEnv *env, jclass clz, jstring s) {
29900         LDKStr s_conv = java_to_owned_str(env, s);
29901         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
29902         *ret_conv = Invoice_from_str(s_conv);
29903         return (uint64_t)ret_conv;
29904 }
29905
29906 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1from_1str(JNIEnv *env, jclass clz, jstring s) {
29907         LDKStr s_conv = java_to_owned_str(env, s);
29908         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
29909         *ret_conv = SignedRawInvoice_from_str(s_conv);
29910         return (uint64_t)ret_conv;
29911 }
29912
29913 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Invoice_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
29914         LDKInvoice o_conv;
29915         o_conv.inner = (void*)(o & (~1));
29916         o_conv.is_owned = false;
29917         LDKStr ret_str = Invoice_to_str(&o_conv);
29918         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
29919         Str_free(ret_str);
29920         return ret_conv;
29921 }
29922
29923 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
29924         LDKSignedRawInvoice o_conv;
29925         o_conv.inner = (void*)(o & (~1));
29926         o_conv.is_owned = false;
29927         LDKStr ret_str = SignedRawInvoice_to_str(&o_conv);
29928         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
29929         Str_free(ret_str);
29930         return ret_conv;
29931 }
29932
29933 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Currency_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
29934         LDKCurrency* o_conv = (LDKCurrency*)(o & ~1);
29935         LDKStr ret_str = Currency_to_str(o_conv);
29936         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
29937         Str_free(ret_str);
29938         return ret_conv;
29939 }
29940
29941 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SiPrefix_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
29942         LDKSiPrefix* o_conv = (LDKSiPrefix*)(o & ~1);
29943         LDKStr ret_str = SiPrefix_to_str(o_conv);
29944         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
29945         Str_free(ret_str);
29946         return ret_conv;
29947 }
29948