Merge pull request #50 from TheBlueMatt/main
[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 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentIdDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3211         return ((LDKCResult_PaymentIdDecodeErrorZ*)arg)->result_ok;
3212 }
3213 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentIdDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3214         LDKCResult_PaymentIdDecodeErrorZ *val = (LDKCResult_PaymentIdDecodeErrorZ*)(arg & ~1);
3215         CHECK(val->result_ok);
3216         LDKPaymentId res_var = (*val->contents.result);
3217         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3218         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3219         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
3220         return res_ref;
3221 }
3222 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentIdDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3223         LDKCResult_PaymentIdDecodeErrorZ *val = (LDKCResult_PaymentIdDecodeErrorZ*)(arg & ~1);
3224         CHECK(!val->result_ok);
3225         LDKDecodeError err_var = (*val->contents.err);
3226         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3227         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3228         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
3229         return err_ref;
3230 }
3231 static jclass LDKCOption_u16Z_Some_class = NULL;
3232 static jmethodID LDKCOption_u16Z_Some_meth = NULL;
3233 static jclass LDKCOption_u16Z_None_class = NULL;
3234 static jmethodID LDKCOption_u16Z_None_meth = NULL;
3235 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u16Z_init (JNIEnv *env, jclass clz) {
3236         LDKCOption_u16Z_Some_class =
3237                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_u16Z$Some;"));
3238         CHECK(LDKCOption_u16Z_Some_class != NULL);
3239         LDKCOption_u16Z_Some_meth = (*env)->GetMethodID(env, LDKCOption_u16Z_Some_class, "<init>", "(S)V");
3240         CHECK(LDKCOption_u16Z_Some_meth != NULL);
3241         LDKCOption_u16Z_None_class =
3242                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_u16Z$None;"));
3243         CHECK(LDKCOption_u16Z_None_class != NULL);
3244         LDKCOption_u16Z_None_meth = (*env)->GetMethodID(env, LDKCOption_u16Z_None_class, "<init>", "()V");
3245         CHECK(LDKCOption_u16Z_None_meth != NULL);
3246 }
3247 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u16Z_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3248         LDKCOption_u16Z *obj = (LDKCOption_u16Z*)(ptr & ~1);
3249         switch(obj->tag) {
3250                 case LDKCOption_u16Z_Some: {
3251                         return (*env)->NewObject(env, LDKCOption_u16Z_Some_class, LDKCOption_u16Z_Some_meth, obj->some);
3252                 }
3253                 case LDKCOption_u16Z_None: {
3254                         return (*env)->NewObject(env, LDKCOption_u16Z_None_class, LDKCOption_u16Z_None_meth);
3255                 }
3256                 default: abort();
3257         }
3258 }
3259 static jclass LDKAPIError_APIMisuseError_class = NULL;
3260 static jmethodID LDKAPIError_APIMisuseError_meth = NULL;
3261 static jclass LDKAPIError_FeeRateTooHigh_class = NULL;
3262 static jmethodID LDKAPIError_FeeRateTooHigh_meth = NULL;
3263 static jclass LDKAPIError_RouteError_class = NULL;
3264 static jmethodID LDKAPIError_RouteError_meth = NULL;
3265 static jclass LDKAPIError_ChannelUnavailable_class = NULL;
3266 static jmethodID LDKAPIError_ChannelUnavailable_meth = NULL;
3267 static jclass LDKAPIError_MonitorUpdateFailed_class = NULL;
3268 static jmethodID LDKAPIError_MonitorUpdateFailed_meth = NULL;
3269 static jclass LDKAPIError_IncompatibleShutdownScript_class = NULL;
3270 static jmethodID LDKAPIError_IncompatibleShutdownScript_meth = NULL;
3271 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKAPIError_init (JNIEnv *env, jclass clz) {
3272         LDKAPIError_APIMisuseError_class =
3273                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$APIMisuseError;"));
3274         CHECK(LDKAPIError_APIMisuseError_class != NULL);
3275         LDKAPIError_APIMisuseError_meth = (*env)->GetMethodID(env, LDKAPIError_APIMisuseError_class, "<init>", "(Ljava/lang/String;)V");
3276         CHECK(LDKAPIError_APIMisuseError_meth != NULL);
3277         LDKAPIError_FeeRateTooHigh_class =
3278                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$FeeRateTooHigh;"));
3279         CHECK(LDKAPIError_FeeRateTooHigh_class != NULL);
3280         LDKAPIError_FeeRateTooHigh_meth = (*env)->GetMethodID(env, LDKAPIError_FeeRateTooHigh_class, "<init>", "(Ljava/lang/String;I)V");
3281         CHECK(LDKAPIError_FeeRateTooHigh_meth != NULL);
3282         LDKAPIError_RouteError_class =
3283                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$RouteError;"));
3284         CHECK(LDKAPIError_RouteError_class != NULL);
3285         LDKAPIError_RouteError_meth = (*env)->GetMethodID(env, LDKAPIError_RouteError_class, "<init>", "(Ljava/lang/String;)V");
3286         CHECK(LDKAPIError_RouteError_meth != NULL);
3287         LDKAPIError_ChannelUnavailable_class =
3288                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$ChannelUnavailable;"));
3289         CHECK(LDKAPIError_ChannelUnavailable_class != NULL);
3290         LDKAPIError_ChannelUnavailable_meth = (*env)->GetMethodID(env, LDKAPIError_ChannelUnavailable_class, "<init>", "(Ljava/lang/String;)V");
3291         CHECK(LDKAPIError_ChannelUnavailable_meth != NULL);
3292         LDKAPIError_MonitorUpdateFailed_class =
3293                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$MonitorUpdateFailed;"));
3294         CHECK(LDKAPIError_MonitorUpdateFailed_class != NULL);
3295         LDKAPIError_MonitorUpdateFailed_meth = (*env)->GetMethodID(env, LDKAPIError_MonitorUpdateFailed_class, "<init>", "()V");
3296         CHECK(LDKAPIError_MonitorUpdateFailed_meth != NULL);
3297         LDKAPIError_IncompatibleShutdownScript_class =
3298                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$IncompatibleShutdownScript;"));
3299         CHECK(LDKAPIError_IncompatibleShutdownScript_class != NULL);
3300         LDKAPIError_IncompatibleShutdownScript_meth = (*env)->GetMethodID(env, LDKAPIError_IncompatibleShutdownScript_class, "<init>", "(J)V");
3301         CHECK(LDKAPIError_IncompatibleShutdownScript_meth != NULL);
3302 }
3303 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKAPIError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3304         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
3305         switch(obj->tag) {
3306                 case LDKAPIError_APIMisuseError: {
3307                         LDKStr err_str = obj->api_misuse_error.err;
3308                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
3309                         return (*env)->NewObject(env, LDKAPIError_APIMisuseError_class, LDKAPIError_APIMisuseError_meth, err_conv);
3310                 }
3311                 case LDKAPIError_FeeRateTooHigh: {
3312                         LDKStr err_str = obj->fee_rate_too_high.err;
3313                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
3314                         return (*env)->NewObject(env, LDKAPIError_FeeRateTooHigh_class, LDKAPIError_FeeRateTooHigh_meth, err_conv, obj->fee_rate_too_high.feerate);
3315                 }
3316                 case LDKAPIError_RouteError: {
3317                         LDKStr err_str = obj->route_error.err;
3318                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
3319                         return (*env)->NewObject(env, LDKAPIError_RouteError_class, LDKAPIError_RouteError_meth, err_conv);
3320                 }
3321                 case LDKAPIError_ChannelUnavailable: {
3322                         LDKStr err_str = obj->channel_unavailable.err;
3323                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
3324                         return (*env)->NewObject(env, LDKAPIError_ChannelUnavailable_class, LDKAPIError_ChannelUnavailable_meth, err_conv);
3325                 }
3326                 case LDKAPIError_MonitorUpdateFailed: {
3327                         return (*env)->NewObject(env, LDKAPIError_MonitorUpdateFailed_class, LDKAPIError_MonitorUpdateFailed_meth);
3328                 }
3329                 case LDKAPIError_IncompatibleShutdownScript: {
3330                         LDKShutdownScript script_var = obj->incompatible_shutdown_script.script;
3331                         CHECK((((uint64_t)script_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3332                         CHECK((((uint64_t)&script_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3333                         uint64_t script_ref = (uint64_t)script_var.inner & ~1;
3334                         return (*env)->NewObject(env, LDKAPIError_IncompatibleShutdownScript_class, LDKAPIError_IncompatibleShutdownScript_meth, script_ref);
3335                 }
3336                 default: abort();
3337         }
3338 }
3339 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneAPIErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3340         return ((LDKCResult_NoneAPIErrorZ*)arg)->result_ok;
3341 }
3342 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3343         LDKCResult_NoneAPIErrorZ *val = (LDKCResult_NoneAPIErrorZ*)(arg & ~1);
3344         CHECK(val->result_ok);
3345         return *val->contents.result;
3346 }
3347 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3348         LDKCResult_NoneAPIErrorZ *val = (LDKCResult_NoneAPIErrorZ*)(arg & ~1);
3349         CHECK(!val->result_ok);
3350         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
3351         return err_ref;
3352 }
3353 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1CResult_1NoneAPIErrorZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
3354         LDKCVec_CResult_NoneAPIErrorZZ *ret = MALLOC(sizeof(LDKCVec_CResult_NoneAPIErrorZZ), "LDKCVec_CResult_NoneAPIErrorZZ");
3355         ret->datalen = (*env)->GetArrayLength(env, elems);
3356         if (ret->datalen == 0) {
3357                 ret->data = NULL;
3358         } else {
3359                 ret->data = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ) * ret->datalen, "LDKCVec_CResult_NoneAPIErrorZZ Data");
3360                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3361                 for (size_t i = 0; i < ret->datalen; i++) {
3362                         int64_t arr_elem = java_elems[i];
3363                         LDKCResult_NoneAPIErrorZ arr_elem_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)arr_elem) & ~1);
3364                         arr_elem_conv = CResult_NoneAPIErrorZ_clone((LDKCResult_NoneAPIErrorZ*)(((uint64_t)arr_elem) & ~1));
3365                         ret->data[i] = arr_elem_conv;
3366                 }
3367                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3368         }
3369         return (uint64_t)ret;
3370 }
3371 static inline LDKCVec_CResult_NoneAPIErrorZZ CVec_CResult_NoneAPIErrorZZ_clone(const LDKCVec_CResult_NoneAPIErrorZZ *orig) {
3372         LDKCVec_CResult_NoneAPIErrorZZ ret = { .data = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ) * orig->datalen, "LDKCVec_CResult_NoneAPIErrorZZ clone bytes"), .datalen = orig->datalen };
3373         for (size_t i = 0; i < ret.datalen; i++) {
3374                 ret.data[i] = CResult_NoneAPIErrorZ_clone(&orig->data[i]);
3375         }
3376         return ret;
3377 }
3378 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1APIErrorZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
3379         LDKCVec_APIErrorZ *ret = MALLOC(sizeof(LDKCVec_APIErrorZ), "LDKCVec_APIErrorZ");
3380         ret->datalen = (*env)->GetArrayLength(env, elems);
3381         if (ret->datalen == 0) {
3382                 ret->data = NULL;
3383         } else {
3384                 ret->data = MALLOC(sizeof(LDKAPIError) * ret->datalen, "LDKCVec_APIErrorZ Data");
3385                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3386                 for (size_t i = 0; i < ret->datalen; i++) {
3387                         int64_t arr_elem = java_elems[i];
3388                         LDKAPIError arr_elem_conv = *(LDKAPIError*)(((uint64_t)arr_elem) & ~1);
3389                         arr_elem_conv = APIError_clone((LDKAPIError*)(((uint64_t)arr_elem) & ~1));
3390                         ret->data[i] = arr_elem_conv;
3391                 }
3392                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3393         }
3394         return (uint64_t)ret;
3395 }
3396 static inline LDKCVec_APIErrorZ CVec_APIErrorZ_clone(const LDKCVec_APIErrorZ *orig) {
3397         LDKCVec_APIErrorZ ret = { .data = MALLOC(sizeof(LDKAPIError) * orig->datalen, "LDKCVec_APIErrorZ clone bytes"), .datalen = orig->datalen };
3398         for (size_t i = 0; i < ret.datalen; i++) {
3399                 ret.data[i] = APIError_clone(&orig->data[i]);
3400         }
3401         return ret;
3402 }
3403 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1_1u832APIErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3404         return ((LDKCResult__u832APIErrorZ*)arg)->result_ok;
3405 }
3406 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1_1u832APIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3407         LDKCResult__u832APIErrorZ *val = (LDKCResult__u832APIErrorZ*)(arg & ~1);
3408         CHECK(val->result_ok);
3409         int8_tArray res_arr = (*env)->NewByteArray(env, 32);
3410         (*env)->SetByteArrayRegion(env, res_arr, 0, 32, (*val->contents.result).data);
3411         return res_arr;
3412 }
3413 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1_1u832APIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3414         LDKCResult__u832APIErrorZ *val = (LDKCResult__u832APIErrorZ*)(arg & ~1);
3415         CHECK(!val->result_ok);
3416         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
3417         return err_ref;
3418 }
3419 static jclass LDKPaymentSendFailure_ParameterError_class = NULL;
3420 static jmethodID LDKPaymentSendFailure_ParameterError_meth = NULL;
3421 static jclass LDKPaymentSendFailure_PathParameterError_class = NULL;
3422 static jmethodID LDKPaymentSendFailure_PathParameterError_meth = NULL;
3423 static jclass LDKPaymentSendFailure_AllFailedRetrySafe_class = NULL;
3424 static jmethodID LDKPaymentSendFailure_AllFailedRetrySafe_meth = NULL;
3425 static jclass LDKPaymentSendFailure_PartialFailure_class = NULL;
3426 static jmethodID LDKPaymentSendFailure_PartialFailure_meth = NULL;
3427 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKPaymentSendFailure_init (JNIEnv *env, jclass clz) {
3428         LDKPaymentSendFailure_ParameterError_class =
3429                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentSendFailure$ParameterError;"));
3430         CHECK(LDKPaymentSendFailure_ParameterError_class != NULL);
3431         LDKPaymentSendFailure_ParameterError_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_ParameterError_class, "<init>", "(J)V");
3432         CHECK(LDKPaymentSendFailure_ParameterError_meth != NULL);
3433         LDKPaymentSendFailure_PathParameterError_class =
3434                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentSendFailure$PathParameterError;"));
3435         CHECK(LDKPaymentSendFailure_PathParameterError_class != NULL);
3436         LDKPaymentSendFailure_PathParameterError_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_PathParameterError_class, "<init>", "([J)V");
3437         CHECK(LDKPaymentSendFailure_PathParameterError_meth != NULL);
3438         LDKPaymentSendFailure_AllFailedRetrySafe_class =
3439                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentSendFailure$AllFailedRetrySafe;"));
3440         CHECK(LDKPaymentSendFailure_AllFailedRetrySafe_class != NULL);
3441         LDKPaymentSendFailure_AllFailedRetrySafe_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_AllFailedRetrySafe_class, "<init>", "([J)V");
3442         CHECK(LDKPaymentSendFailure_AllFailedRetrySafe_meth != NULL);
3443         LDKPaymentSendFailure_PartialFailure_class =
3444                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentSendFailure$PartialFailure;"));
3445         CHECK(LDKPaymentSendFailure_PartialFailure_class != NULL);
3446         LDKPaymentSendFailure_PartialFailure_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_PartialFailure_class, "<init>", "([J)V");
3447         CHECK(LDKPaymentSendFailure_PartialFailure_meth != NULL);
3448 }
3449 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPaymentSendFailure_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3450         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
3451         switch(obj->tag) {
3452                 case LDKPaymentSendFailure_ParameterError: {
3453                         uint64_t parameter_error_ref = ((uint64_t)&obj->parameter_error) | 1;
3454                         return (*env)->NewObject(env, LDKPaymentSendFailure_ParameterError_class, LDKPaymentSendFailure_ParameterError_meth, parameter_error_ref);
3455                 }
3456                 case LDKPaymentSendFailure_PathParameterError: {
3457                         LDKCVec_CResult_NoneAPIErrorZZ path_parameter_error_var = obj->path_parameter_error;
3458                         int64_tArray path_parameter_error_arr = (*env)->NewLongArray(env, path_parameter_error_var.datalen);
3459                         int64_t *path_parameter_error_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_parameter_error_arr, NULL);
3460                         for (size_t w = 0; w < path_parameter_error_var.datalen; w++) {
3461                                 LDKCResult_NoneAPIErrorZ* path_parameter_error_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
3462                                 *path_parameter_error_conv_22_conv = path_parameter_error_var.data[w];
3463                                 *path_parameter_error_conv_22_conv = CResult_NoneAPIErrorZ_clone(path_parameter_error_conv_22_conv);
3464                                 path_parameter_error_arr_ptr[w] = (uint64_t)path_parameter_error_conv_22_conv;
3465                         }
3466                         (*env)->ReleasePrimitiveArrayCritical(env, path_parameter_error_arr, path_parameter_error_arr_ptr, 0);
3467                         return (*env)->NewObject(env, LDKPaymentSendFailure_PathParameterError_class, LDKPaymentSendFailure_PathParameterError_meth, path_parameter_error_arr);
3468                 }
3469                 case LDKPaymentSendFailure_AllFailedRetrySafe: {
3470                         LDKCVec_APIErrorZ all_failed_retry_safe_var = obj->all_failed_retry_safe;
3471                         int64_tArray all_failed_retry_safe_arr = (*env)->NewLongArray(env, all_failed_retry_safe_var.datalen);
3472                         int64_t *all_failed_retry_safe_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, all_failed_retry_safe_arr, NULL);
3473                         for (size_t k = 0; k < all_failed_retry_safe_var.datalen; k++) {
3474                                 uint64_t all_failed_retry_safe_conv_10_ref = ((uint64_t)&all_failed_retry_safe_var.data[k]) | 1;
3475                                 all_failed_retry_safe_arr_ptr[k] = all_failed_retry_safe_conv_10_ref;
3476                         }
3477                         (*env)->ReleasePrimitiveArrayCritical(env, all_failed_retry_safe_arr, all_failed_retry_safe_arr_ptr, 0);
3478                         return (*env)->NewObject(env, LDKPaymentSendFailure_AllFailedRetrySafe_class, LDKPaymentSendFailure_AllFailedRetrySafe_meth, all_failed_retry_safe_arr);
3479                 }
3480                 case LDKPaymentSendFailure_PartialFailure: {
3481                         LDKCVec_CResult_NoneAPIErrorZZ partial_failure_var = obj->partial_failure;
3482                         int64_tArray partial_failure_arr = (*env)->NewLongArray(env, partial_failure_var.datalen);
3483                         int64_t *partial_failure_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, partial_failure_arr, NULL);
3484                         for (size_t w = 0; w < partial_failure_var.datalen; w++) {
3485                                 LDKCResult_NoneAPIErrorZ* partial_failure_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
3486                                 *partial_failure_conv_22_conv = partial_failure_var.data[w];
3487                                 *partial_failure_conv_22_conv = CResult_NoneAPIErrorZ_clone(partial_failure_conv_22_conv);
3488                                 partial_failure_arr_ptr[w] = (uint64_t)partial_failure_conv_22_conv;
3489                         }
3490                         (*env)->ReleasePrimitiveArrayCritical(env, partial_failure_arr, partial_failure_arr_ptr, 0);
3491                         return (*env)->NewObject(env, LDKPaymentSendFailure_PartialFailure_class, LDKPaymentSendFailure_PartialFailure_meth, partial_failure_arr);
3492                 }
3493                 default: abort();
3494         }
3495 }
3496 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentIdPaymentSendFailureZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3497         return ((LDKCResult_PaymentIdPaymentSendFailureZ*)arg)->result_ok;
3498 }
3499 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentIdPaymentSendFailureZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3500         LDKCResult_PaymentIdPaymentSendFailureZ *val = (LDKCResult_PaymentIdPaymentSendFailureZ*)(arg & ~1);
3501         CHECK(val->result_ok);
3502         LDKPaymentId res_var = (*val->contents.result);
3503         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3504         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3505         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
3506         return res_ref;
3507 }
3508 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentIdPaymentSendFailureZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3509         LDKCResult_PaymentIdPaymentSendFailureZ *val = (LDKCResult_PaymentIdPaymentSendFailureZ*)(arg & ~1);
3510         CHECK(!val->result_ok);
3511         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
3512         return err_ref;
3513 }
3514 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePaymentSendFailureZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3515         return ((LDKCResult_NonePaymentSendFailureZ*)arg)->result_ok;
3516 }
3517 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePaymentSendFailureZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3518         LDKCResult_NonePaymentSendFailureZ *val = (LDKCResult_NonePaymentSendFailureZ*)(arg & ~1);
3519         CHECK(val->result_ok);
3520         return *val->contents.result;
3521 }
3522 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePaymentSendFailureZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3523         LDKCResult_NonePaymentSendFailureZ *val = (LDKCResult_NonePaymentSendFailureZ*)(arg & ~1);
3524         CHECK(!val->result_ok);
3525         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
3526         return err_ref;
3527 }
3528 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1PaymentHashPaymentIdZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
3529         LDKC2Tuple_PaymentHashPaymentIdZ* ret = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
3530         LDKThirtyTwoBytes a_ref;
3531         CHECK((*env)->GetArrayLength(env, a) == 32);
3532         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
3533         ret->a = a_ref;
3534         LDKPaymentId b_conv;
3535         b_conv.inner = (void*)(b & (~1));
3536         b_conv.is_owned = (b & 1) || (b == 0);
3537         b_conv = PaymentId_clone(&b_conv);
3538         ret->b = b_conv;
3539         return (uint64_t)ret;
3540 }
3541 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentIdZ_get_a(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR tuple){
3542         return ThirtyTwoBytes_clone(&tuple->a);
3543 }
3544 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1get_1a(JNIEnv *env, jclass clz, int64_t tuple) {
3545         LDKC2Tuple_PaymentHashPaymentIdZ* tuple_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(tuple & ~1);
3546         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
3547         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_PaymentHashPaymentIdZ_get_a(tuple_conv).data);
3548         return ret_arr;
3549 }
3550
3551 static inline struct LDKPaymentId C2Tuple_PaymentHashPaymentIdZ_get_b(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR tuple){
3552         return PaymentId_clone(&tuple->b);
3553 }
3554 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1get_1b(JNIEnv *env, jclass clz, int64_t tuple) {
3555         LDKC2Tuple_PaymentHashPaymentIdZ* tuple_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(tuple & ~1);
3556         LDKPaymentId ret_var = C2Tuple_PaymentHashPaymentIdZ_get_b(tuple_conv);
3557         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3558         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3559         uint64_t ret_ref = (uint64_t)ret_var.inner;
3560         if (ret_var.is_owned) {
3561                 ret_ref |= 1;
3562         }
3563         return ret_ref;
3564 }
3565
3566 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3567         return ((LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)arg)->result_ok;
3568 }
3569 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3570         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *val = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(arg & ~1);
3571         CHECK(val->result_ok);
3572         LDKC2Tuple_PaymentHashPaymentIdZ* res_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
3573         *res_conv = (*val->contents.result);
3574         *res_conv = C2Tuple_PaymentHashPaymentIdZ_clone(res_conv);
3575         return ((uint64_t)res_conv);
3576 }
3577 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3578         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *val = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(arg & ~1);
3579         CHECK(!val->result_ok);
3580         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
3581         return err_ref;
3582 }
3583 static jclass LDKNetAddress_IPv4_class = NULL;
3584 static jmethodID LDKNetAddress_IPv4_meth = NULL;
3585 static jclass LDKNetAddress_IPv6_class = NULL;
3586 static jmethodID LDKNetAddress_IPv6_meth = NULL;
3587 static jclass LDKNetAddress_OnionV2_class = NULL;
3588 static jmethodID LDKNetAddress_OnionV2_meth = NULL;
3589 static jclass LDKNetAddress_OnionV3_class = NULL;
3590 static jmethodID LDKNetAddress_OnionV3_meth = NULL;
3591 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKNetAddress_init (JNIEnv *env, jclass clz) {
3592         LDKNetAddress_IPv4_class =
3593                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$IPv4;"));
3594         CHECK(LDKNetAddress_IPv4_class != NULL);
3595         LDKNetAddress_IPv4_meth = (*env)->GetMethodID(env, LDKNetAddress_IPv4_class, "<init>", "([BS)V");
3596         CHECK(LDKNetAddress_IPv4_meth != NULL);
3597         LDKNetAddress_IPv6_class =
3598                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$IPv6;"));
3599         CHECK(LDKNetAddress_IPv6_class != NULL);
3600         LDKNetAddress_IPv6_meth = (*env)->GetMethodID(env, LDKNetAddress_IPv6_class, "<init>", "([BS)V");
3601         CHECK(LDKNetAddress_IPv6_meth != NULL);
3602         LDKNetAddress_OnionV2_class =
3603                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$OnionV2;"));
3604         CHECK(LDKNetAddress_OnionV2_class != NULL);
3605         LDKNetAddress_OnionV2_meth = (*env)->GetMethodID(env, LDKNetAddress_OnionV2_class, "<init>", "([BS)V");
3606         CHECK(LDKNetAddress_OnionV2_meth != NULL);
3607         LDKNetAddress_OnionV3_class =
3608                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$OnionV3;"));
3609         CHECK(LDKNetAddress_OnionV3_class != NULL);
3610         LDKNetAddress_OnionV3_meth = (*env)->GetMethodID(env, LDKNetAddress_OnionV3_class, "<init>", "([BSBS)V");
3611         CHECK(LDKNetAddress_OnionV3_meth != NULL);
3612 }
3613 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKNetAddress_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3614         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3615         switch(obj->tag) {
3616                 case LDKNetAddress_IPv4: {
3617                         int8_tArray addr_arr = (*env)->NewByteArray(env, 4);
3618                         (*env)->SetByteArrayRegion(env, addr_arr, 0, 4, obj->i_pv4.addr.data);
3619                         return (*env)->NewObject(env, LDKNetAddress_IPv4_class, LDKNetAddress_IPv4_meth, addr_arr, obj->i_pv4.port);
3620                 }
3621                 case LDKNetAddress_IPv6: {
3622                         int8_tArray addr_arr = (*env)->NewByteArray(env, 16);
3623                         (*env)->SetByteArrayRegion(env, addr_arr, 0, 16, obj->i_pv6.addr.data);
3624                         return (*env)->NewObject(env, LDKNetAddress_IPv6_class, LDKNetAddress_IPv6_meth, addr_arr, obj->i_pv6.port);
3625                 }
3626                 case LDKNetAddress_OnionV2: {
3627                         int8_tArray addr_arr = (*env)->NewByteArray(env, 10);
3628                         (*env)->SetByteArrayRegion(env, addr_arr, 0, 10, obj->onion_v2.addr.data);
3629                         return (*env)->NewObject(env, LDKNetAddress_OnionV2_class, LDKNetAddress_OnionV2_meth, addr_arr, obj->onion_v2.port);
3630                 }
3631                 case LDKNetAddress_OnionV3: {
3632                         int8_tArray ed25519_pubkey_arr = (*env)->NewByteArray(env, 32);
3633                         (*env)->SetByteArrayRegion(env, ed25519_pubkey_arr, 0, 32, obj->onion_v3.ed25519_pubkey.data);
3634                         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);
3635                 }
3636                 default: abort();
3637         }
3638 }
3639 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1NetAddressZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
3640         LDKCVec_NetAddressZ *ret = MALLOC(sizeof(LDKCVec_NetAddressZ), "LDKCVec_NetAddressZ");
3641         ret->datalen = (*env)->GetArrayLength(env, elems);
3642         if (ret->datalen == 0) {
3643                 ret->data = NULL;
3644         } else {
3645                 ret->data = MALLOC(sizeof(LDKNetAddress) * ret->datalen, "LDKCVec_NetAddressZ Data");
3646                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3647                 for (size_t i = 0; i < ret->datalen; i++) {
3648                         int64_t arr_elem = java_elems[i];
3649                         LDKNetAddress arr_elem_conv = *(LDKNetAddress*)(((uint64_t)arr_elem) & ~1);
3650                         arr_elem_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)arr_elem) & ~1));
3651                         ret->data[i] = arr_elem_conv;
3652                 }
3653                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3654         }
3655         return (uint64_t)ret;
3656 }
3657 static inline LDKCVec_NetAddressZ CVec_NetAddressZ_clone(const LDKCVec_NetAddressZ *orig) {
3658         LDKCVec_NetAddressZ ret = { .data = MALLOC(sizeof(LDKNetAddress) * orig->datalen, "LDKCVec_NetAddressZ clone bytes"), .datalen = orig->datalen };
3659         for (size_t i = 0; i < ret.datalen; i++) {
3660                 ret.data[i] = NetAddress_clone(&orig->data[i]);
3661         }
3662         return ret;
3663 }
3664 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1PaymentHashPaymentSecretZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int8_tArray b) {
3665         LDKC2Tuple_PaymentHashPaymentSecretZ* ret = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
3666         LDKThirtyTwoBytes a_ref;
3667         CHECK((*env)->GetArrayLength(env, a) == 32);
3668         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
3669         ret->a = a_ref;
3670         LDKThirtyTwoBytes b_ref;
3671         CHECK((*env)->GetArrayLength(env, b) == 32);
3672         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
3673         ret->b = b_ref;
3674         return (uint64_t)ret;
3675 }
3676 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentSecretZ_get_a(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR tuple){
3677         return ThirtyTwoBytes_clone(&tuple->a);
3678 }
3679 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1get_1a(JNIEnv *env, jclass clz, int64_t tuple) {
3680         LDKC2Tuple_PaymentHashPaymentSecretZ* tuple_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(tuple & ~1);
3681         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
3682         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_PaymentHashPaymentSecretZ_get_a(tuple_conv).data);
3683         return ret_arr;
3684 }
3685
3686 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentSecretZ_get_b(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR tuple){
3687         return ThirtyTwoBytes_clone(&tuple->b);
3688 }
3689 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1get_1b(JNIEnv *env, jclass clz, int64_t tuple) {
3690         LDKC2Tuple_PaymentHashPaymentSecretZ* tuple_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(tuple & ~1);
3691         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
3692         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_PaymentHashPaymentSecretZ_get_b(tuple_conv).data);
3693         return ret_arr;
3694 }
3695
3696 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentSecretAPIErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3697         return ((LDKCResult_PaymentSecretAPIErrorZ*)arg)->result_ok;
3698 }
3699 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentSecretAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3700         LDKCResult_PaymentSecretAPIErrorZ *val = (LDKCResult_PaymentSecretAPIErrorZ*)(arg & ~1);
3701         CHECK(val->result_ok);
3702         int8_tArray res_arr = (*env)->NewByteArray(env, 32);
3703         (*env)->SetByteArrayRegion(env, res_arr, 0, 32, (*val->contents.result).data);
3704         return res_arr;
3705 }
3706 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentSecretAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3707         LDKCResult_PaymentSecretAPIErrorZ *val = (LDKCResult_PaymentSecretAPIErrorZ*)(arg & ~1);
3708         CHECK(!val->result_ok);
3709         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
3710         return err_ref;
3711 }
3712 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1ChannelMonitorZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
3713         LDKCVec_ChannelMonitorZ *ret = MALLOC(sizeof(LDKCVec_ChannelMonitorZ), "LDKCVec_ChannelMonitorZ");
3714         ret->datalen = (*env)->GetArrayLength(env, elems);
3715         if (ret->datalen == 0) {
3716                 ret->data = NULL;
3717         } else {
3718                 ret->data = MALLOC(sizeof(LDKChannelMonitor) * ret->datalen, "LDKCVec_ChannelMonitorZ Data");
3719                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3720                 for (size_t i = 0; i < ret->datalen; i++) {
3721                         int64_t arr_elem = java_elems[i];
3722                         LDKChannelMonitor arr_elem_conv;
3723                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3724                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3725                         arr_elem_conv = ChannelMonitor_clone(&arr_elem_conv);
3726                         ret->data[i] = arr_elem_conv;
3727                 }
3728                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3729         }
3730         return (uint64_t)ret;
3731 }
3732 static inline LDKCVec_ChannelMonitorZ CVec_ChannelMonitorZ_clone(const LDKCVec_ChannelMonitorZ *orig) {
3733         LDKCVec_ChannelMonitorZ ret = { .data = MALLOC(sizeof(LDKChannelMonitor) * orig->datalen, "LDKCVec_ChannelMonitorZ clone bytes"), .datalen = orig->datalen };
3734         for (size_t i = 0; i < ret.datalen; i++) {
3735                 ret.data[i] = ChannelMonitor_clone(&orig->data[i]);
3736         }
3737         return ret;
3738 }
3739 typedef struct LDKWatch_JCalls {
3740         atomic_size_t refcnt;
3741         JavaVM *vm;
3742         jweak o;
3743         jmethodID watch_channel_meth;
3744         jmethodID update_channel_meth;
3745         jmethodID release_pending_monitor_events_meth;
3746 } LDKWatch_JCalls;
3747 static void LDKWatch_JCalls_free(void* this_arg) {
3748         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
3749         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3750                 JNIEnv *env;
3751                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3752                 if (get_jenv_res == JNI_EDETACHED) {
3753                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3754                 } else {
3755                         DO_ASSERT(get_jenv_res == JNI_OK);
3756                 }
3757                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
3758                 if (get_jenv_res == JNI_EDETACHED) {
3759                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3760                 }
3761                 FREE(j_calls);
3762         }
3763 }
3764 LDKCResult_NoneChannelMonitorUpdateErrZ watch_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitor monitor) {
3765         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
3766         JNIEnv *env;
3767         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3768         if (get_jenv_res == JNI_EDETACHED) {
3769                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3770         } else {
3771                 DO_ASSERT(get_jenv_res == JNI_OK);
3772         }
3773         LDKOutPoint funding_txo_var = funding_txo;
3774         CHECK((((uint64_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3775         CHECK((((uint64_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3776         uint64_t funding_txo_ref = (uint64_t)funding_txo_var.inner;
3777         if (funding_txo_var.is_owned) {
3778                 funding_txo_ref |= 1;
3779         }
3780         LDKChannelMonitor monitor_var = monitor;
3781         CHECK((((uint64_t)monitor_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3782         CHECK((((uint64_t)&monitor_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3783         uint64_t monitor_ref = (uint64_t)monitor_var.inner;
3784         if (monitor_var.is_owned) {
3785                 monitor_ref |= 1;
3786         }
3787         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3788         CHECK(obj != NULL);
3789         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->watch_channel_meth, funding_txo_ref, monitor_ref);
3790         if ((*env)->ExceptionCheck(env)) {
3791                 (*env)->ExceptionDescribe(env);
3792                 (*env)->FatalError(env, "A call to watch_channel in LDKWatch from rust threw an exception.");
3793         }
3794         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
3795         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
3796         if (get_jenv_res == JNI_EDETACHED) {
3797                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3798         }
3799         return ret_conv;
3800 }
3801 LDKCResult_NoneChannelMonitorUpdateErrZ update_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitorUpdate update) {
3802         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
3803         JNIEnv *env;
3804         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3805         if (get_jenv_res == JNI_EDETACHED) {
3806                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3807         } else {
3808                 DO_ASSERT(get_jenv_res == JNI_OK);
3809         }
3810         LDKOutPoint funding_txo_var = funding_txo;
3811         CHECK((((uint64_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3812         CHECK((((uint64_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3813         uint64_t funding_txo_ref = (uint64_t)funding_txo_var.inner;
3814         if (funding_txo_var.is_owned) {
3815                 funding_txo_ref |= 1;
3816         }
3817         LDKChannelMonitorUpdate update_var = update;
3818         CHECK((((uint64_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3819         CHECK((((uint64_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3820         uint64_t update_ref = (uint64_t)update_var.inner;
3821         if (update_var.is_owned) {
3822                 update_ref |= 1;
3823         }
3824         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3825         CHECK(obj != NULL);
3826         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->update_channel_meth, funding_txo_ref, update_ref);
3827         if ((*env)->ExceptionCheck(env)) {
3828                 (*env)->ExceptionDescribe(env);
3829                 (*env)->FatalError(env, "A call to update_channel in LDKWatch from rust threw an exception.");
3830         }
3831         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
3832         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
3833         if (get_jenv_res == JNI_EDETACHED) {
3834                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3835         }
3836         return ret_conv;
3837 }
3838 LDKCVec_MonitorEventZ release_pending_monitor_events_LDKWatch_jcall(const void* this_arg) {
3839         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
3840         JNIEnv *env;
3841         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3842         if (get_jenv_res == JNI_EDETACHED) {
3843                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3844         } else {
3845                 DO_ASSERT(get_jenv_res == JNI_OK);
3846         }
3847         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3848         CHECK(obj != NULL);
3849         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->release_pending_monitor_events_meth);
3850         if ((*env)->ExceptionCheck(env)) {
3851                 (*env)->ExceptionDescribe(env);
3852                 (*env)->FatalError(env, "A call to release_pending_monitor_events in LDKWatch from rust threw an exception.");
3853         }
3854         LDKCVec_MonitorEventZ ret_constr;
3855         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
3856         if (ret_constr.datalen > 0)
3857                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
3858         else
3859                 ret_constr.data = NULL;
3860         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
3861         for (size_t o = 0; o < ret_constr.datalen; o++) {
3862                 int64_t ret_conv_14 = ret_vals[o];
3863                 LDKMonitorEvent ret_conv_14_conv = *(LDKMonitorEvent*)(((uint64_t)ret_conv_14) & ~1);
3864                 ret_conv_14_conv = MonitorEvent_clone((LDKMonitorEvent*)(((uint64_t)ret_conv_14) & ~1));
3865                 ret_constr.data[o] = ret_conv_14_conv;
3866         }
3867         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
3868         if (get_jenv_res == JNI_EDETACHED) {
3869                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3870         }
3871         return ret_constr;
3872 }
3873 static void LDKWatch_JCalls_cloned(LDKWatch* new_obj) {
3874         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) new_obj->this_arg;
3875         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3876 }
3877 static inline LDKWatch LDKWatch_init (JNIEnv *env, jclass clz, jobject o) {
3878         jclass c = (*env)->GetObjectClass(env, o);
3879         CHECK(c != NULL);
3880         LDKWatch_JCalls *calls = MALLOC(sizeof(LDKWatch_JCalls), "LDKWatch_JCalls");
3881         atomic_init(&calls->refcnt, 1);
3882         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
3883         calls->o = (*env)->NewWeakGlobalRef(env, o);
3884         calls->watch_channel_meth = (*env)->GetMethodID(env, c, "watch_channel", "(JJ)J");
3885         CHECK(calls->watch_channel_meth != NULL);
3886         calls->update_channel_meth = (*env)->GetMethodID(env, c, "update_channel", "(JJ)J");
3887         CHECK(calls->update_channel_meth != NULL);
3888         calls->release_pending_monitor_events_meth = (*env)->GetMethodID(env, c, "release_pending_monitor_events", "()[J");
3889         CHECK(calls->release_pending_monitor_events_meth != NULL);
3890
3891         LDKWatch ret = {
3892                 .this_arg = (void*) calls,
3893                 .watch_channel = watch_channel_LDKWatch_jcall,
3894                 .update_channel = update_channel_LDKWatch_jcall,
3895                 .release_pending_monitor_events = release_pending_monitor_events_LDKWatch_jcall,
3896                 .free = LDKWatch_JCalls_free,
3897         };
3898         return ret;
3899 }
3900 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKWatch_1new(JNIEnv *env, jclass clz, jobject o) {
3901         LDKWatch *res_ptr = MALLOC(sizeof(LDKWatch), "LDKWatch");
3902         *res_ptr = LDKWatch_init(env, clz, o);
3903         return (uint64_t)res_ptr;
3904 }
3905 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) {
3906         LDKWatch* this_arg_conv = (LDKWatch*)(((uint64_t)this_arg) & ~1);
3907         LDKOutPoint funding_txo_conv;
3908         funding_txo_conv.inner = (void*)(funding_txo & (~1));
3909         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
3910         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
3911         LDKChannelMonitor monitor_conv;
3912         monitor_conv.inner = (void*)(monitor & (~1));
3913         monitor_conv.is_owned = (monitor & 1) || (monitor == 0);
3914         monitor_conv = ChannelMonitor_clone(&monitor_conv);
3915         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
3916         *ret_conv = (this_arg_conv->watch_channel)(this_arg_conv->this_arg, funding_txo_conv, monitor_conv);
3917         return (uint64_t)ret_conv;
3918 }
3919
3920 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) {
3921         LDKWatch* this_arg_conv = (LDKWatch*)(((uint64_t)this_arg) & ~1);
3922         LDKOutPoint funding_txo_conv;
3923         funding_txo_conv.inner = (void*)(funding_txo & (~1));
3924         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
3925         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
3926         LDKChannelMonitorUpdate update_conv;
3927         update_conv.inner = (void*)(update & (~1));
3928         update_conv.is_owned = (update & 1) || (update == 0);
3929         update_conv = ChannelMonitorUpdate_clone(&update_conv);
3930         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
3931         *ret_conv = (this_arg_conv->update_channel)(this_arg_conv->this_arg, funding_txo_conv, update_conv);
3932         return (uint64_t)ret_conv;
3933 }
3934
3935 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Watch_1release_1pending_1monitor_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
3936         LDKWatch* this_arg_conv = (LDKWatch*)(((uint64_t)this_arg) & ~1);
3937         LDKCVec_MonitorEventZ ret_var = (this_arg_conv->release_pending_monitor_events)(this_arg_conv->this_arg);
3938         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
3939         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
3940         for (size_t o = 0; o < ret_var.datalen; o++) {
3941                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
3942                 *ret_conv_14_copy = MonitorEvent_clone(&ret_var.data[o]);
3943                 uint64_t ret_conv_14_ref = (uint64_t)ret_conv_14_copy;
3944                 ret_arr_ptr[o] = ret_conv_14_ref;
3945         }
3946         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
3947         FREE(ret_var.data);
3948         return ret_arr;
3949 }
3950
3951 typedef struct LDKBroadcasterInterface_JCalls {
3952         atomic_size_t refcnt;
3953         JavaVM *vm;
3954         jweak o;
3955         jmethodID broadcast_transaction_meth;
3956 } LDKBroadcasterInterface_JCalls;
3957 static void LDKBroadcasterInterface_JCalls_free(void* this_arg) {
3958         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
3959         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3960                 JNIEnv *env;
3961                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3962                 if (get_jenv_res == JNI_EDETACHED) {
3963                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3964                 } else {
3965                         DO_ASSERT(get_jenv_res == JNI_OK);
3966                 }
3967                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
3968                 if (get_jenv_res == JNI_EDETACHED) {
3969                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3970                 }
3971                 FREE(j_calls);
3972         }
3973 }
3974 void broadcast_transaction_LDKBroadcasterInterface_jcall(const void* this_arg, LDKTransaction tx) {
3975         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
3976         JNIEnv *env;
3977         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3978         if (get_jenv_res == JNI_EDETACHED) {
3979                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3980         } else {
3981                 DO_ASSERT(get_jenv_res == JNI_OK);
3982         }
3983         LDKTransaction tx_var = tx;
3984         int8_tArray tx_arr = (*env)->NewByteArray(env, tx_var.datalen);
3985         (*env)->SetByteArrayRegion(env, tx_arr, 0, tx_var.datalen, tx_var.data);
3986         Transaction_free(tx_var);
3987         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3988         CHECK(obj != NULL);
3989         (*env)->CallVoidMethod(env, obj, j_calls->broadcast_transaction_meth, tx_arr);
3990         if ((*env)->ExceptionCheck(env)) {
3991                 (*env)->ExceptionDescribe(env);
3992                 (*env)->FatalError(env, "A call to broadcast_transaction in LDKBroadcasterInterface from rust threw an exception.");
3993         }
3994         if (get_jenv_res == JNI_EDETACHED) {
3995                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3996         }
3997 }
3998 static void LDKBroadcasterInterface_JCalls_cloned(LDKBroadcasterInterface* new_obj) {
3999         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) new_obj->this_arg;
4000         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4001 }
4002 static inline LDKBroadcasterInterface LDKBroadcasterInterface_init (JNIEnv *env, jclass clz, jobject o) {
4003         jclass c = (*env)->GetObjectClass(env, o);
4004         CHECK(c != NULL);
4005         LDKBroadcasterInterface_JCalls *calls = MALLOC(sizeof(LDKBroadcasterInterface_JCalls), "LDKBroadcasterInterface_JCalls");
4006         atomic_init(&calls->refcnt, 1);
4007         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
4008         calls->o = (*env)->NewWeakGlobalRef(env, o);
4009         calls->broadcast_transaction_meth = (*env)->GetMethodID(env, c, "broadcast_transaction", "([B)V");
4010         CHECK(calls->broadcast_transaction_meth != NULL);
4011
4012         LDKBroadcasterInterface ret = {
4013                 .this_arg = (void*) calls,
4014                 .broadcast_transaction = broadcast_transaction_LDKBroadcasterInterface_jcall,
4015                 .free = LDKBroadcasterInterface_JCalls_free,
4016         };
4017         return ret;
4018 }
4019 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKBroadcasterInterface_1new(JNIEnv *env, jclass clz, jobject o) {
4020         LDKBroadcasterInterface *res_ptr = MALLOC(sizeof(LDKBroadcasterInterface), "LDKBroadcasterInterface");
4021         *res_ptr = LDKBroadcasterInterface_init(env, clz, o);
4022         return (uint64_t)res_ptr;
4023 }
4024 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BroadcasterInterface_1broadcast_1transaction(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray tx) {
4025         LDKBroadcasterInterface* this_arg_conv = (LDKBroadcasterInterface*)(((uint64_t)this_arg) & ~1);
4026         LDKTransaction tx_ref;
4027         tx_ref.datalen = (*env)->GetArrayLength(env, tx);
4028         tx_ref.data = MALLOC(tx_ref.datalen, "LDKTransaction Bytes");
4029         (*env)->GetByteArrayRegion(env, tx, 0, tx_ref.datalen, tx_ref.data);
4030         tx_ref.data_is_owned = true;
4031         (this_arg_conv->broadcast_transaction)(this_arg_conv->this_arg, tx_ref);
4032 }
4033
4034 typedef struct LDKKeysInterface_JCalls {
4035         atomic_size_t refcnt;
4036         JavaVM *vm;
4037         jweak o;
4038         jmethodID get_node_secret_meth;
4039         jmethodID get_destination_script_meth;
4040         jmethodID get_shutdown_scriptpubkey_meth;
4041         jmethodID get_channel_signer_meth;
4042         jmethodID get_secure_random_bytes_meth;
4043         jmethodID read_chan_signer_meth;
4044         jmethodID sign_invoice_meth;
4045 } LDKKeysInterface_JCalls;
4046 static void LDKKeysInterface_JCalls_free(void* this_arg) {
4047         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4048         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4049                 JNIEnv *env;
4050                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4051                 if (get_jenv_res == JNI_EDETACHED) {
4052                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4053                 } else {
4054                         DO_ASSERT(get_jenv_res == JNI_OK);
4055                 }
4056                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
4057                 if (get_jenv_res == JNI_EDETACHED) {
4058                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4059                 }
4060                 FREE(j_calls);
4061         }
4062 }
4063 LDKSecretKey get_node_secret_LDKKeysInterface_jcall(const void* this_arg) {
4064         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4065         JNIEnv *env;
4066         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4067         if (get_jenv_res == JNI_EDETACHED) {
4068                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4069         } else {
4070                 DO_ASSERT(get_jenv_res == JNI_OK);
4071         }
4072         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4073         CHECK(obj != NULL);
4074         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_node_secret_meth);
4075         if ((*env)->ExceptionCheck(env)) {
4076                 (*env)->ExceptionDescribe(env);
4077                 (*env)->FatalError(env, "A call to get_node_secret in LDKKeysInterface from rust threw an exception.");
4078         }
4079         LDKSecretKey ret_ref;
4080         CHECK((*env)->GetArrayLength(env, ret) == 32);
4081         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.bytes);
4082         if (get_jenv_res == JNI_EDETACHED) {
4083                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4084         }
4085         return ret_ref;
4086 }
4087 LDKCVec_u8Z get_destination_script_LDKKeysInterface_jcall(const void* this_arg) {
4088         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4089         JNIEnv *env;
4090         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4091         if (get_jenv_res == JNI_EDETACHED) {
4092                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4093         } else {
4094                 DO_ASSERT(get_jenv_res == JNI_OK);
4095         }
4096         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4097         CHECK(obj != NULL);
4098         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_destination_script_meth);
4099         if ((*env)->ExceptionCheck(env)) {
4100                 (*env)->ExceptionDescribe(env);
4101                 (*env)->FatalError(env, "A call to get_destination_script in LDKKeysInterface from rust threw an exception.");
4102         }
4103         LDKCVec_u8Z ret_ref;
4104         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
4105         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
4106         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
4107         if (get_jenv_res == JNI_EDETACHED) {
4108                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4109         }
4110         return ret_ref;
4111 }
4112 LDKShutdownScript get_shutdown_scriptpubkey_LDKKeysInterface_jcall(const void* this_arg) {
4113         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4114         JNIEnv *env;
4115         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4116         if (get_jenv_res == JNI_EDETACHED) {
4117                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4118         } else {
4119                 DO_ASSERT(get_jenv_res == JNI_OK);
4120         }
4121         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4122         CHECK(obj != NULL);
4123         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_shutdown_scriptpubkey_meth);
4124         if ((*env)->ExceptionCheck(env)) {
4125                 (*env)->ExceptionDescribe(env);
4126                 (*env)->FatalError(env, "A call to get_shutdown_scriptpubkey in LDKKeysInterface from rust threw an exception.");
4127         }
4128         LDKShutdownScript ret_conv;
4129         ret_conv.inner = (void*)(ret & (~1));
4130         ret_conv.is_owned = (ret & 1) || (ret == 0);
4131         ret_conv = ShutdownScript_clone(&ret_conv);
4132         if (get_jenv_res == JNI_EDETACHED) {
4133                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4134         }
4135         return ret_conv;
4136 }
4137 LDKSign get_channel_signer_LDKKeysInterface_jcall(const void* this_arg, bool inbound, uint64_t channel_value_satoshis) {
4138         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4139         JNIEnv *env;
4140         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4141         if (get_jenv_res == JNI_EDETACHED) {
4142                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4143         } else {
4144                 DO_ASSERT(get_jenv_res == JNI_OK);
4145         }
4146         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4147         CHECK(obj != NULL);
4148         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_channel_signer_meth, inbound, channel_value_satoshis);
4149         if ((*env)->ExceptionCheck(env)) {
4150                 (*env)->ExceptionDescribe(env);
4151                 (*env)->FatalError(env, "A call to get_channel_signer in LDKKeysInterface from rust threw an exception.");
4152         }
4153         LDKSign ret_conv = *(LDKSign*)(((uint64_t)ret) & ~1);
4154         ret_conv = Sign_clone(&ret_conv);
4155         if (get_jenv_res == JNI_EDETACHED) {
4156                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4157         }
4158         return ret_conv;
4159 }
4160 LDKThirtyTwoBytes get_secure_random_bytes_LDKKeysInterface_jcall(const void* this_arg) {
4161         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4162         JNIEnv *env;
4163         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4164         if (get_jenv_res == JNI_EDETACHED) {
4165                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4166         } else {
4167                 DO_ASSERT(get_jenv_res == JNI_OK);
4168         }
4169         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4170         CHECK(obj != NULL);
4171         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_secure_random_bytes_meth);
4172         if ((*env)->ExceptionCheck(env)) {
4173                 (*env)->ExceptionDescribe(env);
4174                 (*env)->FatalError(env, "A call to get_secure_random_bytes in LDKKeysInterface from rust threw an exception.");
4175         }
4176         LDKThirtyTwoBytes ret_ref;
4177         CHECK((*env)->GetArrayLength(env, ret) == 32);
4178         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
4179         if (get_jenv_res == JNI_EDETACHED) {
4180                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4181         }
4182         return ret_ref;
4183 }
4184 LDKCResult_SignDecodeErrorZ read_chan_signer_LDKKeysInterface_jcall(const void* this_arg, LDKu8slice reader) {
4185         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4186         JNIEnv *env;
4187         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4188         if (get_jenv_res == JNI_EDETACHED) {
4189                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4190         } else {
4191                 DO_ASSERT(get_jenv_res == JNI_OK);
4192         }
4193         LDKu8slice reader_var = reader;
4194         int8_tArray reader_arr = (*env)->NewByteArray(env, reader_var.datalen);
4195         (*env)->SetByteArrayRegion(env, reader_arr, 0, reader_var.datalen, reader_var.data);
4196         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4197         CHECK(obj != NULL);
4198         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->read_chan_signer_meth, reader_arr);
4199         if ((*env)->ExceptionCheck(env)) {
4200                 (*env)->ExceptionDescribe(env);
4201                 (*env)->FatalError(env, "A call to read_chan_signer in LDKKeysInterface from rust threw an exception.");
4202         }
4203         LDKCResult_SignDecodeErrorZ ret_conv = *(LDKCResult_SignDecodeErrorZ*)(((uint64_t)ret) & ~1);
4204         ret_conv = CResult_SignDecodeErrorZ_clone((LDKCResult_SignDecodeErrorZ*)(((uint64_t)ret) & ~1));
4205         if (get_jenv_res == JNI_EDETACHED) {
4206                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4207         }
4208         return ret_conv;
4209 }
4210 LDKCResult_RecoverableSignatureNoneZ sign_invoice_LDKKeysInterface_jcall(const void* this_arg, LDKCVec_u8Z invoice_preimage) {
4211         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4212         JNIEnv *env;
4213         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4214         if (get_jenv_res == JNI_EDETACHED) {
4215                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4216         } else {
4217                 DO_ASSERT(get_jenv_res == JNI_OK);
4218         }
4219         LDKCVec_u8Z invoice_preimage_var = invoice_preimage;
4220         int8_tArray invoice_preimage_arr = (*env)->NewByteArray(env, invoice_preimage_var.datalen);
4221         (*env)->SetByteArrayRegion(env, invoice_preimage_arr, 0, invoice_preimage_var.datalen, invoice_preimage_var.data);
4222         CVec_u8Z_free(invoice_preimage_var);
4223         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4224         CHECK(obj != NULL);
4225         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_invoice_meth, invoice_preimage_arr);
4226         if ((*env)->ExceptionCheck(env)) {
4227                 (*env)->ExceptionDescribe(env);
4228                 (*env)->FatalError(env, "A call to sign_invoice in LDKKeysInterface from rust threw an exception.");
4229         }
4230         LDKCResult_RecoverableSignatureNoneZ ret_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(((uint64_t)ret) & ~1);
4231         ret_conv = CResult_RecoverableSignatureNoneZ_clone((LDKCResult_RecoverableSignatureNoneZ*)(((uint64_t)ret) & ~1));
4232         if (get_jenv_res == JNI_EDETACHED) {
4233                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4234         }
4235         return ret_conv;
4236 }
4237 static void LDKKeysInterface_JCalls_cloned(LDKKeysInterface* new_obj) {
4238         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) new_obj->this_arg;
4239         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4240 }
4241 static inline LDKKeysInterface LDKKeysInterface_init (JNIEnv *env, jclass clz, jobject o) {
4242         jclass c = (*env)->GetObjectClass(env, o);
4243         CHECK(c != NULL);
4244         LDKKeysInterface_JCalls *calls = MALLOC(sizeof(LDKKeysInterface_JCalls), "LDKKeysInterface_JCalls");
4245         atomic_init(&calls->refcnt, 1);
4246         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
4247         calls->o = (*env)->NewWeakGlobalRef(env, o);
4248         calls->get_node_secret_meth = (*env)->GetMethodID(env, c, "get_node_secret", "()[B");
4249         CHECK(calls->get_node_secret_meth != NULL);
4250         calls->get_destination_script_meth = (*env)->GetMethodID(env, c, "get_destination_script", "()[B");
4251         CHECK(calls->get_destination_script_meth != NULL);
4252         calls->get_shutdown_scriptpubkey_meth = (*env)->GetMethodID(env, c, "get_shutdown_scriptpubkey", "()J");
4253         CHECK(calls->get_shutdown_scriptpubkey_meth != NULL);
4254         calls->get_channel_signer_meth = (*env)->GetMethodID(env, c, "get_channel_signer", "(ZJ)J");
4255         CHECK(calls->get_channel_signer_meth != NULL);
4256         calls->get_secure_random_bytes_meth = (*env)->GetMethodID(env, c, "get_secure_random_bytes", "()[B");
4257         CHECK(calls->get_secure_random_bytes_meth != NULL);
4258         calls->read_chan_signer_meth = (*env)->GetMethodID(env, c, "read_chan_signer", "([B)J");
4259         CHECK(calls->read_chan_signer_meth != NULL);
4260         calls->sign_invoice_meth = (*env)->GetMethodID(env, c, "sign_invoice", "([B)J");
4261         CHECK(calls->sign_invoice_meth != NULL);
4262
4263         LDKKeysInterface ret = {
4264                 .this_arg = (void*) calls,
4265                 .get_node_secret = get_node_secret_LDKKeysInterface_jcall,
4266                 .get_destination_script = get_destination_script_LDKKeysInterface_jcall,
4267                 .get_shutdown_scriptpubkey = get_shutdown_scriptpubkey_LDKKeysInterface_jcall,
4268                 .get_channel_signer = get_channel_signer_LDKKeysInterface_jcall,
4269                 .get_secure_random_bytes = get_secure_random_bytes_LDKKeysInterface_jcall,
4270                 .read_chan_signer = read_chan_signer_LDKKeysInterface_jcall,
4271                 .sign_invoice = sign_invoice_LDKKeysInterface_jcall,
4272                 .free = LDKKeysInterface_JCalls_free,
4273         };
4274         return ret;
4275 }
4276 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKKeysInterface_1new(JNIEnv *env, jclass clz, jobject o) {
4277         LDKKeysInterface *res_ptr = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
4278         *res_ptr = LDKKeysInterface_init(env, clz, o);
4279         return (uint64_t)res_ptr;
4280 }
4281 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1node_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
4282         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
4283         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
4284         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->get_node_secret)(this_arg_conv->this_arg).bytes);
4285         return ret_arr;
4286 }
4287
4288 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1destination_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
4289         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
4290         LDKCVec_u8Z ret_var = (this_arg_conv->get_destination_script)(this_arg_conv->this_arg);
4291         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
4292         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
4293         CVec_u8Z_free(ret_var);
4294         return ret_arr;
4295 }
4296
4297 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1shutdown_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_arg) {
4298         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
4299         LDKShutdownScript ret_var = (this_arg_conv->get_shutdown_scriptpubkey)(this_arg_conv->this_arg);
4300         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4301         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4302         uint64_t ret_ref = (uint64_t)ret_var.inner;
4303         if (ret_var.is_owned) {
4304                 ret_ref |= 1;
4305         }
4306         return ret_ref;
4307 }
4308
4309 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) {
4310         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
4311         LDKSign* ret_ret =MALLOC(sizeof(LDKSign), "LDKSign");
4312         *ret_ret = (this_arg_conv->get_channel_signer)(this_arg_conv->this_arg, inbound, channel_value_satoshis);
4313         return (uint64_t)ret_ret;
4314 }
4315
4316 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1secure_1random_1bytes(JNIEnv *env, jclass clz, int64_t this_arg) {
4317         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
4318         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
4319         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->get_secure_random_bytes)(this_arg_conv->this_arg).data);
4320         return ret_arr;
4321 }
4322
4323 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1read_1chan_1signer(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray reader) {
4324         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
4325         LDKu8slice reader_ref;
4326         reader_ref.datalen = (*env)->GetArrayLength(env, reader);
4327         reader_ref.data = (*env)->GetByteArrayElements (env, reader, NULL);
4328         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
4329         *ret_conv = (this_arg_conv->read_chan_signer)(this_arg_conv->this_arg, reader_ref);
4330         (*env)->ReleaseByteArrayElements(env, reader, (int8_t*)reader_ref.data, 0);
4331         return (uint64_t)ret_conv;
4332 }
4333
4334 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1sign_1invoice(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray invoice_preimage) {
4335         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
4336         LDKCVec_u8Z invoice_preimage_ref;
4337         invoice_preimage_ref.datalen = (*env)->GetArrayLength(env, invoice_preimage);
4338         invoice_preimage_ref.data = MALLOC(invoice_preimage_ref.datalen, "LDKCVec_u8Z Bytes");
4339         (*env)->GetByteArrayRegion(env, invoice_preimage, 0, invoice_preimage_ref.datalen, invoice_preimage_ref.data);
4340         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
4341         *ret_conv = (this_arg_conv->sign_invoice)(this_arg_conv->this_arg, invoice_preimage_ref);
4342         return (uint64_t)ret_conv;
4343 }
4344
4345 typedef struct LDKFeeEstimator_JCalls {
4346         atomic_size_t refcnt;
4347         JavaVM *vm;
4348         jweak o;
4349         jmethodID get_est_sat_per_1000_weight_meth;
4350 } LDKFeeEstimator_JCalls;
4351 static void LDKFeeEstimator_JCalls_free(void* this_arg) {
4352         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
4353         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
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                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
4362                 if (get_jenv_res == JNI_EDETACHED) {
4363                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4364                 }
4365                 FREE(j_calls);
4366         }
4367 }
4368 uint32_t get_est_sat_per_1000_weight_LDKFeeEstimator_jcall(const void* this_arg, LDKConfirmationTarget confirmation_target) {
4369         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
4370         JNIEnv *env;
4371         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4372         if (get_jenv_res == JNI_EDETACHED) {
4373                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4374         } else {
4375                 DO_ASSERT(get_jenv_res == JNI_OK);
4376         }
4377         jclass confirmation_target_conv = LDKConfirmationTarget_to_java(env, confirmation_target);
4378         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4379         CHECK(obj != NULL);
4380         int32_t ret = (*env)->CallIntMethod(env, obj, j_calls->get_est_sat_per_1000_weight_meth, confirmation_target_conv);
4381         if ((*env)->ExceptionCheck(env)) {
4382                 (*env)->ExceptionDescribe(env);
4383                 (*env)->FatalError(env, "A call to get_est_sat_per_1000_weight in LDKFeeEstimator from rust threw an exception.");
4384         }
4385         if (get_jenv_res == JNI_EDETACHED) {
4386                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4387         }
4388         return ret;
4389 }
4390 static void LDKFeeEstimator_JCalls_cloned(LDKFeeEstimator* new_obj) {
4391         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) new_obj->this_arg;
4392         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4393 }
4394 static inline LDKFeeEstimator LDKFeeEstimator_init (JNIEnv *env, jclass clz, jobject o) {
4395         jclass c = (*env)->GetObjectClass(env, o);
4396         CHECK(c != NULL);
4397         LDKFeeEstimator_JCalls *calls = MALLOC(sizeof(LDKFeeEstimator_JCalls), "LDKFeeEstimator_JCalls");
4398         atomic_init(&calls->refcnt, 1);
4399         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
4400         calls->o = (*env)->NewWeakGlobalRef(env, o);
4401         calls->get_est_sat_per_1000_weight_meth = (*env)->GetMethodID(env, c, "get_est_sat_per_1000_weight", "(Lorg/ldk/enums/ConfirmationTarget;)I");
4402         CHECK(calls->get_est_sat_per_1000_weight_meth != NULL);
4403
4404         LDKFeeEstimator ret = {
4405                 .this_arg = (void*) calls,
4406                 .get_est_sat_per_1000_weight = get_est_sat_per_1000_weight_LDKFeeEstimator_jcall,
4407                 .free = LDKFeeEstimator_JCalls_free,
4408         };
4409         return ret;
4410 }
4411 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKFeeEstimator_1new(JNIEnv *env, jclass clz, jobject o) {
4412         LDKFeeEstimator *res_ptr = MALLOC(sizeof(LDKFeeEstimator), "LDKFeeEstimator");
4413         *res_ptr = LDKFeeEstimator_init(env, clz, o);
4414         return (uint64_t)res_ptr;
4415 }
4416 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) {
4417         LDKFeeEstimator* this_arg_conv = (LDKFeeEstimator*)(((uint64_t)this_arg) & ~1);
4418         LDKConfirmationTarget confirmation_target_conv = LDKConfirmationTarget_from_java(env, confirmation_target);
4419         int32_t ret_val = (this_arg_conv->get_est_sat_per_1000_weight)(this_arg_conv->this_arg, confirmation_target_conv);
4420         return ret_val;
4421 }
4422
4423 typedef struct LDKLogger_JCalls {
4424         atomic_size_t refcnt;
4425         JavaVM *vm;
4426         jweak o;
4427         jmethodID log_meth;
4428 } LDKLogger_JCalls;
4429 static void LDKLogger_JCalls_free(void* this_arg) {
4430         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
4431         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4432                 JNIEnv *env;
4433                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4434                 if (get_jenv_res == JNI_EDETACHED) {
4435                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4436                 } else {
4437                         DO_ASSERT(get_jenv_res == JNI_OK);
4438                 }
4439                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
4440                 if (get_jenv_res == JNI_EDETACHED) {
4441                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4442                 }
4443                 FREE(j_calls);
4444         }
4445 }
4446 void log_LDKLogger_jcall(const void* this_arg, const char* record) {
4447         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
4448         JNIEnv *env;
4449         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4450         if (get_jenv_res == JNI_EDETACHED) {
4451                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4452         } else {
4453                 DO_ASSERT(get_jenv_res == JNI_OK);
4454         }
4455         const char* record_str = record;
4456         jstring record_conv = str_ref_to_java(env, record_str, strlen(record_str));
4457         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4458         CHECK(obj != NULL);
4459         (*env)->CallVoidMethod(env, obj, j_calls->log_meth, record_conv);
4460         if ((*env)->ExceptionCheck(env)) {
4461                 (*env)->ExceptionDescribe(env);
4462                 (*env)->FatalError(env, "A call to log in LDKLogger from rust threw an exception.");
4463         }
4464         if (get_jenv_res == JNI_EDETACHED) {
4465                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4466         }
4467 }
4468 static void LDKLogger_JCalls_cloned(LDKLogger* new_obj) {
4469         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) new_obj->this_arg;
4470         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4471 }
4472 static inline LDKLogger LDKLogger_init (JNIEnv *env, jclass clz, jobject o) {
4473         jclass c = (*env)->GetObjectClass(env, o);
4474         CHECK(c != NULL);
4475         LDKLogger_JCalls *calls = MALLOC(sizeof(LDKLogger_JCalls), "LDKLogger_JCalls");
4476         atomic_init(&calls->refcnt, 1);
4477         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
4478         calls->o = (*env)->NewWeakGlobalRef(env, o);
4479         calls->log_meth = (*env)->GetMethodID(env, c, "log", "(Ljava/lang/String;)V");
4480         CHECK(calls->log_meth != NULL);
4481
4482         LDKLogger ret = {
4483                 .this_arg = (void*) calls,
4484                 .log = log_LDKLogger_jcall,
4485                 .free = LDKLogger_JCalls_free,
4486         };
4487         return ret;
4488 }
4489 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKLogger_1new(JNIEnv *env, jclass clz, jobject o) {
4490         LDKLogger *res_ptr = MALLOC(sizeof(LDKLogger), "LDKLogger");
4491         *res_ptr = LDKLogger_init(env, clz, o);
4492         return (uint64_t)res_ptr;
4493 }
4494 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1BlockHashChannelManagerZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
4495         LDKC2Tuple_BlockHashChannelManagerZ* ret = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
4496         LDKThirtyTwoBytes a_ref;
4497         CHECK((*env)->GetArrayLength(env, a) == 32);
4498         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
4499         ret->a = a_ref;
4500         LDKChannelManager b_conv;
4501         b_conv.inner = (void*)(b & (~1));
4502         b_conv.is_owned = (b & 1) || (b == 0);
4503         // Warning: we need a move here but no clone is available for LDKChannelManager
4504         ret->b = b_conv;
4505         return (uint64_t)ret;
4506 }
4507 static inline struct LDKThirtyTwoBytes C2Tuple_BlockHashChannelManagerZ_get_a(LDKC2Tuple_BlockHashChannelManagerZ *NONNULL_PTR tuple){
4508         return ThirtyTwoBytes_clone(&tuple->a);
4509 }
4510 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1get_1a(JNIEnv *env, jclass clz, int64_t tuple) {
4511         LDKC2Tuple_BlockHashChannelManagerZ* tuple_conv = (LDKC2Tuple_BlockHashChannelManagerZ*)(tuple & ~1);
4512         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
4513         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_BlockHashChannelManagerZ_get_a(tuple_conv).data);
4514         return ret_arr;
4515 }
4516
4517 static inline struct LDKChannelManager *C2Tuple_BlockHashChannelManagerZ_get_b(LDKC2Tuple_BlockHashChannelManagerZ *NONNULL_PTR tuple){
4518         return &tuple->b;
4519 }
4520 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1get_1b(JNIEnv *env, jclass clz, int64_t tuple) {
4521         LDKC2Tuple_BlockHashChannelManagerZ* tuple_conv = (LDKC2Tuple_BlockHashChannelManagerZ*)(tuple & ~1);
4522         LDKChannelManager ret_var = *C2Tuple_BlockHashChannelManagerZ_get_b(tuple_conv);
4523         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4524         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4525         uint64_t ret_ref = (uint64_t)ret_var.inner & ~1;
4526         return ret_ref;
4527 }
4528
4529 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4530         return ((LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)arg)->result_ok;
4531 }
4532 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4533         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(arg & ~1);
4534         CHECK(val->result_ok);
4535         LDKC2Tuple_BlockHashChannelManagerZ* res_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
4536         *res_conv = (*val->contents.result);
4537         // Warning: we really need to clone here, but no clone is available for LDKC2Tuple_BlockHashChannelManagerZ
4538         return ((uint64_t)res_conv) | 1;
4539 }
4540 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4541         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(arg & ~1);
4542         CHECK(!val->result_ok);
4543         LDKDecodeError err_var = (*val->contents.err);
4544         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4545         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4546         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4547         return err_ref;
4548 }
4549 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelConfigDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4550         return ((LDKCResult_ChannelConfigDecodeErrorZ*)arg)->result_ok;
4551 }
4552 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelConfigDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4553         LDKCResult_ChannelConfigDecodeErrorZ *val = (LDKCResult_ChannelConfigDecodeErrorZ*)(arg & ~1);
4554         CHECK(val->result_ok);
4555         LDKChannelConfig res_var = (*val->contents.result);
4556         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4557         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4558         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4559         return res_ref;
4560 }
4561 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelConfigDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4562         LDKCResult_ChannelConfigDecodeErrorZ *val = (LDKCResult_ChannelConfigDecodeErrorZ*)(arg & ~1);
4563         CHECK(!val->result_ok);
4564         LDKDecodeError err_var = (*val->contents.err);
4565         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4566         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4567         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4568         return err_ref;
4569 }
4570 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OutPointDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4571         return ((LDKCResult_OutPointDecodeErrorZ*)arg)->result_ok;
4572 }
4573 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OutPointDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4574         LDKCResult_OutPointDecodeErrorZ *val = (LDKCResult_OutPointDecodeErrorZ*)(arg & ~1);
4575         CHECK(val->result_ok);
4576         LDKOutPoint res_var = (*val->contents.result);
4577         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4578         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4579         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4580         return res_ref;
4581 }
4582 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OutPointDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4583         LDKCResult_OutPointDecodeErrorZ *val = (LDKCResult_OutPointDecodeErrorZ*)(arg & ~1);
4584         CHECK(!val->result_ok);
4585         LDKDecodeError err_var = (*val->contents.err);
4586         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4587         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4588         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4589         return err_ref;
4590 }
4591 typedef struct LDKType_JCalls {
4592         atomic_size_t refcnt;
4593         JavaVM *vm;
4594         jweak o;
4595         jmethodID type_id_meth;
4596         jmethodID debug_str_meth;
4597         jmethodID write_meth;
4598 } LDKType_JCalls;
4599 static void LDKType_JCalls_free(void* this_arg) {
4600         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
4601         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4602                 JNIEnv *env;
4603                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4604                 if (get_jenv_res == JNI_EDETACHED) {
4605                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4606                 } else {
4607                         DO_ASSERT(get_jenv_res == JNI_OK);
4608                 }
4609                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
4610                 if (get_jenv_res == JNI_EDETACHED) {
4611                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4612                 }
4613                 FREE(j_calls);
4614         }
4615 }
4616 uint16_t type_id_LDKType_jcall(const void* this_arg) {
4617         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
4618         JNIEnv *env;
4619         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4620         if (get_jenv_res == JNI_EDETACHED) {
4621                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4622         } else {
4623                 DO_ASSERT(get_jenv_res == JNI_OK);
4624         }
4625         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4626         CHECK(obj != NULL);
4627         int16_t ret = (*env)->CallShortMethod(env, obj, j_calls->type_id_meth);
4628         if ((*env)->ExceptionCheck(env)) {
4629                 (*env)->ExceptionDescribe(env);
4630                 (*env)->FatalError(env, "A call to type_id in LDKType from rust threw an exception.");
4631         }
4632         if (get_jenv_res == JNI_EDETACHED) {
4633                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4634         }
4635         return ret;
4636 }
4637 LDKStr debug_str_LDKType_jcall(const void* this_arg) {
4638         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
4639         JNIEnv *env;
4640         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4641         if (get_jenv_res == JNI_EDETACHED) {
4642                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4643         } else {
4644                 DO_ASSERT(get_jenv_res == JNI_OK);
4645         }
4646         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4647         CHECK(obj != NULL);
4648         jstring ret = (*env)->CallObjectMethod(env, obj, j_calls->debug_str_meth);
4649         if ((*env)->ExceptionCheck(env)) {
4650                 (*env)->ExceptionDescribe(env);
4651                 (*env)->FatalError(env, "A call to debug_str in LDKType from rust threw an exception.");
4652         }
4653         LDKStr ret_conv = java_to_owned_str(env, ret);
4654         if (get_jenv_res == JNI_EDETACHED) {
4655                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4656         }
4657         return ret_conv;
4658 }
4659 LDKCVec_u8Z write_LDKType_jcall(const void* this_arg) {
4660         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
4661         JNIEnv *env;
4662         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4663         if (get_jenv_res == JNI_EDETACHED) {
4664                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4665         } else {
4666                 DO_ASSERT(get_jenv_res == JNI_OK);
4667         }
4668         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4669         CHECK(obj != NULL);
4670         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->write_meth);
4671         if ((*env)->ExceptionCheck(env)) {
4672                 (*env)->ExceptionDescribe(env);
4673                 (*env)->FatalError(env, "A call to write in LDKType from rust threw an exception.");
4674         }
4675         LDKCVec_u8Z ret_ref;
4676         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
4677         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
4678         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
4679         if (get_jenv_res == JNI_EDETACHED) {
4680                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4681         }
4682         return ret_ref;
4683 }
4684 static void LDKType_JCalls_cloned(LDKType* new_obj) {
4685         LDKType_JCalls *j_calls = (LDKType_JCalls*) new_obj->this_arg;
4686         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4687 }
4688 static inline LDKType LDKType_init (JNIEnv *env, jclass clz, jobject o) {
4689         jclass c = (*env)->GetObjectClass(env, o);
4690         CHECK(c != NULL);
4691         LDKType_JCalls *calls = MALLOC(sizeof(LDKType_JCalls), "LDKType_JCalls");
4692         atomic_init(&calls->refcnt, 1);
4693         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
4694         calls->o = (*env)->NewWeakGlobalRef(env, o);
4695         calls->type_id_meth = (*env)->GetMethodID(env, c, "type_id", "()S");
4696         CHECK(calls->type_id_meth != NULL);
4697         calls->debug_str_meth = (*env)->GetMethodID(env, c, "debug_str", "()Ljava/lang/String;");
4698         CHECK(calls->debug_str_meth != NULL);
4699         calls->write_meth = (*env)->GetMethodID(env, c, "write", "()[B");
4700         CHECK(calls->write_meth != NULL);
4701
4702         LDKType ret = {
4703                 .this_arg = (void*) calls,
4704                 .type_id = type_id_LDKType_jcall,
4705                 .debug_str = debug_str_LDKType_jcall,
4706                 .write = write_LDKType_jcall,
4707                 .cloned = LDKType_JCalls_cloned,
4708                 .free = LDKType_JCalls_free,
4709         };
4710         return ret;
4711 }
4712 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKType_1new(JNIEnv *env, jclass clz, jobject o) {
4713         LDKType *res_ptr = MALLOC(sizeof(LDKType), "LDKType");
4714         *res_ptr = LDKType_init(env, clz, o);
4715         return (uint64_t)res_ptr;
4716 }
4717 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Type_1type_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
4718         LDKType* this_arg_conv = (LDKType*)(((uint64_t)this_arg) & ~1);
4719         int16_t ret_val = (this_arg_conv->type_id)(this_arg_conv->this_arg);
4720         return ret_val;
4721 }
4722
4723 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Type_1debug_1str(JNIEnv *env, jclass clz, int64_t this_arg) {
4724         LDKType* this_arg_conv = (LDKType*)(((uint64_t)this_arg) & ~1);
4725         LDKStr ret_str = (this_arg_conv->debug_str)(this_arg_conv->this_arg);
4726         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
4727         Str_free(ret_str);
4728         return ret_conv;
4729 }
4730
4731 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Type_1write(JNIEnv *env, jclass clz, int64_t this_arg) {
4732         LDKType* this_arg_conv = (LDKType*)(((uint64_t)this_arg) & ~1);
4733         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
4734         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
4735         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
4736         CVec_u8Z_free(ret_var);
4737         return ret_arr;
4738 }
4739
4740 static jclass LDKCOption_TypeZ_Some_class = NULL;
4741 static jmethodID LDKCOption_TypeZ_Some_meth = NULL;
4742 static jclass LDKCOption_TypeZ_None_class = NULL;
4743 static jmethodID LDKCOption_TypeZ_None_meth = NULL;
4744 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1TypeZ_init (JNIEnv *env, jclass clz) {
4745         LDKCOption_TypeZ_Some_class =
4746                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_TypeZ$Some;"));
4747         CHECK(LDKCOption_TypeZ_Some_class != NULL);
4748         LDKCOption_TypeZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_TypeZ_Some_class, "<init>", "(J)V");
4749         CHECK(LDKCOption_TypeZ_Some_meth != NULL);
4750         LDKCOption_TypeZ_None_class =
4751                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_TypeZ$None;"));
4752         CHECK(LDKCOption_TypeZ_None_class != NULL);
4753         LDKCOption_TypeZ_None_meth = (*env)->GetMethodID(env, LDKCOption_TypeZ_None_class, "<init>", "()V");
4754         CHECK(LDKCOption_TypeZ_None_meth != NULL);
4755 }
4756 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1TypeZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
4757         LDKCOption_TypeZ *obj = (LDKCOption_TypeZ*)(ptr & ~1);
4758         switch(obj->tag) {
4759                 case LDKCOption_TypeZ_Some: {
4760                         LDKType* some_ret =MALLOC(sizeof(LDKType), "LDKType");
4761                         *some_ret = Type_clone(&obj->some);
4762                         return (*env)->NewObject(env, LDKCOption_TypeZ_Some_class, LDKCOption_TypeZ_Some_meth, (uint64_t)some_ret);
4763                 }
4764                 case LDKCOption_TypeZ_None: {
4765                         return (*env)->NewObject(env, LDKCOption_TypeZ_None_class, LDKCOption_TypeZ_None_meth);
4766                 }
4767                 default: abort();
4768         }
4769 }
4770 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1COption_1TypeZDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4771         return ((LDKCResult_COption_TypeZDecodeErrorZ*)arg)->result_ok;
4772 }
4773 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1COption_1TypeZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4774         LDKCResult_COption_TypeZDecodeErrorZ *val = (LDKCResult_COption_TypeZDecodeErrorZ*)(arg & ~1);
4775         CHECK(val->result_ok);
4776         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
4777         return res_ref;
4778 }
4779 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1COption_1TypeZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4780         LDKCResult_COption_TypeZDecodeErrorZ *val = (LDKCResult_COption_TypeZDecodeErrorZ*)(arg & ~1);
4781         CHECK(!val->result_ok);
4782         LDKDecodeError err_var = (*val->contents.err);
4783         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4784         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4785         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4786         return err_ref;
4787 }
4788 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SiPrefixNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4789         return ((LDKCResult_SiPrefixNoneZ*)arg)->result_ok;
4790 }
4791 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SiPrefixNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4792         LDKCResult_SiPrefixNoneZ *val = (LDKCResult_SiPrefixNoneZ*)(arg & ~1);
4793         CHECK(val->result_ok);
4794         jclass res_conv = LDKSiPrefix_to_java(env, (*val->contents.result));
4795         return res_conv;
4796 }
4797 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SiPrefixNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4798         LDKCResult_SiPrefixNoneZ *val = (LDKCResult_SiPrefixNoneZ*)(arg & ~1);
4799         CHECK(!val->result_ok);
4800         return *val->contents.err;
4801 }
4802 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4803         return ((LDKCResult_InvoiceNoneZ*)arg)->result_ok;
4804 }
4805 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4806         LDKCResult_InvoiceNoneZ *val = (LDKCResult_InvoiceNoneZ*)(arg & ~1);
4807         CHECK(val->result_ok);
4808         LDKInvoice res_var = (*val->contents.result);
4809         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4810         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4811         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4812         return res_ref;
4813 }
4814 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4815         LDKCResult_InvoiceNoneZ *val = (LDKCResult_InvoiceNoneZ*)(arg & ~1);
4816         CHECK(!val->result_ok);
4817         return *val->contents.err;
4818 }
4819 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignedRawInvoiceNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4820         return ((LDKCResult_SignedRawInvoiceNoneZ*)arg)->result_ok;
4821 }
4822 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignedRawInvoiceNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4823         LDKCResult_SignedRawInvoiceNoneZ *val = (LDKCResult_SignedRawInvoiceNoneZ*)(arg & ~1);
4824         CHECK(val->result_ok);
4825         LDKSignedRawInvoice res_var = (*val->contents.result);
4826         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4827         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4828         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4829         return res_ref;
4830 }
4831 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignedRawInvoiceNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4832         LDKCResult_SignedRawInvoiceNoneZ *val = (LDKCResult_SignedRawInvoiceNoneZ*)(arg & ~1);
4833         CHECK(!val->result_ok);
4834         return *val->contents.err;
4835 }
4836 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) {
4837         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
4838         LDKRawInvoice a_conv;
4839         a_conv.inner = (void*)(a & (~1));
4840         a_conv.is_owned = (a & 1) || (a == 0);
4841         a_conv = RawInvoice_clone(&a_conv);
4842         ret->a = a_conv;
4843         LDKThirtyTwoBytes b_ref;
4844         CHECK((*env)->GetArrayLength(env, b) == 32);
4845         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
4846         ret->b = b_ref;
4847         LDKInvoiceSignature c_conv;
4848         c_conv.inner = (void*)(c & (~1));
4849         c_conv.is_owned = (c & 1) || (c == 0);
4850         c_conv = InvoiceSignature_clone(&c_conv);
4851         ret->c = c_conv;
4852         return (uint64_t)ret;
4853 }
4854 static inline struct LDKRawInvoice C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR tuple){
4855         return RawInvoice_clone(&tuple->a);
4856 }
4857 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1a(JNIEnv *env, jclass clz, int64_t tuple) {
4858         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* tuple_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(tuple & ~1);
4859         LDKRawInvoice ret_var = C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(tuple_conv);
4860         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4861         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4862         uint64_t ret_ref = (uint64_t)ret_var.inner;
4863         if (ret_var.is_owned) {
4864                 ret_ref |= 1;
4865         }
4866         return ret_ref;
4867 }
4868
4869 static inline struct LDKThirtyTwoBytes C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR tuple){
4870         return ThirtyTwoBytes_clone(&tuple->b);
4871 }
4872 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1b(JNIEnv *env, jclass clz, int64_t tuple) {
4873         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* tuple_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(tuple & ~1);
4874         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
4875         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(tuple_conv).data);
4876         return ret_arr;
4877 }
4878
4879 static inline struct LDKInvoiceSignature C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR tuple){
4880         return InvoiceSignature_clone(&tuple->c);
4881 }
4882 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1c(JNIEnv *env, jclass clz, int64_t tuple) {
4883         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* tuple_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(tuple & ~1);
4884         LDKInvoiceSignature ret_var = C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(tuple_conv);
4885         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4886         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4887         uint64_t ret_ref = (uint64_t)ret_var.inner;
4888         if (ret_var.is_owned) {
4889                 ret_ref |= 1;
4890         }
4891         return ret_ref;
4892 }
4893
4894 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PayeePubKeyErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4895         return ((LDKCResult_PayeePubKeyErrorZ*)arg)->result_ok;
4896 }
4897 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PayeePubKeyErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4898         LDKCResult_PayeePubKeyErrorZ *val = (LDKCResult_PayeePubKeyErrorZ*)(arg & ~1);
4899         CHECK(val->result_ok);
4900         LDKPayeePubKey res_var = (*val->contents.result);
4901         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4902         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4903         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4904         return res_ref;
4905 }
4906 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PayeePubKeyErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4907         LDKCResult_PayeePubKeyErrorZ *val = (LDKCResult_PayeePubKeyErrorZ*)(arg & ~1);
4908         CHECK(!val->result_ok);
4909         jclass err_conv = LDKSecp256k1Error_to_java(env, (*val->contents.err));
4910         return err_conv;
4911 }
4912 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1PrivateRouteZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
4913         LDKCVec_PrivateRouteZ *ret = MALLOC(sizeof(LDKCVec_PrivateRouteZ), "LDKCVec_PrivateRouteZ");
4914         ret->datalen = (*env)->GetArrayLength(env, elems);
4915         if (ret->datalen == 0) {
4916                 ret->data = NULL;
4917         } else {
4918                 ret->data = MALLOC(sizeof(LDKPrivateRoute) * ret->datalen, "LDKCVec_PrivateRouteZ Data");
4919                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
4920                 for (size_t i = 0; i < ret->datalen; i++) {
4921                         int64_t arr_elem = java_elems[i];
4922                         LDKPrivateRoute arr_elem_conv;
4923                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
4924                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
4925                         arr_elem_conv = PrivateRoute_clone(&arr_elem_conv);
4926                         ret->data[i] = arr_elem_conv;
4927                 }
4928                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
4929         }
4930         return (uint64_t)ret;
4931 }
4932 static inline LDKCVec_PrivateRouteZ CVec_PrivateRouteZ_clone(const LDKCVec_PrivateRouteZ *orig) {
4933         LDKCVec_PrivateRouteZ ret = { .data = MALLOC(sizeof(LDKPrivateRoute) * orig->datalen, "LDKCVec_PrivateRouteZ clone bytes"), .datalen = orig->datalen };
4934         for (size_t i = 0; i < ret.datalen; i++) {
4935                 ret.data[i] = PrivateRoute_clone(&orig->data[i]);
4936         }
4937         return ret;
4938 }
4939 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PositiveTimestampCreationErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4940         return ((LDKCResult_PositiveTimestampCreationErrorZ*)arg)->result_ok;
4941 }
4942 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PositiveTimestampCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4943         LDKCResult_PositiveTimestampCreationErrorZ *val = (LDKCResult_PositiveTimestampCreationErrorZ*)(arg & ~1);
4944         CHECK(val->result_ok);
4945         LDKPositiveTimestamp res_var = (*val->contents.result);
4946         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4947         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4948         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4949         return res_ref;
4950 }
4951 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PositiveTimestampCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4952         LDKCResult_PositiveTimestampCreationErrorZ *val = (LDKCResult_PositiveTimestampCreationErrorZ*)(arg & ~1);
4953         CHECK(!val->result_ok);
4954         jclass err_conv = LDKCreationError_to_java(env, (*val->contents.err));
4955         return err_conv;
4956 }
4957 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneSemanticErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4958         return ((LDKCResult_NoneSemanticErrorZ*)arg)->result_ok;
4959 }
4960 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneSemanticErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4961         LDKCResult_NoneSemanticErrorZ *val = (LDKCResult_NoneSemanticErrorZ*)(arg & ~1);
4962         CHECK(val->result_ok);
4963         return *val->contents.result;
4964 }
4965 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneSemanticErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4966         LDKCResult_NoneSemanticErrorZ *val = (LDKCResult_NoneSemanticErrorZ*)(arg & ~1);
4967         CHECK(!val->result_ok);
4968         jclass err_conv = LDKSemanticError_to_java(env, (*val->contents.err));
4969         return err_conv;
4970 }
4971 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceSemanticErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4972         return ((LDKCResult_InvoiceSemanticErrorZ*)arg)->result_ok;
4973 }
4974 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceSemanticErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4975         LDKCResult_InvoiceSemanticErrorZ *val = (LDKCResult_InvoiceSemanticErrorZ*)(arg & ~1);
4976         CHECK(val->result_ok);
4977         LDKInvoice res_var = (*val->contents.result);
4978         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4979         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4980         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4981         return res_ref;
4982 }
4983 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceSemanticErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4984         LDKCResult_InvoiceSemanticErrorZ *val = (LDKCResult_InvoiceSemanticErrorZ*)(arg & ~1);
4985         CHECK(!val->result_ok);
4986         jclass err_conv = LDKSemanticError_to_java(env, (*val->contents.err));
4987         return err_conv;
4988 }
4989 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DescriptionCreationErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4990         return ((LDKCResult_DescriptionCreationErrorZ*)arg)->result_ok;
4991 }
4992 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DescriptionCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4993         LDKCResult_DescriptionCreationErrorZ *val = (LDKCResult_DescriptionCreationErrorZ*)(arg & ~1);
4994         CHECK(val->result_ok);
4995         LDKDescription res_var = (*val->contents.result);
4996         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4997         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4998         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4999         return res_ref;
5000 }
5001 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DescriptionCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5002         LDKCResult_DescriptionCreationErrorZ *val = (LDKCResult_DescriptionCreationErrorZ*)(arg & ~1);
5003         CHECK(!val->result_ok);
5004         jclass err_conv = LDKCreationError_to_java(env, (*val->contents.err));
5005         return err_conv;
5006 }
5007 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ExpiryTimeCreationErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5008         return ((LDKCResult_ExpiryTimeCreationErrorZ*)arg)->result_ok;
5009 }
5010 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ExpiryTimeCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5011         LDKCResult_ExpiryTimeCreationErrorZ *val = (LDKCResult_ExpiryTimeCreationErrorZ*)(arg & ~1);
5012         CHECK(val->result_ok);
5013         LDKExpiryTime res_var = (*val->contents.result);
5014         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5015         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5016         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5017         return res_ref;
5018 }
5019 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ExpiryTimeCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5020         LDKCResult_ExpiryTimeCreationErrorZ *val = (LDKCResult_ExpiryTimeCreationErrorZ*)(arg & ~1);
5021         CHECK(!val->result_ok);
5022         jclass err_conv = LDKCreationError_to_java(env, (*val->contents.err));
5023         return err_conv;
5024 }
5025 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PrivateRouteCreationErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5026         return ((LDKCResult_PrivateRouteCreationErrorZ*)arg)->result_ok;
5027 }
5028 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PrivateRouteCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5029         LDKCResult_PrivateRouteCreationErrorZ *val = (LDKCResult_PrivateRouteCreationErrorZ*)(arg & ~1);
5030         CHECK(val->result_ok);
5031         LDKPrivateRoute res_var = (*val->contents.result);
5032         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5033         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5034         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5035         return res_ref;
5036 }
5037 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PrivateRouteCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5038         LDKCResult_PrivateRouteCreationErrorZ *val = (LDKCResult_PrivateRouteCreationErrorZ*)(arg & ~1);
5039         CHECK(!val->result_ok);
5040         jclass err_conv = LDKCreationError_to_java(env, (*val->contents.err));
5041         return err_conv;
5042 }
5043 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1StringErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5044         return ((LDKCResult_StringErrorZ*)arg)->result_ok;
5045 }
5046 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_LDKCResult_1StringErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5047         LDKCResult_StringErrorZ *val = (LDKCResult_StringErrorZ*)(arg & ~1);
5048         CHECK(val->result_ok);
5049         LDKStr res_str = (*val->contents.result);
5050         jstring res_conv = str_ref_to_java(env, res_str.chars, res_str.len);
5051         return res_conv;
5052 }
5053 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1StringErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5054         LDKCResult_StringErrorZ *val = (LDKCResult_StringErrorZ*)(arg & ~1);
5055         CHECK(!val->result_ok);
5056         jclass err_conv = LDKSecp256k1Error_to_java(env, (*val->contents.err));
5057         return err_conv;
5058 }
5059 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelMonitorUpdateDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5060         return ((LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)arg)->result_ok;
5061 }
5062 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelMonitorUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5063         LDKCResult_ChannelMonitorUpdateDecodeErrorZ *val = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(arg & ~1);
5064         CHECK(val->result_ok);
5065         LDKChannelMonitorUpdate res_var = (*val->contents.result);
5066         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5067         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5068         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5069         return res_ref;
5070 }
5071 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelMonitorUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5072         LDKCResult_ChannelMonitorUpdateDecodeErrorZ *val = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(arg & ~1);
5073         CHECK(!val->result_ok);
5074         LDKDecodeError err_var = (*val->contents.err);
5075         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5076         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5077         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5078         return err_ref;
5079 }
5080 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCUpdateDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5081         return ((LDKCResult_HTLCUpdateDecodeErrorZ*)arg)->result_ok;
5082 }
5083 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5084         LDKCResult_HTLCUpdateDecodeErrorZ *val = (LDKCResult_HTLCUpdateDecodeErrorZ*)(arg & ~1);
5085         CHECK(val->result_ok);
5086         LDKHTLCUpdate res_var = (*val->contents.result);
5087         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5088         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5089         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5090         return res_ref;
5091 }
5092 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5093         LDKCResult_HTLCUpdateDecodeErrorZ *val = (LDKCResult_HTLCUpdateDecodeErrorZ*)(arg & ~1);
5094         CHECK(!val->result_ok);
5095         LDKDecodeError err_var = (*val->contents.err);
5096         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5097         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5098         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5099         return err_ref;
5100 }
5101 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneMonitorUpdateErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5102         return ((LDKCResult_NoneMonitorUpdateErrorZ*)arg)->result_ok;
5103 }
5104 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneMonitorUpdateErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5105         LDKCResult_NoneMonitorUpdateErrorZ *val = (LDKCResult_NoneMonitorUpdateErrorZ*)(arg & ~1);
5106         CHECK(val->result_ok);
5107         return *val->contents.result;
5108 }
5109 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneMonitorUpdateErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5110         LDKCResult_NoneMonitorUpdateErrorZ *val = (LDKCResult_NoneMonitorUpdateErrorZ*)(arg & ~1);
5111         CHECK(!val->result_ok);
5112         LDKMonitorUpdateError err_var = (*val->contents.err);
5113         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5114         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5115         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5116         return err_ref;
5117 }
5118 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1OutPointScriptZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
5119         LDKC2Tuple_OutPointScriptZ* ret = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
5120         LDKOutPoint a_conv;
5121         a_conv.inner = (void*)(a & (~1));
5122         a_conv.is_owned = (a & 1) || (a == 0);
5123         a_conv = OutPoint_clone(&a_conv);
5124         ret->a = a_conv;
5125         LDKCVec_u8Z b_ref;
5126         b_ref.datalen = (*env)->GetArrayLength(env, b);
5127         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
5128         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
5129         ret->b = b_ref;
5130         return (uint64_t)ret;
5131 }
5132 static inline struct LDKOutPoint C2Tuple_OutPointScriptZ_get_a(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR tuple){
5133         return OutPoint_clone(&tuple->a);
5134 }
5135 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1get_1a(JNIEnv *env, jclass clz, int64_t tuple) {
5136         LDKC2Tuple_OutPointScriptZ* tuple_conv = (LDKC2Tuple_OutPointScriptZ*)(tuple & ~1);
5137         LDKOutPoint ret_var = C2Tuple_OutPointScriptZ_get_a(tuple_conv);
5138         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5139         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5140         uint64_t ret_ref = (uint64_t)ret_var.inner;
5141         if (ret_var.is_owned) {
5142                 ret_ref |= 1;
5143         }
5144         return ret_ref;
5145 }
5146
5147 static inline struct LDKCVec_u8Z C2Tuple_OutPointScriptZ_get_b(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR tuple){
5148         return CVec_u8Z_clone(&tuple->b);
5149 }
5150 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1get_1b(JNIEnv *env, jclass clz, int64_t tuple) {
5151         LDKC2Tuple_OutPointScriptZ* tuple_conv = (LDKC2Tuple_OutPointScriptZ*)(tuple & ~1);
5152         LDKCVec_u8Z ret_var = C2Tuple_OutPointScriptZ_get_b(tuple_conv);
5153         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
5154         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
5155         CVec_u8Z_free(ret_var);
5156         return ret_arr;
5157 }
5158
5159 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1u32ScriptZ_1new(JNIEnv *env, jclass clz, int32_t a, int8_tArray b) {
5160         LDKC2Tuple_u32ScriptZ* ret = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
5161         ret->a = a;
5162         LDKCVec_u8Z b_ref;
5163         b_ref.datalen = (*env)->GetArrayLength(env, b);
5164         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
5165         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
5166         ret->b = b_ref;
5167         return (uint64_t)ret;
5168 }
5169 static inline uint32_t C2Tuple_u32ScriptZ_get_a(LDKC2Tuple_u32ScriptZ *NONNULL_PTR tuple){
5170         return tuple->a;
5171 }
5172 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1get_1a(JNIEnv *env, jclass clz, int64_t tuple) {
5173         LDKC2Tuple_u32ScriptZ* tuple_conv = (LDKC2Tuple_u32ScriptZ*)(tuple & ~1);
5174         int32_t ret_val = C2Tuple_u32ScriptZ_get_a(tuple_conv);
5175         return ret_val;
5176 }
5177
5178 static inline struct LDKCVec_u8Z C2Tuple_u32ScriptZ_get_b(LDKC2Tuple_u32ScriptZ *NONNULL_PTR tuple){
5179         return CVec_u8Z_clone(&tuple->b);
5180 }
5181 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1get_1b(JNIEnv *env, jclass clz, int64_t tuple) {
5182         LDKC2Tuple_u32ScriptZ* tuple_conv = (LDKC2Tuple_u32ScriptZ*)(tuple & ~1);
5183         LDKCVec_u8Z ret_var = C2Tuple_u32ScriptZ_get_b(tuple_conv);
5184         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
5185         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
5186         CVec_u8Z_free(ret_var);
5187         return ret_arr;
5188 }
5189
5190 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1u32ScriptZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
5191         LDKCVec_C2Tuple_u32ScriptZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_u32ScriptZZ), "LDKCVec_C2Tuple_u32ScriptZZ");
5192         ret->datalen = (*env)->GetArrayLength(env, elems);
5193         if (ret->datalen == 0) {
5194                 ret->data = NULL;
5195         } else {
5196                 ret->data = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ) * ret->datalen, "LDKCVec_C2Tuple_u32ScriptZZ Data");
5197                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
5198                 for (size_t i = 0; i < ret->datalen; i++) {
5199                         int64_t arr_elem = java_elems[i];
5200                         LDKC2Tuple_u32ScriptZ arr_elem_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)arr_elem) & ~1);
5201                         arr_elem_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)(((uint64_t)arr_elem) & ~1));
5202                         ret->data[i] = arr_elem_conv;
5203                 }
5204                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
5205         }
5206         return (uint64_t)ret;
5207 }
5208 static inline LDKCVec_C2Tuple_u32ScriptZZ CVec_C2Tuple_u32ScriptZZ_clone(const LDKCVec_C2Tuple_u32ScriptZZ *orig) {
5209         LDKCVec_C2Tuple_u32ScriptZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ) * orig->datalen, "LDKCVec_C2Tuple_u32ScriptZZ clone bytes"), .datalen = orig->datalen };
5210         for (size_t i = 0; i < ret.datalen; i++) {
5211                 ret.data[i] = C2Tuple_u32ScriptZ_clone(&orig->data[i]);
5212         }
5213         return ret;
5214 }
5215 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
5216         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
5217         LDKThirtyTwoBytes a_ref;
5218         CHECK((*env)->GetArrayLength(env, a) == 32);
5219         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
5220         ret->a = a_ref;
5221         LDKCVec_C2Tuple_u32ScriptZZ b_constr;
5222         b_constr.datalen = (*env)->GetArrayLength(env, b);
5223         if (b_constr.datalen > 0)
5224                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
5225         else
5226                 b_constr.data = NULL;
5227         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
5228         for (size_t v = 0; v < b_constr.datalen; v++) {
5229                 int64_t b_conv_21 = b_vals[v];
5230                 LDKC2Tuple_u32ScriptZ b_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_21) & ~1);
5231                 b_conv_21_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_21) & ~1));
5232                 b_constr.data[v] = b_conv_21_conv;
5233         }
5234         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
5235         ret->b = b_constr;
5236         return (uint64_t)ret;
5237 }
5238 static inline struct LDKThirtyTwoBytes C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR tuple){
5239         return ThirtyTwoBytes_clone(&tuple->a);
5240 }
5241 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1get_1a(JNIEnv *env, jclass clz, int64_t tuple) {
5242         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* tuple_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(tuple & ~1);
5243         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5244         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(tuple_conv).data);
5245         return ret_arr;
5246 }
5247
5248 static inline struct LDKCVec_C2Tuple_u32ScriptZZ C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR tuple){
5249         return CVec_C2Tuple_u32ScriptZZ_clone(&tuple->b);
5250 }
5251 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1get_1b(JNIEnv *env, jclass clz, int64_t tuple) {
5252         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* tuple_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(tuple & ~1);
5253         LDKCVec_C2Tuple_u32ScriptZZ ret_var = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(tuple_conv);
5254         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
5255         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
5256         for (size_t v = 0; v < ret_var.datalen; v++) {
5257                 LDKC2Tuple_u32ScriptZ* ret_conv_21_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
5258                 *ret_conv_21_conv = ret_var.data[v];
5259                 ret_arr_ptr[v] = ((uint64_t)ret_conv_21_conv);
5260         }
5261         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
5262         FREE(ret_var.data);
5263         return ret_arr;
5264 }
5265
5266 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
5267         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ");
5268         ret->datalen = (*env)->GetArrayLength(env, elems);
5269         if (ret->datalen == 0) {
5270                 ret->data = NULL;
5271         } else {
5272                 ret->data = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ) * ret->datalen, "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ Data");
5273                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
5274                 for (size_t i = 0; i < ret->datalen; i++) {
5275                         int64_t arr_elem = java_elems[i];
5276                         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ arr_elem_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)arr_elem) & ~1);
5277                         arr_elem_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone((LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)arr_elem) & ~1));
5278                         ret->data[i] = arr_elem_conv;
5279                 }
5280                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
5281         }
5282         return (uint64_t)ret;
5283 }
5284 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ *orig) {
5285         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 };
5286         for (size_t i = 0; i < ret.datalen; i++) {
5287                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(&orig->data[i]);
5288         }
5289         return ret;
5290 }
5291 static jclass LDKPaymentPurpose_InvoicePayment_class = NULL;
5292 static jmethodID LDKPaymentPurpose_InvoicePayment_meth = NULL;
5293 static jclass LDKPaymentPurpose_SpontaneousPayment_class = NULL;
5294 static jmethodID LDKPaymentPurpose_SpontaneousPayment_meth = NULL;
5295 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKPaymentPurpose_init (JNIEnv *env, jclass clz) {
5296         LDKPaymentPurpose_InvoicePayment_class =
5297                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentPurpose$InvoicePayment;"));
5298         CHECK(LDKPaymentPurpose_InvoicePayment_class != NULL);
5299         LDKPaymentPurpose_InvoicePayment_meth = (*env)->GetMethodID(env, LDKPaymentPurpose_InvoicePayment_class, "<init>", "([B[BJ)V");
5300         CHECK(LDKPaymentPurpose_InvoicePayment_meth != NULL);
5301         LDKPaymentPurpose_SpontaneousPayment_class =
5302                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentPurpose$SpontaneousPayment;"));
5303         CHECK(LDKPaymentPurpose_SpontaneousPayment_class != NULL);
5304         LDKPaymentPurpose_SpontaneousPayment_meth = (*env)->GetMethodID(env, LDKPaymentPurpose_SpontaneousPayment_class, "<init>", "([B)V");
5305         CHECK(LDKPaymentPurpose_SpontaneousPayment_meth != NULL);
5306 }
5307 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPaymentPurpose_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
5308         LDKPaymentPurpose *obj = (LDKPaymentPurpose*)(ptr & ~1);
5309         switch(obj->tag) {
5310                 case LDKPaymentPurpose_InvoicePayment: {
5311                         int8_tArray payment_preimage_arr = (*env)->NewByteArray(env, 32);
5312                         (*env)->SetByteArrayRegion(env, payment_preimage_arr, 0, 32, obj->invoice_payment.payment_preimage.data);
5313                         int8_tArray payment_secret_arr = (*env)->NewByteArray(env, 32);
5314                         (*env)->SetByteArrayRegion(env, payment_secret_arr, 0, 32, obj->invoice_payment.payment_secret.data);
5315                         return (*env)->NewObject(env, LDKPaymentPurpose_InvoicePayment_class, LDKPaymentPurpose_InvoicePayment_meth, payment_preimage_arr, payment_secret_arr, obj->invoice_payment.user_payment_id);
5316                 }
5317                 case LDKPaymentPurpose_SpontaneousPayment: {
5318                         int8_tArray spontaneous_payment_arr = (*env)->NewByteArray(env, 32);
5319                         (*env)->SetByteArrayRegion(env, spontaneous_payment_arr, 0, 32, obj->spontaneous_payment.data);
5320                         return (*env)->NewObject(env, LDKPaymentPurpose_SpontaneousPayment_class, LDKPaymentPurpose_SpontaneousPayment_meth, spontaneous_payment_arr);
5321                 }
5322                 default: abort();
5323         }
5324 }
5325 static jclass LDKClosureReason_CounterpartyForceClosed_class = NULL;
5326 static jmethodID LDKClosureReason_CounterpartyForceClosed_meth = NULL;
5327 static jclass LDKClosureReason_HolderForceClosed_class = NULL;
5328 static jmethodID LDKClosureReason_HolderForceClosed_meth = NULL;
5329 static jclass LDKClosureReason_CooperativeClosure_class = NULL;
5330 static jmethodID LDKClosureReason_CooperativeClosure_meth = NULL;
5331 static jclass LDKClosureReason_CommitmentTxConfirmed_class = NULL;
5332 static jmethodID LDKClosureReason_CommitmentTxConfirmed_meth = NULL;
5333 static jclass LDKClosureReason_ProcessingError_class = NULL;
5334 static jmethodID LDKClosureReason_ProcessingError_meth = NULL;
5335 static jclass LDKClosureReason_DisconnectedPeer_class = NULL;
5336 static jmethodID LDKClosureReason_DisconnectedPeer_meth = NULL;
5337 static jclass LDKClosureReason_OutdatedChannelManager_class = NULL;
5338 static jmethodID LDKClosureReason_OutdatedChannelManager_meth = NULL;
5339 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKClosureReason_init (JNIEnv *env, jclass clz) {
5340         LDKClosureReason_CounterpartyForceClosed_class =
5341                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKClosureReason$CounterpartyForceClosed;"));
5342         CHECK(LDKClosureReason_CounterpartyForceClosed_class != NULL);
5343         LDKClosureReason_CounterpartyForceClosed_meth = (*env)->GetMethodID(env, LDKClosureReason_CounterpartyForceClosed_class, "<init>", "(Ljava/lang/String;)V");
5344         CHECK(LDKClosureReason_CounterpartyForceClosed_meth != NULL);
5345         LDKClosureReason_HolderForceClosed_class =
5346                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKClosureReason$HolderForceClosed;"));
5347         CHECK(LDKClosureReason_HolderForceClosed_class != NULL);
5348         LDKClosureReason_HolderForceClosed_meth = (*env)->GetMethodID(env, LDKClosureReason_HolderForceClosed_class, "<init>", "()V");
5349         CHECK(LDKClosureReason_HolderForceClosed_meth != NULL);
5350         LDKClosureReason_CooperativeClosure_class =
5351                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKClosureReason$CooperativeClosure;"));
5352         CHECK(LDKClosureReason_CooperativeClosure_class != NULL);
5353         LDKClosureReason_CooperativeClosure_meth = (*env)->GetMethodID(env, LDKClosureReason_CooperativeClosure_class, "<init>", "()V");
5354         CHECK(LDKClosureReason_CooperativeClosure_meth != NULL);
5355         LDKClosureReason_CommitmentTxConfirmed_class =
5356                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKClosureReason$CommitmentTxConfirmed;"));
5357         CHECK(LDKClosureReason_CommitmentTxConfirmed_class != NULL);
5358         LDKClosureReason_CommitmentTxConfirmed_meth = (*env)->GetMethodID(env, LDKClosureReason_CommitmentTxConfirmed_class, "<init>", "()V");
5359         CHECK(LDKClosureReason_CommitmentTxConfirmed_meth != NULL);
5360         LDKClosureReason_ProcessingError_class =
5361                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKClosureReason$ProcessingError;"));
5362         CHECK(LDKClosureReason_ProcessingError_class != NULL);
5363         LDKClosureReason_ProcessingError_meth = (*env)->GetMethodID(env, LDKClosureReason_ProcessingError_class, "<init>", "(Ljava/lang/String;)V");
5364         CHECK(LDKClosureReason_ProcessingError_meth != NULL);
5365         LDKClosureReason_DisconnectedPeer_class =
5366                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKClosureReason$DisconnectedPeer;"));
5367         CHECK(LDKClosureReason_DisconnectedPeer_class != NULL);
5368         LDKClosureReason_DisconnectedPeer_meth = (*env)->GetMethodID(env, LDKClosureReason_DisconnectedPeer_class, "<init>", "()V");
5369         CHECK(LDKClosureReason_DisconnectedPeer_meth != NULL);
5370         LDKClosureReason_OutdatedChannelManager_class =
5371                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKClosureReason$OutdatedChannelManager;"));
5372         CHECK(LDKClosureReason_OutdatedChannelManager_class != NULL);
5373         LDKClosureReason_OutdatedChannelManager_meth = (*env)->GetMethodID(env, LDKClosureReason_OutdatedChannelManager_class, "<init>", "()V");
5374         CHECK(LDKClosureReason_OutdatedChannelManager_meth != NULL);
5375 }
5376 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKClosureReason_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
5377         LDKClosureReason *obj = (LDKClosureReason*)(ptr & ~1);
5378         switch(obj->tag) {
5379                 case LDKClosureReason_CounterpartyForceClosed: {
5380                         LDKStr peer_msg_str = obj->counterparty_force_closed.peer_msg;
5381                         jstring peer_msg_conv = str_ref_to_java(env, peer_msg_str.chars, peer_msg_str.len);
5382                         return (*env)->NewObject(env, LDKClosureReason_CounterpartyForceClosed_class, LDKClosureReason_CounterpartyForceClosed_meth, peer_msg_conv);
5383                 }
5384                 case LDKClosureReason_HolderForceClosed: {
5385                         return (*env)->NewObject(env, LDKClosureReason_HolderForceClosed_class, LDKClosureReason_HolderForceClosed_meth);
5386                 }
5387                 case LDKClosureReason_CooperativeClosure: {
5388                         return (*env)->NewObject(env, LDKClosureReason_CooperativeClosure_class, LDKClosureReason_CooperativeClosure_meth);
5389                 }
5390                 case LDKClosureReason_CommitmentTxConfirmed: {
5391                         return (*env)->NewObject(env, LDKClosureReason_CommitmentTxConfirmed_class, LDKClosureReason_CommitmentTxConfirmed_meth);
5392                 }
5393                 case LDKClosureReason_ProcessingError: {
5394                         LDKStr err_str = obj->processing_error.err;
5395                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
5396                         return (*env)->NewObject(env, LDKClosureReason_ProcessingError_class, LDKClosureReason_ProcessingError_meth, err_conv);
5397                 }
5398                 case LDKClosureReason_DisconnectedPeer: {
5399                         return (*env)->NewObject(env, LDKClosureReason_DisconnectedPeer_class, LDKClosureReason_DisconnectedPeer_meth);
5400                 }
5401                 case LDKClosureReason_OutdatedChannelManager: {
5402                         return (*env)->NewObject(env, LDKClosureReason_OutdatedChannelManager_class, LDKClosureReason_OutdatedChannelManager_meth);
5403                 }
5404                 default: abort();
5405         }
5406 }
5407 static jclass LDKEvent_FundingGenerationReady_class = NULL;
5408 static jmethodID LDKEvent_FundingGenerationReady_meth = NULL;
5409 static jclass LDKEvent_PaymentReceived_class = NULL;
5410 static jmethodID LDKEvent_PaymentReceived_meth = NULL;
5411 static jclass LDKEvent_PaymentSent_class = NULL;
5412 static jmethodID LDKEvent_PaymentSent_meth = NULL;
5413 static jclass LDKEvent_PaymentPathFailed_class = NULL;
5414 static jmethodID LDKEvent_PaymentPathFailed_meth = NULL;
5415 static jclass LDKEvent_PendingHTLCsForwardable_class = NULL;
5416 static jmethodID LDKEvent_PendingHTLCsForwardable_meth = NULL;
5417 static jclass LDKEvent_SpendableOutputs_class = NULL;
5418 static jmethodID LDKEvent_SpendableOutputs_meth = NULL;
5419 static jclass LDKEvent_PaymentForwarded_class = NULL;
5420 static jmethodID LDKEvent_PaymentForwarded_meth = NULL;
5421 static jclass LDKEvent_ChannelClosed_class = NULL;
5422 static jmethodID LDKEvent_ChannelClosed_meth = NULL;
5423 static jclass LDKEvent_DiscardFunding_class = NULL;
5424 static jmethodID LDKEvent_DiscardFunding_meth = NULL;
5425 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKEvent_init (JNIEnv *env, jclass clz) {
5426         LDKEvent_FundingGenerationReady_class =
5427                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$FundingGenerationReady;"));
5428         CHECK(LDKEvent_FundingGenerationReady_class != NULL);
5429         LDKEvent_FundingGenerationReady_meth = (*env)->GetMethodID(env, LDKEvent_FundingGenerationReady_class, "<init>", "([BJ[BJ)V");
5430         CHECK(LDKEvent_FundingGenerationReady_meth != NULL);
5431         LDKEvent_PaymentReceived_class =
5432                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PaymentReceived;"));
5433         CHECK(LDKEvent_PaymentReceived_class != NULL);
5434         LDKEvent_PaymentReceived_meth = (*env)->GetMethodID(env, LDKEvent_PaymentReceived_class, "<init>", "([BJJ)V");
5435         CHECK(LDKEvent_PaymentReceived_meth != NULL);
5436         LDKEvent_PaymentSent_class =
5437                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PaymentSent;"));
5438         CHECK(LDKEvent_PaymentSent_class != NULL);
5439         LDKEvent_PaymentSent_meth = (*env)->GetMethodID(env, LDKEvent_PaymentSent_class, "<init>", "([B[B)V");
5440         CHECK(LDKEvent_PaymentSent_meth != NULL);
5441         LDKEvent_PaymentPathFailed_class =
5442                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PaymentPathFailed;"));
5443         CHECK(LDKEvent_PaymentPathFailed_class != NULL);
5444         LDKEvent_PaymentPathFailed_meth = (*env)->GetMethodID(env, LDKEvent_PaymentPathFailed_class, "<init>", "([BZJZ[JJ)V");
5445         CHECK(LDKEvent_PaymentPathFailed_meth != NULL);
5446         LDKEvent_PendingHTLCsForwardable_class =
5447                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PendingHTLCsForwardable;"));
5448         CHECK(LDKEvent_PendingHTLCsForwardable_class != NULL);
5449         LDKEvent_PendingHTLCsForwardable_meth = (*env)->GetMethodID(env, LDKEvent_PendingHTLCsForwardable_class, "<init>", "(J)V");
5450         CHECK(LDKEvent_PendingHTLCsForwardable_meth != NULL);
5451         LDKEvent_SpendableOutputs_class =
5452                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$SpendableOutputs;"));
5453         CHECK(LDKEvent_SpendableOutputs_class != NULL);
5454         LDKEvent_SpendableOutputs_meth = (*env)->GetMethodID(env, LDKEvent_SpendableOutputs_class, "<init>", "([J)V");
5455         CHECK(LDKEvent_SpendableOutputs_meth != NULL);
5456         LDKEvent_PaymentForwarded_class =
5457                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PaymentForwarded;"));
5458         CHECK(LDKEvent_PaymentForwarded_class != NULL);
5459         LDKEvent_PaymentForwarded_meth = (*env)->GetMethodID(env, LDKEvent_PaymentForwarded_class, "<init>", "(JZ)V");
5460         CHECK(LDKEvent_PaymentForwarded_meth != NULL);
5461         LDKEvent_ChannelClosed_class =
5462                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$ChannelClosed;"));
5463         CHECK(LDKEvent_ChannelClosed_class != NULL);
5464         LDKEvent_ChannelClosed_meth = (*env)->GetMethodID(env, LDKEvent_ChannelClosed_class, "<init>", "([BJJ)V");
5465         CHECK(LDKEvent_ChannelClosed_meth != NULL);
5466         LDKEvent_DiscardFunding_class =
5467                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$DiscardFunding;"));
5468         CHECK(LDKEvent_DiscardFunding_class != NULL);
5469         LDKEvent_DiscardFunding_meth = (*env)->GetMethodID(env, LDKEvent_DiscardFunding_class, "<init>", "([B[B)V");
5470         CHECK(LDKEvent_DiscardFunding_meth != NULL);
5471 }
5472 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
5473         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
5474         switch(obj->tag) {
5475                 case LDKEvent_FundingGenerationReady: {
5476                         int8_tArray temporary_channel_id_arr = (*env)->NewByteArray(env, 32);
5477                         (*env)->SetByteArrayRegion(env, temporary_channel_id_arr, 0, 32, obj->funding_generation_ready.temporary_channel_id.data);
5478                         LDKCVec_u8Z output_script_var = obj->funding_generation_ready.output_script;
5479                         int8_tArray output_script_arr = (*env)->NewByteArray(env, output_script_var.datalen);
5480                         (*env)->SetByteArrayRegion(env, output_script_arr, 0, output_script_var.datalen, output_script_var.data);
5481                         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);
5482                 }
5483                 case LDKEvent_PaymentReceived: {
5484                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
5485                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_received.payment_hash.data);
5486                         uint64_t purpose_ref = ((uint64_t)&obj->payment_received.purpose) | 1;
5487                         return (*env)->NewObject(env, LDKEvent_PaymentReceived_class, LDKEvent_PaymentReceived_meth, payment_hash_arr, obj->payment_received.amt, purpose_ref);
5488                 }
5489                 case LDKEvent_PaymentSent: {
5490                         int8_tArray payment_preimage_arr = (*env)->NewByteArray(env, 32);
5491                         (*env)->SetByteArrayRegion(env, payment_preimage_arr, 0, 32, obj->payment_sent.payment_preimage.data);
5492                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
5493                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_sent.payment_hash.data);
5494                         return (*env)->NewObject(env, LDKEvent_PaymentSent_class, LDKEvent_PaymentSent_meth, payment_preimage_arr, payment_hash_arr);
5495                 }
5496                 case LDKEvent_PaymentPathFailed: {
5497                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
5498                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_path_failed.payment_hash.data);
5499                         uint64_t network_update_ref = ((uint64_t)&obj->payment_path_failed.network_update) | 1;
5500                         LDKCVec_RouteHopZ path_var = obj->payment_path_failed.path;
5501                         int64_tArray path_arr = (*env)->NewLongArray(env, path_var.datalen);
5502                         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
5503                         for (size_t k = 0; k < path_var.datalen; k++) {
5504                                 LDKRouteHop path_conv_10_var = path_var.data[k];
5505                                 CHECK((((uint64_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5506                                 CHECK((((uint64_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5507                                 uint64_t path_conv_10_ref = (uint64_t)path_conv_10_var.inner & ~1;
5508                                 path_arr_ptr[k] = path_conv_10_ref;
5509                         }
5510                         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
5511                         uint64_t short_channel_id_ref = ((uint64_t)&obj->payment_path_failed.short_channel_id) | 1;
5512                         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, short_channel_id_ref);
5513                 }
5514                 case LDKEvent_PendingHTLCsForwardable: {
5515                         return (*env)->NewObject(env, LDKEvent_PendingHTLCsForwardable_class, LDKEvent_PendingHTLCsForwardable_meth, obj->pending_htl_cs_forwardable.time_forwardable);
5516                 }
5517                 case LDKEvent_SpendableOutputs: {
5518                         LDKCVec_SpendableOutputDescriptorZ outputs_var = obj->spendable_outputs.outputs;
5519                         int64_tArray outputs_arr = (*env)->NewLongArray(env, outputs_var.datalen);
5520                         int64_t *outputs_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, outputs_arr, NULL);
5521                         for (size_t b = 0; b < outputs_var.datalen; b++) {
5522                                 uint64_t outputs_conv_27_ref = ((uint64_t)&outputs_var.data[b]) | 1;
5523                                 outputs_arr_ptr[b] = outputs_conv_27_ref;
5524                         }
5525                         (*env)->ReleasePrimitiveArrayCritical(env, outputs_arr, outputs_arr_ptr, 0);
5526                         return (*env)->NewObject(env, LDKEvent_SpendableOutputs_class, LDKEvent_SpendableOutputs_meth, outputs_arr);
5527                 }
5528                 case LDKEvent_PaymentForwarded: {
5529                         uint64_t fee_earned_msat_ref = ((uint64_t)&obj->payment_forwarded.fee_earned_msat) | 1;
5530                         return (*env)->NewObject(env, LDKEvent_PaymentForwarded_class, LDKEvent_PaymentForwarded_meth, fee_earned_msat_ref, obj->payment_forwarded.claim_from_onchain_tx);
5531                 }
5532                 case LDKEvent_ChannelClosed: {
5533                         int8_tArray channel_id_arr = (*env)->NewByteArray(env, 32);
5534                         (*env)->SetByteArrayRegion(env, channel_id_arr, 0, 32, obj->channel_closed.channel_id.data);
5535                         uint64_t reason_ref = ((uint64_t)&obj->channel_closed.reason) | 1;
5536                         return (*env)->NewObject(env, LDKEvent_ChannelClosed_class, LDKEvent_ChannelClosed_meth, channel_id_arr, obj->channel_closed.user_channel_id, reason_ref);
5537                 }
5538                 case LDKEvent_DiscardFunding: {
5539                         int8_tArray channel_id_arr = (*env)->NewByteArray(env, 32);
5540                         (*env)->SetByteArrayRegion(env, channel_id_arr, 0, 32, obj->discard_funding.channel_id.data);
5541                         LDKTransaction transaction_var = obj->discard_funding.transaction;
5542                         int8_tArray transaction_arr = (*env)->NewByteArray(env, transaction_var.datalen);
5543                         (*env)->SetByteArrayRegion(env, transaction_arr, 0, transaction_var.datalen, transaction_var.data);
5544                         return (*env)->NewObject(env, LDKEvent_DiscardFunding_class, LDKEvent_DiscardFunding_meth, channel_id_arr, transaction_arr);
5545                 }
5546                 default: abort();
5547         }
5548 }
5549 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1EventZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
5550         LDKCVec_EventZ *ret = MALLOC(sizeof(LDKCVec_EventZ), "LDKCVec_EventZ");
5551         ret->datalen = (*env)->GetArrayLength(env, elems);
5552         if (ret->datalen == 0) {
5553                 ret->data = NULL;
5554         } else {
5555                 ret->data = MALLOC(sizeof(LDKEvent) * ret->datalen, "LDKCVec_EventZ Data");
5556                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
5557                 for (size_t i = 0; i < ret->datalen; i++) {
5558                         int64_t arr_elem = java_elems[i];
5559                         LDKEvent arr_elem_conv = *(LDKEvent*)(((uint64_t)arr_elem) & ~1);
5560                         arr_elem_conv = Event_clone((LDKEvent*)(((uint64_t)arr_elem) & ~1));
5561                         ret->data[i] = arr_elem_conv;
5562                 }
5563                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
5564         }
5565         return (uint64_t)ret;
5566 }
5567 static inline LDKCVec_EventZ CVec_EventZ_clone(const LDKCVec_EventZ *orig) {
5568         LDKCVec_EventZ ret = { .data = MALLOC(sizeof(LDKEvent) * orig->datalen, "LDKCVec_EventZ clone bytes"), .datalen = orig->datalen };
5569         for (size_t i = 0; i < ret.datalen; i++) {
5570                 ret.data[i] = Event_clone(&orig->data[i]);
5571         }
5572         return ret;
5573 }
5574 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1u32TxOutZ_1new(JNIEnv *env, jclass clz, int32_t a, int64_t b) {
5575         LDKC2Tuple_u32TxOutZ* ret = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
5576         ret->a = a;
5577         LDKTxOut b_conv = *(LDKTxOut*)(((uint64_t)b) & ~1);
5578         b_conv = TxOut_clone((LDKTxOut*)(((uint64_t)b) & ~1));
5579         ret->b = b_conv;
5580         return (uint64_t)ret;
5581 }
5582 static inline uint32_t C2Tuple_u32TxOutZ_get_a(LDKC2Tuple_u32TxOutZ *NONNULL_PTR tuple){
5583         return tuple->a;
5584 }
5585 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1get_1a(JNIEnv *env, jclass clz, int64_t tuple) {
5586         LDKC2Tuple_u32TxOutZ* tuple_conv = (LDKC2Tuple_u32TxOutZ*)(tuple & ~1);
5587         int32_t ret_val = C2Tuple_u32TxOutZ_get_a(tuple_conv);
5588         return ret_val;
5589 }
5590
5591 static inline struct LDKTxOut C2Tuple_u32TxOutZ_get_b(LDKC2Tuple_u32TxOutZ *NONNULL_PTR tuple){
5592         return TxOut_clone(&tuple->b);
5593 }
5594 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1get_1b(JNIEnv *env, jclass clz, int64_t tuple) {
5595         LDKC2Tuple_u32TxOutZ* tuple_conv = (LDKC2Tuple_u32TxOutZ*)(tuple & ~1);
5596         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
5597         *ret_ref = C2Tuple_u32TxOutZ_get_b(tuple_conv);
5598         return (uint64_t)ret_ref;
5599 }
5600
5601 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1u32TxOutZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
5602         LDKCVec_C2Tuple_u32TxOutZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_u32TxOutZZ), "LDKCVec_C2Tuple_u32TxOutZZ");
5603         ret->datalen = (*env)->GetArrayLength(env, elems);
5604         if (ret->datalen == 0) {
5605                 ret->data = NULL;
5606         } else {
5607                 ret->data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * ret->datalen, "LDKCVec_C2Tuple_u32TxOutZZ Data");
5608                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
5609                 for (size_t i = 0; i < ret->datalen; i++) {
5610                         int64_t arr_elem = java_elems[i];
5611                         LDKC2Tuple_u32TxOutZ arr_elem_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)arr_elem) & ~1);
5612                         arr_elem_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uint64_t)arr_elem) & ~1));
5613                         ret->data[i] = arr_elem_conv;
5614                 }
5615                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
5616         }
5617         return (uint64_t)ret;
5618 }
5619 static inline LDKCVec_C2Tuple_u32TxOutZZ CVec_C2Tuple_u32TxOutZZ_clone(const LDKCVec_C2Tuple_u32TxOutZZ *orig) {
5620         LDKCVec_C2Tuple_u32TxOutZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * orig->datalen, "LDKCVec_C2Tuple_u32TxOutZZ clone bytes"), .datalen = orig->datalen };
5621         for (size_t i = 0; i < ret.datalen; i++) {
5622                 ret.data[i] = C2Tuple_u32TxOutZ_clone(&orig->data[i]);
5623         }
5624         return ret;
5625 }
5626 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
5627         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
5628         LDKThirtyTwoBytes a_ref;
5629         CHECK((*env)->GetArrayLength(env, a) == 32);
5630         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
5631         ret->a = a_ref;
5632         LDKCVec_C2Tuple_u32TxOutZZ b_constr;
5633         b_constr.datalen = (*env)->GetArrayLength(env, b);
5634         if (b_constr.datalen > 0)
5635                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
5636         else
5637                 b_constr.data = NULL;
5638         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
5639         for (size_t u = 0; u < b_constr.datalen; u++) {
5640                 int64_t b_conv_20 = b_vals[u];
5641                 LDKC2Tuple_u32TxOutZ b_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_20) & ~1);
5642                 b_conv_20_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_20) & ~1));
5643                 b_constr.data[u] = b_conv_20_conv;
5644         }
5645         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
5646         ret->b = b_constr;
5647         return (uint64_t)ret;
5648 }
5649 static inline struct LDKThirtyTwoBytes C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR tuple){
5650         return ThirtyTwoBytes_clone(&tuple->a);
5651 }
5652 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1get_1a(JNIEnv *env, jclass clz, int64_t tuple) {
5653         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* tuple_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(tuple & ~1);
5654         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5655         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(tuple_conv).data);
5656         return ret_arr;
5657 }
5658
5659 static inline struct LDKCVec_C2Tuple_u32TxOutZZ C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR tuple){
5660         return CVec_C2Tuple_u32TxOutZZ_clone(&tuple->b);
5661 }
5662 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1get_1b(JNIEnv *env, jclass clz, int64_t tuple) {
5663         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* tuple_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(tuple & ~1);
5664         LDKCVec_C2Tuple_u32TxOutZZ ret_var = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(tuple_conv);
5665         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
5666         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
5667         for (size_t u = 0; u < ret_var.datalen; u++) {
5668                 LDKC2Tuple_u32TxOutZ* ret_conv_20_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
5669                 *ret_conv_20_conv = ret_var.data[u];
5670                 ret_arr_ptr[u] = ((uint64_t)ret_conv_20_conv);
5671         }
5672         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
5673         FREE(ret_var.data);
5674         return ret_arr;
5675 }
5676
5677 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
5678         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ");
5679         ret->datalen = (*env)->GetArrayLength(env, elems);
5680         if (ret->datalen == 0) {
5681                 ret->data = NULL;
5682         } else {
5683                 ret->data = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ) * ret->datalen, "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Data");
5684                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
5685                 for (size_t i = 0; i < ret->datalen; i++) {
5686                         int64_t arr_elem = java_elems[i];
5687                         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ arr_elem_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)arr_elem) & ~1);
5688                         arr_elem_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone((LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)arr_elem) & ~1));
5689                         ret->data[i] = arr_elem_conv;
5690                 }
5691                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
5692         }
5693         return (uint64_t)ret;
5694 }
5695 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ *orig) {
5696         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 };
5697         for (size_t i = 0; i < ret.datalen; i++) {
5698                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(&orig->data[i]);
5699         }
5700         return ret;
5701 }
5702 static jclass LDKBalance_ClaimableOnChannelClose_class = NULL;
5703 static jmethodID LDKBalance_ClaimableOnChannelClose_meth = NULL;
5704 static jclass LDKBalance_ClaimableAwaitingConfirmations_class = NULL;
5705 static jmethodID LDKBalance_ClaimableAwaitingConfirmations_meth = NULL;
5706 static jclass LDKBalance_ContentiousClaimable_class = NULL;
5707 static jmethodID LDKBalance_ContentiousClaimable_meth = NULL;
5708 static jclass LDKBalance_MaybeClaimableHTLCAwaitingTimeout_class = NULL;
5709 static jmethodID LDKBalance_MaybeClaimableHTLCAwaitingTimeout_meth = NULL;
5710 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKBalance_init (JNIEnv *env, jclass clz) {
5711         LDKBalance_ClaimableOnChannelClose_class =
5712                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKBalance$ClaimableOnChannelClose;"));
5713         CHECK(LDKBalance_ClaimableOnChannelClose_class != NULL);
5714         LDKBalance_ClaimableOnChannelClose_meth = (*env)->GetMethodID(env, LDKBalance_ClaimableOnChannelClose_class, "<init>", "(J)V");
5715         CHECK(LDKBalance_ClaimableOnChannelClose_meth != NULL);
5716         LDKBalance_ClaimableAwaitingConfirmations_class =
5717                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKBalance$ClaimableAwaitingConfirmations;"));
5718         CHECK(LDKBalance_ClaimableAwaitingConfirmations_class != NULL);
5719         LDKBalance_ClaimableAwaitingConfirmations_meth = (*env)->GetMethodID(env, LDKBalance_ClaimableAwaitingConfirmations_class, "<init>", "(JI)V");
5720         CHECK(LDKBalance_ClaimableAwaitingConfirmations_meth != NULL);
5721         LDKBalance_ContentiousClaimable_class =
5722                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKBalance$ContentiousClaimable;"));
5723         CHECK(LDKBalance_ContentiousClaimable_class != NULL);
5724         LDKBalance_ContentiousClaimable_meth = (*env)->GetMethodID(env, LDKBalance_ContentiousClaimable_class, "<init>", "(JI)V");
5725         CHECK(LDKBalance_ContentiousClaimable_meth != NULL);
5726         LDKBalance_MaybeClaimableHTLCAwaitingTimeout_class =
5727                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKBalance$MaybeClaimableHTLCAwaitingTimeout;"));
5728         CHECK(LDKBalance_MaybeClaimableHTLCAwaitingTimeout_class != NULL);
5729         LDKBalance_MaybeClaimableHTLCAwaitingTimeout_meth = (*env)->GetMethodID(env, LDKBalance_MaybeClaimableHTLCAwaitingTimeout_class, "<init>", "(JI)V");
5730         CHECK(LDKBalance_MaybeClaimableHTLCAwaitingTimeout_meth != NULL);
5731 }
5732 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKBalance_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
5733         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
5734         switch(obj->tag) {
5735                 case LDKBalance_ClaimableOnChannelClose: {
5736                         return (*env)->NewObject(env, LDKBalance_ClaimableOnChannelClose_class, LDKBalance_ClaimableOnChannelClose_meth, obj->claimable_on_channel_close.claimable_amount_satoshis);
5737                 }
5738                 case LDKBalance_ClaimableAwaitingConfirmations: {
5739                         return (*env)->NewObject(env, LDKBalance_ClaimableAwaitingConfirmations_class, LDKBalance_ClaimableAwaitingConfirmations_meth, obj->claimable_awaiting_confirmations.claimable_amount_satoshis, obj->claimable_awaiting_confirmations.confirmation_height);
5740                 }
5741                 case LDKBalance_ContentiousClaimable: {
5742                         return (*env)->NewObject(env, LDKBalance_ContentiousClaimable_class, LDKBalance_ContentiousClaimable_meth, obj->contentious_claimable.claimable_amount_satoshis, obj->contentious_claimable.timeout_height);
5743                 }
5744                 case LDKBalance_MaybeClaimableHTLCAwaitingTimeout: {
5745                         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);
5746                 }
5747                 default: abort();
5748         }
5749 }
5750 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1BalanceZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
5751         LDKCVec_BalanceZ *ret = MALLOC(sizeof(LDKCVec_BalanceZ), "LDKCVec_BalanceZ");
5752         ret->datalen = (*env)->GetArrayLength(env, elems);
5753         if (ret->datalen == 0) {
5754                 ret->data = NULL;
5755         } else {
5756                 ret->data = MALLOC(sizeof(LDKBalance) * ret->datalen, "LDKCVec_BalanceZ Data");
5757                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
5758                 for (size_t i = 0; i < ret->datalen; i++) {
5759                         int64_t arr_elem = java_elems[i];
5760                         LDKBalance arr_elem_conv = *(LDKBalance*)(((uint64_t)arr_elem) & ~1);
5761                         arr_elem_conv = Balance_clone((LDKBalance*)(((uint64_t)arr_elem) & ~1));
5762                         ret->data[i] = arr_elem_conv;
5763                 }
5764                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
5765         }
5766         return (uint64_t)ret;
5767 }
5768 static inline LDKCVec_BalanceZ CVec_BalanceZ_clone(const LDKCVec_BalanceZ *orig) {
5769         LDKCVec_BalanceZ ret = { .data = MALLOC(sizeof(LDKBalance) * orig->datalen, "LDKCVec_BalanceZ clone bytes"), .datalen = orig->datalen };
5770         for (size_t i = 0; i < ret.datalen; i++) {
5771                 ret.data[i] = Balance_clone(&orig->data[i]);
5772         }
5773         return ret;
5774 }
5775 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5776         return ((LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)arg)->result_ok;
5777 }
5778 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5779         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1);
5780         CHECK(val->result_ok);
5781         LDKC2Tuple_BlockHashChannelMonitorZ* res_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
5782         *res_conv = (*val->contents.result);
5783         *res_conv = C2Tuple_BlockHashChannelMonitorZ_clone(res_conv);
5784         return ((uint64_t)res_conv);
5785 }
5786 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5787         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1);
5788         CHECK(!val->result_ok);
5789         LDKDecodeError err_var = (*val->contents.err);
5790         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5791         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5792         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5793         return err_ref;
5794 }
5795 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneLightningErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5796         return ((LDKCResult_NoneLightningErrorZ*)arg)->result_ok;
5797 }
5798 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5799         LDKCResult_NoneLightningErrorZ *val = (LDKCResult_NoneLightningErrorZ*)(arg & ~1);
5800         CHECK(val->result_ok);
5801         return *val->contents.result;
5802 }
5803 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5804         LDKCResult_NoneLightningErrorZ *val = (LDKCResult_NoneLightningErrorZ*)(arg & ~1);
5805         CHECK(!val->result_ok);
5806         LDKLightningError err_var = (*val->contents.err);
5807         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5808         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5809         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5810         return err_ref;
5811 }
5812 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1PublicKeyTypeZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
5813         LDKC2Tuple_PublicKeyTypeZ* ret = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
5814         LDKPublicKey a_ref;
5815         CHECK((*env)->GetArrayLength(env, a) == 33);
5816         (*env)->GetByteArrayRegion(env, a, 0, 33, a_ref.compressed_form);
5817         ret->a = a_ref;
5818         LDKType b_conv = *(LDKType*)(((uint64_t)b) & ~1);
5819         b_conv = Type_clone(&b_conv);
5820         ret->b = b_conv;
5821         return (uint64_t)ret;
5822 }
5823 static inline struct LDKPublicKey C2Tuple_PublicKeyTypeZ_get_a(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR tuple){
5824         return tuple->a;
5825 }
5826 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1get_1a(JNIEnv *env, jclass clz, int64_t tuple) {
5827         LDKC2Tuple_PublicKeyTypeZ* tuple_conv = (LDKC2Tuple_PublicKeyTypeZ*)(tuple & ~1);
5828         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
5829         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, C2Tuple_PublicKeyTypeZ_get_a(tuple_conv).compressed_form);
5830         return ret_arr;
5831 }
5832
5833 static inline struct LDKType C2Tuple_PublicKeyTypeZ_get_b(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR tuple){
5834         return Type_clone(&tuple->b);
5835 }
5836 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1get_1b(JNIEnv *env, jclass clz, int64_t tuple) {
5837         LDKC2Tuple_PublicKeyTypeZ* tuple_conv = (LDKC2Tuple_PublicKeyTypeZ*)(tuple & ~1);
5838         LDKType* ret_ret =MALLOC(sizeof(LDKType), "LDKType");
5839         *ret_ret = C2Tuple_PublicKeyTypeZ_get_b(tuple_conv);
5840         return (uint64_t)ret_ret;
5841 }
5842
5843 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1PublicKeyTypeZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
5844         LDKCVec_C2Tuple_PublicKeyTypeZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_PublicKeyTypeZZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ");
5845         ret->datalen = (*env)->GetArrayLength(env, elems);
5846         if (ret->datalen == 0) {
5847                 ret->data = NULL;
5848         } else {
5849                 ret->data = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ) * ret->datalen, "LDKCVec_C2Tuple_PublicKeyTypeZZ Data");
5850                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
5851                 for (size_t i = 0; i < ret->datalen; i++) {
5852                         int64_t arr_elem = java_elems[i];
5853                         LDKC2Tuple_PublicKeyTypeZ arr_elem_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(((uint64_t)arr_elem) & ~1);
5854                         arr_elem_conv = C2Tuple_PublicKeyTypeZ_clone((LDKC2Tuple_PublicKeyTypeZ*)(((uint64_t)arr_elem) & ~1));
5855                         ret->data[i] = arr_elem_conv;
5856                 }
5857                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
5858         }
5859         return (uint64_t)ret;
5860 }
5861 static inline LDKCVec_C2Tuple_PublicKeyTypeZZ CVec_C2Tuple_PublicKeyTypeZZ_clone(const LDKCVec_C2Tuple_PublicKeyTypeZZ *orig) {
5862         LDKCVec_C2Tuple_PublicKeyTypeZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ) * orig->datalen, "LDKCVec_C2Tuple_PublicKeyTypeZZ clone bytes"), .datalen = orig->datalen };
5863         for (size_t i = 0; i < ret.datalen; i++) {
5864                 ret.data[i] = C2Tuple_PublicKeyTypeZ_clone(&orig->data[i]);
5865         }
5866         return ret;
5867 }
5868 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolLightningErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5869         return ((LDKCResult_boolLightningErrorZ*)arg)->result_ok;
5870 }
5871 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5872         LDKCResult_boolLightningErrorZ *val = (LDKCResult_boolLightningErrorZ*)(arg & ~1);
5873         CHECK(val->result_ok);
5874         return *val->contents.result;
5875 }
5876 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5877         LDKCResult_boolLightningErrorZ *val = (LDKCResult_boolLightningErrorZ*)(arg & ~1);
5878         CHECK(!val->result_ok);
5879         LDKLightningError err_var = (*val->contents.err);
5880         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5881         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5882         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5883         return err_ref;
5884 }
5885 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) {
5886         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
5887         LDKChannelAnnouncement a_conv;
5888         a_conv.inner = (void*)(a & (~1));
5889         a_conv.is_owned = (a & 1) || (a == 0);
5890         a_conv = ChannelAnnouncement_clone(&a_conv);
5891         ret->a = a_conv;
5892         LDKChannelUpdate b_conv;
5893         b_conv.inner = (void*)(b & (~1));
5894         b_conv.is_owned = (b & 1) || (b == 0);
5895         b_conv = ChannelUpdate_clone(&b_conv);
5896         ret->b = b_conv;
5897         LDKChannelUpdate c_conv;
5898         c_conv.inner = (void*)(c & (~1));
5899         c_conv.is_owned = (c & 1) || (c == 0);
5900         c_conv = ChannelUpdate_clone(&c_conv);
5901         ret->c = c_conv;
5902         return (uint64_t)ret;
5903 }
5904 static inline struct LDKChannelAnnouncement C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR tuple){
5905         return ChannelAnnouncement_clone(&tuple->a);
5906 }
5907 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1a(JNIEnv *env, jclass clz, int64_t tuple) {
5908         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* tuple_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(tuple & ~1);
5909         LDKChannelAnnouncement ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(tuple_conv);
5910         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5911         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5912         uint64_t ret_ref = (uint64_t)ret_var.inner;
5913         if (ret_var.is_owned) {
5914                 ret_ref |= 1;
5915         }
5916         return ret_ref;
5917 }
5918
5919 static inline struct LDKChannelUpdate C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR tuple){
5920         return ChannelUpdate_clone(&tuple->b);
5921 }
5922 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1b(JNIEnv *env, jclass clz, int64_t tuple) {
5923         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* tuple_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(tuple & ~1);
5924         LDKChannelUpdate ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(tuple_conv);
5925         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5926         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5927         uint64_t ret_ref = (uint64_t)ret_var.inner;
5928         if (ret_var.is_owned) {
5929                 ret_ref |= 1;
5930         }
5931         return ret_ref;
5932 }
5933
5934 static inline struct LDKChannelUpdate C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR tuple){
5935         return ChannelUpdate_clone(&tuple->c);
5936 }
5937 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1c(JNIEnv *env, jclass clz, int64_t tuple) {
5938         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* tuple_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(tuple & ~1);
5939         LDKChannelUpdate ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(tuple_conv);
5940         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5941         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5942         uint64_t ret_ref = (uint64_t)ret_var.inner;
5943         if (ret_var.is_owned) {
5944                 ret_ref |= 1;
5945         }
5946         return ret_ref;
5947 }
5948
5949 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
5950         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *ret = MALLOC(sizeof(LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ");
5951         ret->datalen = (*env)->GetArrayLength(env, elems);
5952         if (ret->datalen == 0) {
5953                 ret->data = NULL;
5954         } else {
5955                 ret->data = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) * ret->datalen, "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Data");
5956                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
5957                 for (size_t i = 0; i < ret->datalen; i++) {
5958                         int64_t arr_elem = java_elems[i];
5959                         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ arr_elem_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)arr_elem) & ~1);
5960                         arr_elem_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone((LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)arr_elem) & ~1));
5961                         ret->data[i] = arr_elem_conv;
5962                 }
5963                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
5964         }
5965         return (uint64_t)ret;
5966 }
5967 static inline LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone(const LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *orig) {
5968         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret = { .data = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) * orig->datalen, "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ clone bytes"), .datalen = orig->datalen };
5969         for (size_t i = 0; i < ret.datalen; i++) {
5970                 ret.data[i] = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(&orig->data[i]);
5971         }
5972         return ret;
5973 }
5974 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1NodeAnnouncementZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
5975         LDKCVec_NodeAnnouncementZ *ret = MALLOC(sizeof(LDKCVec_NodeAnnouncementZ), "LDKCVec_NodeAnnouncementZ");
5976         ret->datalen = (*env)->GetArrayLength(env, elems);
5977         if (ret->datalen == 0) {
5978                 ret->data = NULL;
5979         } else {
5980                 ret->data = MALLOC(sizeof(LDKNodeAnnouncement) * ret->datalen, "LDKCVec_NodeAnnouncementZ Data");
5981                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
5982                 for (size_t i = 0; i < ret->datalen; i++) {
5983                         int64_t arr_elem = java_elems[i];
5984                         LDKNodeAnnouncement arr_elem_conv;
5985                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
5986                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
5987                         arr_elem_conv = NodeAnnouncement_clone(&arr_elem_conv);
5988                         ret->data[i] = arr_elem_conv;
5989                 }
5990                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
5991         }
5992         return (uint64_t)ret;
5993 }
5994 static inline LDKCVec_NodeAnnouncementZ CVec_NodeAnnouncementZ_clone(const LDKCVec_NodeAnnouncementZ *orig) {
5995         LDKCVec_NodeAnnouncementZ ret = { .data = MALLOC(sizeof(LDKNodeAnnouncement) * orig->datalen, "LDKCVec_NodeAnnouncementZ clone bytes"), .datalen = orig->datalen };
5996         for (size_t i = 0; i < ret.datalen; i++) {
5997                 ret.data[i] = NodeAnnouncement_clone(&orig->data[i]);
5998         }
5999         return ret;
6000 }
6001 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1u8ZPeerHandleErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6002         return ((LDKCResult_CVec_u8ZPeerHandleErrorZ*)arg)->result_ok;
6003 }
6004 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1u8ZPeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6005         LDKCResult_CVec_u8ZPeerHandleErrorZ *val = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(arg & ~1);
6006         CHECK(val->result_ok);
6007         LDKCVec_u8Z res_var = (*val->contents.result);
6008         int8_tArray res_arr = (*env)->NewByteArray(env, res_var.datalen);
6009         (*env)->SetByteArrayRegion(env, res_arr, 0, res_var.datalen, res_var.data);
6010         return res_arr;
6011 }
6012 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1u8ZPeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6013         LDKCResult_CVec_u8ZPeerHandleErrorZ *val = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(arg & ~1);
6014         CHECK(!val->result_ok);
6015         LDKPeerHandleError err_var = (*val->contents.err);
6016         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6017         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6018         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6019         return err_ref;
6020 }
6021 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePeerHandleErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6022         return ((LDKCResult_NonePeerHandleErrorZ*)arg)->result_ok;
6023 }
6024 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6025         LDKCResult_NonePeerHandleErrorZ *val = (LDKCResult_NonePeerHandleErrorZ*)(arg & ~1);
6026         CHECK(val->result_ok);
6027         return *val->contents.result;
6028 }
6029 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6030         LDKCResult_NonePeerHandleErrorZ *val = (LDKCResult_NonePeerHandleErrorZ*)(arg & ~1);
6031         CHECK(!val->result_ok);
6032         LDKPeerHandleError err_var = (*val->contents.err);
6033         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6034         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6035         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6036         return err_ref;
6037 }
6038 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolPeerHandleErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6039         return ((LDKCResult_boolPeerHandleErrorZ*)arg)->result_ok;
6040 }
6041 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolPeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6042         LDKCResult_boolPeerHandleErrorZ *val = (LDKCResult_boolPeerHandleErrorZ*)(arg & ~1);
6043         CHECK(val->result_ok);
6044         return *val->contents.result;
6045 }
6046 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolPeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6047         LDKCResult_boolPeerHandleErrorZ *val = (LDKCResult_boolPeerHandleErrorZ*)(arg & ~1);
6048         CHECK(!val->result_ok);
6049         LDKPeerHandleError err_var = (*val->contents.err);
6050         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6051         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6052         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6053         return err_ref;
6054 }
6055 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeIdDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6056         return ((LDKCResult_NodeIdDecodeErrorZ*)arg)->result_ok;
6057 }
6058 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeIdDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6059         LDKCResult_NodeIdDecodeErrorZ *val = (LDKCResult_NodeIdDecodeErrorZ*)(arg & ~1);
6060         CHECK(val->result_ok);
6061         LDKNodeId res_var = (*val->contents.result);
6062         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6063         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6064         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6065         return res_ref;
6066 }
6067 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeIdDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6068         LDKCResult_NodeIdDecodeErrorZ *val = (LDKCResult_NodeIdDecodeErrorZ*)(arg & ~1);
6069         CHECK(!val->result_ok);
6070         LDKDecodeError err_var = (*val->contents.err);
6071         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6072         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6073         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6074         return err_ref;
6075 }
6076 typedef struct LDKAccess_JCalls {
6077         atomic_size_t refcnt;
6078         JavaVM *vm;
6079         jweak o;
6080         jmethodID get_utxo_meth;
6081 } LDKAccess_JCalls;
6082 static void LDKAccess_JCalls_free(void* this_arg) {
6083         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
6084         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6085                 JNIEnv *env;
6086                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6087                 if (get_jenv_res == JNI_EDETACHED) {
6088                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6089                 } else {
6090                         DO_ASSERT(get_jenv_res == JNI_OK);
6091                 }
6092                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6093                 if (get_jenv_res == JNI_EDETACHED) {
6094                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6095                 }
6096                 FREE(j_calls);
6097         }
6098 }
6099 LDKCResult_TxOutAccessErrorZ get_utxo_LDKAccess_jcall(const void* this_arg, const uint8_t (* genesis_hash)[32], uint64_t short_channel_id) {
6100         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
6101         JNIEnv *env;
6102         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6103         if (get_jenv_res == JNI_EDETACHED) {
6104                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6105         } else {
6106                 DO_ASSERT(get_jenv_res == JNI_OK);
6107         }
6108         int8_tArray genesis_hash_arr = (*env)->NewByteArray(env, 32);
6109         (*env)->SetByteArrayRegion(env, genesis_hash_arr, 0, 32, *genesis_hash);
6110         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6111         CHECK(obj != NULL);
6112         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_utxo_meth, genesis_hash_arr, short_channel_id);
6113         if ((*env)->ExceptionCheck(env)) {
6114                 (*env)->ExceptionDescribe(env);
6115                 (*env)->FatalError(env, "A call to get_utxo in LDKAccess from rust threw an exception.");
6116         }
6117         LDKCResult_TxOutAccessErrorZ ret_conv = *(LDKCResult_TxOutAccessErrorZ*)(((uint64_t)ret) & ~1);
6118         ret_conv = CResult_TxOutAccessErrorZ_clone((LDKCResult_TxOutAccessErrorZ*)(((uint64_t)ret) & ~1));
6119         if (get_jenv_res == JNI_EDETACHED) {
6120                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6121         }
6122         return ret_conv;
6123 }
6124 static void LDKAccess_JCalls_cloned(LDKAccess* new_obj) {
6125         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) new_obj->this_arg;
6126         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6127 }
6128 static inline LDKAccess LDKAccess_init (JNIEnv *env, jclass clz, jobject o) {
6129         jclass c = (*env)->GetObjectClass(env, o);
6130         CHECK(c != NULL);
6131         LDKAccess_JCalls *calls = MALLOC(sizeof(LDKAccess_JCalls), "LDKAccess_JCalls");
6132         atomic_init(&calls->refcnt, 1);
6133         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6134         calls->o = (*env)->NewWeakGlobalRef(env, o);
6135         calls->get_utxo_meth = (*env)->GetMethodID(env, c, "get_utxo", "([BJ)J");
6136         CHECK(calls->get_utxo_meth != NULL);
6137
6138         LDKAccess ret = {
6139                 .this_arg = (void*) calls,
6140                 .get_utxo = get_utxo_LDKAccess_jcall,
6141                 .free = LDKAccess_JCalls_free,
6142         };
6143         return ret;
6144 }
6145 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKAccess_1new(JNIEnv *env, jclass clz, jobject o) {
6146         LDKAccess *res_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
6147         *res_ptr = LDKAccess_init(env, clz, o);
6148         return (uint64_t)res_ptr;
6149 }
6150 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) {
6151         LDKAccess* this_arg_conv = (LDKAccess*)(((uint64_t)this_arg) & ~1);
6152         unsigned char genesis_hash_arr[32];
6153         CHECK((*env)->GetArrayLength(env, genesis_hash) == 32);
6154         (*env)->GetByteArrayRegion(env, genesis_hash, 0, 32, genesis_hash_arr);
6155         unsigned char (*genesis_hash_ref)[32] = &genesis_hash_arr;
6156         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
6157         *ret_conv = (this_arg_conv->get_utxo)(this_arg_conv->this_arg, genesis_hash_ref, short_channel_id);
6158         return (uint64_t)ret_conv;
6159 }
6160
6161 static jclass LDKCOption_AccessZ_Some_class = NULL;
6162 static jmethodID LDKCOption_AccessZ_Some_meth = NULL;
6163 static jclass LDKCOption_AccessZ_None_class = NULL;
6164 static jmethodID LDKCOption_AccessZ_None_meth = NULL;
6165 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1AccessZ_init (JNIEnv *env, jclass clz) {
6166         LDKCOption_AccessZ_Some_class =
6167                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_AccessZ$Some;"));
6168         CHECK(LDKCOption_AccessZ_Some_class != NULL);
6169         LDKCOption_AccessZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_AccessZ_Some_class, "<init>", "(J)V");
6170         CHECK(LDKCOption_AccessZ_Some_meth != NULL);
6171         LDKCOption_AccessZ_None_class =
6172                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_AccessZ$None;"));
6173         CHECK(LDKCOption_AccessZ_None_class != NULL);
6174         LDKCOption_AccessZ_None_meth = (*env)->GetMethodID(env, LDKCOption_AccessZ_None_class, "<init>", "()V");
6175         CHECK(LDKCOption_AccessZ_None_meth != NULL);
6176 }
6177 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1AccessZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
6178         LDKCOption_AccessZ *obj = (LDKCOption_AccessZ*)(ptr & ~1);
6179         switch(obj->tag) {
6180                 case LDKCOption_AccessZ_Some: {
6181                         LDKAccess* some_ret =MALLOC(sizeof(LDKAccess), "LDKAccess");
6182                         *some_ret = obj->some;
6183                         // Warning: We likely need to clone here, but no clone is available, so we just do it for Java instances
6184                         if ((*some_ret).free == LDKAccess_JCalls_free) {
6185                                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
6186                                 LDKAccess_JCalls_cloned(&(*some_ret));
6187                         }
6188                         return (*env)->NewObject(env, LDKCOption_AccessZ_Some_class, LDKCOption_AccessZ_Some_meth, (uint64_t)some_ret);
6189                 }
6190                 case LDKCOption_AccessZ_None: {
6191                         return (*env)->NewObject(env, LDKCOption_AccessZ_None_class, LDKCOption_AccessZ_None_meth);
6192                 }
6193                 default: abort();
6194         }
6195 }
6196 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DirectionalChannelInfoDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6197         return ((LDKCResult_DirectionalChannelInfoDecodeErrorZ*)arg)->result_ok;
6198 }
6199 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DirectionalChannelInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6200         LDKCResult_DirectionalChannelInfoDecodeErrorZ *val = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(arg & ~1);
6201         CHECK(val->result_ok);
6202         LDKDirectionalChannelInfo res_var = (*val->contents.result);
6203         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6204         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6205         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6206         return res_ref;
6207 }
6208 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DirectionalChannelInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6209         LDKCResult_DirectionalChannelInfoDecodeErrorZ *val = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(arg & ~1);
6210         CHECK(!val->result_ok);
6211         LDKDecodeError err_var = (*val->contents.err);
6212         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6213         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6214         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6215         return err_ref;
6216 }
6217 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelInfoDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6218         return ((LDKCResult_ChannelInfoDecodeErrorZ*)arg)->result_ok;
6219 }
6220 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6221         LDKCResult_ChannelInfoDecodeErrorZ *val = (LDKCResult_ChannelInfoDecodeErrorZ*)(arg & ~1);
6222         CHECK(val->result_ok);
6223         LDKChannelInfo res_var = (*val->contents.result);
6224         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6225         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6226         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6227         return res_ref;
6228 }
6229 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6230         LDKCResult_ChannelInfoDecodeErrorZ *val = (LDKCResult_ChannelInfoDecodeErrorZ*)(arg & ~1);
6231         CHECK(!val->result_ok);
6232         LDKDecodeError err_var = (*val->contents.err);
6233         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6234         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6235         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6236         return err_ref;
6237 }
6238 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RoutingFeesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6239         return ((LDKCResult_RoutingFeesDecodeErrorZ*)arg)->result_ok;
6240 }
6241 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RoutingFeesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6242         LDKCResult_RoutingFeesDecodeErrorZ *val = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
6243         CHECK(val->result_ok);
6244         LDKRoutingFees res_var = (*val->contents.result);
6245         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6246         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6247         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6248         return res_ref;
6249 }
6250 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RoutingFeesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6251         LDKCResult_RoutingFeesDecodeErrorZ *val = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
6252         CHECK(!val->result_ok);
6253         LDKDecodeError err_var = (*val->contents.err);
6254         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6255         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6256         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6257         return err_ref;
6258 }
6259 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementInfoDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6260         return ((LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)arg)->result_ok;
6261 }
6262 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6263         LDKCResult_NodeAnnouncementInfoDecodeErrorZ *val = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
6264         CHECK(val->result_ok);
6265         LDKNodeAnnouncementInfo res_var = (*val->contents.result);
6266         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6267         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6268         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6269         return res_ref;
6270 }
6271 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6272         LDKCResult_NodeAnnouncementInfoDecodeErrorZ *val = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
6273         CHECK(!val->result_ok);
6274         LDKDecodeError err_var = (*val->contents.err);
6275         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6276         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6277         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6278         return err_ref;
6279 }
6280 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1u64Z_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
6281         LDKCVec_u64Z *ret = MALLOC(sizeof(LDKCVec_u64Z), "LDKCVec_u64Z");
6282         ret->datalen = (*env)->GetArrayLength(env, elems);
6283         if (ret->datalen == 0) {
6284                 ret->data = NULL;
6285         } else {
6286                 ret->data = MALLOC(sizeof(uint64_t) * ret->datalen, "LDKCVec_u64Z Data");
6287                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
6288                 for (size_t i = 0; i < ret->datalen; i++) {
6289                         ret->data[i] = java_elems[i];
6290                 }
6291                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
6292         }
6293         return (uint64_t)ret;
6294 }
6295 static inline LDKCVec_u64Z CVec_u64Z_clone(const LDKCVec_u64Z *orig) {
6296         LDKCVec_u64Z ret = { .data = MALLOC(sizeof(int64_t) * orig->datalen, "LDKCVec_u64Z clone bytes"), .datalen = orig->datalen };
6297         memcpy(ret.data, orig->data, sizeof(int64_t) * ret.datalen);
6298         return ret;
6299 }
6300 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeInfoDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6301         return ((LDKCResult_NodeInfoDecodeErrorZ*)arg)->result_ok;
6302 }
6303 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6304         LDKCResult_NodeInfoDecodeErrorZ *val = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
6305         CHECK(val->result_ok);
6306         LDKNodeInfo res_var = (*val->contents.result);
6307         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6308         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6309         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6310         return res_ref;
6311 }
6312 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6313         LDKCResult_NodeInfoDecodeErrorZ *val = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
6314         CHECK(!val->result_ok);
6315         LDKDecodeError err_var = (*val->contents.err);
6316         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6317         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6318         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6319         return err_ref;
6320 }
6321 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetworkGraphDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6322         return ((LDKCResult_NetworkGraphDecodeErrorZ*)arg)->result_ok;
6323 }
6324 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetworkGraphDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6325         LDKCResult_NetworkGraphDecodeErrorZ *val = (LDKCResult_NetworkGraphDecodeErrorZ*)(arg & ~1);
6326         CHECK(val->result_ok);
6327         LDKNetworkGraph res_var = (*val->contents.result);
6328         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6329         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6330         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6331         return res_ref;
6332 }
6333 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetworkGraphDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6334         LDKCResult_NetworkGraphDecodeErrorZ *val = (LDKCResult_NetworkGraphDecodeErrorZ*)(arg & ~1);
6335         CHECK(!val->result_ok);
6336         LDKDecodeError err_var = (*val->contents.err);
6337         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6338         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6339         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6340         return err_ref;
6341 }
6342 static jclass LDKCOption_CVec_NetAddressZZ_Some_class = NULL;
6343 static jmethodID LDKCOption_CVec_NetAddressZZ_Some_meth = NULL;
6344 static jclass LDKCOption_CVec_NetAddressZZ_None_class = NULL;
6345 static jmethodID LDKCOption_CVec_NetAddressZZ_None_meth = NULL;
6346 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1CVec_1NetAddressZZ_init (JNIEnv *env, jclass clz) {
6347         LDKCOption_CVec_NetAddressZZ_Some_class =
6348                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_CVec_NetAddressZZ$Some;"));
6349         CHECK(LDKCOption_CVec_NetAddressZZ_Some_class != NULL);
6350         LDKCOption_CVec_NetAddressZZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_CVec_NetAddressZZ_Some_class, "<init>", "([J)V");
6351         CHECK(LDKCOption_CVec_NetAddressZZ_Some_meth != NULL);
6352         LDKCOption_CVec_NetAddressZZ_None_class =
6353                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_CVec_NetAddressZZ$None;"));
6354         CHECK(LDKCOption_CVec_NetAddressZZ_None_class != NULL);
6355         LDKCOption_CVec_NetAddressZZ_None_meth = (*env)->GetMethodID(env, LDKCOption_CVec_NetAddressZZ_None_class, "<init>", "()V");
6356         CHECK(LDKCOption_CVec_NetAddressZZ_None_meth != NULL);
6357 }
6358 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1CVec_1NetAddressZZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
6359         LDKCOption_CVec_NetAddressZZ *obj = (LDKCOption_CVec_NetAddressZZ*)(ptr & ~1);
6360         switch(obj->tag) {
6361                 case LDKCOption_CVec_NetAddressZZ_Some: {
6362                         LDKCVec_NetAddressZ some_var = obj->some;
6363                         int64_tArray some_arr = (*env)->NewLongArray(env, some_var.datalen);
6364                         int64_t *some_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, some_arr, NULL);
6365                         for (size_t m = 0; m < some_var.datalen; m++) {
6366                                 uint64_t some_conv_12_ref = ((uint64_t)&some_var.data[m]) | 1;
6367                                 some_arr_ptr[m] = some_conv_12_ref;
6368                         }
6369                         (*env)->ReleasePrimitiveArrayCritical(env, some_arr, some_arr_ptr, 0);
6370                         return (*env)->NewObject(env, LDKCOption_CVec_NetAddressZZ_Some_class, LDKCOption_CVec_NetAddressZZ_Some_meth, some_arr);
6371                 }
6372                 case LDKCOption_CVec_NetAddressZZ_None: {
6373                         return (*env)->NewObject(env, LDKCOption_CVec_NetAddressZZ_None_class, LDKCOption_CVec_NetAddressZZ_None_meth);
6374                 }
6375                 default: abort();
6376         }
6377 }
6378 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressu8Z_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6379         return ((LDKCResult_NetAddressu8Z*)arg)->result_ok;
6380 }
6381 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressu8Z_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6382         LDKCResult_NetAddressu8Z *val = (LDKCResult_NetAddressu8Z*)(arg & ~1);
6383         CHECK(val->result_ok);
6384         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
6385         return res_ref;
6386 }
6387 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressu8Z_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6388         LDKCResult_NetAddressu8Z *val = (LDKCResult_NetAddressu8Z*)(arg & ~1);
6389         CHECK(!val->result_ok);
6390         return *val->contents.err;
6391 }
6392 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CResult_1NetAddressu8ZDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6393         return ((LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)arg)->result_ok;
6394 }
6395 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CResult_1NetAddressu8ZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6396         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ *val = (LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(arg & ~1);
6397         CHECK(val->result_ok);
6398         LDKCResult_NetAddressu8Z* res_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
6399         *res_conv = (*val->contents.result);
6400         *res_conv = CResult_NetAddressu8Z_clone(res_conv);
6401         return (uint64_t)res_conv;
6402 }
6403 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CResult_1NetAddressu8ZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6404         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ *val = (LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(arg & ~1);
6405         CHECK(!val->result_ok);
6406         LDKDecodeError err_var = (*val->contents.err);
6407         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6408         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6409         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6410         return err_ref;
6411 }
6412 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6413         return ((LDKCResult_NetAddressDecodeErrorZ*)arg)->result_ok;
6414 }
6415 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6416         LDKCResult_NetAddressDecodeErrorZ *val = (LDKCResult_NetAddressDecodeErrorZ*)(arg & ~1);
6417         CHECK(val->result_ok);
6418         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
6419         return res_ref;
6420 }
6421 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6422         LDKCResult_NetAddressDecodeErrorZ *val = (LDKCResult_NetAddressDecodeErrorZ*)(arg & ~1);
6423         CHECK(!val->result_ok);
6424         LDKDecodeError err_var = (*val->contents.err);
6425         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6426         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6427         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6428         return err_ref;
6429 }
6430 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1UpdateAddHTLCZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
6431         LDKCVec_UpdateAddHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateAddHTLCZ), "LDKCVec_UpdateAddHTLCZ");
6432         ret->datalen = (*env)->GetArrayLength(env, elems);
6433         if (ret->datalen == 0) {
6434                 ret->data = NULL;
6435         } else {
6436                 ret->data = MALLOC(sizeof(LDKUpdateAddHTLC) * ret->datalen, "LDKCVec_UpdateAddHTLCZ Data");
6437                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
6438                 for (size_t i = 0; i < ret->datalen; i++) {
6439                         int64_t arr_elem = java_elems[i];
6440                         LDKUpdateAddHTLC arr_elem_conv;
6441                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
6442                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
6443                         arr_elem_conv = UpdateAddHTLC_clone(&arr_elem_conv);
6444                         ret->data[i] = arr_elem_conv;
6445                 }
6446                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
6447         }
6448         return (uint64_t)ret;
6449 }
6450 static inline LDKCVec_UpdateAddHTLCZ CVec_UpdateAddHTLCZ_clone(const LDKCVec_UpdateAddHTLCZ *orig) {
6451         LDKCVec_UpdateAddHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateAddHTLC) * orig->datalen, "LDKCVec_UpdateAddHTLCZ clone bytes"), .datalen = orig->datalen };
6452         for (size_t i = 0; i < ret.datalen; i++) {
6453                 ret.data[i] = UpdateAddHTLC_clone(&orig->data[i]);
6454         }
6455         return ret;
6456 }
6457 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1UpdateFulfillHTLCZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
6458         LDKCVec_UpdateFulfillHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateFulfillHTLCZ), "LDKCVec_UpdateFulfillHTLCZ");
6459         ret->datalen = (*env)->GetArrayLength(env, elems);
6460         if (ret->datalen == 0) {
6461                 ret->data = NULL;
6462         } else {
6463                 ret->data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * ret->datalen, "LDKCVec_UpdateFulfillHTLCZ Data");
6464                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
6465                 for (size_t i = 0; i < ret->datalen; i++) {
6466                         int64_t arr_elem = java_elems[i];
6467                         LDKUpdateFulfillHTLC arr_elem_conv;
6468                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
6469                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
6470                         arr_elem_conv = UpdateFulfillHTLC_clone(&arr_elem_conv);
6471                         ret->data[i] = arr_elem_conv;
6472                 }
6473                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
6474         }
6475         return (uint64_t)ret;
6476 }
6477 static inline LDKCVec_UpdateFulfillHTLCZ CVec_UpdateFulfillHTLCZ_clone(const LDKCVec_UpdateFulfillHTLCZ *orig) {
6478         LDKCVec_UpdateFulfillHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * orig->datalen, "LDKCVec_UpdateFulfillHTLCZ clone bytes"), .datalen = orig->datalen };
6479         for (size_t i = 0; i < ret.datalen; i++) {
6480                 ret.data[i] = UpdateFulfillHTLC_clone(&orig->data[i]);
6481         }
6482         return ret;
6483 }
6484 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1UpdateFailHTLCZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
6485         LDKCVec_UpdateFailHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateFailHTLCZ), "LDKCVec_UpdateFailHTLCZ");
6486         ret->datalen = (*env)->GetArrayLength(env, elems);
6487         if (ret->datalen == 0) {
6488                 ret->data = NULL;
6489         } else {
6490                 ret->data = MALLOC(sizeof(LDKUpdateFailHTLC) * ret->datalen, "LDKCVec_UpdateFailHTLCZ Data");
6491                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
6492                 for (size_t i = 0; i < ret->datalen; i++) {
6493                         int64_t arr_elem = java_elems[i];
6494                         LDKUpdateFailHTLC arr_elem_conv;
6495                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
6496                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
6497                         arr_elem_conv = UpdateFailHTLC_clone(&arr_elem_conv);
6498                         ret->data[i] = arr_elem_conv;
6499                 }
6500                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
6501         }
6502         return (uint64_t)ret;
6503 }
6504 static inline LDKCVec_UpdateFailHTLCZ CVec_UpdateFailHTLCZ_clone(const LDKCVec_UpdateFailHTLCZ *orig) {
6505         LDKCVec_UpdateFailHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailHTLC) * orig->datalen, "LDKCVec_UpdateFailHTLCZ clone bytes"), .datalen = orig->datalen };
6506         for (size_t i = 0; i < ret.datalen; i++) {
6507                 ret.data[i] = UpdateFailHTLC_clone(&orig->data[i]);
6508         }
6509         return ret;
6510 }
6511 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1UpdateFailMalformedHTLCZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
6512         LDKCVec_UpdateFailMalformedHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateFailMalformedHTLCZ), "LDKCVec_UpdateFailMalformedHTLCZ");
6513         ret->datalen = (*env)->GetArrayLength(env, elems);
6514         if (ret->datalen == 0) {
6515                 ret->data = NULL;
6516         } else {
6517                 ret->data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * ret->datalen, "LDKCVec_UpdateFailMalformedHTLCZ Data");
6518                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
6519                 for (size_t i = 0; i < ret->datalen; i++) {
6520                         int64_t arr_elem = java_elems[i];
6521                         LDKUpdateFailMalformedHTLC arr_elem_conv;
6522                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
6523                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
6524                         arr_elem_conv = UpdateFailMalformedHTLC_clone(&arr_elem_conv);
6525                         ret->data[i] = arr_elem_conv;
6526                 }
6527                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
6528         }
6529         return (uint64_t)ret;
6530 }
6531 static inline LDKCVec_UpdateFailMalformedHTLCZ CVec_UpdateFailMalformedHTLCZ_clone(const LDKCVec_UpdateFailMalformedHTLCZ *orig) {
6532         LDKCVec_UpdateFailMalformedHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * orig->datalen, "LDKCVec_UpdateFailMalformedHTLCZ clone bytes"), .datalen = orig->datalen };
6533         for (size_t i = 0; i < ret.datalen; i++) {
6534                 ret.data[i] = UpdateFailMalformedHTLC_clone(&orig->data[i]);
6535         }
6536         return ret;
6537 }
6538 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AcceptChannelDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6539         return ((LDKCResult_AcceptChannelDecodeErrorZ*)arg)->result_ok;
6540 }
6541 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AcceptChannelDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6542         LDKCResult_AcceptChannelDecodeErrorZ *val = (LDKCResult_AcceptChannelDecodeErrorZ*)(arg & ~1);
6543         CHECK(val->result_ok);
6544         LDKAcceptChannel res_var = (*val->contents.result);
6545         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6546         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6547         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6548         return res_ref;
6549 }
6550 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AcceptChannelDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6551         LDKCResult_AcceptChannelDecodeErrorZ *val = (LDKCResult_AcceptChannelDecodeErrorZ*)(arg & ~1);
6552         CHECK(!val->result_ok);
6553         LDKDecodeError err_var = (*val->contents.err);
6554         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6555         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6556         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6557         return err_ref;
6558 }
6559 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AnnouncementSignaturesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6560         return ((LDKCResult_AnnouncementSignaturesDecodeErrorZ*)arg)->result_ok;
6561 }
6562 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AnnouncementSignaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6563         LDKCResult_AnnouncementSignaturesDecodeErrorZ *val = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(arg & ~1);
6564         CHECK(val->result_ok);
6565         LDKAnnouncementSignatures res_var = (*val->contents.result);
6566         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6567         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6568         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6569         return res_ref;
6570 }
6571 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AnnouncementSignaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6572         LDKCResult_AnnouncementSignaturesDecodeErrorZ *val = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(arg & ~1);
6573         CHECK(!val->result_ok);
6574         LDKDecodeError err_var = (*val->contents.err);
6575         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6576         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6577         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6578         return err_ref;
6579 }
6580 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelReestablishDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6581         return ((LDKCResult_ChannelReestablishDecodeErrorZ*)arg)->result_ok;
6582 }
6583 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelReestablishDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6584         LDKCResult_ChannelReestablishDecodeErrorZ *val = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
6585         CHECK(val->result_ok);
6586         LDKChannelReestablish res_var = (*val->contents.result);
6587         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6588         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6589         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6590         return res_ref;
6591 }
6592 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelReestablishDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6593         LDKCResult_ChannelReestablishDecodeErrorZ *val = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
6594         CHECK(!val->result_ok);
6595         LDKDecodeError err_var = (*val->contents.err);
6596         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6597         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6598         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6599         return err_ref;
6600 }
6601 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ClosingSignedDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6602         return ((LDKCResult_ClosingSignedDecodeErrorZ*)arg)->result_ok;
6603 }
6604 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ClosingSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6605         LDKCResult_ClosingSignedDecodeErrorZ *val = (LDKCResult_ClosingSignedDecodeErrorZ*)(arg & ~1);
6606         CHECK(val->result_ok);
6607         LDKClosingSigned res_var = (*val->contents.result);
6608         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6609         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6610         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6611         return res_ref;
6612 }
6613 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ClosingSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6614         LDKCResult_ClosingSignedDecodeErrorZ *val = (LDKCResult_ClosingSignedDecodeErrorZ*)(arg & ~1);
6615         CHECK(!val->result_ok);
6616         LDKDecodeError err_var = (*val->contents.err);
6617         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6618         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6619         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6620         return err_ref;
6621 }
6622 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ClosingSignedFeeRangeDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6623         return ((LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)arg)->result_ok;
6624 }
6625 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ClosingSignedFeeRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6626         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *val = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(arg & ~1);
6627         CHECK(val->result_ok);
6628         LDKClosingSignedFeeRange res_var = (*val->contents.result);
6629         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6630         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6631         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6632         return res_ref;
6633 }
6634 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ClosingSignedFeeRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6635         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *val = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(arg & ~1);
6636         CHECK(!val->result_ok);
6637         LDKDecodeError err_var = (*val->contents.err);
6638         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6639         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6640         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6641         return err_ref;
6642 }
6643 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentSignedDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6644         return ((LDKCResult_CommitmentSignedDecodeErrorZ*)arg)->result_ok;
6645 }
6646 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6647         LDKCResult_CommitmentSignedDecodeErrorZ *val = (LDKCResult_CommitmentSignedDecodeErrorZ*)(arg & ~1);
6648         CHECK(val->result_ok);
6649         LDKCommitmentSigned res_var = (*val->contents.result);
6650         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6651         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6652         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6653         return res_ref;
6654 }
6655 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6656         LDKCResult_CommitmentSignedDecodeErrorZ *val = (LDKCResult_CommitmentSignedDecodeErrorZ*)(arg & ~1);
6657         CHECK(!val->result_ok);
6658         LDKDecodeError err_var = (*val->contents.err);
6659         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6660         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6661         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6662         return err_ref;
6663 }
6664 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingCreatedDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6665         return ((LDKCResult_FundingCreatedDecodeErrorZ*)arg)->result_ok;
6666 }
6667 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingCreatedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6668         LDKCResult_FundingCreatedDecodeErrorZ *val = (LDKCResult_FundingCreatedDecodeErrorZ*)(arg & ~1);
6669         CHECK(val->result_ok);
6670         LDKFundingCreated res_var = (*val->contents.result);
6671         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6672         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6673         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6674         return res_ref;
6675 }
6676 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingCreatedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6677         LDKCResult_FundingCreatedDecodeErrorZ *val = (LDKCResult_FundingCreatedDecodeErrorZ*)(arg & ~1);
6678         CHECK(!val->result_ok);
6679         LDKDecodeError err_var = (*val->contents.err);
6680         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6681         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6682         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6683         return err_ref;
6684 }
6685 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingSignedDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6686         return ((LDKCResult_FundingSignedDecodeErrorZ*)arg)->result_ok;
6687 }
6688 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6689         LDKCResult_FundingSignedDecodeErrorZ *val = (LDKCResult_FundingSignedDecodeErrorZ*)(arg & ~1);
6690         CHECK(val->result_ok);
6691         LDKFundingSigned res_var = (*val->contents.result);
6692         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6693         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6694         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6695         return res_ref;
6696 }
6697 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6698         LDKCResult_FundingSignedDecodeErrorZ *val = (LDKCResult_FundingSignedDecodeErrorZ*)(arg & ~1);
6699         CHECK(!val->result_ok);
6700         LDKDecodeError err_var = (*val->contents.err);
6701         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6702         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6703         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6704         return err_ref;
6705 }
6706 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingLockedDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6707         return ((LDKCResult_FundingLockedDecodeErrorZ*)arg)->result_ok;
6708 }
6709 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingLockedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6710         LDKCResult_FundingLockedDecodeErrorZ *val = (LDKCResult_FundingLockedDecodeErrorZ*)(arg & ~1);
6711         CHECK(val->result_ok);
6712         LDKFundingLocked res_var = (*val->contents.result);
6713         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6714         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6715         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6716         return res_ref;
6717 }
6718 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingLockedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6719         LDKCResult_FundingLockedDecodeErrorZ *val = (LDKCResult_FundingLockedDecodeErrorZ*)(arg & ~1);
6720         CHECK(!val->result_ok);
6721         LDKDecodeError err_var = (*val->contents.err);
6722         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6723         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6724         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6725         return err_ref;
6726 }
6727 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6728         return ((LDKCResult_InitDecodeErrorZ*)arg)->result_ok;
6729 }
6730 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6731         LDKCResult_InitDecodeErrorZ *val = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
6732         CHECK(val->result_ok);
6733         LDKInit res_var = (*val->contents.result);
6734         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6735         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6736         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6737         return res_ref;
6738 }
6739 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6740         LDKCResult_InitDecodeErrorZ *val = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
6741         CHECK(!val->result_ok);
6742         LDKDecodeError err_var = (*val->contents.err);
6743         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6744         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6745         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6746         return err_ref;
6747 }
6748 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OpenChannelDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6749         return ((LDKCResult_OpenChannelDecodeErrorZ*)arg)->result_ok;
6750 }
6751 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OpenChannelDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6752         LDKCResult_OpenChannelDecodeErrorZ *val = (LDKCResult_OpenChannelDecodeErrorZ*)(arg & ~1);
6753         CHECK(val->result_ok);
6754         LDKOpenChannel res_var = (*val->contents.result);
6755         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6756         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6757         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6758         return res_ref;
6759 }
6760 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OpenChannelDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6761         LDKCResult_OpenChannelDecodeErrorZ *val = (LDKCResult_OpenChannelDecodeErrorZ*)(arg & ~1);
6762         CHECK(!val->result_ok);
6763         LDKDecodeError err_var = (*val->contents.err);
6764         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6765         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6766         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6767         return err_ref;
6768 }
6769 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RevokeAndACKDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6770         return ((LDKCResult_RevokeAndACKDecodeErrorZ*)arg)->result_ok;
6771 }
6772 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RevokeAndACKDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6773         LDKCResult_RevokeAndACKDecodeErrorZ *val = (LDKCResult_RevokeAndACKDecodeErrorZ*)(arg & ~1);
6774         CHECK(val->result_ok);
6775         LDKRevokeAndACK res_var = (*val->contents.result);
6776         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6777         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6778         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6779         return res_ref;
6780 }
6781 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RevokeAndACKDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6782         LDKCResult_RevokeAndACKDecodeErrorZ *val = (LDKCResult_RevokeAndACKDecodeErrorZ*)(arg & ~1);
6783         CHECK(!val->result_ok);
6784         LDKDecodeError err_var = (*val->contents.err);
6785         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6786         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6787         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6788         return err_ref;
6789 }
6790 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6791         return ((LDKCResult_ShutdownDecodeErrorZ*)arg)->result_ok;
6792 }
6793 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6794         LDKCResult_ShutdownDecodeErrorZ *val = (LDKCResult_ShutdownDecodeErrorZ*)(arg & ~1);
6795         CHECK(val->result_ok);
6796         LDKShutdown res_var = (*val->contents.result);
6797         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6798         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6799         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6800         return res_ref;
6801 }
6802 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6803         LDKCResult_ShutdownDecodeErrorZ *val = (LDKCResult_ShutdownDecodeErrorZ*)(arg & ~1);
6804         CHECK(!val->result_ok);
6805         LDKDecodeError err_var = (*val->contents.err);
6806         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6807         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6808         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6809         return err_ref;
6810 }
6811 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailHTLCDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6812         return ((LDKCResult_UpdateFailHTLCDecodeErrorZ*)arg)->result_ok;
6813 }
6814 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6815         LDKCResult_UpdateFailHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(arg & ~1);
6816         CHECK(val->result_ok);
6817         LDKUpdateFailHTLC res_var = (*val->contents.result);
6818         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6819         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6820         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6821         return res_ref;
6822 }
6823 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6824         LDKCResult_UpdateFailHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(arg & ~1);
6825         CHECK(!val->result_ok);
6826         LDKDecodeError err_var = (*val->contents.err);
6827         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6828         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6829         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6830         return err_ref;
6831 }
6832 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailMalformedHTLCDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6833         return ((LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)arg)->result_ok;
6834 }
6835 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailMalformedHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6836         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(arg & ~1);
6837         CHECK(val->result_ok);
6838         LDKUpdateFailMalformedHTLC res_var = (*val->contents.result);
6839         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6840         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6841         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6842         return res_ref;
6843 }
6844 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailMalformedHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6845         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(arg & ~1);
6846         CHECK(!val->result_ok);
6847         LDKDecodeError err_var = (*val->contents.err);
6848         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6849         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6850         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6851         return err_ref;
6852 }
6853 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFeeDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6854         return ((LDKCResult_UpdateFeeDecodeErrorZ*)arg)->result_ok;
6855 }
6856 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFeeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6857         LDKCResult_UpdateFeeDecodeErrorZ *val = (LDKCResult_UpdateFeeDecodeErrorZ*)(arg & ~1);
6858         CHECK(val->result_ok);
6859         LDKUpdateFee res_var = (*val->contents.result);
6860         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6861         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6862         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6863         return res_ref;
6864 }
6865 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFeeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6866         LDKCResult_UpdateFeeDecodeErrorZ *val = (LDKCResult_UpdateFeeDecodeErrorZ*)(arg & ~1);
6867         CHECK(!val->result_ok);
6868         LDKDecodeError err_var = (*val->contents.err);
6869         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6870         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6871         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6872         return err_ref;
6873 }
6874 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFulfillHTLCDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6875         return ((LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)arg)->result_ok;
6876 }
6877 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFulfillHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6878         LDKCResult_UpdateFulfillHTLCDecodeErrorZ *val = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(arg & ~1);
6879         CHECK(val->result_ok);
6880         LDKUpdateFulfillHTLC res_var = (*val->contents.result);
6881         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6882         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6883         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6884         return res_ref;
6885 }
6886 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFulfillHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6887         LDKCResult_UpdateFulfillHTLCDecodeErrorZ *val = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(arg & ~1);
6888         CHECK(!val->result_ok);
6889         LDKDecodeError err_var = (*val->contents.err);
6890         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6891         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6892         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6893         return err_ref;
6894 }
6895 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateAddHTLCDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6896         return ((LDKCResult_UpdateAddHTLCDecodeErrorZ*)arg)->result_ok;
6897 }
6898 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateAddHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6899         LDKCResult_UpdateAddHTLCDecodeErrorZ *val = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(arg & ~1);
6900         CHECK(val->result_ok);
6901         LDKUpdateAddHTLC res_var = (*val->contents.result);
6902         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6903         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6904         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6905         return res_ref;
6906 }
6907 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateAddHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6908         LDKCResult_UpdateAddHTLCDecodeErrorZ *val = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(arg & ~1);
6909         CHECK(!val->result_ok);
6910         LDKDecodeError err_var = (*val->contents.err);
6911         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6912         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6913         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6914         return err_ref;
6915 }
6916 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PingDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6917         return ((LDKCResult_PingDecodeErrorZ*)arg)->result_ok;
6918 }
6919 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PingDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6920         LDKCResult_PingDecodeErrorZ *val = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
6921         CHECK(val->result_ok);
6922         LDKPing res_var = (*val->contents.result);
6923         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6924         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6925         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6926         return res_ref;
6927 }
6928 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PingDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6929         LDKCResult_PingDecodeErrorZ *val = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
6930         CHECK(!val->result_ok);
6931         LDKDecodeError err_var = (*val->contents.err);
6932         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6933         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6934         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6935         return err_ref;
6936 }
6937 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PongDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6938         return ((LDKCResult_PongDecodeErrorZ*)arg)->result_ok;
6939 }
6940 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PongDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6941         LDKCResult_PongDecodeErrorZ *val = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
6942         CHECK(val->result_ok);
6943         LDKPong res_var = (*val->contents.result);
6944         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6945         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6946         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6947         return res_ref;
6948 }
6949 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PongDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6950         LDKCResult_PongDecodeErrorZ *val = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
6951         CHECK(!val->result_ok);
6952         LDKDecodeError err_var = (*val->contents.err);
6953         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6954         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6955         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6956         return err_ref;
6957 }
6958 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelAnnouncementDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6959         return ((LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)arg)->result_ok;
6960 }
6961 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6962         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
6963         CHECK(val->result_ok);
6964         LDKUnsignedChannelAnnouncement res_var = (*val->contents.result);
6965         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6966         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6967         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6968         return res_ref;
6969 }
6970 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6971         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
6972         CHECK(!val->result_ok);
6973         LDKDecodeError err_var = (*val->contents.err);
6974         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6975         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6976         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6977         return err_ref;
6978 }
6979 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelAnnouncementDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6980         return ((LDKCResult_ChannelAnnouncementDecodeErrorZ*)arg)->result_ok;
6981 }
6982 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6983         LDKCResult_ChannelAnnouncementDecodeErrorZ *val = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(arg & ~1);
6984         CHECK(val->result_ok);
6985         LDKChannelAnnouncement res_var = (*val->contents.result);
6986         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6987         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6988         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6989         return res_ref;
6990 }
6991 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6992         LDKCResult_ChannelAnnouncementDecodeErrorZ *val = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(arg & ~1);
6993         CHECK(!val->result_ok);
6994         LDKDecodeError err_var = (*val->contents.err);
6995         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6996         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6997         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6998         return err_ref;
6999 }
7000 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelUpdateDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
7001         return ((LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)arg)->result_ok;
7002 }
7003 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
7004         LDKCResult_UnsignedChannelUpdateDecodeErrorZ *val = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
7005         CHECK(val->result_ok);
7006         LDKUnsignedChannelUpdate res_var = (*val->contents.result);
7007         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7008         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7009         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
7010         return res_ref;
7011 }
7012 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
7013         LDKCResult_UnsignedChannelUpdateDecodeErrorZ *val = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
7014         CHECK(!val->result_ok);
7015         LDKDecodeError err_var = (*val->contents.err);
7016         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7017         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7018         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
7019         return err_ref;
7020 }
7021 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelUpdateDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
7022         return ((LDKCResult_ChannelUpdateDecodeErrorZ*)arg)->result_ok;
7023 }
7024 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
7025         LDKCResult_ChannelUpdateDecodeErrorZ *val = (LDKCResult_ChannelUpdateDecodeErrorZ*)(arg & ~1);
7026         CHECK(val->result_ok);
7027         LDKChannelUpdate res_var = (*val->contents.result);
7028         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7029         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7030         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
7031         return res_ref;
7032 }
7033 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
7034         LDKCResult_ChannelUpdateDecodeErrorZ *val = (LDKCResult_ChannelUpdateDecodeErrorZ*)(arg & ~1);
7035         CHECK(!val->result_ok);
7036         LDKDecodeError err_var = (*val->contents.err);
7037         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7038         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7039         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
7040         return err_ref;
7041 }
7042 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ErrorMessageDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
7043         return ((LDKCResult_ErrorMessageDecodeErrorZ*)arg)->result_ok;
7044 }
7045 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ErrorMessageDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
7046         LDKCResult_ErrorMessageDecodeErrorZ *val = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
7047         CHECK(val->result_ok);
7048         LDKErrorMessage res_var = (*val->contents.result);
7049         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7050         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7051         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
7052         return res_ref;
7053 }
7054 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ErrorMessageDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
7055         LDKCResult_ErrorMessageDecodeErrorZ *val = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
7056         CHECK(!val->result_ok);
7057         LDKDecodeError err_var = (*val->contents.err);
7058         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7059         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7060         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
7061         return err_ref;
7062 }
7063 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedNodeAnnouncementDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
7064         return ((LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)arg)->result_ok;
7065 }
7066 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedNodeAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
7067         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
7068         CHECK(val->result_ok);
7069         LDKUnsignedNodeAnnouncement res_var = (*val->contents.result);
7070         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7071         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7072         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
7073         return res_ref;
7074 }
7075 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedNodeAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
7076         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
7077         CHECK(!val->result_ok);
7078         LDKDecodeError err_var = (*val->contents.err);
7079         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7080         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7081         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
7082         return err_ref;
7083 }
7084 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
7085         return ((LDKCResult_NodeAnnouncementDecodeErrorZ*)arg)->result_ok;
7086 }
7087 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
7088         LDKCResult_NodeAnnouncementDecodeErrorZ *val = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(arg & ~1);
7089         CHECK(val->result_ok);
7090         LDKNodeAnnouncement res_var = (*val->contents.result);
7091         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7092         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7093         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
7094         return res_ref;
7095 }
7096 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
7097         LDKCResult_NodeAnnouncementDecodeErrorZ *val = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(arg & ~1);
7098         CHECK(!val->result_ok);
7099         LDKDecodeError err_var = (*val->contents.err);
7100         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7101         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7102         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
7103         return err_ref;
7104 }
7105 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryShortChannelIdsDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
7106         return ((LDKCResult_QueryShortChannelIdsDecodeErrorZ*)arg)->result_ok;
7107 }
7108 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryShortChannelIdsDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
7109         LDKCResult_QueryShortChannelIdsDecodeErrorZ *val = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
7110         CHECK(val->result_ok);
7111         LDKQueryShortChannelIds res_var = (*val->contents.result);
7112         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7113         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7114         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
7115         return res_ref;
7116 }
7117 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryShortChannelIdsDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
7118         LDKCResult_QueryShortChannelIdsDecodeErrorZ *val = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
7119         CHECK(!val->result_ok);
7120         LDKDecodeError err_var = (*val->contents.err);
7121         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7122         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7123         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
7124         return err_ref;
7125 }
7126 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyShortChannelIdsEndDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
7127         return ((LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)arg)->result_ok;
7128 }
7129 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyShortChannelIdsEndDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
7130         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *val = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
7131         CHECK(val->result_ok);
7132         LDKReplyShortChannelIdsEnd res_var = (*val->contents.result);
7133         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7134         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7135         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
7136         return res_ref;
7137 }
7138 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyShortChannelIdsEndDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
7139         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *val = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
7140         CHECK(!val->result_ok);
7141         LDKDecodeError err_var = (*val->contents.err);
7142         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7143         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7144         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
7145         return err_ref;
7146 }
7147 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryChannelRangeDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
7148         return ((LDKCResult_QueryChannelRangeDecodeErrorZ*)arg)->result_ok;
7149 }
7150 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryChannelRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
7151         LDKCResult_QueryChannelRangeDecodeErrorZ *val = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
7152         CHECK(val->result_ok);
7153         LDKQueryChannelRange res_var = (*val->contents.result);
7154         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7155         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7156         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
7157         return res_ref;
7158 }
7159 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryChannelRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
7160         LDKCResult_QueryChannelRangeDecodeErrorZ *val = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
7161         CHECK(!val->result_ok);
7162         LDKDecodeError err_var = (*val->contents.err);
7163         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7164         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7165         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
7166         return err_ref;
7167 }
7168 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyChannelRangeDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
7169         return ((LDKCResult_ReplyChannelRangeDecodeErrorZ*)arg)->result_ok;
7170 }
7171 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyChannelRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
7172         LDKCResult_ReplyChannelRangeDecodeErrorZ *val = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
7173         CHECK(val->result_ok);
7174         LDKReplyChannelRange res_var = (*val->contents.result);
7175         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7176         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7177         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
7178         return res_ref;
7179 }
7180 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyChannelRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
7181         LDKCResult_ReplyChannelRangeDecodeErrorZ *val = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
7182         CHECK(!val->result_ok);
7183         LDKDecodeError err_var = (*val->contents.err);
7184         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7185         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7186         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
7187         return err_ref;
7188 }
7189 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1GossipTimestampFilterDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
7190         return ((LDKCResult_GossipTimestampFilterDecodeErrorZ*)arg)->result_ok;
7191 }
7192 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1GossipTimestampFilterDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
7193         LDKCResult_GossipTimestampFilterDecodeErrorZ *val = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
7194         CHECK(val->result_ok);
7195         LDKGossipTimestampFilter res_var = (*val->contents.result);
7196         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7197         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7198         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
7199         return res_ref;
7200 }
7201 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1GossipTimestampFilterDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
7202         LDKCResult_GossipTimestampFilterDecodeErrorZ *val = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
7203         CHECK(!val->result_ok);
7204         LDKDecodeError err_var = (*val->contents.err);
7205         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7206         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7207         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
7208         return err_ref;
7209 }
7210 static jclass LDKSignOrCreationError_SignError_class = NULL;
7211 static jmethodID LDKSignOrCreationError_SignError_meth = NULL;
7212 static jclass LDKSignOrCreationError_CreationError_class = NULL;
7213 static jmethodID LDKSignOrCreationError_CreationError_meth = NULL;
7214 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKSignOrCreationError_init (JNIEnv *env, jclass clz) {
7215         LDKSignOrCreationError_SignError_class =
7216                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKSignOrCreationError$SignError;"));
7217         CHECK(LDKSignOrCreationError_SignError_class != NULL);
7218         LDKSignOrCreationError_SignError_meth = (*env)->GetMethodID(env, LDKSignOrCreationError_SignError_class, "<init>", "()V");
7219         CHECK(LDKSignOrCreationError_SignError_meth != NULL);
7220         LDKSignOrCreationError_CreationError_class =
7221                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKSignOrCreationError$CreationError;"));
7222         CHECK(LDKSignOrCreationError_CreationError_class != NULL);
7223         LDKSignOrCreationError_CreationError_meth = (*env)->GetMethodID(env, LDKSignOrCreationError_CreationError_class, "<init>", "(Lorg/ldk/enums/CreationError;)V");
7224         CHECK(LDKSignOrCreationError_CreationError_meth != NULL);
7225 }
7226 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKSignOrCreationError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
7227         LDKSignOrCreationError *obj = (LDKSignOrCreationError*)(ptr & ~1);
7228         switch(obj->tag) {
7229                 case LDKSignOrCreationError_SignError: {
7230                         return (*env)->NewObject(env, LDKSignOrCreationError_SignError_class, LDKSignOrCreationError_SignError_meth);
7231                 }
7232                 case LDKSignOrCreationError_CreationError: {
7233                         jclass creation_error_conv = LDKCreationError_to_java(env, obj->creation_error);
7234                         return (*env)->NewObject(env, LDKSignOrCreationError_CreationError_class, LDKSignOrCreationError_CreationError_meth, creation_error_conv);
7235                 }
7236                 default: abort();
7237         }
7238 }
7239 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceSignOrCreationErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
7240         return ((LDKCResult_InvoiceSignOrCreationErrorZ*)arg)->result_ok;
7241 }
7242 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceSignOrCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
7243         LDKCResult_InvoiceSignOrCreationErrorZ *val = (LDKCResult_InvoiceSignOrCreationErrorZ*)(arg & ~1);
7244         CHECK(val->result_ok);
7245         LDKInvoice res_var = (*val->contents.result);
7246         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7247         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7248         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
7249         return res_ref;
7250 }
7251 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceSignOrCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
7252         LDKCResult_InvoiceSignOrCreationErrorZ *val = (LDKCResult_InvoiceSignOrCreationErrorZ*)(arg & ~1);
7253         CHECK(!val->result_ok);
7254         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
7255         return err_ref;
7256 }
7257 typedef struct LDKFilter_JCalls {
7258         atomic_size_t refcnt;
7259         JavaVM *vm;
7260         jweak o;
7261         jmethodID register_tx_meth;
7262         jmethodID register_output_meth;
7263 } LDKFilter_JCalls;
7264 static void LDKFilter_JCalls_free(void* this_arg) {
7265         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
7266         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7267                 JNIEnv *env;
7268                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7269                 if (get_jenv_res == JNI_EDETACHED) {
7270                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7271                 } else {
7272                         DO_ASSERT(get_jenv_res == JNI_OK);
7273                 }
7274                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
7275                 if (get_jenv_res == JNI_EDETACHED) {
7276                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7277                 }
7278                 FREE(j_calls);
7279         }
7280 }
7281 void register_tx_LDKFilter_jcall(const void* this_arg, const uint8_t (* txid)[32], LDKu8slice script_pubkey) {
7282         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
7283         JNIEnv *env;
7284         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7285         if (get_jenv_res == JNI_EDETACHED) {
7286                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7287         } else {
7288                 DO_ASSERT(get_jenv_res == JNI_OK);
7289         }
7290         int8_tArray txid_arr = (*env)->NewByteArray(env, 32);
7291         (*env)->SetByteArrayRegion(env, txid_arr, 0, 32, *txid);
7292         LDKu8slice script_pubkey_var = script_pubkey;
7293         int8_tArray script_pubkey_arr = (*env)->NewByteArray(env, script_pubkey_var.datalen);
7294         (*env)->SetByteArrayRegion(env, script_pubkey_arr, 0, script_pubkey_var.datalen, script_pubkey_var.data);
7295         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7296         CHECK(obj != NULL);
7297         (*env)->CallVoidMethod(env, obj, j_calls->register_tx_meth, txid_arr, script_pubkey_arr);
7298         if ((*env)->ExceptionCheck(env)) {
7299                 (*env)->ExceptionDescribe(env);
7300                 (*env)->FatalError(env, "A call to register_tx in LDKFilter from rust threw an exception.");
7301         }
7302         if (get_jenv_res == JNI_EDETACHED) {
7303                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7304         }
7305 }
7306 LDKCOption_C2Tuple_usizeTransactionZZ register_output_LDKFilter_jcall(const void* this_arg, LDKWatchedOutput output) {
7307         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
7308         JNIEnv *env;
7309         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7310         if (get_jenv_res == JNI_EDETACHED) {
7311                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7312         } else {
7313                 DO_ASSERT(get_jenv_res == JNI_OK);
7314         }
7315         LDKWatchedOutput output_var = output;
7316         CHECK((((uint64_t)output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7317         CHECK((((uint64_t)&output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7318         uint64_t output_ref = (uint64_t)output_var.inner;
7319         if (output_var.is_owned) {
7320                 output_ref |= 1;
7321         }
7322         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7323         CHECK(obj != NULL);
7324         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->register_output_meth, output_ref);
7325         if ((*env)->ExceptionCheck(env)) {
7326                 (*env)->ExceptionDescribe(env);
7327                 (*env)->FatalError(env, "A call to register_output in LDKFilter from rust threw an exception.");
7328         }
7329         LDKCOption_C2Tuple_usizeTransactionZZ ret_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(((uint64_t)ret) & ~1);
7330         ret_conv = COption_C2Tuple_usizeTransactionZZ_clone((LDKCOption_C2Tuple_usizeTransactionZZ*)(((uint64_t)ret) & ~1));
7331         if (get_jenv_res == JNI_EDETACHED) {
7332                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7333         }
7334         return ret_conv;
7335 }
7336 static void LDKFilter_JCalls_cloned(LDKFilter* new_obj) {
7337         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) new_obj->this_arg;
7338         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7339 }
7340 static inline LDKFilter LDKFilter_init (JNIEnv *env, jclass clz, jobject o) {
7341         jclass c = (*env)->GetObjectClass(env, o);
7342         CHECK(c != NULL);
7343         LDKFilter_JCalls *calls = MALLOC(sizeof(LDKFilter_JCalls), "LDKFilter_JCalls");
7344         atomic_init(&calls->refcnt, 1);
7345         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
7346         calls->o = (*env)->NewWeakGlobalRef(env, o);
7347         calls->register_tx_meth = (*env)->GetMethodID(env, c, "register_tx", "([B[B)V");
7348         CHECK(calls->register_tx_meth != NULL);
7349         calls->register_output_meth = (*env)->GetMethodID(env, c, "register_output", "(J)J");
7350         CHECK(calls->register_output_meth != NULL);
7351
7352         LDKFilter ret = {
7353                 .this_arg = (void*) calls,
7354                 .register_tx = register_tx_LDKFilter_jcall,
7355                 .register_output = register_output_LDKFilter_jcall,
7356                 .free = LDKFilter_JCalls_free,
7357         };
7358         return ret;
7359 }
7360 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKFilter_1new(JNIEnv *env, jclass clz, jobject o) {
7361         LDKFilter *res_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter");
7362         *res_ptr = LDKFilter_init(env, clz, o);
7363         return (uint64_t)res_ptr;
7364 }
7365 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) {
7366         LDKFilter* this_arg_conv = (LDKFilter*)(((uint64_t)this_arg) & ~1);
7367         unsigned char txid_arr[32];
7368         CHECK((*env)->GetArrayLength(env, txid) == 32);
7369         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
7370         unsigned char (*txid_ref)[32] = &txid_arr;
7371         LDKu8slice script_pubkey_ref;
7372         script_pubkey_ref.datalen = (*env)->GetArrayLength(env, script_pubkey);
7373         script_pubkey_ref.data = (*env)->GetByteArrayElements (env, script_pubkey, NULL);
7374         (this_arg_conv->register_tx)(this_arg_conv->this_arg, txid_ref, script_pubkey_ref);
7375         (*env)->ReleaseByteArrayElements(env, script_pubkey, (int8_t*)script_pubkey_ref.data, 0);
7376 }
7377
7378 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Filter_1register_1output(JNIEnv *env, jclass clz, int64_t this_arg, int64_t output) {
7379         LDKFilter* this_arg_conv = (LDKFilter*)(((uint64_t)this_arg) & ~1);
7380         LDKWatchedOutput output_conv;
7381         output_conv.inner = (void*)(output & (~1));
7382         output_conv.is_owned = (output & 1) || (output == 0);
7383         output_conv = WatchedOutput_clone(&output_conv);
7384         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
7385         *ret_copy = (this_arg_conv->register_output)(this_arg_conv->this_arg, output_conv);
7386         uint64_t ret_ref = (uint64_t)ret_copy;
7387         return ret_ref;
7388 }
7389
7390 static jclass LDKCOption_FilterZ_Some_class = NULL;
7391 static jmethodID LDKCOption_FilterZ_Some_meth = NULL;
7392 static jclass LDKCOption_FilterZ_None_class = NULL;
7393 static jmethodID LDKCOption_FilterZ_None_meth = NULL;
7394 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1FilterZ_init (JNIEnv *env, jclass clz) {
7395         LDKCOption_FilterZ_Some_class =
7396                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_FilterZ$Some;"));
7397         CHECK(LDKCOption_FilterZ_Some_class != NULL);
7398         LDKCOption_FilterZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_FilterZ_Some_class, "<init>", "(J)V");
7399         CHECK(LDKCOption_FilterZ_Some_meth != NULL);
7400         LDKCOption_FilterZ_None_class =
7401                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_FilterZ$None;"));
7402         CHECK(LDKCOption_FilterZ_None_class != NULL);
7403         LDKCOption_FilterZ_None_meth = (*env)->GetMethodID(env, LDKCOption_FilterZ_None_class, "<init>", "()V");
7404         CHECK(LDKCOption_FilterZ_None_meth != NULL);
7405 }
7406 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1FilterZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
7407         LDKCOption_FilterZ *obj = (LDKCOption_FilterZ*)(ptr & ~1);
7408         switch(obj->tag) {
7409                 case LDKCOption_FilterZ_Some: {
7410                         LDKFilter* some_ret =MALLOC(sizeof(LDKFilter), "LDKFilter");
7411                         *some_ret = obj->some;
7412                         // Warning: We likely need to clone here, but no clone is available, so we just do it for Java instances
7413                         if ((*some_ret).free == LDKFilter_JCalls_free) {
7414                                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
7415                                 LDKFilter_JCalls_cloned(&(*some_ret));
7416                         }
7417                         return (*env)->NewObject(env, LDKCOption_FilterZ_Some_class, LDKCOption_FilterZ_Some_meth, (uint64_t)some_ret);
7418                 }
7419                 case LDKCOption_FilterZ_None: {
7420                         return (*env)->NewObject(env, LDKCOption_FilterZ_None_class, LDKCOption_FilterZ_None_meth);
7421                 }
7422                 default: abort();
7423         }
7424 }
7425 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1LockedChannelMonitorNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
7426         return ((LDKCResult_LockedChannelMonitorNoneZ*)arg)->result_ok;
7427 }
7428 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1LockedChannelMonitorNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
7429         LDKCResult_LockedChannelMonitorNoneZ *val = (LDKCResult_LockedChannelMonitorNoneZ*)(arg & ~1);
7430         CHECK(val->result_ok);
7431         LDKLockedChannelMonitor res_var = (*val->contents.result);
7432         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7433         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7434         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
7435         return res_ref;
7436 }
7437 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1LockedChannelMonitorNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
7438         LDKCResult_LockedChannelMonitorNoneZ *val = (LDKCResult_LockedChannelMonitorNoneZ*)(arg & ~1);
7439         CHECK(!val->result_ok);
7440         return *val->contents.err;
7441 }
7442 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1OutPointZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
7443         LDKCVec_OutPointZ *ret = MALLOC(sizeof(LDKCVec_OutPointZ), "LDKCVec_OutPointZ");
7444         ret->datalen = (*env)->GetArrayLength(env, elems);
7445         if (ret->datalen == 0) {
7446                 ret->data = NULL;
7447         } else {
7448                 ret->data = MALLOC(sizeof(LDKOutPoint) * ret->datalen, "LDKCVec_OutPointZ Data");
7449                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
7450                 for (size_t i = 0; i < ret->datalen; i++) {
7451                         int64_t arr_elem = java_elems[i];
7452                         LDKOutPoint arr_elem_conv;
7453                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
7454                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
7455                         arr_elem_conv = OutPoint_clone(&arr_elem_conv);
7456                         ret->data[i] = arr_elem_conv;
7457                 }
7458                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
7459         }
7460         return (uint64_t)ret;
7461 }
7462 static inline LDKCVec_OutPointZ CVec_OutPointZ_clone(const LDKCVec_OutPointZ *orig) {
7463         LDKCVec_OutPointZ ret = { .data = MALLOC(sizeof(LDKOutPoint) * orig->datalen, "LDKCVec_OutPointZ clone bytes"), .datalen = orig->datalen };
7464         for (size_t i = 0; i < ret.datalen; i++) {
7465                 ret.data[i] = OutPoint_clone(&orig->data[i]);
7466         }
7467         return ret;
7468 }
7469 typedef struct LDKMessageSendEventsProvider_JCalls {
7470         atomic_size_t refcnt;
7471         JavaVM *vm;
7472         jweak o;
7473         jmethodID get_and_clear_pending_msg_events_meth;
7474 } LDKMessageSendEventsProvider_JCalls;
7475 static void LDKMessageSendEventsProvider_JCalls_free(void* this_arg) {
7476         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
7477         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7478                 JNIEnv *env;
7479                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7480                 if (get_jenv_res == JNI_EDETACHED) {
7481                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7482                 } else {
7483                         DO_ASSERT(get_jenv_res == JNI_OK);
7484                 }
7485                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
7486                 if (get_jenv_res == JNI_EDETACHED) {
7487                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7488                 }
7489                 FREE(j_calls);
7490         }
7491 }
7492 LDKCVec_MessageSendEventZ get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall(const void* this_arg) {
7493         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
7494         JNIEnv *env;
7495         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7496         if (get_jenv_res == JNI_EDETACHED) {
7497                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7498         } else {
7499                 DO_ASSERT(get_jenv_res == JNI_OK);
7500         }
7501         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7502         CHECK(obj != NULL);
7503         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_and_clear_pending_msg_events_meth);
7504         if ((*env)->ExceptionCheck(env)) {
7505                 (*env)->ExceptionDescribe(env);
7506                 (*env)->FatalError(env, "A call to get_and_clear_pending_msg_events in LDKMessageSendEventsProvider from rust threw an exception.");
7507         }
7508         LDKCVec_MessageSendEventZ ret_constr;
7509         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
7510         if (ret_constr.datalen > 0)
7511                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
7512         else
7513                 ret_constr.data = NULL;
7514         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
7515         for (size_t s = 0; s < ret_constr.datalen; s++) {
7516                 int64_t ret_conv_18 = ret_vals[s];
7517                 LDKMessageSendEvent ret_conv_18_conv = *(LDKMessageSendEvent*)(((uint64_t)ret_conv_18) & ~1);
7518                 ret_conv_18_conv = MessageSendEvent_clone((LDKMessageSendEvent*)(((uint64_t)ret_conv_18) & ~1));
7519                 ret_constr.data[s] = ret_conv_18_conv;
7520         }
7521         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
7522         if (get_jenv_res == JNI_EDETACHED) {
7523                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7524         }
7525         return ret_constr;
7526 }
7527 static void LDKMessageSendEventsProvider_JCalls_cloned(LDKMessageSendEventsProvider* new_obj) {
7528         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) new_obj->this_arg;
7529         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7530 }
7531 static inline LDKMessageSendEventsProvider LDKMessageSendEventsProvider_init (JNIEnv *env, jclass clz, jobject o) {
7532         jclass c = (*env)->GetObjectClass(env, o);
7533         CHECK(c != NULL);
7534         LDKMessageSendEventsProvider_JCalls *calls = MALLOC(sizeof(LDKMessageSendEventsProvider_JCalls), "LDKMessageSendEventsProvider_JCalls");
7535         atomic_init(&calls->refcnt, 1);
7536         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
7537         calls->o = (*env)->NewWeakGlobalRef(env, o);
7538         calls->get_and_clear_pending_msg_events_meth = (*env)->GetMethodID(env, c, "get_and_clear_pending_msg_events", "()[J");
7539         CHECK(calls->get_and_clear_pending_msg_events_meth != NULL);
7540
7541         LDKMessageSendEventsProvider ret = {
7542                 .this_arg = (void*) calls,
7543                 .get_and_clear_pending_msg_events = get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall,
7544                 .free = LDKMessageSendEventsProvider_JCalls_free,
7545         };
7546         return ret;
7547 }
7548 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEventsProvider_1new(JNIEnv *env, jclass clz, jobject o) {
7549         LDKMessageSendEventsProvider *res_ptr = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
7550         *res_ptr = LDKMessageSendEventsProvider_init(env, clz, o);
7551         return (uint64_t)res_ptr;
7552 }
7553 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_MessageSendEventsProvider_1get_1and_1clear_1pending_1msg_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
7554         LDKMessageSendEventsProvider* this_arg_conv = (LDKMessageSendEventsProvider*)(((uint64_t)this_arg) & ~1);
7555         LDKCVec_MessageSendEventZ ret_var = (this_arg_conv->get_and_clear_pending_msg_events)(this_arg_conv->this_arg);
7556         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
7557         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
7558         for (size_t s = 0; s < ret_var.datalen; s++) {
7559                 LDKMessageSendEvent *ret_conv_18_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
7560                 *ret_conv_18_copy = MessageSendEvent_clone(&ret_var.data[s]);
7561                 uint64_t ret_conv_18_ref = (uint64_t)ret_conv_18_copy;
7562                 ret_arr_ptr[s] = ret_conv_18_ref;
7563         }
7564         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
7565         FREE(ret_var.data);
7566         return ret_arr;
7567 }
7568
7569 typedef struct LDKEventHandler_JCalls {
7570         atomic_size_t refcnt;
7571         JavaVM *vm;
7572         jweak o;
7573         jmethodID handle_event_meth;
7574 } LDKEventHandler_JCalls;
7575 static void LDKEventHandler_JCalls_free(void* this_arg) {
7576         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
7577         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7578                 JNIEnv *env;
7579                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7580                 if (get_jenv_res == JNI_EDETACHED) {
7581                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7582                 } else {
7583                         DO_ASSERT(get_jenv_res == JNI_OK);
7584                 }
7585                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
7586                 if (get_jenv_res == JNI_EDETACHED) {
7587                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7588                 }
7589                 FREE(j_calls);
7590         }
7591 }
7592 void handle_event_LDKEventHandler_jcall(const void* this_arg, const LDKEvent * event) {
7593         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
7594         JNIEnv *env;
7595         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7596         if (get_jenv_res == JNI_EDETACHED) {
7597                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7598         } else {
7599                 DO_ASSERT(get_jenv_res == JNI_OK);
7600         }
7601         LDKEvent *ret_event = MALLOC(sizeof(LDKEvent), "LDKEvent ret conversion");
7602         *ret_event = Event_clone(event);
7603         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7604         CHECK(obj != NULL);
7605         (*env)->CallVoidMethod(env, obj, j_calls->handle_event_meth, (uint64_t)ret_event);
7606         if ((*env)->ExceptionCheck(env)) {
7607                 (*env)->ExceptionDescribe(env);
7608                 (*env)->FatalError(env, "A call to handle_event in LDKEventHandler from rust threw an exception.");
7609         }
7610         if (get_jenv_res == JNI_EDETACHED) {
7611                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7612         }
7613 }
7614 static void LDKEventHandler_JCalls_cloned(LDKEventHandler* new_obj) {
7615         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) new_obj->this_arg;
7616         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7617 }
7618 static inline LDKEventHandler LDKEventHandler_init (JNIEnv *env, jclass clz, jobject o) {
7619         jclass c = (*env)->GetObjectClass(env, o);
7620         CHECK(c != NULL);
7621         LDKEventHandler_JCalls *calls = MALLOC(sizeof(LDKEventHandler_JCalls), "LDKEventHandler_JCalls");
7622         atomic_init(&calls->refcnt, 1);
7623         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
7624         calls->o = (*env)->NewWeakGlobalRef(env, o);
7625         calls->handle_event_meth = (*env)->GetMethodID(env, c, "handle_event", "(J)V");
7626         CHECK(calls->handle_event_meth != NULL);
7627
7628         LDKEventHandler ret = {
7629                 .this_arg = (void*) calls,
7630                 .handle_event = handle_event_LDKEventHandler_jcall,
7631                 .free = LDKEventHandler_JCalls_free,
7632         };
7633         return ret;
7634 }
7635 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKEventHandler_1new(JNIEnv *env, jclass clz, jobject o) {
7636         LDKEventHandler *res_ptr = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
7637         *res_ptr = LDKEventHandler_init(env, clz, o);
7638         return (uint64_t)res_ptr;
7639 }
7640 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventHandler_1handle_1event(JNIEnv *env, jclass clz, int64_t this_arg, int64_t event) {
7641         LDKEventHandler* this_arg_conv = (LDKEventHandler*)(((uint64_t)this_arg) & ~1);
7642         LDKEvent* event_conv = (LDKEvent*)event;
7643         (this_arg_conv->handle_event)(this_arg_conv->this_arg, event_conv);
7644 }
7645
7646 typedef struct LDKEventsProvider_JCalls {
7647         atomic_size_t refcnt;
7648         JavaVM *vm;
7649         jweak o;
7650         jmethodID process_pending_events_meth;
7651 } LDKEventsProvider_JCalls;
7652 static void LDKEventsProvider_JCalls_free(void* this_arg) {
7653         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
7654         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7655                 JNIEnv *env;
7656                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7657                 if (get_jenv_res == JNI_EDETACHED) {
7658                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7659                 } else {
7660                         DO_ASSERT(get_jenv_res == JNI_OK);
7661                 }
7662                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
7663                 if (get_jenv_res == JNI_EDETACHED) {
7664                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7665                 }
7666                 FREE(j_calls);
7667         }
7668 }
7669 void process_pending_events_LDKEventsProvider_jcall(const void* this_arg, LDKEventHandler handler) {
7670         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
7671         JNIEnv *env;
7672         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7673         if (get_jenv_res == JNI_EDETACHED) {
7674                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7675         } else {
7676                 DO_ASSERT(get_jenv_res == JNI_OK);
7677         }
7678         LDKEventHandler* handler_ret =MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
7679         *handler_ret = handler;
7680         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7681         CHECK(obj != NULL);
7682         (*env)->CallVoidMethod(env, obj, j_calls->process_pending_events_meth, (uint64_t)handler_ret);
7683         if ((*env)->ExceptionCheck(env)) {
7684                 (*env)->ExceptionDescribe(env);
7685                 (*env)->FatalError(env, "A call to process_pending_events in LDKEventsProvider from rust threw an exception.");
7686         }
7687         if (get_jenv_res == JNI_EDETACHED) {
7688                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7689         }
7690 }
7691 static void LDKEventsProvider_JCalls_cloned(LDKEventsProvider* new_obj) {
7692         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) new_obj->this_arg;
7693         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7694 }
7695 static inline LDKEventsProvider LDKEventsProvider_init (JNIEnv *env, jclass clz, jobject o) {
7696         jclass c = (*env)->GetObjectClass(env, o);
7697         CHECK(c != NULL);
7698         LDKEventsProvider_JCalls *calls = MALLOC(sizeof(LDKEventsProvider_JCalls), "LDKEventsProvider_JCalls");
7699         atomic_init(&calls->refcnt, 1);
7700         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
7701         calls->o = (*env)->NewWeakGlobalRef(env, o);
7702         calls->process_pending_events_meth = (*env)->GetMethodID(env, c, "process_pending_events", "(J)V");
7703         CHECK(calls->process_pending_events_meth != NULL);
7704
7705         LDKEventsProvider ret = {
7706                 .this_arg = (void*) calls,
7707                 .process_pending_events = process_pending_events_LDKEventsProvider_jcall,
7708                 .free = LDKEventsProvider_JCalls_free,
7709         };
7710         return ret;
7711 }
7712 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKEventsProvider_1new(JNIEnv *env, jclass clz, jobject o) {
7713         LDKEventsProvider *res_ptr = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
7714         *res_ptr = LDKEventsProvider_init(env, clz, o);
7715         return (uint64_t)res_ptr;
7716 }
7717 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventsProvider_1process_1pending_1events(JNIEnv *env, jclass clz, int64_t this_arg, int64_t handler) {
7718         LDKEventsProvider* this_arg_conv = (LDKEventsProvider*)(((uint64_t)this_arg) & ~1);
7719         LDKEventHandler handler_conv = *(LDKEventHandler*)(((uint64_t)handler) & ~1);
7720         if (handler_conv.free == LDKEventHandler_JCalls_free) {
7721                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
7722                 LDKEventHandler_JCalls_cloned(&handler_conv);
7723         }
7724         (this_arg_conv->process_pending_events)(this_arg_conv->this_arg, handler_conv);
7725 }
7726
7727 typedef struct LDKListen_JCalls {
7728         atomic_size_t refcnt;
7729         JavaVM *vm;
7730         jweak o;
7731         jmethodID block_connected_meth;
7732         jmethodID block_disconnected_meth;
7733 } LDKListen_JCalls;
7734 static void LDKListen_JCalls_free(void* this_arg) {
7735         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
7736         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7737                 JNIEnv *env;
7738                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7739                 if (get_jenv_res == JNI_EDETACHED) {
7740                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7741                 } else {
7742                         DO_ASSERT(get_jenv_res == JNI_OK);
7743                 }
7744                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
7745                 if (get_jenv_res == JNI_EDETACHED) {
7746                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7747                 }
7748                 FREE(j_calls);
7749         }
7750 }
7751 void block_connected_LDKListen_jcall(const void* this_arg, LDKu8slice block, uint32_t height) {
7752         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
7753         JNIEnv *env;
7754         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7755         if (get_jenv_res == JNI_EDETACHED) {
7756                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7757         } else {
7758                 DO_ASSERT(get_jenv_res == JNI_OK);
7759         }
7760         LDKu8slice block_var = block;
7761         int8_tArray block_arr = (*env)->NewByteArray(env, block_var.datalen);
7762         (*env)->SetByteArrayRegion(env, block_arr, 0, block_var.datalen, block_var.data);
7763         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7764         CHECK(obj != NULL);
7765         (*env)->CallVoidMethod(env, obj, j_calls->block_connected_meth, block_arr, height);
7766         if ((*env)->ExceptionCheck(env)) {
7767                 (*env)->ExceptionDescribe(env);
7768                 (*env)->FatalError(env, "A call to block_connected in LDKListen from rust threw an exception.");
7769         }
7770         if (get_jenv_res == JNI_EDETACHED) {
7771                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7772         }
7773 }
7774 void block_disconnected_LDKListen_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
7775         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
7776         JNIEnv *env;
7777         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7778         if (get_jenv_res == JNI_EDETACHED) {
7779                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7780         } else {
7781                 DO_ASSERT(get_jenv_res == JNI_OK);
7782         }
7783         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
7784         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
7785         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7786         CHECK(obj != NULL);
7787         (*env)->CallVoidMethod(env, obj, j_calls->block_disconnected_meth, header_arr, height);
7788         if ((*env)->ExceptionCheck(env)) {
7789                 (*env)->ExceptionDescribe(env);
7790                 (*env)->FatalError(env, "A call to block_disconnected in LDKListen from rust threw an exception.");
7791         }
7792         if (get_jenv_res == JNI_EDETACHED) {
7793                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7794         }
7795 }
7796 static void LDKListen_JCalls_cloned(LDKListen* new_obj) {
7797         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) new_obj->this_arg;
7798         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7799 }
7800 static inline LDKListen LDKListen_init (JNIEnv *env, jclass clz, jobject o) {
7801         jclass c = (*env)->GetObjectClass(env, o);
7802         CHECK(c != NULL);
7803         LDKListen_JCalls *calls = MALLOC(sizeof(LDKListen_JCalls), "LDKListen_JCalls");
7804         atomic_init(&calls->refcnt, 1);
7805         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
7806         calls->o = (*env)->NewWeakGlobalRef(env, o);
7807         calls->block_connected_meth = (*env)->GetMethodID(env, c, "block_connected", "([BI)V");
7808         CHECK(calls->block_connected_meth != NULL);
7809         calls->block_disconnected_meth = (*env)->GetMethodID(env, c, "block_disconnected", "([BI)V");
7810         CHECK(calls->block_disconnected_meth != NULL);
7811
7812         LDKListen ret = {
7813                 .this_arg = (void*) calls,
7814                 .block_connected = block_connected_LDKListen_jcall,
7815                 .block_disconnected = block_disconnected_LDKListen_jcall,
7816                 .free = LDKListen_JCalls_free,
7817         };
7818         return ret;
7819 }
7820 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKListen_1new(JNIEnv *env, jclass clz, jobject o) {
7821         LDKListen *res_ptr = MALLOC(sizeof(LDKListen), "LDKListen");
7822         *res_ptr = LDKListen_init(env, clz, o);
7823         return (uint64_t)res_ptr;
7824 }
7825 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) {
7826         LDKListen* this_arg_conv = (LDKListen*)(((uint64_t)this_arg) & ~1);
7827         LDKu8slice block_ref;
7828         block_ref.datalen = (*env)->GetArrayLength(env, block);
7829         block_ref.data = (*env)->GetByteArrayElements (env, block, NULL);
7830         (this_arg_conv->block_connected)(this_arg_conv->this_arg, block_ref, height);
7831         (*env)->ReleaseByteArrayElements(env, block, (int8_t*)block_ref.data, 0);
7832 }
7833
7834 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) {
7835         LDKListen* this_arg_conv = (LDKListen*)(((uint64_t)this_arg) & ~1);
7836         unsigned char header_arr[80];
7837         CHECK((*env)->GetArrayLength(env, header) == 80);
7838         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
7839         unsigned char (*header_ref)[80] = &header_arr;
7840         (this_arg_conv->block_disconnected)(this_arg_conv->this_arg, header_ref, height);
7841 }
7842
7843 typedef struct LDKConfirm_JCalls {
7844         atomic_size_t refcnt;
7845         JavaVM *vm;
7846         jweak o;
7847         jmethodID transactions_confirmed_meth;
7848         jmethodID transaction_unconfirmed_meth;
7849         jmethodID best_block_updated_meth;
7850         jmethodID get_relevant_txids_meth;
7851 } LDKConfirm_JCalls;
7852 static void LDKConfirm_JCalls_free(void* this_arg) {
7853         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
7854         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7855                 JNIEnv *env;
7856                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7857                 if (get_jenv_res == JNI_EDETACHED) {
7858                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7859                 } else {
7860                         DO_ASSERT(get_jenv_res == JNI_OK);
7861                 }
7862                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
7863                 if (get_jenv_res == JNI_EDETACHED) {
7864                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7865                 }
7866                 FREE(j_calls);
7867         }
7868 }
7869 void transactions_confirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height) {
7870         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
7871         JNIEnv *env;
7872         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7873         if (get_jenv_res == JNI_EDETACHED) {
7874                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7875         } else {
7876                 DO_ASSERT(get_jenv_res == JNI_OK);
7877         }
7878         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
7879         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
7880         LDKCVec_C2Tuple_usizeTransactionZZ txdata_var = txdata;
7881         int64_tArray txdata_arr = (*env)->NewLongArray(env, txdata_var.datalen);
7882         int64_t *txdata_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, txdata_arr, NULL);
7883         for (size_t c = 0; c < txdata_var.datalen; c++) {
7884                 LDKC2Tuple_usizeTransactionZ* txdata_conv_28_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
7885                 *txdata_conv_28_conv = txdata_var.data[c];
7886                 txdata_arr_ptr[c] = ((uint64_t)txdata_conv_28_conv);
7887         }
7888         (*env)->ReleasePrimitiveArrayCritical(env, txdata_arr, txdata_arr_ptr, 0);
7889         FREE(txdata_var.data);
7890         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7891         CHECK(obj != NULL);
7892         (*env)->CallVoidMethod(env, obj, j_calls->transactions_confirmed_meth, header_arr, txdata_arr, height);
7893         if ((*env)->ExceptionCheck(env)) {
7894                 (*env)->ExceptionDescribe(env);
7895                 (*env)->FatalError(env, "A call to transactions_confirmed in LDKConfirm from rust threw an exception.");
7896         }
7897         if (get_jenv_res == JNI_EDETACHED) {
7898                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7899         }
7900 }
7901 void transaction_unconfirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* txid)[32]) {
7902         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
7903         JNIEnv *env;
7904         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7905         if (get_jenv_res == JNI_EDETACHED) {
7906                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7907         } else {
7908                 DO_ASSERT(get_jenv_res == JNI_OK);
7909         }
7910         int8_tArray txid_arr = (*env)->NewByteArray(env, 32);
7911         (*env)->SetByteArrayRegion(env, txid_arr, 0, 32, *txid);
7912         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7913         CHECK(obj != NULL);
7914         (*env)->CallVoidMethod(env, obj, j_calls->transaction_unconfirmed_meth, txid_arr);
7915         if ((*env)->ExceptionCheck(env)) {
7916                 (*env)->ExceptionDescribe(env);
7917                 (*env)->FatalError(env, "A call to transaction_unconfirmed in LDKConfirm from rust threw an exception.");
7918         }
7919         if (get_jenv_res == JNI_EDETACHED) {
7920                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7921         }
7922 }
7923 void best_block_updated_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
7924         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
7925         JNIEnv *env;
7926         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7927         if (get_jenv_res == JNI_EDETACHED) {
7928                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7929         } else {
7930                 DO_ASSERT(get_jenv_res == JNI_OK);
7931         }
7932         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
7933         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
7934         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7935         CHECK(obj != NULL);
7936         (*env)->CallVoidMethod(env, obj, j_calls->best_block_updated_meth, header_arr, height);
7937         if ((*env)->ExceptionCheck(env)) {
7938                 (*env)->ExceptionDescribe(env);
7939                 (*env)->FatalError(env, "A call to best_block_updated in LDKConfirm from rust threw an exception.");
7940         }
7941         if (get_jenv_res == JNI_EDETACHED) {
7942                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7943         }
7944 }
7945 LDKCVec_TxidZ get_relevant_txids_LDKConfirm_jcall(const void* this_arg) {
7946         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
7947         JNIEnv *env;
7948         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7949         if (get_jenv_res == JNI_EDETACHED) {
7950                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7951         } else {
7952                 DO_ASSERT(get_jenv_res == JNI_OK);
7953         }
7954         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7955         CHECK(obj != NULL);
7956         jobjectArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_relevant_txids_meth);
7957         if ((*env)->ExceptionCheck(env)) {
7958                 (*env)->ExceptionDescribe(env);
7959                 (*env)->FatalError(env, "A call to get_relevant_txids in LDKConfirm from rust threw an exception.");
7960         }
7961         LDKCVec_TxidZ ret_constr;
7962         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
7963         if (ret_constr.datalen > 0)
7964                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
7965         else
7966                 ret_constr.data = NULL;
7967         for (size_t i = 0; i < ret_constr.datalen; i++) {
7968                 int8_tArray ret_conv_8 = (*env)->GetObjectArrayElement(env, ret, i);
7969                 LDKThirtyTwoBytes ret_conv_8_ref;
7970                 CHECK((*env)->GetArrayLength(env, ret_conv_8) == 32);
7971                 (*env)->GetByteArrayRegion(env, ret_conv_8, 0, 32, ret_conv_8_ref.data);
7972                 ret_constr.data[i] = ret_conv_8_ref;
7973         }
7974         if (get_jenv_res == JNI_EDETACHED) {
7975                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7976         }
7977         return ret_constr;
7978 }
7979 static void LDKConfirm_JCalls_cloned(LDKConfirm* new_obj) {
7980         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) new_obj->this_arg;
7981         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7982 }
7983 static inline LDKConfirm LDKConfirm_init (JNIEnv *env, jclass clz, jobject o) {
7984         jclass c = (*env)->GetObjectClass(env, o);
7985         CHECK(c != NULL);
7986         LDKConfirm_JCalls *calls = MALLOC(sizeof(LDKConfirm_JCalls), "LDKConfirm_JCalls");
7987         atomic_init(&calls->refcnt, 1);
7988         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
7989         calls->o = (*env)->NewWeakGlobalRef(env, o);
7990         calls->transactions_confirmed_meth = (*env)->GetMethodID(env, c, "transactions_confirmed", "([B[JI)V");
7991         CHECK(calls->transactions_confirmed_meth != NULL);
7992         calls->transaction_unconfirmed_meth = (*env)->GetMethodID(env, c, "transaction_unconfirmed", "([B)V");
7993         CHECK(calls->transaction_unconfirmed_meth != NULL);
7994         calls->best_block_updated_meth = (*env)->GetMethodID(env, c, "best_block_updated", "([BI)V");
7995         CHECK(calls->best_block_updated_meth != NULL);
7996         calls->get_relevant_txids_meth = (*env)->GetMethodID(env, c, "get_relevant_txids", "()[[B");
7997         CHECK(calls->get_relevant_txids_meth != NULL);
7998
7999         LDKConfirm ret = {
8000                 .this_arg = (void*) calls,
8001                 .transactions_confirmed = transactions_confirmed_LDKConfirm_jcall,
8002                 .transaction_unconfirmed = transaction_unconfirmed_LDKConfirm_jcall,
8003                 .best_block_updated = best_block_updated_LDKConfirm_jcall,
8004                 .get_relevant_txids = get_relevant_txids_LDKConfirm_jcall,
8005                 .free = LDKConfirm_JCalls_free,
8006         };
8007         return ret;
8008 }
8009 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKConfirm_1new(JNIEnv *env, jclass clz, jobject o) {
8010         LDKConfirm *res_ptr = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
8011         *res_ptr = LDKConfirm_init(env, clz, o);
8012         return (uint64_t)res_ptr;
8013 }
8014 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) {
8015         LDKConfirm* this_arg_conv = (LDKConfirm*)(((uint64_t)this_arg) & ~1);
8016         unsigned char header_arr[80];
8017         CHECK((*env)->GetArrayLength(env, header) == 80);
8018         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
8019         unsigned char (*header_ref)[80] = &header_arr;
8020         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
8021         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
8022         if (txdata_constr.datalen > 0)
8023                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
8024         else
8025                 txdata_constr.data = NULL;
8026         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
8027         for (size_t c = 0; c < txdata_constr.datalen; c++) {
8028                 int64_t txdata_conv_28 = txdata_vals[c];
8029                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_28) & ~1);
8030                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_28) & ~1));
8031                 txdata_constr.data[c] = txdata_conv_28_conv;
8032         }
8033         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
8034         (this_arg_conv->transactions_confirmed)(this_arg_conv->this_arg, header_ref, txdata_constr, height);
8035 }
8036
8037 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Confirm_1transaction_1unconfirmed(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray txid) {
8038         LDKConfirm* this_arg_conv = (LDKConfirm*)(((uint64_t)this_arg) & ~1);
8039         unsigned char txid_arr[32];
8040         CHECK((*env)->GetArrayLength(env, txid) == 32);
8041         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
8042         unsigned char (*txid_ref)[32] = &txid_arr;
8043         (this_arg_conv->transaction_unconfirmed)(this_arg_conv->this_arg, txid_ref);
8044 }
8045
8046 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) {
8047         LDKConfirm* this_arg_conv = (LDKConfirm*)(((uint64_t)this_arg) & ~1);
8048         unsigned char header_arr[80];
8049         CHECK((*env)->GetArrayLength(env, header) == 80);
8050         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
8051         unsigned char (*header_ref)[80] = &header_arr;
8052         (this_arg_conv->best_block_updated)(this_arg_conv->this_arg, header_ref, height);
8053 }
8054
8055 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_Confirm_1get_1relevant_1txids(JNIEnv *env, jclass clz, int64_t this_arg) {
8056         LDKConfirm* this_arg_conv = (LDKConfirm*)(((uint64_t)this_arg) & ~1);
8057         LDKCVec_TxidZ ret_var = (this_arg_conv->get_relevant_txids)(this_arg_conv->this_arg);
8058         jobjectArray ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
8059         ;
8060         for (size_t i = 0; i < ret_var.datalen; i++) {
8061                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 32);
8062                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 32, ret_var.data[i].data);
8063                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
8064         }
8065         FREE(ret_var.data);
8066         return ret_arr;
8067 }
8068
8069 typedef struct LDKPersist_JCalls {
8070         atomic_size_t refcnt;
8071         JavaVM *vm;
8072         jweak o;
8073         jmethodID persist_new_channel_meth;
8074         jmethodID update_persisted_channel_meth;
8075 } LDKPersist_JCalls;
8076 static void LDKPersist_JCalls_free(void* this_arg) {
8077         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
8078         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8079                 JNIEnv *env;
8080                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8081                 if (get_jenv_res == JNI_EDETACHED) {
8082                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8083                 } else {
8084                         DO_ASSERT(get_jenv_res == JNI_OK);
8085                 }
8086                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
8087                 if (get_jenv_res == JNI_EDETACHED) {
8088                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8089                 }
8090                 FREE(j_calls);
8091         }
8092 }
8093 LDKCResult_NoneChannelMonitorUpdateErrZ persist_new_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint id, const LDKChannelMonitor * data) {
8094         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
8095         JNIEnv *env;
8096         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8097         if (get_jenv_res == JNI_EDETACHED) {
8098                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8099         } else {
8100                 DO_ASSERT(get_jenv_res == JNI_OK);
8101         }
8102         LDKOutPoint id_var = id;
8103         CHECK((((uint64_t)id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8104         CHECK((((uint64_t)&id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8105         uint64_t id_ref = (uint64_t)id_var.inner;
8106         if (id_var.is_owned) {
8107                 id_ref |= 1;
8108         }
8109         LDKChannelMonitor data_var = *data;
8110         data_var = ChannelMonitor_clone(data);
8111         CHECK((((uint64_t)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8112         CHECK((((uint64_t)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8113         uint64_t data_ref = (uint64_t)data_var.inner;
8114         if (data_var.is_owned) {
8115                 data_ref |= 1;
8116         }
8117         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8118         CHECK(obj != NULL);
8119         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->persist_new_channel_meth, id_ref, data_ref);
8120         if ((*env)->ExceptionCheck(env)) {
8121                 (*env)->ExceptionDescribe(env);
8122                 (*env)->FatalError(env, "A call to persist_new_channel in LDKPersist from rust threw an exception.");
8123         }
8124         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
8125         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
8126         if (get_jenv_res == JNI_EDETACHED) {
8127                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8128         }
8129         return ret_conv;
8130 }
8131 LDKCResult_NoneChannelMonitorUpdateErrZ update_persisted_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint id, const LDKChannelMonitorUpdate * update, const LDKChannelMonitor * data) {
8132         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
8133         JNIEnv *env;
8134         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8135         if (get_jenv_res == JNI_EDETACHED) {
8136                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8137         } else {
8138                 DO_ASSERT(get_jenv_res == JNI_OK);
8139         }
8140         LDKOutPoint id_var = id;
8141         CHECK((((uint64_t)id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8142         CHECK((((uint64_t)&id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8143         uint64_t id_ref = (uint64_t)id_var.inner;
8144         if (id_var.is_owned) {
8145                 id_ref |= 1;
8146         }
8147         LDKChannelMonitorUpdate update_var = *update;
8148         update_var = ChannelMonitorUpdate_clone(update);
8149         CHECK((((uint64_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8150         CHECK((((uint64_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8151         uint64_t update_ref = (uint64_t)update_var.inner;
8152         if (update_var.is_owned) {
8153                 update_ref |= 1;
8154         }
8155         LDKChannelMonitor data_var = *data;
8156         data_var = ChannelMonitor_clone(data);
8157         CHECK((((uint64_t)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8158         CHECK((((uint64_t)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8159         uint64_t data_ref = (uint64_t)data_var.inner;
8160         if (data_var.is_owned) {
8161                 data_ref |= 1;
8162         }
8163         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8164         CHECK(obj != NULL);
8165         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->update_persisted_channel_meth, id_ref, update_ref, data_ref);
8166         if ((*env)->ExceptionCheck(env)) {
8167                 (*env)->ExceptionDescribe(env);
8168                 (*env)->FatalError(env, "A call to update_persisted_channel in LDKPersist from rust threw an exception.");
8169         }
8170         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
8171         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
8172         if (get_jenv_res == JNI_EDETACHED) {
8173                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8174         }
8175         return ret_conv;
8176 }
8177 static void LDKPersist_JCalls_cloned(LDKPersist* new_obj) {
8178         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) new_obj->this_arg;
8179         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8180 }
8181 static inline LDKPersist LDKPersist_init (JNIEnv *env, jclass clz, jobject o) {
8182         jclass c = (*env)->GetObjectClass(env, o);
8183         CHECK(c != NULL);
8184         LDKPersist_JCalls *calls = MALLOC(sizeof(LDKPersist_JCalls), "LDKPersist_JCalls");
8185         atomic_init(&calls->refcnt, 1);
8186         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
8187         calls->o = (*env)->NewWeakGlobalRef(env, o);
8188         calls->persist_new_channel_meth = (*env)->GetMethodID(env, c, "persist_new_channel", "(JJ)J");
8189         CHECK(calls->persist_new_channel_meth != NULL);
8190         calls->update_persisted_channel_meth = (*env)->GetMethodID(env, c, "update_persisted_channel", "(JJJ)J");
8191         CHECK(calls->update_persisted_channel_meth != NULL);
8192
8193         LDKPersist ret = {
8194                 .this_arg = (void*) calls,
8195                 .persist_new_channel = persist_new_channel_LDKPersist_jcall,
8196                 .update_persisted_channel = update_persisted_channel_LDKPersist_jcall,
8197                 .free = LDKPersist_JCalls_free,
8198         };
8199         return ret;
8200 }
8201 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKPersist_1new(JNIEnv *env, jclass clz, jobject o) {
8202         LDKPersist *res_ptr = MALLOC(sizeof(LDKPersist), "LDKPersist");
8203         *res_ptr = LDKPersist_init(env, clz, o);
8204         return (uint64_t)res_ptr;
8205 }
8206 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) {
8207         LDKPersist* this_arg_conv = (LDKPersist*)(((uint64_t)this_arg) & ~1);
8208         LDKOutPoint id_conv;
8209         id_conv.inner = (void*)(id & (~1));
8210         id_conv.is_owned = (id & 1) || (id == 0);
8211         id_conv = OutPoint_clone(&id_conv);
8212         LDKChannelMonitor data_conv;
8213         data_conv.inner = (void*)(data & (~1));
8214         data_conv.is_owned = false;
8215         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
8216         *ret_conv = (this_arg_conv->persist_new_channel)(this_arg_conv->this_arg, id_conv, &data_conv);
8217         return (uint64_t)ret_conv;
8218 }
8219
8220 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) {
8221         LDKPersist* this_arg_conv = (LDKPersist*)(((uint64_t)this_arg) & ~1);
8222         LDKOutPoint id_conv;
8223         id_conv.inner = (void*)(id & (~1));
8224         id_conv.is_owned = (id & 1) || (id == 0);
8225         id_conv = OutPoint_clone(&id_conv);
8226         LDKChannelMonitorUpdate update_conv;
8227         update_conv.inner = (void*)(update & (~1));
8228         update_conv.is_owned = false;
8229         LDKChannelMonitor data_conv;
8230         data_conv.inner = (void*)(data & (~1));
8231         data_conv.is_owned = false;
8232         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
8233         *ret_conv = (this_arg_conv->update_persisted_channel)(this_arg_conv->this_arg, id_conv, &update_conv, &data_conv);
8234         return (uint64_t)ret_conv;
8235 }
8236
8237 typedef struct LDKChannelMessageHandler_JCalls {
8238         atomic_size_t refcnt;
8239         JavaVM *vm;
8240         jweak o;
8241         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
8242         jmethodID handle_open_channel_meth;
8243         jmethodID handle_accept_channel_meth;
8244         jmethodID handle_funding_created_meth;
8245         jmethodID handle_funding_signed_meth;
8246         jmethodID handle_funding_locked_meth;
8247         jmethodID handle_shutdown_meth;
8248         jmethodID handle_closing_signed_meth;
8249         jmethodID handle_update_add_htlc_meth;
8250         jmethodID handle_update_fulfill_htlc_meth;
8251         jmethodID handle_update_fail_htlc_meth;
8252         jmethodID handle_update_fail_malformed_htlc_meth;
8253         jmethodID handle_commitment_signed_meth;
8254         jmethodID handle_revoke_and_ack_meth;
8255         jmethodID handle_update_fee_meth;
8256         jmethodID handle_announcement_signatures_meth;
8257         jmethodID peer_disconnected_meth;
8258         jmethodID peer_connected_meth;
8259         jmethodID handle_channel_reestablish_meth;
8260         jmethodID handle_channel_update_meth;
8261         jmethodID handle_error_meth;
8262 } LDKChannelMessageHandler_JCalls;
8263 static void LDKChannelMessageHandler_JCalls_free(void* this_arg) {
8264         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8265         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8266                 JNIEnv *env;
8267                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8268                 if (get_jenv_res == JNI_EDETACHED) {
8269                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8270                 } else {
8271                         DO_ASSERT(get_jenv_res == JNI_OK);
8272                 }
8273                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
8274                 if (get_jenv_res == JNI_EDETACHED) {
8275                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8276                 }
8277                 FREE(j_calls);
8278         }
8279 }
8280 void handle_open_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKOpenChannel * msg) {
8281         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8282         JNIEnv *env;
8283         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8284         if (get_jenv_res == JNI_EDETACHED) {
8285                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8286         } else {
8287                 DO_ASSERT(get_jenv_res == JNI_OK);
8288         }
8289         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8290         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8291         LDKInitFeatures their_features_var = their_features;
8292         CHECK((((uint64_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8293         CHECK((((uint64_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8294         uint64_t their_features_ref = (uint64_t)their_features_var.inner;
8295         if (their_features_var.is_owned) {
8296                 their_features_ref |= 1;
8297         }
8298         LDKOpenChannel msg_var = *msg;
8299         msg_var = OpenChannel_clone(msg);
8300         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8301         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8302         uint64_t msg_ref = (uint64_t)msg_var.inner;
8303         if (msg_var.is_owned) {
8304                 msg_ref |= 1;
8305         }
8306         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8307         CHECK(obj != NULL);
8308         (*env)->CallVoidMethod(env, obj, j_calls->handle_open_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
8309         if ((*env)->ExceptionCheck(env)) {
8310                 (*env)->ExceptionDescribe(env);
8311                 (*env)->FatalError(env, "A call to handle_open_channel in LDKChannelMessageHandler from rust threw an exception.");
8312         }
8313         if (get_jenv_res == JNI_EDETACHED) {
8314                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8315         }
8316 }
8317 void handle_accept_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKAcceptChannel * msg) {
8318         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8319         JNIEnv *env;
8320         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8321         if (get_jenv_res == JNI_EDETACHED) {
8322                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8323         } else {
8324                 DO_ASSERT(get_jenv_res == JNI_OK);
8325         }
8326         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8327         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8328         LDKInitFeatures their_features_var = their_features;
8329         CHECK((((uint64_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8330         CHECK((((uint64_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8331         uint64_t their_features_ref = (uint64_t)their_features_var.inner;
8332         if (their_features_var.is_owned) {
8333                 their_features_ref |= 1;
8334         }
8335         LDKAcceptChannel msg_var = *msg;
8336         msg_var = AcceptChannel_clone(msg);
8337         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8338         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8339         uint64_t msg_ref = (uint64_t)msg_var.inner;
8340         if (msg_var.is_owned) {
8341                 msg_ref |= 1;
8342         }
8343         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8344         CHECK(obj != NULL);
8345         (*env)->CallVoidMethod(env, obj, j_calls->handle_accept_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
8346         if ((*env)->ExceptionCheck(env)) {
8347                 (*env)->ExceptionDescribe(env);
8348                 (*env)->FatalError(env, "A call to handle_accept_channel in LDKChannelMessageHandler from rust threw an exception.");
8349         }
8350         if (get_jenv_res == JNI_EDETACHED) {
8351                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8352         }
8353 }
8354 void handle_funding_created_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingCreated * msg) {
8355         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8356         JNIEnv *env;
8357         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8358         if (get_jenv_res == JNI_EDETACHED) {
8359                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8360         } else {
8361                 DO_ASSERT(get_jenv_res == JNI_OK);
8362         }
8363         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8364         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8365         LDKFundingCreated msg_var = *msg;
8366         msg_var = FundingCreated_clone(msg);
8367         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8368         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8369         uint64_t msg_ref = (uint64_t)msg_var.inner;
8370         if (msg_var.is_owned) {
8371                 msg_ref |= 1;
8372         }
8373         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8374         CHECK(obj != NULL);
8375         (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_created_meth, their_node_id_arr, msg_ref);
8376         if ((*env)->ExceptionCheck(env)) {
8377                 (*env)->ExceptionDescribe(env);
8378                 (*env)->FatalError(env, "A call to handle_funding_created in LDKChannelMessageHandler from rust threw an exception.");
8379         }
8380         if (get_jenv_res == JNI_EDETACHED) {
8381                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8382         }
8383 }
8384 void handle_funding_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingSigned * msg) {
8385         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8386         JNIEnv *env;
8387         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8388         if (get_jenv_res == JNI_EDETACHED) {
8389                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8390         } else {
8391                 DO_ASSERT(get_jenv_res == JNI_OK);
8392         }
8393         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8394         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8395         LDKFundingSigned msg_var = *msg;
8396         msg_var = FundingSigned_clone(msg);
8397         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8398         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8399         uint64_t msg_ref = (uint64_t)msg_var.inner;
8400         if (msg_var.is_owned) {
8401                 msg_ref |= 1;
8402         }
8403         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8404         CHECK(obj != NULL);
8405         (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_signed_meth, their_node_id_arr, msg_ref);
8406         if ((*env)->ExceptionCheck(env)) {
8407                 (*env)->ExceptionDescribe(env);
8408                 (*env)->FatalError(env, "A call to handle_funding_signed in LDKChannelMessageHandler from rust threw an exception.");
8409         }
8410         if (get_jenv_res == JNI_EDETACHED) {
8411                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8412         }
8413 }
8414 void handle_funding_locked_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingLocked * msg) {
8415         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8416         JNIEnv *env;
8417         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8418         if (get_jenv_res == JNI_EDETACHED) {
8419                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8420         } else {
8421                 DO_ASSERT(get_jenv_res == JNI_OK);
8422         }
8423         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8424         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8425         LDKFundingLocked msg_var = *msg;
8426         msg_var = FundingLocked_clone(msg);
8427         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8428         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8429         uint64_t msg_ref = (uint64_t)msg_var.inner;
8430         if (msg_var.is_owned) {
8431                 msg_ref |= 1;
8432         }
8433         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8434         CHECK(obj != NULL);
8435         (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_locked_meth, their_node_id_arr, msg_ref);
8436         if ((*env)->ExceptionCheck(env)) {
8437                 (*env)->ExceptionDescribe(env);
8438                 (*env)->FatalError(env, "A call to handle_funding_locked in LDKChannelMessageHandler from rust threw an exception.");
8439         }
8440         if (get_jenv_res == JNI_EDETACHED) {
8441                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8442         }
8443 }
8444 void handle_shutdown_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInitFeatures * their_features, const LDKShutdown * msg) {
8445         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8446         JNIEnv *env;
8447         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8448         if (get_jenv_res == JNI_EDETACHED) {
8449                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8450         } else {
8451                 DO_ASSERT(get_jenv_res == JNI_OK);
8452         }
8453         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8454         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8455         LDKInitFeatures their_features_var = *their_features;
8456         their_features_var = InitFeatures_clone(their_features);
8457         CHECK((((uint64_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8458         CHECK((((uint64_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8459         uint64_t their_features_ref = (uint64_t)their_features_var.inner;
8460         if (their_features_var.is_owned) {
8461                 their_features_ref |= 1;
8462         }
8463         LDKShutdown msg_var = *msg;
8464         msg_var = Shutdown_clone(msg);
8465         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8466         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8467         uint64_t msg_ref = (uint64_t)msg_var.inner;
8468         if (msg_var.is_owned) {
8469                 msg_ref |= 1;
8470         }
8471         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8472         CHECK(obj != NULL);
8473         (*env)->CallVoidMethod(env, obj, j_calls->handle_shutdown_meth, their_node_id_arr, their_features_ref, msg_ref);
8474         if ((*env)->ExceptionCheck(env)) {
8475                 (*env)->ExceptionDescribe(env);
8476                 (*env)->FatalError(env, "A call to handle_shutdown in LDKChannelMessageHandler from rust threw an exception.");
8477         }
8478         if (get_jenv_res == JNI_EDETACHED) {
8479                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8480         }
8481 }
8482 void handle_closing_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKClosingSigned * msg) {
8483         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8484         JNIEnv *env;
8485         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8486         if (get_jenv_res == JNI_EDETACHED) {
8487                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8488         } else {
8489                 DO_ASSERT(get_jenv_res == JNI_OK);
8490         }
8491         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8492         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8493         LDKClosingSigned msg_var = *msg;
8494         msg_var = ClosingSigned_clone(msg);
8495         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8496         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8497         uint64_t msg_ref = (uint64_t)msg_var.inner;
8498         if (msg_var.is_owned) {
8499                 msg_ref |= 1;
8500         }
8501         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8502         CHECK(obj != NULL);
8503         (*env)->CallVoidMethod(env, obj, j_calls->handle_closing_signed_meth, their_node_id_arr, msg_ref);
8504         if ((*env)->ExceptionCheck(env)) {
8505                 (*env)->ExceptionDescribe(env);
8506                 (*env)->FatalError(env, "A call to handle_closing_signed in LDKChannelMessageHandler from rust threw an exception.");
8507         }
8508         if (get_jenv_res == JNI_EDETACHED) {
8509                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8510         }
8511 }
8512 void handle_update_add_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateAddHTLC * msg) {
8513         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8514         JNIEnv *env;
8515         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8516         if (get_jenv_res == JNI_EDETACHED) {
8517                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8518         } else {
8519                 DO_ASSERT(get_jenv_res == JNI_OK);
8520         }
8521         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8522         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8523         LDKUpdateAddHTLC msg_var = *msg;
8524         msg_var = UpdateAddHTLC_clone(msg);
8525         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8526         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8527         uint64_t msg_ref = (uint64_t)msg_var.inner;
8528         if (msg_var.is_owned) {
8529                 msg_ref |= 1;
8530         }
8531         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8532         CHECK(obj != NULL);
8533         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_add_htlc_meth, their_node_id_arr, msg_ref);
8534         if ((*env)->ExceptionCheck(env)) {
8535                 (*env)->ExceptionDescribe(env);
8536                 (*env)->FatalError(env, "A call to handle_update_add_htlc in LDKChannelMessageHandler from rust threw an exception.");
8537         }
8538         if (get_jenv_res == JNI_EDETACHED) {
8539                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8540         }
8541 }
8542 void handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFulfillHTLC * msg) {
8543         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8544         JNIEnv *env;
8545         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8546         if (get_jenv_res == JNI_EDETACHED) {
8547                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8548         } else {
8549                 DO_ASSERT(get_jenv_res == JNI_OK);
8550         }
8551         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8552         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8553         LDKUpdateFulfillHTLC msg_var = *msg;
8554         msg_var = UpdateFulfillHTLC_clone(msg);
8555         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8556         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8557         uint64_t msg_ref = (uint64_t)msg_var.inner;
8558         if (msg_var.is_owned) {
8559                 msg_ref |= 1;
8560         }
8561         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8562         CHECK(obj != NULL);
8563         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fulfill_htlc_meth, their_node_id_arr, msg_ref);
8564         if ((*env)->ExceptionCheck(env)) {
8565                 (*env)->ExceptionDescribe(env);
8566                 (*env)->FatalError(env, "A call to handle_update_fulfill_htlc in LDKChannelMessageHandler from rust threw an exception.");
8567         }
8568         if (get_jenv_res == JNI_EDETACHED) {
8569                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8570         }
8571 }
8572 void handle_update_fail_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailHTLC * msg) {
8573         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8574         JNIEnv *env;
8575         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8576         if (get_jenv_res == JNI_EDETACHED) {
8577                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8578         } else {
8579                 DO_ASSERT(get_jenv_res == JNI_OK);
8580         }
8581         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8582         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8583         LDKUpdateFailHTLC msg_var = *msg;
8584         msg_var = UpdateFailHTLC_clone(msg);
8585         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8586         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8587         uint64_t msg_ref = (uint64_t)msg_var.inner;
8588         if (msg_var.is_owned) {
8589                 msg_ref |= 1;
8590         }
8591         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8592         CHECK(obj != NULL);
8593         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fail_htlc_meth, their_node_id_arr, msg_ref);
8594         if ((*env)->ExceptionCheck(env)) {
8595                 (*env)->ExceptionDescribe(env);
8596                 (*env)->FatalError(env, "A call to handle_update_fail_htlc in LDKChannelMessageHandler from rust threw an exception.");
8597         }
8598         if (get_jenv_res == JNI_EDETACHED) {
8599                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8600         }
8601 }
8602 void handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailMalformedHTLC * msg) {
8603         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8604         JNIEnv *env;
8605         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8606         if (get_jenv_res == JNI_EDETACHED) {
8607                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8608         } else {
8609                 DO_ASSERT(get_jenv_res == JNI_OK);
8610         }
8611         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8612         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8613         LDKUpdateFailMalformedHTLC msg_var = *msg;
8614         msg_var = UpdateFailMalformedHTLC_clone(msg);
8615         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8616         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8617         uint64_t msg_ref = (uint64_t)msg_var.inner;
8618         if (msg_var.is_owned) {
8619                 msg_ref |= 1;
8620         }
8621         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8622         CHECK(obj != NULL);
8623         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fail_malformed_htlc_meth, their_node_id_arr, msg_ref);
8624         if ((*env)->ExceptionCheck(env)) {
8625                 (*env)->ExceptionDescribe(env);
8626                 (*env)->FatalError(env, "A call to handle_update_fail_malformed_htlc in LDKChannelMessageHandler from rust threw an exception.");
8627         }
8628         if (get_jenv_res == JNI_EDETACHED) {
8629                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8630         }
8631 }
8632 void handle_commitment_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKCommitmentSigned * msg) {
8633         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8634         JNIEnv *env;
8635         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8636         if (get_jenv_res == JNI_EDETACHED) {
8637                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8638         } else {
8639                 DO_ASSERT(get_jenv_res == JNI_OK);
8640         }
8641         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8642         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8643         LDKCommitmentSigned msg_var = *msg;
8644         msg_var = CommitmentSigned_clone(msg);
8645         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8646         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8647         uint64_t msg_ref = (uint64_t)msg_var.inner;
8648         if (msg_var.is_owned) {
8649                 msg_ref |= 1;
8650         }
8651         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8652         CHECK(obj != NULL);
8653         (*env)->CallVoidMethod(env, obj, j_calls->handle_commitment_signed_meth, their_node_id_arr, msg_ref);
8654         if ((*env)->ExceptionCheck(env)) {
8655                 (*env)->ExceptionDescribe(env);
8656                 (*env)->FatalError(env, "A call to handle_commitment_signed in LDKChannelMessageHandler from rust threw an exception.");
8657         }
8658         if (get_jenv_res == JNI_EDETACHED) {
8659                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8660         }
8661 }
8662 void handle_revoke_and_ack_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKRevokeAndACK * msg) {
8663         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8664         JNIEnv *env;
8665         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8666         if (get_jenv_res == JNI_EDETACHED) {
8667                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8668         } else {
8669                 DO_ASSERT(get_jenv_res == JNI_OK);
8670         }
8671         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8672         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8673         LDKRevokeAndACK msg_var = *msg;
8674         msg_var = RevokeAndACK_clone(msg);
8675         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8676         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8677         uint64_t msg_ref = (uint64_t)msg_var.inner;
8678         if (msg_var.is_owned) {
8679                 msg_ref |= 1;
8680         }
8681         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8682         CHECK(obj != NULL);
8683         (*env)->CallVoidMethod(env, obj, j_calls->handle_revoke_and_ack_meth, their_node_id_arr, msg_ref);
8684         if ((*env)->ExceptionCheck(env)) {
8685                 (*env)->ExceptionDescribe(env);
8686                 (*env)->FatalError(env, "A call to handle_revoke_and_ack in LDKChannelMessageHandler from rust threw an exception.");
8687         }
8688         if (get_jenv_res == JNI_EDETACHED) {
8689                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8690         }
8691 }
8692 void handle_update_fee_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFee * msg) {
8693         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8694         JNIEnv *env;
8695         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8696         if (get_jenv_res == JNI_EDETACHED) {
8697                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8698         } else {
8699                 DO_ASSERT(get_jenv_res == JNI_OK);
8700         }
8701         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8702         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8703         LDKUpdateFee msg_var = *msg;
8704         msg_var = UpdateFee_clone(msg);
8705         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8706         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8707         uint64_t msg_ref = (uint64_t)msg_var.inner;
8708         if (msg_var.is_owned) {
8709                 msg_ref |= 1;
8710         }
8711         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8712         CHECK(obj != NULL);
8713         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fee_meth, their_node_id_arr, msg_ref);
8714         if ((*env)->ExceptionCheck(env)) {
8715                 (*env)->ExceptionDescribe(env);
8716                 (*env)->FatalError(env, "A call to handle_update_fee in LDKChannelMessageHandler from rust threw an exception.");
8717         }
8718         if (get_jenv_res == JNI_EDETACHED) {
8719                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8720         }
8721 }
8722 void handle_announcement_signatures_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKAnnouncementSignatures * msg) {
8723         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8724         JNIEnv *env;
8725         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8726         if (get_jenv_res == JNI_EDETACHED) {
8727                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8728         } else {
8729                 DO_ASSERT(get_jenv_res == JNI_OK);
8730         }
8731         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8732         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8733         LDKAnnouncementSignatures msg_var = *msg;
8734         msg_var = AnnouncementSignatures_clone(msg);
8735         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8736         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8737         uint64_t msg_ref = (uint64_t)msg_var.inner;
8738         if (msg_var.is_owned) {
8739                 msg_ref |= 1;
8740         }
8741         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8742         CHECK(obj != NULL);
8743         (*env)->CallVoidMethod(env, obj, j_calls->handle_announcement_signatures_meth, their_node_id_arr, msg_ref);
8744         if ((*env)->ExceptionCheck(env)) {
8745                 (*env)->ExceptionDescribe(env);
8746                 (*env)->FatalError(env, "A call to handle_announcement_signatures in LDKChannelMessageHandler from rust threw an exception.");
8747         }
8748         if (get_jenv_res == JNI_EDETACHED) {
8749                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8750         }
8751 }
8752 void peer_disconnected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, bool no_connection_possible) {
8753         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8754         JNIEnv *env;
8755         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8756         if (get_jenv_res == JNI_EDETACHED) {
8757                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8758         } else {
8759                 DO_ASSERT(get_jenv_res == JNI_OK);
8760         }
8761         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8762         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8763         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8764         CHECK(obj != NULL);
8765         (*env)->CallVoidMethod(env, obj, j_calls->peer_disconnected_meth, their_node_id_arr, no_connection_possible);
8766         if ((*env)->ExceptionCheck(env)) {
8767                 (*env)->ExceptionDescribe(env);
8768                 (*env)->FatalError(env, "A call to peer_disconnected in LDKChannelMessageHandler from rust threw an exception.");
8769         }
8770         if (get_jenv_res == JNI_EDETACHED) {
8771                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8772         }
8773 }
8774 void peer_connected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * msg) {
8775         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8776         JNIEnv *env;
8777         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8778         if (get_jenv_res == JNI_EDETACHED) {
8779                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8780         } else {
8781                 DO_ASSERT(get_jenv_res == JNI_OK);
8782         }
8783         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8784         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8785         LDKInit msg_var = *msg;
8786         msg_var = Init_clone(msg);
8787         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8788         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8789         uint64_t msg_ref = (uint64_t)msg_var.inner;
8790         if (msg_var.is_owned) {
8791                 msg_ref |= 1;
8792         }
8793         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8794         CHECK(obj != NULL);
8795         (*env)->CallVoidMethod(env, obj, j_calls->peer_connected_meth, their_node_id_arr, msg_ref);
8796         if ((*env)->ExceptionCheck(env)) {
8797                 (*env)->ExceptionDescribe(env);
8798                 (*env)->FatalError(env, "A call to peer_connected in LDKChannelMessageHandler from rust threw an exception.");
8799         }
8800         if (get_jenv_res == JNI_EDETACHED) {
8801                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8802         }
8803 }
8804 void handle_channel_reestablish_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelReestablish * msg) {
8805         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8806         JNIEnv *env;
8807         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8808         if (get_jenv_res == JNI_EDETACHED) {
8809                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8810         } else {
8811                 DO_ASSERT(get_jenv_res == JNI_OK);
8812         }
8813         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8814         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8815         LDKChannelReestablish msg_var = *msg;
8816         msg_var = ChannelReestablish_clone(msg);
8817         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8818         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8819         uint64_t msg_ref = (uint64_t)msg_var.inner;
8820         if (msg_var.is_owned) {
8821                 msg_ref |= 1;
8822         }
8823         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8824         CHECK(obj != NULL);
8825         (*env)->CallVoidMethod(env, obj, j_calls->handle_channel_reestablish_meth, their_node_id_arr, msg_ref);
8826         if ((*env)->ExceptionCheck(env)) {
8827                 (*env)->ExceptionDescribe(env);
8828                 (*env)->FatalError(env, "A call to handle_channel_reestablish in LDKChannelMessageHandler from rust threw an exception.");
8829         }
8830         if (get_jenv_res == JNI_EDETACHED) {
8831                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8832         }
8833 }
8834 void handle_channel_update_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelUpdate * msg) {
8835         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8836         JNIEnv *env;
8837         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8838         if (get_jenv_res == JNI_EDETACHED) {
8839                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8840         } else {
8841                 DO_ASSERT(get_jenv_res == JNI_OK);
8842         }
8843         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8844         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8845         LDKChannelUpdate msg_var = *msg;
8846         msg_var = ChannelUpdate_clone(msg);
8847         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8848         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8849         uint64_t msg_ref = (uint64_t)msg_var.inner;
8850         if (msg_var.is_owned) {
8851                 msg_ref |= 1;
8852         }
8853         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8854         CHECK(obj != NULL);
8855         (*env)->CallVoidMethod(env, obj, j_calls->handle_channel_update_meth, their_node_id_arr, msg_ref);
8856         if ((*env)->ExceptionCheck(env)) {
8857                 (*env)->ExceptionDescribe(env);
8858                 (*env)->FatalError(env, "A call to handle_channel_update in LDKChannelMessageHandler from rust threw an exception.");
8859         }
8860         if (get_jenv_res == JNI_EDETACHED) {
8861                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8862         }
8863 }
8864 void handle_error_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKErrorMessage * msg) {
8865         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8866         JNIEnv *env;
8867         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8868         if (get_jenv_res == JNI_EDETACHED) {
8869                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8870         } else {
8871                 DO_ASSERT(get_jenv_res == JNI_OK);
8872         }
8873         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8874         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8875         LDKErrorMessage msg_var = *msg;
8876         msg_var = ErrorMessage_clone(msg);
8877         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8878         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8879         uint64_t msg_ref = (uint64_t)msg_var.inner;
8880         if (msg_var.is_owned) {
8881                 msg_ref |= 1;
8882         }
8883         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8884         CHECK(obj != NULL);
8885         (*env)->CallVoidMethod(env, obj, j_calls->handle_error_meth, their_node_id_arr, msg_ref);
8886         if ((*env)->ExceptionCheck(env)) {
8887                 (*env)->ExceptionDescribe(env);
8888                 (*env)->FatalError(env, "A call to handle_error in LDKChannelMessageHandler from rust threw an exception.");
8889         }
8890         if (get_jenv_res == JNI_EDETACHED) {
8891                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8892         }
8893 }
8894 static void LDKChannelMessageHandler_JCalls_cloned(LDKChannelMessageHandler* new_obj) {
8895         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) new_obj->this_arg;
8896         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8897         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
8898 }
8899 static inline LDKChannelMessageHandler LDKChannelMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
8900         jclass c = (*env)->GetObjectClass(env, o);
8901         CHECK(c != NULL);
8902         LDKChannelMessageHandler_JCalls *calls = MALLOC(sizeof(LDKChannelMessageHandler_JCalls), "LDKChannelMessageHandler_JCalls");
8903         atomic_init(&calls->refcnt, 1);
8904         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
8905         calls->o = (*env)->NewWeakGlobalRef(env, o);
8906         calls->handle_open_channel_meth = (*env)->GetMethodID(env, c, "handle_open_channel", "([BJJ)V");
8907         CHECK(calls->handle_open_channel_meth != NULL);
8908         calls->handle_accept_channel_meth = (*env)->GetMethodID(env, c, "handle_accept_channel", "([BJJ)V");
8909         CHECK(calls->handle_accept_channel_meth != NULL);
8910         calls->handle_funding_created_meth = (*env)->GetMethodID(env, c, "handle_funding_created", "([BJ)V");
8911         CHECK(calls->handle_funding_created_meth != NULL);
8912         calls->handle_funding_signed_meth = (*env)->GetMethodID(env, c, "handle_funding_signed", "([BJ)V");
8913         CHECK(calls->handle_funding_signed_meth != NULL);
8914         calls->handle_funding_locked_meth = (*env)->GetMethodID(env, c, "handle_funding_locked", "([BJ)V");
8915         CHECK(calls->handle_funding_locked_meth != NULL);
8916         calls->handle_shutdown_meth = (*env)->GetMethodID(env, c, "handle_shutdown", "([BJJ)V");
8917         CHECK(calls->handle_shutdown_meth != NULL);
8918         calls->handle_closing_signed_meth = (*env)->GetMethodID(env, c, "handle_closing_signed", "([BJ)V");
8919         CHECK(calls->handle_closing_signed_meth != NULL);
8920         calls->handle_update_add_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_add_htlc", "([BJ)V");
8921         CHECK(calls->handle_update_add_htlc_meth != NULL);
8922         calls->handle_update_fulfill_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fulfill_htlc", "([BJ)V");
8923         CHECK(calls->handle_update_fulfill_htlc_meth != NULL);
8924         calls->handle_update_fail_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fail_htlc", "([BJ)V");
8925         CHECK(calls->handle_update_fail_htlc_meth != NULL);
8926         calls->handle_update_fail_malformed_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fail_malformed_htlc", "([BJ)V");
8927         CHECK(calls->handle_update_fail_malformed_htlc_meth != NULL);
8928         calls->handle_commitment_signed_meth = (*env)->GetMethodID(env, c, "handle_commitment_signed", "([BJ)V");
8929         CHECK(calls->handle_commitment_signed_meth != NULL);
8930         calls->handle_revoke_and_ack_meth = (*env)->GetMethodID(env, c, "handle_revoke_and_ack", "([BJ)V");
8931         CHECK(calls->handle_revoke_and_ack_meth != NULL);
8932         calls->handle_update_fee_meth = (*env)->GetMethodID(env, c, "handle_update_fee", "([BJ)V");
8933         CHECK(calls->handle_update_fee_meth != NULL);
8934         calls->handle_announcement_signatures_meth = (*env)->GetMethodID(env, c, "handle_announcement_signatures", "([BJ)V");
8935         CHECK(calls->handle_announcement_signatures_meth != NULL);
8936         calls->peer_disconnected_meth = (*env)->GetMethodID(env, c, "peer_disconnected", "([BZ)V");
8937         CHECK(calls->peer_disconnected_meth != NULL);
8938         calls->peer_connected_meth = (*env)->GetMethodID(env, c, "peer_connected", "([BJ)V");
8939         CHECK(calls->peer_connected_meth != NULL);
8940         calls->handle_channel_reestablish_meth = (*env)->GetMethodID(env, c, "handle_channel_reestablish", "([BJ)V");
8941         CHECK(calls->handle_channel_reestablish_meth != NULL);
8942         calls->handle_channel_update_meth = (*env)->GetMethodID(env, c, "handle_channel_update", "([BJ)V");
8943         CHECK(calls->handle_channel_update_meth != NULL);
8944         calls->handle_error_meth = (*env)->GetMethodID(env, c, "handle_error", "([BJ)V");
8945         CHECK(calls->handle_error_meth != NULL);
8946
8947         LDKChannelMessageHandler ret = {
8948                 .this_arg = (void*) calls,
8949                 .handle_open_channel = handle_open_channel_LDKChannelMessageHandler_jcall,
8950                 .handle_accept_channel = handle_accept_channel_LDKChannelMessageHandler_jcall,
8951                 .handle_funding_created = handle_funding_created_LDKChannelMessageHandler_jcall,
8952                 .handle_funding_signed = handle_funding_signed_LDKChannelMessageHandler_jcall,
8953                 .handle_funding_locked = handle_funding_locked_LDKChannelMessageHandler_jcall,
8954                 .handle_shutdown = handle_shutdown_LDKChannelMessageHandler_jcall,
8955                 .handle_closing_signed = handle_closing_signed_LDKChannelMessageHandler_jcall,
8956                 .handle_update_add_htlc = handle_update_add_htlc_LDKChannelMessageHandler_jcall,
8957                 .handle_update_fulfill_htlc = handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall,
8958                 .handle_update_fail_htlc = handle_update_fail_htlc_LDKChannelMessageHandler_jcall,
8959                 .handle_update_fail_malformed_htlc = handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall,
8960                 .handle_commitment_signed = handle_commitment_signed_LDKChannelMessageHandler_jcall,
8961                 .handle_revoke_and_ack = handle_revoke_and_ack_LDKChannelMessageHandler_jcall,
8962                 .handle_update_fee = handle_update_fee_LDKChannelMessageHandler_jcall,
8963                 .handle_announcement_signatures = handle_announcement_signatures_LDKChannelMessageHandler_jcall,
8964                 .peer_disconnected = peer_disconnected_LDKChannelMessageHandler_jcall,
8965                 .peer_connected = peer_connected_LDKChannelMessageHandler_jcall,
8966                 .handle_channel_reestablish = handle_channel_reestablish_LDKChannelMessageHandler_jcall,
8967                 .handle_channel_update = handle_channel_update_LDKChannelMessageHandler_jcall,
8968                 .handle_error = handle_error_LDKChannelMessageHandler_jcall,
8969                 .free = LDKChannelMessageHandler_JCalls_free,
8970                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(env, clz, MessageSendEventsProvider),
8971         };
8972         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
8973         return ret;
8974 }
8975 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
8976         LDKChannelMessageHandler *res_ptr = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
8977         *res_ptr = LDKChannelMessageHandler_init(env, clz, o, MessageSendEventsProvider);
8978         return (uint64_t)res_ptr;
8979 }
8980 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1get_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t arg) {
8981         LDKChannelMessageHandler *inp = (LDKChannelMessageHandler *)(arg & ~1);
8982         uint64_t res_ptr = (uint64_t)&inp->MessageSendEventsProvider;
8983         DO_ASSERT((res_ptr & 1) == 0);
8984         return (int64_t)(res_ptr | 1);
8985 }
8986 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) {
8987         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
8988         LDKPublicKey their_node_id_ref;
8989         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8990         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8991         LDKInitFeatures their_features_conv;
8992         their_features_conv.inner = (void*)(their_features & (~1));
8993         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
8994         their_features_conv = InitFeatures_clone(&their_features_conv);
8995         LDKOpenChannel msg_conv;
8996         msg_conv.inner = (void*)(msg & (~1));
8997         msg_conv.is_owned = false;
8998         (this_arg_conv->handle_open_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
8999 }
9000
9001 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) {
9002         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
9003         LDKPublicKey their_node_id_ref;
9004         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9005         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9006         LDKInitFeatures their_features_conv;
9007         their_features_conv.inner = (void*)(their_features & (~1));
9008         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
9009         their_features_conv = InitFeatures_clone(&their_features_conv);
9010         LDKAcceptChannel msg_conv;
9011         msg_conv.inner = (void*)(msg & (~1));
9012         msg_conv.is_owned = false;
9013         (this_arg_conv->handle_accept_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
9014 }
9015
9016 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) {
9017         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
9018         LDKPublicKey their_node_id_ref;
9019         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9020         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9021         LDKFundingCreated msg_conv;
9022         msg_conv.inner = (void*)(msg & (~1));
9023         msg_conv.is_owned = false;
9024         (this_arg_conv->handle_funding_created)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9025 }
9026
9027 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) {
9028         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
9029         LDKPublicKey their_node_id_ref;
9030         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9031         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9032         LDKFundingSigned msg_conv;
9033         msg_conv.inner = (void*)(msg & (~1));
9034         msg_conv.is_owned = false;
9035         (this_arg_conv->handle_funding_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9036 }
9037
9038 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) {
9039         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
9040         LDKPublicKey their_node_id_ref;
9041         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9042         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9043         LDKFundingLocked msg_conv;
9044         msg_conv.inner = (void*)(msg & (~1));
9045         msg_conv.is_owned = false;
9046         (this_arg_conv->handle_funding_locked)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9047 }
9048
9049 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) {
9050         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
9051         LDKPublicKey their_node_id_ref;
9052         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9053         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9054         LDKInitFeatures their_features_conv;
9055         their_features_conv.inner = (void*)(their_features & (~1));
9056         their_features_conv.is_owned = false;
9057         LDKShutdown msg_conv;
9058         msg_conv.inner = (void*)(msg & (~1));
9059         msg_conv.is_owned = false;
9060         (this_arg_conv->handle_shutdown)(this_arg_conv->this_arg, their_node_id_ref, &their_features_conv, &msg_conv);
9061 }
9062
9063 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) {
9064         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
9065         LDKPublicKey their_node_id_ref;
9066         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9067         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9068         LDKClosingSigned msg_conv;
9069         msg_conv.inner = (void*)(msg & (~1));
9070         msg_conv.is_owned = false;
9071         (this_arg_conv->handle_closing_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9072 }
9073
9074 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) {
9075         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
9076         LDKPublicKey their_node_id_ref;
9077         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9078         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9079         LDKUpdateAddHTLC msg_conv;
9080         msg_conv.inner = (void*)(msg & (~1));
9081         msg_conv.is_owned = false;
9082         (this_arg_conv->handle_update_add_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9083 }
9084
9085 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) {
9086         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
9087         LDKPublicKey their_node_id_ref;
9088         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9089         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9090         LDKUpdateFulfillHTLC msg_conv;
9091         msg_conv.inner = (void*)(msg & (~1));
9092         msg_conv.is_owned = false;
9093         (this_arg_conv->handle_update_fulfill_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9094 }
9095
9096 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) {
9097         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
9098         LDKPublicKey their_node_id_ref;
9099         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9100         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9101         LDKUpdateFailHTLC msg_conv;
9102         msg_conv.inner = (void*)(msg & (~1));
9103         msg_conv.is_owned = false;
9104         (this_arg_conv->handle_update_fail_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9105 }
9106
9107 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) {
9108         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
9109         LDKPublicKey their_node_id_ref;
9110         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9111         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9112         LDKUpdateFailMalformedHTLC msg_conv;
9113         msg_conv.inner = (void*)(msg & (~1));
9114         msg_conv.is_owned = false;
9115         (this_arg_conv->handle_update_fail_malformed_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9116 }
9117
9118 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) {
9119         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
9120         LDKPublicKey their_node_id_ref;
9121         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9122         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9123         LDKCommitmentSigned msg_conv;
9124         msg_conv.inner = (void*)(msg & (~1));
9125         msg_conv.is_owned = false;
9126         (this_arg_conv->handle_commitment_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9127 }
9128
9129 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) {
9130         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
9131         LDKPublicKey their_node_id_ref;
9132         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9133         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9134         LDKRevokeAndACK msg_conv;
9135         msg_conv.inner = (void*)(msg & (~1));
9136         msg_conv.is_owned = false;
9137         (this_arg_conv->handle_revoke_and_ack)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9138 }
9139
9140 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) {
9141         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
9142         LDKPublicKey their_node_id_ref;
9143         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9144         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9145         LDKUpdateFee msg_conv;
9146         msg_conv.inner = (void*)(msg & (~1));
9147         msg_conv.is_owned = false;
9148         (this_arg_conv->handle_update_fee)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9149 }
9150
9151 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) {
9152         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
9153         LDKPublicKey their_node_id_ref;
9154         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9155         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9156         LDKAnnouncementSignatures msg_conv;
9157         msg_conv.inner = (void*)(msg & (~1));
9158         msg_conv.is_owned = false;
9159         (this_arg_conv->handle_announcement_signatures)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9160 }
9161
9162 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) {
9163         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
9164         LDKPublicKey their_node_id_ref;
9165         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9166         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9167         (this_arg_conv->peer_disconnected)(this_arg_conv->this_arg, their_node_id_ref, no_connection_possible);
9168 }
9169
9170 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) {
9171         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
9172         LDKPublicKey their_node_id_ref;
9173         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9174         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9175         LDKInit msg_conv;
9176         msg_conv.inner = (void*)(msg & (~1));
9177         msg_conv.is_owned = false;
9178         (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9179 }
9180
9181 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) {
9182         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
9183         LDKPublicKey their_node_id_ref;
9184         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9185         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9186         LDKChannelReestablish msg_conv;
9187         msg_conv.inner = (void*)(msg & (~1));
9188         msg_conv.is_owned = false;
9189         (this_arg_conv->handle_channel_reestablish)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9190 }
9191
9192 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) {
9193         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
9194         LDKPublicKey their_node_id_ref;
9195         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9196         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9197         LDKChannelUpdate msg_conv;
9198         msg_conv.inner = (void*)(msg & (~1));
9199         msg_conv.is_owned = false;
9200         (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9201 }
9202
9203 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) {
9204         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
9205         LDKPublicKey their_node_id_ref;
9206         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9207         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9208         LDKErrorMessage msg_conv;
9209         msg_conv.inner = (void*)(msg & (~1));
9210         msg_conv.is_owned = false;
9211         (this_arg_conv->handle_error)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9212 }
9213
9214 typedef struct LDKRoutingMessageHandler_JCalls {
9215         atomic_size_t refcnt;
9216         JavaVM *vm;
9217         jweak o;
9218         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
9219         jmethodID handle_node_announcement_meth;
9220         jmethodID handle_channel_announcement_meth;
9221         jmethodID handle_channel_update_meth;
9222         jmethodID get_next_channel_announcements_meth;
9223         jmethodID get_next_node_announcements_meth;
9224         jmethodID sync_routing_table_meth;
9225         jmethodID handle_reply_channel_range_meth;
9226         jmethodID handle_reply_short_channel_ids_end_meth;
9227         jmethodID handle_query_channel_range_meth;
9228         jmethodID handle_query_short_channel_ids_meth;
9229 } LDKRoutingMessageHandler_JCalls;
9230 static void LDKRoutingMessageHandler_JCalls_free(void* this_arg) {
9231         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9232         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
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                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
9241                 if (get_jenv_res == JNI_EDETACHED) {
9242                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9243                 }
9244                 FREE(j_calls);
9245         }
9246 }
9247 LDKCResult_boolLightningErrorZ handle_node_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKNodeAnnouncement * msg) {
9248         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9249         JNIEnv *env;
9250         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9251         if (get_jenv_res == JNI_EDETACHED) {
9252                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9253         } else {
9254                 DO_ASSERT(get_jenv_res == JNI_OK);
9255         }
9256         LDKNodeAnnouncement msg_var = *msg;
9257         msg_var = NodeAnnouncement_clone(msg);
9258         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9259         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9260         uint64_t msg_ref = (uint64_t)msg_var.inner;
9261         if (msg_var.is_owned) {
9262                 msg_ref |= 1;
9263         }
9264         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9265         CHECK(obj != NULL);
9266         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_node_announcement_meth, msg_ref);
9267         if ((*env)->ExceptionCheck(env)) {
9268                 (*env)->ExceptionDescribe(env);
9269                 (*env)->FatalError(env, "A call to handle_node_announcement in LDKRoutingMessageHandler from rust threw an exception.");
9270         }
9271         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1);
9272         ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1));
9273         if (get_jenv_res == JNI_EDETACHED) {
9274                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9275         }
9276         return ret_conv;
9277 }
9278 LDKCResult_boolLightningErrorZ handle_channel_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelAnnouncement * msg) {
9279         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9280         JNIEnv *env;
9281         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9282         if (get_jenv_res == JNI_EDETACHED) {
9283                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9284         } else {
9285                 DO_ASSERT(get_jenv_res == JNI_OK);
9286         }
9287         LDKChannelAnnouncement msg_var = *msg;
9288         msg_var = ChannelAnnouncement_clone(msg);
9289         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9290         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9291         uint64_t msg_ref = (uint64_t)msg_var.inner;
9292         if (msg_var.is_owned) {
9293                 msg_ref |= 1;
9294         }
9295         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9296         CHECK(obj != NULL);
9297         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_channel_announcement_meth, msg_ref);
9298         if ((*env)->ExceptionCheck(env)) {
9299                 (*env)->ExceptionDescribe(env);
9300                 (*env)->FatalError(env, "A call to handle_channel_announcement in LDKRoutingMessageHandler from rust threw an exception.");
9301         }
9302         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1);
9303         ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1));
9304         if (get_jenv_res == JNI_EDETACHED) {
9305                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9306         }
9307         return ret_conv;
9308 }
9309 LDKCResult_boolLightningErrorZ handle_channel_update_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelUpdate * msg) {
9310         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9311         JNIEnv *env;
9312         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9313         if (get_jenv_res == JNI_EDETACHED) {
9314                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9315         } else {
9316                 DO_ASSERT(get_jenv_res == JNI_OK);
9317         }
9318         LDKChannelUpdate msg_var = *msg;
9319         msg_var = ChannelUpdate_clone(msg);
9320         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9321         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9322         uint64_t msg_ref = (uint64_t)msg_var.inner;
9323         if (msg_var.is_owned) {
9324                 msg_ref |= 1;
9325         }
9326         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9327         CHECK(obj != NULL);
9328         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_channel_update_meth, msg_ref);
9329         if ((*env)->ExceptionCheck(env)) {
9330                 (*env)->ExceptionDescribe(env);
9331                 (*env)->FatalError(env, "A call to handle_channel_update in LDKRoutingMessageHandler from rust threw an exception.");
9332         }
9333         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1);
9334         ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1));
9335         if (get_jenv_res == JNI_EDETACHED) {
9336                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9337         }
9338         return ret_conv;
9339 }
9340 LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ get_next_channel_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, uint64_t starting_point, uint8_t batch_amount) {
9341         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9342         JNIEnv *env;
9343         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9344         if (get_jenv_res == JNI_EDETACHED) {
9345                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9346         } else {
9347                 DO_ASSERT(get_jenv_res == JNI_OK);
9348         }
9349         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9350         CHECK(obj != NULL);
9351         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_next_channel_announcements_meth, starting_point, batch_amount);
9352         if ((*env)->ExceptionCheck(env)) {
9353                 (*env)->ExceptionDescribe(env);
9354                 (*env)->FatalError(env, "A call to get_next_channel_announcements in LDKRoutingMessageHandler from rust threw an exception.");
9355         }
9356         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_constr;
9357         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
9358         if (ret_constr.datalen > 0)
9359                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
9360         else
9361                 ret_constr.data = NULL;
9362         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
9363         for (size_t h = 0; h < ret_constr.datalen; h++) {
9364                 int64_t ret_conv_59 = ret_vals[h];
9365                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ ret_conv_59_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)ret_conv_59) & ~1);
9366                 ret_conv_59_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone((LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)ret_conv_59) & ~1));
9367                 ret_constr.data[h] = ret_conv_59_conv;
9368         }
9369         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
9370         if (get_jenv_res == JNI_EDETACHED) {
9371                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9372         }
9373         return ret_constr;
9374 }
9375 LDKCVec_NodeAnnouncementZ get_next_node_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey starting_point, uint8_t batch_amount) {
9376         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9377         JNIEnv *env;
9378         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9379         if (get_jenv_res == JNI_EDETACHED) {
9380                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9381         } else {
9382                 DO_ASSERT(get_jenv_res == JNI_OK);
9383         }
9384         int8_tArray starting_point_arr = (*env)->NewByteArray(env, 33);
9385         (*env)->SetByteArrayRegion(env, starting_point_arr, 0, 33, starting_point.compressed_form);
9386         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9387         CHECK(obj != NULL);
9388         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_next_node_announcements_meth, starting_point_arr, batch_amount);
9389         if ((*env)->ExceptionCheck(env)) {
9390                 (*env)->ExceptionDescribe(env);
9391                 (*env)->FatalError(env, "A call to get_next_node_announcements in LDKRoutingMessageHandler from rust threw an exception.");
9392         }
9393         LDKCVec_NodeAnnouncementZ ret_constr;
9394         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
9395         if (ret_constr.datalen > 0)
9396                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
9397         else
9398                 ret_constr.data = NULL;
9399         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
9400         for (size_t s = 0; s < ret_constr.datalen; s++) {
9401                 int64_t ret_conv_18 = ret_vals[s];
9402                 LDKNodeAnnouncement ret_conv_18_conv;
9403                 ret_conv_18_conv.inner = (void*)(ret_conv_18 & (~1));
9404                 ret_conv_18_conv.is_owned = (ret_conv_18 & 1) || (ret_conv_18 == 0);
9405                 ret_conv_18_conv = NodeAnnouncement_clone(&ret_conv_18_conv);
9406                 ret_constr.data[s] = ret_conv_18_conv;
9407         }
9408         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
9409         if (get_jenv_res == JNI_EDETACHED) {
9410                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9411         }
9412         return ret_constr;
9413 }
9414 void sync_routing_table_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * init) {
9415         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9416         JNIEnv *env;
9417         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9418         if (get_jenv_res == JNI_EDETACHED) {
9419                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9420         } else {
9421                 DO_ASSERT(get_jenv_res == JNI_OK);
9422         }
9423         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
9424         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
9425         LDKInit init_var = *init;
9426         init_var = Init_clone(init);
9427         CHECK((((uint64_t)init_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9428         CHECK((((uint64_t)&init_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9429         uint64_t init_ref = (uint64_t)init_var.inner;
9430         if (init_var.is_owned) {
9431                 init_ref |= 1;
9432         }
9433         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9434         CHECK(obj != NULL);
9435         (*env)->CallVoidMethod(env, obj, j_calls->sync_routing_table_meth, their_node_id_arr, init_ref);
9436         if ((*env)->ExceptionCheck(env)) {
9437                 (*env)->ExceptionDescribe(env);
9438                 (*env)->FatalError(env, "A call to sync_routing_table in LDKRoutingMessageHandler from rust threw an exception.");
9439         }
9440         if (get_jenv_res == JNI_EDETACHED) {
9441                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9442         }
9443 }
9444 LDKCResult_NoneLightningErrorZ handle_reply_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyChannelRange msg) {
9445         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9446         JNIEnv *env;
9447         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9448         if (get_jenv_res == JNI_EDETACHED) {
9449                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9450         } else {
9451                 DO_ASSERT(get_jenv_res == JNI_OK);
9452         }
9453         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
9454         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
9455         LDKReplyChannelRange msg_var = msg;
9456         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9457         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9458         uint64_t msg_ref = (uint64_t)msg_var.inner;
9459         if (msg_var.is_owned) {
9460                 msg_ref |= 1;
9461         }
9462         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9463         CHECK(obj != NULL);
9464         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_reply_channel_range_meth, their_node_id_arr, msg_ref);
9465         if ((*env)->ExceptionCheck(env)) {
9466                 (*env)->ExceptionDescribe(env);
9467                 (*env)->FatalError(env, "A call to handle_reply_channel_range in LDKRoutingMessageHandler from rust threw an exception.");
9468         }
9469         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
9470         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
9471         if (get_jenv_res == JNI_EDETACHED) {
9472                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9473         }
9474         return ret_conv;
9475 }
9476 LDKCResult_NoneLightningErrorZ handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyShortChannelIdsEnd msg) {
9477         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9478         JNIEnv *env;
9479         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9480         if (get_jenv_res == JNI_EDETACHED) {
9481                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9482         } else {
9483                 DO_ASSERT(get_jenv_res == JNI_OK);
9484         }
9485         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
9486         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
9487         LDKReplyShortChannelIdsEnd msg_var = msg;
9488         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9489         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9490         uint64_t msg_ref = (uint64_t)msg_var.inner;
9491         if (msg_var.is_owned) {
9492                 msg_ref |= 1;
9493         }
9494         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9495         CHECK(obj != NULL);
9496         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_reply_short_channel_ids_end_meth, their_node_id_arr, msg_ref);
9497         if ((*env)->ExceptionCheck(env)) {
9498                 (*env)->ExceptionDescribe(env);
9499                 (*env)->FatalError(env, "A call to handle_reply_short_channel_ids_end in LDKRoutingMessageHandler from rust threw an exception.");
9500         }
9501         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
9502         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
9503         if (get_jenv_res == JNI_EDETACHED) {
9504                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9505         }
9506         return ret_conv;
9507 }
9508 LDKCResult_NoneLightningErrorZ handle_query_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryChannelRange msg) {
9509         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9510         JNIEnv *env;
9511         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9512         if (get_jenv_res == JNI_EDETACHED) {
9513                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9514         } else {
9515                 DO_ASSERT(get_jenv_res == JNI_OK);
9516         }
9517         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
9518         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
9519         LDKQueryChannelRange msg_var = msg;
9520         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9521         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9522         uint64_t msg_ref = (uint64_t)msg_var.inner;
9523         if (msg_var.is_owned) {
9524                 msg_ref |= 1;
9525         }
9526         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9527         CHECK(obj != NULL);
9528         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_query_channel_range_meth, their_node_id_arr, msg_ref);
9529         if ((*env)->ExceptionCheck(env)) {
9530                 (*env)->ExceptionDescribe(env);
9531                 (*env)->FatalError(env, "A call to handle_query_channel_range in LDKRoutingMessageHandler from rust threw an exception.");
9532         }
9533         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
9534         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
9535         if (get_jenv_res == JNI_EDETACHED) {
9536                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9537         }
9538         return ret_conv;
9539 }
9540 LDKCResult_NoneLightningErrorZ handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryShortChannelIds msg) {
9541         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9542         JNIEnv *env;
9543         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9544         if (get_jenv_res == JNI_EDETACHED) {
9545                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9546         } else {
9547                 DO_ASSERT(get_jenv_res == JNI_OK);
9548         }
9549         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
9550         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
9551         LDKQueryShortChannelIds msg_var = msg;
9552         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9553         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9554         uint64_t msg_ref = (uint64_t)msg_var.inner;
9555         if (msg_var.is_owned) {
9556                 msg_ref |= 1;
9557         }
9558         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9559         CHECK(obj != NULL);
9560         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_query_short_channel_ids_meth, their_node_id_arr, msg_ref);
9561         if ((*env)->ExceptionCheck(env)) {
9562                 (*env)->ExceptionDescribe(env);
9563                 (*env)->FatalError(env, "A call to handle_query_short_channel_ids in LDKRoutingMessageHandler from rust threw an exception.");
9564         }
9565         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
9566         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
9567         if (get_jenv_res == JNI_EDETACHED) {
9568                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9569         }
9570         return ret_conv;
9571 }
9572 static void LDKRoutingMessageHandler_JCalls_cloned(LDKRoutingMessageHandler* new_obj) {
9573         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) new_obj->this_arg;
9574         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
9575         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
9576 }
9577 static inline LDKRoutingMessageHandler LDKRoutingMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
9578         jclass c = (*env)->GetObjectClass(env, o);
9579         CHECK(c != NULL);
9580         LDKRoutingMessageHandler_JCalls *calls = MALLOC(sizeof(LDKRoutingMessageHandler_JCalls), "LDKRoutingMessageHandler_JCalls");
9581         atomic_init(&calls->refcnt, 1);
9582         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
9583         calls->o = (*env)->NewWeakGlobalRef(env, o);
9584         calls->handle_node_announcement_meth = (*env)->GetMethodID(env, c, "handle_node_announcement", "(J)J");
9585         CHECK(calls->handle_node_announcement_meth != NULL);
9586         calls->handle_channel_announcement_meth = (*env)->GetMethodID(env, c, "handle_channel_announcement", "(J)J");
9587         CHECK(calls->handle_channel_announcement_meth != NULL);
9588         calls->handle_channel_update_meth = (*env)->GetMethodID(env, c, "handle_channel_update", "(J)J");
9589         CHECK(calls->handle_channel_update_meth != NULL);
9590         calls->get_next_channel_announcements_meth = (*env)->GetMethodID(env, c, "get_next_channel_announcements", "(JB)[J");
9591         CHECK(calls->get_next_channel_announcements_meth != NULL);
9592         calls->get_next_node_announcements_meth = (*env)->GetMethodID(env, c, "get_next_node_announcements", "([BB)[J");
9593         CHECK(calls->get_next_node_announcements_meth != NULL);
9594         calls->sync_routing_table_meth = (*env)->GetMethodID(env, c, "sync_routing_table", "([BJ)V");
9595         CHECK(calls->sync_routing_table_meth != NULL);
9596         calls->handle_reply_channel_range_meth = (*env)->GetMethodID(env, c, "handle_reply_channel_range", "([BJ)J");
9597         CHECK(calls->handle_reply_channel_range_meth != NULL);
9598         calls->handle_reply_short_channel_ids_end_meth = (*env)->GetMethodID(env, c, "handle_reply_short_channel_ids_end", "([BJ)J");
9599         CHECK(calls->handle_reply_short_channel_ids_end_meth != NULL);
9600         calls->handle_query_channel_range_meth = (*env)->GetMethodID(env, c, "handle_query_channel_range", "([BJ)J");
9601         CHECK(calls->handle_query_channel_range_meth != NULL);
9602         calls->handle_query_short_channel_ids_meth = (*env)->GetMethodID(env, c, "handle_query_short_channel_ids", "([BJ)J");
9603         CHECK(calls->handle_query_short_channel_ids_meth != NULL);
9604
9605         LDKRoutingMessageHandler ret = {
9606                 .this_arg = (void*) calls,
9607                 .handle_node_announcement = handle_node_announcement_LDKRoutingMessageHandler_jcall,
9608                 .handle_channel_announcement = handle_channel_announcement_LDKRoutingMessageHandler_jcall,
9609                 .handle_channel_update = handle_channel_update_LDKRoutingMessageHandler_jcall,
9610                 .get_next_channel_announcements = get_next_channel_announcements_LDKRoutingMessageHandler_jcall,
9611                 .get_next_node_announcements = get_next_node_announcements_LDKRoutingMessageHandler_jcall,
9612                 .sync_routing_table = sync_routing_table_LDKRoutingMessageHandler_jcall,
9613                 .handle_reply_channel_range = handle_reply_channel_range_LDKRoutingMessageHandler_jcall,
9614                 .handle_reply_short_channel_ids_end = handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall,
9615                 .handle_query_channel_range = handle_query_channel_range_LDKRoutingMessageHandler_jcall,
9616                 .handle_query_short_channel_ids = handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall,
9617                 .free = LDKRoutingMessageHandler_JCalls_free,
9618                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(env, clz, MessageSendEventsProvider),
9619         };
9620         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
9621         return ret;
9622 }
9623 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
9624         LDKRoutingMessageHandler *res_ptr = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
9625         *res_ptr = LDKRoutingMessageHandler_init(env, clz, o, MessageSendEventsProvider);
9626         return (uint64_t)res_ptr;
9627 }
9628 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1get_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t arg) {
9629         LDKRoutingMessageHandler *inp = (LDKRoutingMessageHandler *)(arg & ~1);
9630         uint64_t res_ptr = (uint64_t)&inp->MessageSendEventsProvider;
9631         DO_ASSERT((res_ptr & 1) == 0);
9632         return (int64_t)(res_ptr | 1);
9633 }
9634 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1node_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
9635         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
9636         LDKNodeAnnouncement msg_conv;
9637         msg_conv.inner = (void*)(msg & (~1));
9638         msg_conv.is_owned = false;
9639         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
9640         *ret_conv = (this_arg_conv->handle_node_announcement)(this_arg_conv->this_arg, &msg_conv);
9641         return (uint64_t)ret_conv;
9642 }
9643
9644 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1channel_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
9645         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
9646         LDKChannelAnnouncement msg_conv;
9647         msg_conv.inner = (void*)(msg & (~1));
9648         msg_conv.is_owned = false;
9649         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
9650         *ret_conv = (this_arg_conv->handle_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
9651         return (uint64_t)ret_conv;
9652 }
9653
9654 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1channel_1update(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
9655         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
9656         LDKChannelUpdate msg_conv;
9657         msg_conv.inner = (void*)(msg & (~1));
9658         msg_conv.is_owned = false;
9659         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
9660         *ret_conv = (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, &msg_conv);
9661         return (uint64_t)ret_conv;
9662 }
9663
9664 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) {
9665         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
9666         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_var = (this_arg_conv->get_next_channel_announcements)(this_arg_conv->this_arg, starting_point, batch_amount);
9667         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
9668         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
9669         for (size_t h = 0; h < ret_var.datalen; h++) {
9670                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv_59_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
9671                 *ret_conv_59_conv = ret_var.data[h];
9672                 ret_arr_ptr[h] = ((uint64_t)ret_conv_59_conv);
9673         }
9674         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
9675         FREE(ret_var.data);
9676         return ret_arr;
9677 }
9678
9679 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) {
9680         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
9681         LDKPublicKey starting_point_ref;
9682         CHECK((*env)->GetArrayLength(env, starting_point) == 33);
9683         (*env)->GetByteArrayRegion(env, starting_point, 0, 33, starting_point_ref.compressed_form);
9684         LDKCVec_NodeAnnouncementZ ret_var = (this_arg_conv->get_next_node_announcements)(this_arg_conv->this_arg, starting_point_ref, batch_amount);
9685         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
9686         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
9687         for (size_t s = 0; s < ret_var.datalen; s++) {
9688                 LDKNodeAnnouncement ret_conv_18_var = ret_var.data[s];
9689                 CHECK((((uint64_t)ret_conv_18_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9690                 CHECK((((uint64_t)&ret_conv_18_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9691                 uint64_t ret_conv_18_ref = (uint64_t)ret_conv_18_var.inner;
9692                 if (ret_conv_18_var.is_owned) {
9693                         ret_conv_18_ref |= 1;
9694                 }
9695                 ret_arr_ptr[s] = ret_conv_18_ref;
9696         }
9697         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
9698         FREE(ret_var.data);
9699         return ret_arr;
9700 }
9701
9702 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) {
9703         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
9704         LDKPublicKey their_node_id_ref;
9705         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9706         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9707         LDKInit init_conv;
9708         init_conv.inner = (void*)(init & (~1));
9709         init_conv.is_owned = false;
9710         (this_arg_conv->sync_routing_table)(this_arg_conv->this_arg, their_node_id_ref, &init_conv);
9711 }
9712
9713 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) {
9714         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
9715         LDKPublicKey their_node_id_ref;
9716         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9717         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9718         LDKReplyChannelRange msg_conv;
9719         msg_conv.inner = (void*)(msg & (~1));
9720         msg_conv.is_owned = (msg & 1) || (msg == 0);
9721         msg_conv = ReplyChannelRange_clone(&msg_conv);
9722         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
9723         *ret_conv = (this_arg_conv->handle_reply_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
9724         return (uint64_t)ret_conv;
9725 }
9726
9727 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) {
9728         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
9729         LDKPublicKey their_node_id_ref;
9730         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9731         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9732         LDKReplyShortChannelIdsEnd msg_conv;
9733         msg_conv.inner = (void*)(msg & (~1));
9734         msg_conv.is_owned = (msg & 1) || (msg == 0);
9735         msg_conv = ReplyShortChannelIdsEnd_clone(&msg_conv);
9736         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
9737         *ret_conv = (this_arg_conv->handle_reply_short_channel_ids_end)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
9738         return (uint64_t)ret_conv;
9739 }
9740
9741 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) {
9742         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
9743         LDKPublicKey their_node_id_ref;
9744         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9745         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9746         LDKQueryChannelRange msg_conv;
9747         msg_conv.inner = (void*)(msg & (~1));
9748         msg_conv.is_owned = (msg & 1) || (msg == 0);
9749         msg_conv = QueryChannelRange_clone(&msg_conv);
9750         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
9751         *ret_conv = (this_arg_conv->handle_query_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
9752         return (uint64_t)ret_conv;
9753 }
9754
9755 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) {
9756         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
9757         LDKPublicKey their_node_id_ref;
9758         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9759         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9760         LDKQueryShortChannelIds msg_conv;
9761         msg_conv.inner = (void*)(msg & (~1));
9762         msg_conv.is_owned = (msg & 1) || (msg == 0);
9763         msg_conv = QueryShortChannelIds_clone(&msg_conv);
9764         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
9765         *ret_conv = (this_arg_conv->handle_query_short_channel_ids)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
9766         return (uint64_t)ret_conv;
9767 }
9768
9769 typedef struct LDKCustomMessageReader_JCalls {
9770         atomic_size_t refcnt;
9771         JavaVM *vm;
9772         jweak o;
9773         jmethodID read_meth;
9774 } LDKCustomMessageReader_JCalls;
9775 static void LDKCustomMessageReader_JCalls_free(void* this_arg) {
9776         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) this_arg;
9777         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
9778                 JNIEnv *env;
9779                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9780                 if (get_jenv_res == JNI_EDETACHED) {
9781                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9782                 } else {
9783                         DO_ASSERT(get_jenv_res == JNI_OK);
9784                 }
9785                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
9786                 if (get_jenv_res == JNI_EDETACHED) {
9787                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9788                 }
9789                 FREE(j_calls);
9790         }
9791 }
9792 LDKCResult_COption_TypeZDecodeErrorZ read_LDKCustomMessageReader_jcall(const void* this_arg, uint16_t message_type, LDKu8slice buffer) {
9793         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) this_arg;
9794         JNIEnv *env;
9795         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9796         if (get_jenv_res == JNI_EDETACHED) {
9797                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9798         } else {
9799                 DO_ASSERT(get_jenv_res == JNI_OK);
9800         }
9801         LDKu8slice buffer_var = buffer;
9802         int8_tArray buffer_arr = (*env)->NewByteArray(env, buffer_var.datalen);
9803         (*env)->SetByteArrayRegion(env, buffer_arr, 0, buffer_var.datalen, buffer_var.data);
9804         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9805         CHECK(obj != NULL);
9806         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->read_meth, message_type, buffer_arr);
9807         if ((*env)->ExceptionCheck(env)) {
9808                 (*env)->ExceptionDescribe(env);
9809                 (*env)->FatalError(env, "A call to read in LDKCustomMessageReader from rust threw an exception.");
9810         }
9811         LDKCResult_COption_TypeZDecodeErrorZ ret_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(((uint64_t)ret) & ~1);
9812         ret_conv = CResult_COption_TypeZDecodeErrorZ_clone((LDKCResult_COption_TypeZDecodeErrorZ*)(((uint64_t)ret) & ~1));
9813         if (get_jenv_res == JNI_EDETACHED) {
9814                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9815         }
9816         return ret_conv;
9817 }
9818 static void LDKCustomMessageReader_JCalls_cloned(LDKCustomMessageReader* new_obj) {
9819         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) new_obj->this_arg;
9820         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
9821 }
9822 static inline LDKCustomMessageReader LDKCustomMessageReader_init (JNIEnv *env, jclass clz, jobject o) {
9823         jclass c = (*env)->GetObjectClass(env, o);
9824         CHECK(c != NULL);
9825         LDKCustomMessageReader_JCalls *calls = MALLOC(sizeof(LDKCustomMessageReader_JCalls), "LDKCustomMessageReader_JCalls");
9826         atomic_init(&calls->refcnt, 1);
9827         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
9828         calls->o = (*env)->NewWeakGlobalRef(env, o);
9829         calls->read_meth = (*env)->GetMethodID(env, c, "read", "(S[B)J");
9830         CHECK(calls->read_meth != NULL);
9831
9832         LDKCustomMessageReader ret = {
9833                 .this_arg = (void*) calls,
9834                 .read = read_LDKCustomMessageReader_jcall,
9835                 .free = LDKCustomMessageReader_JCalls_free,
9836         };
9837         return ret;
9838 }
9839 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCustomMessageReader_1new(JNIEnv *env, jclass clz, jobject o) {
9840         LDKCustomMessageReader *res_ptr = MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader");
9841         *res_ptr = LDKCustomMessageReader_init(env, clz, o);
9842         return (uint64_t)res_ptr;
9843 }
9844 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) {
9845         LDKCustomMessageReader* this_arg_conv = (LDKCustomMessageReader*)(((uint64_t)this_arg) & ~1);
9846         LDKu8slice buffer_ref;
9847         buffer_ref.datalen = (*env)->GetArrayLength(env, buffer);
9848         buffer_ref.data = (*env)->GetByteArrayElements (env, buffer, NULL);
9849         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
9850         *ret_conv = (this_arg_conv->read)(this_arg_conv->this_arg, message_type, buffer_ref);
9851         (*env)->ReleaseByteArrayElements(env, buffer, (int8_t*)buffer_ref.data, 0);
9852         return (uint64_t)ret_conv;
9853 }
9854
9855 typedef struct LDKCustomMessageHandler_JCalls {
9856         atomic_size_t refcnt;
9857         JavaVM *vm;
9858         jweak o;
9859         LDKCustomMessageReader_JCalls* CustomMessageReader;
9860         jmethodID handle_custom_message_meth;
9861         jmethodID get_and_clear_pending_msg_meth;
9862 } LDKCustomMessageHandler_JCalls;
9863 static void LDKCustomMessageHandler_JCalls_free(void* this_arg) {
9864         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
9865         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
9866                 JNIEnv *env;
9867                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9868                 if (get_jenv_res == JNI_EDETACHED) {
9869                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9870                 } else {
9871                         DO_ASSERT(get_jenv_res == JNI_OK);
9872                 }
9873                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
9874                 if (get_jenv_res == JNI_EDETACHED) {
9875                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9876                 }
9877                 FREE(j_calls);
9878         }
9879 }
9880 LDKCResult_NoneLightningErrorZ handle_custom_message_LDKCustomMessageHandler_jcall(const void* this_arg, LDKType msg, LDKPublicKey sender_node_id) {
9881         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
9882         JNIEnv *env;
9883         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9884         if (get_jenv_res == JNI_EDETACHED) {
9885                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9886         } else {
9887                 DO_ASSERT(get_jenv_res == JNI_OK);
9888         }
9889         LDKType* msg_ret =MALLOC(sizeof(LDKType), "LDKType");
9890         *msg_ret = msg;
9891         int8_tArray sender_node_id_arr = (*env)->NewByteArray(env, 33);
9892         (*env)->SetByteArrayRegion(env, sender_node_id_arr, 0, 33, sender_node_id.compressed_form);
9893         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9894         CHECK(obj != NULL);
9895         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_custom_message_meth, (uint64_t)msg_ret, sender_node_id_arr);
9896         if ((*env)->ExceptionCheck(env)) {
9897                 (*env)->ExceptionDescribe(env);
9898                 (*env)->FatalError(env, "A call to handle_custom_message in LDKCustomMessageHandler from rust threw an exception.");
9899         }
9900         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
9901         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
9902         if (get_jenv_res == JNI_EDETACHED) {
9903                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9904         }
9905         return ret_conv;
9906 }
9907 LDKCVec_C2Tuple_PublicKeyTypeZZ get_and_clear_pending_msg_LDKCustomMessageHandler_jcall(const void* this_arg) {
9908         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
9909         JNIEnv *env;
9910         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9911         if (get_jenv_res == JNI_EDETACHED) {
9912                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9913         } else {
9914                 DO_ASSERT(get_jenv_res == JNI_OK);
9915         }
9916         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9917         CHECK(obj != NULL);
9918         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_and_clear_pending_msg_meth);
9919         if ((*env)->ExceptionCheck(env)) {
9920                 (*env)->ExceptionDescribe(env);
9921                 (*env)->FatalError(env, "A call to get_and_clear_pending_msg in LDKCustomMessageHandler from rust threw an exception.");
9922         }
9923         LDKCVec_C2Tuple_PublicKeyTypeZZ ret_constr;
9924         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
9925         if (ret_constr.datalen > 0)
9926                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ Elements");
9927         else
9928                 ret_constr.data = NULL;
9929         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
9930         for (size_t z = 0; z < ret_constr.datalen; z++) {
9931                 int64_t ret_conv_25 = ret_vals[z];
9932                 LDKC2Tuple_PublicKeyTypeZ ret_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(((uint64_t)ret_conv_25) & ~1);
9933                 ret_conv_25_conv = C2Tuple_PublicKeyTypeZ_clone((LDKC2Tuple_PublicKeyTypeZ*)(((uint64_t)ret_conv_25) & ~1));
9934                 ret_constr.data[z] = ret_conv_25_conv;
9935         }
9936         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
9937         if (get_jenv_res == JNI_EDETACHED) {
9938                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9939         }
9940         return ret_constr;
9941 }
9942 static void LDKCustomMessageHandler_JCalls_cloned(LDKCustomMessageHandler* new_obj) {
9943         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) new_obj->this_arg;
9944         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
9945         atomic_fetch_add_explicit(&j_calls->CustomMessageReader->refcnt, 1, memory_order_release);
9946 }
9947 static inline LDKCustomMessageHandler LDKCustomMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject CustomMessageReader) {
9948         jclass c = (*env)->GetObjectClass(env, o);
9949         CHECK(c != NULL);
9950         LDKCustomMessageHandler_JCalls *calls = MALLOC(sizeof(LDKCustomMessageHandler_JCalls), "LDKCustomMessageHandler_JCalls");
9951         atomic_init(&calls->refcnt, 1);
9952         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
9953         calls->o = (*env)->NewWeakGlobalRef(env, o);
9954         calls->handle_custom_message_meth = (*env)->GetMethodID(env, c, "handle_custom_message", "(J[B)J");
9955         CHECK(calls->handle_custom_message_meth != NULL);
9956         calls->get_and_clear_pending_msg_meth = (*env)->GetMethodID(env, c, "get_and_clear_pending_msg", "()[J");
9957         CHECK(calls->get_and_clear_pending_msg_meth != NULL);
9958
9959         LDKCustomMessageHandler ret = {
9960                 .this_arg = (void*) calls,
9961                 .handle_custom_message = handle_custom_message_LDKCustomMessageHandler_jcall,
9962                 .get_and_clear_pending_msg = get_and_clear_pending_msg_LDKCustomMessageHandler_jcall,
9963                 .free = LDKCustomMessageHandler_JCalls_free,
9964                 .CustomMessageReader = LDKCustomMessageReader_init(env, clz, CustomMessageReader),
9965         };
9966         calls->CustomMessageReader = ret.CustomMessageReader.this_arg;
9967         return ret;
9968 }
9969 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCustomMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject CustomMessageReader) {
9970         LDKCustomMessageHandler *res_ptr = MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler");
9971         *res_ptr = LDKCustomMessageHandler_init(env, clz, o, CustomMessageReader);
9972         return (uint64_t)res_ptr;
9973 }
9974 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCustomMessageHandler_1get_1CustomMessageReader(JNIEnv *env, jclass clz, int64_t arg) {
9975         LDKCustomMessageHandler *inp = (LDKCustomMessageHandler *)(arg & ~1);
9976         uint64_t res_ptr = (uint64_t)&inp->CustomMessageReader;
9977         DO_ASSERT((res_ptr & 1) == 0);
9978         return (int64_t)(res_ptr | 1);
9979 }
9980 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) {
9981         LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)(((uint64_t)this_arg) & ~1);
9982         LDKType msg_conv = *(LDKType*)(((uint64_t)msg) & ~1);
9983         if (msg_conv.free == LDKType_JCalls_free) {
9984                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
9985                 LDKType_JCalls_cloned(&msg_conv);
9986         }
9987         LDKPublicKey sender_node_id_ref;
9988         CHECK((*env)->GetArrayLength(env, sender_node_id) == 33);
9989         (*env)->GetByteArrayRegion(env, sender_node_id, 0, 33, sender_node_id_ref.compressed_form);
9990         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
9991         *ret_conv = (this_arg_conv->handle_custom_message)(this_arg_conv->this_arg, msg_conv, sender_node_id_ref);
9992         return (uint64_t)ret_conv;
9993 }
9994
9995 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CustomMessageHandler_1get_1and_1clear_1pending_1msg(JNIEnv *env, jclass clz, int64_t this_arg) {
9996         LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)(((uint64_t)this_arg) & ~1);
9997         LDKCVec_C2Tuple_PublicKeyTypeZZ ret_var = (this_arg_conv->get_and_clear_pending_msg)(this_arg_conv->this_arg);
9998         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
9999         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
10000         for (size_t z = 0; z < ret_var.datalen; z++) {
10001                 LDKC2Tuple_PublicKeyTypeZ* ret_conv_25_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
10002                 *ret_conv_25_conv = ret_var.data[z];
10003                 ret_arr_ptr[z] = ((uint64_t)ret_conv_25_conv);
10004         }
10005         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
10006         FREE(ret_var.data);
10007         return ret_arr;
10008 }
10009
10010 typedef struct LDKSocketDescriptor_JCalls {
10011         atomic_size_t refcnt;
10012         JavaVM *vm;
10013         jweak o;
10014         jmethodID send_data_meth;
10015         jmethodID disconnect_socket_meth;
10016         jmethodID eq_meth;
10017         jmethodID hash_meth;
10018 } LDKSocketDescriptor_JCalls;
10019 static void LDKSocketDescriptor_JCalls_free(void* this_arg) {
10020         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
10021         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10022                 JNIEnv *env;
10023                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10024                 if (get_jenv_res == JNI_EDETACHED) {
10025                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10026                 } else {
10027                         DO_ASSERT(get_jenv_res == JNI_OK);
10028                 }
10029                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
10030                 if (get_jenv_res == JNI_EDETACHED) {
10031                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10032                 }
10033                 FREE(j_calls);
10034         }
10035 }
10036 uintptr_t send_data_LDKSocketDescriptor_jcall(void* this_arg, LDKu8slice data, bool resume_read) {
10037         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
10038         JNIEnv *env;
10039         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10040         if (get_jenv_res == JNI_EDETACHED) {
10041                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10042         } else {
10043                 DO_ASSERT(get_jenv_res == JNI_OK);
10044         }
10045         LDKu8slice data_var = data;
10046         int8_tArray data_arr = (*env)->NewByteArray(env, data_var.datalen);
10047         (*env)->SetByteArrayRegion(env, data_arr, 0, data_var.datalen, data_var.data);
10048         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10049         CHECK(obj != NULL);
10050         int64_t ret = (*env)->CallLongMethod(env, obj, j_calls->send_data_meth, data_arr, resume_read);
10051         if ((*env)->ExceptionCheck(env)) {
10052                 (*env)->ExceptionDescribe(env);
10053                 (*env)->FatalError(env, "A call to send_data in LDKSocketDescriptor from rust threw an exception.");
10054         }
10055         if (get_jenv_res == JNI_EDETACHED) {
10056                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10057         }
10058         return ret;
10059 }
10060 void disconnect_socket_LDKSocketDescriptor_jcall(void* this_arg) {
10061         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
10062         JNIEnv *env;
10063         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10064         if (get_jenv_res == JNI_EDETACHED) {
10065                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10066         } else {
10067                 DO_ASSERT(get_jenv_res == JNI_OK);
10068         }
10069         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10070         CHECK(obj != NULL);
10071         (*env)->CallVoidMethod(env, obj, j_calls->disconnect_socket_meth);
10072         if ((*env)->ExceptionCheck(env)) {
10073                 (*env)->ExceptionDescribe(env);
10074                 (*env)->FatalError(env, "A call to disconnect_socket in LDKSocketDescriptor from rust threw an exception.");
10075         }
10076         if (get_jenv_res == JNI_EDETACHED) {
10077                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10078         }
10079 }
10080 bool eq_LDKSocketDescriptor_jcall(const void* this_arg, const LDKSocketDescriptor * other_arg) {
10081         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
10082         JNIEnv *env;
10083         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10084         if (get_jenv_res == JNI_EDETACHED) {
10085                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10086         } else {
10087                 DO_ASSERT(get_jenv_res == JNI_OK);
10088         }
10089         LDKSocketDescriptor *other_arg_clone = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
10090         *other_arg_clone = SocketDescriptor_clone(other_arg);
10091         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10092         CHECK(obj != NULL);
10093         jboolean ret = (*env)->CallBooleanMethod(env, obj, j_calls->eq_meth, (uint64_t)other_arg_clone);
10094         if ((*env)->ExceptionCheck(env)) {
10095                 (*env)->ExceptionDescribe(env);
10096                 (*env)->FatalError(env, "A call to eq in LDKSocketDescriptor from rust threw an exception.");
10097         }
10098         if (get_jenv_res == JNI_EDETACHED) {
10099                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10100         }
10101         return ret;
10102 }
10103 uint64_t hash_LDKSocketDescriptor_jcall(const void* this_arg) {
10104         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
10105         JNIEnv *env;
10106         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10107         if (get_jenv_res == JNI_EDETACHED) {
10108                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10109         } else {
10110                 DO_ASSERT(get_jenv_res == JNI_OK);
10111         }
10112         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10113         CHECK(obj != NULL);
10114         int64_t ret = (*env)->CallLongMethod(env, obj, j_calls->hash_meth);
10115         if ((*env)->ExceptionCheck(env)) {
10116                 (*env)->ExceptionDescribe(env);
10117                 (*env)->FatalError(env, "A call to hash in LDKSocketDescriptor from rust threw an exception.");
10118         }
10119         if (get_jenv_res == JNI_EDETACHED) {
10120                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10121         }
10122         return ret;
10123 }
10124 static void LDKSocketDescriptor_JCalls_cloned(LDKSocketDescriptor* new_obj) {
10125         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) new_obj->this_arg;
10126         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10127 }
10128 static inline LDKSocketDescriptor LDKSocketDescriptor_init (JNIEnv *env, jclass clz, jobject o) {
10129         jclass c = (*env)->GetObjectClass(env, o);
10130         CHECK(c != NULL);
10131         LDKSocketDescriptor_JCalls *calls = MALLOC(sizeof(LDKSocketDescriptor_JCalls), "LDKSocketDescriptor_JCalls");
10132         atomic_init(&calls->refcnt, 1);
10133         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
10134         calls->o = (*env)->NewWeakGlobalRef(env, o);
10135         calls->send_data_meth = (*env)->GetMethodID(env, c, "send_data", "([BZ)J");
10136         CHECK(calls->send_data_meth != NULL);
10137         calls->disconnect_socket_meth = (*env)->GetMethodID(env, c, "disconnect_socket", "()V");
10138         CHECK(calls->disconnect_socket_meth != NULL);
10139         calls->eq_meth = (*env)->GetMethodID(env, c, "eq", "(J)Z");
10140         CHECK(calls->eq_meth != NULL);
10141         calls->hash_meth = (*env)->GetMethodID(env, c, "hash", "()J");
10142         CHECK(calls->hash_meth != NULL);
10143
10144         LDKSocketDescriptor ret = {
10145                 .this_arg = (void*) calls,
10146                 .send_data = send_data_LDKSocketDescriptor_jcall,
10147                 .disconnect_socket = disconnect_socket_LDKSocketDescriptor_jcall,
10148                 .eq = eq_LDKSocketDescriptor_jcall,
10149                 .hash = hash_LDKSocketDescriptor_jcall,
10150                 .cloned = LDKSocketDescriptor_JCalls_cloned,
10151                 .free = LDKSocketDescriptor_JCalls_free,
10152         };
10153         return ret;
10154 }
10155 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSocketDescriptor_1new(JNIEnv *env, jclass clz, jobject o) {
10156         LDKSocketDescriptor *res_ptr = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
10157         *res_ptr = LDKSocketDescriptor_init(env, clz, o);
10158         return (uint64_t)res_ptr;
10159 }
10160 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) {
10161         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)(((uint64_t)this_arg) & ~1);
10162         LDKu8slice data_ref;
10163         data_ref.datalen = (*env)->GetArrayLength(env, data);
10164         data_ref.data = (*env)->GetByteArrayElements (env, data, NULL);
10165         int64_t ret_val = (this_arg_conv->send_data)(this_arg_conv->this_arg, data_ref, resume_read);
10166         (*env)->ReleaseByteArrayElements(env, data, (int8_t*)data_ref.data, 0);
10167         return ret_val;
10168 }
10169
10170 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1disconnect_1socket(JNIEnv *env, jclass clz, int64_t this_arg) {
10171         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)(((uint64_t)this_arg) & ~1);
10172         (this_arg_conv->disconnect_socket)(this_arg_conv->this_arg);
10173 }
10174
10175 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
10176         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)(((uint64_t)this_arg) & ~1);
10177         int64_t ret_val = (this_arg_conv->hash)(this_arg_conv->this_arg);
10178         return ret_val;
10179 }
10180
10181 typedef struct LDKScore_JCalls {
10182         atomic_size_t refcnt;
10183         JavaVM *vm;
10184         jweak o;
10185         jmethodID channel_penalty_msat_meth;
10186 } LDKScore_JCalls;
10187 static void LDKScore_JCalls_free(void* this_arg) {
10188         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
10189         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10190                 JNIEnv *env;
10191                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10192                 if (get_jenv_res == JNI_EDETACHED) {
10193                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10194                 } else {
10195                         DO_ASSERT(get_jenv_res == JNI_OK);
10196                 }
10197                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
10198                 if (get_jenv_res == JNI_EDETACHED) {
10199                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10200                 }
10201                 FREE(j_calls);
10202         }
10203 }
10204 uint64_t channel_penalty_msat_LDKScore_jcall(const void* this_arg, uint64_t short_channel_id) {
10205         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
10206         JNIEnv *env;
10207         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10208         if (get_jenv_res == JNI_EDETACHED) {
10209                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10210         } else {
10211                 DO_ASSERT(get_jenv_res == JNI_OK);
10212         }
10213         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10214         CHECK(obj != NULL);
10215         int64_t ret = (*env)->CallLongMethod(env, obj, j_calls->channel_penalty_msat_meth, short_channel_id);
10216         if ((*env)->ExceptionCheck(env)) {
10217                 (*env)->ExceptionDescribe(env);
10218                 (*env)->FatalError(env, "A call to channel_penalty_msat in LDKScore from rust threw an exception.");
10219         }
10220         if (get_jenv_res == JNI_EDETACHED) {
10221                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10222         }
10223         return ret;
10224 }
10225 static void LDKScore_JCalls_cloned(LDKScore* new_obj) {
10226         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) new_obj->this_arg;
10227         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10228 }
10229 static inline LDKScore LDKScore_init (JNIEnv *env, jclass clz, jobject o) {
10230         jclass c = (*env)->GetObjectClass(env, o);
10231         CHECK(c != NULL);
10232         LDKScore_JCalls *calls = MALLOC(sizeof(LDKScore_JCalls), "LDKScore_JCalls");
10233         atomic_init(&calls->refcnt, 1);
10234         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
10235         calls->o = (*env)->NewWeakGlobalRef(env, o);
10236         calls->channel_penalty_msat_meth = (*env)->GetMethodID(env, c, "channel_penalty_msat", "(J)J");
10237         CHECK(calls->channel_penalty_msat_meth != NULL);
10238
10239         LDKScore ret = {
10240                 .this_arg = (void*) calls,
10241                 .channel_penalty_msat = channel_penalty_msat_LDKScore_jcall,
10242                 .free = LDKScore_JCalls_free,
10243         };
10244         return ret;
10245 }
10246 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKScore_1new(JNIEnv *env, jclass clz, jobject o) {
10247         LDKScore *res_ptr = MALLOC(sizeof(LDKScore), "LDKScore");
10248         *res_ptr = LDKScore_init(env, clz, o);
10249         return (uint64_t)res_ptr;
10250 }
10251 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Score_1channel_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_arg, int64_t short_channel_id) {
10252         LDKScore* this_arg_conv = (LDKScore*)(((uint64_t)this_arg) & ~1);
10253         int64_t ret_val = (this_arg_conv->channel_penalty_msat)(this_arg_conv->this_arg, short_channel_id);
10254         return ret_val;
10255 }
10256
10257 typedef struct LDKChannelManagerPersister_JCalls {
10258         atomic_size_t refcnt;
10259         JavaVM *vm;
10260         jweak o;
10261         jmethodID persist_manager_meth;
10262 } LDKChannelManagerPersister_JCalls;
10263 static void LDKChannelManagerPersister_JCalls_free(void* this_arg) {
10264         LDKChannelManagerPersister_JCalls *j_calls = (LDKChannelManagerPersister_JCalls*) this_arg;
10265         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10266                 JNIEnv *env;
10267                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10268                 if (get_jenv_res == JNI_EDETACHED) {
10269                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10270                 } else {
10271                         DO_ASSERT(get_jenv_res == JNI_OK);
10272                 }
10273                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
10274                 if (get_jenv_res == JNI_EDETACHED) {
10275                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10276                 }
10277                 FREE(j_calls);
10278         }
10279 }
10280 LDKCResult_NoneErrorZ persist_manager_LDKChannelManagerPersister_jcall(const void* this_arg, const LDKChannelManager * channel_manager) {
10281         LDKChannelManagerPersister_JCalls *j_calls = (LDKChannelManagerPersister_JCalls*) this_arg;
10282         JNIEnv *env;
10283         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10284         if (get_jenv_res == JNI_EDETACHED) {
10285                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10286         } else {
10287                 DO_ASSERT(get_jenv_res == JNI_OK);
10288         }
10289         LDKChannelManager channel_manager_var = *channel_manager;
10290         // Warning: we may need a move here but no clone is available for LDKChannelManager
10291         CHECK((((uint64_t)channel_manager_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10292         CHECK((((uint64_t)&channel_manager_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10293         uint64_t channel_manager_ref = (uint64_t)channel_manager_var.inner;
10294         if (channel_manager_var.is_owned) {
10295                 channel_manager_ref |= 1;
10296         }
10297         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10298         CHECK(obj != NULL);
10299         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->persist_manager_meth, channel_manager_ref);
10300         if ((*env)->ExceptionCheck(env)) {
10301                 (*env)->ExceptionDescribe(env);
10302                 (*env)->FatalError(env, "A call to persist_manager in LDKChannelManagerPersister from rust threw an exception.");
10303         }
10304         LDKCResult_NoneErrorZ ret_conv = *(LDKCResult_NoneErrorZ*)(((uint64_t)ret) & ~1);
10305         ret_conv = CResult_NoneErrorZ_clone((LDKCResult_NoneErrorZ*)(((uint64_t)ret) & ~1));
10306         if (get_jenv_res == JNI_EDETACHED) {
10307                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10308         }
10309         return ret_conv;
10310 }
10311 static void LDKChannelManagerPersister_JCalls_cloned(LDKChannelManagerPersister* new_obj) {
10312         LDKChannelManagerPersister_JCalls *j_calls = (LDKChannelManagerPersister_JCalls*) new_obj->this_arg;
10313         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10314 }
10315 static inline LDKChannelManagerPersister LDKChannelManagerPersister_init (JNIEnv *env, jclass clz, jobject o) {
10316         jclass c = (*env)->GetObjectClass(env, o);
10317         CHECK(c != NULL);
10318         LDKChannelManagerPersister_JCalls *calls = MALLOC(sizeof(LDKChannelManagerPersister_JCalls), "LDKChannelManagerPersister_JCalls");
10319         atomic_init(&calls->refcnt, 1);
10320         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
10321         calls->o = (*env)->NewWeakGlobalRef(env, o);
10322         calls->persist_manager_meth = (*env)->GetMethodID(env, c, "persist_manager", "(J)J");
10323         CHECK(calls->persist_manager_meth != NULL);
10324
10325         LDKChannelManagerPersister ret = {
10326                 .this_arg = (void*) calls,
10327                 .persist_manager = persist_manager_LDKChannelManagerPersister_jcall,
10328                 .free = LDKChannelManagerPersister_JCalls_free,
10329         };
10330         return ret;
10331 }
10332 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKChannelManagerPersister_1new(JNIEnv *env, jclass clz, jobject o) {
10333         LDKChannelManagerPersister *res_ptr = MALLOC(sizeof(LDKChannelManagerPersister), "LDKChannelManagerPersister");
10334         *res_ptr = LDKChannelManagerPersister_init(env, clz, o);
10335         return (uint64_t)res_ptr;
10336 }
10337 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerPersister_1persist_1manager(JNIEnv *env, jclass clz, int64_t this_arg, int64_t channel_manager) {
10338         LDKChannelManagerPersister* this_arg_conv = (LDKChannelManagerPersister*)(((uint64_t)this_arg) & ~1);
10339         LDKChannelManager channel_manager_conv;
10340         channel_manager_conv.inner = (void*)(channel_manager & (~1));
10341         channel_manager_conv.is_owned = false;
10342         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
10343         *ret_conv = (this_arg_conv->persist_manager)(this_arg_conv->this_arg, &channel_manager_conv);
10344         return (uint64_t)ret_conv;
10345 }
10346
10347 static jclass LDKFallback_SegWitProgram_class = NULL;
10348 static jmethodID LDKFallback_SegWitProgram_meth = NULL;
10349 static jclass LDKFallback_PubKeyHash_class = NULL;
10350 static jmethodID LDKFallback_PubKeyHash_meth = NULL;
10351 static jclass LDKFallback_ScriptHash_class = NULL;
10352 static jmethodID LDKFallback_ScriptHash_meth = NULL;
10353 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKFallback_init (JNIEnv *env, jclass clz) {
10354         LDKFallback_SegWitProgram_class =
10355                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKFallback$SegWitProgram;"));
10356         CHECK(LDKFallback_SegWitProgram_class != NULL);
10357         LDKFallback_SegWitProgram_meth = (*env)->GetMethodID(env, LDKFallback_SegWitProgram_class, "<init>", "(B[B)V");
10358         CHECK(LDKFallback_SegWitProgram_meth != NULL);
10359         LDKFallback_PubKeyHash_class =
10360                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKFallback$PubKeyHash;"));
10361         CHECK(LDKFallback_PubKeyHash_class != NULL);
10362         LDKFallback_PubKeyHash_meth = (*env)->GetMethodID(env, LDKFallback_PubKeyHash_class, "<init>", "([B)V");
10363         CHECK(LDKFallback_PubKeyHash_meth != NULL);
10364         LDKFallback_ScriptHash_class =
10365                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKFallback$ScriptHash;"));
10366         CHECK(LDKFallback_ScriptHash_class != NULL);
10367         LDKFallback_ScriptHash_meth = (*env)->GetMethodID(env, LDKFallback_ScriptHash_class, "<init>", "([B)V");
10368         CHECK(LDKFallback_ScriptHash_meth != NULL);
10369 }
10370 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKFallback_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
10371         LDKFallback *obj = (LDKFallback*)(ptr & ~1);
10372         switch(obj->tag) {
10373                 case LDKFallback_SegWitProgram: {
10374                         uint8_t version_val = obj->seg_wit_program.version._0;
10375                         LDKCVec_u8Z program_var = obj->seg_wit_program.program;
10376                         int8_tArray program_arr = (*env)->NewByteArray(env, program_var.datalen);
10377                         (*env)->SetByteArrayRegion(env, program_arr, 0, program_var.datalen, program_var.data);
10378                         return (*env)->NewObject(env, LDKFallback_SegWitProgram_class, LDKFallback_SegWitProgram_meth, version_val, program_arr);
10379                 }
10380                 case LDKFallback_PubKeyHash: {
10381                         int8_tArray pub_key_hash_arr = (*env)->NewByteArray(env, 20);
10382                         (*env)->SetByteArrayRegion(env, pub_key_hash_arr, 0, 20, obj->pub_key_hash.data);
10383                         return (*env)->NewObject(env, LDKFallback_PubKeyHash_class, LDKFallback_PubKeyHash_meth, pub_key_hash_arr);
10384                 }
10385                 case LDKFallback_ScriptHash: {
10386                         int8_tArray script_hash_arr = (*env)->NewByteArray(env, 20);
10387                         (*env)->SetByteArrayRegion(env, script_hash_arr, 0, 20, obj->script_hash.data);
10388                         return (*env)->NewObject(env, LDKFallback_ScriptHash_class, LDKFallback_ScriptHash_meth, script_hash_arr);
10389                 }
10390                 default: abort();
10391         }
10392 }
10393 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings__1ldk_1get_1compiled_1version(JNIEnv *env, jclass clz) {
10394         LDKStr ret_str = _ldk_get_compiled_version();
10395         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
10396         Str_free(ret_str);
10397         return ret_conv;
10398 }
10399
10400 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings__1ldk_1c_1bindings_1get_1compiled_1version(JNIEnv *env, jclass clz) {
10401         LDKStr ret_str = _ldk_c_bindings_get_compiled_version();
10402         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
10403         Str_free(ret_str);
10404         return ret_conv;
10405 }
10406
10407 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Transaction_1free(JNIEnv *env, jclass clz, int8_tArray _res) {
10408         LDKTransaction _res_ref;
10409         _res_ref.datalen = (*env)->GetArrayLength(env, _res);
10410         _res_ref.data = MALLOC(_res_ref.datalen, "LDKTransaction Bytes");
10411         (*env)->GetByteArrayRegion(env, _res, 0, _res_ref.datalen, _res_ref.data);
10412         _res_ref.data_is_owned = true;
10413         Transaction_free(_res_ref);
10414 }
10415
10416 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxOut_1new(JNIEnv *env, jclass clz, int8_tArray script_pubkey, int64_t value) {
10417         LDKCVec_u8Z script_pubkey_ref;
10418         script_pubkey_ref.datalen = (*env)->GetArrayLength(env, script_pubkey);
10419         script_pubkey_ref.data = MALLOC(script_pubkey_ref.datalen, "LDKCVec_u8Z Bytes");
10420         (*env)->GetByteArrayRegion(env, script_pubkey, 0, script_pubkey_ref.datalen, script_pubkey_ref.data);
10421         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
10422         *ret_ref = TxOut_new(script_pubkey_ref, value);
10423         return (uint64_t)ret_ref;
10424 }
10425
10426 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxOut_1free(JNIEnv *env, jclass clz, int64_t _res) {
10427         if ((_res & 1) != 0) return;
10428         LDKTxOut _res_conv = *(LDKTxOut*)(((uint64_t)_res) & ~1);
10429         FREE((void*)_res);
10430         TxOut_free(_res_conv);
10431 }
10432
10433 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxOut_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10434         LDKTxOut* orig_conv = (LDKTxOut*)(orig & ~1);
10435         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
10436         *ret_ref = TxOut_clone(orig_conv);
10437         return (uint64_t)ret_ref;
10438 }
10439
10440 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Str_1free(JNIEnv *env, jclass clz, jstring _res) {
10441         LDKStr dummy = { .chars = NULL, .len = 0, .chars_is_owned = false };
10442         Str_free(dummy);
10443 }
10444
10445 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
10446         LDKSecretKey o_ref;
10447         CHECK((*env)->GetArrayLength(env, o) == 32);
10448         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.bytes);
10449         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
10450         *ret_conv = CResult_SecretKeyErrorZ_ok(o_ref);
10451         return (uint64_t)ret_conv;
10452 }
10453
10454 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
10455         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
10456         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
10457         *ret_conv = CResult_SecretKeyErrorZ_err(e_conv);
10458         return (uint64_t)ret_conv;
10459 }
10460
10461 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10462         if ((_res & 1) != 0) return;
10463         LDKCResult_SecretKeyErrorZ _res_conv = *(LDKCResult_SecretKeyErrorZ*)(((uint64_t)_res) & ~1);
10464         FREE((void*)_res);
10465         CResult_SecretKeyErrorZ_free(_res_conv);
10466 }
10467
10468 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
10469         LDKPublicKey o_ref;
10470         CHECK((*env)->GetArrayLength(env, o) == 33);
10471         (*env)->GetByteArrayRegion(env, o, 0, 33, o_ref.compressed_form);
10472         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
10473         *ret_conv = CResult_PublicKeyErrorZ_ok(o_ref);
10474         return (uint64_t)ret_conv;
10475 }
10476
10477 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
10478         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
10479         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
10480         *ret_conv = CResult_PublicKeyErrorZ_err(e_conv);
10481         return (uint64_t)ret_conv;
10482 }
10483
10484 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10485         if ((_res & 1) != 0) return;
10486         LDKCResult_PublicKeyErrorZ _res_conv = *(LDKCResult_PublicKeyErrorZ*)(((uint64_t)_res) & ~1);
10487         FREE((void*)_res);
10488         CResult_PublicKeyErrorZ_free(_res_conv);
10489 }
10490
10491 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10492         LDKCResult_PublicKeyErrorZ* orig_conv = (LDKCResult_PublicKeyErrorZ*)(orig & ~1);
10493         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
10494         *ret_conv = CResult_PublicKeyErrorZ_clone(orig_conv);
10495         return (uint64_t)ret_conv;
10496 }
10497
10498 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10499         LDKTxCreationKeys o_conv;
10500         o_conv.inner = (void*)(o & (~1));
10501         o_conv.is_owned = (o & 1) || (o == 0);
10502         o_conv = TxCreationKeys_clone(&o_conv);
10503         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
10504         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_ok(o_conv);
10505         return (uint64_t)ret_conv;
10506 }
10507
10508 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10509         LDKDecodeError e_conv;
10510         e_conv.inner = (void*)(e & (~1));
10511         e_conv.is_owned = (e & 1) || (e == 0);
10512         e_conv = DecodeError_clone(&e_conv);
10513         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
10514         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_err(e_conv);
10515         return (uint64_t)ret_conv;
10516 }
10517
10518 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10519         if ((_res & 1) != 0) return;
10520         LDKCResult_TxCreationKeysDecodeErrorZ _res_conv = *(LDKCResult_TxCreationKeysDecodeErrorZ*)(((uint64_t)_res) & ~1);
10521         FREE((void*)_res);
10522         CResult_TxCreationKeysDecodeErrorZ_free(_res_conv);
10523 }
10524
10525 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10526         LDKCResult_TxCreationKeysDecodeErrorZ* orig_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(orig & ~1);
10527         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
10528         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(orig_conv);
10529         return (uint64_t)ret_conv;
10530 }
10531
10532 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10533         LDKChannelPublicKeys o_conv;
10534         o_conv.inner = (void*)(o & (~1));
10535         o_conv.is_owned = (o & 1) || (o == 0);
10536         o_conv = ChannelPublicKeys_clone(&o_conv);
10537         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
10538         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_ok(o_conv);
10539         return (uint64_t)ret_conv;
10540 }
10541
10542 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10543         LDKDecodeError e_conv;
10544         e_conv.inner = (void*)(e & (~1));
10545         e_conv.is_owned = (e & 1) || (e == 0);
10546         e_conv = DecodeError_clone(&e_conv);
10547         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
10548         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_err(e_conv);
10549         return (uint64_t)ret_conv;
10550 }
10551
10552 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10553         if ((_res & 1) != 0) return;
10554         LDKCResult_ChannelPublicKeysDecodeErrorZ _res_conv = *(LDKCResult_ChannelPublicKeysDecodeErrorZ*)(((uint64_t)_res) & ~1);
10555         FREE((void*)_res);
10556         CResult_ChannelPublicKeysDecodeErrorZ_free(_res_conv);
10557 }
10558
10559 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10560         LDKCResult_ChannelPublicKeysDecodeErrorZ* orig_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(orig & ~1);
10561         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
10562         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(orig_conv);
10563         return (uint64_t)ret_conv;
10564 }
10565
10566 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10567         LDKTxCreationKeys o_conv;
10568         o_conv.inner = (void*)(o & (~1));
10569         o_conv.is_owned = (o & 1) || (o == 0);
10570         o_conv = TxCreationKeys_clone(&o_conv);
10571         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
10572         *ret_conv = CResult_TxCreationKeysErrorZ_ok(o_conv);
10573         return (uint64_t)ret_conv;
10574 }
10575
10576 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
10577         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
10578         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
10579         *ret_conv = CResult_TxCreationKeysErrorZ_err(e_conv);
10580         return (uint64_t)ret_conv;
10581 }
10582
10583 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10584         if ((_res & 1) != 0) return;
10585         LDKCResult_TxCreationKeysErrorZ _res_conv = *(LDKCResult_TxCreationKeysErrorZ*)(((uint64_t)_res) & ~1);
10586         FREE((void*)_res);
10587         CResult_TxCreationKeysErrorZ_free(_res_conv);
10588 }
10589
10590 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10591         LDKCResult_TxCreationKeysErrorZ* orig_conv = (LDKCResult_TxCreationKeysErrorZ*)(orig & ~1);
10592         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
10593         *ret_conv = CResult_TxCreationKeysErrorZ_clone(orig_conv);
10594         return (uint64_t)ret_conv;
10595 }
10596
10597 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1some(JNIEnv *env, jclass clz, int32_t o) {
10598         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
10599         *ret_copy = COption_u32Z_some(o);
10600         uint64_t ret_ref = (uint64_t)ret_copy;
10601         return ret_ref;
10602 }
10603
10604 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1none(JNIEnv *env, jclass clz) {
10605         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
10606         *ret_copy = COption_u32Z_none();
10607         uint64_t ret_ref = (uint64_t)ret_copy;
10608         return ret_ref;
10609 }
10610
10611 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
10612         if ((_res & 1) != 0) return;
10613         LDKCOption_u32Z _res_conv = *(LDKCOption_u32Z*)(((uint64_t)_res) & ~1);
10614         FREE((void*)_res);
10615         COption_u32Z_free(_res_conv);
10616 }
10617
10618 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10619         LDKCOption_u32Z* orig_conv = (LDKCOption_u32Z*)orig;
10620         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
10621         *ret_copy = COption_u32Z_clone(orig_conv);
10622         uint64_t ret_ref = (uint64_t)ret_copy;
10623         return ret_ref;
10624 }
10625
10626 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10627         LDKHTLCOutputInCommitment o_conv;
10628         o_conv.inner = (void*)(o & (~1));
10629         o_conv.is_owned = (o & 1) || (o == 0);
10630         o_conv = HTLCOutputInCommitment_clone(&o_conv);
10631         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
10632         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(o_conv);
10633         return (uint64_t)ret_conv;
10634 }
10635
10636 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10637         LDKDecodeError e_conv;
10638         e_conv.inner = (void*)(e & (~1));
10639         e_conv.is_owned = (e & 1) || (e == 0);
10640         e_conv = DecodeError_clone(&e_conv);
10641         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
10642         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_err(e_conv);
10643         return (uint64_t)ret_conv;
10644 }
10645
10646 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10647         if ((_res & 1) != 0) return;
10648         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ _res_conv = *(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(((uint64_t)_res) & ~1);
10649         FREE((void*)_res);
10650         CResult_HTLCOutputInCommitmentDecodeErrorZ_free(_res_conv);
10651 }
10652
10653 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10654         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* orig_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(orig & ~1);
10655         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
10656         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(orig_conv);
10657         return (uint64_t)ret_conv;
10658 }
10659
10660 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10661         LDKCounterpartyChannelTransactionParameters o_conv;
10662         o_conv.inner = (void*)(o & (~1));
10663         o_conv.is_owned = (o & 1) || (o == 0);
10664         o_conv = CounterpartyChannelTransactionParameters_clone(&o_conv);
10665         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
10666         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(o_conv);
10667         return (uint64_t)ret_conv;
10668 }
10669
10670 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10671         LDKDecodeError e_conv;
10672         e_conv.inner = (void*)(e & (~1));
10673         e_conv.is_owned = (e & 1) || (e == 0);
10674         e_conv = DecodeError_clone(&e_conv);
10675         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
10676         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(e_conv);
10677         return (uint64_t)ret_conv;
10678 }
10679
10680 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10681         if ((_res & 1) != 0) return;
10682         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(((uint64_t)_res) & ~1);
10683         FREE((void*)_res);
10684         CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(_res_conv);
10685 }
10686
10687 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10688         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
10689         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
10690         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
10691         return (uint64_t)ret_conv;
10692 }
10693
10694 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10695         LDKChannelTransactionParameters o_conv;
10696         o_conv.inner = (void*)(o & (~1));
10697         o_conv.is_owned = (o & 1) || (o == 0);
10698         o_conv = ChannelTransactionParameters_clone(&o_conv);
10699         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
10700         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_ok(o_conv);
10701         return (uint64_t)ret_conv;
10702 }
10703
10704 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10705         LDKDecodeError e_conv;
10706         e_conv.inner = (void*)(e & (~1));
10707         e_conv.is_owned = (e & 1) || (e == 0);
10708         e_conv = DecodeError_clone(&e_conv);
10709         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
10710         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_err(e_conv);
10711         return (uint64_t)ret_conv;
10712 }
10713
10714 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10715         if ((_res & 1) != 0) return;
10716         LDKCResult_ChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(((uint64_t)_res) & ~1);
10717         FREE((void*)_res);
10718         CResult_ChannelTransactionParametersDecodeErrorZ_free(_res_conv);
10719 }
10720
10721 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10722         LDKCResult_ChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
10723         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
10724         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
10725         return (uint64_t)ret_conv;
10726 }
10727
10728 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1SignatureZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
10729         LDKCVec_SignatureZ _res_constr;
10730         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
10731         if (_res_constr.datalen > 0)
10732                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
10733         else
10734                 _res_constr.data = NULL;
10735         for (size_t i = 0; i < _res_constr.datalen; i++) {
10736                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
10737                 LDKSignature _res_conv_8_ref;
10738                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 64);
10739                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 64, _res_conv_8_ref.compact_form);
10740                 _res_constr.data[i] = _res_conv_8_ref;
10741         }
10742         CVec_SignatureZ_free(_res_constr);
10743 }
10744
10745 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10746         LDKHolderCommitmentTransaction o_conv;
10747         o_conv.inner = (void*)(o & (~1));
10748         o_conv.is_owned = (o & 1) || (o == 0);
10749         o_conv = HolderCommitmentTransaction_clone(&o_conv);
10750         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
10751         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_ok(o_conv);
10752         return (uint64_t)ret_conv;
10753 }
10754
10755 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10756         LDKDecodeError e_conv;
10757         e_conv.inner = (void*)(e & (~1));
10758         e_conv.is_owned = (e & 1) || (e == 0);
10759         e_conv = DecodeError_clone(&e_conv);
10760         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
10761         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_err(e_conv);
10762         return (uint64_t)ret_conv;
10763 }
10764
10765 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10766         if ((_res & 1) != 0) return;
10767         LDKCResult_HolderCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(((uint64_t)_res) & ~1);
10768         FREE((void*)_res);
10769         CResult_HolderCommitmentTransactionDecodeErrorZ_free(_res_conv);
10770 }
10771
10772 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10773         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(orig & ~1);
10774         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
10775         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(orig_conv);
10776         return (uint64_t)ret_conv;
10777 }
10778
10779 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10780         LDKBuiltCommitmentTransaction o_conv;
10781         o_conv.inner = (void*)(o & (~1));
10782         o_conv.is_owned = (o & 1) || (o == 0);
10783         o_conv = BuiltCommitmentTransaction_clone(&o_conv);
10784         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
10785         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(o_conv);
10786         return (uint64_t)ret_conv;
10787 }
10788
10789 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10790         LDKDecodeError e_conv;
10791         e_conv.inner = (void*)(e & (~1));
10792         e_conv.is_owned = (e & 1) || (e == 0);
10793         e_conv = DecodeError_clone(&e_conv);
10794         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
10795         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_err(e_conv);
10796         return (uint64_t)ret_conv;
10797 }
10798
10799 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10800         if ((_res & 1) != 0) return;
10801         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(((uint64_t)_res) & ~1);
10802         FREE((void*)_res);
10803         CResult_BuiltCommitmentTransactionDecodeErrorZ_free(_res_conv);
10804 }
10805
10806 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10807         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(orig & ~1);
10808         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
10809         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(orig_conv);
10810         return (uint64_t)ret_conv;
10811 }
10812
10813 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10814         LDKTrustedClosingTransaction o_conv;
10815         o_conv.inner = (void*)(o & (~1));
10816         o_conv.is_owned = (o & 1) || (o == 0);
10817         // Warning: we need a move here but no clone is available for LDKTrustedClosingTransaction
10818         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
10819         *ret_conv = CResult_TrustedClosingTransactionNoneZ_ok(o_conv);
10820         return (uint64_t)ret_conv;
10821 }
10822
10823 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1err(JNIEnv *env, jclass clz) {
10824         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
10825         *ret_conv = CResult_TrustedClosingTransactionNoneZ_err();
10826         return (uint64_t)ret_conv;
10827 }
10828
10829 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10830         if ((_res & 1) != 0) return;
10831         LDKCResult_TrustedClosingTransactionNoneZ _res_conv = *(LDKCResult_TrustedClosingTransactionNoneZ*)(((uint64_t)_res) & ~1);
10832         FREE((void*)_res);
10833         CResult_TrustedClosingTransactionNoneZ_free(_res_conv);
10834 }
10835
10836 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10837         LDKCommitmentTransaction o_conv;
10838         o_conv.inner = (void*)(o & (~1));
10839         o_conv.is_owned = (o & 1) || (o == 0);
10840         o_conv = CommitmentTransaction_clone(&o_conv);
10841         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
10842         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_ok(o_conv);
10843         return (uint64_t)ret_conv;
10844 }
10845
10846 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10847         LDKDecodeError e_conv;
10848         e_conv.inner = (void*)(e & (~1));
10849         e_conv.is_owned = (e & 1) || (e == 0);
10850         e_conv = DecodeError_clone(&e_conv);
10851         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
10852         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_err(e_conv);
10853         return (uint64_t)ret_conv;
10854 }
10855
10856 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10857         if ((_res & 1) != 0) return;
10858         LDKCResult_CommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_CommitmentTransactionDecodeErrorZ*)(((uint64_t)_res) & ~1);
10859         FREE((void*)_res);
10860         CResult_CommitmentTransactionDecodeErrorZ_free(_res_conv);
10861 }
10862
10863 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10864         LDKCResult_CommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(orig & ~1);
10865         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
10866         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(orig_conv);
10867         return (uint64_t)ret_conv;
10868 }
10869
10870 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10871         LDKTrustedCommitmentTransaction o_conv;
10872         o_conv.inner = (void*)(o & (~1));
10873         o_conv.is_owned = (o & 1) || (o == 0);
10874         // Warning: we need a move here but no clone is available for LDKTrustedCommitmentTransaction
10875         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
10876         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_ok(o_conv);
10877         return (uint64_t)ret_conv;
10878 }
10879
10880 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1err(JNIEnv *env, jclass clz) {
10881         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
10882         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_err();
10883         return (uint64_t)ret_conv;
10884 }
10885
10886 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10887         if ((_res & 1) != 0) return;
10888         LDKCResult_TrustedCommitmentTransactionNoneZ _res_conv = *(LDKCResult_TrustedCommitmentTransactionNoneZ*)(((uint64_t)_res) & ~1);
10889         FREE((void*)_res);
10890         CResult_TrustedCommitmentTransactionNoneZ_free(_res_conv);
10891 }
10892
10893 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1ok(JNIEnv *env, jclass clz, jobjectArray o) {
10894         LDKCVec_SignatureZ o_constr;
10895         o_constr.datalen = (*env)->GetArrayLength(env, o);
10896         if (o_constr.datalen > 0)
10897                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
10898         else
10899                 o_constr.data = NULL;
10900         for (size_t i = 0; i < o_constr.datalen; i++) {
10901                 int8_tArray o_conv_8 = (*env)->GetObjectArrayElement(env, o, i);
10902                 LDKSignature o_conv_8_ref;
10903                 CHECK((*env)->GetArrayLength(env, o_conv_8) == 64);
10904                 (*env)->GetByteArrayRegion(env, o_conv_8, 0, 64, o_conv_8_ref.compact_form);
10905                 o_constr.data[i] = o_conv_8_ref;
10906         }
10907         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
10908         *ret_conv = CResult_CVec_SignatureZNoneZ_ok(o_constr);
10909         return (uint64_t)ret_conv;
10910 }
10911
10912 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1err(JNIEnv *env, jclass clz) {
10913         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
10914         *ret_conv = CResult_CVec_SignatureZNoneZ_err();
10915         return (uint64_t)ret_conv;
10916 }
10917
10918 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10919         if ((_res & 1) != 0) return;
10920         LDKCResult_CVec_SignatureZNoneZ _res_conv = *(LDKCResult_CVec_SignatureZNoneZ*)(((uint64_t)_res) & ~1);
10921         FREE((void*)_res);
10922         CResult_CVec_SignatureZNoneZ_free(_res_conv);
10923 }
10924
10925 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10926         LDKCResult_CVec_SignatureZNoneZ* orig_conv = (LDKCResult_CVec_SignatureZNoneZ*)(orig & ~1);
10927         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
10928         *ret_conv = CResult_CVec_SignatureZNoneZ_clone(orig_conv);
10929         return (uint64_t)ret_conv;
10930 }
10931
10932 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10933         LDKShutdownScript o_conv;
10934         o_conv.inner = (void*)(o & (~1));
10935         o_conv.is_owned = (o & 1) || (o == 0);
10936         o_conv = ShutdownScript_clone(&o_conv);
10937         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
10938         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_ok(o_conv);
10939         return (uint64_t)ret_conv;
10940 }
10941
10942 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10943         LDKDecodeError e_conv;
10944         e_conv.inner = (void*)(e & (~1));
10945         e_conv.is_owned = (e & 1) || (e == 0);
10946         e_conv = DecodeError_clone(&e_conv);
10947         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
10948         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_err(e_conv);
10949         return (uint64_t)ret_conv;
10950 }
10951
10952 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10953         if ((_res & 1) != 0) return;
10954         LDKCResult_ShutdownScriptDecodeErrorZ _res_conv = *(LDKCResult_ShutdownScriptDecodeErrorZ*)(((uint64_t)_res) & ~1);
10955         FREE((void*)_res);
10956         CResult_ShutdownScriptDecodeErrorZ_free(_res_conv);
10957 }
10958
10959 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10960         LDKCResult_ShutdownScriptDecodeErrorZ* orig_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(orig & ~1);
10961         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
10962         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone(orig_conv);
10963         return (uint64_t)ret_conv;
10964 }
10965
10966 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10967         LDKShutdownScript o_conv;
10968         o_conv.inner = (void*)(o & (~1));
10969         o_conv.is_owned = (o & 1) || (o == 0);
10970         o_conv = ShutdownScript_clone(&o_conv);
10971         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
10972         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_ok(o_conv);
10973         return (uint64_t)ret_conv;
10974 }
10975
10976 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10977         LDKInvalidShutdownScript e_conv;
10978         e_conv.inner = (void*)(e & (~1));
10979         e_conv.is_owned = (e & 1) || (e == 0);
10980         // Warning: we need a move here but no clone is available for LDKInvalidShutdownScript
10981         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
10982         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_err(e_conv);
10983         return (uint64_t)ret_conv;
10984 }
10985
10986 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10987         if ((_res & 1) != 0) return;
10988         LDKCResult_ShutdownScriptInvalidShutdownScriptZ _res_conv = *(LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(((uint64_t)_res) & ~1);
10989         FREE((void*)_res);
10990         CResult_ShutdownScriptInvalidShutdownScriptZ_free(_res_conv);
10991 }
10992
10993 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1ok(JNIEnv *env, jclass clz) {
10994         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
10995         *ret_conv = CResult_NoneErrorZ_ok();
10996         return (uint64_t)ret_conv;
10997 }
10998
10999 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
11000         LDKIOError e_conv = LDKIOError_from_java(env, e);
11001         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
11002         *ret_conv = CResult_NoneErrorZ_err(e_conv);
11003         return (uint64_t)ret_conv;
11004 }
11005
11006 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11007         if ((_res & 1) != 0) return;
11008         LDKCResult_NoneErrorZ _res_conv = *(LDKCResult_NoneErrorZ*)(((uint64_t)_res) & ~1);
11009         FREE((void*)_res);
11010         CResult_NoneErrorZ_free(_res_conv);
11011 }
11012
11013 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11014         LDKCResult_NoneErrorZ* orig_conv = (LDKCResult_NoneErrorZ*)(orig & ~1);
11015         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
11016         *ret_conv = CResult_NoneErrorZ_clone(orig_conv);
11017         return (uint64_t)ret_conv;
11018 }
11019
11020 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11021         LDKRouteHop o_conv;
11022         o_conv.inner = (void*)(o & (~1));
11023         o_conv.is_owned = (o & 1) || (o == 0);
11024         o_conv = RouteHop_clone(&o_conv);
11025         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
11026         *ret_conv = CResult_RouteHopDecodeErrorZ_ok(o_conv);
11027         return (uint64_t)ret_conv;
11028 }
11029
11030 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11031         LDKDecodeError e_conv;
11032         e_conv.inner = (void*)(e & (~1));
11033         e_conv.is_owned = (e & 1) || (e == 0);
11034         e_conv = DecodeError_clone(&e_conv);
11035         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
11036         *ret_conv = CResult_RouteHopDecodeErrorZ_err(e_conv);
11037         return (uint64_t)ret_conv;
11038 }
11039
11040 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11041         if ((_res & 1) != 0) return;
11042         LDKCResult_RouteHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHopDecodeErrorZ*)(((uint64_t)_res) & ~1);
11043         FREE((void*)_res);
11044         CResult_RouteHopDecodeErrorZ_free(_res_conv);
11045 }
11046
11047 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11048         LDKCResult_RouteHopDecodeErrorZ* orig_conv = (LDKCResult_RouteHopDecodeErrorZ*)(orig & ~1);
11049         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
11050         *ret_conv = CResult_RouteHopDecodeErrorZ_clone(orig_conv);
11051         return (uint64_t)ret_conv;
11052 }
11053
11054 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHopZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
11055         LDKCVec_RouteHopZ _res_constr;
11056         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11057         if (_res_constr.datalen > 0)
11058                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
11059         else
11060                 _res_constr.data = NULL;
11061         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
11062         for (size_t k = 0; k < _res_constr.datalen; k++) {
11063                 int64_t _res_conv_10 = _res_vals[k];
11064                 LDKRouteHop _res_conv_10_conv;
11065                 _res_conv_10_conv.inner = (void*)(_res_conv_10 & (~1));
11066                 _res_conv_10_conv.is_owned = (_res_conv_10 & 1) || (_res_conv_10 == 0);
11067                 _res_constr.data[k] = _res_conv_10_conv;
11068         }
11069         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
11070         CVec_RouteHopZ_free(_res_constr);
11071 }
11072
11073 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CVec_1RouteHopZZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
11074         LDKCVec_CVec_RouteHopZZ _res_constr;
11075         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11076         if (_res_constr.datalen > 0)
11077                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
11078         else
11079                 _res_constr.data = NULL;
11080         for (size_t m = 0; m < _res_constr.datalen; m++) {
11081                 int64_tArray _res_conv_12 = (*env)->GetObjectArrayElement(env, _res, m);
11082                 LDKCVec_RouteHopZ _res_conv_12_constr;
11083                 _res_conv_12_constr.datalen = (*env)->GetArrayLength(env, _res_conv_12);
11084                 if (_res_conv_12_constr.datalen > 0)
11085                         _res_conv_12_constr.data = MALLOC(_res_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
11086                 else
11087                         _res_conv_12_constr.data = NULL;
11088                 int64_t* _res_conv_12_vals = (*env)->GetLongArrayElements (env, _res_conv_12, NULL);
11089                 for (size_t k = 0; k < _res_conv_12_constr.datalen; k++) {
11090                         int64_t _res_conv_12_conv_10 = _res_conv_12_vals[k];
11091                         LDKRouteHop _res_conv_12_conv_10_conv;
11092                         _res_conv_12_conv_10_conv.inner = (void*)(_res_conv_12_conv_10 & (~1));
11093                         _res_conv_12_conv_10_conv.is_owned = (_res_conv_12_conv_10 & 1) || (_res_conv_12_conv_10 == 0);
11094                         _res_conv_12_constr.data[k] = _res_conv_12_conv_10_conv;
11095                 }
11096                 (*env)->ReleaseLongArrayElements(env, _res_conv_12, _res_conv_12_vals, 0);
11097                 _res_constr.data[m] = _res_conv_12_constr;
11098         }
11099         CVec_CVec_RouteHopZZ_free(_res_constr);
11100 }
11101
11102 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11103         LDKRoute o_conv;
11104         o_conv.inner = (void*)(o & (~1));
11105         o_conv.is_owned = (o & 1) || (o == 0);
11106         o_conv = Route_clone(&o_conv);
11107         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
11108         *ret_conv = CResult_RouteDecodeErrorZ_ok(o_conv);
11109         return (uint64_t)ret_conv;
11110 }
11111
11112 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11113         LDKDecodeError e_conv;
11114         e_conv.inner = (void*)(e & (~1));
11115         e_conv.is_owned = (e & 1) || (e == 0);
11116         e_conv = DecodeError_clone(&e_conv);
11117         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
11118         *ret_conv = CResult_RouteDecodeErrorZ_err(e_conv);
11119         return (uint64_t)ret_conv;
11120 }
11121
11122 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11123         if ((_res & 1) != 0) return;
11124         LDKCResult_RouteDecodeErrorZ _res_conv = *(LDKCResult_RouteDecodeErrorZ*)(((uint64_t)_res) & ~1);
11125         FREE((void*)_res);
11126         CResult_RouteDecodeErrorZ_free(_res_conv);
11127 }
11128
11129 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11130         LDKCResult_RouteDecodeErrorZ* orig_conv = (LDKCResult_RouteDecodeErrorZ*)(orig & ~1);
11131         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
11132         *ret_conv = CResult_RouteDecodeErrorZ_clone(orig_conv);
11133         return (uint64_t)ret_conv;
11134 }
11135
11136 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1some(JNIEnv *env, jclass clz, int64_t o) {
11137         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
11138         *ret_copy = COption_u64Z_some(o);
11139         uint64_t ret_ref = (uint64_t)ret_copy;
11140         return ret_ref;
11141 }
11142
11143 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1none(JNIEnv *env, jclass clz) {
11144         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
11145         *ret_copy = COption_u64Z_none();
11146         uint64_t ret_ref = (uint64_t)ret_copy;
11147         return ret_ref;
11148 }
11149
11150 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
11151         if ((_res & 1) != 0) return;
11152         LDKCOption_u64Z _res_conv = *(LDKCOption_u64Z*)(((uint64_t)_res) & ~1);
11153         FREE((void*)_res);
11154         COption_u64Z_free(_res_conv);
11155 }
11156
11157 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11158         LDKCOption_u64Z* orig_conv = (LDKCOption_u64Z*)orig;
11159         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
11160         *ret_copy = COption_u64Z_clone(orig_conv);
11161         uint64_t ret_ref = (uint64_t)ret_copy;
11162         return ret_ref;
11163 }
11164
11165 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ChannelDetailsZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
11166         LDKCVec_ChannelDetailsZ _res_constr;
11167         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11168         if (_res_constr.datalen > 0)
11169                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
11170         else
11171                 _res_constr.data = NULL;
11172         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
11173         for (size_t q = 0; q < _res_constr.datalen; q++) {
11174                 int64_t _res_conv_16 = _res_vals[q];
11175                 LDKChannelDetails _res_conv_16_conv;
11176                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
11177                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
11178                 _res_constr.data[q] = _res_conv_16_conv;
11179         }
11180         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
11181         CVec_ChannelDetailsZ_free(_res_constr);
11182 }
11183
11184 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHintZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
11185         LDKCVec_RouteHintZ _res_constr;
11186         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11187         if (_res_constr.datalen > 0)
11188                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
11189         else
11190                 _res_constr.data = NULL;
11191         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
11192         for (size_t l = 0; l < _res_constr.datalen; l++) {
11193                 int64_t _res_conv_11 = _res_vals[l];
11194                 LDKRouteHint _res_conv_11_conv;
11195                 _res_conv_11_conv.inner = (void*)(_res_conv_11 & (~1));
11196                 _res_conv_11_conv.is_owned = (_res_conv_11 & 1) || (_res_conv_11 == 0);
11197                 _res_constr.data[l] = _res_conv_11_conv;
11198         }
11199         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
11200         CVec_RouteHintZ_free(_res_constr);
11201 }
11202
11203 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11204         LDKRoute o_conv;
11205         o_conv.inner = (void*)(o & (~1));
11206         o_conv.is_owned = (o & 1) || (o == 0);
11207         o_conv = Route_clone(&o_conv);
11208         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
11209         *ret_conv = CResult_RouteLightningErrorZ_ok(o_conv);
11210         return (uint64_t)ret_conv;
11211 }
11212
11213 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11214         LDKLightningError e_conv;
11215         e_conv.inner = (void*)(e & (~1));
11216         e_conv.is_owned = (e & 1) || (e == 0);
11217         e_conv = LightningError_clone(&e_conv);
11218         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
11219         *ret_conv = CResult_RouteLightningErrorZ_err(e_conv);
11220         return (uint64_t)ret_conv;
11221 }
11222
11223 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11224         if ((_res & 1) != 0) return;
11225         LDKCResult_RouteLightningErrorZ _res_conv = *(LDKCResult_RouteLightningErrorZ*)(((uint64_t)_res) & ~1);
11226         FREE((void*)_res);
11227         CResult_RouteLightningErrorZ_free(_res_conv);
11228 }
11229
11230 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11231         LDKCResult_RouteLightningErrorZ* orig_conv = (LDKCResult_RouteLightningErrorZ*)(orig & ~1);
11232         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
11233         *ret_conv = CResult_RouteLightningErrorZ_clone(orig_conv);
11234         return (uint64_t)ret_conv;
11235 }
11236
11237 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11238         LDKTxOut o_conv = *(LDKTxOut*)(((uint64_t)o) & ~1);
11239         o_conv = TxOut_clone((LDKTxOut*)(((uint64_t)o) & ~1));
11240         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
11241         *ret_conv = CResult_TxOutAccessErrorZ_ok(o_conv);
11242         return (uint64_t)ret_conv;
11243 }
11244
11245 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
11246         LDKAccessError e_conv = LDKAccessError_from_java(env, e);
11247         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
11248         *ret_conv = CResult_TxOutAccessErrorZ_err(e_conv);
11249         return (uint64_t)ret_conv;
11250 }
11251
11252 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11253         if ((_res & 1) != 0) return;
11254         LDKCResult_TxOutAccessErrorZ _res_conv = *(LDKCResult_TxOutAccessErrorZ*)(((uint64_t)_res) & ~1);
11255         FREE((void*)_res);
11256         CResult_TxOutAccessErrorZ_free(_res_conv);
11257 }
11258
11259 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11260         LDKCResult_TxOutAccessErrorZ* orig_conv = (LDKCResult_TxOutAccessErrorZ*)(orig & ~1);
11261         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
11262         *ret_conv = CResult_TxOutAccessErrorZ_clone(orig_conv);
11263         return (uint64_t)ret_conv;
11264 }
11265
11266 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11267         LDKC2Tuple_usizeTransactionZ* orig_conv = (LDKC2Tuple_usizeTransactionZ*)(orig & ~1);
11268         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
11269         *ret_conv = C2Tuple_usizeTransactionZ_clone(orig_conv);
11270         return ((uint64_t)ret_conv);
11271 }
11272
11273 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
11274         LDKTransaction b_ref;
11275         b_ref.datalen = (*env)->GetArrayLength(env, b);
11276         b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
11277         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
11278         b_ref.data_is_owned = true;
11279         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
11280         *ret_conv = C2Tuple_usizeTransactionZ_new(a, b_ref);
11281         return ((uint64_t)ret_conv);
11282 }
11283
11284 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11285         if ((_res & 1) != 0) return;
11286         LDKC2Tuple_usizeTransactionZ _res_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)_res) & ~1);
11287         FREE((void*)_res);
11288         C2Tuple_usizeTransactionZ_free(_res_conv);
11289 }
11290
11291 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1usizeTransactionZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
11292         LDKCVec_C2Tuple_usizeTransactionZZ _res_constr;
11293         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11294         if (_res_constr.datalen > 0)
11295                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
11296         else
11297                 _res_constr.data = NULL;
11298         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
11299         for (size_t c = 0; c < _res_constr.datalen; c++) {
11300                 int64_t _res_conv_28 = _res_vals[c];
11301                 LDKC2Tuple_usizeTransactionZ _res_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)_res_conv_28) & ~1);
11302                 FREE((void*)_res_conv_28);
11303                 _res_constr.data[c] = _res_conv_28_conv;
11304         }
11305         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
11306         CVec_C2Tuple_usizeTransactionZZ_free(_res_constr);
11307 }
11308
11309 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TxidZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
11310         LDKCVec_TxidZ _res_constr;
11311         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11312         if (_res_constr.datalen > 0)
11313                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
11314         else
11315                 _res_constr.data = NULL;
11316         for (size_t i = 0; i < _res_constr.datalen; i++) {
11317                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
11318                 LDKThirtyTwoBytes _res_conv_8_ref;
11319                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 32);
11320                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 32, _res_conv_8_ref.data);
11321                 _res_constr.data[i] = _res_conv_8_ref;
11322         }
11323         CVec_TxidZ_free(_res_constr);
11324 }
11325
11326 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1ok(JNIEnv *env, jclass clz) {
11327         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
11328         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_ok();
11329         return (uint64_t)ret_conv;
11330 }
11331
11332 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1err(JNIEnv *env, jclass clz, jclass e) {
11333         LDKChannelMonitorUpdateErr e_conv = LDKChannelMonitorUpdateErr_from_java(env, e);
11334         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
11335         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_err(e_conv);
11336         return (uint64_t)ret_conv;
11337 }
11338
11339 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11340         if ((_res & 1) != 0) return;
11341         LDKCResult_NoneChannelMonitorUpdateErrZ _res_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)_res) & ~1);
11342         FREE((void*)_res);
11343         CResult_NoneChannelMonitorUpdateErrZ_free(_res_conv);
11344 }
11345
11346 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11347         LDKCResult_NoneChannelMonitorUpdateErrZ* orig_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(orig & ~1);
11348         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
11349         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone(orig_conv);
11350         return (uint64_t)ret_conv;
11351 }
11352
11353 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1MonitorEventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
11354         LDKCVec_MonitorEventZ _res_constr;
11355         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11356         if (_res_constr.datalen > 0)
11357                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
11358         else
11359                 _res_constr.data = NULL;
11360         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
11361         for (size_t o = 0; o < _res_constr.datalen; o++) {
11362                 int64_t _res_conv_14 = _res_vals[o];
11363                 LDKMonitorEvent _res_conv_14_conv = *(LDKMonitorEvent*)(((uint64_t)_res_conv_14) & ~1);
11364                 FREE((void*)_res_conv_14);
11365                 _res_constr.data[o] = _res_conv_14_conv;
11366         }
11367         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
11368         CVec_MonitorEventZ_free(_res_constr);
11369 }
11370
11371 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1some(JNIEnv *env, jclass clz, int64_t o) {
11372         LDKC2Tuple_usizeTransactionZ o_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)o) & ~1);
11373         o_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)o) & ~1));
11374         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
11375         *ret_copy = COption_C2Tuple_usizeTransactionZZ_some(o_conv);
11376         uint64_t ret_ref = (uint64_t)ret_copy;
11377         return ret_ref;
11378 }
11379
11380 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1none(JNIEnv *env, jclass clz) {
11381         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
11382         *ret_copy = COption_C2Tuple_usizeTransactionZZ_none();
11383         uint64_t ret_ref = (uint64_t)ret_copy;
11384         return ret_ref;
11385 }
11386
11387 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11388         if ((_res & 1) != 0) return;
11389         LDKCOption_C2Tuple_usizeTransactionZZ _res_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(((uint64_t)_res) & ~1);
11390         FREE((void*)_res);
11391         COption_C2Tuple_usizeTransactionZZ_free(_res_conv);
11392 }
11393
11394 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11395         LDKCOption_C2Tuple_usizeTransactionZZ* orig_conv = (LDKCOption_C2Tuple_usizeTransactionZZ*)orig;
11396         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
11397         *ret_copy = COption_C2Tuple_usizeTransactionZZ_clone(orig_conv);
11398         uint64_t ret_ref = (uint64_t)ret_copy;
11399         return ret_ref;
11400 }
11401
11402 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1some(JNIEnv *env, jclass clz, int64_t o) {
11403         LDKNetworkUpdate o_conv = *(LDKNetworkUpdate*)(((uint64_t)o) & ~1);
11404         o_conv = NetworkUpdate_clone((LDKNetworkUpdate*)(((uint64_t)o) & ~1));
11405         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
11406         *ret_copy = COption_NetworkUpdateZ_some(o_conv);
11407         uint64_t ret_ref = (uint64_t)ret_copy;
11408         return ret_ref;
11409 }
11410
11411 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1none(JNIEnv *env, jclass clz) {
11412         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
11413         *ret_copy = COption_NetworkUpdateZ_none();
11414         uint64_t ret_ref = (uint64_t)ret_copy;
11415         return ret_ref;
11416 }
11417
11418 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11419         if ((_res & 1) != 0) return;
11420         LDKCOption_NetworkUpdateZ _res_conv = *(LDKCOption_NetworkUpdateZ*)(((uint64_t)_res) & ~1);
11421         FREE((void*)_res);
11422         COption_NetworkUpdateZ_free(_res_conv);
11423 }
11424
11425 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11426         LDKCOption_NetworkUpdateZ* orig_conv = (LDKCOption_NetworkUpdateZ*)orig;
11427         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
11428         *ret_copy = COption_NetworkUpdateZ_clone(orig_conv);
11429         uint64_t ret_ref = (uint64_t)ret_copy;
11430         return ret_ref;
11431 }
11432
11433 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1SpendableOutputDescriptorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
11434         LDKCVec_SpendableOutputDescriptorZ _res_constr;
11435         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11436         if (_res_constr.datalen > 0)
11437                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
11438         else
11439                 _res_constr.data = NULL;
11440         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
11441         for (size_t b = 0; b < _res_constr.datalen; b++) {
11442                 int64_t _res_conv_27 = _res_vals[b];
11443                 LDKSpendableOutputDescriptor _res_conv_27_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)_res_conv_27) & ~1);
11444                 FREE((void*)_res_conv_27);
11445                 _res_constr.data[b] = _res_conv_27_conv;
11446         }
11447         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
11448         CVec_SpendableOutputDescriptorZ_free(_res_constr);
11449 }
11450
11451 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1MessageSendEventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
11452         LDKCVec_MessageSendEventZ _res_constr;
11453         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11454         if (_res_constr.datalen > 0)
11455                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
11456         else
11457                 _res_constr.data = NULL;
11458         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
11459         for (size_t s = 0; s < _res_constr.datalen; s++) {
11460                 int64_t _res_conv_18 = _res_vals[s];
11461                 LDKMessageSendEvent _res_conv_18_conv = *(LDKMessageSendEvent*)(((uint64_t)_res_conv_18) & ~1);
11462                 FREE((void*)_res_conv_18);
11463                 _res_constr.data[s] = _res_conv_18_conv;
11464         }
11465         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
11466         CVec_MessageSendEventZ_free(_res_constr);
11467 }
11468
11469 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11470         LDKInitFeatures o_conv;
11471         o_conv.inner = (void*)(o & (~1));
11472         o_conv.is_owned = (o & 1) || (o == 0);
11473         o_conv = InitFeatures_clone(&o_conv);
11474         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
11475         *ret_conv = CResult_InitFeaturesDecodeErrorZ_ok(o_conv);
11476         return (uint64_t)ret_conv;
11477 }
11478
11479 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11480         LDKDecodeError e_conv;
11481         e_conv.inner = (void*)(e & (~1));
11482         e_conv.is_owned = (e & 1) || (e == 0);
11483         e_conv = DecodeError_clone(&e_conv);
11484         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
11485         *ret_conv = CResult_InitFeaturesDecodeErrorZ_err(e_conv);
11486         return (uint64_t)ret_conv;
11487 }
11488
11489 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11490         if ((_res & 1) != 0) return;
11491         LDKCResult_InitFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InitFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
11492         FREE((void*)_res);
11493         CResult_InitFeaturesDecodeErrorZ_free(_res_conv);
11494 }
11495
11496 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11497         LDKNodeFeatures o_conv;
11498         o_conv.inner = (void*)(o & (~1));
11499         o_conv.is_owned = (o & 1) || (o == 0);
11500         o_conv = NodeFeatures_clone(&o_conv);
11501         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
11502         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_ok(o_conv);
11503         return (uint64_t)ret_conv;
11504 }
11505
11506 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11507         LDKDecodeError e_conv;
11508         e_conv.inner = (void*)(e & (~1));
11509         e_conv.is_owned = (e & 1) || (e == 0);
11510         e_conv = DecodeError_clone(&e_conv);
11511         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
11512         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_err(e_conv);
11513         return (uint64_t)ret_conv;
11514 }
11515
11516 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11517         if ((_res & 1) != 0) return;
11518         LDKCResult_NodeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_NodeFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
11519         FREE((void*)_res);
11520         CResult_NodeFeaturesDecodeErrorZ_free(_res_conv);
11521 }
11522
11523 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11524         LDKChannelFeatures o_conv;
11525         o_conv.inner = (void*)(o & (~1));
11526         o_conv.is_owned = (o & 1) || (o == 0);
11527         o_conv = ChannelFeatures_clone(&o_conv);
11528         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
11529         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_ok(o_conv);
11530         return (uint64_t)ret_conv;
11531 }
11532
11533 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11534         LDKDecodeError e_conv;
11535         e_conv.inner = (void*)(e & (~1));
11536         e_conv.is_owned = (e & 1) || (e == 0);
11537         e_conv = DecodeError_clone(&e_conv);
11538         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
11539         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_err(e_conv);
11540         return (uint64_t)ret_conv;
11541 }
11542
11543 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11544         if ((_res & 1) != 0) return;
11545         LDKCResult_ChannelFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
11546         FREE((void*)_res);
11547         CResult_ChannelFeaturesDecodeErrorZ_free(_res_conv);
11548 }
11549
11550 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11551         LDKInvoiceFeatures o_conv;
11552         o_conv.inner = (void*)(o & (~1));
11553         o_conv.is_owned = (o & 1) || (o == 0);
11554         o_conv = InvoiceFeatures_clone(&o_conv);
11555         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
11556         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_ok(o_conv);
11557         return (uint64_t)ret_conv;
11558 }
11559
11560 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11561         LDKDecodeError e_conv;
11562         e_conv.inner = (void*)(e & (~1));
11563         e_conv.is_owned = (e & 1) || (e == 0);
11564         e_conv = DecodeError_clone(&e_conv);
11565         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
11566         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_err(e_conv);
11567         return (uint64_t)ret_conv;
11568 }
11569
11570 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11571         if ((_res & 1) != 0) return;
11572         LDKCResult_InvoiceFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InvoiceFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
11573         FREE((void*)_res);
11574         CResult_InvoiceFeaturesDecodeErrorZ_free(_res_conv);
11575 }
11576
11577 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11578         LDKDelayedPaymentOutputDescriptor o_conv;
11579         o_conv.inner = (void*)(o & (~1));
11580         o_conv.is_owned = (o & 1) || (o == 0);
11581         o_conv = DelayedPaymentOutputDescriptor_clone(&o_conv);
11582         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
11583         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
11584         return (uint64_t)ret_conv;
11585 }
11586
11587 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11588         LDKDecodeError e_conv;
11589         e_conv.inner = (void*)(e & (~1));
11590         e_conv.is_owned = (e & 1) || (e == 0);
11591         e_conv = DecodeError_clone(&e_conv);
11592         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
11593         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
11594         return (uint64_t)ret_conv;
11595 }
11596
11597 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11598         if ((_res & 1) != 0) return;
11599         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(((uint64_t)_res) & ~1);
11600         FREE((void*)_res);
11601         CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
11602 }
11603
11604 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11605         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(orig & ~1);
11606         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
11607         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
11608         return (uint64_t)ret_conv;
11609 }
11610
11611 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11612         LDKStaticPaymentOutputDescriptor o_conv;
11613         o_conv.inner = (void*)(o & (~1));
11614         o_conv.is_owned = (o & 1) || (o == 0);
11615         o_conv = StaticPaymentOutputDescriptor_clone(&o_conv);
11616         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
11617         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
11618         return (uint64_t)ret_conv;
11619 }
11620
11621 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11622         LDKDecodeError e_conv;
11623         e_conv.inner = (void*)(e & (~1));
11624         e_conv.is_owned = (e & 1) || (e == 0);
11625         e_conv = DecodeError_clone(&e_conv);
11626         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
11627         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
11628         return (uint64_t)ret_conv;
11629 }
11630
11631 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11632         if ((_res & 1) != 0) return;
11633         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(((uint64_t)_res) & ~1);
11634         FREE((void*)_res);
11635         CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
11636 }
11637
11638 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11639         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(orig & ~1);
11640         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
11641         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
11642         return (uint64_t)ret_conv;
11643 }
11644
11645 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11646         LDKSpendableOutputDescriptor o_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)o) & ~1);
11647         o_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uint64_t)o) & ~1));
11648         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
11649         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_ok(o_conv);
11650         return (uint64_t)ret_conv;
11651 }
11652
11653 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11654         LDKDecodeError e_conv;
11655         e_conv.inner = (void*)(e & (~1));
11656         e_conv.is_owned = (e & 1) || (e == 0);
11657         e_conv = DecodeError_clone(&e_conv);
11658         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
11659         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_err(e_conv);
11660         return (uint64_t)ret_conv;
11661 }
11662
11663 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11664         if ((_res & 1) != 0) return;
11665         LDKCResult_SpendableOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(((uint64_t)_res) & ~1);
11666         FREE((void*)_res);
11667         CResult_SpendableOutputDescriptorDecodeErrorZ_free(_res_conv);
11668 }
11669
11670 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11671         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(orig & ~1);
11672         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
11673         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(orig_conv);
11674         return (uint64_t)ret_conv;
11675 }
11676
11677 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1ok(JNIEnv *env, jclass clz) {
11678         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
11679         *ret_conv = CResult_NoneNoneZ_ok();
11680         return (uint64_t)ret_conv;
11681 }
11682
11683 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1err(JNIEnv *env, jclass clz) {
11684         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
11685         *ret_conv = CResult_NoneNoneZ_err();
11686         return (uint64_t)ret_conv;
11687 }
11688
11689 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11690         if ((_res & 1) != 0) return;
11691         LDKCResult_NoneNoneZ _res_conv = *(LDKCResult_NoneNoneZ*)(((uint64_t)_res) & ~1);
11692         FREE((void*)_res);
11693         CResult_NoneNoneZ_free(_res_conv);
11694 }
11695
11696 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11697         LDKCResult_NoneNoneZ* orig_conv = (LDKCResult_NoneNoneZ*)(orig & ~1);
11698         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
11699         *ret_conv = CResult_NoneNoneZ_clone(orig_conv);
11700         return (uint64_t)ret_conv;
11701 }
11702
11703 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11704         LDKC2Tuple_SignatureCVec_SignatureZZ* orig_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(orig & ~1);
11705         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
11706         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_clone(orig_conv);
11707         return ((uint64_t)ret_conv);
11708 }
11709
11710 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, jobjectArray b) {
11711         LDKSignature a_ref;
11712         CHECK((*env)->GetArrayLength(env, a) == 64);
11713         (*env)->GetByteArrayRegion(env, a, 0, 64, a_ref.compact_form);
11714         LDKCVec_SignatureZ b_constr;
11715         b_constr.datalen = (*env)->GetArrayLength(env, b);
11716         if (b_constr.datalen > 0)
11717                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
11718         else
11719                 b_constr.data = NULL;
11720         for (size_t i = 0; i < b_constr.datalen; i++) {
11721                 int8_tArray b_conv_8 = (*env)->GetObjectArrayElement(env, b, i);
11722                 LDKSignature b_conv_8_ref;
11723                 CHECK((*env)->GetArrayLength(env, b_conv_8) == 64);
11724                 (*env)->GetByteArrayRegion(env, b_conv_8, 0, 64, b_conv_8_ref.compact_form);
11725                 b_constr.data[i] = b_conv_8_ref;
11726         }
11727         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
11728         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_new(a_ref, b_constr);
11729         return ((uint64_t)ret_conv);
11730 }
11731
11732 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11733         if ((_res & 1) != 0) return;
11734         LDKC2Tuple_SignatureCVec_SignatureZZ _res_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(((uint64_t)_res) & ~1);
11735         FREE((void*)_res);
11736         C2Tuple_SignatureCVec_SignatureZZ_free(_res_conv);
11737 }
11738
11739 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11740         LDKC2Tuple_SignatureCVec_SignatureZZ o_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(((uint64_t)o) & ~1);
11741         o_conv = C2Tuple_SignatureCVec_SignatureZZ_clone((LDKC2Tuple_SignatureCVec_SignatureZZ*)(((uint64_t)o) & ~1));
11742         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
11743         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(o_conv);
11744         return (uint64_t)ret_conv;
11745 }
11746
11747 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1err(JNIEnv *env, jclass clz) {
11748         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
11749         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err();
11750         return (uint64_t)ret_conv;
11751 }
11752
11753 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11754         if ((_res & 1) != 0) return;
11755         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ _res_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)_res) & ~1);
11756         FREE((void*)_res);
11757         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(_res_conv);
11758 }
11759
11760 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11761         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* orig_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(orig & ~1);
11762         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
11763         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(orig_conv);
11764         return (uint64_t)ret_conv;
11765 }
11766
11767 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
11768         LDKSignature o_ref;
11769         CHECK((*env)->GetArrayLength(env, o) == 64);
11770         (*env)->GetByteArrayRegion(env, o, 0, 64, o_ref.compact_form);
11771         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
11772         *ret_conv = CResult_SignatureNoneZ_ok(o_ref);
11773         return (uint64_t)ret_conv;
11774 }
11775
11776 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1err(JNIEnv *env, jclass clz) {
11777         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
11778         *ret_conv = CResult_SignatureNoneZ_err();
11779         return (uint64_t)ret_conv;
11780 }
11781
11782 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11783         if ((_res & 1) != 0) return;
11784         LDKCResult_SignatureNoneZ _res_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)_res) & ~1);
11785         FREE((void*)_res);
11786         CResult_SignatureNoneZ_free(_res_conv);
11787 }
11788
11789 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11790         LDKCResult_SignatureNoneZ* orig_conv = (LDKCResult_SignatureNoneZ*)(orig & ~1);
11791         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
11792         *ret_conv = CResult_SignatureNoneZ_clone(orig_conv);
11793         return (uint64_t)ret_conv;
11794 }
11795
11796 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11797         LDKSign o_conv = *(LDKSign*)(((uint64_t)o) & ~1);
11798         if (o_conv.free == LDKSign_JCalls_free) {
11799                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
11800                 LDKSign_JCalls_cloned(&o_conv);
11801         }
11802         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
11803         *ret_conv = CResult_SignDecodeErrorZ_ok(o_conv);
11804         return (uint64_t)ret_conv;
11805 }
11806
11807 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11808         LDKDecodeError e_conv;
11809         e_conv.inner = (void*)(e & (~1));
11810         e_conv.is_owned = (e & 1) || (e == 0);
11811         e_conv = DecodeError_clone(&e_conv);
11812         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
11813         *ret_conv = CResult_SignDecodeErrorZ_err(e_conv);
11814         return (uint64_t)ret_conv;
11815 }
11816
11817 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11818         if ((_res & 1) != 0) return;
11819         LDKCResult_SignDecodeErrorZ _res_conv = *(LDKCResult_SignDecodeErrorZ*)(((uint64_t)_res) & ~1);
11820         FREE((void*)_res);
11821         CResult_SignDecodeErrorZ_free(_res_conv);
11822 }
11823
11824 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11825         LDKCResult_SignDecodeErrorZ* orig_conv = (LDKCResult_SignDecodeErrorZ*)(orig & ~1);
11826         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
11827         *ret_conv = CResult_SignDecodeErrorZ_clone(orig_conv);
11828         return (uint64_t)ret_conv;
11829 }
11830
11831 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u8Z_1free(JNIEnv *env, jclass clz, int8_tArray _res) {
11832         LDKCVec_u8Z _res_ref;
11833         _res_ref.datalen = (*env)->GetArrayLength(env, _res);
11834         _res_ref.data = MALLOC(_res_ref.datalen, "LDKCVec_u8Z Bytes");
11835         (*env)->GetByteArrayRegion(env, _res, 0, _res_ref.datalen, _res_ref.data);
11836         CVec_u8Z_free(_res_ref);
11837 }
11838
11839 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray arg) {
11840         LDKRecoverableSignature arg_ref;
11841         CHECK((*env)->GetArrayLength(env, arg) == 68);
11842         (*env)->GetByteArrayRegion(env, arg, 0, 68, arg_ref.serialized_form);
11843         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
11844         *ret_conv = CResult_RecoverableSignatureNoneZ_ok(arg_ref);
11845         return (uint64_t)ret_conv;
11846 }
11847
11848 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1err(JNIEnv *env, jclass clz) {
11849         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
11850         *ret_conv = CResult_RecoverableSignatureNoneZ_err();
11851         return (uint64_t)ret_conv;
11852 }
11853
11854 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11855         if ((_res & 1) != 0) return;
11856         LDKCResult_RecoverableSignatureNoneZ _res_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(((uint64_t)_res) & ~1);
11857         FREE((void*)_res);
11858         CResult_RecoverableSignatureNoneZ_free(_res_conv);
11859 }
11860
11861 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11862         LDKCResult_RecoverableSignatureNoneZ* orig_conv = (LDKCResult_RecoverableSignatureNoneZ*)(orig & ~1);
11863         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
11864         *ret_conv = CResult_RecoverableSignatureNoneZ_clone(orig_conv);
11865         return (uint64_t)ret_conv;
11866 }
11867
11868 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CVec_1u8ZZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
11869         LDKCVec_CVec_u8ZZ _res_constr;
11870         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11871         if (_res_constr.datalen > 0)
11872                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
11873         else
11874                 _res_constr.data = NULL;
11875         for (size_t i = 0; i < _res_constr.datalen; i++) {
11876                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
11877                 LDKCVec_u8Z _res_conv_8_ref;
11878                 _res_conv_8_ref.datalen = (*env)->GetArrayLength(env, _res_conv_8);
11879                 _res_conv_8_ref.data = MALLOC(_res_conv_8_ref.datalen, "LDKCVec_u8Z Bytes");
11880                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, _res_conv_8_ref.datalen, _res_conv_8_ref.data);
11881                 _res_constr.data[i] = _res_conv_8_ref;
11882         }
11883         CVec_CVec_u8ZZ_free(_res_constr);
11884 }
11885
11886 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1ok(JNIEnv *env, jclass clz, jobjectArray o) {
11887         LDKCVec_CVec_u8ZZ o_constr;
11888         o_constr.datalen = (*env)->GetArrayLength(env, o);
11889         if (o_constr.datalen > 0)
11890                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
11891         else
11892                 o_constr.data = NULL;
11893         for (size_t i = 0; i < o_constr.datalen; i++) {
11894                 int8_tArray o_conv_8 = (*env)->GetObjectArrayElement(env, o, i);
11895                 LDKCVec_u8Z o_conv_8_ref;
11896                 o_conv_8_ref.datalen = (*env)->GetArrayLength(env, o_conv_8);
11897                 o_conv_8_ref.data = MALLOC(o_conv_8_ref.datalen, "LDKCVec_u8Z Bytes");
11898                 (*env)->GetByteArrayRegion(env, o_conv_8, 0, o_conv_8_ref.datalen, o_conv_8_ref.data);
11899                 o_constr.data[i] = o_conv_8_ref;
11900         }
11901         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
11902         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_ok(o_constr);
11903         return (uint64_t)ret_conv;
11904 }
11905
11906 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1err(JNIEnv *env, jclass clz) {
11907         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
11908         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_err();
11909         return (uint64_t)ret_conv;
11910 }
11911
11912 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11913         if ((_res & 1) != 0) return;
11914         LDKCResult_CVec_CVec_u8ZZNoneZ _res_conv = *(LDKCResult_CVec_CVec_u8ZZNoneZ*)(((uint64_t)_res) & ~1);
11915         FREE((void*)_res);
11916         CResult_CVec_CVec_u8ZZNoneZ_free(_res_conv);
11917 }
11918
11919 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11920         LDKCResult_CVec_CVec_u8ZZNoneZ* orig_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(orig & ~1);
11921         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
11922         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(orig_conv);
11923         return (uint64_t)ret_conv;
11924 }
11925
11926 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11927         LDKInMemorySigner o_conv;
11928         o_conv.inner = (void*)(o & (~1));
11929         o_conv.is_owned = (o & 1) || (o == 0);
11930         o_conv = InMemorySigner_clone(&o_conv);
11931         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
11932         *ret_conv = CResult_InMemorySignerDecodeErrorZ_ok(o_conv);
11933         return (uint64_t)ret_conv;
11934 }
11935
11936 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11937         LDKDecodeError e_conv;
11938         e_conv.inner = (void*)(e & (~1));
11939         e_conv.is_owned = (e & 1) || (e == 0);
11940         e_conv = DecodeError_clone(&e_conv);
11941         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
11942         *ret_conv = CResult_InMemorySignerDecodeErrorZ_err(e_conv);
11943         return (uint64_t)ret_conv;
11944 }
11945
11946 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11947         if ((_res & 1) != 0) return;
11948         LDKCResult_InMemorySignerDecodeErrorZ _res_conv = *(LDKCResult_InMemorySignerDecodeErrorZ*)(((uint64_t)_res) & ~1);
11949         FREE((void*)_res);
11950         CResult_InMemorySignerDecodeErrorZ_free(_res_conv);
11951 }
11952
11953 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11954         LDKCResult_InMemorySignerDecodeErrorZ* orig_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(orig & ~1);
11955         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
11956         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(orig_conv);
11957         return (uint64_t)ret_conv;
11958 }
11959
11960 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TxOutZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
11961         LDKCVec_TxOutZ _res_constr;
11962         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11963         if (_res_constr.datalen > 0)
11964                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
11965         else
11966                 _res_constr.data = NULL;
11967         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
11968         for (size_t h = 0; h < _res_constr.datalen; h++) {
11969                 int64_t _res_conv_7 = _res_vals[h];
11970                 LDKTxOut _res_conv_7_conv = *(LDKTxOut*)(((uint64_t)_res_conv_7) & ~1);
11971                 FREE((void*)_res_conv_7);
11972                 _res_constr.data[h] = _res_conv_7_conv;
11973         }
11974         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
11975         CVec_TxOutZ_free(_res_constr);
11976 }
11977
11978 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
11979         LDKTransaction o_ref;
11980         o_ref.datalen = (*env)->GetArrayLength(env, o);
11981         o_ref.data = MALLOC(o_ref.datalen, "LDKTransaction Bytes");
11982         (*env)->GetByteArrayRegion(env, o, 0, o_ref.datalen, o_ref.data);
11983         o_ref.data_is_owned = true;
11984         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
11985         *ret_conv = CResult_TransactionNoneZ_ok(o_ref);
11986         return (uint64_t)ret_conv;
11987 }
11988
11989 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1err(JNIEnv *env, jclass clz) {
11990         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
11991         *ret_conv = CResult_TransactionNoneZ_err();
11992         return (uint64_t)ret_conv;
11993 }
11994
11995 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11996         if ((_res & 1) != 0) return;
11997         LDKCResult_TransactionNoneZ _res_conv = *(LDKCResult_TransactionNoneZ*)(((uint64_t)_res) & ~1);
11998         FREE((void*)_res);
11999         CResult_TransactionNoneZ_free(_res_conv);
12000 }
12001
12002 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12003         LDKCResult_TransactionNoneZ* orig_conv = (LDKCResult_TransactionNoneZ*)(orig & ~1);
12004         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
12005         *ret_conv = CResult_TransactionNoneZ_clone(orig_conv);
12006         return (uint64_t)ret_conv;
12007 }
12008
12009 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12010         LDKC2Tuple_BlockHashChannelMonitorZ* orig_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(orig & ~1);
12011         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
12012         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone(orig_conv);
12013         return ((uint64_t)ret_conv);
12014 }
12015
12016 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
12017         LDKThirtyTwoBytes a_ref;
12018         CHECK((*env)->GetArrayLength(env, a) == 32);
12019         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
12020         LDKChannelMonitor b_conv;
12021         b_conv.inner = (void*)(b & (~1));
12022         b_conv.is_owned = (b & 1) || (b == 0);
12023         b_conv = ChannelMonitor_clone(&b_conv);
12024         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
12025         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_new(a_ref, b_conv);
12026         return ((uint64_t)ret_conv);
12027 }
12028
12029 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12030         if ((_res & 1) != 0) return;
12031         LDKC2Tuple_BlockHashChannelMonitorZ _res_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)_res) & ~1);
12032         FREE((void*)_res);
12033         C2Tuple_BlockHashChannelMonitorZ_free(_res_conv);
12034 }
12035
12036 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1BlockHashChannelMonitorZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
12037         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ _res_constr;
12038         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
12039         if (_res_constr.datalen > 0)
12040                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Elements");
12041         else
12042                 _res_constr.data = NULL;
12043         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
12044         for (size_t j = 0; j < _res_constr.datalen; j++) {
12045                 int64_t _res_conv_35 = _res_vals[j];
12046                 LDKC2Tuple_BlockHashChannelMonitorZ _res_conv_35_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)_res_conv_35) & ~1);
12047                 FREE((void*)_res_conv_35);
12048                 _res_constr.data[j] = _res_conv_35_conv;
12049         }
12050         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
12051         CVec_C2Tuple_BlockHashChannelMonitorZZ_free(_res_constr);
12052 }
12053
12054 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1ok(JNIEnv *env, jclass clz, int64_tArray o) {
12055         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ o_constr;
12056         o_constr.datalen = (*env)->GetArrayLength(env, o);
12057         if (o_constr.datalen > 0)
12058                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Elements");
12059         else
12060                 o_constr.data = NULL;
12061         int64_t* o_vals = (*env)->GetLongArrayElements (env, o, NULL);
12062         for (size_t j = 0; j < o_constr.datalen; j++) {
12063                 int64_t o_conv_35 = o_vals[j];
12064                 LDKC2Tuple_BlockHashChannelMonitorZ o_conv_35_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)o_conv_35) & ~1);
12065                 o_conv_35_conv = C2Tuple_BlockHashChannelMonitorZ_clone((LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)o_conv_35) & ~1));
12066                 o_constr.data[j] = o_conv_35_conv;
12067         }
12068         (*env)->ReleaseLongArrayElements(env, o, o_vals, 0);
12069         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
12070         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_ok(o_constr);
12071         return (uint64_t)ret_conv;
12072 }
12073
12074 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
12075         LDKIOError e_conv = LDKIOError_from_java(env, e);
12076         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
12077         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_err(e_conv);
12078         return (uint64_t)ret_conv;
12079 }
12080
12081 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12082         if ((_res & 1) != 0) return;
12083         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ _res_conv = *(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(((uint64_t)_res) & ~1);
12084         FREE((void*)_res);
12085         CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_free(_res_conv);
12086 }
12087
12088 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12089         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* orig_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(orig & ~1);
12090         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
12091         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone(orig_conv);
12092         return (uint64_t)ret_conv;
12093 }
12094
12095 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12096         LDKPaymentId o_conv;
12097         o_conv.inner = (void*)(o & (~1));
12098         o_conv.is_owned = (o & 1) || (o == 0);
12099         o_conv = PaymentId_clone(&o_conv);
12100         LDKCResult_PaymentIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdDecodeErrorZ), "LDKCResult_PaymentIdDecodeErrorZ");
12101         *ret_conv = CResult_PaymentIdDecodeErrorZ_ok(o_conv);
12102         return (uint64_t)ret_conv;
12103 }
12104
12105 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12106         LDKDecodeError e_conv;
12107         e_conv.inner = (void*)(e & (~1));
12108         e_conv.is_owned = (e & 1) || (e == 0);
12109         e_conv = DecodeError_clone(&e_conv);
12110         LDKCResult_PaymentIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdDecodeErrorZ), "LDKCResult_PaymentIdDecodeErrorZ");
12111         *ret_conv = CResult_PaymentIdDecodeErrorZ_err(e_conv);
12112         return (uint64_t)ret_conv;
12113 }
12114
12115 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12116         if ((_res & 1) != 0) return;
12117         LDKCResult_PaymentIdDecodeErrorZ _res_conv = *(LDKCResult_PaymentIdDecodeErrorZ*)(((uint64_t)_res) & ~1);
12118         FREE((void*)_res);
12119         CResult_PaymentIdDecodeErrorZ_free(_res_conv);
12120 }
12121
12122 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12123         LDKCResult_PaymentIdDecodeErrorZ* orig_conv = (LDKCResult_PaymentIdDecodeErrorZ*)(orig & ~1);
12124         LDKCResult_PaymentIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdDecodeErrorZ), "LDKCResult_PaymentIdDecodeErrorZ");
12125         *ret_conv = CResult_PaymentIdDecodeErrorZ_clone(orig_conv);
12126         return (uint64_t)ret_conv;
12127 }
12128
12129 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1some(JNIEnv *env, jclass clz, int16_t o) {
12130         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
12131         *ret_copy = COption_u16Z_some(o);
12132         uint64_t ret_ref = (uint64_t)ret_copy;
12133         return ret_ref;
12134 }
12135
12136 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1none(JNIEnv *env, jclass clz) {
12137         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
12138         *ret_copy = COption_u16Z_none();
12139         uint64_t ret_ref = (uint64_t)ret_copy;
12140         return ret_ref;
12141 }
12142
12143 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
12144         if ((_res & 1) != 0) return;
12145         LDKCOption_u16Z _res_conv = *(LDKCOption_u16Z*)(((uint64_t)_res) & ~1);
12146         FREE((void*)_res);
12147         COption_u16Z_free(_res_conv);
12148 }
12149
12150 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12151         LDKCOption_u16Z* orig_conv = (LDKCOption_u16Z*)orig;
12152         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
12153         *ret_copy = COption_u16Z_clone(orig_conv);
12154         uint64_t ret_ref = (uint64_t)ret_copy;
12155         return ret_ref;
12156 }
12157
12158 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1ok(JNIEnv *env, jclass clz) {
12159         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
12160         *ret_conv = CResult_NoneAPIErrorZ_ok();
12161         return (uint64_t)ret_conv;
12162 }
12163
12164 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12165         LDKAPIError e_conv = *(LDKAPIError*)(((uint64_t)e) & ~1);
12166         e_conv = APIError_clone((LDKAPIError*)(((uint64_t)e) & ~1));
12167         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
12168         *ret_conv = CResult_NoneAPIErrorZ_err(e_conv);
12169         return (uint64_t)ret_conv;
12170 }
12171
12172 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12173         if ((_res & 1) != 0) return;
12174         LDKCResult_NoneAPIErrorZ _res_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)_res) & ~1);
12175         FREE((void*)_res);
12176         CResult_NoneAPIErrorZ_free(_res_conv);
12177 }
12178
12179 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12180         LDKCResult_NoneAPIErrorZ* orig_conv = (LDKCResult_NoneAPIErrorZ*)(orig & ~1);
12181         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
12182         *ret_conv = CResult_NoneAPIErrorZ_clone(orig_conv);
12183         return (uint64_t)ret_conv;
12184 }
12185
12186 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CResult_1NoneAPIErrorZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
12187         LDKCVec_CResult_NoneAPIErrorZZ _res_constr;
12188         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
12189         if (_res_constr.datalen > 0)
12190                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
12191         else
12192                 _res_constr.data = NULL;
12193         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
12194         for (size_t w = 0; w < _res_constr.datalen; w++) {
12195                 int64_t _res_conv_22 = _res_vals[w];
12196                 LDKCResult_NoneAPIErrorZ _res_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)_res_conv_22) & ~1);
12197                 FREE((void*)_res_conv_22);
12198                 _res_constr.data[w] = _res_conv_22_conv;
12199         }
12200         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
12201         CVec_CResult_NoneAPIErrorZZ_free(_res_constr);
12202 }
12203
12204 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1APIErrorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
12205         LDKCVec_APIErrorZ _res_constr;
12206         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
12207         if (_res_constr.datalen > 0)
12208                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
12209         else
12210                 _res_constr.data = NULL;
12211         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
12212         for (size_t k = 0; k < _res_constr.datalen; k++) {
12213                 int64_t _res_conv_10 = _res_vals[k];
12214                 LDKAPIError _res_conv_10_conv = *(LDKAPIError*)(((uint64_t)_res_conv_10) & ~1);
12215                 FREE((void*)_res_conv_10);
12216                 _res_constr.data[k] = _res_conv_10_conv;
12217         }
12218         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
12219         CVec_APIErrorZ_free(_res_constr);
12220 }
12221
12222 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
12223         LDKThirtyTwoBytes o_ref;
12224         CHECK((*env)->GetArrayLength(env, o) == 32);
12225         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
12226         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
12227         *ret_conv = CResult__u832APIErrorZ_ok(o_ref);
12228         return (uint64_t)ret_conv;
12229 }
12230
12231 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12232         LDKAPIError e_conv = *(LDKAPIError*)(((uint64_t)e) & ~1);
12233         e_conv = APIError_clone((LDKAPIError*)(((uint64_t)e) & ~1));
12234         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
12235         *ret_conv = CResult__u832APIErrorZ_err(e_conv);
12236         return (uint64_t)ret_conv;
12237 }
12238
12239 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12240         if ((_res & 1) != 0) return;
12241         LDKCResult__u832APIErrorZ _res_conv = *(LDKCResult__u832APIErrorZ*)(((uint64_t)_res) & ~1);
12242         FREE((void*)_res);
12243         CResult__u832APIErrorZ_free(_res_conv);
12244 }
12245
12246 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12247         LDKCResult__u832APIErrorZ* orig_conv = (LDKCResult__u832APIErrorZ*)(orig & ~1);
12248         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
12249         *ret_conv = CResult__u832APIErrorZ_clone(orig_conv);
12250         return (uint64_t)ret_conv;
12251 }
12252
12253 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12254         LDKPaymentId o_conv;
12255         o_conv.inner = (void*)(o & (~1));
12256         o_conv.is_owned = (o & 1) || (o == 0);
12257         o_conv = PaymentId_clone(&o_conv);
12258         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
12259         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_ok(o_conv);
12260         return (uint64_t)ret_conv;
12261 }
12262
12263 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12264         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(((uint64_t)e) & ~1);
12265         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uint64_t)e) & ~1));
12266         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
12267         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_err(e_conv);
12268         return (uint64_t)ret_conv;
12269 }
12270
12271 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12272         if ((_res & 1) != 0) return;
12273         LDKCResult_PaymentIdPaymentSendFailureZ _res_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(((uint64_t)_res) & ~1);
12274         FREE((void*)_res);
12275         CResult_PaymentIdPaymentSendFailureZ_free(_res_conv);
12276 }
12277
12278 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12279         LDKCResult_PaymentIdPaymentSendFailureZ* orig_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(orig & ~1);
12280         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
12281         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_clone(orig_conv);
12282         return (uint64_t)ret_conv;
12283 }
12284
12285 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1ok(JNIEnv *env, jclass clz) {
12286         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
12287         *ret_conv = CResult_NonePaymentSendFailureZ_ok();
12288         return (uint64_t)ret_conv;
12289 }
12290
12291 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12292         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(((uint64_t)e) & ~1);
12293         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uint64_t)e) & ~1));
12294         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
12295         *ret_conv = CResult_NonePaymentSendFailureZ_err(e_conv);
12296         return (uint64_t)ret_conv;
12297 }
12298
12299 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12300         if ((_res & 1) != 0) return;
12301         LDKCResult_NonePaymentSendFailureZ _res_conv = *(LDKCResult_NonePaymentSendFailureZ*)(((uint64_t)_res) & ~1);
12302         FREE((void*)_res);
12303         CResult_NonePaymentSendFailureZ_free(_res_conv);
12304 }
12305
12306 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12307         LDKCResult_NonePaymentSendFailureZ* orig_conv = (LDKCResult_NonePaymentSendFailureZ*)(orig & ~1);
12308         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
12309         *ret_conv = CResult_NonePaymentSendFailureZ_clone(orig_conv);
12310         return (uint64_t)ret_conv;
12311 }
12312
12313 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12314         LDKC2Tuple_PaymentHashPaymentIdZ* orig_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(orig & ~1);
12315         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
12316         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone(orig_conv);
12317         return ((uint64_t)ret_conv);
12318 }
12319
12320 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
12321         LDKThirtyTwoBytes a_ref;
12322         CHECK((*env)->GetArrayLength(env, a) == 32);
12323         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
12324         LDKPaymentId b_conv;
12325         b_conv.inner = (void*)(b & (~1));
12326         b_conv.is_owned = (b & 1) || (b == 0);
12327         b_conv = PaymentId_clone(&b_conv);
12328         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
12329         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_new(a_ref, b_conv);
12330         return ((uint64_t)ret_conv);
12331 }
12332
12333 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12334         if ((_res & 1) != 0) return;
12335         LDKC2Tuple_PaymentHashPaymentIdZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentIdZ*)(((uint64_t)_res) & ~1);
12336         FREE((void*)_res);
12337         C2Tuple_PaymentHashPaymentIdZ_free(_res_conv);
12338 }
12339
12340 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12341         LDKC2Tuple_PaymentHashPaymentIdZ o_conv = *(LDKC2Tuple_PaymentHashPaymentIdZ*)(((uint64_t)o) & ~1);
12342         o_conv = C2Tuple_PaymentHashPaymentIdZ_clone((LDKC2Tuple_PaymentHashPaymentIdZ*)(((uint64_t)o) & ~1));
12343         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
12344         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_ok(o_conv);
12345         return (uint64_t)ret_conv;
12346 }
12347
12348 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12349         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(((uint64_t)e) & ~1);
12350         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uint64_t)e) & ~1));
12351         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
12352         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_err(e_conv);
12353         return (uint64_t)ret_conv;
12354 }
12355
12356 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12357         if ((_res & 1) != 0) return;
12358         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(((uint64_t)_res) & ~1);
12359         FREE((void*)_res);
12360         CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_free(_res_conv);
12361 }
12362
12363 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12364         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(orig & ~1);
12365         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
12366         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(orig_conv);
12367         return (uint64_t)ret_conv;
12368 }
12369
12370 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1NetAddressZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
12371         LDKCVec_NetAddressZ _res_constr;
12372         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
12373         if (_res_constr.datalen > 0)
12374                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
12375         else
12376                 _res_constr.data = NULL;
12377         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
12378         for (size_t m = 0; m < _res_constr.datalen; m++) {
12379                 int64_t _res_conv_12 = _res_vals[m];
12380                 LDKNetAddress _res_conv_12_conv = *(LDKNetAddress*)(((uint64_t)_res_conv_12) & ~1);
12381                 FREE((void*)_res_conv_12);
12382                 _res_constr.data[m] = _res_conv_12_conv;
12383         }
12384         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
12385         CVec_NetAddressZ_free(_res_constr);
12386 }
12387
12388 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12389         LDKC2Tuple_PaymentHashPaymentSecretZ* orig_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(orig & ~1);
12390         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
12391         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone(orig_conv);
12392         return ((uint64_t)ret_conv);
12393 }
12394
12395 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int8_tArray b) {
12396         LDKThirtyTwoBytes a_ref;
12397         CHECK((*env)->GetArrayLength(env, a) == 32);
12398         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
12399         LDKThirtyTwoBytes b_ref;
12400         CHECK((*env)->GetArrayLength(env, b) == 32);
12401         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
12402         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
12403         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_new(a_ref, b_ref);
12404         return ((uint64_t)ret_conv);
12405 }
12406
12407 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12408         if ((_res & 1) != 0) return;
12409         LDKC2Tuple_PaymentHashPaymentSecretZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(((uint64_t)_res) & ~1);
12410         FREE((void*)_res);
12411         C2Tuple_PaymentHashPaymentSecretZ_free(_res_conv);
12412 }
12413
12414 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
12415         LDKThirtyTwoBytes o_ref;
12416         CHECK((*env)->GetArrayLength(env, o) == 32);
12417         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
12418         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
12419         *ret_conv = CResult_PaymentSecretAPIErrorZ_ok(o_ref);
12420         return (uint64_t)ret_conv;
12421 }
12422
12423 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12424         LDKAPIError e_conv = *(LDKAPIError*)(((uint64_t)e) & ~1);
12425         e_conv = APIError_clone((LDKAPIError*)(((uint64_t)e) & ~1));
12426         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
12427         *ret_conv = CResult_PaymentSecretAPIErrorZ_err(e_conv);
12428         return (uint64_t)ret_conv;
12429 }
12430
12431 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12432         if ((_res & 1) != 0) return;
12433         LDKCResult_PaymentSecretAPIErrorZ _res_conv = *(LDKCResult_PaymentSecretAPIErrorZ*)(((uint64_t)_res) & ~1);
12434         FREE((void*)_res);
12435         CResult_PaymentSecretAPIErrorZ_free(_res_conv);
12436 }
12437
12438 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12439         LDKCResult_PaymentSecretAPIErrorZ* orig_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(orig & ~1);
12440         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
12441         *ret_conv = CResult_PaymentSecretAPIErrorZ_clone(orig_conv);
12442         return (uint64_t)ret_conv;
12443 }
12444
12445 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ChannelMonitorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
12446         LDKCVec_ChannelMonitorZ _res_constr;
12447         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
12448         if (_res_constr.datalen > 0)
12449                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
12450         else
12451                 _res_constr.data = NULL;
12452         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
12453         for (size_t q = 0; q < _res_constr.datalen; q++) {
12454                 int64_t _res_conv_16 = _res_vals[q];
12455                 LDKChannelMonitor _res_conv_16_conv;
12456                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
12457                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
12458                 _res_constr.data[q] = _res_conv_16_conv;
12459         }
12460         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
12461         CVec_ChannelMonitorZ_free(_res_constr);
12462 }
12463
12464 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
12465         LDKThirtyTwoBytes a_ref;
12466         CHECK((*env)->GetArrayLength(env, a) == 32);
12467         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
12468         LDKChannelManager b_conv;
12469         b_conv.inner = (void*)(b & (~1));
12470         b_conv.is_owned = (b & 1) || (b == 0);
12471         // Warning: we need a move here but no clone is available for LDKChannelManager
12472         LDKC2Tuple_BlockHashChannelManagerZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
12473         *ret_conv = C2Tuple_BlockHashChannelManagerZ_new(a_ref, b_conv);
12474         return ((uint64_t)ret_conv);
12475 }
12476
12477 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12478         if ((_res & 1) != 0) return;
12479         LDKC2Tuple_BlockHashChannelManagerZ _res_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(((uint64_t)_res) & ~1);
12480         FREE((void*)_res);
12481         C2Tuple_BlockHashChannelManagerZ_free(_res_conv);
12482 }
12483
12484 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12485         LDKC2Tuple_BlockHashChannelManagerZ o_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(((uint64_t)o) & ~1);
12486         // Warning: we may need a move here but no clone is available for LDKC2Tuple_BlockHashChannelManagerZ
12487         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
12488         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(o_conv);
12489         return (uint64_t)ret_conv;
12490 }
12491
12492 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12493         LDKDecodeError e_conv;
12494         e_conv.inner = (void*)(e & (~1));
12495         e_conv.is_owned = (e & 1) || (e == 0);
12496         e_conv = DecodeError_clone(&e_conv);
12497         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
12498         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(e_conv);
12499         return (uint64_t)ret_conv;
12500 }
12501
12502 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12503         if ((_res & 1) != 0) return;
12504         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(((uint64_t)_res) & ~1);
12505         FREE((void*)_res);
12506         CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(_res_conv);
12507 }
12508
12509 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12510         LDKChannelConfig o_conv;
12511         o_conv.inner = (void*)(o & (~1));
12512         o_conv.is_owned = (o & 1) || (o == 0);
12513         o_conv = ChannelConfig_clone(&o_conv);
12514         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
12515         *ret_conv = CResult_ChannelConfigDecodeErrorZ_ok(o_conv);
12516         return (uint64_t)ret_conv;
12517 }
12518
12519 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12520         LDKDecodeError e_conv;
12521         e_conv.inner = (void*)(e & (~1));
12522         e_conv.is_owned = (e & 1) || (e == 0);
12523         e_conv = DecodeError_clone(&e_conv);
12524         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
12525         *ret_conv = CResult_ChannelConfigDecodeErrorZ_err(e_conv);
12526         return (uint64_t)ret_conv;
12527 }
12528
12529 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12530         if ((_res & 1) != 0) return;
12531         LDKCResult_ChannelConfigDecodeErrorZ _res_conv = *(LDKCResult_ChannelConfigDecodeErrorZ*)(((uint64_t)_res) & ~1);
12532         FREE((void*)_res);
12533         CResult_ChannelConfigDecodeErrorZ_free(_res_conv);
12534 }
12535
12536 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12537         LDKCResult_ChannelConfigDecodeErrorZ* orig_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(orig & ~1);
12538         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
12539         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(orig_conv);
12540         return (uint64_t)ret_conv;
12541 }
12542
12543 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12544         LDKOutPoint o_conv;
12545         o_conv.inner = (void*)(o & (~1));
12546         o_conv.is_owned = (o & 1) || (o == 0);
12547         o_conv = OutPoint_clone(&o_conv);
12548         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
12549         *ret_conv = CResult_OutPointDecodeErrorZ_ok(o_conv);
12550         return (uint64_t)ret_conv;
12551 }
12552
12553 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12554         LDKDecodeError e_conv;
12555         e_conv.inner = (void*)(e & (~1));
12556         e_conv.is_owned = (e & 1) || (e == 0);
12557         e_conv = DecodeError_clone(&e_conv);
12558         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
12559         *ret_conv = CResult_OutPointDecodeErrorZ_err(e_conv);
12560         return (uint64_t)ret_conv;
12561 }
12562
12563 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12564         if ((_res & 1) != 0) return;
12565         LDKCResult_OutPointDecodeErrorZ _res_conv = *(LDKCResult_OutPointDecodeErrorZ*)(((uint64_t)_res) & ~1);
12566         FREE((void*)_res);
12567         CResult_OutPointDecodeErrorZ_free(_res_conv);
12568 }
12569
12570 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12571         LDKCResult_OutPointDecodeErrorZ* orig_conv = (LDKCResult_OutPointDecodeErrorZ*)(orig & ~1);
12572         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
12573         *ret_conv = CResult_OutPointDecodeErrorZ_clone(orig_conv);
12574         return (uint64_t)ret_conv;
12575 }
12576
12577 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1some(JNIEnv *env, jclass clz, int64_t o) {
12578         LDKType o_conv = *(LDKType*)(((uint64_t)o) & ~1);
12579         if (o_conv.free == LDKType_JCalls_free) {
12580                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
12581                 LDKType_JCalls_cloned(&o_conv);
12582         }
12583         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
12584         *ret_copy = COption_TypeZ_some(o_conv);
12585         uint64_t ret_ref = (uint64_t)ret_copy;
12586         return ret_ref;
12587 }
12588
12589 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1none(JNIEnv *env, jclass clz) {
12590         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
12591         *ret_copy = COption_TypeZ_none();
12592         uint64_t ret_ref = (uint64_t)ret_copy;
12593         return ret_ref;
12594 }
12595
12596 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12597         if ((_res & 1) != 0) return;
12598         LDKCOption_TypeZ _res_conv = *(LDKCOption_TypeZ*)(((uint64_t)_res) & ~1);
12599         FREE((void*)_res);
12600         COption_TypeZ_free(_res_conv);
12601 }
12602
12603 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12604         LDKCOption_TypeZ* orig_conv = (LDKCOption_TypeZ*)orig;
12605         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
12606         *ret_copy = COption_TypeZ_clone(orig_conv);
12607         uint64_t ret_ref = (uint64_t)ret_copy;
12608         return ret_ref;
12609 }
12610
12611 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12612         LDKCOption_TypeZ o_conv = *(LDKCOption_TypeZ*)(((uint64_t)o) & ~1);
12613         o_conv = COption_TypeZ_clone((LDKCOption_TypeZ*)(((uint64_t)o) & ~1));
12614         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
12615         *ret_conv = CResult_COption_TypeZDecodeErrorZ_ok(o_conv);
12616         return (uint64_t)ret_conv;
12617 }
12618
12619 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12620         LDKDecodeError e_conv;
12621         e_conv.inner = (void*)(e & (~1));
12622         e_conv.is_owned = (e & 1) || (e == 0);
12623         e_conv = DecodeError_clone(&e_conv);
12624         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
12625         *ret_conv = CResult_COption_TypeZDecodeErrorZ_err(e_conv);
12626         return (uint64_t)ret_conv;
12627 }
12628
12629 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12630         if ((_res & 1) != 0) return;
12631         LDKCResult_COption_TypeZDecodeErrorZ _res_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(((uint64_t)_res) & ~1);
12632         FREE((void*)_res);
12633         CResult_COption_TypeZDecodeErrorZ_free(_res_conv);
12634 }
12635
12636 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12637         LDKCResult_COption_TypeZDecodeErrorZ* orig_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(orig & ~1);
12638         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
12639         *ret_conv = CResult_COption_TypeZDecodeErrorZ_clone(orig_conv);
12640         return (uint64_t)ret_conv;
12641 }
12642
12643 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixNoneZ_1ok(JNIEnv *env, jclass clz, jclass o) {
12644         LDKSiPrefix o_conv = LDKSiPrefix_from_java(env, o);
12645         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
12646         *ret_conv = CResult_SiPrefixNoneZ_ok(o_conv);
12647         return (uint64_t)ret_conv;
12648 }
12649
12650 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixNoneZ_1err(JNIEnv *env, jclass clz) {
12651         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
12652         *ret_conv = CResult_SiPrefixNoneZ_err();
12653         return (uint64_t)ret_conv;
12654 }
12655
12656 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12657         if ((_res & 1) != 0) return;
12658         LDKCResult_SiPrefixNoneZ _res_conv = *(LDKCResult_SiPrefixNoneZ*)(((uint64_t)_res) & ~1);
12659         FREE((void*)_res);
12660         CResult_SiPrefixNoneZ_free(_res_conv);
12661 }
12662
12663 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12664         LDKCResult_SiPrefixNoneZ* orig_conv = (LDKCResult_SiPrefixNoneZ*)(orig & ~1);
12665         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
12666         *ret_conv = CResult_SiPrefixNoneZ_clone(orig_conv);
12667         return (uint64_t)ret_conv;
12668 }
12669
12670 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12671         LDKInvoice o_conv;
12672         o_conv.inner = (void*)(o & (~1));
12673         o_conv.is_owned = (o & 1) || (o == 0);
12674         o_conv = Invoice_clone(&o_conv);
12675         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
12676         *ret_conv = CResult_InvoiceNoneZ_ok(o_conv);
12677         return (uint64_t)ret_conv;
12678 }
12679
12680 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceNoneZ_1err(JNIEnv *env, jclass clz) {
12681         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
12682         *ret_conv = CResult_InvoiceNoneZ_err();
12683         return (uint64_t)ret_conv;
12684 }
12685
12686 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12687         if ((_res & 1) != 0) return;
12688         LDKCResult_InvoiceNoneZ _res_conv = *(LDKCResult_InvoiceNoneZ*)(((uint64_t)_res) & ~1);
12689         FREE((void*)_res);
12690         CResult_InvoiceNoneZ_free(_res_conv);
12691 }
12692
12693 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12694         LDKCResult_InvoiceNoneZ* orig_conv = (LDKCResult_InvoiceNoneZ*)(orig & ~1);
12695         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
12696         *ret_conv = CResult_InvoiceNoneZ_clone(orig_conv);
12697         return (uint64_t)ret_conv;
12698 }
12699
12700 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12701         LDKSignedRawInvoice o_conv;
12702         o_conv.inner = (void*)(o & (~1));
12703         o_conv.is_owned = (o & 1) || (o == 0);
12704         o_conv = SignedRawInvoice_clone(&o_conv);
12705         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
12706         *ret_conv = CResult_SignedRawInvoiceNoneZ_ok(o_conv);
12707         return (uint64_t)ret_conv;
12708 }
12709
12710 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceNoneZ_1err(JNIEnv *env, jclass clz) {
12711         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
12712         *ret_conv = CResult_SignedRawInvoiceNoneZ_err();
12713         return (uint64_t)ret_conv;
12714 }
12715
12716 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12717         if ((_res & 1) != 0) return;
12718         LDKCResult_SignedRawInvoiceNoneZ _res_conv = *(LDKCResult_SignedRawInvoiceNoneZ*)(((uint64_t)_res) & ~1);
12719         FREE((void*)_res);
12720         CResult_SignedRawInvoiceNoneZ_free(_res_conv);
12721 }
12722
12723 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12724         LDKCResult_SignedRawInvoiceNoneZ* orig_conv = (LDKCResult_SignedRawInvoiceNoneZ*)(orig & ~1);
12725         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
12726         *ret_conv = CResult_SignedRawInvoiceNoneZ_clone(orig_conv);
12727         return (uint64_t)ret_conv;
12728 }
12729
12730 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12731         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* orig_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(orig & ~1);
12732         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
12733         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(orig_conv);
12734         return ((uint64_t)ret_conv);
12735 }
12736
12737 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) {
12738         LDKRawInvoice a_conv;
12739         a_conv.inner = (void*)(a & (~1));
12740         a_conv.is_owned = (a & 1) || (a == 0);
12741         a_conv = RawInvoice_clone(&a_conv);
12742         LDKThirtyTwoBytes b_ref;
12743         CHECK((*env)->GetArrayLength(env, b) == 32);
12744         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
12745         LDKInvoiceSignature c_conv;
12746         c_conv.inner = (void*)(c & (~1));
12747         c_conv.is_owned = (c & 1) || (c == 0);
12748         c_conv = InvoiceSignature_clone(&c_conv);
12749         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
12750         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_new(a_conv, b_ref, c_conv);
12751         return ((uint64_t)ret_conv);
12752 }
12753
12754 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12755         if ((_res & 1) != 0) return;
12756         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ _res_conv = *(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(((uint64_t)_res) & ~1);
12757         FREE((void*)_res);
12758         C3Tuple_RawInvoice_u832InvoiceSignatureZ_free(_res_conv);
12759 }
12760
12761 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12762         LDKPayeePubKey o_conv;
12763         o_conv.inner = (void*)(o & (~1));
12764         o_conv.is_owned = (o & 1) || (o == 0);
12765         o_conv = PayeePubKey_clone(&o_conv);
12766         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
12767         *ret_conv = CResult_PayeePubKeyErrorZ_ok(o_conv);
12768         return (uint64_t)ret_conv;
12769 }
12770
12771 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
12772         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
12773         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
12774         *ret_conv = CResult_PayeePubKeyErrorZ_err(e_conv);
12775         return (uint64_t)ret_conv;
12776 }
12777
12778 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12779         if ((_res & 1) != 0) return;
12780         LDKCResult_PayeePubKeyErrorZ _res_conv = *(LDKCResult_PayeePubKeyErrorZ*)(((uint64_t)_res) & ~1);
12781         FREE((void*)_res);
12782         CResult_PayeePubKeyErrorZ_free(_res_conv);
12783 }
12784
12785 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12786         LDKCResult_PayeePubKeyErrorZ* orig_conv = (LDKCResult_PayeePubKeyErrorZ*)(orig & ~1);
12787         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
12788         *ret_conv = CResult_PayeePubKeyErrorZ_clone(orig_conv);
12789         return (uint64_t)ret_conv;
12790 }
12791
12792 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PrivateRouteZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
12793         LDKCVec_PrivateRouteZ _res_constr;
12794         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
12795         if (_res_constr.datalen > 0)
12796                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPrivateRoute), "LDKCVec_PrivateRouteZ Elements");
12797         else
12798                 _res_constr.data = NULL;
12799         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
12800         for (size_t o = 0; o < _res_constr.datalen; o++) {
12801                 int64_t _res_conv_14 = _res_vals[o];
12802                 LDKPrivateRoute _res_conv_14_conv;
12803                 _res_conv_14_conv.inner = (void*)(_res_conv_14 & (~1));
12804                 _res_conv_14_conv.is_owned = (_res_conv_14 & 1) || (_res_conv_14 == 0);
12805                 _res_constr.data[o] = _res_conv_14_conv;
12806         }
12807         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
12808         CVec_PrivateRouteZ_free(_res_constr);
12809 }
12810
12811 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12812         LDKPositiveTimestamp o_conv;
12813         o_conv.inner = (void*)(o & (~1));
12814         o_conv.is_owned = (o & 1) || (o == 0);
12815         o_conv = PositiveTimestamp_clone(&o_conv);
12816         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
12817         *ret_conv = CResult_PositiveTimestampCreationErrorZ_ok(o_conv);
12818         return (uint64_t)ret_conv;
12819 }
12820
12821 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
12822         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
12823         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
12824         *ret_conv = CResult_PositiveTimestampCreationErrorZ_err(e_conv);
12825         return (uint64_t)ret_conv;
12826 }
12827
12828 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12829         if ((_res & 1) != 0) return;
12830         LDKCResult_PositiveTimestampCreationErrorZ _res_conv = *(LDKCResult_PositiveTimestampCreationErrorZ*)(((uint64_t)_res) & ~1);
12831         FREE((void*)_res);
12832         CResult_PositiveTimestampCreationErrorZ_free(_res_conv);
12833 }
12834
12835 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12836         LDKCResult_PositiveTimestampCreationErrorZ* orig_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(orig & ~1);
12837         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
12838         *ret_conv = CResult_PositiveTimestampCreationErrorZ_clone(orig_conv);
12839         return (uint64_t)ret_conv;
12840 }
12841
12842 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1ok(JNIEnv *env, jclass clz) {
12843         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
12844         *ret_conv = CResult_NoneSemanticErrorZ_ok();
12845         return (uint64_t)ret_conv;
12846 }
12847
12848 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
12849         LDKSemanticError e_conv = LDKSemanticError_from_java(env, e);
12850         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
12851         *ret_conv = CResult_NoneSemanticErrorZ_err(e_conv);
12852         return (uint64_t)ret_conv;
12853 }
12854
12855 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12856         if ((_res & 1) != 0) return;
12857         LDKCResult_NoneSemanticErrorZ _res_conv = *(LDKCResult_NoneSemanticErrorZ*)(((uint64_t)_res) & ~1);
12858         FREE((void*)_res);
12859         CResult_NoneSemanticErrorZ_free(_res_conv);
12860 }
12861
12862 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12863         LDKCResult_NoneSemanticErrorZ* orig_conv = (LDKCResult_NoneSemanticErrorZ*)(orig & ~1);
12864         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
12865         *ret_conv = CResult_NoneSemanticErrorZ_clone(orig_conv);
12866         return (uint64_t)ret_conv;
12867 }
12868
12869 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12870         LDKInvoice o_conv;
12871         o_conv.inner = (void*)(o & (~1));
12872         o_conv.is_owned = (o & 1) || (o == 0);
12873         o_conv = Invoice_clone(&o_conv);
12874         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
12875         *ret_conv = CResult_InvoiceSemanticErrorZ_ok(o_conv);
12876         return (uint64_t)ret_conv;
12877 }
12878
12879 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
12880         LDKSemanticError e_conv = LDKSemanticError_from_java(env, e);
12881         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
12882         *ret_conv = CResult_InvoiceSemanticErrorZ_err(e_conv);
12883         return (uint64_t)ret_conv;
12884 }
12885
12886 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12887         if ((_res & 1) != 0) return;
12888         LDKCResult_InvoiceSemanticErrorZ _res_conv = *(LDKCResult_InvoiceSemanticErrorZ*)(((uint64_t)_res) & ~1);
12889         FREE((void*)_res);
12890         CResult_InvoiceSemanticErrorZ_free(_res_conv);
12891 }
12892
12893 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12894         LDKCResult_InvoiceSemanticErrorZ* orig_conv = (LDKCResult_InvoiceSemanticErrorZ*)(orig & ~1);
12895         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
12896         *ret_conv = CResult_InvoiceSemanticErrorZ_clone(orig_conv);
12897         return (uint64_t)ret_conv;
12898 }
12899
12900 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12901         LDKDescription o_conv;
12902         o_conv.inner = (void*)(o & (~1));
12903         o_conv.is_owned = (o & 1) || (o == 0);
12904         o_conv = Description_clone(&o_conv);
12905         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
12906         *ret_conv = CResult_DescriptionCreationErrorZ_ok(o_conv);
12907         return (uint64_t)ret_conv;
12908 }
12909
12910 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
12911         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
12912         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
12913         *ret_conv = CResult_DescriptionCreationErrorZ_err(e_conv);
12914         return (uint64_t)ret_conv;
12915 }
12916
12917 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12918         if ((_res & 1) != 0) return;
12919         LDKCResult_DescriptionCreationErrorZ _res_conv = *(LDKCResult_DescriptionCreationErrorZ*)(((uint64_t)_res) & ~1);
12920         FREE((void*)_res);
12921         CResult_DescriptionCreationErrorZ_free(_res_conv);
12922 }
12923
12924 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12925         LDKCResult_DescriptionCreationErrorZ* orig_conv = (LDKCResult_DescriptionCreationErrorZ*)(orig & ~1);
12926         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
12927         *ret_conv = CResult_DescriptionCreationErrorZ_clone(orig_conv);
12928         return (uint64_t)ret_conv;
12929 }
12930
12931 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ExpiryTimeCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12932         LDKExpiryTime o_conv;
12933         o_conv.inner = (void*)(o & (~1));
12934         o_conv.is_owned = (o & 1) || (o == 0);
12935         o_conv = ExpiryTime_clone(&o_conv);
12936         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
12937         *ret_conv = CResult_ExpiryTimeCreationErrorZ_ok(o_conv);
12938         return (uint64_t)ret_conv;
12939 }
12940
12941 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ExpiryTimeCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
12942         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
12943         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
12944         *ret_conv = CResult_ExpiryTimeCreationErrorZ_err(e_conv);
12945         return (uint64_t)ret_conv;
12946 }
12947
12948 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ExpiryTimeCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12949         if ((_res & 1) != 0) return;
12950         LDKCResult_ExpiryTimeCreationErrorZ _res_conv = *(LDKCResult_ExpiryTimeCreationErrorZ*)(((uint64_t)_res) & ~1);
12951         FREE((void*)_res);
12952         CResult_ExpiryTimeCreationErrorZ_free(_res_conv);
12953 }
12954
12955 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ExpiryTimeCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12956         LDKCResult_ExpiryTimeCreationErrorZ* orig_conv = (LDKCResult_ExpiryTimeCreationErrorZ*)(orig & ~1);
12957         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
12958         *ret_conv = CResult_ExpiryTimeCreationErrorZ_clone(orig_conv);
12959         return (uint64_t)ret_conv;
12960 }
12961
12962 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12963         LDKPrivateRoute o_conv;
12964         o_conv.inner = (void*)(o & (~1));
12965         o_conv.is_owned = (o & 1) || (o == 0);
12966         o_conv = PrivateRoute_clone(&o_conv);
12967         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
12968         *ret_conv = CResult_PrivateRouteCreationErrorZ_ok(o_conv);
12969         return (uint64_t)ret_conv;
12970 }
12971
12972 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
12973         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
12974         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
12975         *ret_conv = CResult_PrivateRouteCreationErrorZ_err(e_conv);
12976         return (uint64_t)ret_conv;
12977 }
12978
12979 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12980         if ((_res & 1) != 0) return;
12981         LDKCResult_PrivateRouteCreationErrorZ _res_conv = *(LDKCResult_PrivateRouteCreationErrorZ*)(((uint64_t)_res) & ~1);
12982         FREE((void*)_res);
12983         CResult_PrivateRouteCreationErrorZ_free(_res_conv);
12984 }
12985
12986 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12987         LDKCResult_PrivateRouteCreationErrorZ* orig_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(orig & ~1);
12988         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
12989         *ret_conv = CResult_PrivateRouteCreationErrorZ_clone(orig_conv);
12990         return (uint64_t)ret_conv;
12991 }
12992
12993 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1ok(JNIEnv *env, jclass clz, jstring o) {
12994         LDKStr o_conv = java_to_owned_str(env, o);
12995         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
12996         *ret_conv = CResult_StringErrorZ_ok(o_conv);
12997         return (uint64_t)ret_conv;
12998 }
12999
13000 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
13001         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
13002         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
13003         *ret_conv = CResult_StringErrorZ_err(e_conv);
13004         return (uint64_t)ret_conv;
13005 }
13006
13007 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13008         if ((_res & 1) != 0) return;
13009         LDKCResult_StringErrorZ _res_conv = *(LDKCResult_StringErrorZ*)(((uint64_t)_res) & ~1);
13010         FREE((void*)_res);
13011         CResult_StringErrorZ_free(_res_conv);
13012 }
13013
13014 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13015         LDKChannelMonitorUpdate o_conv;
13016         o_conv.inner = (void*)(o & (~1));
13017         o_conv.is_owned = (o & 1) || (o == 0);
13018         o_conv = ChannelMonitorUpdate_clone(&o_conv);
13019         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
13020         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_ok(o_conv);
13021         return (uint64_t)ret_conv;
13022 }
13023
13024 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13025         LDKDecodeError e_conv;
13026         e_conv.inner = (void*)(e & (~1));
13027         e_conv.is_owned = (e & 1) || (e == 0);
13028         e_conv = DecodeError_clone(&e_conv);
13029         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
13030         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_err(e_conv);
13031         return (uint64_t)ret_conv;
13032 }
13033
13034 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13035         if ((_res & 1) != 0) return;
13036         LDKCResult_ChannelMonitorUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
13037         FREE((void*)_res);
13038         CResult_ChannelMonitorUpdateDecodeErrorZ_free(_res_conv);
13039 }
13040
13041 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13042         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(orig & ~1);
13043         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
13044         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(orig_conv);
13045         return (uint64_t)ret_conv;
13046 }
13047
13048 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13049         LDKHTLCUpdate o_conv;
13050         o_conv.inner = (void*)(o & (~1));
13051         o_conv.is_owned = (o & 1) || (o == 0);
13052         o_conv = HTLCUpdate_clone(&o_conv);
13053         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
13054         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_ok(o_conv);
13055         return (uint64_t)ret_conv;
13056 }
13057
13058 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13059         LDKDecodeError e_conv;
13060         e_conv.inner = (void*)(e & (~1));
13061         e_conv.is_owned = (e & 1) || (e == 0);
13062         e_conv = DecodeError_clone(&e_conv);
13063         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
13064         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_err(e_conv);
13065         return (uint64_t)ret_conv;
13066 }
13067
13068 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13069         if ((_res & 1) != 0) return;
13070         LDKCResult_HTLCUpdateDecodeErrorZ _res_conv = *(LDKCResult_HTLCUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
13071         FREE((void*)_res);
13072         CResult_HTLCUpdateDecodeErrorZ_free(_res_conv);
13073 }
13074
13075 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13076         LDKCResult_HTLCUpdateDecodeErrorZ* orig_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(orig & ~1);
13077         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
13078         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(orig_conv);
13079         return (uint64_t)ret_conv;
13080 }
13081
13082 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneMonitorUpdateErrorZ_1ok(JNIEnv *env, jclass clz) {
13083         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
13084         *ret_conv = CResult_NoneMonitorUpdateErrorZ_ok();
13085         return (uint64_t)ret_conv;
13086 }
13087
13088 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneMonitorUpdateErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13089         LDKMonitorUpdateError e_conv;
13090         e_conv.inner = (void*)(e & (~1));
13091         e_conv.is_owned = (e & 1) || (e == 0);
13092         e_conv = MonitorUpdateError_clone(&e_conv);
13093         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
13094         *ret_conv = CResult_NoneMonitorUpdateErrorZ_err(e_conv);
13095         return (uint64_t)ret_conv;
13096 }
13097
13098 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneMonitorUpdateErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13099         if ((_res & 1) != 0) return;
13100         LDKCResult_NoneMonitorUpdateErrorZ _res_conv = *(LDKCResult_NoneMonitorUpdateErrorZ*)(((uint64_t)_res) & ~1);
13101         FREE((void*)_res);
13102         CResult_NoneMonitorUpdateErrorZ_free(_res_conv);
13103 }
13104
13105 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneMonitorUpdateErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13106         LDKCResult_NoneMonitorUpdateErrorZ* orig_conv = (LDKCResult_NoneMonitorUpdateErrorZ*)(orig & ~1);
13107         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
13108         *ret_conv = CResult_NoneMonitorUpdateErrorZ_clone(orig_conv);
13109         return (uint64_t)ret_conv;
13110 }
13111
13112 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13113         LDKC2Tuple_OutPointScriptZ* orig_conv = (LDKC2Tuple_OutPointScriptZ*)(orig & ~1);
13114         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
13115         *ret_conv = C2Tuple_OutPointScriptZ_clone(orig_conv);
13116         return ((uint64_t)ret_conv);
13117 }
13118
13119 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
13120         LDKOutPoint a_conv;
13121         a_conv.inner = (void*)(a & (~1));
13122         a_conv.is_owned = (a & 1) || (a == 0);
13123         a_conv = OutPoint_clone(&a_conv);
13124         LDKCVec_u8Z b_ref;
13125         b_ref.datalen = (*env)->GetArrayLength(env, b);
13126         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
13127         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
13128         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
13129         *ret_conv = C2Tuple_OutPointScriptZ_new(a_conv, b_ref);
13130         return ((uint64_t)ret_conv);
13131 }
13132
13133 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13134         if ((_res & 1) != 0) return;
13135         LDKC2Tuple_OutPointScriptZ _res_conv = *(LDKC2Tuple_OutPointScriptZ*)(((uint64_t)_res) & ~1);
13136         FREE((void*)_res);
13137         C2Tuple_OutPointScriptZ_free(_res_conv);
13138 }
13139
13140 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13141         LDKC2Tuple_u32ScriptZ* orig_conv = (LDKC2Tuple_u32ScriptZ*)(orig & ~1);
13142         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
13143         *ret_conv = C2Tuple_u32ScriptZ_clone(orig_conv);
13144         return ((uint64_t)ret_conv);
13145 }
13146
13147 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1new(JNIEnv *env, jclass clz, int32_t a, int8_tArray b) {
13148         LDKCVec_u8Z b_ref;
13149         b_ref.datalen = (*env)->GetArrayLength(env, b);
13150         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
13151         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
13152         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
13153         *ret_conv = C2Tuple_u32ScriptZ_new(a, b_ref);
13154         return ((uint64_t)ret_conv);
13155 }
13156
13157 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13158         if ((_res & 1) != 0) return;
13159         LDKC2Tuple_u32ScriptZ _res_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)_res) & ~1);
13160         FREE((void*)_res);
13161         C2Tuple_u32ScriptZ_free(_res_conv);
13162 }
13163
13164 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1u32ScriptZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
13165         LDKCVec_C2Tuple_u32ScriptZZ _res_constr;
13166         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
13167         if (_res_constr.datalen > 0)
13168                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
13169         else
13170                 _res_constr.data = NULL;
13171         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
13172         for (size_t v = 0; v < _res_constr.datalen; v++) {
13173                 int64_t _res_conv_21 = _res_vals[v];
13174                 LDKC2Tuple_u32ScriptZ _res_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)_res_conv_21) & ~1);
13175                 FREE((void*)_res_conv_21);
13176                 _res_constr.data[v] = _res_conv_21_conv;
13177         }
13178         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
13179         CVec_C2Tuple_u32ScriptZZ_free(_res_constr);
13180 }
13181
13182 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13183         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(orig & ~1);
13184         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
13185         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(orig_conv);
13186         return ((uint64_t)ret_conv);
13187 }
13188
13189 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
13190         LDKThirtyTwoBytes a_ref;
13191         CHECK((*env)->GetArrayLength(env, a) == 32);
13192         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
13193         LDKCVec_C2Tuple_u32ScriptZZ b_constr;
13194         b_constr.datalen = (*env)->GetArrayLength(env, b);
13195         if (b_constr.datalen > 0)
13196                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
13197         else
13198                 b_constr.data = NULL;
13199         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
13200         for (size_t v = 0; v < b_constr.datalen; v++) {
13201                 int64_t b_conv_21 = b_vals[v];
13202                 LDKC2Tuple_u32ScriptZ b_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_21) & ~1);
13203                 b_conv_21_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_21) & ~1));
13204                 b_constr.data[v] = b_conv_21_conv;
13205         }
13206         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
13207         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
13208         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(a_ref, b_constr);
13209         return ((uint64_t)ret_conv);
13210 }
13211
13212 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13213         if ((_res & 1) != 0) return;
13214         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)_res) & ~1);
13215         FREE((void*)_res);
13216         C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(_res_conv);
13217 }
13218
13219 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
13220         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ _res_constr;
13221         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
13222         if (_res_constr.datalen > 0)
13223                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ Elements");
13224         else
13225                 _res_constr.data = NULL;
13226         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
13227         for (size_t o = 0; o < _res_constr.datalen; o++) {
13228                 int64_t _res_conv_40 = _res_vals[o];
13229                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv_40_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)_res_conv_40) & ~1);
13230                 FREE((void*)_res_conv_40);
13231                 _res_constr.data[o] = _res_conv_40_conv;
13232         }
13233         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
13234         CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(_res_constr);
13235 }
13236
13237 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1EventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
13238         LDKCVec_EventZ _res_constr;
13239         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
13240         if (_res_constr.datalen > 0)
13241                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKEvent), "LDKCVec_EventZ Elements");
13242         else
13243                 _res_constr.data = NULL;
13244         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
13245         for (size_t h = 0; h < _res_constr.datalen; h++) {
13246                 int64_t _res_conv_7 = _res_vals[h];
13247                 LDKEvent _res_conv_7_conv = *(LDKEvent*)(((uint64_t)_res_conv_7) & ~1);
13248                 FREE((void*)_res_conv_7);
13249                 _res_constr.data[h] = _res_conv_7_conv;
13250         }
13251         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
13252         CVec_EventZ_free(_res_constr);
13253 }
13254
13255 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TransactionZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
13256         LDKCVec_TransactionZ _res_constr;
13257         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
13258         if (_res_constr.datalen > 0)
13259                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTransaction), "LDKCVec_TransactionZ Elements");
13260         else
13261                 _res_constr.data = NULL;
13262         for (size_t i = 0; i < _res_constr.datalen; i++) {
13263                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
13264                 LDKTransaction _res_conv_8_ref;
13265                 _res_conv_8_ref.datalen = (*env)->GetArrayLength(env, _res_conv_8);
13266                 _res_conv_8_ref.data = MALLOC(_res_conv_8_ref.datalen, "LDKTransaction Bytes");
13267                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, _res_conv_8_ref.datalen, _res_conv_8_ref.data);
13268                 _res_conv_8_ref.data_is_owned = true;
13269                 _res_constr.data[i] = _res_conv_8_ref;
13270         }
13271         CVec_TransactionZ_free(_res_constr);
13272 }
13273
13274 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13275         LDKC2Tuple_u32TxOutZ* orig_conv = (LDKC2Tuple_u32TxOutZ*)(orig & ~1);
13276         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
13277         *ret_conv = C2Tuple_u32TxOutZ_clone(orig_conv);
13278         return ((uint64_t)ret_conv);
13279 }
13280
13281 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1new(JNIEnv *env, jclass clz, int32_t a, int64_t b) {
13282         LDKTxOut b_conv = *(LDKTxOut*)(((uint64_t)b) & ~1);
13283         b_conv = TxOut_clone((LDKTxOut*)(((uint64_t)b) & ~1));
13284         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
13285         *ret_conv = C2Tuple_u32TxOutZ_new(a, b_conv);
13286         return ((uint64_t)ret_conv);
13287 }
13288
13289 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13290         if ((_res & 1) != 0) return;
13291         LDKC2Tuple_u32TxOutZ _res_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)_res) & ~1);
13292         FREE((void*)_res);
13293         C2Tuple_u32TxOutZ_free(_res_conv);
13294 }
13295
13296 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1u32TxOutZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
13297         LDKCVec_C2Tuple_u32TxOutZZ _res_constr;
13298         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
13299         if (_res_constr.datalen > 0)
13300                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
13301         else
13302                 _res_constr.data = NULL;
13303         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
13304         for (size_t u = 0; u < _res_constr.datalen; u++) {
13305                 int64_t _res_conv_20 = _res_vals[u];
13306                 LDKC2Tuple_u32TxOutZ _res_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)_res_conv_20) & ~1);
13307                 FREE((void*)_res_conv_20);
13308                 _res_constr.data[u] = _res_conv_20_conv;
13309         }
13310         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
13311         CVec_C2Tuple_u32TxOutZZ_free(_res_constr);
13312 }
13313
13314 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13315         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(orig & ~1);
13316         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
13317         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(orig_conv);
13318         return ((uint64_t)ret_conv);
13319 }
13320
13321 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
13322         LDKThirtyTwoBytes a_ref;
13323         CHECK((*env)->GetArrayLength(env, a) == 32);
13324         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
13325         LDKCVec_C2Tuple_u32TxOutZZ b_constr;
13326         b_constr.datalen = (*env)->GetArrayLength(env, b);
13327         if (b_constr.datalen > 0)
13328                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
13329         else
13330                 b_constr.data = NULL;
13331         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
13332         for (size_t u = 0; u < b_constr.datalen; u++) {
13333                 int64_t b_conv_20 = b_vals[u];
13334                 LDKC2Tuple_u32TxOutZ b_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_20) & ~1);
13335                 b_conv_20_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_20) & ~1));
13336                 b_constr.data[u] = b_conv_20_conv;
13337         }
13338         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
13339         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
13340         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(a_ref, b_constr);
13341         return ((uint64_t)ret_conv);
13342 }
13343
13344 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13345         if ((_res & 1) != 0) return;
13346         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)_res) & ~1);
13347         FREE((void*)_res);
13348         C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(_res_conv);
13349 }
13350
13351 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
13352         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ _res_constr;
13353         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
13354         if (_res_constr.datalen > 0)
13355                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Elements");
13356         else
13357                 _res_constr.data = NULL;
13358         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
13359         for (size_t n = 0; n < _res_constr.datalen; n++) {
13360                 int64_t _res_conv_39 = _res_vals[n];
13361                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv_39_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)_res_conv_39) & ~1);
13362                 FREE((void*)_res_conv_39);
13363                 _res_constr.data[n] = _res_conv_39_conv;
13364         }
13365         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
13366         CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(_res_constr);
13367 }
13368
13369 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1BalanceZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
13370         LDKCVec_BalanceZ _res_constr;
13371         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
13372         if (_res_constr.datalen > 0)
13373                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKBalance), "LDKCVec_BalanceZ Elements");
13374         else
13375                 _res_constr.data = NULL;
13376         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
13377         for (size_t j = 0; j < _res_constr.datalen; j++) {
13378                 int64_t _res_conv_9 = _res_vals[j];
13379                 LDKBalance _res_conv_9_conv = *(LDKBalance*)(((uint64_t)_res_conv_9) & ~1);
13380                 FREE((void*)_res_conv_9);
13381                 _res_constr.data[j] = _res_conv_9_conv;
13382         }
13383         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
13384         CVec_BalanceZ_free(_res_constr);
13385 }
13386
13387 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13388         LDKC2Tuple_BlockHashChannelMonitorZ o_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)o) & ~1);
13389         o_conv = C2Tuple_BlockHashChannelMonitorZ_clone((LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)o) & ~1));
13390         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
13391         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(o_conv);
13392         return (uint64_t)ret_conv;
13393 }
13394
13395 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13396         LDKDecodeError e_conv;
13397         e_conv.inner = (void*)(e & (~1));
13398         e_conv.is_owned = (e & 1) || (e == 0);
13399         e_conv = DecodeError_clone(&e_conv);
13400         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
13401         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(e_conv);
13402         return (uint64_t)ret_conv;
13403 }
13404
13405 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13406         if ((_res & 1) != 0) return;
13407         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(((uint64_t)_res) & ~1);
13408         FREE((void*)_res);
13409         CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(_res_conv);
13410 }
13411
13412 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13413         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* orig_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(orig & ~1);
13414         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
13415         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone(orig_conv);
13416         return (uint64_t)ret_conv;
13417 }
13418
13419 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1ok(JNIEnv *env, jclass clz) {
13420         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
13421         *ret_conv = CResult_NoneLightningErrorZ_ok();
13422         return (uint64_t)ret_conv;
13423 }
13424
13425 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13426         LDKLightningError e_conv;
13427         e_conv.inner = (void*)(e & (~1));
13428         e_conv.is_owned = (e & 1) || (e == 0);
13429         e_conv = LightningError_clone(&e_conv);
13430         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
13431         *ret_conv = CResult_NoneLightningErrorZ_err(e_conv);
13432         return (uint64_t)ret_conv;
13433 }
13434
13435 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13436         if ((_res & 1) != 0) return;
13437         LDKCResult_NoneLightningErrorZ _res_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)_res) & ~1);
13438         FREE((void*)_res);
13439         CResult_NoneLightningErrorZ_free(_res_conv);
13440 }
13441
13442 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13443         LDKCResult_NoneLightningErrorZ* orig_conv = (LDKCResult_NoneLightningErrorZ*)(orig & ~1);
13444         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
13445         *ret_conv = CResult_NoneLightningErrorZ_clone(orig_conv);
13446         return (uint64_t)ret_conv;
13447 }
13448
13449 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13450         LDKC2Tuple_PublicKeyTypeZ* orig_conv = (LDKC2Tuple_PublicKeyTypeZ*)(orig & ~1);
13451         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
13452         *ret_conv = C2Tuple_PublicKeyTypeZ_clone(orig_conv);
13453         return ((uint64_t)ret_conv);
13454 }
13455
13456 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
13457         LDKPublicKey a_ref;
13458         CHECK((*env)->GetArrayLength(env, a) == 33);
13459         (*env)->GetByteArrayRegion(env, a, 0, 33, a_ref.compressed_form);
13460         LDKType b_conv = *(LDKType*)(((uint64_t)b) & ~1);
13461         if (b_conv.free == LDKType_JCalls_free) {
13462                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
13463                 LDKType_JCalls_cloned(&b_conv);
13464         }
13465         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
13466         *ret_conv = C2Tuple_PublicKeyTypeZ_new(a_ref, b_conv);
13467         return ((uint64_t)ret_conv);
13468 }
13469
13470 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13471         if ((_res & 1) != 0) return;
13472         LDKC2Tuple_PublicKeyTypeZ _res_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(((uint64_t)_res) & ~1);
13473         FREE((void*)_res);
13474         C2Tuple_PublicKeyTypeZ_free(_res_conv);
13475 }
13476
13477 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1PublicKeyTypeZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
13478         LDKCVec_C2Tuple_PublicKeyTypeZZ _res_constr;
13479         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
13480         if (_res_constr.datalen > 0)
13481                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ Elements");
13482         else
13483                 _res_constr.data = NULL;
13484         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
13485         for (size_t z = 0; z < _res_constr.datalen; z++) {
13486                 int64_t _res_conv_25 = _res_vals[z];
13487                 LDKC2Tuple_PublicKeyTypeZ _res_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(((uint64_t)_res_conv_25) & ~1);
13488                 FREE((void*)_res_conv_25);
13489                 _res_constr.data[z] = _res_conv_25_conv;
13490         }
13491         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
13492         CVec_C2Tuple_PublicKeyTypeZZ_free(_res_constr);
13493 }
13494
13495 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1ok(JNIEnv *env, jclass clz, jboolean o) {
13496         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
13497         *ret_conv = CResult_boolLightningErrorZ_ok(o);
13498         return (uint64_t)ret_conv;
13499 }
13500
13501 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13502         LDKLightningError e_conv;
13503         e_conv.inner = (void*)(e & (~1));
13504         e_conv.is_owned = (e & 1) || (e == 0);
13505         e_conv = LightningError_clone(&e_conv);
13506         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
13507         *ret_conv = CResult_boolLightningErrorZ_err(e_conv);
13508         return (uint64_t)ret_conv;
13509 }
13510
13511 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13512         if ((_res & 1) != 0) return;
13513         LDKCResult_boolLightningErrorZ _res_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)_res) & ~1);
13514         FREE((void*)_res);
13515         CResult_boolLightningErrorZ_free(_res_conv);
13516 }
13517
13518 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13519         LDKCResult_boolLightningErrorZ* orig_conv = (LDKCResult_boolLightningErrorZ*)(orig & ~1);
13520         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
13521         *ret_conv = CResult_boolLightningErrorZ_clone(orig_conv);
13522         return (uint64_t)ret_conv;
13523 }
13524
13525 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13526         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* orig_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(orig & ~1);
13527         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
13528         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(orig_conv);
13529         return ((uint64_t)ret_conv);
13530 }
13531
13532 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) {
13533         LDKChannelAnnouncement a_conv;
13534         a_conv.inner = (void*)(a & (~1));
13535         a_conv.is_owned = (a & 1) || (a == 0);
13536         a_conv = ChannelAnnouncement_clone(&a_conv);
13537         LDKChannelUpdate b_conv;
13538         b_conv.inner = (void*)(b & (~1));
13539         b_conv.is_owned = (b & 1) || (b == 0);
13540         b_conv = ChannelUpdate_clone(&b_conv);
13541         LDKChannelUpdate c_conv;
13542         c_conv.inner = (void*)(c & (~1));
13543         c_conv.is_owned = (c & 1) || (c == 0);
13544         c_conv = ChannelUpdate_clone(&c_conv);
13545         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
13546         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(a_conv, b_conv, c_conv);
13547         return ((uint64_t)ret_conv);
13548 }
13549
13550 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13551         if ((_res & 1) != 0) return;
13552         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)_res) & ~1);
13553         FREE((void*)_res);
13554         C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(_res_conv);
13555 }
13556
13557 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
13558         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ _res_constr;
13559         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
13560         if (_res_constr.datalen > 0)
13561                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
13562         else
13563                 _res_constr.data = NULL;
13564         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
13565         for (size_t h = 0; h < _res_constr.datalen; h++) {
13566                 int64_t _res_conv_59 = _res_vals[h];
13567                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv_59_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)_res_conv_59) & ~1);
13568                 FREE((void*)_res_conv_59);
13569                 _res_constr.data[h] = _res_conv_59_conv;
13570         }
13571         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
13572         CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(_res_constr);
13573 }
13574
13575 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1NodeAnnouncementZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
13576         LDKCVec_NodeAnnouncementZ _res_constr;
13577         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
13578         if (_res_constr.datalen > 0)
13579                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
13580         else
13581                 _res_constr.data = NULL;
13582         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
13583         for (size_t s = 0; s < _res_constr.datalen; s++) {
13584                 int64_t _res_conv_18 = _res_vals[s];
13585                 LDKNodeAnnouncement _res_conv_18_conv;
13586                 _res_conv_18_conv.inner = (void*)(_res_conv_18 & (~1));
13587                 _res_conv_18_conv.is_owned = (_res_conv_18 & 1) || (_res_conv_18 == 0);
13588                 _res_constr.data[s] = _res_conv_18_conv;
13589         }
13590         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
13591         CVec_NodeAnnouncementZ_free(_res_constr);
13592 }
13593
13594 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PublicKeyZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
13595         LDKCVec_PublicKeyZ _res_constr;
13596         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
13597         if (_res_constr.datalen > 0)
13598                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
13599         else
13600                 _res_constr.data = NULL;
13601         for (size_t i = 0; i < _res_constr.datalen; i++) {
13602                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
13603                 LDKPublicKey _res_conv_8_ref;
13604                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 33);
13605                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 33, _res_conv_8_ref.compressed_form);
13606                 _res_constr.data[i] = _res_conv_8_ref;
13607         }
13608         CVec_PublicKeyZ_free(_res_constr);
13609 }
13610
13611 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
13612         LDKCVec_u8Z o_ref;
13613         o_ref.datalen = (*env)->GetArrayLength(env, o);
13614         o_ref.data = MALLOC(o_ref.datalen, "LDKCVec_u8Z Bytes");
13615         (*env)->GetByteArrayRegion(env, o, 0, o_ref.datalen, o_ref.data);
13616         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
13617         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_ok(o_ref);
13618         return (uint64_t)ret_conv;
13619 }
13620
13621 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13622         LDKPeerHandleError e_conv;
13623         e_conv.inner = (void*)(e & (~1));
13624         e_conv.is_owned = (e & 1) || (e == 0);
13625         e_conv = PeerHandleError_clone(&e_conv);
13626         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
13627         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_err(e_conv);
13628         return (uint64_t)ret_conv;
13629 }
13630
13631 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13632         if ((_res & 1) != 0) return;
13633         LDKCResult_CVec_u8ZPeerHandleErrorZ _res_conv = *(LDKCResult_CVec_u8ZPeerHandleErrorZ*)(((uint64_t)_res) & ~1);
13634         FREE((void*)_res);
13635         CResult_CVec_u8ZPeerHandleErrorZ_free(_res_conv);
13636 }
13637
13638 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13639         LDKCResult_CVec_u8ZPeerHandleErrorZ* orig_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(orig & ~1);
13640         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
13641         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(orig_conv);
13642         return (uint64_t)ret_conv;
13643 }
13644
13645 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1ok(JNIEnv *env, jclass clz) {
13646         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
13647         *ret_conv = CResult_NonePeerHandleErrorZ_ok();
13648         return (uint64_t)ret_conv;
13649 }
13650
13651 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13652         LDKPeerHandleError e_conv;
13653         e_conv.inner = (void*)(e & (~1));
13654         e_conv.is_owned = (e & 1) || (e == 0);
13655         e_conv = PeerHandleError_clone(&e_conv);
13656         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
13657         *ret_conv = CResult_NonePeerHandleErrorZ_err(e_conv);
13658         return (uint64_t)ret_conv;
13659 }
13660
13661 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13662         if ((_res & 1) != 0) return;
13663         LDKCResult_NonePeerHandleErrorZ _res_conv = *(LDKCResult_NonePeerHandleErrorZ*)(((uint64_t)_res) & ~1);
13664         FREE((void*)_res);
13665         CResult_NonePeerHandleErrorZ_free(_res_conv);
13666 }
13667
13668 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13669         LDKCResult_NonePeerHandleErrorZ* orig_conv = (LDKCResult_NonePeerHandleErrorZ*)(orig & ~1);
13670         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
13671         *ret_conv = CResult_NonePeerHandleErrorZ_clone(orig_conv);
13672         return (uint64_t)ret_conv;
13673 }
13674
13675 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1ok(JNIEnv *env, jclass clz, jboolean o) {
13676         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
13677         *ret_conv = CResult_boolPeerHandleErrorZ_ok(o);
13678         return (uint64_t)ret_conv;
13679 }
13680
13681 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13682         LDKPeerHandleError e_conv;
13683         e_conv.inner = (void*)(e & (~1));
13684         e_conv.is_owned = (e & 1) || (e == 0);
13685         e_conv = PeerHandleError_clone(&e_conv);
13686         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
13687         *ret_conv = CResult_boolPeerHandleErrorZ_err(e_conv);
13688         return (uint64_t)ret_conv;
13689 }
13690
13691 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13692         if ((_res & 1) != 0) return;
13693         LDKCResult_boolPeerHandleErrorZ _res_conv = *(LDKCResult_boolPeerHandleErrorZ*)(((uint64_t)_res) & ~1);
13694         FREE((void*)_res);
13695         CResult_boolPeerHandleErrorZ_free(_res_conv);
13696 }
13697
13698 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13699         LDKCResult_boolPeerHandleErrorZ* orig_conv = (LDKCResult_boolPeerHandleErrorZ*)(orig & ~1);
13700         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
13701         *ret_conv = CResult_boolPeerHandleErrorZ_clone(orig_conv);
13702         return (uint64_t)ret_conv;
13703 }
13704
13705 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13706         LDKNodeId o_conv;
13707         o_conv.inner = (void*)(o & (~1));
13708         o_conv.is_owned = (o & 1) || (o == 0);
13709         o_conv = NodeId_clone(&o_conv);
13710         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
13711         *ret_conv = CResult_NodeIdDecodeErrorZ_ok(o_conv);
13712         return (uint64_t)ret_conv;
13713 }
13714
13715 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13716         LDKDecodeError e_conv;
13717         e_conv.inner = (void*)(e & (~1));
13718         e_conv.is_owned = (e & 1) || (e == 0);
13719         e_conv = DecodeError_clone(&e_conv);
13720         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
13721         *ret_conv = CResult_NodeIdDecodeErrorZ_err(e_conv);
13722         return (uint64_t)ret_conv;
13723 }
13724
13725 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13726         if ((_res & 1) != 0) return;
13727         LDKCResult_NodeIdDecodeErrorZ _res_conv = *(LDKCResult_NodeIdDecodeErrorZ*)(((uint64_t)_res) & ~1);
13728         FREE((void*)_res);
13729         CResult_NodeIdDecodeErrorZ_free(_res_conv);
13730 }
13731
13732 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13733         LDKCResult_NodeIdDecodeErrorZ* orig_conv = (LDKCResult_NodeIdDecodeErrorZ*)(orig & ~1);
13734         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
13735         *ret_conv = CResult_NodeIdDecodeErrorZ_clone(orig_conv);
13736         return (uint64_t)ret_conv;
13737 }
13738
13739 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1AccessZ_1some(JNIEnv *env, jclass clz, int64_t o) {
13740         LDKAccess o_conv = *(LDKAccess*)(((uint64_t)o) & ~1);
13741         if (o_conv.free == LDKAccess_JCalls_free) {
13742                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
13743                 LDKAccess_JCalls_cloned(&o_conv);
13744         }
13745         LDKCOption_AccessZ *ret_copy = MALLOC(sizeof(LDKCOption_AccessZ), "LDKCOption_AccessZ");
13746         *ret_copy = COption_AccessZ_some(o_conv);
13747         uint64_t ret_ref = (uint64_t)ret_copy;
13748         return ret_ref;
13749 }
13750
13751 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1AccessZ_1none(JNIEnv *env, jclass clz) {
13752         LDKCOption_AccessZ *ret_copy = MALLOC(sizeof(LDKCOption_AccessZ), "LDKCOption_AccessZ");
13753         *ret_copy = COption_AccessZ_none();
13754         uint64_t ret_ref = (uint64_t)ret_copy;
13755         return ret_ref;
13756 }
13757
13758 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1AccessZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13759         if ((_res & 1) != 0) return;
13760         LDKCOption_AccessZ _res_conv = *(LDKCOption_AccessZ*)(((uint64_t)_res) & ~1);
13761         FREE((void*)_res);
13762         COption_AccessZ_free(_res_conv);
13763 }
13764
13765 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DirectionalChannelInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13766         LDKDirectionalChannelInfo o_conv;
13767         o_conv.inner = (void*)(o & (~1));
13768         o_conv.is_owned = (o & 1) || (o == 0);
13769         o_conv = DirectionalChannelInfo_clone(&o_conv);
13770         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
13771         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_ok(o_conv);
13772         return (uint64_t)ret_conv;
13773 }
13774
13775 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DirectionalChannelInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13776         LDKDecodeError e_conv;
13777         e_conv.inner = (void*)(e & (~1));
13778         e_conv.is_owned = (e & 1) || (e == 0);
13779         e_conv = DecodeError_clone(&e_conv);
13780         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
13781         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_err(e_conv);
13782         return (uint64_t)ret_conv;
13783 }
13784
13785 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1DirectionalChannelInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13786         if ((_res & 1) != 0) return;
13787         LDKCResult_DirectionalChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
13788         FREE((void*)_res);
13789         CResult_DirectionalChannelInfoDecodeErrorZ_free(_res_conv);
13790 }
13791
13792 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DirectionalChannelInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13793         LDKCResult_DirectionalChannelInfoDecodeErrorZ* orig_conv = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(orig & ~1);
13794         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
13795         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_clone(orig_conv);
13796         return (uint64_t)ret_conv;
13797 }
13798
13799 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13800         LDKChannelInfo o_conv;
13801         o_conv.inner = (void*)(o & (~1));
13802         o_conv.is_owned = (o & 1) || (o == 0);
13803         o_conv = ChannelInfo_clone(&o_conv);
13804         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
13805         *ret_conv = CResult_ChannelInfoDecodeErrorZ_ok(o_conv);
13806         return (uint64_t)ret_conv;
13807 }
13808
13809 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13810         LDKDecodeError e_conv;
13811         e_conv.inner = (void*)(e & (~1));
13812         e_conv.is_owned = (e & 1) || (e == 0);
13813         e_conv = DecodeError_clone(&e_conv);
13814         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
13815         *ret_conv = CResult_ChannelInfoDecodeErrorZ_err(e_conv);
13816         return (uint64_t)ret_conv;
13817 }
13818
13819 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13820         if ((_res & 1) != 0) return;
13821         LDKCResult_ChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
13822         FREE((void*)_res);
13823         CResult_ChannelInfoDecodeErrorZ_free(_res_conv);
13824 }
13825
13826 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13827         LDKCResult_ChannelInfoDecodeErrorZ* orig_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(orig & ~1);
13828         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
13829         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(orig_conv);
13830         return (uint64_t)ret_conv;
13831 }
13832
13833 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13834         LDKRoutingFees o_conv;
13835         o_conv.inner = (void*)(o & (~1));
13836         o_conv.is_owned = (o & 1) || (o == 0);
13837         o_conv = RoutingFees_clone(&o_conv);
13838         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
13839         *ret_conv = CResult_RoutingFeesDecodeErrorZ_ok(o_conv);
13840         return (uint64_t)ret_conv;
13841 }
13842
13843 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13844         LDKDecodeError e_conv;
13845         e_conv.inner = (void*)(e & (~1));
13846         e_conv.is_owned = (e & 1) || (e == 0);
13847         e_conv = DecodeError_clone(&e_conv);
13848         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
13849         *ret_conv = CResult_RoutingFeesDecodeErrorZ_err(e_conv);
13850         return (uint64_t)ret_conv;
13851 }
13852
13853 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13854         if ((_res & 1) != 0) return;
13855         LDKCResult_RoutingFeesDecodeErrorZ _res_conv = *(LDKCResult_RoutingFeesDecodeErrorZ*)(((uint64_t)_res) & ~1);
13856         FREE((void*)_res);
13857         CResult_RoutingFeesDecodeErrorZ_free(_res_conv);
13858 }
13859
13860 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13861         LDKCResult_RoutingFeesDecodeErrorZ* orig_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(orig & ~1);
13862         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
13863         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(orig_conv);
13864         return (uint64_t)ret_conv;
13865 }
13866
13867 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13868         LDKNodeAnnouncementInfo o_conv;
13869         o_conv.inner = (void*)(o & (~1));
13870         o_conv.is_owned = (o & 1) || (o == 0);
13871         o_conv = NodeAnnouncementInfo_clone(&o_conv);
13872         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
13873         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_ok(o_conv);
13874         return (uint64_t)ret_conv;
13875 }
13876
13877 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13878         LDKDecodeError e_conv;
13879         e_conv.inner = (void*)(e & (~1));
13880         e_conv.is_owned = (e & 1) || (e == 0);
13881         e_conv = DecodeError_clone(&e_conv);
13882         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
13883         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_err(e_conv);
13884         return (uint64_t)ret_conv;
13885 }
13886
13887 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13888         if ((_res & 1) != 0) return;
13889         LDKCResult_NodeAnnouncementInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
13890         FREE((void*)_res);
13891         CResult_NodeAnnouncementInfoDecodeErrorZ_free(_res_conv);
13892 }
13893
13894 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13895         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(orig & ~1);
13896         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
13897         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(orig_conv);
13898         return (uint64_t)ret_conv;
13899 }
13900
13901 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u64Z_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
13902         LDKCVec_u64Z _res_constr;
13903         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
13904         if (_res_constr.datalen > 0)
13905                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
13906         else
13907                 _res_constr.data = NULL;
13908         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
13909         for (size_t g = 0; g < _res_constr.datalen; g++) {
13910                 int64_t _res_conv_6 = _res_vals[g];
13911                 _res_constr.data[g] = _res_conv_6;
13912         }
13913         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
13914         CVec_u64Z_free(_res_constr);
13915 }
13916
13917 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13918         LDKNodeInfo o_conv;
13919         o_conv.inner = (void*)(o & (~1));
13920         o_conv.is_owned = (o & 1) || (o == 0);
13921         o_conv = NodeInfo_clone(&o_conv);
13922         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
13923         *ret_conv = CResult_NodeInfoDecodeErrorZ_ok(o_conv);
13924         return (uint64_t)ret_conv;
13925 }
13926
13927 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13928         LDKDecodeError e_conv;
13929         e_conv.inner = (void*)(e & (~1));
13930         e_conv.is_owned = (e & 1) || (e == 0);
13931         e_conv = DecodeError_clone(&e_conv);
13932         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
13933         *ret_conv = CResult_NodeInfoDecodeErrorZ_err(e_conv);
13934         return (uint64_t)ret_conv;
13935 }
13936
13937 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13938         if ((_res & 1) != 0) return;
13939         LDKCResult_NodeInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
13940         FREE((void*)_res);
13941         CResult_NodeInfoDecodeErrorZ_free(_res_conv);
13942 }
13943
13944 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13945         LDKCResult_NodeInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(orig & ~1);
13946         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
13947         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(orig_conv);
13948         return (uint64_t)ret_conv;
13949 }
13950
13951 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13952         LDKNetworkGraph o_conv;
13953         o_conv.inner = (void*)(o & (~1));
13954         o_conv.is_owned = (o & 1) || (o == 0);
13955         o_conv = NetworkGraph_clone(&o_conv);
13956         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
13957         *ret_conv = CResult_NetworkGraphDecodeErrorZ_ok(o_conv);
13958         return (uint64_t)ret_conv;
13959 }
13960
13961 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13962         LDKDecodeError e_conv;
13963         e_conv.inner = (void*)(e & (~1));
13964         e_conv.is_owned = (e & 1) || (e == 0);
13965         e_conv = DecodeError_clone(&e_conv);
13966         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
13967         *ret_conv = CResult_NetworkGraphDecodeErrorZ_err(e_conv);
13968         return (uint64_t)ret_conv;
13969 }
13970
13971 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13972         if ((_res & 1) != 0) return;
13973         LDKCResult_NetworkGraphDecodeErrorZ _res_conv = *(LDKCResult_NetworkGraphDecodeErrorZ*)(((uint64_t)_res) & ~1);
13974         FREE((void*)_res);
13975         CResult_NetworkGraphDecodeErrorZ_free(_res_conv);
13976 }
13977
13978 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13979         LDKCResult_NetworkGraphDecodeErrorZ* orig_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(orig & ~1);
13980         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
13981         *ret_conv = CResult_NetworkGraphDecodeErrorZ_clone(orig_conv);
13982         return (uint64_t)ret_conv;
13983 }
13984
13985 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1some(JNIEnv *env, jclass clz, int64_tArray o) {
13986         LDKCVec_NetAddressZ o_constr;
13987         o_constr.datalen = (*env)->GetArrayLength(env, o);
13988         if (o_constr.datalen > 0)
13989                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
13990         else
13991                 o_constr.data = NULL;
13992         int64_t* o_vals = (*env)->GetLongArrayElements (env, o, NULL);
13993         for (size_t m = 0; m < o_constr.datalen; m++) {
13994                 int64_t o_conv_12 = o_vals[m];
13995                 LDKNetAddress o_conv_12_conv = *(LDKNetAddress*)(((uint64_t)o_conv_12) & ~1);
13996                 o_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)o_conv_12) & ~1));
13997                 o_constr.data[m] = o_conv_12_conv;
13998         }
13999         (*env)->ReleaseLongArrayElements(env, o, o_vals, 0);
14000         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
14001         *ret_copy = COption_CVec_NetAddressZZ_some(o_constr);
14002         uint64_t ret_ref = (uint64_t)ret_copy;
14003         return ret_ref;
14004 }
14005
14006 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1none(JNIEnv *env, jclass clz) {
14007         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
14008         *ret_copy = COption_CVec_NetAddressZZ_none();
14009         uint64_t ret_ref = (uint64_t)ret_copy;
14010         return ret_ref;
14011 }
14012
14013 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14014         if ((_res & 1) != 0) return;
14015         LDKCOption_CVec_NetAddressZZ _res_conv = *(LDKCOption_CVec_NetAddressZZ*)(((uint64_t)_res) & ~1);
14016         FREE((void*)_res);
14017         COption_CVec_NetAddressZZ_free(_res_conv);
14018 }
14019
14020 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14021         LDKCOption_CVec_NetAddressZZ* orig_conv = (LDKCOption_CVec_NetAddressZZ*)orig;
14022         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
14023         *ret_copy = COption_CVec_NetAddressZZ_clone(orig_conv);
14024         uint64_t ret_ref = (uint64_t)ret_copy;
14025         return ret_ref;
14026 }
14027
14028 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressu8Z_1ok(JNIEnv *env, jclass clz, int64_t o) {
14029         LDKNetAddress o_conv = *(LDKNetAddress*)(((uint64_t)o) & ~1);
14030         o_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)o) & ~1));
14031         LDKCResult_NetAddressu8Z* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
14032         *ret_conv = CResult_NetAddressu8Z_ok(o_conv);
14033         return (uint64_t)ret_conv;
14034 }
14035
14036 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressu8Z_1err(JNIEnv *env, jclass clz, int8_t e) {
14037         LDKCResult_NetAddressu8Z* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
14038         *ret_conv = CResult_NetAddressu8Z_err(e);
14039         return (uint64_t)ret_conv;
14040 }
14041
14042 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressu8Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
14043         if ((_res & 1) != 0) return;
14044         LDKCResult_NetAddressu8Z _res_conv = *(LDKCResult_NetAddressu8Z*)(((uint64_t)_res) & ~1);
14045         FREE((void*)_res);
14046         CResult_NetAddressu8Z_free(_res_conv);
14047 }
14048
14049 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressu8Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14050         LDKCResult_NetAddressu8Z* orig_conv = (LDKCResult_NetAddressu8Z*)(orig & ~1);
14051         LDKCResult_NetAddressu8Z* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
14052         *ret_conv = CResult_NetAddressu8Z_clone(orig_conv);
14053         return (uint64_t)ret_conv;
14054 }
14055
14056 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CResult_1NetAddressu8ZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14057         LDKCResult_NetAddressu8Z o_conv = *(LDKCResult_NetAddressu8Z*)(((uint64_t)o) & ~1);
14058         o_conv = CResult_NetAddressu8Z_clone((LDKCResult_NetAddressu8Z*)(((uint64_t)o) & ~1));
14059         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
14060         *ret_conv = CResult_CResult_NetAddressu8ZDecodeErrorZ_ok(o_conv);
14061         return (uint64_t)ret_conv;
14062 }
14063
14064 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CResult_1NetAddressu8ZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14065         LDKDecodeError e_conv;
14066         e_conv.inner = (void*)(e & (~1));
14067         e_conv.is_owned = (e & 1) || (e == 0);
14068         e_conv = DecodeError_clone(&e_conv);
14069         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
14070         *ret_conv = CResult_CResult_NetAddressu8ZDecodeErrorZ_err(e_conv);
14071         return (uint64_t)ret_conv;
14072 }
14073
14074 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CResult_1NetAddressu8ZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14075         if ((_res & 1) != 0) return;
14076         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ _res_conv = *(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(((uint64_t)_res) & ~1);
14077         FREE((void*)_res);
14078         CResult_CResult_NetAddressu8ZDecodeErrorZ_free(_res_conv);
14079 }
14080
14081 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CResult_1NetAddressu8ZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14082         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* orig_conv = (LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(orig & ~1);
14083         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
14084         *ret_conv = CResult_CResult_NetAddressu8ZDecodeErrorZ_clone(orig_conv);
14085         return (uint64_t)ret_conv;
14086 }
14087
14088 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14089         LDKNetAddress o_conv = *(LDKNetAddress*)(((uint64_t)o) & ~1);
14090         o_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)o) & ~1));
14091         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
14092         *ret_conv = CResult_NetAddressDecodeErrorZ_ok(o_conv);
14093         return (uint64_t)ret_conv;
14094 }
14095
14096 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14097         LDKDecodeError e_conv;
14098         e_conv.inner = (void*)(e & (~1));
14099         e_conv.is_owned = (e & 1) || (e == 0);
14100         e_conv = DecodeError_clone(&e_conv);
14101         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
14102         *ret_conv = CResult_NetAddressDecodeErrorZ_err(e_conv);
14103         return (uint64_t)ret_conv;
14104 }
14105
14106 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14107         if ((_res & 1) != 0) return;
14108         LDKCResult_NetAddressDecodeErrorZ _res_conv = *(LDKCResult_NetAddressDecodeErrorZ*)(((uint64_t)_res) & ~1);
14109         FREE((void*)_res);
14110         CResult_NetAddressDecodeErrorZ_free(_res_conv);
14111 }
14112
14113 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14114         LDKCResult_NetAddressDecodeErrorZ* orig_conv = (LDKCResult_NetAddressDecodeErrorZ*)(orig & ~1);
14115         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
14116         *ret_conv = CResult_NetAddressDecodeErrorZ_clone(orig_conv);
14117         return (uint64_t)ret_conv;
14118 }
14119
14120 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateAddHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
14121         LDKCVec_UpdateAddHTLCZ _res_constr;
14122         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
14123         if (_res_constr.datalen > 0)
14124                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
14125         else
14126                 _res_constr.data = NULL;
14127         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
14128         for (size_t p = 0; p < _res_constr.datalen; p++) {
14129                 int64_t _res_conv_15 = _res_vals[p];
14130                 LDKUpdateAddHTLC _res_conv_15_conv;
14131                 _res_conv_15_conv.inner = (void*)(_res_conv_15 & (~1));
14132                 _res_conv_15_conv.is_owned = (_res_conv_15 & 1) || (_res_conv_15 == 0);
14133                 _res_constr.data[p] = _res_conv_15_conv;
14134         }
14135         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
14136         CVec_UpdateAddHTLCZ_free(_res_constr);
14137 }
14138
14139 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFulfillHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
14140         LDKCVec_UpdateFulfillHTLCZ _res_constr;
14141         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
14142         if (_res_constr.datalen > 0)
14143                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
14144         else
14145                 _res_constr.data = NULL;
14146         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
14147         for (size_t t = 0; t < _res_constr.datalen; t++) {
14148                 int64_t _res_conv_19 = _res_vals[t];
14149                 LDKUpdateFulfillHTLC _res_conv_19_conv;
14150                 _res_conv_19_conv.inner = (void*)(_res_conv_19 & (~1));
14151                 _res_conv_19_conv.is_owned = (_res_conv_19 & 1) || (_res_conv_19 == 0);
14152                 _res_constr.data[t] = _res_conv_19_conv;
14153         }
14154         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
14155         CVec_UpdateFulfillHTLCZ_free(_res_constr);
14156 }
14157
14158 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFailHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
14159         LDKCVec_UpdateFailHTLCZ _res_constr;
14160         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
14161         if (_res_constr.datalen > 0)
14162                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
14163         else
14164                 _res_constr.data = NULL;
14165         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
14166         for (size_t q = 0; q < _res_constr.datalen; q++) {
14167                 int64_t _res_conv_16 = _res_vals[q];
14168                 LDKUpdateFailHTLC _res_conv_16_conv;
14169                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
14170                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
14171                 _res_constr.data[q] = _res_conv_16_conv;
14172         }
14173         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
14174         CVec_UpdateFailHTLCZ_free(_res_constr);
14175 }
14176
14177 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFailMalformedHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
14178         LDKCVec_UpdateFailMalformedHTLCZ _res_constr;
14179         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
14180         if (_res_constr.datalen > 0)
14181                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
14182         else
14183                 _res_constr.data = NULL;
14184         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
14185         for (size_t z = 0; z < _res_constr.datalen; z++) {
14186                 int64_t _res_conv_25 = _res_vals[z];
14187                 LDKUpdateFailMalformedHTLC _res_conv_25_conv;
14188                 _res_conv_25_conv.inner = (void*)(_res_conv_25 & (~1));
14189                 _res_conv_25_conv.is_owned = (_res_conv_25 & 1) || (_res_conv_25 == 0);
14190                 _res_constr.data[z] = _res_conv_25_conv;
14191         }
14192         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
14193         CVec_UpdateFailMalformedHTLCZ_free(_res_constr);
14194 }
14195
14196 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14197         LDKAcceptChannel o_conv;
14198         o_conv.inner = (void*)(o & (~1));
14199         o_conv.is_owned = (o & 1) || (o == 0);
14200         o_conv = AcceptChannel_clone(&o_conv);
14201         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
14202         *ret_conv = CResult_AcceptChannelDecodeErrorZ_ok(o_conv);
14203         return (uint64_t)ret_conv;
14204 }
14205
14206 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14207         LDKDecodeError e_conv;
14208         e_conv.inner = (void*)(e & (~1));
14209         e_conv.is_owned = (e & 1) || (e == 0);
14210         e_conv = DecodeError_clone(&e_conv);
14211         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
14212         *ret_conv = CResult_AcceptChannelDecodeErrorZ_err(e_conv);
14213         return (uint64_t)ret_conv;
14214 }
14215
14216 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14217         if ((_res & 1) != 0) return;
14218         LDKCResult_AcceptChannelDecodeErrorZ _res_conv = *(LDKCResult_AcceptChannelDecodeErrorZ*)(((uint64_t)_res) & ~1);
14219         FREE((void*)_res);
14220         CResult_AcceptChannelDecodeErrorZ_free(_res_conv);
14221 }
14222
14223 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14224         LDKCResult_AcceptChannelDecodeErrorZ* orig_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(orig & ~1);
14225         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
14226         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(orig_conv);
14227         return (uint64_t)ret_conv;
14228 }
14229
14230 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14231         LDKAnnouncementSignatures o_conv;
14232         o_conv.inner = (void*)(o & (~1));
14233         o_conv.is_owned = (o & 1) || (o == 0);
14234         o_conv = AnnouncementSignatures_clone(&o_conv);
14235         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
14236         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_ok(o_conv);
14237         return (uint64_t)ret_conv;
14238 }
14239
14240 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14241         LDKDecodeError e_conv;
14242         e_conv.inner = (void*)(e & (~1));
14243         e_conv.is_owned = (e & 1) || (e == 0);
14244         e_conv = DecodeError_clone(&e_conv);
14245         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
14246         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_err(e_conv);
14247         return (uint64_t)ret_conv;
14248 }
14249
14250 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14251         if ((_res & 1) != 0) return;
14252         LDKCResult_AnnouncementSignaturesDecodeErrorZ _res_conv = *(LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
14253         FREE((void*)_res);
14254         CResult_AnnouncementSignaturesDecodeErrorZ_free(_res_conv);
14255 }
14256
14257 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14258         LDKCResult_AnnouncementSignaturesDecodeErrorZ* orig_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(orig & ~1);
14259         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
14260         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(orig_conv);
14261         return (uint64_t)ret_conv;
14262 }
14263
14264 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14265         LDKChannelReestablish o_conv;
14266         o_conv.inner = (void*)(o & (~1));
14267         o_conv.is_owned = (o & 1) || (o == 0);
14268         o_conv = ChannelReestablish_clone(&o_conv);
14269         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
14270         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_ok(o_conv);
14271         return (uint64_t)ret_conv;
14272 }
14273
14274 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14275         LDKDecodeError e_conv;
14276         e_conv.inner = (void*)(e & (~1));
14277         e_conv.is_owned = (e & 1) || (e == 0);
14278         e_conv = DecodeError_clone(&e_conv);
14279         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
14280         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_err(e_conv);
14281         return (uint64_t)ret_conv;
14282 }
14283
14284 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14285         if ((_res & 1) != 0) return;
14286         LDKCResult_ChannelReestablishDecodeErrorZ _res_conv = *(LDKCResult_ChannelReestablishDecodeErrorZ*)(((uint64_t)_res) & ~1);
14287         FREE((void*)_res);
14288         CResult_ChannelReestablishDecodeErrorZ_free(_res_conv);
14289 }
14290
14291 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14292         LDKCResult_ChannelReestablishDecodeErrorZ* orig_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(orig & ~1);
14293         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
14294         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(orig_conv);
14295         return (uint64_t)ret_conv;
14296 }
14297
14298 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14299         LDKClosingSigned o_conv;
14300         o_conv.inner = (void*)(o & (~1));
14301         o_conv.is_owned = (o & 1) || (o == 0);
14302         o_conv = ClosingSigned_clone(&o_conv);
14303         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
14304         *ret_conv = CResult_ClosingSignedDecodeErrorZ_ok(o_conv);
14305         return (uint64_t)ret_conv;
14306 }
14307
14308 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14309         LDKDecodeError e_conv;
14310         e_conv.inner = (void*)(e & (~1));
14311         e_conv.is_owned = (e & 1) || (e == 0);
14312         e_conv = DecodeError_clone(&e_conv);
14313         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
14314         *ret_conv = CResult_ClosingSignedDecodeErrorZ_err(e_conv);
14315         return (uint64_t)ret_conv;
14316 }
14317
14318 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14319         if ((_res & 1) != 0) return;
14320         LDKCResult_ClosingSignedDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedDecodeErrorZ*)(((uint64_t)_res) & ~1);
14321         FREE((void*)_res);
14322         CResult_ClosingSignedDecodeErrorZ_free(_res_conv);
14323 }
14324
14325 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14326         LDKCResult_ClosingSignedDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(orig & ~1);
14327         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
14328         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(orig_conv);
14329         return (uint64_t)ret_conv;
14330 }
14331
14332 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14333         LDKClosingSignedFeeRange o_conv;
14334         o_conv.inner = (void*)(o & (~1));
14335         o_conv.is_owned = (o & 1) || (o == 0);
14336         o_conv = ClosingSignedFeeRange_clone(&o_conv);
14337         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
14338         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_ok(o_conv);
14339         return (uint64_t)ret_conv;
14340 }
14341
14342 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14343         LDKDecodeError e_conv;
14344         e_conv.inner = (void*)(e & (~1));
14345         e_conv.is_owned = (e & 1) || (e == 0);
14346         e_conv = DecodeError_clone(&e_conv);
14347         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
14348         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_err(e_conv);
14349         return (uint64_t)ret_conv;
14350 }
14351
14352 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14353         if ((_res & 1) != 0) return;
14354         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(((uint64_t)_res) & ~1);
14355         FREE((void*)_res);
14356         CResult_ClosingSignedFeeRangeDecodeErrorZ_free(_res_conv);
14357 }
14358
14359 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14360         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(orig & ~1);
14361         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
14362         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(orig_conv);
14363         return (uint64_t)ret_conv;
14364 }
14365
14366 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14367         LDKCommitmentSigned o_conv;
14368         o_conv.inner = (void*)(o & (~1));
14369         o_conv.is_owned = (o & 1) || (o == 0);
14370         o_conv = CommitmentSigned_clone(&o_conv);
14371         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
14372         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_ok(o_conv);
14373         return (uint64_t)ret_conv;
14374 }
14375
14376 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14377         LDKDecodeError e_conv;
14378         e_conv.inner = (void*)(e & (~1));
14379         e_conv.is_owned = (e & 1) || (e == 0);
14380         e_conv = DecodeError_clone(&e_conv);
14381         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
14382         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_err(e_conv);
14383         return (uint64_t)ret_conv;
14384 }
14385
14386 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14387         if ((_res & 1) != 0) return;
14388         LDKCResult_CommitmentSignedDecodeErrorZ _res_conv = *(LDKCResult_CommitmentSignedDecodeErrorZ*)(((uint64_t)_res) & ~1);
14389         FREE((void*)_res);
14390         CResult_CommitmentSignedDecodeErrorZ_free(_res_conv);
14391 }
14392
14393 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14394         LDKCResult_CommitmentSignedDecodeErrorZ* orig_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(orig & ~1);
14395         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
14396         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(orig_conv);
14397         return (uint64_t)ret_conv;
14398 }
14399
14400 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14401         LDKFundingCreated o_conv;
14402         o_conv.inner = (void*)(o & (~1));
14403         o_conv.is_owned = (o & 1) || (o == 0);
14404         o_conv = FundingCreated_clone(&o_conv);
14405         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
14406         *ret_conv = CResult_FundingCreatedDecodeErrorZ_ok(o_conv);
14407         return (uint64_t)ret_conv;
14408 }
14409
14410 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14411         LDKDecodeError e_conv;
14412         e_conv.inner = (void*)(e & (~1));
14413         e_conv.is_owned = (e & 1) || (e == 0);
14414         e_conv = DecodeError_clone(&e_conv);
14415         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
14416         *ret_conv = CResult_FundingCreatedDecodeErrorZ_err(e_conv);
14417         return (uint64_t)ret_conv;
14418 }
14419
14420 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14421         if ((_res & 1) != 0) return;
14422         LDKCResult_FundingCreatedDecodeErrorZ _res_conv = *(LDKCResult_FundingCreatedDecodeErrorZ*)(((uint64_t)_res) & ~1);
14423         FREE((void*)_res);
14424         CResult_FundingCreatedDecodeErrorZ_free(_res_conv);
14425 }
14426
14427 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14428         LDKCResult_FundingCreatedDecodeErrorZ* orig_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(orig & ~1);
14429         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
14430         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(orig_conv);
14431         return (uint64_t)ret_conv;
14432 }
14433
14434 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14435         LDKFundingSigned o_conv;
14436         o_conv.inner = (void*)(o & (~1));
14437         o_conv.is_owned = (o & 1) || (o == 0);
14438         o_conv = FundingSigned_clone(&o_conv);
14439         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
14440         *ret_conv = CResult_FundingSignedDecodeErrorZ_ok(o_conv);
14441         return (uint64_t)ret_conv;
14442 }
14443
14444 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14445         LDKDecodeError e_conv;
14446         e_conv.inner = (void*)(e & (~1));
14447         e_conv.is_owned = (e & 1) || (e == 0);
14448         e_conv = DecodeError_clone(&e_conv);
14449         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
14450         *ret_conv = CResult_FundingSignedDecodeErrorZ_err(e_conv);
14451         return (uint64_t)ret_conv;
14452 }
14453
14454 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14455         if ((_res & 1) != 0) return;
14456         LDKCResult_FundingSignedDecodeErrorZ _res_conv = *(LDKCResult_FundingSignedDecodeErrorZ*)(((uint64_t)_res) & ~1);
14457         FREE((void*)_res);
14458         CResult_FundingSignedDecodeErrorZ_free(_res_conv);
14459 }
14460
14461 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14462         LDKCResult_FundingSignedDecodeErrorZ* orig_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(orig & ~1);
14463         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
14464         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(orig_conv);
14465         return (uint64_t)ret_conv;
14466 }
14467
14468 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14469         LDKFundingLocked o_conv;
14470         o_conv.inner = (void*)(o & (~1));
14471         o_conv.is_owned = (o & 1) || (o == 0);
14472         o_conv = FundingLocked_clone(&o_conv);
14473         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
14474         *ret_conv = CResult_FundingLockedDecodeErrorZ_ok(o_conv);
14475         return (uint64_t)ret_conv;
14476 }
14477
14478 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14479         LDKDecodeError e_conv;
14480         e_conv.inner = (void*)(e & (~1));
14481         e_conv.is_owned = (e & 1) || (e == 0);
14482         e_conv = DecodeError_clone(&e_conv);
14483         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
14484         *ret_conv = CResult_FundingLockedDecodeErrorZ_err(e_conv);
14485         return (uint64_t)ret_conv;
14486 }
14487
14488 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14489         if ((_res & 1) != 0) return;
14490         LDKCResult_FundingLockedDecodeErrorZ _res_conv = *(LDKCResult_FundingLockedDecodeErrorZ*)(((uint64_t)_res) & ~1);
14491         FREE((void*)_res);
14492         CResult_FundingLockedDecodeErrorZ_free(_res_conv);
14493 }
14494
14495 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14496         LDKCResult_FundingLockedDecodeErrorZ* orig_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(orig & ~1);
14497         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
14498         *ret_conv = CResult_FundingLockedDecodeErrorZ_clone(orig_conv);
14499         return (uint64_t)ret_conv;
14500 }
14501
14502 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14503         LDKInit o_conv;
14504         o_conv.inner = (void*)(o & (~1));
14505         o_conv.is_owned = (o & 1) || (o == 0);
14506         o_conv = Init_clone(&o_conv);
14507         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
14508         *ret_conv = CResult_InitDecodeErrorZ_ok(o_conv);
14509         return (uint64_t)ret_conv;
14510 }
14511
14512 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14513         LDKDecodeError e_conv;
14514         e_conv.inner = (void*)(e & (~1));
14515         e_conv.is_owned = (e & 1) || (e == 0);
14516         e_conv = DecodeError_clone(&e_conv);
14517         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
14518         *ret_conv = CResult_InitDecodeErrorZ_err(e_conv);
14519         return (uint64_t)ret_conv;
14520 }
14521
14522 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14523         if ((_res & 1) != 0) return;
14524         LDKCResult_InitDecodeErrorZ _res_conv = *(LDKCResult_InitDecodeErrorZ*)(((uint64_t)_res) & ~1);
14525         FREE((void*)_res);
14526         CResult_InitDecodeErrorZ_free(_res_conv);
14527 }
14528
14529 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14530         LDKCResult_InitDecodeErrorZ* orig_conv = (LDKCResult_InitDecodeErrorZ*)(orig & ~1);
14531         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
14532         *ret_conv = CResult_InitDecodeErrorZ_clone(orig_conv);
14533         return (uint64_t)ret_conv;
14534 }
14535
14536 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14537         LDKOpenChannel o_conv;
14538         o_conv.inner = (void*)(o & (~1));
14539         o_conv.is_owned = (o & 1) || (o == 0);
14540         o_conv = OpenChannel_clone(&o_conv);
14541         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
14542         *ret_conv = CResult_OpenChannelDecodeErrorZ_ok(o_conv);
14543         return (uint64_t)ret_conv;
14544 }
14545
14546 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14547         LDKDecodeError e_conv;
14548         e_conv.inner = (void*)(e & (~1));
14549         e_conv.is_owned = (e & 1) || (e == 0);
14550         e_conv = DecodeError_clone(&e_conv);
14551         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
14552         *ret_conv = CResult_OpenChannelDecodeErrorZ_err(e_conv);
14553         return (uint64_t)ret_conv;
14554 }
14555
14556 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14557         if ((_res & 1) != 0) return;
14558         LDKCResult_OpenChannelDecodeErrorZ _res_conv = *(LDKCResult_OpenChannelDecodeErrorZ*)(((uint64_t)_res) & ~1);
14559         FREE((void*)_res);
14560         CResult_OpenChannelDecodeErrorZ_free(_res_conv);
14561 }
14562
14563 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14564         LDKCResult_OpenChannelDecodeErrorZ* orig_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(orig & ~1);
14565         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
14566         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(orig_conv);
14567         return (uint64_t)ret_conv;
14568 }
14569
14570 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14571         LDKRevokeAndACK o_conv;
14572         o_conv.inner = (void*)(o & (~1));
14573         o_conv.is_owned = (o & 1) || (o == 0);
14574         o_conv = RevokeAndACK_clone(&o_conv);
14575         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
14576         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_ok(o_conv);
14577         return (uint64_t)ret_conv;
14578 }
14579
14580 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14581         LDKDecodeError e_conv;
14582         e_conv.inner = (void*)(e & (~1));
14583         e_conv.is_owned = (e & 1) || (e == 0);
14584         e_conv = DecodeError_clone(&e_conv);
14585         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
14586         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_err(e_conv);
14587         return (uint64_t)ret_conv;
14588 }
14589
14590 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14591         if ((_res & 1) != 0) return;
14592         LDKCResult_RevokeAndACKDecodeErrorZ _res_conv = *(LDKCResult_RevokeAndACKDecodeErrorZ*)(((uint64_t)_res) & ~1);
14593         FREE((void*)_res);
14594         CResult_RevokeAndACKDecodeErrorZ_free(_res_conv);
14595 }
14596
14597 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14598         LDKCResult_RevokeAndACKDecodeErrorZ* orig_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(orig & ~1);
14599         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
14600         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(orig_conv);
14601         return (uint64_t)ret_conv;
14602 }
14603
14604 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14605         LDKShutdown o_conv;
14606         o_conv.inner = (void*)(o & (~1));
14607         o_conv.is_owned = (o & 1) || (o == 0);
14608         o_conv = Shutdown_clone(&o_conv);
14609         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
14610         *ret_conv = CResult_ShutdownDecodeErrorZ_ok(o_conv);
14611         return (uint64_t)ret_conv;
14612 }
14613
14614 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14615         LDKDecodeError e_conv;
14616         e_conv.inner = (void*)(e & (~1));
14617         e_conv.is_owned = (e & 1) || (e == 0);
14618         e_conv = DecodeError_clone(&e_conv);
14619         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
14620         *ret_conv = CResult_ShutdownDecodeErrorZ_err(e_conv);
14621         return (uint64_t)ret_conv;
14622 }
14623
14624 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14625         if ((_res & 1) != 0) return;
14626         LDKCResult_ShutdownDecodeErrorZ _res_conv = *(LDKCResult_ShutdownDecodeErrorZ*)(((uint64_t)_res) & ~1);
14627         FREE((void*)_res);
14628         CResult_ShutdownDecodeErrorZ_free(_res_conv);
14629 }
14630
14631 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14632         LDKCResult_ShutdownDecodeErrorZ* orig_conv = (LDKCResult_ShutdownDecodeErrorZ*)(orig & ~1);
14633         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
14634         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(orig_conv);
14635         return (uint64_t)ret_conv;
14636 }
14637
14638 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14639         LDKUpdateFailHTLC o_conv;
14640         o_conv.inner = (void*)(o & (~1));
14641         o_conv.is_owned = (o & 1) || (o == 0);
14642         o_conv = UpdateFailHTLC_clone(&o_conv);
14643         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
14644         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_ok(o_conv);
14645         return (uint64_t)ret_conv;
14646 }
14647
14648 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14649         LDKDecodeError e_conv;
14650         e_conv.inner = (void*)(e & (~1));
14651         e_conv.is_owned = (e & 1) || (e == 0);
14652         e_conv = DecodeError_clone(&e_conv);
14653         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
14654         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_err(e_conv);
14655         return (uint64_t)ret_conv;
14656 }
14657
14658 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14659         if ((_res & 1) != 0) return;
14660         LDKCResult_UpdateFailHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
14661         FREE((void*)_res);
14662         CResult_UpdateFailHTLCDecodeErrorZ_free(_res_conv);
14663 }
14664
14665 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14666         LDKCResult_UpdateFailHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(orig & ~1);
14667         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
14668         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(orig_conv);
14669         return (uint64_t)ret_conv;
14670 }
14671
14672 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14673         LDKUpdateFailMalformedHTLC o_conv;
14674         o_conv.inner = (void*)(o & (~1));
14675         o_conv.is_owned = (o & 1) || (o == 0);
14676         o_conv = UpdateFailMalformedHTLC_clone(&o_conv);
14677         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
14678         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(o_conv);
14679         return (uint64_t)ret_conv;
14680 }
14681
14682 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14683         LDKDecodeError e_conv;
14684         e_conv.inner = (void*)(e & (~1));
14685         e_conv.is_owned = (e & 1) || (e == 0);
14686         e_conv = DecodeError_clone(&e_conv);
14687         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
14688         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(e_conv);
14689         return (uint64_t)ret_conv;
14690 }
14691
14692 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14693         if ((_res & 1) != 0) return;
14694         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
14695         FREE((void*)_res);
14696         CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(_res_conv);
14697 }
14698
14699 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14700         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(orig & ~1);
14701         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
14702         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(orig_conv);
14703         return (uint64_t)ret_conv;
14704 }
14705
14706 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14707         LDKUpdateFee o_conv;
14708         o_conv.inner = (void*)(o & (~1));
14709         o_conv.is_owned = (o & 1) || (o == 0);
14710         o_conv = UpdateFee_clone(&o_conv);
14711         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
14712         *ret_conv = CResult_UpdateFeeDecodeErrorZ_ok(o_conv);
14713         return (uint64_t)ret_conv;
14714 }
14715
14716 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14717         LDKDecodeError e_conv;
14718         e_conv.inner = (void*)(e & (~1));
14719         e_conv.is_owned = (e & 1) || (e == 0);
14720         e_conv = DecodeError_clone(&e_conv);
14721         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
14722         *ret_conv = CResult_UpdateFeeDecodeErrorZ_err(e_conv);
14723         return (uint64_t)ret_conv;
14724 }
14725
14726 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14727         if ((_res & 1) != 0) return;
14728         LDKCResult_UpdateFeeDecodeErrorZ _res_conv = *(LDKCResult_UpdateFeeDecodeErrorZ*)(((uint64_t)_res) & ~1);
14729         FREE((void*)_res);
14730         CResult_UpdateFeeDecodeErrorZ_free(_res_conv);
14731 }
14732
14733 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14734         LDKCResult_UpdateFeeDecodeErrorZ* orig_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(orig & ~1);
14735         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
14736         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(orig_conv);
14737         return (uint64_t)ret_conv;
14738 }
14739
14740 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14741         LDKUpdateFulfillHTLC o_conv;
14742         o_conv.inner = (void*)(o & (~1));
14743         o_conv.is_owned = (o & 1) || (o == 0);
14744         o_conv = UpdateFulfillHTLC_clone(&o_conv);
14745         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
14746         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_ok(o_conv);
14747         return (uint64_t)ret_conv;
14748 }
14749
14750 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14751         LDKDecodeError e_conv;
14752         e_conv.inner = (void*)(e & (~1));
14753         e_conv.is_owned = (e & 1) || (e == 0);
14754         e_conv = DecodeError_clone(&e_conv);
14755         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
14756         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_err(e_conv);
14757         return (uint64_t)ret_conv;
14758 }
14759
14760 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14761         if ((_res & 1) != 0) return;
14762         LDKCResult_UpdateFulfillHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
14763         FREE((void*)_res);
14764         CResult_UpdateFulfillHTLCDecodeErrorZ_free(_res_conv);
14765 }
14766
14767 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14768         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(orig & ~1);
14769         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
14770         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(orig_conv);
14771         return (uint64_t)ret_conv;
14772 }
14773
14774 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14775         LDKUpdateAddHTLC o_conv;
14776         o_conv.inner = (void*)(o & (~1));
14777         o_conv.is_owned = (o & 1) || (o == 0);
14778         o_conv = UpdateAddHTLC_clone(&o_conv);
14779         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
14780         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_ok(o_conv);
14781         return (uint64_t)ret_conv;
14782 }
14783
14784 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14785         LDKDecodeError e_conv;
14786         e_conv.inner = (void*)(e & (~1));
14787         e_conv.is_owned = (e & 1) || (e == 0);
14788         e_conv = DecodeError_clone(&e_conv);
14789         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
14790         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_err(e_conv);
14791         return (uint64_t)ret_conv;
14792 }
14793
14794 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14795         if ((_res & 1) != 0) return;
14796         LDKCResult_UpdateAddHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateAddHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
14797         FREE((void*)_res);
14798         CResult_UpdateAddHTLCDecodeErrorZ_free(_res_conv);
14799 }
14800
14801 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14802         LDKCResult_UpdateAddHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(orig & ~1);
14803         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
14804         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(orig_conv);
14805         return (uint64_t)ret_conv;
14806 }
14807
14808 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14809         LDKPing o_conv;
14810         o_conv.inner = (void*)(o & (~1));
14811         o_conv.is_owned = (o & 1) || (o == 0);
14812         o_conv = Ping_clone(&o_conv);
14813         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
14814         *ret_conv = CResult_PingDecodeErrorZ_ok(o_conv);
14815         return (uint64_t)ret_conv;
14816 }
14817
14818 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14819         LDKDecodeError e_conv;
14820         e_conv.inner = (void*)(e & (~1));
14821         e_conv.is_owned = (e & 1) || (e == 0);
14822         e_conv = DecodeError_clone(&e_conv);
14823         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
14824         *ret_conv = CResult_PingDecodeErrorZ_err(e_conv);
14825         return (uint64_t)ret_conv;
14826 }
14827
14828 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14829         if ((_res & 1) != 0) return;
14830         LDKCResult_PingDecodeErrorZ _res_conv = *(LDKCResult_PingDecodeErrorZ*)(((uint64_t)_res) & ~1);
14831         FREE((void*)_res);
14832         CResult_PingDecodeErrorZ_free(_res_conv);
14833 }
14834
14835 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14836         LDKCResult_PingDecodeErrorZ* orig_conv = (LDKCResult_PingDecodeErrorZ*)(orig & ~1);
14837         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
14838         *ret_conv = CResult_PingDecodeErrorZ_clone(orig_conv);
14839         return (uint64_t)ret_conv;
14840 }
14841
14842 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14843         LDKPong o_conv;
14844         o_conv.inner = (void*)(o & (~1));
14845         o_conv.is_owned = (o & 1) || (o == 0);
14846         o_conv = Pong_clone(&o_conv);
14847         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
14848         *ret_conv = CResult_PongDecodeErrorZ_ok(o_conv);
14849         return (uint64_t)ret_conv;
14850 }
14851
14852 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14853         LDKDecodeError e_conv;
14854         e_conv.inner = (void*)(e & (~1));
14855         e_conv.is_owned = (e & 1) || (e == 0);
14856         e_conv = DecodeError_clone(&e_conv);
14857         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
14858         *ret_conv = CResult_PongDecodeErrorZ_err(e_conv);
14859         return (uint64_t)ret_conv;
14860 }
14861
14862 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14863         if ((_res & 1) != 0) return;
14864         LDKCResult_PongDecodeErrorZ _res_conv = *(LDKCResult_PongDecodeErrorZ*)(((uint64_t)_res) & ~1);
14865         FREE((void*)_res);
14866         CResult_PongDecodeErrorZ_free(_res_conv);
14867 }
14868
14869 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14870         LDKCResult_PongDecodeErrorZ* orig_conv = (LDKCResult_PongDecodeErrorZ*)(orig & ~1);
14871         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
14872         *ret_conv = CResult_PongDecodeErrorZ_clone(orig_conv);
14873         return (uint64_t)ret_conv;
14874 }
14875
14876 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14877         LDKUnsignedChannelAnnouncement o_conv;
14878         o_conv.inner = (void*)(o & (~1));
14879         o_conv.is_owned = (o & 1) || (o == 0);
14880         o_conv = UnsignedChannelAnnouncement_clone(&o_conv);
14881         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
14882         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(o_conv);
14883         return (uint64_t)ret_conv;
14884 }
14885
14886 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14887         LDKDecodeError e_conv;
14888         e_conv.inner = (void*)(e & (~1));
14889         e_conv.is_owned = (e & 1) || (e == 0);
14890         e_conv = DecodeError_clone(&e_conv);
14891         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
14892         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(e_conv);
14893         return (uint64_t)ret_conv;
14894 }
14895
14896 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14897         if ((_res & 1) != 0) return;
14898         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
14899         FREE((void*)_res);
14900         CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(_res_conv);
14901 }
14902
14903 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14904         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(orig & ~1);
14905         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
14906         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(orig_conv);
14907         return (uint64_t)ret_conv;
14908 }
14909
14910 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14911         LDKChannelAnnouncement o_conv;
14912         o_conv.inner = (void*)(o & (~1));
14913         o_conv.is_owned = (o & 1) || (o == 0);
14914         o_conv = ChannelAnnouncement_clone(&o_conv);
14915         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
14916         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_ok(o_conv);
14917         return (uint64_t)ret_conv;
14918 }
14919
14920 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14921         LDKDecodeError e_conv;
14922         e_conv.inner = (void*)(e & (~1));
14923         e_conv.is_owned = (e & 1) || (e == 0);
14924         e_conv = DecodeError_clone(&e_conv);
14925         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
14926         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_err(e_conv);
14927         return (uint64_t)ret_conv;
14928 }
14929
14930 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14931         if ((_res & 1) != 0) return;
14932         LDKCResult_ChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_ChannelAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
14933         FREE((void*)_res);
14934         CResult_ChannelAnnouncementDecodeErrorZ_free(_res_conv);
14935 }
14936
14937 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14938         LDKCResult_ChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(orig & ~1);
14939         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
14940         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(orig_conv);
14941         return (uint64_t)ret_conv;
14942 }
14943
14944 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14945         LDKUnsignedChannelUpdate o_conv;
14946         o_conv.inner = (void*)(o & (~1));
14947         o_conv.is_owned = (o & 1) || (o == 0);
14948         o_conv = UnsignedChannelUpdate_clone(&o_conv);
14949         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
14950         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_ok(o_conv);
14951         return (uint64_t)ret_conv;
14952 }
14953
14954 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14955         LDKDecodeError e_conv;
14956         e_conv.inner = (void*)(e & (~1));
14957         e_conv.is_owned = (e & 1) || (e == 0);
14958         e_conv = DecodeError_clone(&e_conv);
14959         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
14960         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_err(e_conv);
14961         return (uint64_t)ret_conv;
14962 }
14963
14964 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14965         if ((_res & 1) != 0) return;
14966         LDKCResult_UnsignedChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
14967         FREE((void*)_res);
14968         CResult_UnsignedChannelUpdateDecodeErrorZ_free(_res_conv);
14969 }
14970
14971 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14972         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(orig & ~1);
14973         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
14974         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(orig_conv);
14975         return (uint64_t)ret_conv;
14976 }
14977
14978 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14979         LDKChannelUpdate o_conv;
14980         o_conv.inner = (void*)(o & (~1));
14981         o_conv.is_owned = (o & 1) || (o == 0);
14982         o_conv = ChannelUpdate_clone(&o_conv);
14983         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
14984         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_ok(o_conv);
14985         return (uint64_t)ret_conv;
14986 }
14987
14988 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14989         LDKDecodeError e_conv;
14990         e_conv.inner = (void*)(e & (~1));
14991         e_conv.is_owned = (e & 1) || (e == 0);
14992         e_conv = DecodeError_clone(&e_conv);
14993         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
14994         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_err(e_conv);
14995         return (uint64_t)ret_conv;
14996 }
14997
14998 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14999         if ((_res & 1) != 0) return;
15000         LDKCResult_ChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
15001         FREE((void*)_res);
15002         CResult_ChannelUpdateDecodeErrorZ_free(_res_conv);
15003 }
15004
15005 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15006         LDKCResult_ChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(orig & ~1);
15007         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
15008         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(orig_conv);
15009         return (uint64_t)ret_conv;
15010 }
15011
15012 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15013         LDKErrorMessage o_conv;
15014         o_conv.inner = (void*)(o & (~1));
15015         o_conv.is_owned = (o & 1) || (o == 0);
15016         o_conv = ErrorMessage_clone(&o_conv);
15017         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
15018         *ret_conv = CResult_ErrorMessageDecodeErrorZ_ok(o_conv);
15019         return (uint64_t)ret_conv;
15020 }
15021
15022 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15023         LDKDecodeError e_conv;
15024         e_conv.inner = (void*)(e & (~1));
15025         e_conv.is_owned = (e & 1) || (e == 0);
15026         e_conv = DecodeError_clone(&e_conv);
15027         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
15028         *ret_conv = CResult_ErrorMessageDecodeErrorZ_err(e_conv);
15029         return (uint64_t)ret_conv;
15030 }
15031
15032 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15033         if ((_res & 1) != 0) return;
15034         LDKCResult_ErrorMessageDecodeErrorZ _res_conv = *(LDKCResult_ErrorMessageDecodeErrorZ*)(((uint64_t)_res) & ~1);
15035         FREE((void*)_res);
15036         CResult_ErrorMessageDecodeErrorZ_free(_res_conv);
15037 }
15038
15039 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15040         LDKCResult_ErrorMessageDecodeErrorZ* orig_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(orig & ~1);
15041         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
15042         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(orig_conv);
15043         return (uint64_t)ret_conv;
15044 }
15045
15046 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15047         LDKUnsignedNodeAnnouncement o_conv;
15048         o_conv.inner = (void*)(o & (~1));
15049         o_conv.is_owned = (o & 1) || (o == 0);
15050         o_conv = UnsignedNodeAnnouncement_clone(&o_conv);
15051         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
15052         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(o_conv);
15053         return (uint64_t)ret_conv;
15054 }
15055
15056 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15057         LDKDecodeError e_conv;
15058         e_conv.inner = (void*)(e & (~1));
15059         e_conv.is_owned = (e & 1) || (e == 0);
15060         e_conv = DecodeError_clone(&e_conv);
15061         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
15062         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(e_conv);
15063         return (uint64_t)ret_conv;
15064 }
15065
15066 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15067         if ((_res & 1) != 0) return;
15068         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
15069         FREE((void*)_res);
15070         CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(_res_conv);
15071 }
15072
15073 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15074         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(orig & ~1);
15075         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
15076         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(orig_conv);
15077         return (uint64_t)ret_conv;
15078 }
15079
15080 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15081         LDKNodeAnnouncement o_conv;
15082         o_conv.inner = (void*)(o & (~1));
15083         o_conv.is_owned = (o & 1) || (o == 0);
15084         o_conv = NodeAnnouncement_clone(&o_conv);
15085         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
15086         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_ok(o_conv);
15087         return (uint64_t)ret_conv;
15088 }
15089
15090 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15091         LDKDecodeError e_conv;
15092         e_conv.inner = (void*)(e & (~1));
15093         e_conv.is_owned = (e & 1) || (e == 0);
15094         e_conv = DecodeError_clone(&e_conv);
15095         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
15096         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_err(e_conv);
15097         return (uint64_t)ret_conv;
15098 }
15099
15100 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15101         if ((_res & 1) != 0) return;
15102         LDKCResult_NodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
15103         FREE((void*)_res);
15104         CResult_NodeAnnouncementDecodeErrorZ_free(_res_conv);
15105 }
15106
15107 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15108         LDKCResult_NodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(orig & ~1);
15109         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
15110         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(orig_conv);
15111         return (uint64_t)ret_conv;
15112 }
15113
15114 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15115         LDKQueryShortChannelIds o_conv;
15116         o_conv.inner = (void*)(o & (~1));
15117         o_conv.is_owned = (o & 1) || (o == 0);
15118         o_conv = QueryShortChannelIds_clone(&o_conv);
15119         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
15120         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_ok(o_conv);
15121         return (uint64_t)ret_conv;
15122 }
15123
15124 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15125         LDKDecodeError e_conv;
15126         e_conv.inner = (void*)(e & (~1));
15127         e_conv.is_owned = (e & 1) || (e == 0);
15128         e_conv = DecodeError_clone(&e_conv);
15129         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
15130         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_err(e_conv);
15131         return (uint64_t)ret_conv;
15132 }
15133
15134 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15135         if ((_res & 1) != 0) return;
15136         LDKCResult_QueryShortChannelIdsDecodeErrorZ _res_conv = *(LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(((uint64_t)_res) & ~1);
15137         FREE((void*)_res);
15138         CResult_QueryShortChannelIdsDecodeErrorZ_free(_res_conv);
15139 }
15140
15141 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15142         LDKCResult_QueryShortChannelIdsDecodeErrorZ* orig_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(orig & ~1);
15143         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
15144         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(orig_conv);
15145         return (uint64_t)ret_conv;
15146 }
15147
15148 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15149         LDKReplyShortChannelIdsEnd o_conv;
15150         o_conv.inner = (void*)(o & (~1));
15151         o_conv.is_owned = (o & 1) || (o == 0);
15152         o_conv = ReplyShortChannelIdsEnd_clone(&o_conv);
15153         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
15154         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(o_conv);
15155         return (uint64_t)ret_conv;
15156 }
15157
15158 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15159         LDKDecodeError e_conv;
15160         e_conv.inner = (void*)(e & (~1));
15161         e_conv.is_owned = (e & 1) || (e == 0);
15162         e_conv = DecodeError_clone(&e_conv);
15163         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
15164         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(e_conv);
15165         return (uint64_t)ret_conv;
15166 }
15167
15168 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15169         if ((_res & 1) != 0) return;
15170         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ _res_conv = *(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(((uint64_t)_res) & ~1);
15171         FREE((void*)_res);
15172         CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(_res_conv);
15173 }
15174
15175 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15176         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* orig_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(orig & ~1);
15177         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
15178         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(orig_conv);
15179         return (uint64_t)ret_conv;
15180 }
15181
15182 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15183         LDKQueryChannelRange o_conv;
15184         o_conv.inner = (void*)(o & (~1));
15185         o_conv.is_owned = (o & 1) || (o == 0);
15186         o_conv = QueryChannelRange_clone(&o_conv);
15187         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
15188         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_ok(o_conv);
15189         return (uint64_t)ret_conv;
15190 }
15191
15192 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15193         LDKDecodeError e_conv;
15194         e_conv.inner = (void*)(e & (~1));
15195         e_conv.is_owned = (e & 1) || (e == 0);
15196         e_conv = DecodeError_clone(&e_conv);
15197         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
15198         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_err(e_conv);
15199         return (uint64_t)ret_conv;
15200 }
15201
15202 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15203         if ((_res & 1) != 0) return;
15204         LDKCResult_QueryChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_QueryChannelRangeDecodeErrorZ*)(((uint64_t)_res) & ~1);
15205         FREE((void*)_res);
15206         CResult_QueryChannelRangeDecodeErrorZ_free(_res_conv);
15207 }
15208
15209 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15210         LDKCResult_QueryChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(orig & ~1);
15211         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
15212         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(orig_conv);
15213         return (uint64_t)ret_conv;
15214 }
15215
15216 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15217         LDKReplyChannelRange o_conv;
15218         o_conv.inner = (void*)(o & (~1));
15219         o_conv.is_owned = (o & 1) || (o == 0);
15220         o_conv = ReplyChannelRange_clone(&o_conv);
15221         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
15222         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_ok(o_conv);
15223         return (uint64_t)ret_conv;
15224 }
15225
15226 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15227         LDKDecodeError e_conv;
15228         e_conv.inner = (void*)(e & (~1));
15229         e_conv.is_owned = (e & 1) || (e == 0);
15230         e_conv = DecodeError_clone(&e_conv);
15231         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
15232         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_err(e_conv);
15233         return (uint64_t)ret_conv;
15234 }
15235
15236 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15237         if ((_res & 1) != 0) return;
15238         LDKCResult_ReplyChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_ReplyChannelRangeDecodeErrorZ*)(((uint64_t)_res) & ~1);
15239         FREE((void*)_res);
15240         CResult_ReplyChannelRangeDecodeErrorZ_free(_res_conv);
15241 }
15242
15243 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15244         LDKCResult_ReplyChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(orig & ~1);
15245         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
15246         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(orig_conv);
15247         return (uint64_t)ret_conv;
15248 }
15249
15250 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15251         LDKGossipTimestampFilter o_conv;
15252         o_conv.inner = (void*)(o & (~1));
15253         o_conv.is_owned = (o & 1) || (o == 0);
15254         o_conv = GossipTimestampFilter_clone(&o_conv);
15255         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
15256         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_ok(o_conv);
15257         return (uint64_t)ret_conv;
15258 }
15259
15260 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15261         LDKDecodeError e_conv;
15262         e_conv.inner = (void*)(e & (~1));
15263         e_conv.is_owned = (e & 1) || (e == 0);
15264         e_conv = DecodeError_clone(&e_conv);
15265         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
15266         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_err(e_conv);
15267         return (uint64_t)ret_conv;
15268 }
15269
15270 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15271         if ((_res & 1) != 0) return;
15272         LDKCResult_GossipTimestampFilterDecodeErrorZ _res_conv = *(LDKCResult_GossipTimestampFilterDecodeErrorZ*)(((uint64_t)_res) & ~1);
15273         FREE((void*)_res);
15274         CResult_GossipTimestampFilterDecodeErrorZ_free(_res_conv);
15275 }
15276
15277 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15278         LDKCResult_GossipTimestampFilterDecodeErrorZ* orig_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(orig & ~1);
15279         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
15280         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(orig_conv);
15281         return (uint64_t)ret_conv;
15282 }
15283
15284 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15285         LDKInvoice o_conv;
15286         o_conv.inner = (void*)(o & (~1));
15287         o_conv.is_owned = (o & 1) || (o == 0);
15288         o_conv = Invoice_clone(&o_conv);
15289         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
15290         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_ok(o_conv);
15291         return (uint64_t)ret_conv;
15292 }
15293
15294 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15295         LDKSignOrCreationError e_conv = *(LDKSignOrCreationError*)(((uint64_t)e) & ~1);
15296         e_conv = SignOrCreationError_clone((LDKSignOrCreationError*)(((uint64_t)e) & ~1));
15297         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
15298         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_err(e_conv);
15299         return (uint64_t)ret_conv;
15300 }
15301
15302 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15303         if ((_res & 1) != 0) return;
15304         LDKCResult_InvoiceSignOrCreationErrorZ _res_conv = *(LDKCResult_InvoiceSignOrCreationErrorZ*)(((uint64_t)_res) & ~1);
15305         FREE((void*)_res);
15306         CResult_InvoiceSignOrCreationErrorZ_free(_res_conv);
15307 }
15308
15309 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15310         LDKCResult_InvoiceSignOrCreationErrorZ* orig_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(orig & ~1);
15311         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
15312         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone(orig_conv);
15313         return (uint64_t)ret_conv;
15314 }
15315
15316 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1FilterZ_1some(JNIEnv *env, jclass clz, int64_t o) {
15317         LDKFilter o_conv = *(LDKFilter*)(((uint64_t)o) & ~1);
15318         if (o_conv.free == LDKFilter_JCalls_free) {
15319                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
15320                 LDKFilter_JCalls_cloned(&o_conv);
15321         }
15322         LDKCOption_FilterZ *ret_copy = MALLOC(sizeof(LDKCOption_FilterZ), "LDKCOption_FilterZ");
15323         *ret_copy = COption_FilterZ_some(o_conv);
15324         uint64_t ret_ref = (uint64_t)ret_copy;
15325         return ret_ref;
15326 }
15327
15328 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1FilterZ_1none(JNIEnv *env, jclass clz) {
15329         LDKCOption_FilterZ *ret_copy = MALLOC(sizeof(LDKCOption_FilterZ), "LDKCOption_FilterZ");
15330         *ret_copy = COption_FilterZ_none();
15331         uint64_t ret_ref = (uint64_t)ret_copy;
15332         return ret_ref;
15333 }
15334
15335 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1FilterZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15336         if ((_res & 1) != 0) return;
15337         LDKCOption_FilterZ _res_conv = *(LDKCOption_FilterZ*)(((uint64_t)_res) & ~1);
15338         FREE((void*)_res);
15339         COption_FilterZ_free(_res_conv);
15340 }
15341
15342 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15343         LDKLockedChannelMonitor o_conv;
15344         o_conv.inner = (void*)(o & (~1));
15345         o_conv.is_owned = (o & 1) || (o == 0);
15346         // Warning: we need a move here but no clone is available for LDKLockedChannelMonitor
15347         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
15348         *ret_conv = CResult_LockedChannelMonitorNoneZ_ok(o_conv);
15349         return (uint64_t)ret_conv;
15350 }
15351
15352 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1err(JNIEnv *env, jclass clz) {
15353         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
15354         *ret_conv = CResult_LockedChannelMonitorNoneZ_err();
15355         return (uint64_t)ret_conv;
15356 }
15357
15358 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15359         if ((_res & 1) != 0) return;
15360         LDKCResult_LockedChannelMonitorNoneZ _res_conv = *(LDKCResult_LockedChannelMonitorNoneZ*)(((uint64_t)_res) & ~1);
15361         FREE((void*)_res);
15362         CResult_LockedChannelMonitorNoneZ_free(_res_conv);
15363 }
15364
15365 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1OutPointZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
15366         LDKCVec_OutPointZ _res_constr;
15367         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
15368         if (_res_constr.datalen > 0)
15369                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKOutPoint), "LDKCVec_OutPointZ Elements");
15370         else
15371                 _res_constr.data = NULL;
15372         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
15373         for (size_t k = 0; k < _res_constr.datalen; k++) {
15374                 int64_t _res_conv_10 = _res_vals[k];
15375                 LDKOutPoint _res_conv_10_conv;
15376                 _res_conv_10_conv.inner = (void*)(_res_conv_10 & (~1));
15377                 _res_conv_10_conv.is_owned = (_res_conv_10 & 1) || (_res_conv_10 == 0);
15378                 _res_constr.data[k] = _res_conv_10_conv;
15379         }
15380         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
15381         CVec_OutPointZ_free(_res_constr);
15382 }
15383
15384 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
15385         if ((this_ptr & 1) != 0) return;
15386         LDKPaymentPurpose this_ptr_conv = *(LDKPaymentPurpose*)(((uint64_t)this_ptr) & ~1);
15387         FREE((void*)this_ptr);
15388         PaymentPurpose_free(this_ptr_conv);
15389 }
15390
15391 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15392         LDKPaymentPurpose* orig_conv = (LDKPaymentPurpose*)orig;
15393         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
15394         *ret_copy = PaymentPurpose_clone(orig_conv);
15395         uint64_t ret_ref = (uint64_t)ret_copy;
15396         return ret_ref;
15397 }
15398
15399 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) {
15400         LDKThirtyTwoBytes payment_preimage_ref;
15401         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
15402         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
15403         LDKThirtyTwoBytes payment_secret_ref;
15404         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
15405         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
15406         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
15407         *ret_copy = PaymentPurpose_invoice_payment(payment_preimage_ref, payment_secret_ref, user_payment_id);
15408         uint64_t ret_ref = (uint64_t)ret_copy;
15409         return ret_ref;
15410 }
15411
15412 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1spontaneous_1payment(JNIEnv *env, jclass clz, int8_tArray a) {
15413         LDKThirtyTwoBytes a_ref;
15414         CHECK((*env)->GetArrayLength(env, a) == 32);
15415         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
15416         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
15417         *ret_copy = PaymentPurpose_spontaneous_payment(a_ref);
15418         uint64_t ret_ref = (uint64_t)ret_copy;
15419         return ret_ref;
15420 }
15421
15422 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosureReason_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
15423         if ((this_ptr & 1) != 0) return;
15424         LDKClosureReason this_ptr_conv = *(LDKClosureReason*)(((uint64_t)this_ptr) & ~1);
15425         FREE((void*)this_ptr);
15426         ClosureReason_free(this_ptr_conv);
15427 }
15428
15429 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15430         LDKClosureReason* orig_conv = (LDKClosureReason*)orig;
15431         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
15432         *ret_copy = ClosureReason_clone(orig_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_ClosureReason_1counterparty_1force_1closed(JNIEnv *env, jclass clz, jstring peer_msg) {
15438         LDKStr peer_msg_conv = java_to_owned_str(env, peer_msg);
15439         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
15440         *ret_copy = ClosureReason_counterparty_force_closed(peer_msg_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_ClosureReason_1holder_1force_1closed(JNIEnv *env, jclass clz) {
15446         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
15447         *ret_copy = ClosureReason_holder_force_closed();
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_ClosureReason_1cooperative_1closure(JNIEnv *env, jclass clz) {
15453         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
15454         *ret_copy = ClosureReason_cooperative_closure();
15455         uint64_t ret_ref = (uint64_t)ret_copy;
15456         return ret_ref;
15457 }
15458
15459 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1commitment_1tx_1confirmed(JNIEnv *env, jclass clz) {
15460         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
15461         *ret_copy = ClosureReason_commitment_tx_confirmed();
15462         uint64_t ret_ref = (uint64_t)ret_copy;
15463         return ret_ref;
15464 }
15465
15466 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1processing_1error(JNIEnv *env, jclass clz, jstring err) {
15467         LDKStr err_conv = java_to_owned_str(env, err);
15468         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
15469         *ret_copy = ClosureReason_processing_error(err_conv);
15470         uint64_t ret_ref = (uint64_t)ret_copy;
15471         return ret_ref;
15472 }
15473
15474 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1disconnected_1peer(JNIEnv *env, jclass clz) {
15475         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
15476         *ret_copy = ClosureReason_disconnected_peer();
15477         uint64_t ret_ref = (uint64_t)ret_copy;
15478         return ret_ref;
15479 }
15480
15481 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1outdated_1channel_1manager(JNIEnv *env, jclass clz) {
15482         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
15483         *ret_copy = ClosureReason_outdated_channel_manager();
15484         uint64_t ret_ref = (uint64_t)ret_copy;
15485         return ret_ref;
15486 }
15487
15488 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosureReason_1write(JNIEnv *env, jclass clz, int64_t obj) {
15489         LDKClosureReason* obj_conv = (LDKClosureReason*)obj;
15490         LDKCVec_u8Z ret_var = ClosureReason_write(obj_conv);
15491         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
15492         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
15493         CVec_u8Z_free(ret_var);
15494         return ret_arr;
15495 }
15496
15497 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Event_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
15498         if ((this_ptr & 1) != 0) return;
15499         LDKEvent this_ptr_conv = *(LDKEvent*)(((uint64_t)this_ptr) & ~1);
15500         FREE((void*)this_ptr);
15501         Event_free(this_ptr_conv);
15502 }
15503
15504 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15505         LDKEvent* orig_conv = (LDKEvent*)orig;
15506         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
15507         *ret_copy = Event_clone(orig_conv);
15508         uint64_t ret_ref = (uint64_t)ret_copy;
15509         return ret_ref;
15510 }
15511
15512 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) {
15513         LDKThirtyTwoBytes temporary_channel_id_ref;
15514         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
15515         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_ref.data);
15516         LDKCVec_u8Z output_script_ref;
15517         output_script_ref.datalen = (*env)->GetArrayLength(env, output_script);
15518         output_script_ref.data = MALLOC(output_script_ref.datalen, "LDKCVec_u8Z Bytes");
15519         (*env)->GetByteArrayRegion(env, output_script, 0, output_script_ref.datalen, output_script_ref.data);
15520         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
15521         *ret_copy = Event_funding_generation_ready(temporary_channel_id_ref, channel_value_satoshis, output_script_ref, user_channel_id);
15522         uint64_t ret_ref = (uint64_t)ret_copy;
15523         return ret_ref;
15524 }
15525
15526 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) {
15527         LDKThirtyTwoBytes payment_hash_ref;
15528         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
15529         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
15530         LDKPaymentPurpose purpose_conv = *(LDKPaymentPurpose*)(((uint64_t)purpose) & ~1);
15531         purpose_conv = PaymentPurpose_clone((LDKPaymentPurpose*)(((uint64_t)purpose) & ~1));
15532         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
15533         *ret_copy = Event_payment_received(payment_hash_ref, amt, purpose_conv);
15534         uint64_t ret_ref = (uint64_t)ret_copy;
15535         return ret_ref;
15536 }
15537
15538 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1payment_1sent(JNIEnv *env, jclass clz, int8_tArray payment_preimage, int8_tArray payment_hash) {
15539         LDKThirtyTwoBytes payment_preimage_ref;
15540         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
15541         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
15542         LDKThirtyTwoBytes payment_hash_ref;
15543         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
15544         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
15545         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
15546         *ret_copy = Event_payment_sent(payment_preimage_ref, payment_hash_ref);
15547         uint64_t ret_ref = (uint64_t)ret_copy;
15548         return ret_ref;
15549 }
15550
15551 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, int64_t short_channel_id) {
15552         LDKThirtyTwoBytes payment_hash_ref;
15553         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
15554         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
15555         LDKCOption_NetworkUpdateZ network_update_conv = *(LDKCOption_NetworkUpdateZ*)(((uint64_t)network_update) & ~1);
15556         network_update_conv = COption_NetworkUpdateZ_clone((LDKCOption_NetworkUpdateZ*)(((uint64_t)network_update) & ~1));
15557         LDKCVec_RouteHopZ path_constr;
15558         path_constr.datalen = (*env)->GetArrayLength(env, path);
15559         if (path_constr.datalen > 0)
15560                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
15561         else
15562                 path_constr.data = NULL;
15563         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
15564         for (size_t k = 0; k < path_constr.datalen; k++) {
15565                 int64_t path_conv_10 = path_vals[k];
15566                 LDKRouteHop path_conv_10_conv;
15567                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
15568                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
15569                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
15570                 path_constr.data[k] = path_conv_10_conv;
15571         }
15572         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
15573         LDKCOption_u64Z short_channel_id_conv = *(LDKCOption_u64Z*)(((uint64_t)short_channel_id) & ~1);
15574         short_channel_id_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)short_channel_id) & ~1));
15575         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
15576         *ret_copy = Event_payment_path_failed(payment_hash_ref, rejected_by_dest, network_update_conv, all_paths_failed, path_constr, short_channel_id_conv);
15577         uint64_t ret_ref = (uint64_t)ret_copy;
15578         return ret_ref;
15579 }
15580
15581 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1pending_1htlcs_1forwardable(JNIEnv *env, jclass clz, int64_t time_forwardable) {
15582         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
15583         *ret_copy = Event_pending_htlcs_forwardable(time_forwardable);
15584         uint64_t ret_ref = (uint64_t)ret_copy;
15585         return ret_ref;
15586 }
15587
15588 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1spendable_1outputs(JNIEnv *env, jclass clz, int64_tArray outputs) {
15589         LDKCVec_SpendableOutputDescriptorZ outputs_constr;
15590         outputs_constr.datalen = (*env)->GetArrayLength(env, outputs);
15591         if (outputs_constr.datalen > 0)
15592                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
15593         else
15594                 outputs_constr.data = NULL;
15595         int64_t* outputs_vals = (*env)->GetLongArrayElements (env, outputs, NULL);
15596         for (size_t b = 0; b < outputs_constr.datalen; b++) {
15597                 int64_t outputs_conv_27 = outputs_vals[b];
15598                 LDKSpendableOutputDescriptor outputs_conv_27_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)outputs_conv_27) & ~1);
15599                 outputs_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uint64_t)outputs_conv_27) & ~1));
15600                 outputs_constr.data[b] = outputs_conv_27_conv;
15601         }
15602         (*env)->ReleaseLongArrayElements(env, outputs, outputs_vals, 0);
15603         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
15604         *ret_copy = Event_spendable_outputs(outputs_constr);
15605         uint64_t ret_ref = (uint64_t)ret_copy;
15606         return ret_ref;
15607 }
15608
15609 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) {
15610         LDKCOption_u64Z fee_earned_msat_conv = *(LDKCOption_u64Z*)(((uint64_t)fee_earned_msat) & ~1);
15611         fee_earned_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)fee_earned_msat) & ~1));
15612         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
15613         *ret_copy = Event_payment_forwarded(fee_earned_msat_conv, claim_from_onchain_tx);
15614         uint64_t ret_ref = (uint64_t)ret_copy;
15615         return ret_ref;
15616 }
15617
15618 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1channel_1closed(JNIEnv *env, jclass clz, int8_tArray channel_id, int64_t user_channel_id, int64_t reason) {
15619         LDKThirtyTwoBytes channel_id_ref;
15620         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
15621         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_ref.data);
15622         LDKClosureReason reason_conv = *(LDKClosureReason*)(((uint64_t)reason) & ~1);
15623         reason_conv = ClosureReason_clone((LDKClosureReason*)(((uint64_t)reason) & ~1));
15624         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
15625         *ret_copy = Event_channel_closed(channel_id_ref, user_channel_id, reason_conv);
15626         uint64_t ret_ref = (uint64_t)ret_copy;
15627         return ret_ref;
15628 }
15629
15630 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1discard_1funding(JNIEnv *env, jclass clz, int8_tArray channel_id, int8_tArray transaction) {
15631         LDKThirtyTwoBytes channel_id_ref;
15632         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
15633         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_ref.data);
15634         LDKTransaction transaction_ref;
15635         transaction_ref.datalen = (*env)->GetArrayLength(env, transaction);
15636         transaction_ref.data = MALLOC(transaction_ref.datalen, "LDKTransaction Bytes");
15637         (*env)->GetByteArrayRegion(env, transaction, 0, transaction_ref.datalen, transaction_ref.data);
15638         transaction_ref.data_is_owned = true;
15639         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
15640         *ret_copy = Event_discard_funding(channel_id_ref, transaction_ref);
15641         uint64_t ret_ref = (uint64_t)ret_copy;
15642         return ret_ref;
15643 }
15644
15645 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Event_1write(JNIEnv *env, jclass clz, int64_t obj) {
15646         LDKEvent* obj_conv = (LDKEvent*)obj;
15647         LDKCVec_u8Z ret_var = Event_write(obj_conv);
15648         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
15649         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
15650         CVec_u8Z_free(ret_var);
15651         return ret_arr;
15652 }
15653
15654 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
15655         if ((this_ptr & 1) != 0) return;
15656         LDKMessageSendEvent this_ptr_conv = *(LDKMessageSendEvent*)(((uint64_t)this_ptr) & ~1);
15657         FREE((void*)this_ptr);
15658         MessageSendEvent_free(this_ptr_conv);
15659 }
15660
15661 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15662         LDKMessageSendEvent* orig_conv = (LDKMessageSendEvent*)orig;
15663         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
15664         *ret_copy = MessageSendEvent_clone(orig_conv);
15665         uint64_t ret_ref = (uint64_t)ret_copy;
15666         return ret_ref;
15667 }
15668
15669 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1accept_1channel(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
15670         LDKPublicKey node_id_ref;
15671         CHECK((*env)->GetArrayLength(env, node_id) == 33);
15672         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
15673         LDKAcceptChannel msg_conv;
15674         msg_conv.inner = (void*)(msg & (~1));
15675         msg_conv.is_owned = (msg & 1) || (msg == 0);
15676         msg_conv = AcceptChannel_clone(&msg_conv);
15677         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
15678         *ret_copy = MessageSendEvent_send_accept_channel(node_id_ref, msg_conv);
15679         uint64_t ret_ref = (uint64_t)ret_copy;
15680         return ret_ref;
15681 }
15682
15683 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1open_1channel(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
15684         LDKPublicKey node_id_ref;
15685         CHECK((*env)->GetArrayLength(env, node_id) == 33);
15686         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
15687         LDKOpenChannel msg_conv;
15688         msg_conv.inner = (void*)(msg & (~1));
15689         msg_conv.is_owned = (msg & 1) || (msg == 0);
15690         msg_conv = OpenChannel_clone(&msg_conv);
15691         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
15692         *ret_copy = MessageSendEvent_send_open_channel(node_id_ref, msg_conv);
15693         uint64_t ret_ref = (uint64_t)ret_copy;
15694         return ret_ref;
15695 }
15696
15697 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1funding_1created(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
15698         LDKPublicKey node_id_ref;
15699         CHECK((*env)->GetArrayLength(env, node_id) == 33);
15700         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
15701         LDKFundingCreated msg_conv;
15702         msg_conv.inner = (void*)(msg & (~1));
15703         msg_conv.is_owned = (msg & 1) || (msg == 0);
15704         msg_conv = FundingCreated_clone(&msg_conv);
15705         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
15706         *ret_copy = MessageSendEvent_send_funding_created(node_id_ref, msg_conv);
15707         uint64_t ret_ref = (uint64_t)ret_copy;
15708         return ret_ref;
15709 }
15710
15711 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1funding_1signed(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
15712         LDKPublicKey node_id_ref;
15713         CHECK((*env)->GetArrayLength(env, node_id) == 33);
15714         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
15715         LDKFundingSigned msg_conv;
15716         msg_conv.inner = (void*)(msg & (~1));
15717         msg_conv.is_owned = (msg & 1) || (msg == 0);
15718         msg_conv = FundingSigned_clone(&msg_conv);
15719         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
15720         *ret_copy = MessageSendEvent_send_funding_signed(node_id_ref, msg_conv);
15721         uint64_t ret_ref = (uint64_t)ret_copy;
15722         return ret_ref;
15723 }
15724
15725 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1funding_1locked(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
15726         LDKPublicKey node_id_ref;
15727         CHECK((*env)->GetArrayLength(env, node_id) == 33);
15728         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
15729         LDKFundingLocked msg_conv;
15730         msg_conv.inner = (void*)(msg & (~1));
15731         msg_conv.is_owned = (msg & 1) || (msg == 0);
15732         msg_conv = FundingLocked_clone(&msg_conv);
15733         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
15734         *ret_copy = MessageSendEvent_send_funding_locked(node_id_ref, msg_conv);
15735         uint64_t ret_ref = (uint64_t)ret_copy;
15736         return ret_ref;
15737 }
15738
15739 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1announcement_1signatures(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
15740         LDKPublicKey node_id_ref;
15741         CHECK((*env)->GetArrayLength(env, node_id) == 33);
15742         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
15743         LDKAnnouncementSignatures msg_conv;
15744         msg_conv.inner = (void*)(msg & (~1));
15745         msg_conv.is_owned = (msg & 1) || (msg == 0);
15746         msg_conv = AnnouncementSignatures_clone(&msg_conv);
15747         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
15748         *ret_copy = MessageSendEvent_send_announcement_signatures(node_id_ref, msg_conv);
15749         uint64_t ret_ref = (uint64_t)ret_copy;
15750         return ret_ref;
15751 }
15752
15753 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1update_1htlcs(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t updates) {
15754         LDKPublicKey node_id_ref;
15755         CHECK((*env)->GetArrayLength(env, node_id) == 33);
15756         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
15757         LDKCommitmentUpdate updates_conv;
15758         updates_conv.inner = (void*)(updates & (~1));
15759         updates_conv.is_owned = (updates & 1) || (updates == 0);
15760         updates_conv = CommitmentUpdate_clone(&updates_conv);
15761         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
15762         *ret_copy = MessageSendEvent_update_htlcs(node_id_ref, updates_conv);
15763         uint64_t ret_ref = (uint64_t)ret_copy;
15764         return ret_ref;
15765 }
15766
15767 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) {
15768         LDKPublicKey node_id_ref;
15769         CHECK((*env)->GetArrayLength(env, node_id) == 33);
15770         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
15771         LDKRevokeAndACK msg_conv;
15772         msg_conv.inner = (void*)(msg & (~1));
15773         msg_conv.is_owned = (msg & 1) || (msg == 0);
15774         msg_conv = RevokeAndACK_clone(&msg_conv);
15775         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
15776         *ret_copy = MessageSendEvent_send_revoke_and_ack(node_id_ref, msg_conv);
15777         uint64_t ret_ref = (uint64_t)ret_copy;
15778         return ret_ref;
15779 }
15780
15781 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1closing_1signed(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
15782         LDKPublicKey node_id_ref;
15783         CHECK((*env)->GetArrayLength(env, node_id) == 33);
15784         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
15785         LDKClosingSigned msg_conv;
15786         msg_conv.inner = (void*)(msg & (~1));
15787         msg_conv.is_owned = (msg & 1) || (msg == 0);
15788         msg_conv = ClosingSigned_clone(&msg_conv);
15789         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
15790         *ret_copy = MessageSendEvent_send_closing_signed(node_id_ref, msg_conv);
15791         uint64_t ret_ref = (uint64_t)ret_copy;
15792         return ret_ref;
15793 }
15794
15795 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1shutdown(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
15796         LDKPublicKey node_id_ref;
15797         CHECK((*env)->GetArrayLength(env, node_id) == 33);
15798         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
15799         LDKShutdown msg_conv;
15800         msg_conv.inner = (void*)(msg & (~1));
15801         msg_conv.is_owned = (msg & 1) || (msg == 0);
15802         msg_conv = Shutdown_clone(&msg_conv);
15803         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
15804         *ret_copy = MessageSendEvent_send_shutdown(node_id_ref, msg_conv);
15805         uint64_t ret_ref = (uint64_t)ret_copy;
15806         return ret_ref;
15807 }
15808
15809 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1channel_1reestablish(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
15810         LDKPublicKey node_id_ref;
15811         CHECK((*env)->GetArrayLength(env, node_id) == 33);
15812         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
15813         LDKChannelReestablish msg_conv;
15814         msg_conv.inner = (void*)(msg & (~1));
15815         msg_conv.is_owned = (msg & 1) || (msg == 0);
15816         msg_conv = ChannelReestablish_clone(&msg_conv);
15817         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
15818         *ret_copy = MessageSendEvent_send_channel_reestablish(node_id_ref, msg_conv);
15819         uint64_t ret_ref = (uint64_t)ret_copy;
15820         return ret_ref;
15821 }
15822
15823 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1broadcast_1channel_1announcement(JNIEnv *env, jclass clz, int64_t msg, int64_t update_msg) {
15824         LDKChannelAnnouncement msg_conv;
15825         msg_conv.inner = (void*)(msg & (~1));
15826         msg_conv.is_owned = (msg & 1) || (msg == 0);
15827         msg_conv = ChannelAnnouncement_clone(&msg_conv);
15828         LDKChannelUpdate update_msg_conv;
15829         update_msg_conv.inner = (void*)(update_msg & (~1));
15830         update_msg_conv.is_owned = (update_msg & 1) || (update_msg == 0);
15831         update_msg_conv = ChannelUpdate_clone(&update_msg_conv);
15832         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
15833         *ret_copy = MessageSendEvent_broadcast_channel_announcement(msg_conv, update_msg_conv);
15834         uint64_t ret_ref = (uint64_t)ret_copy;
15835         return ret_ref;
15836 }
15837
15838 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1broadcast_1node_1announcement(JNIEnv *env, jclass clz, int64_t msg) {
15839         LDKNodeAnnouncement msg_conv;
15840         msg_conv.inner = (void*)(msg & (~1));
15841         msg_conv.is_owned = (msg & 1) || (msg == 0);
15842         msg_conv = NodeAnnouncement_clone(&msg_conv);
15843         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
15844         *ret_copy = MessageSendEvent_broadcast_node_announcement(msg_conv);
15845         uint64_t ret_ref = (uint64_t)ret_copy;
15846         return ret_ref;
15847 }
15848
15849 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1broadcast_1channel_1update(JNIEnv *env, jclass clz, int64_t msg) {
15850         LDKChannelUpdate msg_conv;
15851         msg_conv.inner = (void*)(msg & (~1));
15852         msg_conv.is_owned = (msg & 1) || (msg == 0);
15853         msg_conv = ChannelUpdate_clone(&msg_conv);
15854         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
15855         *ret_copy = MessageSendEvent_broadcast_channel_update(msg_conv);
15856         uint64_t ret_ref = (uint64_t)ret_copy;
15857         return ret_ref;
15858 }
15859
15860 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1channel_1update(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
15861         LDKPublicKey node_id_ref;
15862         CHECK((*env)->GetArrayLength(env, node_id) == 33);
15863         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
15864         LDKChannelUpdate msg_conv;
15865         msg_conv.inner = (void*)(msg & (~1));
15866         msg_conv.is_owned = (msg & 1) || (msg == 0);
15867         msg_conv = ChannelUpdate_clone(&msg_conv);
15868         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
15869         *ret_copy = MessageSendEvent_send_channel_update(node_id_ref, msg_conv);
15870         uint64_t ret_ref = (uint64_t)ret_copy;
15871         return ret_ref;
15872 }
15873
15874 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1handle_1error(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t action) {
15875         LDKPublicKey node_id_ref;
15876         CHECK((*env)->GetArrayLength(env, node_id) == 33);
15877         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
15878         LDKErrorAction action_conv = *(LDKErrorAction*)(((uint64_t)action) & ~1);
15879         action_conv = ErrorAction_clone((LDKErrorAction*)(((uint64_t)action) & ~1));
15880         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
15881         *ret_copy = MessageSendEvent_handle_error(node_id_ref, action_conv);
15882         uint64_t ret_ref = (uint64_t)ret_copy;
15883         return ret_ref;
15884 }
15885
15886 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) {
15887         LDKPublicKey node_id_ref;
15888         CHECK((*env)->GetArrayLength(env, node_id) == 33);
15889         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
15890         LDKQueryChannelRange msg_conv;
15891         msg_conv.inner = (void*)(msg & (~1));
15892         msg_conv.is_owned = (msg & 1) || (msg == 0);
15893         msg_conv = QueryChannelRange_clone(&msg_conv);
15894         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
15895         *ret_copy = MessageSendEvent_send_channel_range_query(node_id_ref, msg_conv);
15896         uint64_t ret_ref = (uint64_t)ret_copy;
15897         return ret_ref;
15898 }
15899
15900 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) {
15901         LDKPublicKey node_id_ref;
15902         CHECK((*env)->GetArrayLength(env, node_id) == 33);
15903         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
15904         LDKQueryShortChannelIds msg_conv;
15905         msg_conv.inner = (void*)(msg & (~1));
15906         msg_conv.is_owned = (msg & 1) || (msg == 0);
15907         msg_conv = QueryShortChannelIds_clone(&msg_conv);
15908         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
15909         *ret_copy = MessageSendEvent_send_short_ids_query(node_id_ref, msg_conv);
15910         uint64_t ret_ref = (uint64_t)ret_copy;
15911         return ret_ref;
15912 }
15913
15914 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) {
15915         LDKPublicKey node_id_ref;
15916         CHECK((*env)->GetArrayLength(env, node_id) == 33);
15917         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
15918         LDKReplyChannelRange msg_conv;
15919         msg_conv.inner = (void*)(msg & (~1));
15920         msg_conv.is_owned = (msg & 1) || (msg == 0);
15921         msg_conv = ReplyChannelRange_clone(&msg_conv);
15922         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
15923         *ret_copy = MessageSendEvent_send_reply_channel_range(node_id_ref, msg_conv);
15924         uint64_t ret_ref = (uint64_t)ret_copy;
15925         return ret_ref;
15926 }
15927
15928 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageSendEventsProvider_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
15929         if ((this_ptr & 1) != 0) return;
15930         LDKMessageSendEventsProvider this_ptr_conv = *(LDKMessageSendEventsProvider*)(((uint64_t)this_ptr) & ~1);
15931         FREE((void*)this_ptr);
15932         MessageSendEventsProvider_free(this_ptr_conv);
15933 }
15934
15935 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventsProvider_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
15936         if ((this_ptr & 1) != 0) return;
15937         LDKEventsProvider this_ptr_conv = *(LDKEventsProvider*)(((uint64_t)this_ptr) & ~1);
15938         FREE((void*)this_ptr);
15939         EventsProvider_free(this_ptr_conv);
15940 }
15941
15942 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
15943         if ((this_ptr & 1) != 0) return;
15944         LDKEventHandler this_ptr_conv = *(LDKEventHandler*)(((uint64_t)this_ptr) & ~1);
15945         FREE((void*)this_ptr);
15946         EventHandler_free(this_ptr_conv);
15947 }
15948
15949 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_APIError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
15950         if ((this_ptr & 1) != 0) return;
15951         LDKAPIError this_ptr_conv = *(LDKAPIError*)(((uint64_t)this_ptr) & ~1);
15952         FREE((void*)this_ptr);
15953         APIError_free(this_ptr_conv);
15954 }
15955
15956 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15957         LDKAPIError* orig_conv = (LDKAPIError*)orig;
15958         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
15959         *ret_copy = APIError_clone(orig_conv);
15960         uint64_t ret_ref = (uint64_t)ret_copy;
15961         return ret_ref;
15962 }
15963
15964 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1apimisuse_1error(JNIEnv *env, jclass clz, jstring err) {
15965         LDKStr err_conv = java_to_owned_str(env, err);
15966         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
15967         *ret_copy = APIError_apimisuse_error(err_conv);
15968         uint64_t ret_ref = (uint64_t)ret_copy;
15969         return ret_ref;
15970 }
15971
15972 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1fee_1rate_1too_1high(JNIEnv *env, jclass clz, jstring err, int32_t feerate) {
15973         LDKStr err_conv = java_to_owned_str(env, err);
15974         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
15975         *ret_copy = APIError_fee_rate_too_high(err_conv, feerate);
15976         uint64_t ret_ref = (uint64_t)ret_copy;
15977         return ret_ref;
15978 }
15979
15980 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1route_1error(JNIEnv *env, jclass clz, jstring err) {
15981         LDKStr err_conv = java_to_owned_str(env, err);
15982         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
15983         *ret_copy = APIError_route_error(err_conv);
15984         uint64_t ret_ref = (uint64_t)ret_copy;
15985         return ret_ref;
15986 }
15987
15988 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1channel_1unavailable(JNIEnv *env, jclass clz, jstring err) {
15989         LDKStr err_conv = java_to_owned_str(env, err);
15990         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
15991         *ret_copy = APIError_channel_unavailable(err_conv);
15992         uint64_t ret_ref = (uint64_t)ret_copy;
15993         return ret_ref;
15994 }
15995
15996 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1monitor_1update_1failed(JNIEnv *env, jclass clz) {
15997         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
15998         *ret_copy = APIError_monitor_update_failed();
15999         uint64_t ret_ref = (uint64_t)ret_copy;
16000         return ret_ref;
16001 }
16002
16003 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1incompatible_1shutdown_1script(JNIEnv *env, jclass clz, int64_t script) {
16004         LDKShutdownScript script_conv;
16005         script_conv.inner = (void*)(script & (~1));
16006         script_conv.is_owned = (script & 1) || (script == 0);
16007         script_conv = ShutdownScript_clone(&script_conv);
16008         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
16009         *ret_copy = APIError_incompatible_shutdown_script(script_conv);
16010         uint64_t ret_ref = (uint64_t)ret_copy;
16011         return ret_ref;
16012 }
16013
16014 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_sign(JNIEnv *env, jclass clz, int8_tArray msg, int8_tArray sk) {
16015         LDKu8slice msg_ref;
16016         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
16017         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
16018         unsigned char sk_arr[32];
16019         CHECK((*env)->GetArrayLength(env, sk) == 32);
16020         (*env)->GetByteArrayRegion(env, sk, 0, 32, sk_arr);
16021         unsigned char (*sk_ref)[32] = &sk_arr;
16022         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
16023         *ret_conv = sign(msg_ref, sk_ref);
16024         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
16025         return (uint64_t)ret_conv;
16026 }
16027
16028 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_recover_1pk(JNIEnv *env, jclass clz, int8_tArray msg, jstring sig) {
16029         LDKu8slice msg_ref;
16030         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
16031         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
16032         LDKStr sig_conv = java_to_owned_str(env, sig);
16033         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
16034         *ret_conv = recover_pk(msg_ref, sig_conv);
16035         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
16036         return (uint64_t)ret_conv;
16037 }
16038
16039 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_verify(JNIEnv *env, jclass clz, int8_tArray msg, jstring sig, int8_tArray pk) {
16040         LDKu8slice msg_ref;
16041         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
16042         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
16043         LDKStr sig_conv = java_to_owned_str(env, sig);
16044         LDKPublicKey pk_ref;
16045         CHECK((*env)->GetArrayLength(env, pk) == 33);
16046         (*env)->GetByteArrayRegion(env, pk, 0, 33, pk_ref.compressed_form);
16047         jboolean ret_val = verify(msg_ref, sig_conv, pk_ref);
16048         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
16049         return ret_val;
16050 }
16051
16052 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16053         LDKLevel* orig_conv = (LDKLevel*)(orig & ~1);
16054         jclass ret_conv = LDKLevel_to_java(env, Level_clone(orig_conv));
16055         return ret_conv;
16056 }
16057
16058 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1trace(JNIEnv *env, jclass clz) {
16059         jclass ret_conv = LDKLevel_to_java(env, Level_trace());
16060         return ret_conv;
16061 }
16062
16063 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1debug(JNIEnv *env, jclass clz) {
16064         jclass ret_conv = LDKLevel_to_java(env, Level_debug());
16065         return ret_conv;
16066 }
16067
16068 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1info(JNIEnv *env, jclass clz) {
16069         jclass ret_conv = LDKLevel_to_java(env, Level_info());
16070         return ret_conv;
16071 }
16072
16073 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1warn(JNIEnv *env, jclass clz) {
16074         jclass ret_conv = LDKLevel_to_java(env, Level_warn());
16075         return ret_conv;
16076 }
16077
16078 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1error(JNIEnv *env, jclass clz) {
16079         jclass ret_conv = LDKLevel_to_java(env, Level_error());
16080         return ret_conv;
16081 }
16082
16083 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Level_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
16084         LDKLevel* a_conv = (LDKLevel*)(a & ~1);
16085         LDKLevel* b_conv = (LDKLevel*)(b & ~1);
16086         jboolean ret_val = Level_eq(a_conv, b_conv);
16087         return ret_val;
16088 }
16089
16090 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Level_1hash(JNIEnv *env, jclass clz, int64_t o) {
16091         LDKLevel* o_conv = (LDKLevel*)(o & ~1);
16092         int64_t ret_val = Level_hash(o_conv);
16093         return ret_val;
16094 }
16095
16096 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1max(JNIEnv *env, jclass clz) {
16097         jclass ret_conv = LDKLevel_to_java(env, Level_max());
16098         return ret_conv;
16099 }
16100
16101 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Logger_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
16102         if ((this_ptr & 1) != 0) return;
16103         LDKLogger this_ptr_conv = *(LDKLogger*)(((uint64_t)this_ptr) & ~1);
16104         FREE((void*)this_ptr);
16105         Logger_free(this_ptr_conv);
16106 }
16107
16108 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
16109         LDKChannelHandshakeConfig this_obj_conv;
16110         this_obj_conv.inner = (void*)(this_obj & (~1));
16111         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16112         ChannelHandshakeConfig_free(this_obj_conv);
16113 }
16114
16115 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
16116         LDKChannelHandshakeConfig this_ptr_conv;
16117         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16118         this_ptr_conv.is_owned = false;
16119         int32_t ret_val = ChannelHandshakeConfig_get_minimum_depth(&this_ptr_conv);
16120         return ret_val;
16121 }
16122
16123 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
16124         LDKChannelHandshakeConfig this_ptr_conv;
16125         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16126         this_ptr_conv.is_owned = false;
16127         ChannelHandshakeConfig_set_minimum_depth(&this_ptr_conv, val);
16128 }
16129
16130 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1our_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
16131         LDKChannelHandshakeConfig this_ptr_conv;
16132         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16133         this_ptr_conv.is_owned = false;
16134         int16_t ret_val = ChannelHandshakeConfig_get_our_to_self_delay(&this_ptr_conv);
16135         return ret_val;
16136 }
16137
16138 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) {
16139         LDKChannelHandshakeConfig this_ptr_conv;
16140         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16141         this_ptr_conv.is_owned = false;
16142         ChannelHandshakeConfig_set_our_to_self_delay(&this_ptr_conv, val);
16143 }
16144
16145 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1our_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
16146         LDKChannelHandshakeConfig this_ptr_conv;
16147         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16148         this_ptr_conv.is_owned = false;
16149         int64_t ret_val = ChannelHandshakeConfig_get_our_htlc_minimum_msat(&this_ptr_conv);
16150         return ret_val;
16151 }
16152
16153 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) {
16154         LDKChannelHandshakeConfig this_ptr_conv;
16155         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16156         this_ptr_conv.is_owned = false;
16157         ChannelHandshakeConfig_set_our_htlc_minimum_msat(&this_ptr_conv, val);
16158 }
16159
16160 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) {
16161         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_new(minimum_depth_arg, our_to_self_delay_arg, our_htlc_minimum_msat_arg);
16162         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16163         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16164         uint64_t ret_ref = (uint64_t)ret_var.inner;
16165         if (ret_var.is_owned) {
16166                 ret_ref |= 1;
16167         }
16168         return ret_ref;
16169 }
16170
16171 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16172         LDKChannelHandshakeConfig orig_conv;
16173         orig_conv.inner = (void*)(orig & (~1));
16174         orig_conv.is_owned = false;
16175         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(&orig_conv);
16176         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16177         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16178         uint64_t ret_ref = (uint64_t)ret_var.inner;
16179         if (ret_var.is_owned) {
16180                 ret_ref |= 1;
16181         }
16182         return ret_ref;
16183 }
16184
16185 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1default(JNIEnv *env, jclass clz) {
16186         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_default();
16187         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16188         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16189         uint64_t ret_ref = (uint64_t)ret_var.inner;
16190         if (ret_var.is_owned) {
16191                 ret_ref |= 1;
16192         }
16193         return ret_ref;
16194 }
16195
16196 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
16197         LDKChannelHandshakeLimits this_obj_conv;
16198         this_obj_conv.inner = (void*)(this_obj & (~1));
16199         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16200         ChannelHandshakeLimits_free(this_obj_conv);
16201 }
16202
16203 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
16204         LDKChannelHandshakeLimits this_ptr_conv;
16205         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16206         this_ptr_conv.is_owned = false;
16207         int64_t ret_val = ChannelHandshakeLimits_get_min_funding_satoshis(&this_ptr_conv);
16208         return ret_val;
16209 }
16210
16211 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1min_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16212         LDKChannelHandshakeLimits this_ptr_conv;
16213         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16214         this_ptr_conv.is_owned = false;
16215         ChannelHandshakeLimits_set_min_funding_satoshis(&this_ptr_conv, val);
16216 }
16217
16218 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
16219         LDKChannelHandshakeLimits this_ptr_conv;
16220         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16221         this_ptr_conv.is_owned = false;
16222         int64_t ret_val = ChannelHandshakeLimits_get_max_htlc_minimum_msat(&this_ptr_conv);
16223         return ret_val;
16224 }
16225
16226 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) {
16227         LDKChannelHandshakeLimits this_ptr_conv;
16228         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16229         this_ptr_conv.is_owned = false;
16230         ChannelHandshakeLimits_set_max_htlc_minimum_msat(&this_ptr_conv, val);
16231 }
16232
16233 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) {
16234         LDKChannelHandshakeLimits this_ptr_conv;
16235         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16236         this_ptr_conv.is_owned = false;
16237         int64_t ret_val = ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(&this_ptr_conv);
16238         return ret_val;
16239 }
16240
16241 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) {
16242         LDKChannelHandshakeLimits this_ptr_conv;
16243         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16244         this_ptr_conv.is_owned = false;
16245         ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
16246 }
16247
16248 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
16249         LDKChannelHandshakeLimits this_ptr_conv;
16250         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16251         this_ptr_conv.is_owned = false;
16252         int64_t ret_val = ChannelHandshakeLimits_get_max_channel_reserve_satoshis(&this_ptr_conv);
16253         return ret_val;
16254 }
16255
16256 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) {
16257         LDKChannelHandshakeLimits this_ptr_conv;
16258         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16259         this_ptr_conv.is_owned = false;
16260         ChannelHandshakeLimits_set_max_channel_reserve_satoshis(&this_ptr_conv, val);
16261 }
16262
16263 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
16264         LDKChannelHandshakeLimits this_ptr_conv;
16265         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16266         this_ptr_conv.is_owned = false;
16267         int16_t ret_val = ChannelHandshakeLimits_get_min_max_accepted_htlcs(&this_ptr_conv);
16268         return ret_val;
16269 }
16270
16271 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) {
16272         LDKChannelHandshakeLimits this_ptr_conv;
16273         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16274         this_ptr_conv.is_owned = false;
16275         ChannelHandshakeLimits_set_min_max_accepted_htlcs(&this_ptr_conv, val);
16276 }
16277
16278 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
16279         LDKChannelHandshakeLimits this_ptr_conv;
16280         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16281         this_ptr_conv.is_owned = false;
16282         int32_t ret_val = ChannelHandshakeLimits_get_max_minimum_depth(&this_ptr_conv);
16283         return ret_val;
16284 }
16285
16286 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1max_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
16287         LDKChannelHandshakeLimits this_ptr_conv;
16288         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16289         this_ptr_conv.is_owned = false;
16290         ChannelHandshakeLimits_set_max_minimum_depth(&this_ptr_conv, val);
16291 }
16292
16293 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1force_1announced_1channel_1preference(JNIEnv *env, jclass clz, int64_t this_ptr) {
16294         LDKChannelHandshakeLimits this_ptr_conv;
16295         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16296         this_ptr_conv.is_owned = false;
16297         jboolean ret_val = ChannelHandshakeLimits_get_force_announced_channel_preference(&this_ptr_conv);
16298         return ret_val;
16299 }
16300
16301 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1force_1announced_1channel_1preference(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
16302         LDKChannelHandshakeLimits this_ptr_conv;
16303         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16304         this_ptr_conv.is_owned = false;
16305         ChannelHandshakeLimits_set_force_announced_channel_preference(&this_ptr_conv, val);
16306 }
16307
16308 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1their_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
16309         LDKChannelHandshakeLimits this_ptr_conv;
16310         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16311         this_ptr_conv.is_owned = false;
16312         int16_t ret_val = ChannelHandshakeLimits_get_their_to_self_delay(&this_ptr_conv);
16313         return ret_val;
16314 }
16315
16316 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) {
16317         LDKChannelHandshakeLimits this_ptr_conv;
16318         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16319         this_ptr_conv.is_owned = false;
16320         ChannelHandshakeLimits_set_their_to_self_delay(&this_ptr_conv, val);
16321 }
16322
16323 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) {
16324         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);
16325         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16326         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16327         uint64_t ret_ref = (uint64_t)ret_var.inner;
16328         if (ret_var.is_owned) {
16329                 ret_ref |= 1;
16330         }
16331         return ret_ref;
16332 }
16333
16334 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16335         LDKChannelHandshakeLimits orig_conv;
16336         orig_conv.inner = (void*)(orig & (~1));
16337         orig_conv.is_owned = false;
16338         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(&orig_conv);
16339         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16340         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16341         uint64_t ret_ref = (uint64_t)ret_var.inner;
16342         if (ret_var.is_owned) {
16343                 ret_ref |= 1;
16344         }
16345         return ret_ref;
16346 }
16347
16348 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1default(JNIEnv *env, jclass clz) {
16349         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_default();
16350         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16351         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16352         uint64_t ret_ref = (uint64_t)ret_var.inner;
16353         if (ret_var.is_owned) {
16354                 ret_ref |= 1;
16355         }
16356         return ret_ref;
16357 }
16358
16359 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
16360         LDKChannelConfig this_obj_conv;
16361         this_obj_conv.inner = (void*)(this_obj & (~1));
16362         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16363         ChannelConfig_free(this_obj_conv);
16364 }
16365
16366 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1forwarding_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
16367         LDKChannelConfig this_ptr_conv;
16368         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16369         this_ptr_conv.is_owned = false;
16370         int32_t ret_val = ChannelConfig_get_forwarding_fee_proportional_millionths(&this_ptr_conv);
16371         return ret_val;
16372 }
16373
16374 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) {
16375         LDKChannelConfig this_ptr_conv;
16376         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16377         this_ptr_conv.is_owned = false;
16378         ChannelConfig_set_forwarding_fee_proportional_millionths(&this_ptr_conv, val);
16379 }
16380
16381 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1forwarding_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
16382         LDKChannelConfig this_ptr_conv;
16383         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16384         this_ptr_conv.is_owned = false;
16385         int32_t ret_val = ChannelConfig_get_forwarding_fee_base_msat(&this_ptr_conv);
16386         return ret_val;
16387 }
16388
16389 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) {
16390         LDKChannelConfig this_ptr_conv;
16391         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16392         this_ptr_conv.is_owned = false;
16393         ChannelConfig_set_forwarding_fee_base_msat(&this_ptr_conv, val);
16394 }
16395
16396 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
16397         LDKChannelConfig this_ptr_conv;
16398         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16399         this_ptr_conv.is_owned = false;
16400         int16_t ret_val = ChannelConfig_get_cltv_expiry_delta(&this_ptr_conv);
16401         return ret_val;
16402 }
16403
16404 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
16405         LDKChannelConfig this_ptr_conv;
16406         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16407         this_ptr_conv.is_owned = false;
16408         ChannelConfig_set_cltv_expiry_delta(&this_ptr_conv, val);
16409 }
16410
16411 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1announced_1channel(JNIEnv *env, jclass clz, int64_t this_ptr) {
16412         LDKChannelConfig this_ptr_conv;
16413         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16414         this_ptr_conv.is_owned = false;
16415         jboolean ret_val = ChannelConfig_get_announced_channel(&this_ptr_conv);
16416         return ret_val;
16417 }
16418
16419 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1announced_1channel(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
16420         LDKChannelConfig this_ptr_conv;
16421         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16422         this_ptr_conv.is_owned = false;
16423         ChannelConfig_set_announced_channel(&this_ptr_conv, val);
16424 }
16425
16426 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1commit_1upfront_1shutdown_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
16427         LDKChannelConfig this_ptr_conv;
16428         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16429         this_ptr_conv.is_owned = false;
16430         jboolean ret_val = ChannelConfig_get_commit_upfront_shutdown_pubkey(&this_ptr_conv);
16431         return ret_val;
16432 }
16433
16434 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1commit_1upfront_1shutdown_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
16435         LDKChannelConfig this_ptr_conv;
16436         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16437         this_ptr_conv.is_owned = false;
16438         ChannelConfig_set_commit_upfront_shutdown_pubkey(&this_ptr_conv, val);
16439 }
16440
16441 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1max_1dust_1htlc_1exposure_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
16442         LDKChannelConfig this_ptr_conv;
16443         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16444         this_ptr_conv.is_owned = false;
16445         int64_t ret_val = ChannelConfig_get_max_dust_htlc_exposure_msat(&this_ptr_conv);
16446         return ret_val;
16447 }
16448
16449 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) {
16450         LDKChannelConfig this_ptr_conv;
16451         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16452         this_ptr_conv.is_owned = false;
16453         ChannelConfig_set_max_dust_htlc_exposure_msat(&this_ptr_conv, val);
16454 }
16455
16456 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) {
16457         LDKChannelConfig this_ptr_conv;
16458         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16459         this_ptr_conv.is_owned = false;
16460         int64_t ret_val = ChannelConfig_get_force_close_avoidance_max_fee_satoshis(&this_ptr_conv);
16461         return ret_val;
16462 }
16463
16464 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) {
16465         LDKChannelConfig this_ptr_conv;
16466         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16467         this_ptr_conv.is_owned = false;
16468         ChannelConfig_set_force_close_avoidance_max_fee_satoshis(&this_ptr_conv, val);
16469 }
16470
16471 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) {
16472         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);
16473         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16474         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16475         uint64_t ret_ref = (uint64_t)ret_var.inner;
16476         if (ret_var.is_owned) {
16477                 ret_ref |= 1;
16478         }
16479         return ret_ref;
16480 }
16481
16482 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16483         LDKChannelConfig orig_conv;
16484         orig_conv.inner = (void*)(orig & (~1));
16485         orig_conv.is_owned = false;
16486         LDKChannelConfig ret_var = ChannelConfig_clone(&orig_conv);
16487         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16488         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16489         uint64_t ret_ref = (uint64_t)ret_var.inner;
16490         if (ret_var.is_owned) {
16491                 ret_ref |= 1;
16492         }
16493         return ret_ref;
16494 }
16495
16496 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1default(JNIEnv *env, jclass clz) {
16497         LDKChannelConfig ret_var = ChannelConfig_default();
16498         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16499         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16500         uint64_t ret_ref = (uint64_t)ret_var.inner;
16501         if (ret_var.is_owned) {
16502                 ret_ref |= 1;
16503         }
16504         return ret_ref;
16505 }
16506
16507 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1write(JNIEnv *env, jclass clz, int64_t obj) {
16508         LDKChannelConfig obj_conv;
16509         obj_conv.inner = (void*)(obj & (~1));
16510         obj_conv.is_owned = false;
16511         LDKCVec_u8Z ret_var = ChannelConfig_write(&obj_conv);
16512         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
16513         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
16514         CVec_u8Z_free(ret_var);
16515         return ret_arr;
16516 }
16517
16518 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
16519         LDKu8slice ser_ref;
16520         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
16521         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
16522         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
16523         *ret_conv = ChannelConfig_read(ser_ref);
16524         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
16525         return (uint64_t)ret_conv;
16526 }
16527
16528 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
16529         LDKUserConfig this_obj_conv;
16530         this_obj_conv.inner = (void*)(this_obj & (~1));
16531         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16532         UserConfig_free(this_obj_conv);
16533 }
16534
16535 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1own_1channel_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
16536         LDKUserConfig this_ptr_conv;
16537         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16538         this_ptr_conv.is_owned = false;
16539         LDKChannelHandshakeConfig ret_var = UserConfig_get_own_channel_config(&this_ptr_conv);
16540         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16541         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16542         uint64_t ret_ref = (uint64_t)ret_var.inner;
16543         if (ret_var.is_owned) {
16544                 ret_ref |= 1;
16545         }
16546         return ret_ref;
16547 }
16548
16549 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1own_1channel_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16550         LDKUserConfig this_ptr_conv;
16551         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16552         this_ptr_conv.is_owned = false;
16553         LDKChannelHandshakeConfig val_conv;
16554         val_conv.inner = (void*)(val & (~1));
16555         val_conv.is_owned = (val & 1) || (val == 0);
16556         val_conv = ChannelHandshakeConfig_clone(&val_conv);
16557         UserConfig_set_own_channel_config(&this_ptr_conv, val_conv);
16558 }
16559
16560 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1peer_1channel_1config_1limits(JNIEnv *env, jclass clz, int64_t this_ptr) {
16561         LDKUserConfig this_ptr_conv;
16562         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16563         this_ptr_conv.is_owned = false;
16564         LDKChannelHandshakeLimits ret_var = UserConfig_get_peer_channel_config_limits(&this_ptr_conv);
16565         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16566         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16567         uint64_t ret_ref = (uint64_t)ret_var.inner;
16568         if (ret_var.is_owned) {
16569                 ret_ref |= 1;
16570         }
16571         return ret_ref;
16572 }
16573
16574 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) {
16575         LDKUserConfig this_ptr_conv;
16576         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16577         this_ptr_conv.is_owned = false;
16578         LDKChannelHandshakeLimits val_conv;
16579         val_conv.inner = (void*)(val & (~1));
16580         val_conv.is_owned = (val & 1) || (val == 0);
16581         val_conv = ChannelHandshakeLimits_clone(&val_conv);
16582         UserConfig_set_peer_channel_config_limits(&this_ptr_conv, val_conv);
16583 }
16584
16585 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1channel_1options(JNIEnv *env, jclass clz, int64_t this_ptr) {
16586         LDKUserConfig this_ptr_conv;
16587         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16588         this_ptr_conv.is_owned = false;
16589         LDKChannelConfig ret_var = UserConfig_get_channel_options(&this_ptr_conv);
16590         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16591         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16592         uint64_t ret_ref = (uint64_t)ret_var.inner;
16593         if (ret_var.is_owned) {
16594                 ret_ref |= 1;
16595         }
16596         return ret_ref;
16597 }
16598
16599 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1channel_1options(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16600         LDKUserConfig this_ptr_conv;
16601         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16602         this_ptr_conv.is_owned = false;
16603         LDKChannelConfig val_conv;
16604         val_conv.inner = (void*)(val & (~1));
16605         val_conv.is_owned = (val & 1) || (val == 0);
16606         val_conv = ChannelConfig_clone(&val_conv);
16607         UserConfig_set_channel_options(&this_ptr_conv, val_conv);
16608 }
16609
16610 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1accept_1forwards_1to_1priv_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
16611         LDKUserConfig this_ptr_conv;
16612         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16613         this_ptr_conv.is_owned = false;
16614         jboolean ret_val = UserConfig_get_accept_forwards_to_priv_channels(&this_ptr_conv);
16615         return ret_val;
16616 }
16617
16618 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) {
16619         LDKUserConfig this_ptr_conv;
16620         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16621         this_ptr_conv.is_owned = false;
16622         UserConfig_set_accept_forwards_to_priv_channels(&this_ptr_conv, val);
16623 }
16624
16625 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) {
16626         LDKChannelHandshakeConfig own_channel_config_arg_conv;
16627         own_channel_config_arg_conv.inner = (void*)(own_channel_config_arg & (~1));
16628         own_channel_config_arg_conv.is_owned = (own_channel_config_arg & 1) || (own_channel_config_arg == 0);
16629         own_channel_config_arg_conv = ChannelHandshakeConfig_clone(&own_channel_config_arg_conv);
16630         LDKChannelHandshakeLimits peer_channel_config_limits_arg_conv;
16631         peer_channel_config_limits_arg_conv.inner = (void*)(peer_channel_config_limits_arg & (~1));
16632         peer_channel_config_limits_arg_conv.is_owned = (peer_channel_config_limits_arg & 1) || (peer_channel_config_limits_arg == 0);
16633         peer_channel_config_limits_arg_conv = ChannelHandshakeLimits_clone(&peer_channel_config_limits_arg_conv);
16634         LDKChannelConfig channel_options_arg_conv;
16635         channel_options_arg_conv.inner = (void*)(channel_options_arg & (~1));
16636         channel_options_arg_conv.is_owned = (channel_options_arg & 1) || (channel_options_arg == 0);
16637         channel_options_arg_conv = ChannelConfig_clone(&channel_options_arg_conv);
16638         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);
16639         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16640         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16641         uint64_t ret_ref = (uint64_t)ret_var.inner;
16642         if (ret_var.is_owned) {
16643                 ret_ref |= 1;
16644         }
16645         return ret_ref;
16646 }
16647
16648 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16649         LDKUserConfig orig_conv;
16650         orig_conv.inner = (void*)(orig & (~1));
16651         orig_conv.is_owned = false;
16652         LDKUserConfig ret_var = UserConfig_clone(&orig_conv);
16653         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16654         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16655         uint64_t ret_ref = (uint64_t)ret_var.inner;
16656         if (ret_var.is_owned) {
16657                 ret_ref |= 1;
16658         }
16659         return ret_ref;
16660 }
16661
16662 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1default(JNIEnv *env, jclass clz) {
16663         LDKUserConfig ret_var = UserConfig_default();
16664         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16665         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16666         uint64_t ret_ref = (uint64_t)ret_var.inner;
16667         if (ret_var.is_owned) {
16668                 ret_ref |= 1;
16669         }
16670         return ret_ref;
16671 }
16672
16673 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BestBlock_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
16674         LDKBestBlock this_obj_conv;
16675         this_obj_conv.inner = (void*)(this_obj & (~1));
16676         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16677         BestBlock_free(this_obj_conv);
16678 }
16679
16680 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16681         LDKBestBlock orig_conv;
16682         orig_conv.inner = (void*)(orig & (~1));
16683         orig_conv.is_owned = false;
16684         LDKBestBlock ret_var = BestBlock_clone(&orig_conv);
16685         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16686         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16687         uint64_t ret_ref = (uint64_t)ret_var.inner;
16688         if (ret_var.is_owned) {
16689                 ret_ref |= 1;
16690         }
16691         return ret_ref;
16692 }
16693
16694 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1from_1genesis(JNIEnv *env, jclass clz, jclass network) {
16695         LDKNetwork network_conv = LDKNetwork_from_java(env, network);
16696         LDKBestBlock ret_var = BestBlock_from_genesis(network_conv);
16697         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16698         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16699         uint64_t ret_ref = (uint64_t)ret_var.inner;
16700         if (ret_var.is_owned) {
16701                 ret_ref |= 1;
16702         }
16703         return ret_ref;
16704 }
16705
16706 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1new(JNIEnv *env, jclass clz, int8_tArray block_hash, int32_t height) {
16707         LDKThirtyTwoBytes block_hash_ref;
16708         CHECK((*env)->GetArrayLength(env, block_hash) == 32);
16709         (*env)->GetByteArrayRegion(env, block_hash, 0, 32, block_hash_ref.data);
16710         LDKBestBlock ret_var = BestBlock_new(block_hash_ref, height);
16711         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16712         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16713         uint64_t ret_ref = (uint64_t)ret_var.inner;
16714         if (ret_var.is_owned) {
16715                 ret_ref |= 1;
16716         }
16717         return ret_ref;
16718 }
16719
16720 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BestBlock_1block_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
16721         LDKBestBlock this_arg_conv;
16722         this_arg_conv.inner = (void*)(this_arg & (~1));
16723         this_arg_conv.is_owned = false;
16724         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
16725         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, BestBlock_block_hash(&this_arg_conv).data);
16726         return ret_arr;
16727 }
16728
16729 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1height(JNIEnv *env, jclass clz, int64_t this_arg) {
16730         LDKBestBlock this_arg_conv;
16731         this_arg_conv.inner = (void*)(this_arg & (~1));
16732         this_arg_conv.is_owned = false;
16733         int32_t ret_val = BestBlock_height(&this_arg_conv);
16734         return ret_val;
16735 }
16736
16737 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_AccessError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16738         LDKAccessError* orig_conv = (LDKAccessError*)(orig & ~1);
16739         jclass ret_conv = LDKAccessError_to_java(env, AccessError_clone(orig_conv));
16740         return ret_conv;
16741 }
16742
16743 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_AccessError_1unknown_1chain(JNIEnv *env, jclass clz) {
16744         jclass ret_conv = LDKAccessError_to_java(env, AccessError_unknown_chain());
16745         return ret_conv;
16746 }
16747
16748 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_AccessError_1unknown_1tx(JNIEnv *env, jclass clz) {
16749         jclass ret_conv = LDKAccessError_to_java(env, AccessError_unknown_tx());
16750         return ret_conv;
16751 }
16752
16753 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Access_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
16754         if ((this_ptr & 1) != 0) return;
16755         LDKAccess this_ptr_conv = *(LDKAccess*)(((uint64_t)this_ptr) & ~1);
16756         FREE((void*)this_ptr);
16757         Access_free(this_ptr_conv);
16758 }
16759
16760 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Listen_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
16761         if ((this_ptr & 1) != 0) return;
16762         LDKListen this_ptr_conv = *(LDKListen*)(((uint64_t)this_ptr) & ~1);
16763         FREE((void*)this_ptr);
16764         Listen_free(this_ptr_conv);
16765 }
16766
16767 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Confirm_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
16768         if ((this_ptr & 1) != 0) return;
16769         LDKConfirm this_ptr_conv = *(LDKConfirm*)(((uint64_t)this_ptr) & ~1);
16770         FREE((void*)this_ptr);
16771         Confirm_free(this_ptr_conv);
16772 }
16773
16774 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateErr_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16775         LDKChannelMonitorUpdateErr* orig_conv = (LDKChannelMonitorUpdateErr*)(orig & ~1);
16776         jclass ret_conv = LDKChannelMonitorUpdateErr_to_java(env, ChannelMonitorUpdateErr_clone(orig_conv));
16777         return ret_conv;
16778 }
16779
16780 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateErr_1temporary_1failure(JNIEnv *env, jclass clz) {
16781         jclass ret_conv = LDKChannelMonitorUpdateErr_to_java(env, ChannelMonitorUpdateErr_temporary_failure());
16782         return ret_conv;
16783 }
16784
16785 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateErr_1permanent_1failure(JNIEnv *env, jclass clz) {
16786         jclass ret_conv = LDKChannelMonitorUpdateErr_to_java(env, ChannelMonitorUpdateErr_permanent_failure());
16787         return ret_conv;
16788 }
16789
16790 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Watch_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
16791         if ((this_ptr & 1) != 0) return;
16792         LDKWatch this_ptr_conv = *(LDKWatch*)(((uint64_t)this_ptr) & ~1);
16793         FREE((void*)this_ptr);
16794         Watch_free(this_ptr_conv);
16795 }
16796
16797 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Filter_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
16798         if ((this_ptr & 1) != 0) return;
16799         LDKFilter this_ptr_conv = *(LDKFilter*)(((uint64_t)this_ptr) & ~1);
16800         FREE((void*)this_ptr);
16801         Filter_free(this_ptr_conv);
16802 }
16803
16804 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
16805         LDKWatchedOutput this_obj_conv;
16806         this_obj_conv.inner = (void*)(this_obj & (~1));
16807         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16808         WatchedOutput_free(this_obj_conv);
16809 }
16810
16811 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1block_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
16812         LDKWatchedOutput this_ptr_conv;
16813         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16814         this_ptr_conv.is_owned = false;
16815         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
16816         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, WatchedOutput_get_block_hash(&this_ptr_conv).data);
16817         return ret_arr;
16818 }
16819
16820 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1block_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
16821         LDKWatchedOutput this_ptr_conv;
16822         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16823         this_ptr_conv.is_owned = false;
16824         LDKThirtyTwoBytes val_ref;
16825         CHECK((*env)->GetArrayLength(env, val) == 32);
16826         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
16827         WatchedOutput_set_block_hash(&this_ptr_conv, val_ref);
16828 }
16829
16830 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
16831         LDKWatchedOutput this_ptr_conv;
16832         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16833         this_ptr_conv.is_owned = false;
16834         LDKOutPoint ret_var = WatchedOutput_get_outpoint(&this_ptr_conv);
16835         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16836         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16837         uint64_t ret_ref = (uint64_t)ret_var.inner;
16838         if (ret_var.is_owned) {
16839                 ret_ref |= 1;
16840         }
16841         return ret_ref;
16842 }
16843
16844 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16845         LDKWatchedOutput this_ptr_conv;
16846         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16847         this_ptr_conv.is_owned = false;
16848         LDKOutPoint val_conv;
16849         val_conv.inner = (void*)(val & (~1));
16850         val_conv.is_owned = (val & 1) || (val == 0);
16851         val_conv = OutPoint_clone(&val_conv);
16852         WatchedOutput_set_outpoint(&this_ptr_conv, val_conv);
16853 }
16854
16855 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1script_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
16856         LDKWatchedOutput this_ptr_conv;
16857         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16858         this_ptr_conv.is_owned = false;
16859         LDKu8slice ret_var = WatchedOutput_get_script_pubkey(&this_ptr_conv);
16860         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
16861         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
16862         return ret_arr;
16863 }
16864
16865 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1script_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
16866         LDKWatchedOutput this_ptr_conv;
16867         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16868         this_ptr_conv.is_owned = false;
16869         LDKCVec_u8Z val_ref;
16870         val_ref.datalen = (*env)->GetArrayLength(env, val);
16871         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
16872         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
16873         WatchedOutput_set_script_pubkey(&this_ptr_conv, val_ref);
16874 }
16875
16876 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) {
16877         LDKThirtyTwoBytes block_hash_arg_ref;
16878         CHECK((*env)->GetArrayLength(env, block_hash_arg) == 32);
16879         (*env)->GetByteArrayRegion(env, block_hash_arg, 0, 32, block_hash_arg_ref.data);
16880         LDKOutPoint outpoint_arg_conv;
16881         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
16882         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
16883         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
16884         LDKCVec_u8Z script_pubkey_arg_ref;
16885         script_pubkey_arg_ref.datalen = (*env)->GetArrayLength(env, script_pubkey_arg);
16886         script_pubkey_arg_ref.data = MALLOC(script_pubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
16887         (*env)->GetByteArrayRegion(env, script_pubkey_arg, 0, script_pubkey_arg_ref.datalen, script_pubkey_arg_ref.data);
16888         LDKWatchedOutput ret_var = WatchedOutput_new(block_hash_arg_ref, outpoint_arg_conv, script_pubkey_arg_ref);
16889         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16890         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16891         uint64_t ret_ref = (uint64_t)ret_var.inner;
16892         if (ret_var.is_owned) {
16893                 ret_ref |= 1;
16894         }
16895         return ret_ref;
16896 }
16897
16898 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16899         LDKWatchedOutput orig_conv;
16900         orig_conv.inner = (void*)(orig & (~1));
16901         orig_conv.is_owned = false;
16902         LDKWatchedOutput ret_var = WatchedOutput_clone(&orig_conv);
16903         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16904         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16905         uint64_t ret_ref = (uint64_t)ret_var.inner;
16906         if (ret_var.is_owned) {
16907                 ret_ref |= 1;
16908         }
16909         return ret_ref;
16910 }
16911
16912 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1hash(JNIEnv *env, jclass clz, int64_t o) {
16913         LDKWatchedOutput o_conv;
16914         o_conv.inner = (void*)(o & (~1));
16915         o_conv.is_owned = false;
16916         int64_t ret_val = WatchedOutput_hash(&o_conv);
16917         return ret_val;
16918 }
16919
16920 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BroadcasterInterface_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
16921         if ((this_ptr & 1) != 0) return;
16922         LDKBroadcasterInterface this_ptr_conv = *(LDKBroadcasterInterface*)(((uint64_t)this_ptr) & ~1);
16923         FREE((void*)this_ptr);
16924         BroadcasterInterface_free(this_ptr_conv);
16925 }
16926
16927 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16928         LDKConfirmationTarget* orig_conv = (LDKConfirmationTarget*)(orig & ~1);
16929         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_clone(orig_conv));
16930         return ret_conv;
16931 }
16932
16933 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1background(JNIEnv *env, jclass clz) {
16934         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_background());
16935         return ret_conv;
16936 }
16937
16938 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1normal(JNIEnv *env, jclass clz) {
16939         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_normal());
16940         return ret_conv;
16941 }
16942
16943 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1high_1priority(JNIEnv *env, jclass clz) {
16944         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_high_priority());
16945         return ret_conv;
16946 }
16947
16948 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
16949         LDKConfirmationTarget* a_conv = (LDKConfirmationTarget*)(a & ~1);
16950         LDKConfirmationTarget* b_conv = (LDKConfirmationTarget*)(b & ~1);
16951         jboolean ret_val = ConfirmationTarget_eq(a_conv, b_conv);
16952         return ret_val;
16953 }
16954
16955 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FeeEstimator_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
16956         if ((this_ptr & 1) != 0) return;
16957         LDKFeeEstimator this_ptr_conv = *(LDKFeeEstimator*)(((uint64_t)this_ptr) & ~1);
16958         FREE((void*)this_ptr);
16959         FeeEstimator_free(this_ptr_conv);
16960 }
16961
16962 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Persist_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
16963         if ((this_ptr & 1) != 0) return;
16964         LDKPersist this_ptr_conv = *(LDKPersist*)(((uint64_t)this_ptr) & ~1);
16965         FREE((void*)this_ptr);
16966         Persist_free(this_ptr_conv);
16967 }
16968
16969 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LockedChannelMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
16970         LDKLockedChannelMonitor this_obj_conv;
16971         this_obj_conv.inner = (void*)(this_obj & (~1));
16972         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16973         LockedChannelMonitor_free(this_obj_conv);
16974 }
16975
16976 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
16977         LDKChainMonitor this_obj_conv;
16978         this_obj_conv.inner = (void*)(this_obj & (~1));
16979         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16980         ChainMonitor_free(this_obj_conv);
16981 }
16982
16983 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) {
16984         LDKCOption_FilterZ chain_source_conv = *(LDKCOption_FilterZ*)(((uint64_t)chain_source) & ~1);
16985         // Warning: we may need a move here but no clone is available for LDKCOption_FilterZ
16986         if (chain_source_conv.tag == LDKCOption_FilterZ_Some) {
16987                 // Manually implement clone for Java trait instances
16988                 if (chain_source_conv.some.free == LDKFilter_JCalls_free) {
16989                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16990                         LDKFilter_JCalls_cloned(&chain_source_conv.some);
16991                 }
16992         }
16993         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
16994         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
16995                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16996                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
16997         }
16998         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
16999         if (logger_conv.free == LDKLogger_JCalls_free) {
17000                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
17001                 LDKLogger_JCalls_cloned(&logger_conv);
17002         }
17003         LDKFeeEstimator feeest_conv = *(LDKFeeEstimator*)(((uint64_t)feeest) & ~1);
17004         if (feeest_conv.free == LDKFeeEstimator_JCalls_free) {
17005                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
17006                 LDKFeeEstimator_JCalls_cloned(&feeest_conv);
17007         }
17008         LDKPersist persister_conv = *(LDKPersist*)(((uint64_t)persister) & ~1);
17009         if (persister_conv.free == LDKPersist_JCalls_free) {
17010                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
17011                 LDKPersist_JCalls_cloned(&persister_conv);
17012         }
17013         LDKChainMonitor ret_var = ChainMonitor_new(chain_source_conv, broadcaster_conv, logger_conv, feeest_conv, persister_conv);
17014         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17015         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17016         uint64_t ret_ref = (uint64_t)ret_var.inner;
17017         if (ret_var.is_owned) {
17018                 ret_ref |= 1;
17019         }
17020         return ret_ref;
17021 }
17022
17023 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) {
17024         LDKChainMonitor this_arg_conv;
17025         this_arg_conv.inner = (void*)(this_arg & (~1));
17026         this_arg_conv.is_owned = false;
17027         LDKCVec_ChannelDetailsZ ignored_channels_constr;
17028         ignored_channels_constr.datalen = (*env)->GetArrayLength(env, ignored_channels);
17029         if (ignored_channels_constr.datalen > 0)
17030                 ignored_channels_constr.data = MALLOC(ignored_channels_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
17031         else
17032                 ignored_channels_constr.data = NULL;
17033         int64_t* ignored_channels_vals = (*env)->GetLongArrayElements (env, ignored_channels, NULL);
17034         for (size_t q = 0; q < ignored_channels_constr.datalen; q++) {
17035                 int64_t ignored_channels_conv_16 = ignored_channels_vals[q];
17036                 LDKChannelDetails ignored_channels_conv_16_conv;
17037                 ignored_channels_conv_16_conv.inner = (void*)(ignored_channels_conv_16 & (~1));
17038                 ignored_channels_conv_16_conv.is_owned = (ignored_channels_conv_16 & 1) || (ignored_channels_conv_16 == 0);
17039                 ignored_channels_conv_16_conv = ChannelDetails_clone(&ignored_channels_conv_16_conv);
17040                 ignored_channels_constr.data[q] = ignored_channels_conv_16_conv;
17041         }
17042         (*env)->ReleaseLongArrayElements(env, ignored_channels, ignored_channels_vals, 0);
17043         LDKCVec_BalanceZ ret_var = ChainMonitor_get_claimable_balances(&this_arg_conv, ignored_channels_constr);
17044         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
17045         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
17046         for (size_t j = 0; j < ret_var.datalen; j++) {
17047                 LDKBalance *ret_conv_9_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
17048                 *ret_conv_9_copy = Balance_clone(&ret_var.data[j]);
17049                 uint64_t ret_conv_9_ref = (uint64_t)ret_conv_9_copy;
17050                 ret_arr_ptr[j] = ret_conv_9_ref;
17051         }
17052         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
17053         FREE(ret_var.data);
17054         return ret_arr;
17055 }
17056
17057 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1get_1monitor(JNIEnv *env, jclass clz, int64_t this_arg, int64_t funding_txo) {
17058         LDKChainMonitor this_arg_conv;
17059         this_arg_conv.inner = (void*)(this_arg & (~1));
17060         this_arg_conv.is_owned = false;
17061         LDKOutPoint funding_txo_conv;
17062         funding_txo_conv.inner = (void*)(funding_txo & (~1));
17063         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
17064         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
17065         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
17066         *ret_conv = ChainMonitor_get_monitor(&this_arg_conv, funding_txo_conv);
17067         return (uint64_t)ret_conv;
17068 }
17069
17070 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1list_1monitors(JNIEnv *env, jclass clz, int64_t this_arg) {
17071         LDKChainMonitor this_arg_conv;
17072         this_arg_conv.inner = (void*)(this_arg & (~1));
17073         this_arg_conv.is_owned = false;
17074         LDKCVec_OutPointZ ret_var = ChainMonitor_list_monitors(&this_arg_conv);
17075         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
17076         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
17077         for (size_t k = 0; k < ret_var.datalen; k++) {
17078                 LDKOutPoint ret_conv_10_var = ret_var.data[k];
17079                 CHECK((((uint64_t)ret_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17080                 CHECK((((uint64_t)&ret_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17081                 uint64_t ret_conv_10_ref = (uint64_t)ret_conv_10_var.inner;
17082                 if (ret_conv_10_var.is_owned) {
17083                         ret_conv_10_ref |= 1;
17084                 }
17085                 ret_arr_ptr[k] = ret_conv_10_ref;
17086         }
17087         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
17088         FREE(ret_var.data);
17089         return ret_arr;
17090 }
17091
17092 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Listen(JNIEnv *env, jclass clz, int64_t this_arg) {
17093         LDKChainMonitor this_arg_conv;
17094         this_arg_conv.inner = (void*)(this_arg & (~1));
17095         this_arg_conv.is_owned = false;
17096         LDKListen* ret_ret =MALLOC(sizeof(LDKListen), "LDKListen");
17097         *ret_ret = ChainMonitor_as_Listen(&this_arg_conv);
17098         return (uint64_t)ret_ret;
17099 }
17100
17101 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Confirm(JNIEnv *env, jclass clz, int64_t this_arg) {
17102         LDKChainMonitor this_arg_conv;
17103         this_arg_conv.inner = (void*)(this_arg & (~1));
17104         this_arg_conv.is_owned = false;
17105         LDKConfirm* ret_ret =MALLOC(sizeof(LDKConfirm), "LDKConfirm");
17106         *ret_ret = ChainMonitor_as_Confirm(&this_arg_conv);
17107         return (uint64_t)ret_ret;
17108 }
17109
17110 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Watch(JNIEnv *env, jclass clz, int64_t this_arg) {
17111         LDKChainMonitor this_arg_conv;
17112         this_arg_conv.inner = (void*)(this_arg & (~1));
17113         this_arg_conv.is_owned = false;
17114         LDKWatch* ret_ret =MALLOC(sizeof(LDKWatch), "LDKWatch");
17115         *ret_ret = ChainMonitor_as_Watch(&this_arg_conv);
17116         return (uint64_t)ret_ret;
17117 }
17118
17119 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1EventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
17120         LDKChainMonitor this_arg_conv;
17121         this_arg_conv.inner = (void*)(this_arg & (~1));
17122         this_arg_conv.is_owned = false;
17123         LDKEventsProvider* ret_ret =MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
17124         *ret_ret = ChainMonitor_as_EventsProvider(&this_arg_conv);
17125         return (uint64_t)ret_ret;
17126 }
17127
17128 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17129         LDKChannelMonitorUpdate this_obj_conv;
17130         this_obj_conv.inner = (void*)(this_obj & (~1));
17131         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17132         ChannelMonitorUpdate_free(this_obj_conv);
17133 }
17134
17135 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1get_1update_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
17136         LDKChannelMonitorUpdate this_ptr_conv;
17137         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17138         this_ptr_conv.is_owned = false;
17139         int64_t ret_val = ChannelMonitorUpdate_get_update_id(&this_ptr_conv);
17140         return ret_val;
17141 }
17142
17143 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1set_1update_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17144         LDKChannelMonitorUpdate this_ptr_conv;
17145         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17146         this_ptr_conv.is_owned = false;
17147         ChannelMonitorUpdate_set_update_id(&this_ptr_conv, val);
17148 }
17149
17150 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17151         LDKChannelMonitorUpdate orig_conv;
17152         orig_conv.inner = (void*)(orig & (~1));
17153         orig_conv.is_owned = false;
17154         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(&orig_conv);
17155         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17156         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17157         uint64_t ret_ref = (uint64_t)ret_var.inner;
17158         if (ret_var.is_owned) {
17159                 ret_ref |= 1;
17160         }
17161         return ret_ref;
17162 }
17163
17164 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
17165         LDKChannelMonitorUpdate obj_conv;
17166         obj_conv.inner = (void*)(obj & (~1));
17167         obj_conv.is_owned = false;
17168         LDKCVec_u8Z ret_var = ChannelMonitorUpdate_write(&obj_conv);
17169         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17170         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17171         CVec_u8Z_free(ret_var);
17172         return ret_arr;
17173 }
17174
17175 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17176         LDKu8slice ser_ref;
17177         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17178         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17179         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
17180         *ret_conv = ChannelMonitorUpdate_read(ser_ref);
17181         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17182         return (uint64_t)ret_conv;
17183 }
17184
17185 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorUpdateError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17186         LDKMonitorUpdateError this_obj_conv;
17187         this_obj_conv.inner = (void*)(this_obj & (~1));
17188         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17189         MonitorUpdateError_free(this_obj_conv);
17190 }
17191
17192 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorUpdateError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17193         LDKMonitorUpdateError orig_conv;
17194         orig_conv.inner = (void*)(orig & (~1));
17195         orig_conv.is_owned = false;
17196         LDKMonitorUpdateError ret_var = MonitorUpdateError_clone(&orig_conv);
17197         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17198         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17199         uint64_t ret_ref = (uint64_t)ret_var.inner;
17200         if (ret_var.is_owned) {
17201                 ret_ref |= 1;
17202         }
17203         return ret_ref;
17204 }
17205
17206 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
17207         if ((this_ptr & 1) != 0) return;
17208         LDKMonitorEvent this_ptr_conv = *(LDKMonitorEvent*)(((uint64_t)this_ptr) & ~1);
17209         FREE((void*)this_ptr);
17210         MonitorEvent_free(this_ptr_conv);
17211 }
17212
17213 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17214         LDKMonitorEvent* orig_conv = (LDKMonitorEvent*)orig;
17215         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
17216         *ret_copy = MonitorEvent_clone(orig_conv);
17217         uint64_t ret_ref = (uint64_t)ret_copy;
17218         return ret_ref;
17219 }
17220
17221 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1htlcevent(JNIEnv *env, jclass clz, int64_t a) {
17222         LDKHTLCUpdate a_conv;
17223         a_conv.inner = (void*)(a & (~1));
17224         a_conv.is_owned = (a & 1) || (a == 0);
17225         a_conv = HTLCUpdate_clone(&a_conv);
17226         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
17227         *ret_copy = MonitorEvent_htlcevent(a_conv);
17228         uint64_t ret_ref = (uint64_t)ret_copy;
17229         return ret_ref;
17230 }
17231
17232 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1commitment_1tx_1confirmed(JNIEnv *env, jclass clz, int64_t a) {
17233         LDKOutPoint a_conv;
17234         a_conv.inner = (void*)(a & (~1));
17235         a_conv.is_owned = (a & 1) || (a == 0);
17236         a_conv = OutPoint_clone(&a_conv);
17237         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
17238         *ret_copy = MonitorEvent_commitment_tx_confirmed(a_conv);
17239         uint64_t ret_ref = (uint64_t)ret_copy;
17240         return ret_ref;
17241 }
17242
17243 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17244         LDKHTLCUpdate this_obj_conv;
17245         this_obj_conv.inner = (void*)(this_obj & (~1));
17246         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17247         HTLCUpdate_free(this_obj_conv);
17248 }
17249
17250 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17251         LDKHTLCUpdate orig_conv;
17252         orig_conv.inner = (void*)(orig & (~1));
17253         orig_conv.is_owned = false;
17254         LDKHTLCUpdate ret_var = HTLCUpdate_clone(&orig_conv);
17255         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17256         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17257         uint64_t ret_ref = (uint64_t)ret_var.inner;
17258         if (ret_var.is_owned) {
17259                 ret_ref |= 1;
17260         }
17261         return ret_ref;
17262 }
17263
17264 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
17265         LDKHTLCUpdate obj_conv;
17266         obj_conv.inner = (void*)(obj & (~1));
17267         obj_conv.is_owned = false;
17268         LDKCVec_u8Z ret_var = HTLCUpdate_write(&obj_conv);
17269         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17270         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17271         CVec_u8Z_free(ret_var);
17272         return ret_arr;
17273 }
17274
17275 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17276         LDKu8slice ser_ref;
17277         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17278         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17279         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
17280         *ret_conv = HTLCUpdate_read(ser_ref);
17281         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17282         return (uint64_t)ret_conv;
17283 }
17284
17285 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Balance_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
17286         if ((this_ptr & 1) != 0) return;
17287         LDKBalance this_ptr_conv = *(LDKBalance*)(((uint64_t)this_ptr) & ~1);
17288         FREE((void*)this_ptr);
17289         Balance_free(this_ptr_conv);
17290 }
17291
17292 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17293         LDKBalance* orig_conv = (LDKBalance*)orig;
17294         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
17295         *ret_copy = Balance_clone(orig_conv);
17296         uint64_t ret_ref = (uint64_t)ret_copy;
17297         return ret_ref;
17298 }
17299
17300 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1claimable_1on_1channel_1close(JNIEnv *env, jclass clz, int64_t claimable_amount_satoshis) {
17301         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
17302         *ret_copy = Balance_claimable_on_channel_close(claimable_amount_satoshis);
17303         uint64_t ret_ref = (uint64_t)ret_copy;
17304         return ret_ref;
17305 }
17306
17307 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) {
17308         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
17309         *ret_copy = Balance_claimable_awaiting_confirmations(claimable_amount_satoshis, confirmation_height);
17310         uint64_t ret_ref = (uint64_t)ret_copy;
17311         return ret_ref;
17312 }
17313
17314 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) {
17315         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
17316         *ret_copy = Balance_contentious_claimable(claimable_amount_satoshis, timeout_height);
17317         uint64_t ret_ref = (uint64_t)ret_copy;
17318         return ret_ref;
17319 }
17320
17321 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) {
17322         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
17323         *ret_copy = Balance_maybe_claimable_htlcawaiting_timeout(claimable_amount_satoshis, claimable_height);
17324         uint64_t ret_ref = (uint64_t)ret_copy;
17325         return ret_ref;
17326 }
17327
17328 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Balance_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
17329         LDKBalance* a_conv = (LDKBalance*)a;
17330         LDKBalance* b_conv = (LDKBalance*)b;
17331         jboolean ret_val = Balance_eq(a_conv, b_conv);
17332         return ret_val;
17333 }
17334
17335 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17336         LDKChannelMonitor this_obj_conv;
17337         this_obj_conv.inner = (void*)(this_obj & (~1));
17338         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17339         ChannelMonitor_free(this_obj_conv);
17340 }
17341
17342 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17343         LDKChannelMonitor orig_conv;
17344         orig_conv.inner = (void*)(orig & (~1));
17345         orig_conv.is_owned = false;
17346         LDKChannelMonitor ret_var = ChannelMonitor_clone(&orig_conv);
17347         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17348         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17349         uint64_t ret_ref = (uint64_t)ret_var.inner;
17350         if (ret_var.is_owned) {
17351                 ret_ref |= 1;
17352         }
17353         return ret_ref;
17354 }
17355
17356 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1write(JNIEnv *env, jclass clz, int64_t obj) {
17357         LDKChannelMonitor obj_conv;
17358         obj_conv.inner = (void*)(obj & (~1));
17359         obj_conv.is_owned = false;
17360         LDKCVec_u8Z ret_var = ChannelMonitor_write(&obj_conv);
17361         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17362         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17363         CVec_u8Z_free(ret_var);
17364         return ret_arr;
17365 }
17366
17367 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) {
17368         LDKChannelMonitor this_arg_conv;
17369         this_arg_conv.inner = (void*)(this_arg & (~1));
17370         this_arg_conv.is_owned = false;
17371         LDKChannelMonitorUpdate updates_conv;
17372         updates_conv.inner = (void*)(updates & (~1));
17373         updates_conv.is_owned = false;
17374         LDKBroadcasterInterface* broadcaster_conv = (LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
17375         LDKFeeEstimator* fee_estimator_conv = (LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
17376         LDKLogger* logger_conv = (LDKLogger*)(((uint64_t)logger) & ~1);
17377         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
17378         *ret_conv = ChannelMonitor_update_monitor(&this_arg_conv, &updates_conv, broadcaster_conv, fee_estimator_conv, logger_conv);
17379         return (uint64_t)ret_conv;
17380 }
17381
17382 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1latest_1update_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
17383         LDKChannelMonitor this_arg_conv;
17384         this_arg_conv.inner = (void*)(this_arg & (~1));
17385         this_arg_conv.is_owned = false;
17386         int64_t ret_val = ChannelMonitor_get_latest_update_id(&this_arg_conv);
17387         return ret_val;
17388 }
17389
17390 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_arg) {
17391         LDKChannelMonitor this_arg_conv;
17392         this_arg_conv.inner = (void*)(this_arg & (~1));
17393         this_arg_conv.is_owned = false;
17394         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
17395         *ret_conv = ChannelMonitor_get_funding_txo(&this_arg_conv);
17396         return ((uint64_t)ret_conv);
17397 }
17398
17399 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1outputs_1to_1watch(JNIEnv *env, jclass clz, int64_t this_arg) {
17400         LDKChannelMonitor this_arg_conv;
17401         this_arg_conv.inner = (void*)(this_arg & (~1));
17402         this_arg_conv.is_owned = false;
17403         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ ret_var = ChannelMonitor_get_outputs_to_watch(&this_arg_conv);
17404         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
17405         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
17406         for (size_t o = 0; o < ret_var.datalen; o++) {
17407                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv_40_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
17408                 *ret_conv_40_conv = ret_var.data[o];
17409                 ret_arr_ptr[o] = ((uint64_t)ret_conv_40_conv);
17410         }
17411         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
17412         FREE(ret_var.data);
17413         return ret_arr;
17414 }
17415
17416 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1load_1outputs_1to_1watch(JNIEnv *env, jclass clz, int64_t this_arg, int64_t filter) {
17417         LDKChannelMonitor this_arg_conv;
17418         this_arg_conv.inner = (void*)(this_arg & (~1));
17419         this_arg_conv.is_owned = false;
17420         LDKFilter* filter_conv = (LDKFilter*)(((uint64_t)filter) & ~1);
17421         ChannelMonitor_load_outputs_to_watch(&this_arg_conv, filter_conv);
17422 }
17423
17424 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1and_1clear_1pending_1monitor_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
17425         LDKChannelMonitor this_arg_conv;
17426         this_arg_conv.inner = (void*)(this_arg & (~1));
17427         this_arg_conv.is_owned = false;
17428         LDKCVec_MonitorEventZ ret_var = ChannelMonitor_get_and_clear_pending_monitor_events(&this_arg_conv);
17429         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
17430         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
17431         for (size_t o = 0; o < ret_var.datalen; o++) {
17432                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
17433                 *ret_conv_14_copy = MonitorEvent_clone(&ret_var.data[o]);
17434                 uint64_t ret_conv_14_ref = (uint64_t)ret_conv_14_copy;
17435                 ret_arr_ptr[o] = ret_conv_14_ref;
17436         }
17437         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
17438         FREE(ret_var.data);
17439         return ret_arr;
17440 }
17441
17442 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1and_1clear_1pending_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
17443         LDKChannelMonitor this_arg_conv;
17444         this_arg_conv.inner = (void*)(this_arg & (~1));
17445         this_arg_conv.is_owned = false;
17446         LDKCVec_EventZ ret_var = ChannelMonitor_get_and_clear_pending_events(&this_arg_conv);
17447         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
17448         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
17449         for (size_t h = 0; h < ret_var.datalen; h++) {
17450                 LDKEvent *ret_conv_7_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
17451                 *ret_conv_7_copy = Event_clone(&ret_var.data[h]);
17452                 uint64_t ret_conv_7_ref = (uint64_t)ret_conv_7_copy;
17453                 ret_arr_ptr[h] = ret_conv_7_ref;
17454         }
17455         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
17456         FREE(ret_var.data);
17457         return ret_arr;
17458 }
17459
17460 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) {
17461         LDKChannelMonitor this_arg_conv;
17462         this_arg_conv.inner = (void*)(this_arg & (~1));
17463         this_arg_conv.is_owned = false;
17464         LDKLogger* logger_conv = (LDKLogger*)(((uint64_t)logger) & ~1);
17465         LDKCVec_TransactionZ ret_var = ChannelMonitor_get_latest_holder_commitment_txn(&this_arg_conv, logger_conv);
17466         jobjectArray ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
17467         ;
17468         for (size_t i = 0; i < ret_var.datalen; i++) {
17469                 LDKTransaction ret_conv_8_var = ret_var.data[i];
17470                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, ret_conv_8_var.datalen);
17471                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, ret_conv_8_var.datalen, ret_conv_8_var.data);
17472                 Transaction_free(ret_conv_8_var);
17473                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
17474         }
17475         FREE(ret_var.data);
17476         return ret_arr;
17477 }
17478
17479 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) {
17480         LDKChannelMonitor this_arg_conv;
17481         this_arg_conv.inner = (void*)(this_arg & (~1));
17482         this_arg_conv.is_owned = false;
17483         unsigned char header_arr[80];
17484         CHECK((*env)->GetArrayLength(env, header) == 80);
17485         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
17486         unsigned char (*header_ref)[80] = &header_arr;
17487         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
17488         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
17489         if (txdata_constr.datalen > 0)
17490                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
17491         else
17492                 txdata_constr.data = NULL;
17493         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
17494         for (size_t c = 0; c < txdata_constr.datalen; c++) {
17495                 int64_t txdata_conv_28 = txdata_vals[c];
17496                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_28) & ~1);
17497                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_28) & ~1));
17498                 txdata_constr.data[c] = txdata_conv_28_conv;
17499         }
17500         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
17501         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
17502         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
17503                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
17504                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
17505         }
17506         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
17507         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
17508                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
17509                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
17510         }
17511         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
17512         if (logger_conv.free == LDKLogger_JCalls_free) {
17513                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
17514                 LDKLogger_JCalls_cloned(&logger_conv);
17515         }
17516         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);
17517         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
17518         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
17519         for (size_t n = 0; n < ret_var.datalen; n++) {
17520                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
17521                 *ret_conv_39_conv = ret_var.data[n];
17522                 ret_arr_ptr[n] = ((uint64_t)ret_conv_39_conv);
17523         }
17524         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
17525         FREE(ret_var.data);
17526         return ret_arr;
17527 }
17528
17529 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) {
17530         LDKChannelMonitor this_arg_conv;
17531         this_arg_conv.inner = (void*)(this_arg & (~1));
17532         this_arg_conv.is_owned = false;
17533         unsigned char header_arr[80];
17534         CHECK((*env)->GetArrayLength(env, header) == 80);
17535         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
17536         unsigned char (*header_ref)[80] = &header_arr;
17537         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
17538         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
17539                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
17540                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
17541         }
17542         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
17543         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
17544                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
17545                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
17546         }
17547         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
17548         if (logger_conv.free == LDKLogger_JCalls_free) {
17549                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
17550                 LDKLogger_JCalls_cloned(&logger_conv);
17551         }
17552         ChannelMonitor_block_disconnected(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
17553 }
17554
17555 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) {
17556         LDKChannelMonitor this_arg_conv;
17557         this_arg_conv.inner = (void*)(this_arg & (~1));
17558         this_arg_conv.is_owned = false;
17559         unsigned char header_arr[80];
17560         CHECK((*env)->GetArrayLength(env, header) == 80);
17561         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
17562         unsigned char (*header_ref)[80] = &header_arr;
17563         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
17564         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
17565         if (txdata_constr.datalen > 0)
17566                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
17567         else
17568                 txdata_constr.data = NULL;
17569         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
17570         for (size_t c = 0; c < txdata_constr.datalen; c++) {
17571                 int64_t txdata_conv_28 = txdata_vals[c];
17572                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_28) & ~1);
17573                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_28) & ~1));
17574                 txdata_constr.data[c] = txdata_conv_28_conv;
17575         }
17576         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
17577         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
17578         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
17579                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
17580                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
17581         }
17582         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
17583         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
17584                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
17585                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
17586         }
17587         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
17588         if (logger_conv.free == LDKLogger_JCalls_free) {
17589                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
17590                 LDKLogger_JCalls_cloned(&logger_conv);
17591         }
17592         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);
17593         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
17594         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
17595         for (size_t n = 0; n < ret_var.datalen; n++) {
17596                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
17597                 *ret_conv_39_conv = ret_var.data[n];
17598                 ret_arr_ptr[n] = ((uint64_t)ret_conv_39_conv);
17599         }
17600         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
17601         FREE(ret_var.data);
17602         return ret_arr;
17603 }
17604
17605 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) {
17606         LDKChannelMonitor this_arg_conv;
17607         this_arg_conv.inner = (void*)(this_arg & (~1));
17608         this_arg_conv.is_owned = false;
17609         unsigned char txid_arr[32];
17610         CHECK((*env)->GetArrayLength(env, txid) == 32);
17611         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
17612         unsigned char (*txid_ref)[32] = &txid_arr;
17613         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
17614         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
17615                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
17616                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
17617         }
17618         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
17619         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
17620                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
17621                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
17622         }
17623         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
17624         if (logger_conv.free == LDKLogger_JCalls_free) {
17625                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
17626                 LDKLogger_JCalls_cloned(&logger_conv);
17627         }
17628         ChannelMonitor_transaction_unconfirmed(&this_arg_conv, txid_ref, broadcaster_conv, fee_estimator_conv, logger_conv);
17629 }
17630
17631 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) {
17632         LDKChannelMonitor this_arg_conv;
17633         this_arg_conv.inner = (void*)(this_arg & (~1));
17634         this_arg_conv.is_owned = false;
17635         unsigned char header_arr[80];
17636         CHECK((*env)->GetArrayLength(env, header) == 80);
17637         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
17638         unsigned char (*header_ref)[80] = &header_arr;
17639         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
17640         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
17641                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
17642                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
17643         }
17644         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
17645         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
17646                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
17647                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
17648         }
17649         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
17650         if (logger_conv.free == LDKLogger_JCalls_free) {
17651                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
17652                 LDKLogger_JCalls_cloned(&logger_conv);
17653         }
17654         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ ret_var = ChannelMonitor_best_block_updated(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
17655         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
17656         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
17657         for (size_t n = 0; n < ret_var.datalen; n++) {
17658                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
17659                 *ret_conv_39_conv = ret_var.data[n];
17660                 ret_arr_ptr[n] = ((uint64_t)ret_conv_39_conv);
17661         }
17662         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
17663         FREE(ret_var.data);
17664         return ret_arr;
17665 }
17666
17667 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1relevant_1txids(JNIEnv *env, jclass clz, int64_t this_arg) {
17668         LDKChannelMonitor this_arg_conv;
17669         this_arg_conv.inner = (void*)(this_arg & (~1));
17670         this_arg_conv.is_owned = false;
17671         LDKCVec_TxidZ ret_var = ChannelMonitor_get_relevant_txids(&this_arg_conv);
17672         jobjectArray ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
17673         ;
17674         for (size_t i = 0; i < ret_var.datalen; i++) {
17675                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 32);
17676                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 32, ret_var.data[i].data);
17677                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
17678         }
17679         FREE(ret_var.data);
17680         return ret_arr;
17681 }
17682
17683 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1current_1best_1block(JNIEnv *env, jclass clz, int64_t this_arg) {
17684         LDKChannelMonitor this_arg_conv;
17685         this_arg_conv.inner = (void*)(this_arg & (~1));
17686         this_arg_conv.is_owned = false;
17687         LDKBestBlock ret_var = ChannelMonitor_current_best_block(&this_arg_conv);
17688         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17689         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17690         uint64_t ret_ref = (uint64_t)ret_var.inner;
17691         if (ret_var.is_owned) {
17692                 ret_ref |= 1;
17693         }
17694         return ret_ref;
17695 }
17696
17697 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1claimable_1balances(JNIEnv *env, jclass clz, int64_t this_arg) {
17698         LDKChannelMonitor this_arg_conv;
17699         this_arg_conv.inner = (void*)(this_arg & (~1));
17700         this_arg_conv.is_owned = false;
17701         LDKCVec_BalanceZ ret_var = ChannelMonitor_get_claimable_balances(&this_arg_conv);
17702         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
17703         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
17704         for (size_t j = 0; j < ret_var.datalen; j++) {
17705                 LDKBalance *ret_conv_9_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
17706                 *ret_conv_9_copy = Balance_clone(&ret_var.data[j]);
17707                 uint64_t ret_conv_9_ref = (uint64_t)ret_conv_9_copy;
17708                 ret_arr_ptr[j] = ret_conv_9_ref;
17709         }
17710         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
17711         FREE(ret_var.data);
17712         return ret_arr;
17713 }
17714
17715 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
17716         LDKu8slice ser_ref;
17717         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17718         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17719         LDKKeysInterface* arg_conv = (LDKKeysInterface*)(((uint64_t)arg) & ~1);
17720         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
17721         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_read(ser_ref, arg_conv);
17722         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17723         return (uint64_t)ret_conv;
17724 }
17725
17726 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17727         LDKOutPoint this_obj_conv;
17728         this_obj_conv.inner = (void*)(this_obj & (~1));
17729         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17730         OutPoint_free(this_obj_conv);
17731 }
17732
17733 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1get_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
17734         LDKOutPoint this_ptr_conv;
17735         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17736         this_ptr_conv.is_owned = false;
17737         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
17738         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OutPoint_get_txid(&this_ptr_conv));
17739         return ret_arr;
17740 }
17741
17742 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1set_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17743         LDKOutPoint this_ptr_conv;
17744         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17745         this_ptr_conv.is_owned = false;
17746         LDKThirtyTwoBytes val_ref;
17747         CHECK((*env)->GetArrayLength(env, val) == 32);
17748         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
17749         OutPoint_set_txid(&this_ptr_conv, val_ref);
17750 }
17751
17752 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1get_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
17753         LDKOutPoint this_ptr_conv;
17754         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17755         this_ptr_conv.is_owned = false;
17756         int16_t ret_val = OutPoint_get_index(&this_ptr_conv);
17757         return ret_val;
17758 }
17759
17760 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1set_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
17761         LDKOutPoint this_ptr_conv;
17762         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17763         this_ptr_conv.is_owned = false;
17764         OutPoint_set_index(&this_ptr_conv, val);
17765 }
17766
17767 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1new(JNIEnv *env, jclass clz, int8_tArray txid_arg, int16_t index_arg) {
17768         LDKThirtyTwoBytes txid_arg_ref;
17769         CHECK((*env)->GetArrayLength(env, txid_arg) == 32);
17770         (*env)->GetByteArrayRegion(env, txid_arg, 0, 32, txid_arg_ref.data);
17771         LDKOutPoint ret_var = OutPoint_new(txid_arg_ref, index_arg);
17772         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17773         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17774         uint64_t ret_ref = (uint64_t)ret_var.inner;
17775         if (ret_var.is_owned) {
17776                 ret_ref |= 1;
17777         }
17778         return ret_ref;
17779 }
17780
17781 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17782         LDKOutPoint orig_conv;
17783         orig_conv.inner = (void*)(orig & (~1));
17784         orig_conv.is_owned = false;
17785         LDKOutPoint ret_var = OutPoint_clone(&orig_conv);
17786         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17787         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17788         uint64_t ret_ref = (uint64_t)ret_var.inner;
17789         if (ret_var.is_owned) {
17790                 ret_ref |= 1;
17791         }
17792         return ret_ref;
17793 }
17794
17795 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_OutPoint_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
17796         LDKOutPoint a_conv;
17797         a_conv.inner = (void*)(a & (~1));
17798         a_conv.is_owned = false;
17799         LDKOutPoint b_conv;
17800         b_conv.inner = (void*)(b & (~1));
17801         b_conv.is_owned = false;
17802         jboolean ret_val = OutPoint_eq(&a_conv, &b_conv);
17803         return ret_val;
17804 }
17805
17806 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1hash(JNIEnv *env, jclass clz, int64_t o) {
17807         LDKOutPoint o_conv;
17808         o_conv.inner = (void*)(o & (~1));
17809         o_conv.is_owned = false;
17810         int64_t ret_val = OutPoint_hash(&o_conv);
17811         return ret_val;
17812 }
17813
17814 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1to_1channel_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
17815         LDKOutPoint this_arg_conv;
17816         this_arg_conv.inner = (void*)(this_arg & (~1));
17817         this_arg_conv.is_owned = false;
17818         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
17819         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, OutPoint_to_channel_id(&this_arg_conv).data);
17820         return ret_arr;
17821 }
17822
17823 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1write(JNIEnv *env, jclass clz, int64_t obj) {
17824         LDKOutPoint obj_conv;
17825         obj_conv.inner = (void*)(obj & (~1));
17826         obj_conv.is_owned = false;
17827         LDKCVec_u8Z ret_var = OutPoint_write(&obj_conv);
17828         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17829         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17830         CVec_u8Z_free(ret_var);
17831         return ret_arr;
17832 }
17833
17834 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17835         LDKu8slice ser_ref;
17836         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17837         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17838         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
17839         *ret_conv = OutPoint_read(ser_ref);
17840         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17841         return (uint64_t)ret_conv;
17842 }
17843
17844 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17845         LDKDelayedPaymentOutputDescriptor this_obj_conv;
17846         this_obj_conv.inner = (void*)(this_obj & (~1));
17847         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17848         DelayedPaymentOutputDescriptor_free(this_obj_conv);
17849 }
17850
17851 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
17852         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
17853         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17854         this_ptr_conv.is_owned = false;
17855         LDKOutPoint ret_var = DelayedPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
17856         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17857         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17858         uint64_t ret_ref = (uint64_t)ret_var.inner;
17859         if (ret_var.is_owned) {
17860                 ret_ref |= 1;
17861         }
17862         return ret_ref;
17863 }
17864
17865 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17866         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
17867         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17868         this_ptr_conv.is_owned = false;
17869         LDKOutPoint val_conv;
17870         val_conv.inner = (void*)(val & (~1));
17871         val_conv.is_owned = (val & 1) || (val == 0);
17872         val_conv = OutPoint_clone(&val_conv);
17873         DelayedPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
17874 }
17875
17876 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
17877         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
17878         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17879         this_ptr_conv.is_owned = false;
17880         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
17881         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DelayedPaymentOutputDescriptor_get_per_commitment_point(&this_ptr_conv).compressed_form);
17882         return ret_arr;
17883 }
17884
17885 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17886         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
17887         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17888         this_ptr_conv.is_owned = false;
17889         LDKPublicKey val_ref;
17890         CHECK((*env)->GetArrayLength(env, val) == 33);
17891         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
17892         DelayedPaymentOutputDescriptor_set_per_commitment_point(&this_ptr_conv, val_ref);
17893 }
17894
17895 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
17896         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
17897         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17898         this_ptr_conv.is_owned = false;
17899         int16_t ret_val = DelayedPaymentOutputDescriptor_get_to_self_delay(&this_ptr_conv);
17900         return ret_val;
17901 }
17902
17903 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
17904         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
17905         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17906         this_ptr_conv.is_owned = false;
17907         DelayedPaymentOutputDescriptor_set_to_self_delay(&this_ptr_conv, val);
17908 }
17909
17910 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1output(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17911         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
17912         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17913         this_ptr_conv.is_owned = false;
17914         LDKTxOut val_conv = *(LDKTxOut*)(((uint64_t)val) & ~1);
17915         val_conv = TxOut_clone((LDKTxOut*)(((uint64_t)val) & ~1));
17916         DelayedPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
17917 }
17918
17919 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1revocation_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
17920         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
17921         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17922         this_ptr_conv.is_owned = false;
17923         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
17924         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DelayedPaymentOutputDescriptor_get_revocation_pubkey(&this_ptr_conv).compressed_form);
17925         return ret_arr;
17926 }
17927
17928 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1revocation_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17929         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
17930         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17931         this_ptr_conv.is_owned = false;
17932         LDKPublicKey val_ref;
17933         CHECK((*env)->GetArrayLength(env, val) == 33);
17934         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
17935         DelayedPaymentOutputDescriptor_set_revocation_pubkey(&this_ptr_conv, val_ref);
17936 }
17937
17938 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
17939         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
17940         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17941         this_ptr_conv.is_owned = false;
17942         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
17943         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *DelayedPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv));
17944         return ret_arr;
17945 }
17946
17947 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17948         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
17949         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17950         this_ptr_conv.is_owned = false;
17951         LDKThirtyTwoBytes val_ref;
17952         CHECK((*env)->GetArrayLength(env, val) == 32);
17953         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
17954         DelayedPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
17955 }
17956
17957 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
17958         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
17959         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17960         this_ptr_conv.is_owned = false;
17961         int64_t ret_val = DelayedPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
17962         return ret_val;
17963 }
17964
17965 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17966         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
17967         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17968         this_ptr_conv.is_owned = false;
17969         DelayedPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
17970 }
17971
17972 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) {
17973         LDKOutPoint outpoint_arg_conv;
17974         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
17975         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
17976         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
17977         LDKPublicKey per_commitment_point_arg_ref;
17978         CHECK((*env)->GetArrayLength(env, per_commitment_point_arg) == 33);
17979         (*env)->GetByteArrayRegion(env, per_commitment_point_arg, 0, 33, per_commitment_point_arg_ref.compressed_form);
17980         LDKTxOut output_arg_conv = *(LDKTxOut*)(((uint64_t)output_arg) & ~1);
17981         output_arg_conv = TxOut_clone((LDKTxOut*)(((uint64_t)output_arg) & ~1));
17982         LDKPublicKey revocation_pubkey_arg_ref;
17983         CHECK((*env)->GetArrayLength(env, revocation_pubkey_arg) == 33);
17984         (*env)->GetByteArrayRegion(env, revocation_pubkey_arg, 0, 33, revocation_pubkey_arg_ref.compressed_form);
17985         LDKThirtyTwoBytes channel_keys_id_arg_ref;
17986         CHECK((*env)->GetArrayLength(env, channel_keys_id_arg) == 32);
17987         (*env)->GetByteArrayRegion(env, channel_keys_id_arg, 0, 32, channel_keys_id_arg_ref.data);
17988         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);
17989         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17990         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17991         uint64_t ret_ref = (uint64_t)ret_var.inner;
17992         if (ret_var.is_owned) {
17993                 ret_ref |= 1;
17994         }
17995         return ret_ref;
17996 }
17997
17998 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17999         LDKDelayedPaymentOutputDescriptor orig_conv;
18000         orig_conv.inner = (void*)(orig & (~1));
18001         orig_conv.is_owned = false;
18002         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(&orig_conv);
18003         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18004         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18005         uint64_t ret_ref = (uint64_t)ret_var.inner;
18006         if (ret_var.is_owned) {
18007                 ret_ref |= 1;
18008         }
18009         return ret_ref;
18010 }
18011
18012 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
18013         LDKDelayedPaymentOutputDescriptor obj_conv;
18014         obj_conv.inner = (void*)(obj & (~1));
18015         obj_conv.is_owned = false;
18016         LDKCVec_u8Z ret_var = DelayedPaymentOutputDescriptor_write(&obj_conv);
18017         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
18018         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
18019         CVec_u8Z_free(ret_var);
18020         return ret_arr;
18021 }
18022
18023 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
18024         LDKu8slice ser_ref;
18025         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
18026         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
18027         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
18028         *ret_conv = DelayedPaymentOutputDescriptor_read(ser_ref);
18029         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
18030         return (uint64_t)ret_conv;
18031 }
18032
18033 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18034         LDKStaticPaymentOutputDescriptor this_obj_conv;
18035         this_obj_conv.inner = (void*)(this_obj & (~1));
18036         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18037         StaticPaymentOutputDescriptor_free(this_obj_conv);
18038 }
18039
18040 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
18041         LDKStaticPaymentOutputDescriptor this_ptr_conv;
18042         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18043         this_ptr_conv.is_owned = false;
18044         LDKOutPoint ret_var = StaticPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
18045         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18046         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18047         uint64_t ret_ref = (uint64_t)ret_var.inner;
18048         if (ret_var.is_owned) {
18049                 ret_ref |= 1;
18050         }
18051         return ret_ref;
18052 }
18053
18054 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18055         LDKStaticPaymentOutputDescriptor this_ptr_conv;
18056         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18057         this_ptr_conv.is_owned = false;
18058         LDKOutPoint val_conv;
18059         val_conv.inner = (void*)(val & (~1));
18060         val_conv.is_owned = (val & 1) || (val == 0);
18061         val_conv = OutPoint_clone(&val_conv);
18062         StaticPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
18063 }
18064
18065 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1output(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18066         LDKStaticPaymentOutputDescriptor this_ptr_conv;
18067         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18068         this_ptr_conv.is_owned = false;
18069         LDKTxOut val_conv = *(LDKTxOut*)(((uint64_t)val) & ~1);
18070         val_conv = TxOut_clone((LDKTxOut*)(((uint64_t)val) & ~1));
18071         StaticPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
18072 }
18073
18074 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18075         LDKStaticPaymentOutputDescriptor this_ptr_conv;
18076         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18077         this_ptr_conv.is_owned = false;
18078         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18079         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *StaticPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv));
18080         return ret_arr;
18081 }
18082
18083 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18084         LDKStaticPaymentOutputDescriptor this_ptr_conv;
18085         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18086         this_ptr_conv.is_owned = false;
18087         LDKThirtyTwoBytes val_ref;
18088         CHECK((*env)->GetArrayLength(env, val) == 32);
18089         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18090         StaticPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
18091 }
18092
18093 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
18094         LDKStaticPaymentOutputDescriptor this_ptr_conv;
18095         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18096         this_ptr_conv.is_owned = false;
18097         int64_t ret_val = StaticPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
18098         return ret_val;
18099 }
18100
18101 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18102         LDKStaticPaymentOutputDescriptor this_ptr_conv;
18103         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18104         this_ptr_conv.is_owned = false;
18105         StaticPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
18106 }
18107
18108 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) {
18109         LDKOutPoint outpoint_arg_conv;
18110         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
18111         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
18112         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
18113         LDKTxOut output_arg_conv = *(LDKTxOut*)(((uint64_t)output_arg) & ~1);
18114         output_arg_conv = TxOut_clone((LDKTxOut*)(((uint64_t)output_arg) & ~1));
18115         LDKThirtyTwoBytes channel_keys_id_arg_ref;
18116         CHECK((*env)->GetArrayLength(env, channel_keys_id_arg) == 32);
18117         (*env)->GetByteArrayRegion(env, channel_keys_id_arg, 0, 32, channel_keys_id_arg_ref.data);
18118         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_new(outpoint_arg_conv, output_arg_conv, channel_keys_id_arg_ref, channel_value_satoshis_arg);
18119         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18120         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18121         uint64_t ret_ref = (uint64_t)ret_var.inner;
18122         if (ret_var.is_owned) {
18123                 ret_ref |= 1;
18124         }
18125         return ret_ref;
18126 }
18127
18128 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18129         LDKStaticPaymentOutputDescriptor orig_conv;
18130         orig_conv.inner = (void*)(orig & (~1));
18131         orig_conv.is_owned = false;
18132         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(&orig_conv);
18133         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18134         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18135         uint64_t ret_ref = (uint64_t)ret_var.inner;
18136         if (ret_var.is_owned) {
18137                 ret_ref |= 1;
18138         }
18139         return ret_ref;
18140 }
18141
18142 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
18143         LDKStaticPaymentOutputDescriptor obj_conv;
18144         obj_conv.inner = (void*)(obj & (~1));
18145         obj_conv.is_owned = false;
18146         LDKCVec_u8Z ret_var = StaticPaymentOutputDescriptor_write(&obj_conv);
18147         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
18148         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
18149         CVec_u8Z_free(ret_var);
18150         return ret_arr;
18151 }
18152
18153 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
18154         LDKu8slice ser_ref;
18155         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
18156         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
18157         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
18158         *ret_conv = StaticPaymentOutputDescriptor_read(ser_ref);
18159         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
18160         return (uint64_t)ret_conv;
18161 }
18162
18163 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
18164         if ((this_ptr & 1) != 0) return;
18165         LDKSpendableOutputDescriptor this_ptr_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)this_ptr) & ~1);
18166         FREE((void*)this_ptr);
18167         SpendableOutputDescriptor_free(this_ptr_conv);
18168 }
18169
18170 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18171         LDKSpendableOutputDescriptor* orig_conv = (LDKSpendableOutputDescriptor*)orig;
18172         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
18173         *ret_copy = SpendableOutputDescriptor_clone(orig_conv);
18174         uint64_t ret_ref = (uint64_t)ret_copy;
18175         return ret_ref;
18176 }
18177
18178 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1static_1output(JNIEnv *env, jclass clz, int64_t outpoint, int64_t output) {
18179         LDKOutPoint outpoint_conv;
18180         outpoint_conv.inner = (void*)(outpoint & (~1));
18181         outpoint_conv.is_owned = (outpoint & 1) || (outpoint == 0);
18182         outpoint_conv = OutPoint_clone(&outpoint_conv);
18183         LDKTxOut output_conv = *(LDKTxOut*)(((uint64_t)output) & ~1);
18184         output_conv = TxOut_clone((LDKTxOut*)(((uint64_t)output) & ~1));
18185         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
18186         *ret_copy = SpendableOutputDescriptor_static_output(outpoint_conv, output_conv);
18187         uint64_t ret_ref = (uint64_t)ret_copy;
18188         return ret_ref;
18189 }
18190
18191 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1delayed_1payment_1output(JNIEnv *env, jclass clz, int64_t a) {
18192         LDKDelayedPaymentOutputDescriptor a_conv;
18193         a_conv.inner = (void*)(a & (~1));
18194         a_conv.is_owned = (a & 1) || (a == 0);
18195         a_conv = DelayedPaymentOutputDescriptor_clone(&a_conv);
18196         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
18197         *ret_copy = SpendableOutputDescriptor_delayed_payment_output(a_conv);
18198         uint64_t ret_ref = (uint64_t)ret_copy;
18199         return ret_ref;
18200 }
18201
18202 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1static_1payment_1output(JNIEnv *env, jclass clz, int64_t a) {
18203         LDKStaticPaymentOutputDescriptor a_conv;
18204         a_conv.inner = (void*)(a & (~1));
18205         a_conv.is_owned = (a & 1) || (a == 0);
18206         a_conv = StaticPaymentOutputDescriptor_clone(&a_conv);
18207         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
18208         *ret_copy = SpendableOutputDescriptor_static_payment_output(a_conv);
18209         uint64_t ret_ref = (uint64_t)ret_copy;
18210         return ret_ref;
18211 }
18212
18213 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
18214         LDKSpendableOutputDescriptor* obj_conv = (LDKSpendableOutputDescriptor*)obj;
18215         LDKCVec_u8Z ret_var = SpendableOutputDescriptor_write(obj_conv);
18216         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
18217         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
18218         CVec_u8Z_free(ret_var);
18219         return ret_arr;
18220 }
18221
18222 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
18223         LDKu8slice ser_ref;
18224         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
18225         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
18226         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
18227         *ret_conv = SpendableOutputDescriptor_read(ser_ref);
18228         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
18229         return (uint64_t)ret_conv;
18230 }
18231
18232 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BaseSign_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
18233         if ((this_ptr & 1) != 0) return;
18234         LDKBaseSign this_ptr_conv = *(LDKBaseSign*)(((uint64_t)this_ptr) & ~1);
18235         FREE((void*)this_ptr);
18236         BaseSign_free(this_ptr_conv);
18237 }
18238
18239 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sign_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18240         LDKSign* orig_conv = (LDKSign*)(((uint64_t)orig) & ~1);
18241         LDKSign* ret_ret =MALLOC(sizeof(LDKSign), "LDKSign");
18242         *ret_ret = Sign_clone(orig_conv);
18243         return (uint64_t)ret_ret;
18244 }
18245
18246 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Sign_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
18247         if ((this_ptr & 1) != 0) return;
18248         LDKSign this_ptr_conv = *(LDKSign*)(((uint64_t)this_ptr) & ~1);
18249         FREE((void*)this_ptr);
18250         Sign_free(this_ptr_conv);
18251 }
18252
18253 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_KeysInterface_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
18254         if ((this_ptr & 1) != 0) return;
18255         LDKKeysInterface this_ptr_conv = *(LDKKeysInterface*)(((uint64_t)this_ptr) & ~1);
18256         FREE((void*)this_ptr);
18257         KeysInterface_free(this_ptr_conv);
18258 }
18259
18260 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18261         LDKInMemorySigner this_obj_conv;
18262         this_obj_conv.inner = (void*)(this_obj & (~1));
18263         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18264         InMemorySigner_free(this_obj_conv);
18265 }
18266
18267 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1funding_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
18268         LDKInMemorySigner this_ptr_conv;
18269         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18270         this_ptr_conv.is_owned = false;
18271         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18272         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_funding_key(&this_ptr_conv));
18273         return ret_arr;
18274 }
18275
18276 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1funding_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18277         LDKInMemorySigner this_ptr_conv;
18278         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18279         this_ptr_conv.is_owned = false;
18280         LDKSecretKey val_ref;
18281         CHECK((*env)->GetArrayLength(env, val) == 32);
18282         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
18283         InMemorySigner_set_funding_key(&this_ptr_conv, val_ref);
18284 }
18285
18286 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1revocation_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
18287         LDKInMemorySigner this_ptr_conv;
18288         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18289         this_ptr_conv.is_owned = false;
18290         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18291         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_revocation_base_key(&this_ptr_conv));
18292         return ret_arr;
18293 }
18294
18295 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1revocation_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18296         LDKInMemorySigner this_ptr_conv;
18297         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18298         this_ptr_conv.is_owned = false;
18299         LDKSecretKey val_ref;
18300         CHECK((*env)->GetArrayLength(env, val) == 32);
18301         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
18302         InMemorySigner_set_revocation_base_key(&this_ptr_conv, val_ref);
18303 }
18304
18305 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
18306         LDKInMemorySigner this_ptr_conv;
18307         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18308         this_ptr_conv.is_owned = false;
18309         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18310         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_payment_key(&this_ptr_conv));
18311         return ret_arr;
18312 }
18313
18314 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18315         LDKInMemorySigner this_ptr_conv;
18316         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18317         this_ptr_conv.is_owned = false;
18318         LDKSecretKey val_ref;
18319         CHECK((*env)->GetArrayLength(env, val) == 32);
18320         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
18321         InMemorySigner_set_payment_key(&this_ptr_conv, val_ref);
18322 }
18323
18324 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1delayed_1payment_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
18325         LDKInMemorySigner this_ptr_conv;
18326         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18327         this_ptr_conv.is_owned = false;
18328         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18329         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_delayed_payment_base_key(&this_ptr_conv));
18330         return ret_arr;
18331 }
18332
18333 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) {
18334         LDKInMemorySigner this_ptr_conv;
18335         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18336         this_ptr_conv.is_owned = false;
18337         LDKSecretKey val_ref;
18338         CHECK((*env)->GetArrayLength(env, val) == 32);
18339         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
18340         InMemorySigner_set_delayed_payment_base_key(&this_ptr_conv, val_ref);
18341 }
18342
18343 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1htlc_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
18344         LDKInMemorySigner this_ptr_conv;
18345         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18346         this_ptr_conv.is_owned = false;
18347         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18348         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_htlc_base_key(&this_ptr_conv));
18349         return ret_arr;
18350 }
18351
18352 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1htlc_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18353         LDKInMemorySigner this_ptr_conv;
18354         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18355         this_ptr_conv.is_owned = false;
18356         LDKSecretKey val_ref;
18357         CHECK((*env)->GetArrayLength(env, val) == 32);
18358         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
18359         InMemorySigner_set_htlc_base_key(&this_ptr_conv, val_ref);
18360 }
18361
18362 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1commitment_1seed(JNIEnv *env, jclass clz, int64_t this_ptr) {
18363         LDKInMemorySigner this_ptr_conv;
18364         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18365         this_ptr_conv.is_owned = false;
18366         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18367         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_commitment_seed(&this_ptr_conv));
18368         return ret_arr;
18369 }
18370
18371 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1commitment_1seed(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18372         LDKInMemorySigner this_ptr_conv;
18373         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18374         this_ptr_conv.is_owned = false;
18375         LDKThirtyTwoBytes val_ref;
18376         CHECK((*env)->GetArrayLength(env, val) == 32);
18377         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18378         InMemorySigner_set_commitment_seed(&this_ptr_conv, val_ref);
18379 }
18380
18381 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18382         LDKInMemorySigner orig_conv;
18383         orig_conv.inner = (void*)(orig & (~1));
18384         orig_conv.is_owned = false;
18385         LDKInMemorySigner ret_var = InMemorySigner_clone(&orig_conv);
18386         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18387         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18388         uint64_t ret_ref = (uint64_t)ret_var.inner;
18389         if (ret_var.is_owned) {
18390                 ret_ref |= 1;
18391         }
18392         return ret_ref;
18393 }
18394
18395 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) {
18396         LDKSecretKey funding_key_ref;
18397         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
18398         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_ref.bytes);
18399         LDKSecretKey revocation_base_key_ref;
18400         CHECK((*env)->GetArrayLength(env, revocation_base_key) == 32);
18401         (*env)->GetByteArrayRegion(env, revocation_base_key, 0, 32, revocation_base_key_ref.bytes);
18402         LDKSecretKey payment_key_ref;
18403         CHECK((*env)->GetArrayLength(env, payment_key) == 32);
18404         (*env)->GetByteArrayRegion(env, payment_key, 0, 32, payment_key_ref.bytes);
18405         LDKSecretKey delayed_payment_base_key_ref;
18406         CHECK((*env)->GetArrayLength(env, delayed_payment_base_key) == 32);
18407         (*env)->GetByteArrayRegion(env, delayed_payment_base_key, 0, 32, delayed_payment_base_key_ref.bytes);
18408         LDKSecretKey htlc_base_key_ref;
18409         CHECK((*env)->GetArrayLength(env, htlc_base_key) == 32);
18410         (*env)->GetByteArrayRegion(env, htlc_base_key, 0, 32, htlc_base_key_ref.bytes);
18411         LDKThirtyTwoBytes commitment_seed_ref;
18412         CHECK((*env)->GetArrayLength(env, commitment_seed) == 32);
18413         (*env)->GetByteArrayRegion(env, commitment_seed, 0, 32, commitment_seed_ref.data);
18414         LDKThirtyTwoBytes channel_keys_id_ref;
18415         CHECK((*env)->GetArrayLength(env, channel_keys_id) == 32);
18416         (*env)->GetByteArrayRegion(env, channel_keys_id, 0, 32, channel_keys_id_ref.data);
18417         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);
18418         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18419         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18420         uint64_t ret_ref = (uint64_t)ret_var.inner;
18421         if (ret_var.is_owned) {
18422                 ret_ref |= 1;
18423         }
18424         return ret_ref;
18425 }
18426
18427 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1counterparty_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
18428         LDKInMemorySigner this_arg_conv;
18429         this_arg_conv.inner = (void*)(this_arg & (~1));
18430         this_arg_conv.is_owned = false;
18431         LDKChannelPublicKeys ret_var = InMemorySigner_counterparty_pubkeys(&this_arg_conv);
18432         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18433         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18434         uint64_t ret_ref = (uint64_t)ret_var.inner;
18435         if (ret_var.is_owned) {
18436                 ret_ref |= 1;
18437         }
18438         return ret_ref;
18439 }
18440
18441 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1counterparty_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
18442         LDKInMemorySigner this_arg_conv;
18443         this_arg_conv.inner = (void*)(this_arg & (~1));
18444         this_arg_conv.is_owned = false;
18445         int16_t ret_val = InMemorySigner_counterparty_selected_contest_delay(&this_arg_conv);
18446         return ret_val;
18447 }
18448
18449 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1holder_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
18450         LDKInMemorySigner this_arg_conv;
18451         this_arg_conv.inner = (void*)(this_arg & (~1));
18452         this_arg_conv.is_owned = false;
18453         int16_t ret_val = InMemorySigner_holder_selected_contest_delay(&this_arg_conv);
18454         return ret_val;
18455 }
18456
18457 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_arg) {
18458         LDKInMemorySigner this_arg_conv;
18459         this_arg_conv.inner = (void*)(this_arg & (~1));
18460         this_arg_conv.is_owned = false;
18461         jboolean ret_val = InMemorySigner_is_outbound(&this_arg_conv);
18462         return ret_val;
18463 }
18464
18465 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_arg) {
18466         LDKInMemorySigner this_arg_conv;
18467         this_arg_conv.inner = (void*)(this_arg & (~1));
18468         this_arg_conv.is_owned = false;
18469         LDKOutPoint ret_var = InMemorySigner_funding_outpoint(&this_arg_conv);
18470         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18471         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18472         uint64_t ret_ref = (uint64_t)ret_var.inner;
18473         if (ret_var.is_owned) {
18474                 ret_ref |= 1;
18475         }
18476         return ret_ref;
18477 }
18478
18479 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1channel_1parameters(JNIEnv *env, jclass clz, int64_t this_arg) {
18480         LDKInMemorySigner this_arg_conv;
18481         this_arg_conv.inner = (void*)(this_arg & (~1));
18482         this_arg_conv.is_owned = false;
18483         LDKChannelTransactionParameters ret_var = InMemorySigner_get_channel_parameters(&this_arg_conv);
18484         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18485         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18486         uint64_t ret_ref = (uint64_t)ret_var.inner;
18487         if (ret_var.is_owned) {
18488                 ret_ref |= 1;
18489         }
18490         return ret_ref;
18491 }
18492
18493 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) {
18494         LDKInMemorySigner this_arg_conv;
18495         this_arg_conv.inner = (void*)(this_arg & (~1));
18496         this_arg_conv.is_owned = false;
18497         LDKTransaction spend_tx_ref;
18498         spend_tx_ref.datalen = (*env)->GetArrayLength(env, spend_tx);
18499         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
18500         (*env)->GetByteArrayRegion(env, spend_tx, 0, spend_tx_ref.datalen, spend_tx_ref.data);
18501         spend_tx_ref.data_is_owned = true;
18502         LDKStaticPaymentOutputDescriptor descriptor_conv;
18503         descriptor_conv.inner = (void*)(descriptor & (~1));
18504         descriptor_conv.is_owned = false;
18505         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
18506         *ret_conv = InMemorySigner_sign_counterparty_payment_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
18507         return (uint64_t)ret_conv;
18508 }
18509
18510 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) {
18511         LDKInMemorySigner this_arg_conv;
18512         this_arg_conv.inner = (void*)(this_arg & (~1));
18513         this_arg_conv.is_owned = false;
18514         LDKTransaction spend_tx_ref;
18515         spend_tx_ref.datalen = (*env)->GetArrayLength(env, spend_tx);
18516         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
18517         (*env)->GetByteArrayRegion(env, spend_tx, 0, spend_tx_ref.datalen, spend_tx_ref.data);
18518         spend_tx_ref.data_is_owned = true;
18519         LDKDelayedPaymentOutputDescriptor descriptor_conv;
18520         descriptor_conv.inner = (void*)(descriptor & (~1));
18521         descriptor_conv.is_owned = false;
18522         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
18523         *ret_conv = InMemorySigner_sign_dynamic_p2wsh_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
18524         return (uint64_t)ret_conv;
18525 }
18526
18527 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1as_1BaseSign(JNIEnv *env, jclass clz, int64_t this_arg) {
18528         LDKInMemorySigner this_arg_conv;
18529         this_arg_conv.inner = (void*)(this_arg & (~1));
18530         this_arg_conv.is_owned = false;
18531         LDKBaseSign* ret_ret =MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
18532         *ret_ret = InMemorySigner_as_BaseSign(&this_arg_conv);
18533         return (uint64_t)ret_ret;
18534 }
18535
18536 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1as_1Sign(JNIEnv *env, jclass clz, int64_t this_arg) {
18537         LDKInMemorySigner this_arg_conv;
18538         this_arg_conv.inner = (void*)(this_arg & (~1));
18539         this_arg_conv.is_owned = false;
18540         LDKSign* ret_ret =MALLOC(sizeof(LDKSign), "LDKSign");
18541         *ret_ret = InMemorySigner_as_Sign(&this_arg_conv);
18542         return (uint64_t)ret_ret;
18543 }
18544
18545 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1write(JNIEnv *env, jclass clz, int64_t obj) {
18546         LDKInMemorySigner obj_conv;
18547         obj_conv.inner = (void*)(obj & (~1));
18548         obj_conv.is_owned = false;
18549         LDKCVec_u8Z ret_var = InMemorySigner_write(&obj_conv);
18550         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
18551         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
18552         CVec_u8Z_free(ret_var);
18553         return ret_arr;
18554 }
18555
18556 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
18557         LDKu8slice ser_ref;
18558         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
18559         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
18560         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
18561         *ret_conv = InMemorySigner_read(ser_ref);
18562         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
18563         return (uint64_t)ret_conv;
18564 }
18565
18566 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_KeysManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18567         LDKKeysManager this_obj_conv;
18568         this_obj_conv.inner = (void*)(this_obj & (~1));
18569         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18570         KeysManager_free(this_obj_conv);
18571 }
18572
18573 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) {
18574         unsigned char seed_arr[32];
18575         CHECK((*env)->GetArrayLength(env, seed) == 32);
18576         (*env)->GetByteArrayRegion(env, seed, 0, 32, seed_arr);
18577         unsigned char (*seed_ref)[32] = &seed_arr;
18578         LDKKeysManager ret_var = KeysManager_new(seed_ref, starting_time_secs, starting_time_nanos);
18579         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18580         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18581         uint64_t ret_ref = (uint64_t)ret_var.inner;
18582         if (ret_var.is_owned) {
18583                 ret_ref |= 1;
18584         }
18585         return ret_ref;
18586 }
18587
18588 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) {
18589         LDKKeysManager this_arg_conv;
18590         this_arg_conv.inner = (void*)(this_arg & (~1));
18591         this_arg_conv.is_owned = false;
18592         unsigned char params_arr[32];
18593         CHECK((*env)->GetArrayLength(env, params) == 32);
18594         (*env)->GetByteArrayRegion(env, params, 0, 32, params_arr);
18595         unsigned char (*params_ref)[32] = &params_arr;
18596         LDKInMemorySigner ret_var = KeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
18597         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18598         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18599         uint64_t ret_ref = (uint64_t)ret_var.inner;
18600         if (ret_var.is_owned) {
18601                 ret_ref |= 1;
18602         }
18603         return ret_ref;
18604 }
18605
18606 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) {
18607         LDKKeysManager this_arg_conv;
18608         this_arg_conv.inner = (void*)(this_arg & (~1));
18609         this_arg_conv.is_owned = false;
18610         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
18611         descriptors_constr.datalen = (*env)->GetArrayLength(env, descriptors);
18612         if (descriptors_constr.datalen > 0)
18613                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
18614         else
18615                 descriptors_constr.data = NULL;
18616         int64_t* descriptors_vals = (*env)->GetLongArrayElements (env, descriptors, NULL);
18617         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
18618                 int64_t descriptors_conv_27 = descriptors_vals[b];
18619                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)descriptors_conv_27) & ~1);
18620                 descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uint64_t)descriptors_conv_27) & ~1));
18621                 descriptors_constr.data[b] = descriptors_conv_27_conv;
18622         }
18623         (*env)->ReleaseLongArrayElements(env, descriptors, descriptors_vals, 0);
18624         LDKCVec_TxOutZ outputs_constr;
18625         outputs_constr.datalen = (*env)->GetArrayLength(env, outputs);
18626         if (outputs_constr.datalen > 0)
18627                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
18628         else
18629                 outputs_constr.data = NULL;
18630         int64_t* outputs_vals = (*env)->GetLongArrayElements (env, outputs, NULL);
18631         for (size_t h = 0; h < outputs_constr.datalen; h++) {
18632                 int64_t outputs_conv_7 = outputs_vals[h];
18633                 LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(((uint64_t)outputs_conv_7) & ~1);
18634                 outputs_conv_7_conv = TxOut_clone((LDKTxOut*)(((uint64_t)outputs_conv_7) & ~1));
18635                 outputs_constr.data[h] = outputs_conv_7_conv;
18636         }
18637         (*env)->ReleaseLongArrayElements(env, outputs, outputs_vals, 0);
18638         LDKCVec_u8Z change_destination_script_ref;
18639         change_destination_script_ref.datalen = (*env)->GetArrayLength(env, change_destination_script);
18640         change_destination_script_ref.data = MALLOC(change_destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
18641         (*env)->GetByteArrayRegion(env, change_destination_script, 0, change_destination_script_ref.datalen, change_destination_script_ref.data);
18642         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
18643         *ret_conv = KeysManager_spend_spendable_outputs(&this_arg_conv, descriptors_constr, outputs_constr, change_destination_script_ref, feerate_sat_per_1000_weight);
18644         return (uint64_t)ret_conv;
18645 }
18646
18647 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysManager_1as_1KeysInterface(JNIEnv *env, jclass clz, int64_t this_arg) {
18648         LDKKeysManager this_arg_conv;
18649         this_arg_conv.inner = (void*)(this_arg & (~1));
18650         this_arg_conv.is_owned = false;
18651         LDKKeysInterface* ret_ret =MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
18652         *ret_ret = KeysManager_as_KeysInterface(&this_arg_conv);
18653         return (uint64_t)ret_ret;
18654 }
18655
18656 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentId_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18657         LDKPaymentId this_obj_conv;
18658         this_obj_conv.inner = (void*)(this_obj & (~1));
18659         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18660         PaymentId_free(this_obj_conv);
18661 }
18662
18663 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentId_1hash(JNIEnv *env, jclass clz, int64_t o) {
18664         LDKPaymentId o_conv;
18665         o_conv.inner = (void*)(o & (~1));
18666         o_conv.is_owned = false;
18667         int64_t ret_val = PaymentId_hash(&o_conv);
18668         return ret_val;
18669 }
18670
18671 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentId_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18672         LDKPaymentId orig_conv;
18673         orig_conv.inner = (void*)(orig & (~1));
18674         orig_conv.is_owned = false;
18675         LDKPaymentId ret_var = PaymentId_clone(&orig_conv);
18676         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18677         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18678         uint64_t ret_ref = (uint64_t)ret_var.inner;
18679         if (ret_var.is_owned) {
18680                 ret_ref |= 1;
18681         }
18682         return ret_ref;
18683 }
18684
18685 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PaymentId_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
18686         LDKPaymentId a_conv;
18687         a_conv.inner = (void*)(a & (~1));
18688         a_conv.is_owned = false;
18689         LDKPaymentId b_conv;
18690         b_conv.inner = (void*)(b & (~1));
18691         b_conv.is_owned = false;
18692         jboolean ret_val = PaymentId_eq(&a_conv, &b_conv);
18693         return ret_val;
18694 }
18695
18696 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PaymentId_1write(JNIEnv *env, jclass clz, int64_t obj) {
18697         LDKPaymentId obj_conv;
18698         obj_conv.inner = (void*)(obj & (~1));
18699         obj_conv.is_owned = false;
18700         LDKCVec_u8Z ret_var = PaymentId_write(&obj_conv);
18701         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
18702         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
18703         CVec_u8Z_free(ret_var);
18704         return ret_arr;
18705 }
18706
18707 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentId_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
18708         LDKu8slice ser_ref;
18709         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
18710         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
18711         LDKCResult_PaymentIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdDecodeErrorZ), "LDKCResult_PaymentIdDecodeErrorZ");
18712         *ret_conv = PaymentId_read(ser_ref);
18713         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
18714         return (uint64_t)ret_conv;
18715 }
18716
18717 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18718         LDKChannelManager this_obj_conv;
18719         this_obj_conv.inner = (void*)(this_obj & (~1));
18720         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18721         ChannelManager_free(this_obj_conv);
18722 }
18723
18724 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18725         LDKChainParameters this_obj_conv;
18726         this_obj_conv.inner = (void*)(this_obj & (~1));
18727         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18728         ChainParameters_free(this_obj_conv);
18729 }
18730
18731 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChainParameters_1get_1network(JNIEnv *env, jclass clz, int64_t this_ptr) {
18732         LDKChainParameters this_ptr_conv;
18733         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18734         this_ptr_conv.is_owned = false;
18735         jclass ret_conv = LDKNetwork_to_java(env, ChainParameters_get_network(&this_ptr_conv));
18736         return ret_conv;
18737 }
18738
18739 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1set_1network(JNIEnv *env, jclass clz, int64_t this_ptr, jclass val) {
18740         LDKChainParameters this_ptr_conv;
18741         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18742         this_ptr_conv.is_owned = false;
18743         LDKNetwork val_conv = LDKNetwork_from_java(env, val);
18744         ChainParameters_set_network(&this_ptr_conv, val_conv);
18745 }
18746
18747 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1get_1best_1block(JNIEnv *env, jclass clz, int64_t this_ptr) {
18748         LDKChainParameters this_ptr_conv;
18749         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18750         this_ptr_conv.is_owned = false;
18751         LDKBestBlock ret_var = ChainParameters_get_best_block(&this_ptr_conv);
18752         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18753         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18754         uint64_t ret_ref = (uint64_t)ret_var.inner;
18755         if (ret_var.is_owned) {
18756                 ret_ref |= 1;
18757         }
18758         return ret_ref;
18759 }
18760
18761 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1set_1best_1block(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18762         LDKChainParameters this_ptr_conv;
18763         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18764         this_ptr_conv.is_owned = false;
18765         LDKBestBlock val_conv;
18766         val_conv.inner = (void*)(val & (~1));
18767         val_conv.is_owned = (val & 1) || (val == 0);
18768         val_conv = BestBlock_clone(&val_conv);
18769         ChainParameters_set_best_block(&this_ptr_conv, val_conv);
18770 }
18771
18772 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1new(JNIEnv *env, jclass clz, jclass network_arg, int64_t best_block_arg) {
18773         LDKNetwork network_arg_conv = LDKNetwork_from_java(env, network_arg);
18774         LDKBestBlock best_block_arg_conv;
18775         best_block_arg_conv.inner = (void*)(best_block_arg & (~1));
18776         best_block_arg_conv.is_owned = (best_block_arg & 1) || (best_block_arg == 0);
18777         best_block_arg_conv = BestBlock_clone(&best_block_arg_conv);
18778         LDKChainParameters ret_var = ChainParameters_new(network_arg_conv, best_block_arg_conv);
18779         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18780         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18781         uint64_t ret_ref = (uint64_t)ret_var.inner;
18782         if (ret_var.is_owned) {
18783                 ret_ref |= 1;
18784         }
18785         return ret_ref;
18786 }
18787
18788 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18789         LDKChainParameters orig_conv;
18790         orig_conv.inner = (void*)(orig & (~1));
18791         orig_conv.is_owned = false;
18792         LDKChainParameters ret_var = ChainParameters_clone(&orig_conv);
18793         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18794         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18795         uint64_t ret_ref = (uint64_t)ret_var.inner;
18796         if (ret_var.is_owned) {
18797                 ret_ref |= 1;
18798         }
18799         return ret_ref;
18800 }
18801
18802 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18803         LDKCounterpartyForwardingInfo this_obj_conv;
18804         this_obj_conv.inner = (void*)(this_obj & (~1));
18805         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18806         CounterpartyForwardingInfo_free(this_obj_conv);
18807 }
18808
18809 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1get_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
18810         LDKCounterpartyForwardingInfo this_ptr_conv;
18811         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18812         this_ptr_conv.is_owned = false;
18813         int32_t ret_val = CounterpartyForwardingInfo_get_fee_base_msat(&this_ptr_conv);
18814         return ret_val;
18815 }
18816
18817 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1set_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
18818         LDKCounterpartyForwardingInfo this_ptr_conv;
18819         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18820         this_ptr_conv.is_owned = false;
18821         CounterpartyForwardingInfo_set_fee_base_msat(&this_ptr_conv, val);
18822 }
18823
18824 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1get_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
18825         LDKCounterpartyForwardingInfo this_ptr_conv;
18826         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18827         this_ptr_conv.is_owned = false;
18828         int32_t ret_val = CounterpartyForwardingInfo_get_fee_proportional_millionths(&this_ptr_conv);
18829         return ret_val;
18830 }
18831
18832 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1set_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
18833         LDKCounterpartyForwardingInfo this_ptr_conv;
18834         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18835         this_ptr_conv.is_owned = false;
18836         CounterpartyForwardingInfo_set_fee_proportional_millionths(&this_ptr_conv, val);
18837 }
18838
18839 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
18840         LDKCounterpartyForwardingInfo this_ptr_conv;
18841         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18842         this_ptr_conv.is_owned = false;
18843         int16_t ret_val = CounterpartyForwardingInfo_get_cltv_expiry_delta(&this_ptr_conv);
18844         return ret_val;
18845 }
18846
18847 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
18848         LDKCounterpartyForwardingInfo this_ptr_conv;
18849         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18850         this_ptr_conv.is_owned = false;
18851         CounterpartyForwardingInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
18852 }
18853
18854 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) {
18855         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_new(fee_base_msat_arg, fee_proportional_millionths_arg, cltv_expiry_delta_arg);
18856         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18857         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18858         uint64_t ret_ref = (uint64_t)ret_var.inner;
18859         if (ret_var.is_owned) {
18860                 ret_ref |= 1;
18861         }
18862         return ret_ref;
18863 }
18864
18865 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18866         LDKCounterpartyForwardingInfo orig_conv;
18867         orig_conv.inner = (void*)(orig & (~1));
18868         orig_conv.is_owned = false;
18869         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_clone(&orig_conv);
18870         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18871         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18872         uint64_t ret_ref = (uint64_t)ret_var.inner;
18873         if (ret_var.is_owned) {
18874                 ret_ref |= 1;
18875         }
18876         return ret_ref;
18877 }
18878
18879 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18880         LDKChannelCounterparty this_obj_conv;
18881         this_obj_conv.inner = (void*)(this_obj & (~1));
18882         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18883         ChannelCounterparty_free(this_obj_conv);
18884 }
18885
18886 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18887         LDKChannelCounterparty this_ptr_conv;
18888         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18889         this_ptr_conv.is_owned = false;
18890         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
18891         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelCounterparty_get_node_id(&this_ptr_conv).compressed_form);
18892         return ret_arr;
18893 }
18894
18895 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18896         LDKChannelCounterparty this_ptr_conv;
18897         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18898         this_ptr_conv.is_owned = false;
18899         LDKPublicKey val_ref;
18900         CHECK((*env)->GetArrayLength(env, val) == 33);
18901         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
18902         ChannelCounterparty_set_node_id(&this_ptr_conv, val_ref);
18903 }
18904
18905 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
18906         LDKChannelCounterparty this_ptr_conv;
18907         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18908         this_ptr_conv.is_owned = false;
18909         LDKInitFeatures ret_var = ChannelCounterparty_get_features(&this_ptr_conv);
18910         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18911         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18912         uint64_t ret_ref = (uint64_t)ret_var.inner;
18913         if (ret_var.is_owned) {
18914                 ret_ref |= 1;
18915         }
18916         return ret_ref;
18917 }
18918
18919 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18920         LDKChannelCounterparty this_ptr_conv;
18921         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18922         this_ptr_conv.is_owned = false;
18923         LDKInitFeatures val_conv;
18924         val_conv.inner = (void*)(val & (~1));
18925         val_conv.is_owned = (val & 1) || (val == 0);
18926         val_conv = InitFeatures_clone(&val_conv);
18927         ChannelCounterparty_set_features(&this_ptr_conv, val_conv);
18928 }
18929
18930 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr) {
18931         LDKChannelCounterparty this_ptr_conv;
18932         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18933         this_ptr_conv.is_owned = false;
18934         int64_t ret_val = ChannelCounterparty_get_unspendable_punishment_reserve(&this_ptr_conv);
18935         return ret_val;
18936 }
18937
18938 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18939         LDKChannelCounterparty this_ptr_conv;
18940         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18941         this_ptr_conv.is_owned = false;
18942         ChannelCounterparty_set_unspendable_punishment_reserve(&this_ptr_conv, val);
18943 }
18944
18945 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1forwarding_1info(JNIEnv *env, jclass clz, int64_t this_ptr) {
18946         LDKChannelCounterparty this_ptr_conv;
18947         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18948         this_ptr_conv.is_owned = false;
18949         LDKCounterpartyForwardingInfo ret_var = ChannelCounterparty_get_forwarding_info(&this_ptr_conv);
18950         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18951         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18952         uint64_t ret_ref = (uint64_t)ret_var.inner;
18953         if (ret_var.is_owned) {
18954                 ret_ref |= 1;
18955         }
18956         return ret_ref;
18957 }
18958
18959 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1forwarding_1info(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18960         LDKChannelCounterparty this_ptr_conv;
18961         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18962         this_ptr_conv.is_owned = false;
18963         LDKCounterpartyForwardingInfo val_conv;
18964         val_conv.inner = (void*)(val & (~1));
18965         val_conv.is_owned = (val & 1) || (val == 0);
18966         val_conv = CounterpartyForwardingInfo_clone(&val_conv);
18967         ChannelCounterparty_set_forwarding_info(&this_ptr_conv, val_conv);
18968 }
18969
18970 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) {
18971         LDKPublicKey node_id_arg_ref;
18972         CHECK((*env)->GetArrayLength(env, node_id_arg) == 33);
18973         (*env)->GetByteArrayRegion(env, node_id_arg, 0, 33, node_id_arg_ref.compressed_form);
18974         LDKInitFeatures features_arg_conv;
18975         features_arg_conv.inner = (void*)(features_arg & (~1));
18976         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
18977         features_arg_conv = InitFeatures_clone(&features_arg_conv);
18978         LDKCounterpartyForwardingInfo forwarding_info_arg_conv;
18979         forwarding_info_arg_conv.inner = (void*)(forwarding_info_arg & (~1));
18980         forwarding_info_arg_conv.is_owned = (forwarding_info_arg & 1) || (forwarding_info_arg == 0);
18981         forwarding_info_arg_conv = CounterpartyForwardingInfo_clone(&forwarding_info_arg_conv);
18982         LDKChannelCounterparty ret_var = ChannelCounterparty_new(node_id_arg_ref, features_arg_conv, unspendable_punishment_reserve_arg, forwarding_info_arg_conv);
18983         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18984         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18985         uint64_t ret_ref = (uint64_t)ret_var.inner;
18986         if (ret_var.is_owned) {
18987                 ret_ref |= 1;
18988         }
18989         return ret_ref;
18990 }
18991
18992 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18993         LDKChannelCounterparty orig_conv;
18994         orig_conv.inner = (void*)(orig & (~1));
18995         orig_conv.is_owned = false;
18996         LDKChannelCounterparty ret_var = ChannelCounterparty_clone(&orig_conv);
18997         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18998         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18999         uint64_t ret_ref = (uint64_t)ret_var.inner;
19000         if (ret_var.is_owned) {
19001                 ret_ref |= 1;
19002         }
19003         return ret_ref;
19004 }
19005
19006 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19007         LDKChannelDetails this_obj_conv;
19008         this_obj_conv.inner = (void*)(this_obj & (~1));
19009         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19010         ChannelDetails_free(this_obj_conv);
19011 }
19012
19013 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
19014         LDKChannelDetails this_ptr_conv;
19015         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19016         this_ptr_conv.is_owned = false;
19017         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
19018         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ChannelDetails_get_channel_id(&this_ptr_conv));
19019         return ret_arr;
19020 }
19021
19022 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19023         LDKChannelDetails this_ptr_conv;
19024         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19025         this_ptr_conv.is_owned = false;
19026         LDKThirtyTwoBytes val_ref;
19027         CHECK((*env)->GetArrayLength(env, val) == 32);
19028         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
19029         ChannelDetails_set_channel_id(&this_ptr_conv, val_ref);
19030 }
19031
19032 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1counterparty(JNIEnv *env, jclass clz, int64_t this_ptr) {
19033         LDKChannelDetails this_ptr_conv;
19034         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19035         this_ptr_conv.is_owned = false;
19036         LDKChannelCounterparty ret_var = ChannelDetails_get_counterparty(&this_ptr_conv);
19037         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19038         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19039         uint64_t ret_ref = (uint64_t)ret_var.inner;
19040         if (ret_var.is_owned) {
19041                 ret_ref |= 1;
19042         }
19043         return ret_ref;
19044 }
19045
19046 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1counterparty(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19047         LDKChannelDetails this_ptr_conv;
19048         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19049         this_ptr_conv.is_owned = false;
19050         LDKChannelCounterparty val_conv;
19051         val_conv.inner = (void*)(val & (~1));
19052         val_conv.is_owned = (val & 1) || (val == 0);
19053         val_conv = ChannelCounterparty_clone(&val_conv);
19054         ChannelDetails_set_counterparty(&this_ptr_conv, val_conv);
19055 }
19056
19057 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_ptr) {
19058         LDKChannelDetails this_ptr_conv;
19059         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19060         this_ptr_conv.is_owned = false;
19061         LDKOutPoint ret_var = ChannelDetails_get_funding_txo(&this_ptr_conv);
19062         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19063         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19064         uint64_t ret_ref = (uint64_t)ret_var.inner;
19065         if (ret_var.is_owned) {
19066                 ret_ref |= 1;
19067         }
19068         return ret_ref;
19069 }
19070
19071 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19072         LDKChannelDetails this_ptr_conv;
19073         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19074         this_ptr_conv.is_owned = false;
19075         LDKOutPoint val_conv;
19076         val_conv.inner = (void*)(val & (~1));
19077         val_conv.is_owned = (val & 1) || (val == 0);
19078         val_conv = OutPoint_clone(&val_conv);
19079         ChannelDetails_set_funding_txo(&this_ptr_conv, val_conv);
19080 }
19081
19082 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
19083         LDKChannelDetails this_ptr_conv;
19084         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19085         this_ptr_conv.is_owned = false;
19086         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
19087         *ret_copy = ChannelDetails_get_short_channel_id(&this_ptr_conv);
19088         uint64_t ret_ref = (uint64_t)ret_copy;
19089         return ret_ref;
19090 }
19091
19092 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19093         LDKChannelDetails this_ptr_conv;
19094         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19095         this_ptr_conv.is_owned = false;
19096         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
19097         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1));
19098         ChannelDetails_set_short_channel_id(&this_ptr_conv, val_conv);
19099 }
19100
19101 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
19102         LDKChannelDetails this_ptr_conv;
19103         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19104         this_ptr_conv.is_owned = false;
19105         int64_t ret_val = ChannelDetails_get_channel_value_satoshis(&this_ptr_conv);
19106         return ret_val;
19107 }
19108
19109 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19110         LDKChannelDetails this_ptr_conv;
19111         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19112         this_ptr_conv.is_owned = false;
19113         ChannelDetails_set_channel_value_satoshis(&this_ptr_conv, val);
19114 }
19115
19116 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr) {
19117         LDKChannelDetails this_ptr_conv;
19118         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19119         this_ptr_conv.is_owned = false;
19120         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
19121         *ret_copy = ChannelDetails_get_unspendable_punishment_reserve(&this_ptr_conv);
19122         uint64_t ret_ref = (uint64_t)ret_copy;
19123         return ret_ref;
19124 }
19125
19126 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19127         LDKChannelDetails this_ptr_conv;
19128         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19129         this_ptr_conv.is_owned = false;
19130         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
19131         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1));
19132         ChannelDetails_set_unspendable_punishment_reserve(&this_ptr_conv, val_conv);
19133 }
19134
19135 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1user_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
19136         LDKChannelDetails this_ptr_conv;
19137         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19138         this_ptr_conv.is_owned = false;
19139         int64_t ret_val = ChannelDetails_get_user_channel_id(&this_ptr_conv);
19140         return ret_val;
19141 }
19142
19143 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1user_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19144         LDKChannelDetails this_ptr_conv;
19145         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19146         this_ptr_conv.is_owned = false;
19147         ChannelDetails_set_user_channel_id(&this_ptr_conv, val);
19148 }
19149
19150 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1outbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
19151         LDKChannelDetails this_ptr_conv;
19152         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19153         this_ptr_conv.is_owned = false;
19154         int64_t ret_val = ChannelDetails_get_outbound_capacity_msat(&this_ptr_conv);
19155         return ret_val;
19156 }
19157
19158 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1outbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19159         LDKChannelDetails this_ptr_conv;
19160         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19161         this_ptr_conv.is_owned = false;
19162         ChannelDetails_set_outbound_capacity_msat(&this_ptr_conv, val);
19163 }
19164
19165 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
19166         LDKChannelDetails this_ptr_conv;
19167         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19168         this_ptr_conv.is_owned = false;
19169         int64_t ret_val = ChannelDetails_get_inbound_capacity_msat(&this_ptr_conv);
19170         return ret_val;
19171 }
19172
19173 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1inbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19174         LDKChannelDetails this_ptr_conv;
19175         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19176         this_ptr_conv.is_owned = false;
19177         ChannelDetails_set_inbound_capacity_msat(&this_ptr_conv, val);
19178 }
19179
19180 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1confirmations_1required(JNIEnv *env, jclass clz, int64_t this_ptr) {
19181         LDKChannelDetails this_ptr_conv;
19182         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19183         this_ptr_conv.is_owned = false;
19184         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
19185         *ret_copy = ChannelDetails_get_confirmations_required(&this_ptr_conv);
19186         uint64_t ret_ref = (uint64_t)ret_copy;
19187         return ret_ref;
19188 }
19189
19190 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1confirmations_1required(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19191         LDKChannelDetails this_ptr_conv;
19192         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19193         this_ptr_conv.is_owned = false;
19194         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(((uint64_t)val) & ~1);
19195         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uint64_t)val) & ~1));
19196         ChannelDetails_set_confirmations_required(&this_ptr_conv, val_conv);
19197 }
19198
19199 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1force_1close_1spend_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
19200         LDKChannelDetails this_ptr_conv;
19201         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19202         this_ptr_conv.is_owned = false;
19203         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
19204         *ret_copy = ChannelDetails_get_force_close_spend_delay(&this_ptr_conv);
19205         uint64_t ret_ref = (uint64_t)ret_copy;
19206         return ret_ref;
19207 }
19208
19209 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) {
19210         LDKChannelDetails this_ptr_conv;
19211         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19212         this_ptr_conv.is_owned = false;
19213         LDKCOption_u16Z val_conv = *(LDKCOption_u16Z*)(((uint64_t)val) & ~1);
19214         val_conv = COption_u16Z_clone((LDKCOption_u16Z*)(((uint64_t)val) & ~1));
19215         ChannelDetails_set_force_close_spend_delay(&this_ptr_conv, val_conv);
19216 }
19217
19218 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_ptr) {
19219         LDKChannelDetails this_ptr_conv;
19220         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19221         this_ptr_conv.is_owned = false;
19222         jboolean ret_val = ChannelDetails_get_is_outbound(&this_ptr_conv);
19223         return ret_val;
19224 }
19225
19226 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
19227         LDKChannelDetails this_ptr_conv;
19228         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19229         this_ptr_conv.is_owned = false;
19230         ChannelDetails_set_is_outbound(&this_ptr_conv, val);
19231 }
19232
19233 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1funding_1locked(JNIEnv *env, jclass clz, int64_t this_ptr) {
19234         LDKChannelDetails this_ptr_conv;
19235         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19236         this_ptr_conv.is_owned = false;
19237         jboolean ret_val = ChannelDetails_get_is_funding_locked(&this_ptr_conv);
19238         return ret_val;
19239 }
19240
19241 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1funding_1locked(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
19242         LDKChannelDetails this_ptr_conv;
19243         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19244         this_ptr_conv.is_owned = false;
19245         ChannelDetails_set_is_funding_locked(&this_ptr_conv, val);
19246 }
19247
19248 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1usable(JNIEnv *env, jclass clz, int64_t this_ptr) {
19249         LDKChannelDetails this_ptr_conv;
19250         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19251         this_ptr_conv.is_owned = false;
19252         jboolean ret_val = ChannelDetails_get_is_usable(&this_ptr_conv);
19253         return ret_val;
19254 }
19255
19256 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1usable(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
19257         LDKChannelDetails this_ptr_conv;
19258         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19259         this_ptr_conv.is_owned = false;
19260         ChannelDetails_set_is_usable(&this_ptr_conv, val);
19261 }
19262
19263 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1public(JNIEnv *env, jclass clz, int64_t this_ptr) {
19264         LDKChannelDetails this_ptr_conv;
19265         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19266         this_ptr_conv.is_owned = false;
19267         jboolean ret_val = ChannelDetails_get_is_public(&this_ptr_conv);
19268         return ret_val;
19269 }
19270
19271 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1public(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
19272         LDKChannelDetails this_ptr_conv;
19273         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19274         this_ptr_conv.is_owned = false;
19275         ChannelDetails_set_is_public(&this_ptr_conv, val);
19276 }
19277
19278 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int64_t counterparty_arg, int64_t funding_txo_arg, int64_t short_channel_id_arg, int64_t channel_value_satoshis_arg, int64_t unspendable_punishment_reserve_arg, int64_t user_channel_id_arg, int64_t outbound_capacity_msat_arg, int64_t inbound_capacity_msat_arg, int64_t confirmations_required_arg, int64_t force_close_spend_delay_arg, jboolean is_outbound_arg, jboolean is_funding_locked_arg, jboolean is_usable_arg, jboolean is_public_arg) {
19279         LDKThirtyTwoBytes channel_id_arg_ref;
19280         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
19281         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
19282         LDKChannelCounterparty counterparty_arg_conv;
19283         counterparty_arg_conv.inner = (void*)(counterparty_arg & (~1));
19284         counterparty_arg_conv.is_owned = (counterparty_arg & 1) || (counterparty_arg == 0);
19285         counterparty_arg_conv = ChannelCounterparty_clone(&counterparty_arg_conv);
19286         LDKOutPoint funding_txo_arg_conv;
19287         funding_txo_arg_conv.inner = (void*)(funding_txo_arg & (~1));
19288         funding_txo_arg_conv.is_owned = (funding_txo_arg & 1) || (funding_txo_arg == 0);
19289         funding_txo_arg_conv = OutPoint_clone(&funding_txo_arg_conv);
19290         LDKCOption_u64Z short_channel_id_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)short_channel_id_arg) & ~1);
19291         short_channel_id_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)short_channel_id_arg) & ~1));
19292         LDKCOption_u64Z unspendable_punishment_reserve_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)unspendable_punishment_reserve_arg) & ~1);
19293         LDKCOption_u32Z confirmations_required_arg_conv = *(LDKCOption_u32Z*)(((uint64_t)confirmations_required_arg) & ~1);
19294         confirmations_required_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uint64_t)confirmations_required_arg) & ~1));
19295         LDKCOption_u16Z force_close_spend_delay_arg_conv = *(LDKCOption_u16Z*)(((uint64_t)force_close_spend_delay_arg) & ~1);
19296         force_close_spend_delay_arg_conv = COption_u16Z_clone((LDKCOption_u16Z*)(((uint64_t)force_close_spend_delay_arg) & ~1));
19297         LDKChannelDetails ret_var = ChannelDetails_new(channel_id_arg_ref, counterparty_arg_conv, funding_txo_arg_conv, short_channel_id_arg_conv, channel_value_satoshis_arg, unspendable_punishment_reserve_arg_conv, user_channel_id_arg, outbound_capacity_msat_arg, inbound_capacity_msat_arg, confirmations_required_arg_conv, force_close_spend_delay_arg_conv, is_outbound_arg, is_funding_locked_arg, is_usable_arg, is_public_arg);
19298         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19299         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19300         uint64_t ret_ref = (uint64_t)ret_var.inner;
19301         if (ret_var.is_owned) {
19302                 ret_ref |= 1;
19303         }
19304         return ret_ref;
19305 }
19306
19307 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19308         LDKChannelDetails orig_conv;
19309         orig_conv.inner = (void*)(orig & (~1));
19310         orig_conv.is_owned = false;
19311         LDKChannelDetails ret_var = ChannelDetails_clone(&orig_conv);
19312         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19313         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19314         uint64_t ret_ref = (uint64_t)ret_var.inner;
19315         if (ret_var.is_owned) {
19316                 ret_ref |= 1;
19317         }
19318         return ret_ref;
19319 }
19320
19321 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
19322         if ((this_ptr & 1) != 0) return;
19323         LDKPaymentSendFailure this_ptr_conv = *(LDKPaymentSendFailure*)(((uint64_t)this_ptr) & ~1);
19324         FREE((void*)this_ptr);
19325         PaymentSendFailure_free(this_ptr_conv);
19326 }
19327
19328 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19329         LDKPaymentSendFailure* orig_conv = (LDKPaymentSendFailure*)orig;
19330         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
19331         *ret_copy = PaymentSendFailure_clone(orig_conv);
19332         uint64_t ret_ref = (uint64_t)ret_copy;
19333         return ret_ref;
19334 }
19335
19336 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1parameter_1error(JNIEnv *env, jclass clz, int64_t a) {
19337         LDKAPIError a_conv = *(LDKAPIError*)(((uint64_t)a) & ~1);
19338         a_conv = APIError_clone((LDKAPIError*)(((uint64_t)a) & ~1));
19339         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
19340         *ret_copy = PaymentSendFailure_parameter_error(a_conv);
19341         uint64_t ret_ref = (uint64_t)ret_copy;
19342         return ret_ref;
19343 }
19344
19345 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1path_1parameter_1error(JNIEnv *env, jclass clz, int64_tArray a) {
19346         LDKCVec_CResult_NoneAPIErrorZZ a_constr;
19347         a_constr.datalen = (*env)->GetArrayLength(env, a);
19348         if (a_constr.datalen > 0)
19349                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
19350         else
19351                 a_constr.data = NULL;
19352         int64_t* a_vals = (*env)->GetLongArrayElements (env, a, NULL);
19353         for (size_t w = 0; w < a_constr.datalen; w++) {
19354                 int64_t a_conv_22 = a_vals[w];
19355                 LDKCResult_NoneAPIErrorZ a_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)a_conv_22) & ~1);
19356                 a_conv_22_conv = CResult_NoneAPIErrorZ_clone((LDKCResult_NoneAPIErrorZ*)(((uint64_t)a_conv_22) & ~1));
19357                 a_constr.data[w] = a_conv_22_conv;
19358         }
19359         (*env)->ReleaseLongArrayElements(env, a, a_vals, 0);
19360         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
19361         *ret_copy = PaymentSendFailure_path_parameter_error(a_constr);
19362         uint64_t ret_ref = (uint64_t)ret_copy;
19363         return ret_ref;
19364 }
19365
19366 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1all_1failed_1retry_1safe(JNIEnv *env, jclass clz, int64_tArray a) {
19367         LDKCVec_APIErrorZ a_constr;
19368         a_constr.datalen = (*env)->GetArrayLength(env, a);
19369         if (a_constr.datalen > 0)
19370                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
19371         else
19372                 a_constr.data = NULL;
19373         int64_t* a_vals = (*env)->GetLongArrayElements (env, a, NULL);
19374         for (size_t k = 0; k < a_constr.datalen; k++) {
19375                 int64_t a_conv_10 = a_vals[k];
19376                 LDKAPIError a_conv_10_conv = *(LDKAPIError*)(((uint64_t)a_conv_10) & ~1);
19377                 a_conv_10_conv = APIError_clone((LDKAPIError*)(((uint64_t)a_conv_10) & ~1));
19378                 a_constr.data[k] = a_conv_10_conv;
19379         }
19380         (*env)->ReleaseLongArrayElements(env, a, a_vals, 0);
19381         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
19382         *ret_copy = PaymentSendFailure_all_failed_retry_safe(a_constr);
19383         uint64_t ret_ref = (uint64_t)ret_copy;
19384         return ret_ref;
19385 }
19386
19387 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1partial_1failure(JNIEnv *env, jclass clz, int64_tArray a) {
19388         LDKCVec_CResult_NoneAPIErrorZZ a_constr;
19389         a_constr.datalen = (*env)->GetArrayLength(env, a);
19390         if (a_constr.datalen > 0)
19391                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
19392         else
19393                 a_constr.data = NULL;
19394         int64_t* a_vals = (*env)->GetLongArrayElements (env, a, NULL);
19395         for (size_t w = 0; w < a_constr.datalen; w++) {
19396                 int64_t a_conv_22 = a_vals[w];
19397                 LDKCResult_NoneAPIErrorZ a_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)a_conv_22) & ~1);
19398                 a_conv_22_conv = CResult_NoneAPIErrorZ_clone((LDKCResult_NoneAPIErrorZ*)(((uint64_t)a_conv_22) & ~1));
19399                 a_constr.data[w] = a_conv_22_conv;
19400         }
19401         (*env)->ReleaseLongArrayElements(env, a, a_vals, 0);
19402         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
19403         *ret_copy = PaymentSendFailure_partial_failure(a_constr);
19404         uint64_t ret_ref = (uint64_t)ret_copy;
19405         return ret_ref;
19406 }
19407
19408 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) {
19409         LDKFeeEstimator fee_est_conv = *(LDKFeeEstimator*)(((uint64_t)fee_est) & ~1);
19410         if (fee_est_conv.free == LDKFeeEstimator_JCalls_free) {
19411                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
19412                 LDKFeeEstimator_JCalls_cloned(&fee_est_conv);
19413         }
19414         LDKWatch chain_monitor_conv = *(LDKWatch*)(((uint64_t)chain_monitor) & ~1);
19415         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
19416                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
19417                 LDKWatch_JCalls_cloned(&chain_monitor_conv);
19418         }
19419         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)tx_broadcaster) & ~1);
19420         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
19421                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
19422                 LDKBroadcasterInterface_JCalls_cloned(&tx_broadcaster_conv);
19423         }
19424         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
19425         if (logger_conv.free == LDKLogger_JCalls_free) {
19426                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
19427                 LDKLogger_JCalls_cloned(&logger_conv);
19428         }
19429         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
19430         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
19431                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
19432                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
19433         }
19434         LDKUserConfig config_conv;
19435         config_conv.inner = (void*)(config & (~1));
19436         config_conv.is_owned = (config & 1) || (config == 0);
19437         config_conv = UserConfig_clone(&config_conv);
19438         LDKChainParameters params_conv;
19439         params_conv.inner = (void*)(params & (~1));
19440         params_conv.is_owned = (params & 1) || (params == 0);
19441         params_conv = ChainParameters_clone(&params_conv);
19442         LDKChannelManager ret_var = ChannelManager_new(fee_est_conv, chain_monitor_conv, tx_broadcaster_conv, logger_conv, keys_manager_conv, config_conv, params_conv);
19443         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19444         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19445         uint64_t ret_ref = (uint64_t)ret_var.inner;
19446         if (ret_var.is_owned) {
19447                 ret_ref |= 1;
19448         }
19449         return ret_ref;
19450 }
19451
19452 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1current_1default_1configuration(JNIEnv *env, jclass clz, int64_t this_arg) {
19453         LDKChannelManager this_arg_conv;
19454         this_arg_conv.inner = (void*)(this_arg & (~1));
19455         this_arg_conv.is_owned = false;
19456         LDKUserConfig ret_var = ChannelManager_get_current_default_configuration(&this_arg_conv);
19457         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19458         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19459         uint64_t ret_ref = (uint64_t)ret_var.inner;
19460         if (ret_var.is_owned) {
19461                 ret_ref |= 1;
19462         }
19463         return ret_ref;
19464 }
19465
19466 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1create_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_network_key, int64_t channel_value_satoshis, int64_t push_msat, int64_t user_channel_id, int64_t override_config) {
19467         LDKChannelManager this_arg_conv;
19468         this_arg_conv.inner = (void*)(this_arg & (~1));
19469         this_arg_conv.is_owned = false;
19470         LDKPublicKey their_network_key_ref;
19471         CHECK((*env)->GetArrayLength(env, their_network_key) == 33);
19472         (*env)->GetByteArrayRegion(env, their_network_key, 0, 33, their_network_key_ref.compressed_form);
19473         LDKUserConfig override_config_conv;
19474         override_config_conv.inner = (void*)(override_config & (~1));
19475         override_config_conv.is_owned = (override_config & 1) || (override_config == 0);
19476         override_config_conv = UserConfig_clone(&override_config_conv);
19477         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
19478         *ret_conv = ChannelManager_create_channel(&this_arg_conv, their_network_key_ref, channel_value_satoshis, push_msat, user_channel_id, override_config_conv);
19479         return (uint64_t)ret_conv;
19480 }
19481
19482 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
19483         LDKChannelManager this_arg_conv;
19484         this_arg_conv.inner = (void*)(this_arg & (~1));
19485         this_arg_conv.is_owned = false;
19486         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_channels(&this_arg_conv);
19487         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
19488         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
19489         for (size_t q = 0; q < ret_var.datalen; q++) {
19490                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
19491                 CHECK((((uint64_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19492                 CHECK((((uint64_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19493                 uint64_t ret_conv_16_ref = (uint64_t)ret_conv_16_var.inner;
19494                 if (ret_conv_16_var.is_owned) {
19495                         ret_conv_16_ref |= 1;
19496                 }
19497                 ret_arr_ptr[q] = ret_conv_16_ref;
19498         }
19499         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
19500         FREE(ret_var.data);
19501         return ret_arr;
19502 }
19503
19504 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1usable_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
19505         LDKChannelManager this_arg_conv;
19506         this_arg_conv.inner = (void*)(this_arg & (~1));
19507         this_arg_conv.is_owned = false;
19508         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_usable_channels(&this_arg_conv);
19509         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
19510         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
19511         for (size_t q = 0; q < ret_var.datalen; q++) {
19512                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
19513                 CHECK((((uint64_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19514                 CHECK((((uint64_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19515                 uint64_t ret_conv_16_ref = (uint64_t)ret_conv_16_var.inner;
19516                 if (ret_conv_16_var.is_owned) {
19517                         ret_conv_16_ref |= 1;
19518                 }
19519                 ret_arr_ptr[q] = ret_conv_16_ref;
19520         }
19521         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
19522         FREE(ret_var.data);
19523         return ret_arr;
19524 }
19525
19526 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1close_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray channel_id) {
19527         LDKChannelManager this_arg_conv;
19528         this_arg_conv.inner = (void*)(this_arg & (~1));
19529         this_arg_conv.is_owned = false;
19530         unsigned char channel_id_arr[32];
19531         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
19532         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
19533         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
19534         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
19535         *ret_conv = ChannelManager_close_channel(&this_arg_conv, channel_id_ref);
19536         return (uint64_t)ret_conv;
19537 }
19538
19539 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) {
19540         LDKChannelManager this_arg_conv;
19541         this_arg_conv.inner = (void*)(this_arg & (~1));
19542         this_arg_conv.is_owned = false;
19543         unsigned char channel_id_arr[32];
19544         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
19545         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
19546         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
19547         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
19548         *ret_conv = ChannelManager_close_channel_with_target_feerate(&this_arg_conv, channel_id_ref, target_feerate_sats_per_1000_weight);
19549         return (uint64_t)ret_conv;
19550 }
19551
19552 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) {
19553         LDKChannelManager this_arg_conv;
19554         this_arg_conv.inner = (void*)(this_arg & (~1));
19555         this_arg_conv.is_owned = false;
19556         unsigned char channel_id_arr[32];
19557         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
19558         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
19559         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
19560         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
19561         *ret_conv = ChannelManager_force_close_channel(&this_arg_conv, channel_id_ref);
19562         return (uint64_t)ret_conv;
19563 }
19564
19565 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1force_1close_1all_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
19566         LDKChannelManager this_arg_conv;
19567         this_arg_conv.inner = (void*)(this_arg & (~1));
19568         this_arg_conv.is_owned = false;
19569         ChannelManager_force_close_all_channels(&this_arg_conv);
19570 }
19571
19572 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) {
19573         LDKChannelManager this_arg_conv;
19574         this_arg_conv.inner = (void*)(this_arg & (~1));
19575         this_arg_conv.is_owned = false;
19576         LDKRoute route_conv;
19577         route_conv.inner = (void*)(route & (~1));
19578         route_conv.is_owned = false;
19579         LDKThirtyTwoBytes payment_hash_ref;
19580         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
19581         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
19582         LDKThirtyTwoBytes payment_secret_ref;
19583         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
19584         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
19585         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
19586         *ret_conv = ChannelManager_send_payment(&this_arg_conv, &route_conv, payment_hash_ref, payment_secret_ref);
19587         return (uint64_t)ret_conv;
19588 }
19589
19590 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1retry_1payment(JNIEnv *env, jclass clz, int64_t this_arg, int64_t route, int64_t payment_id) {
19591         LDKChannelManager this_arg_conv;
19592         this_arg_conv.inner = (void*)(this_arg & (~1));
19593         this_arg_conv.is_owned = false;
19594         LDKRoute route_conv;
19595         route_conv.inner = (void*)(route & (~1));
19596         route_conv.is_owned = false;
19597         LDKPaymentId payment_id_conv;
19598         payment_id_conv.inner = (void*)(payment_id & (~1));
19599         payment_id_conv.is_owned = (payment_id & 1) || (payment_id == 0);
19600         payment_id_conv = PaymentId_clone(&payment_id_conv);
19601         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
19602         *ret_conv = ChannelManager_retry_payment(&this_arg_conv, &route_conv, payment_id_conv);
19603         return (uint64_t)ret_conv;
19604 }
19605
19606 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) {
19607         LDKChannelManager this_arg_conv;
19608         this_arg_conv.inner = (void*)(this_arg & (~1));
19609         this_arg_conv.is_owned = false;
19610         LDKRoute route_conv;
19611         route_conv.inner = (void*)(route & (~1));
19612         route_conv.is_owned = false;
19613         LDKThirtyTwoBytes payment_preimage_ref;
19614         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
19615         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
19616         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
19617         *ret_conv = ChannelManager_send_spontaneous_payment(&this_arg_conv, &route_conv, payment_preimage_ref);
19618         return (uint64_t)ret_conv;
19619 }
19620
19621 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) {
19622         LDKChannelManager this_arg_conv;
19623         this_arg_conv.inner = (void*)(this_arg & (~1));
19624         this_arg_conv.is_owned = false;
19625         unsigned char temporary_channel_id_arr[32];
19626         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
19627         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_arr);
19628         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
19629         LDKTransaction funding_transaction_ref;
19630         funding_transaction_ref.datalen = (*env)->GetArrayLength(env, funding_transaction);
19631         funding_transaction_ref.data = MALLOC(funding_transaction_ref.datalen, "LDKTransaction Bytes");
19632         (*env)->GetByteArrayRegion(env, funding_transaction, 0, funding_transaction_ref.datalen, funding_transaction_ref.data);
19633         funding_transaction_ref.data_is_owned = true;
19634         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
19635         *ret_conv = ChannelManager_funding_transaction_generated(&this_arg_conv, temporary_channel_id_ref, funding_transaction_ref);
19636         return (uint64_t)ret_conv;
19637 }
19638
19639 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) {
19640         LDKChannelManager this_arg_conv;
19641         this_arg_conv.inner = (void*)(this_arg & (~1));
19642         this_arg_conv.is_owned = false;
19643         LDKThreeBytes rgb_ref;
19644         CHECK((*env)->GetArrayLength(env, rgb) == 3);
19645         (*env)->GetByteArrayRegion(env, rgb, 0, 3, rgb_ref.data);
19646         LDKThirtyTwoBytes alias_ref;
19647         CHECK((*env)->GetArrayLength(env, alias) == 32);
19648         (*env)->GetByteArrayRegion(env, alias, 0, 32, alias_ref.data);
19649         LDKCVec_NetAddressZ addresses_constr;
19650         addresses_constr.datalen = (*env)->GetArrayLength(env, addresses);
19651         if (addresses_constr.datalen > 0)
19652                 addresses_constr.data = MALLOC(addresses_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
19653         else
19654                 addresses_constr.data = NULL;
19655         int64_t* addresses_vals = (*env)->GetLongArrayElements (env, addresses, NULL);
19656         for (size_t m = 0; m < addresses_constr.datalen; m++) {
19657                 int64_t addresses_conv_12 = addresses_vals[m];
19658                 LDKNetAddress addresses_conv_12_conv = *(LDKNetAddress*)(((uint64_t)addresses_conv_12) & ~1);
19659                 addresses_constr.data[m] = addresses_conv_12_conv;
19660         }
19661         (*env)->ReleaseLongArrayElements(env, addresses, addresses_vals, 0);
19662         ChannelManager_broadcast_node_announcement(&this_arg_conv, rgb_ref, alias_ref, addresses_constr);
19663 }
19664
19665 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1process_1pending_1htlc_1forwards(JNIEnv *env, jclass clz, int64_t this_arg) {
19666         LDKChannelManager this_arg_conv;
19667         this_arg_conv.inner = (void*)(this_arg & (~1));
19668         this_arg_conv.is_owned = false;
19669         ChannelManager_process_pending_htlc_forwards(&this_arg_conv);
19670 }
19671
19672 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1timer_1tick_1occurred(JNIEnv *env, jclass clz, int64_t this_arg) {
19673         LDKChannelManager this_arg_conv;
19674         this_arg_conv.inner = (void*)(this_arg & (~1));
19675         this_arg_conv.is_owned = false;
19676         ChannelManager_timer_tick_occurred(&this_arg_conv);
19677 }
19678
19679 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelManager_1fail_1htlc_1backwards(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_hash) {
19680         LDKChannelManager this_arg_conv;
19681         this_arg_conv.inner = (void*)(this_arg & (~1));
19682         this_arg_conv.is_owned = false;
19683         unsigned char payment_hash_arr[32];
19684         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
19685         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_arr);
19686         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
19687         jboolean ret_val = ChannelManager_fail_htlc_backwards(&this_arg_conv, payment_hash_ref);
19688         return ret_val;
19689 }
19690
19691 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelManager_1claim_1funds(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_preimage) {
19692         LDKChannelManager this_arg_conv;
19693         this_arg_conv.inner = (void*)(this_arg & (~1));
19694         this_arg_conv.is_owned = false;
19695         LDKThirtyTwoBytes payment_preimage_ref;
19696         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
19697         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
19698         jboolean ret_val = ChannelManager_claim_funds(&this_arg_conv, payment_preimage_ref);
19699         return ret_val;
19700 }
19701
19702 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1our_1node_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
19703         LDKChannelManager this_arg_conv;
19704         this_arg_conv.inner = (void*)(this_arg & (~1));
19705         this_arg_conv.is_owned = false;
19706         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
19707         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelManager_get_our_node_id(&this_arg_conv).compressed_form);
19708         return ret_arr;
19709 }
19710
19711 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) {
19712         LDKChannelManager this_arg_conv;
19713         this_arg_conv.inner = (void*)(this_arg & (~1));
19714         this_arg_conv.is_owned = false;
19715         LDKOutPoint funding_txo_conv;
19716         funding_txo_conv.inner = (void*)(funding_txo & (~1));
19717         funding_txo_conv.is_owned = false;
19718         ChannelManager_channel_monitor_updated(&this_arg_conv, &funding_txo_conv, highest_applied_update_id);
19719 }
19720
19721 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) {
19722         LDKChannelManager this_arg_conv;
19723         this_arg_conv.inner = (void*)(this_arg & (~1));
19724         this_arg_conv.is_owned = false;
19725         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(((uint64_t)min_value_msat) & ~1);
19726         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)min_value_msat) & ~1));
19727         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
19728         *ret_conv = ChannelManager_create_inbound_payment(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs, user_payment_id);
19729         return ((uint64_t)ret_conv);
19730 }
19731
19732 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) {
19733         LDKChannelManager this_arg_conv;
19734         this_arg_conv.inner = (void*)(this_arg & (~1));
19735         this_arg_conv.is_owned = false;
19736         LDKThirtyTwoBytes payment_hash_ref;
19737         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
19738         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
19739         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(((uint64_t)min_value_msat) & ~1);
19740         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)min_value_msat) & ~1));
19741         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
19742         *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);
19743         return (uint64_t)ret_conv;
19744 }
19745
19746 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
19747         LDKChannelManager this_arg_conv;
19748         this_arg_conv.inner = (void*)(this_arg & (~1));
19749         this_arg_conv.is_owned = false;
19750         LDKMessageSendEventsProvider* ret_ret =MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
19751         *ret_ret = ChannelManager_as_MessageSendEventsProvider(&this_arg_conv);
19752         return (uint64_t)ret_ret;
19753 }
19754
19755 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1EventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
19756         LDKChannelManager this_arg_conv;
19757         this_arg_conv.inner = (void*)(this_arg & (~1));
19758         this_arg_conv.is_owned = false;
19759         LDKEventsProvider* ret_ret =MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
19760         *ret_ret = ChannelManager_as_EventsProvider(&this_arg_conv);
19761         return (uint64_t)ret_ret;
19762 }
19763
19764 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Listen(JNIEnv *env, jclass clz, int64_t this_arg) {
19765         LDKChannelManager this_arg_conv;
19766         this_arg_conv.inner = (void*)(this_arg & (~1));
19767         this_arg_conv.is_owned = false;
19768         LDKListen* ret_ret =MALLOC(sizeof(LDKListen), "LDKListen");
19769         *ret_ret = ChannelManager_as_Listen(&this_arg_conv);
19770         return (uint64_t)ret_ret;
19771 }
19772
19773 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Confirm(JNIEnv *env, jclass clz, int64_t this_arg) {
19774         LDKChannelManager this_arg_conv;
19775         this_arg_conv.inner = (void*)(this_arg & (~1));
19776         this_arg_conv.is_owned = false;
19777         LDKConfirm* ret_ret =MALLOC(sizeof(LDKConfirm), "LDKConfirm");
19778         *ret_ret = ChannelManager_as_Confirm(&this_arg_conv);
19779         return (uint64_t)ret_ret;
19780 }
19781
19782 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) {
19783         LDKChannelManager this_arg_conv;
19784         this_arg_conv.inner = (void*)(this_arg & (~1));
19785         this_arg_conv.is_owned = false;
19786         jboolean ret_val = ChannelManager_await_persistable_update_timeout(&this_arg_conv, max_wait);
19787         return ret_val;
19788 }
19789
19790 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1await_1persistable_1update(JNIEnv *env, jclass clz, int64_t this_arg) {
19791         LDKChannelManager this_arg_conv;
19792         this_arg_conv.inner = (void*)(this_arg & (~1));
19793         this_arg_conv.is_owned = false;
19794         ChannelManager_await_persistable_update(&this_arg_conv);
19795 }
19796
19797 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1current_1best_1block(JNIEnv *env, jclass clz, int64_t this_arg) {
19798         LDKChannelManager this_arg_conv;
19799         this_arg_conv.inner = (void*)(this_arg & (~1));
19800         this_arg_conv.is_owned = false;
19801         LDKBestBlock ret_var = ChannelManager_current_best_block(&this_arg_conv);
19802         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19803         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19804         uint64_t ret_ref = (uint64_t)ret_var.inner;
19805         if (ret_var.is_owned) {
19806                 ret_ref |= 1;
19807         }
19808         return ret_ref;
19809 }
19810
19811 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1ChannelMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
19812         LDKChannelManager this_arg_conv;
19813         this_arg_conv.inner = (void*)(this_arg & (~1));
19814         this_arg_conv.is_owned = false;
19815         LDKChannelMessageHandler* ret_ret =MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
19816         *ret_ret = ChannelManager_as_ChannelMessageHandler(&this_arg_conv);
19817         return (uint64_t)ret_ret;
19818 }
19819
19820 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1write(JNIEnv *env, jclass clz, int64_t obj) {
19821         LDKChannelManager obj_conv;
19822         obj_conv.inner = (void*)(obj & (~1));
19823         obj_conv.is_owned = false;
19824         LDKCVec_u8Z ret_var = ChannelManager_write(&obj_conv);
19825         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
19826         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
19827         CVec_u8Z_free(ret_var);
19828         return ret_arr;
19829 }
19830
19831 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19832         LDKChannelManagerReadArgs this_obj_conv;
19833         this_obj_conv.inner = (void*)(this_obj & (~1));
19834         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19835         ChannelManagerReadArgs_free(this_obj_conv);
19836 }
19837
19838 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1keys_1manager(JNIEnv *env, jclass clz, int64_t this_ptr) {
19839         LDKChannelManagerReadArgs this_ptr_conv;
19840         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19841         this_ptr_conv.is_owned = false;
19842         uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_keys_manager(&this_ptr_conv);
19843         return ret_ret;
19844 }
19845
19846 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1keys_1manager(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19847         LDKChannelManagerReadArgs this_ptr_conv;
19848         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19849         this_ptr_conv.is_owned = false;
19850         LDKKeysInterface val_conv = *(LDKKeysInterface*)(((uint64_t)val) & ~1);
19851         if (val_conv.free == LDKKeysInterface_JCalls_free) {
19852                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
19853                 LDKKeysInterface_JCalls_cloned(&val_conv);
19854         }
19855         ChannelManagerReadArgs_set_keys_manager(&this_ptr_conv, val_conv);
19856 }
19857
19858 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1fee_1estimator(JNIEnv *env, jclass clz, int64_t this_ptr) {
19859         LDKChannelManagerReadArgs this_ptr_conv;
19860         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19861         this_ptr_conv.is_owned = false;
19862         uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_fee_estimator(&this_ptr_conv);
19863         return ret_ret;
19864 }
19865
19866 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1fee_1estimator(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19867         LDKChannelManagerReadArgs this_ptr_conv;
19868         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19869         this_ptr_conv.is_owned = false;
19870         LDKFeeEstimator val_conv = *(LDKFeeEstimator*)(((uint64_t)val) & ~1);
19871         if (val_conv.free == LDKFeeEstimator_JCalls_free) {
19872                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
19873                 LDKFeeEstimator_JCalls_cloned(&val_conv);
19874         }
19875         ChannelManagerReadArgs_set_fee_estimator(&this_ptr_conv, val_conv);
19876 }
19877
19878 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1chain_1monitor(JNIEnv *env, jclass clz, int64_t this_ptr) {
19879         LDKChannelManagerReadArgs this_ptr_conv;
19880         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19881         this_ptr_conv.is_owned = false;
19882         uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_chain_monitor(&this_ptr_conv);
19883         return ret_ret;
19884 }
19885
19886 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1chain_1monitor(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19887         LDKChannelManagerReadArgs this_ptr_conv;
19888         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19889         this_ptr_conv.is_owned = false;
19890         LDKWatch val_conv = *(LDKWatch*)(((uint64_t)val) & ~1);
19891         if (val_conv.free == LDKWatch_JCalls_free) {
19892                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
19893                 LDKWatch_JCalls_cloned(&val_conv);
19894         }
19895         ChannelManagerReadArgs_set_chain_monitor(&this_ptr_conv, val_conv);
19896 }
19897
19898 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1tx_1broadcaster(JNIEnv *env, jclass clz, int64_t this_ptr) {
19899         LDKChannelManagerReadArgs this_ptr_conv;
19900         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19901         this_ptr_conv.is_owned = false;
19902         uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_tx_broadcaster(&this_ptr_conv);
19903         return ret_ret;
19904 }
19905
19906 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1tx_1broadcaster(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19907         LDKChannelManagerReadArgs this_ptr_conv;
19908         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19909         this_ptr_conv.is_owned = false;
19910         LDKBroadcasterInterface val_conv = *(LDKBroadcasterInterface*)(((uint64_t)val) & ~1);
19911         if (val_conv.free == LDKBroadcasterInterface_JCalls_free) {
19912                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
19913                 LDKBroadcasterInterface_JCalls_cloned(&val_conv);
19914         }
19915         ChannelManagerReadArgs_set_tx_broadcaster(&this_ptr_conv, val_conv);
19916 }
19917
19918 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1logger(JNIEnv *env, jclass clz, int64_t this_ptr) {
19919         LDKChannelManagerReadArgs this_ptr_conv;
19920         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19921         this_ptr_conv.is_owned = false;
19922         uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_logger(&this_ptr_conv);
19923         return ret_ret;
19924 }
19925
19926 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1logger(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19927         LDKChannelManagerReadArgs this_ptr_conv;
19928         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19929         this_ptr_conv.is_owned = false;
19930         LDKLogger val_conv = *(LDKLogger*)(((uint64_t)val) & ~1);
19931         if (val_conv.free == LDKLogger_JCalls_free) {
19932                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
19933                 LDKLogger_JCalls_cloned(&val_conv);
19934         }
19935         ChannelManagerReadArgs_set_logger(&this_ptr_conv, val_conv);
19936 }
19937
19938 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1default_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
19939         LDKChannelManagerReadArgs this_ptr_conv;
19940         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19941         this_ptr_conv.is_owned = false;
19942         LDKUserConfig ret_var = ChannelManagerReadArgs_get_default_config(&this_ptr_conv);
19943         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19944         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19945         uint64_t ret_ref = (uint64_t)ret_var.inner;
19946         if (ret_var.is_owned) {
19947                 ret_ref |= 1;
19948         }
19949         return ret_ref;
19950 }
19951
19952 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1default_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19953         LDKChannelManagerReadArgs this_ptr_conv;
19954         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19955         this_ptr_conv.is_owned = false;
19956         LDKUserConfig val_conv;
19957         val_conv.inner = (void*)(val & (~1));
19958         val_conv.is_owned = (val & 1) || (val == 0);
19959         val_conv = UserConfig_clone(&val_conv);
19960         ChannelManagerReadArgs_set_default_config(&this_ptr_conv, val_conv);
19961 }
19962
19963 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) {
19964         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
19965         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
19966                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
19967                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
19968         }
19969         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
19970         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
19971                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
19972                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
19973         }
19974         LDKWatch chain_monitor_conv = *(LDKWatch*)(((uint64_t)chain_monitor) & ~1);
19975         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
19976                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
19977                 LDKWatch_JCalls_cloned(&chain_monitor_conv);
19978         }
19979         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)tx_broadcaster) & ~1);
19980         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
19981                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
19982                 LDKBroadcasterInterface_JCalls_cloned(&tx_broadcaster_conv);
19983         }
19984         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
19985         if (logger_conv.free == LDKLogger_JCalls_free) {
19986                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
19987                 LDKLogger_JCalls_cloned(&logger_conv);
19988         }
19989         LDKUserConfig default_config_conv;
19990         default_config_conv.inner = (void*)(default_config & (~1));
19991         default_config_conv.is_owned = (default_config & 1) || (default_config == 0);
19992         default_config_conv = UserConfig_clone(&default_config_conv);
19993         LDKCVec_ChannelMonitorZ channel_monitors_constr;
19994         channel_monitors_constr.datalen = (*env)->GetArrayLength(env, channel_monitors);
19995         if (channel_monitors_constr.datalen > 0)
19996                 channel_monitors_constr.data = MALLOC(channel_monitors_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
19997         else
19998                 channel_monitors_constr.data = NULL;
19999         int64_t* channel_monitors_vals = (*env)->GetLongArrayElements (env, channel_monitors, NULL);
20000         for (size_t q = 0; q < channel_monitors_constr.datalen; q++) {
20001                 int64_t channel_monitors_conv_16 = channel_monitors_vals[q];
20002                 LDKChannelMonitor channel_monitors_conv_16_conv;
20003                 channel_monitors_conv_16_conv.inner = (void*)(channel_monitors_conv_16 & (~1));
20004                 channel_monitors_conv_16_conv.is_owned = (channel_monitors_conv_16 & 1) || (channel_monitors_conv_16 == 0);
20005                 channel_monitors_constr.data[q] = channel_monitors_conv_16_conv;
20006         }
20007         (*env)->ReleaseLongArrayElements(env, channel_monitors, channel_monitors_vals, 0);
20008         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);
20009         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20010         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20011         uint64_t ret_ref = (uint64_t)ret_var.inner;
20012         if (ret_var.is_owned) {
20013                 ret_ref |= 1;
20014         }
20015         return ret_ref;
20016 }
20017
20018 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
20019         LDKu8slice ser_ref;
20020         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20021         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20022         LDKChannelManagerReadArgs arg_conv;
20023         arg_conv.inner = (void*)(arg & (~1));
20024         arg_conv.is_owned = (arg & 1) || (arg == 0);
20025         // Warning: we need a move here but no clone is available for LDKChannelManagerReadArgs
20026         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
20027         *ret_conv = C2Tuple_BlockHashChannelManagerZ_read(ser_ref, arg_conv);
20028         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20029         return (uint64_t)ret_conv;
20030 }
20031
20032 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DecodeError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20033         LDKDecodeError this_obj_conv;
20034         this_obj_conv.inner = (void*)(this_obj & (~1));
20035         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20036         DecodeError_free(this_obj_conv);
20037 }
20038
20039 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20040         LDKDecodeError orig_conv;
20041         orig_conv.inner = (void*)(orig & (~1));
20042         orig_conv.is_owned = false;
20043         LDKDecodeError ret_var = DecodeError_clone(&orig_conv);
20044         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20045         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20046         uint64_t ret_ref = (uint64_t)ret_var.inner;
20047         if (ret_var.is_owned) {
20048                 ret_ref |= 1;
20049         }
20050         return ret_ref;
20051 }
20052
20053 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20054         LDKInit this_obj_conv;
20055         this_obj_conv.inner = (void*)(this_obj & (~1));
20056         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20057         Init_free(this_obj_conv);
20058 }
20059
20060 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
20061         LDKInit this_ptr_conv;
20062         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20063         this_ptr_conv.is_owned = false;
20064         LDKInitFeatures ret_var = Init_get_features(&this_ptr_conv);
20065         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20066         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20067         uint64_t ret_ref = (uint64_t)ret_var.inner;
20068         if (ret_var.is_owned) {
20069                 ret_ref |= 1;
20070         }
20071         return ret_ref;
20072 }
20073
20074 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20075         LDKInit this_ptr_conv;
20076         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20077         this_ptr_conv.is_owned = false;
20078         LDKInitFeatures val_conv;
20079         val_conv.inner = (void*)(val & (~1));
20080         val_conv.is_owned = (val & 1) || (val == 0);
20081         val_conv = InitFeatures_clone(&val_conv);
20082         Init_set_features(&this_ptr_conv, val_conv);
20083 }
20084
20085 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1new(JNIEnv *env, jclass clz, int64_t features_arg) {
20086         LDKInitFeatures features_arg_conv;
20087         features_arg_conv.inner = (void*)(features_arg & (~1));
20088         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
20089         features_arg_conv = InitFeatures_clone(&features_arg_conv);
20090         LDKInit ret_var = Init_new(features_arg_conv);
20091         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20092         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20093         uint64_t ret_ref = (uint64_t)ret_var.inner;
20094         if (ret_var.is_owned) {
20095                 ret_ref |= 1;
20096         }
20097         return ret_ref;
20098 }
20099
20100 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20101         LDKInit orig_conv;
20102         orig_conv.inner = (void*)(orig & (~1));
20103         orig_conv.is_owned = false;
20104         LDKInit ret_var = Init_clone(&orig_conv);
20105         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20106         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20107         uint64_t ret_ref = (uint64_t)ret_var.inner;
20108         if (ret_var.is_owned) {
20109                 ret_ref |= 1;
20110         }
20111         return ret_ref;
20112 }
20113
20114 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20115         LDKErrorMessage this_obj_conv;
20116         this_obj_conv.inner = (void*)(this_obj & (~1));
20117         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20118         ErrorMessage_free(this_obj_conv);
20119 }
20120
20121 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
20122         LDKErrorMessage this_ptr_conv;
20123         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20124         this_ptr_conv.is_owned = false;
20125         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
20126         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ErrorMessage_get_channel_id(&this_ptr_conv));
20127         return ret_arr;
20128 }
20129
20130 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20131         LDKErrorMessage this_ptr_conv;
20132         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20133         this_ptr_conv.is_owned = false;
20134         LDKThirtyTwoBytes val_ref;
20135         CHECK((*env)->GetArrayLength(env, val) == 32);
20136         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
20137         ErrorMessage_set_channel_id(&this_ptr_conv, val_ref);
20138 }
20139
20140 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1get_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
20141         LDKErrorMessage this_ptr_conv;
20142         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20143         this_ptr_conv.is_owned = false;
20144         LDKStr ret_str = ErrorMessage_get_data(&this_ptr_conv);
20145         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
20146         Str_free(ret_str);
20147         return ret_conv;
20148 }
20149
20150 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1set_1data(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
20151         LDKErrorMessage this_ptr_conv;
20152         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20153         this_ptr_conv.is_owned = false;
20154         LDKStr val_conv = java_to_owned_str(env, val);
20155         ErrorMessage_set_data(&this_ptr_conv, val_conv);
20156 }
20157
20158 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, jstring data_arg) {
20159         LDKThirtyTwoBytes channel_id_arg_ref;
20160         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
20161         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
20162         LDKStr data_arg_conv = java_to_owned_str(env, data_arg);
20163         LDKErrorMessage ret_var = ErrorMessage_new(channel_id_arg_ref, data_arg_conv);
20164         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20165         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20166         uint64_t ret_ref = (uint64_t)ret_var.inner;
20167         if (ret_var.is_owned) {
20168                 ret_ref |= 1;
20169         }
20170         return ret_ref;
20171 }
20172
20173 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20174         LDKErrorMessage orig_conv;
20175         orig_conv.inner = (void*)(orig & (~1));
20176         orig_conv.is_owned = false;
20177         LDKErrorMessage ret_var = ErrorMessage_clone(&orig_conv);
20178         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20179         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20180         uint64_t ret_ref = (uint64_t)ret_var.inner;
20181         if (ret_var.is_owned) {
20182                 ret_ref |= 1;
20183         }
20184         return ret_ref;
20185 }
20186
20187 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20188         LDKPing this_obj_conv;
20189         this_obj_conv.inner = (void*)(this_obj & (~1));
20190         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20191         Ping_free(this_obj_conv);
20192 }
20193
20194 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Ping_1get_1ponglen(JNIEnv *env, jclass clz, int64_t this_ptr) {
20195         LDKPing this_ptr_conv;
20196         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20197         this_ptr_conv.is_owned = false;
20198         int16_t ret_val = Ping_get_ponglen(&this_ptr_conv);
20199         return ret_val;
20200 }
20201
20202 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1set_1ponglen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
20203         LDKPing this_ptr_conv;
20204         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20205         this_ptr_conv.is_owned = false;
20206         Ping_set_ponglen(&this_ptr_conv, val);
20207 }
20208
20209 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Ping_1get_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr) {
20210         LDKPing this_ptr_conv;
20211         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20212         this_ptr_conv.is_owned = false;
20213         int16_t ret_val = Ping_get_byteslen(&this_ptr_conv);
20214         return ret_val;
20215 }
20216
20217 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1set_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
20218         LDKPing this_ptr_conv;
20219         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20220         this_ptr_conv.is_owned = false;
20221         Ping_set_byteslen(&this_ptr_conv, val);
20222 }
20223
20224 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1new(JNIEnv *env, jclass clz, int16_t ponglen_arg, int16_t byteslen_arg) {
20225         LDKPing ret_var = Ping_new(ponglen_arg, byteslen_arg);
20226         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20227         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20228         uint64_t ret_ref = (uint64_t)ret_var.inner;
20229         if (ret_var.is_owned) {
20230                 ret_ref |= 1;
20231         }
20232         return ret_ref;
20233 }
20234
20235 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20236         LDKPing orig_conv;
20237         orig_conv.inner = (void*)(orig & (~1));
20238         orig_conv.is_owned = false;
20239         LDKPing ret_var = Ping_clone(&orig_conv);
20240         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20241         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20242         uint64_t ret_ref = (uint64_t)ret_var.inner;
20243         if (ret_var.is_owned) {
20244                 ret_ref |= 1;
20245         }
20246         return ret_ref;
20247 }
20248
20249 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Pong_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20250         LDKPong this_obj_conv;
20251         this_obj_conv.inner = (void*)(this_obj & (~1));
20252         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20253         Pong_free(this_obj_conv);
20254 }
20255
20256 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Pong_1get_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr) {
20257         LDKPong this_ptr_conv;
20258         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20259         this_ptr_conv.is_owned = false;
20260         int16_t ret_val = Pong_get_byteslen(&this_ptr_conv);
20261         return ret_val;
20262 }
20263
20264 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Pong_1set_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
20265         LDKPong this_ptr_conv;
20266         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20267         this_ptr_conv.is_owned = false;
20268         Pong_set_byteslen(&this_ptr_conv, val);
20269 }
20270
20271 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1new(JNIEnv *env, jclass clz, int16_t byteslen_arg) {
20272         LDKPong ret_var = Pong_new(byteslen_arg);
20273         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20274         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20275         uint64_t ret_ref = (uint64_t)ret_var.inner;
20276         if (ret_var.is_owned) {
20277                 ret_ref |= 1;
20278         }
20279         return ret_ref;
20280 }
20281
20282 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20283         LDKPong orig_conv;
20284         orig_conv.inner = (void*)(orig & (~1));
20285         orig_conv.is_owned = false;
20286         LDKPong ret_var = Pong_clone(&orig_conv);
20287         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20288         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20289         uint64_t ret_ref = (uint64_t)ret_var.inner;
20290         if (ret_var.is_owned) {
20291                 ret_ref |= 1;
20292         }
20293         return ret_ref;
20294 }
20295
20296 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20297         LDKOpenChannel this_obj_conv;
20298         this_obj_conv.inner = (void*)(this_obj & (~1));
20299         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20300         OpenChannel_free(this_obj_conv);
20301 }
20302
20303 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
20304         LDKOpenChannel this_ptr_conv;
20305         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20306         this_ptr_conv.is_owned = false;
20307         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
20308         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OpenChannel_get_chain_hash(&this_ptr_conv));
20309         return ret_arr;
20310 }
20311
20312 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20313         LDKOpenChannel this_ptr_conv;
20314         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20315         this_ptr_conv.is_owned = false;
20316         LDKThirtyTwoBytes val_ref;
20317         CHECK((*env)->GetArrayLength(env, val) == 32);
20318         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
20319         OpenChannel_set_chain_hash(&this_ptr_conv, val_ref);
20320 }
20321
20322 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
20323         LDKOpenChannel this_ptr_conv;
20324         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20325         this_ptr_conv.is_owned = false;
20326         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
20327         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OpenChannel_get_temporary_channel_id(&this_ptr_conv));
20328         return ret_arr;
20329 }
20330
20331 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20332         LDKOpenChannel this_ptr_conv;
20333         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20334         this_ptr_conv.is_owned = false;
20335         LDKThirtyTwoBytes val_ref;
20336         CHECK((*env)->GetArrayLength(env, val) == 32);
20337         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
20338         OpenChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
20339 }
20340
20341 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
20342         LDKOpenChannel this_ptr_conv;
20343         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20344         this_ptr_conv.is_owned = false;
20345         int64_t ret_val = OpenChannel_get_funding_satoshis(&this_ptr_conv);
20346         return ret_val;
20347 }
20348
20349 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20350         LDKOpenChannel this_ptr_conv;
20351         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20352         this_ptr_conv.is_owned = false;
20353         OpenChannel_set_funding_satoshis(&this_ptr_conv, val);
20354 }
20355
20356 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1push_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
20357         LDKOpenChannel this_ptr_conv;
20358         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20359         this_ptr_conv.is_owned = false;
20360         int64_t ret_val = OpenChannel_get_push_msat(&this_ptr_conv);
20361         return ret_val;
20362 }
20363
20364 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1push_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20365         LDKOpenChannel this_ptr_conv;
20366         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20367         this_ptr_conv.is_owned = false;
20368         OpenChannel_set_push_msat(&this_ptr_conv, val);
20369 }
20370
20371 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
20372         LDKOpenChannel this_ptr_conv;
20373         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20374         this_ptr_conv.is_owned = false;
20375         int64_t ret_val = OpenChannel_get_dust_limit_satoshis(&this_ptr_conv);
20376         return ret_val;
20377 }
20378
20379 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20380         LDKOpenChannel this_ptr_conv;
20381         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20382         this_ptr_conv.is_owned = false;
20383         OpenChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
20384 }
20385
20386 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) {
20387         LDKOpenChannel this_ptr_conv;
20388         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20389         this_ptr_conv.is_owned = false;
20390         int64_t ret_val = OpenChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
20391         return ret_val;
20392 }
20393
20394 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) {
20395         LDKOpenChannel this_ptr_conv;
20396         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20397         this_ptr_conv.is_owned = false;
20398         OpenChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
20399 }
20400
20401 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
20402         LDKOpenChannel this_ptr_conv;
20403         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20404         this_ptr_conv.is_owned = false;
20405         int64_t ret_val = OpenChannel_get_channel_reserve_satoshis(&this_ptr_conv);
20406         return ret_val;
20407 }
20408
20409 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20410         LDKOpenChannel this_ptr_conv;
20411         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20412         this_ptr_conv.is_owned = false;
20413         OpenChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
20414 }
20415
20416 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
20417         LDKOpenChannel this_ptr_conv;
20418         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20419         this_ptr_conv.is_owned = false;
20420         int64_t ret_val = OpenChannel_get_htlc_minimum_msat(&this_ptr_conv);
20421         return ret_val;
20422 }
20423
20424 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20425         LDKOpenChannel this_ptr_conv;
20426         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20427         this_ptr_conv.is_owned = false;
20428         OpenChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
20429 }
20430
20431 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr) {
20432         LDKOpenChannel this_ptr_conv;
20433         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20434         this_ptr_conv.is_owned = false;
20435         int32_t ret_val = OpenChannel_get_feerate_per_kw(&this_ptr_conv);
20436         return ret_val;
20437 }
20438
20439 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
20440         LDKOpenChannel this_ptr_conv;
20441         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20442         this_ptr_conv.is_owned = false;
20443         OpenChannel_set_feerate_per_kw(&this_ptr_conv, val);
20444 }
20445
20446 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
20447         LDKOpenChannel this_ptr_conv;
20448         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20449         this_ptr_conv.is_owned = false;
20450         int16_t ret_val = OpenChannel_get_to_self_delay(&this_ptr_conv);
20451         return ret_val;
20452 }
20453
20454 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
20455         LDKOpenChannel this_ptr_conv;
20456         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20457         this_ptr_conv.is_owned = false;
20458         OpenChannel_set_to_self_delay(&this_ptr_conv, val);
20459 }
20460
20461 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
20462         LDKOpenChannel this_ptr_conv;
20463         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20464         this_ptr_conv.is_owned = false;
20465         int16_t ret_val = OpenChannel_get_max_accepted_htlcs(&this_ptr_conv);
20466         return ret_val;
20467 }
20468
20469 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
20470         LDKOpenChannel this_ptr_conv;
20471         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20472         this_ptr_conv.is_owned = false;
20473         OpenChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
20474 }
20475
20476 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
20477         LDKOpenChannel this_ptr_conv;
20478         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20479         this_ptr_conv.is_owned = false;
20480         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
20481         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_funding_pubkey(&this_ptr_conv).compressed_form);
20482         return ret_arr;
20483 }
20484
20485 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20486         LDKOpenChannel this_ptr_conv;
20487         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20488         this_ptr_conv.is_owned = false;
20489         LDKPublicKey val_ref;
20490         CHECK((*env)->GetArrayLength(env, val) == 33);
20491         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
20492         OpenChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
20493 }
20494
20495 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
20496         LDKOpenChannel this_ptr_conv;
20497         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20498         this_ptr_conv.is_owned = false;
20499         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
20500         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form);
20501         return ret_arr;
20502 }
20503
20504 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20505         LDKOpenChannel this_ptr_conv;
20506         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20507         this_ptr_conv.is_owned = false;
20508         LDKPublicKey val_ref;
20509         CHECK((*env)->GetArrayLength(env, val) == 33);
20510         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
20511         OpenChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
20512 }
20513
20514 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
20515         LDKOpenChannel this_ptr_conv;
20516         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20517         this_ptr_conv.is_owned = false;
20518         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
20519         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_payment_point(&this_ptr_conv).compressed_form);
20520         return ret_arr;
20521 }
20522
20523 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20524         LDKOpenChannel this_ptr_conv;
20525         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20526         this_ptr_conv.is_owned = false;
20527         LDKPublicKey val_ref;
20528         CHECK((*env)->GetArrayLength(env, val) == 33);
20529         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
20530         OpenChannel_set_payment_point(&this_ptr_conv, val_ref);
20531 }
20532
20533 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
20534         LDKOpenChannel this_ptr_conv;
20535         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20536         this_ptr_conv.is_owned = false;
20537         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
20538         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
20539         return ret_arr;
20540 }
20541
20542 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20543         LDKOpenChannel this_ptr_conv;
20544         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20545         this_ptr_conv.is_owned = false;
20546         LDKPublicKey val_ref;
20547         CHECK((*env)->GetArrayLength(env, val) == 33);
20548         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
20549         OpenChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
20550 }
20551
20552 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
20553         LDKOpenChannel this_ptr_conv;
20554         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20555         this_ptr_conv.is_owned = false;
20556         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
20557         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form);
20558         return ret_arr;
20559 }
20560
20561 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20562         LDKOpenChannel this_ptr_conv;
20563         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20564         this_ptr_conv.is_owned = false;
20565         LDKPublicKey val_ref;
20566         CHECK((*env)->GetArrayLength(env, val) == 33);
20567         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
20568         OpenChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
20569 }
20570
20571 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1first_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
20572         LDKOpenChannel this_ptr_conv;
20573         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20574         this_ptr_conv.is_owned = false;
20575         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
20576         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form);
20577         return ret_arr;
20578 }
20579
20580 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) {
20581         LDKOpenChannel this_ptr_conv;
20582         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20583         this_ptr_conv.is_owned = false;
20584         LDKPublicKey val_ref;
20585         CHECK((*env)->GetArrayLength(env, val) == 33);
20586         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
20587         OpenChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
20588 }
20589
20590 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1flags(JNIEnv *env, jclass clz, int64_t this_ptr) {
20591         LDKOpenChannel this_ptr_conv;
20592         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20593         this_ptr_conv.is_owned = false;
20594         int8_t ret_val = OpenChannel_get_channel_flags(&this_ptr_conv);
20595         return ret_val;
20596 }
20597
20598 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1flags(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
20599         LDKOpenChannel this_ptr_conv;
20600         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20601         this_ptr_conv.is_owned = false;
20602         OpenChannel_set_channel_flags(&this_ptr_conv, val);
20603 }
20604
20605 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20606         LDKOpenChannel orig_conv;
20607         orig_conv.inner = (void*)(orig & (~1));
20608         orig_conv.is_owned = false;
20609         LDKOpenChannel ret_var = OpenChannel_clone(&orig_conv);
20610         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20611         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20612         uint64_t ret_ref = (uint64_t)ret_var.inner;
20613         if (ret_var.is_owned) {
20614                 ret_ref |= 1;
20615         }
20616         return ret_ref;
20617 }
20618
20619 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20620         LDKAcceptChannel this_obj_conv;
20621         this_obj_conv.inner = (void*)(this_obj & (~1));
20622         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20623         AcceptChannel_free(this_obj_conv);
20624 }
20625
20626 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
20627         LDKAcceptChannel this_ptr_conv;
20628         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20629         this_ptr_conv.is_owned = false;
20630         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
20631         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *AcceptChannel_get_temporary_channel_id(&this_ptr_conv));
20632         return ret_arr;
20633 }
20634
20635 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20636         LDKAcceptChannel this_ptr_conv;
20637         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20638         this_ptr_conv.is_owned = false;
20639         LDKThirtyTwoBytes val_ref;
20640         CHECK((*env)->GetArrayLength(env, val) == 32);
20641         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
20642         AcceptChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
20643 }
20644
20645 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
20646         LDKAcceptChannel this_ptr_conv;
20647         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20648         this_ptr_conv.is_owned = false;
20649         int64_t ret_val = AcceptChannel_get_dust_limit_satoshis(&this_ptr_conv);
20650         return ret_val;
20651 }
20652
20653 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20654         LDKAcceptChannel this_ptr_conv;
20655         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20656         this_ptr_conv.is_owned = false;
20657         AcceptChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
20658 }
20659
20660 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) {
20661         LDKAcceptChannel this_ptr_conv;
20662         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20663         this_ptr_conv.is_owned = false;
20664         int64_t ret_val = AcceptChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
20665         return ret_val;
20666 }
20667
20668 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) {
20669         LDKAcceptChannel this_ptr_conv;
20670         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20671         this_ptr_conv.is_owned = false;
20672         AcceptChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
20673 }
20674
20675 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
20676         LDKAcceptChannel this_ptr_conv;
20677         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20678         this_ptr_conv.is_owned = false;
20679         int64_t ret_val = AcceptChannel_get_channel_reserve_satoshis(&this_ptr_conv);
20680         return ret_val;
20681 }
20682
20683 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20684         LDKAcceptChannel this_ptr_conv;
20685         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20686         this_ptr_conv.is_owned = false;
20687         AcceptChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
20688 }
20689
20690 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
20691         LDKAcceptChannel this_ptr_conv;
20692         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20693         this_ptr_conv.is_owned = false;
20694         int64_t ret_val = AcceptChannel_get_htlc_minimum_msat(&this_ptr_conv);
20695         return ret_val;
20696 }
20697
20698 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20699         LDKAcceptChannel this_ptr_conv;
20700         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20701         this_ptr_conv.is_owned = false;
20702         AcceptChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
20703 }
20704
20705 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
20706         LDKAcceptChannel this_ptr_conv;
20707         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20708         this_ptr_conv.is_owned = false;
20709         int32_t ret_val = AcceptChannel_get_minimum_depth(&this_ptr_conv);
20710         return ret_val;
20711 }
20712
20713 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
20714         LDKAcceptChannel this_ptr_conv;
20715         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20716         this_ptr_conv.is_owned = false;
20717         AcceptChannel_set_minimum_depth(&this_ptr_conv, val);
20718 }
20719
20720 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
20721         LDKAcceptChannel this_ptr_conv;
20722         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20723         this_ptr_conv.is_owned = false;
20724         int16_t ret_val = AcceptChannel_get_to_self_delay(&this_ptr_conv);
20725         return ret_val;
20726 }
20727
20728 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
20729         LDKAcceptChannel this_ptr_conv;
20730         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20731         this_ptr_conv.is_owned = false;
20732         AcceptChannel_set_to_self_delay(&this_ptr_conv, val);
20733 }
20734
20735 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
20736         LDKAcceptChannel this_ptr_conv;
20737         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20738         this_ptr_conv.is_owned = false;
20739         int16_t ret_val = AcceptChannel_get_max_accepted_htlcs(&this_ptr_conv);
20740         return ret_val;
20741 }
20742
20743 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
20744         LDKAcceptChannel this_ptr_conv;
20745         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20746         this_ptr_conv.is_owned = false;
20747         AcceptChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
20748 }
20749
20750 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
20751         LDKAcceptChannel this_ptr_conv;
20752         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20753         this_ptr_conv.is_owned = false;
20754         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
20755         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_funding_pubkey(&this_ptr_conv).compressed_form);
20756         return ret_arr;
20757 }
20758
20759 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20760         LDKAcceptChannel this_ptr_conv;
20761         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20762         this_ptr_conv.is_owned = false;
20763         LDKPublicKey val_ref;
20764         CHECK((*env)->GetArrayLength(env, val) == 33);
20765         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
20766         AcceptChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
20767 }
20768
20769 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
20770         LDKAcceptChannel this_ptr_conv;
20771         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20772         this_ptr_conv.is_owned = false;
20773         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
20774         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form);
20775         return ret_arr;
20776 }
20777
20778 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20779         LDKAcceptChannel this_ptr_conv;
20780         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20781         this_ptr_conv.is_owned = false;
20782         LDKPublicKey val_ref;
20783         CHECK((*env)->GetArrayLength(env, val) == 33);
20784         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
20785         AcceptChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
20786 }
20787
20788 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
20789         LDKAcceptChannel this_ptr_conv;
20790         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20791         this_ptr_conv.is_owned = false;
20792         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
20793         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_payment_point(&this_ptr_conv).compressed_form);
20794         return ret_arr;
20795 }
20796
20797 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20798         LDKAcceptChannel this_ptr_conv;
20799         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20800         this_ptr_conv.is_owned = false;
20801         LDKPublicKey val_ref;
20802         CHECK((*env)->GetArrayLength(env, val) == 33);
20803         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
20804         AcceptChannel_set_payment_point(&this_ptr_conv, val_ref);
20805 }
20806
20807 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
20808         LDKAcceptChannel this_ptr_conv;
20809         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20810         this_ptr_conv.is_owned = false;
20811         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
20812         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
20813         return ret_arr;
20814 }
20815
20816 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20817         LDKAcceptChannel this_ptr_conv;
20818         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20819         this_ptr_conv.is_owned = false;
20820         LDKPublicKey val_ref;
20821         CHECK((*env)->GetArrayLength(env, val) == 33);
20822         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
20823         AcceptChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
20824 }
20825
20826 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
20827         LDKAcceptChannel this_ptr_conv;
20828         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20829         this_ptr_conv.is_owned = false;
20830         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
20831         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form);
20832         return ret_arr;
20833 }
20834
20835 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20836         LDKAcceptChannel this_ptr_conv;
20837         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20838         this_ptr_conv.is_owned = false;
20839         LDKPublicKey val_ref;
20840         CHECK((*env)->GetArrayLength(env, val) == 33);
20841         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
20842         AcceptChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
20843 }
20844
20845 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1first_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
20846         LDKAcceptChannel 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, 33);
20850         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form);
20851         return ret_arr;
20852 }
20853
20854 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) {
20855         LDKAcceptChannel this_ptr_conv;
20856         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20857         this_ptr_conv.is_owned = false;
20858         LDKPublicKey val_ref;
20859         CHECK((*env)->GetArrayLength(env, val) == 33);
20860         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
20861         AcceptChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
20862 }
20863
20864 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20865         LDKAcceptChannel orig_conv;
20866         orig_conv.inner = (void*)(orig & (~1));
20867         orig_conv.is_owned = false;
20868         LDKAcceptChannel ret_var = AcceptChannel_clone(&orig_conv);
20869         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20870         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20871         uint64_t ret_ref = (uint64_t)ret_var.inner;
20872         if (ret_var.is_owned) {
20873                 ret_ref |= 1;
20874         }
20875         return ret_ref;
20876 }
20877
20878 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20879         LDKFundingCreated this_obj_conv;
20880         this_obj_conv.inner = (void*)(this_obj & (~1));
20881         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20882         FundingCreated_free(this_obj_conv);
20883 }
20884
20885 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
20886         LDKFundingCreated this_ptr_conv;
20887         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20888         this_ptr_conv.is_owned = false;
20889         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
20890         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingCreated_get_temporary_channel_id(&this_ptr_conv));
20891         return ret_arr;
20892 }
20893
20894 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20895         LDKFundingCreated this_ptr_conv;
20896         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20897         this_ptr_conv.is_owned = false;
20898         LDKThirtyTwoBytes val_ref;
20899         CHECK((*env)->GetArrayLength(env, val) == 32);
20900         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
20901         FundingCreated_set_temporary_channel_id(&this_ptr_conv, val_ref);
20902 }
20903
20904 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1funding_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
20905         LDKFundingCreated this_ptr_conv;
20906         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20907         this_ptr_conv.is_owned = false;
20908         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
20909         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingCreated_get_funding_txid(&this_ptr_conv));
20910         return ret_arr;
20911 }
20912
20913 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1funding_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20914         LDKFundingCreated this_ptr_conv;
20915         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20916         this_ptr_conv.is_owned = false;
20917         LDKThirtyTwoBytes val_ref;
20918         CHECK((*env)->GetArrayLength(env, val) == 32);
20919         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
20920         FundingCreated_set_funding_txid(&this_ptr_conv, val_ref);
20921 }
20922
20923 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1funding_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
20924         LDKFundingCreated this_ptr_conv;
20925         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20926         this_ptr_conv.is_owned = false;
20927         int16_t ret_val = FundingCreated_get_funding_output_index(&this_ptr_conv);
20928         return ret_val;
20929 }
20930
20931 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1funding_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
20932         LDKFundingCreated this_ptr_conv;
20933         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20934         this_ptr_conv.is_owned = false;
20935         FundingCreated_set_funding_output_index(&this_ptr_conv, val);
20936 }
20937
20938 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
20939         LDKFundingCreated this_ptr_conv;
20940         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20941         this_ptr_conv.is_owned = false;
20942         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
20943         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, FundingCreated_get_signature(&this_ptr_conv).compact_form);
20944         return ret_arr;
20945 }
20946
20947 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20948         LDKFundingCreated this_ptr_conv;
20949         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20950         this_ptr_conv.is_owned = false;
20951         LDKSignature val_ref;
20952         CHECK((*env)->GetArrayLength(env, val) == 64);
20953         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
20954         FundingCreated_set_signature(&this_ptr_conv, val_ref);
20955 }
20956
20957 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) {
20958         LDKThirtyTwoBytes temporary_channel_id_arg_ref;
20959         CHECK((*env)->GetArrayLength(env, temporary_channel_id_arg) == 32);
20960         (*env)->GetByteArrayRegion(env, temporary_channel_id_arg, 0, 32, temporary_channel_id_arg_ref.data);
20961         LDKThirtyTwoBytes funding_txid_arg_ref;
20962         CHECK((*env)->GetArrayLength(env, funding_txid_arg) == 32);
20963         (*env)->GetByteArrayRegion(env, funding_txid_arg, 0, 32, funding_txid_arg_ref.data);
20964         LDKSignature signature_arg_ref;
20965         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
20966         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
20967         LDKFundingCreated ret_var = FundingCreated_new(temporary_channel_id_arg_ref, funding_txid_arg_ref, funding_output_index_arg, signature_arg_ref);
20968         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20969         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20970         uint64_t ret_ref = (uint64_t)ret_var.inner;
20971         if (ret_var.is_owned) {
20972                 ret_ref |= 1;
20973         }
20974         return ret_ref;
20975 }
20976
20977 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20978         LDKFundingCreated orig_conv;
20979         orig_conv.inner = (void*)(orig & (~1));
20980         orig_conv.is_owned = false;
20981         LDKFundingCreated ret_var = FundingCreated_clone(&orig_conv);
20982         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20983         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20984         uint64_t ret_ref = (uint64_t)ret_var.inner;
20985         if (ret_var.is_owned) {
20986                 ret_ref |= 1;
20987         }
20988         return ret_ref;
20989 }
20990
20991 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20992         LDKFundingSigned this_obj_conv;
20993         this_obj_conv.inner = (void*)(this_obj & (~1));
20994         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20995         FundingSigned_free(this_obj_conv);
20996 }
20997
20998 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
20999         LDKFundingSigned this_ptr_conv;
21000         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21001         this_ptr_conv.is_owned = false;
21002         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
21003         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingSigned_get_channel_id(&this_ptr_conv));
21004         return ret_arr;
21005 }
21006
21007 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21008         LDKFundingSigned this_ptr_conv;
21009         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21010         this_ptr_conv.is_owned = false;
21011         LDKThirtyTwoBytes val_ref;
21012         CHECK((*env)->GetArrayLength(env, val) == 32);
21013         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
21014         FundingSigned_set_channel_id(&this_ptr_conv, val_ref);
21015 }
21016
21017 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
21018         LDKFundingSigned this_ptr_conv;
21019         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21020         this_ptr_conv.is_owned = false;
21021         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
21022         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, FundingSigned_get_signature(&this_ptr_conv).compact_form);
21023         return ret_arr;
21024 }
21025
21026 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21027         LDKFundingSigned this_ptr_conv;
21028         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21029         this_ptr_conv.is_owned = false;
21030         LDKSignature val_ref;
21031         CHECK((*env)->GetArrayLength(env, val) == 64);
21032         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
21033         FundingSigned_set_signature(&this_ptr_conv, val_ref);
21034 }
21035
21036 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray signature_arg) {
21037         LDKThirtyTwoBytes channel_id_arg_ref;
21038         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
21039         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
21040         LDKSignature signature_arg_ref;
21041         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
21042         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
21043         LDKFundingSigned ret_var = FundingSigned_new(channel_id_arg_ref, signature_arg_ref);
21044         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21045         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21046         uint64_t ret_ref = (uint64_t)ret_var.inner;
21047         if (ret_var.is_owned) {
21048                 ret_ref |= 1;
21049         }
21050         return ret_ref;
21051 }
21052
21053 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21054         LDKFundingSigned orig_conv;
21055         orig_conv.inner = (void*)(orig & (~1));
21056         orig_conv.is_owned = false;
21057         LDKFundingSigned ret_var = FundingSigned_clone(&orig_conv);
21058         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21059         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21060         uint64_t ret_ref = (uint64_t)ret_var.inner;
21061         if (ret_var.is_owned) {
21062                 ret_ref |= 1;
21063         }
21064         return ret_ref;
21065 }
21066
21067 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingLocked_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
21068         LDKFundingLocked this_obj_conv;
21069         this_obj_conv.inner = (void*)(this_obj & (~1));
21070         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21071         FundingLocked_free(this_obj_conv);
21072 }
21073
21074 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingLocked_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
21075         LDKFundingLocked this_ptr_conv;
21076         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21077         this_ptr_conv.is_owned = false;
21078         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
21079         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingLocked_get_channel_id(&this_ptr_conv));
21080         return ret_arr;
21081 }
21082
21083 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingLocked_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21084         LDKFundingLocked this_ptr_conv;
21085         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21086         this_ptr_conv.is_owned = false;
21087         LDKThirtyTwoBytes val_ref;
21088         CHECK((*env)->GetArrayLength(env, val) == 32);
21089         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
21090         FundingLocked_set_channel_id(&this_ptr_conv, val_ref);
21091 }
21092
21093 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingLocked_1get_1next_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
21094         LDKFundingLocked this_ptr_conv;
21095         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21096         this_ptr_conv.is_owned = false;
21097         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
21098         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, FundingLocked_get_next_per_commitment_point(&this_ptr_conv).compressed_form);
21099         return ret_arr;
21100 }
21101
21102 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) {
21103         LDKFundingLocked this_ptr_conv;
21104         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21105         this_ptr_conv.is_owned = false;
21106         LDKPublicKey val_ref;
21107         CHECK((*env)->GetArrayLength(env, val) == 33);
21108         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
21109         FundingLocked_set_next_per_commitment_point(&this_ptr_conv, val_ref);
21110 }
21111
21112 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) {
21113         LDKThirtyTwoBytes channel_id_arg_ref;
21114         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
21115         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
21116         LDKPublicKey next_per_commitment_point_arg_ref;
21117         CHECK((*env)->GetArrayLength(env, next_per_commitment_point_arg) == 33);
21118         (*env)->GetByteArrayRegion(env, next_per_commitment_point_arg, 0, 33, next_per_commitment_point_arg_ref.compressed_form);
21119         LDKFundingLocked ret_var = FundingLocked_new(channel_id_arg_ref, next_per_commitment_point_arg_ref);
21120         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21121         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21122         uint64_t ret_ref = (uint64_t)ret_var.inner;
21123         if (ret_var.is_owned) {
21124                 ret_ref |= 1;
21125         }
21126         return ret_ref;
21127 }
21128
21129 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingLocked_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21130         LDKFundingLocked orig_conv;
21131         orig_conv.inner = (void*)(orig & (~1));
21132         orig_conv.is_owned = false;
21133         LDKFundingLocked ret_var = FundingLocked_clone(&orig_conv);
21134         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21135         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21136         uint64_t ret_ref = (uint64_t)ret_var.inner;
21137         if (ret_var.is_owned) {
21138                 ret_ref |= 1;
21139         }
21140         return ret_ref;
21141 }
21142
21143 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
21144         LDKShutdown this_obj_conv;
21145         this_obj_conv.inner = (void*)(this_obj & (~1));
21146         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21147         Shutdown_free(this_obj_conv);
21148 }
21149
21150 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
21151         LDKShutdown this_ptr_conv;
21152         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21153         this_ptr_conv.is_owned = false;
21154         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
21155         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *Shutdown_get_channel_id(&this_ptr_conv));
21156         return ret_arr;
21157 }
21158
21159 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21160         LDKShutdown this_ptr_conv;
21161         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21162         this_ptr_conv.is_owned = false;
21163         LDKThirtyTwoBytes val_ref;
21164         CHECK((*env)->GetArrayLength(env, val) == 32);
21165         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
21166         Shutdown_set_channel_id(&this_ptr_conv, val_ref);
21167 }
21168
21169 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1get_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
21170         LDKShutdown this_ptr_conv;
21171         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21172         this_ptr_conv.is_owned = false;
21173         LDKu8slice ret_var = Shutdown_get_scriptpubkey(&this_ptr_conv);
21174         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21175         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21176         return ret_arr;
21177 }
21178
21179 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1set_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21180         LDKShutdown this_ptr_conv;
21181         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21182         this_ptr_conv.is_owned = false;
21183         LDKCVec_u8Z val_ref;
21184         val_ref.datalen = (*env)->GetArrayLength(env, val);
21185         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
21186         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
21187         Shutdown_set_scriptpubkey(&this_ptr_conv, val_ref);
21188 }
21189
21190 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray scriptpubkey_arg) {
21191         LDKThirtyTwoBytes channel_id_arg_ref;
21192         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
21193         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
21194         LDKCVec_u8Z scriptpubkey_arg_ref;
21195         scriptpubkey_arg_ref.datalen = (*env)->GetArrayLength(env, scriptpubkey_arg);
21196         scriptpubkey_arg_ref.data = MALLOC(scriptpubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
21197         (*env)->GetByteArrayRegion(env, scriptpubkey_arg, 0, scriptpubkey_arg_ref.datalen, scriptpubkey_arg_ref.data);
21198         LDKShutdown ret_var = Shutdown_new(channel_id_arg_ref, scriptpubkey_arg_ref);
21199         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21200         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21201         uint64_t ret_ref = (uint64_t)ret_var.inner;
21202         if (ret_var.is_owned) {
21203                 ret_ref |= 1;
21204         }
21205         return ret_ref;
21206 }
21207
21208 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21209         LDKShutdown orig_conv;
21210         orig_conv.inner = (void*)(orig & (~1));
21211         orig_conv.is_owned = false;
21212         LDKShutdown ret_var = Shutdown_clone(&orig_conv);
21213         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21214         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21215         uint64_t ret_ref = (uint64_t)ret_var.inner;
21216         if (ret_var.is_owned) {
21217                 ret_ref |= 1;
21218         }
21219         return ret_ref;
21220 }
21221
21222 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
21223         LDKClosingSignedFeeRange this_obj_conv;
21224         this_obj_conv.inner = (void*)(this_obj & (~1));
21225         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21226         ClosingSignedFeeRange_free(this_obj_conv);
21227 }
21228
21229 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1get_1min_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
21230         LDKClosingSignedFeeRange this_ptr_conv;
21231         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21232         this_ptr_conv.is_owned = false;
21233         int64_t ret_val = ClosingSignedFeeRange_get_min_fee_satoshis(&this_ptr_conv);
21234         return ret_val;
21235 }
21236
21237 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1set_1min_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
21238         LDKClosingSignedFeeRange this_ptr_conv;
21239         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21240         this_ptr_conv.is_owned = false;
21241         ClosingSignedFeeRange_set_min_fee_satoshis(&this_ptr_conv, val);
21242 }
21243
21244 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1get_1max_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
21245         LDKClosingSignedFeeRange this_ptr_conv;
21246         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21247         this_ptr_conv.is_owned = false;
21248         int64_t ret_val = ClosingSignedFeeRange_get_max_fee_satoshis(&this_ptr_conv);
21249         return ret_val;
21250 }
21251
21252 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1set_1max_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
21253         LDKClosingSignedFeeRange this_ptr_conv;
21254         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21255         this_ptr_conv.is_owned = false;
21256         ClosingSignedFeeRange_set_max_fee_satoshis(&this_ptr_conv, val);
21257 }
21258
21259 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) {
21260         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_new(min_fee_satoshis_arg, max_fee_satoshis_arg);
21261         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21262         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21263         uint64_t ret_ref = (uint64_t)ret_var.inner;
21264         if (ret_var.is_owned) {
21265                 ret_ref |= 1;
21266         }
21267         return ret_ref;
21268 }
21269
21270 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21271         LDKClosingSignedFeeRange orig_conv;
21272         orig_conv.inner = (void*)(orig & (~1));
21273         orig_conv.is_owned = false;
21274         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_clone(&orig_conv);
21275         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21276         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21277         uint64_t ret_ref = (uint64_t)ret_var.inner;
21278         if (ret_var.is_owned) {
21279                 ret_ref |= 1;
21280         }
21281         return ret_ref;
21282 }
21283
21284 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
21285         LDKClosingSigned this_obj_conv;
21286         this_obj_conv.inner = (void*)(this_obj & (~1));
21287         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21288         ClosingSigned_free(this_obj_conv);
21289 }
21290
21291 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
21292         LDKClosingSigned this_ptr_conv;
21293         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21294         this_ptr_conv.is_owned = false;
21295         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
21296         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ClosingSigned_get_channel_id(&this_ptr_conv));
21297         return ret_arr;
21298 }
21299
21300 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21301         LDKClosingSigned this_ptr_conv;
21302         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21303         this_ptr_conv.is_owned = false;
21304         LDKThirtyTwoBytes val_ref;
21305         CHECK((*env)->GetArrayLength(env, val) == 32);
21306         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
21307         ClosingSigned_set_channel_id(&this_ptr_conv, val_ref);
21308 }
21309
21310 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
21311         LDKClosingSigned this_ptr_conv;
21312         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21313         this_ptr_conv.is_owned = false;
21314         int64_t ret_val = ClosingSigned_get_fee_satoshis(&this_ptr_conv);
21315         return ret_val;
21316 }
21317
21318 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
21319         LDKClosingSigned this_ptr_conv;
21320         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21321         this_ptr_conv.is_owned = false;
21322         ClosingSigned_set_fee_satoshis(&this_ptr_conv, val);
21323 }
21324
21325 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
21326         LDKClosingSigned this_ptr_conv;
21327         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21328         this_ptr_conv.is_owned = false;
21329         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
21330         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ClosingSigned_get_signature(&this_ptr_conv).compact_form);
21331         return ret_arr;
21332 }
21333
21334 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21335         LDKClosingSigned this_ptr_conv;
21336         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21337         this_ptr_conv.is_owned = false;
21338         LDKSignature val_ref;
21339         CHECK((*env)->GetArrayLength(env, val) == 64);
21340         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
21341         ClosingSigned_set_signature(&this_ptr_conv, val_ref);
21342 }
21343
21344 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1fee_1range(JNIEnv *env, jclass clz, int64_t this_ptr) {
21345         LDKClosingSigned this_ptr_conv;
21346         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21347         this_ptr_conv.is_owned = false;
21348         LDKClosingSignedFeeRange ret_var = ClosingSigned_get_fee_range(&this_ptr_conv);
21349         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21350         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21351         uint64_t ret_ref = (uint64_t)ret_var.inner;
21352         if (ret_var.is_owned) {
21353                 ret_ref |= 1;
21354         }
21355         return ret_ref;
21356 }
21357
21358 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1fee_1range(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
21359         LDKClosingSigned this_ptr_conv;
21360         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21361         this_ptr_conv.is_owned = false;
21362         LDKClosingSignedFeeRange val_conv;
21363         val_conv.inner = (void*)(val & (~1));
21364         val_conv.is_owned = (val & 1) || (val == 0);
21365         val_conv = ClosingSignedFeeRange_clone(&val_conv);
21366         ClosingSigned_set_fee_range(&this_ptr_conv, val_conv);
21367 }
21368
21369 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) {
21370         LDKThirtyTwoBytes channel_id_arg_ref;
21371         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
21372         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
21373         LDKSignature signature_arg_ref;
21374         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
21375         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
21376         LDKClosingSignedFeeRange fee_range_arg_conv;
21377         fee_range_arg_conv.inner = (void*)(fee_range_arg & (~1));
21378         fee_range_arg_conv.is_owned = (fee_range_arg & 1) || (fee_range_arg == 0);
21379         fee_range_arg_conv = ClosingSignedFeeRange_clone(&fee_range_arg_conv);
21380         LDKClosingSigned ret_var = ClosingSigned_new(channel_id_arg_ref, fee_satoshis_arg, signature_arg_ref, fee_range_arg_conv);
21381         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21382         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21383         uint64_t ret_ref = (uint64_t)ret_var.inner;
21384         if (ret_var.is_owned) {
21385                 ret_ref |= 1;
21386         }
21387         return ret_ref;
21388 }
21389
21390 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21391         LDKClosingSigned orig_conv;
21392         orig_conv.inner = (void*)(orig & (~1));
21393         orig_conv.is_owned = false;
21394         LDKClosingSigned ret_var = ClosingSigned_clone(&orig_conv);
21395         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21396         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21397         uint64_t ret_ref = (uint64_t)ret_var.inner;
21398         if (ret_var.is_owned) {
21399                 ret_ref |= 1;
21400         }
21401         return ret_ref;
21402 }
21403
21404 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
21405         LDKUpdateAddHTLC this_obj_conv;
21406         this_obj_conv.inner = (void*)(this_obj & (~1));
21407         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21408         UpdateAddHTLC_free(this_obj_conv);
21409 }
21410
21411 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
21412         LDKUpdateAddHTLC this_ptr_conv;
21413         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21414         this_ptr_conv.is_owned = false;
21415         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
21416         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateAddHTLC_get_channel_id(&this_ptr_conv));
21417         return ret_arr;
21418 }
21419
21420 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21421         LDKUpdateAddHTLC this_ptr_conv;
21422         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21423         this_ptr_conv.is_owned = false;
21424         LDKThirtyTwoBytes val_ref;
21425         CHECK((*env)->GetArrayLength(env, val) == 32);
21426         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
21427         UpdateAddHTLC_set_channel_id(&this_ptr_conv, val_ref);
21428 }
21429
21430 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
21431         LDKUpdateAddHTLC this_ptr_conv;
21432         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21433         this_ptr_conv.is_owned = false;
21434         int64_t ret_val = UpdateAddHTLC_get_htlc_id(&this_ptr_conv);
21435         return ret_val;
21436 }
21437
21438 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
21439         LDKUpdateAddHTLC this_ptr_conv;
21440         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21441         this_ptr_conv.is_owned = false;
21442         UpdateAddHTLC_set_htlc_id(&this_ptr_conv, val);
21443 }
21444
21445 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
21446         LDKUpdateAddHTLC this_ptr_conv;
21447         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21448         this_ptr_conv.is_owned = false;
21449         int64_t ret_val = UpdateAddHTLC_get_amount_msat(&this_ptr_conv);
21450         return ret_val;
21451 }
21452
21453 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
21454         LDKUpdateAddHTLC this_ptr_conv;
21455         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21456         this_ptr_conv.is_owned = false;
21457         UpdateAddHTLC_set_amount_msat(&this_ptr_conv, val);
21458 }
21459
21460 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
21461         LDKUpdateAddHTLC this_ptr_conv;
21462         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21463         this_ptr_conv.is_owned = false;
21464         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
21465         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateAddHTLC_get_payment_hash(&this_ptr_conv));
21466         return ret_arr;
21467 }
21468
21469 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21470         LDKUpdateAddHTLC this_ptr_conv;
21471         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21472         this_ptr_conv.is_owned = false;
21473         LDKThirtyTwoBytes val_ref;
21474         CHECK((*env)->GetArrayLength(env, val) == 32);
21475         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
21476         UpdateAddHTLC_set_payment_hash(&this_ptr_conv, val_ref);
21477 }
21478
21479 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr) {
21480         LDKUpdateAddHTLC this_ptr_conv;
21481         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21482         this_ptr_conv.is_owned = false;
21483         int32_t ret_val = UpdateAddHTLC_get_cltv_expiry(&this_ptr_conv);
21484         return ret_val;
21485 }
21486
21487 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
21488         LDKUpdateAddHTLC this_ptr_conv;
21489         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21490         this_ptr_conv.is_owned = false;
21491         UpdateAddHTLC_set_cltv_expiry(&this_ptr_conv, val);
21492 }
21493
21494 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21495         LDKUpdateAddHTLC orig_conv;
21496         orig_conv.inner = (void*)(orig & (~1));
21497         orig_conv.is_owned = false;
21498         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(&orig_conv);
21499         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21500         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21501         uint64_t ret_ref = (uint64_t)ret_var.inner;
21502         if (ret_var.is_owned) {
21503                 ret_ref |= 1;
21504         }
21505         return ret_ref;
21506 }
21507
21508 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
21509         LDKUpdateFulfillHTLC this_obj_conv;
21510         this_obj_conv.inner = (void*)(this_obj & (~1));
21511         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21512         UpdateFulfillHTLC_free(this_obj_conv);
21513 }
21514
21515 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
21516         LDKUpdateFulfillHTLC this_ptr_conv;
21517         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21518         this_ptr_conv.is_owned = false;
21519         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
21520         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFulfillHTLC_get_channel_id(&this_ptr_conv));
21521         return ret_arr;
21522 }
21523
21524 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21525         LDKUpdateFulfillHTLC this_ptr_conv;
21526         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21527         this_ptr_conv.is_owned = false;
21528         LDKThirtyTwoBytes val_ref;
21529         CHECK((*env)->GetArrayLength(env, val) == 32);
21530         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
21531         UpdateFulfillHTLC_set_channel_id(&this_ptr_conv, val_ref);
21532 }
21533
21534 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
21535         LDKUpdateFulfillHTLC this_ptr_conv;
21536         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21537         this_ptr_conv.is_owned = false;
21538         int64_t ret_val = UpdateFulfillHTLC_get_htlc_id(&this_ptr_conv);
21539         return ret_val;
21540 }
21541
21542 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
21543         LDKUpdateFulfillHTLC this_ptr_conv;
21544         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21545         this_ptr_conv.is_owned = false;
21546         UpdateFulfillHTLC_set_htlc_id(&this_ptr_conv, val);
21547 }
21548
21549 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1payment_1preimage(JNIEnv *env, jclass clz, int64_t this_ptr) {
21550         LDKUpdateFulfillHTLC this_ptr_conv;
21551         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21552         this_ptr_conv.is_owned = false;
21553         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
21554         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFulfillHTLC_get_payment_preimage(&this_ptr_conv));
21555         return ret_arr;
21556 }
21557
21558 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1payment_1preimage(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21559         LDKUpdateFulfillHTLC this_ptr_conv;
21560         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21561         this_ptr_conv.is_owned = false;
21562         LDKThirtyTwoBytes val_ref;
21563         CHECK((*env)->GetArrayLength(env, val) == 32);
21564         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
21565         UpdateFulfillHTLC_set_payment_preimage(&this_ptr_conv, val_ref);
21566 }
21567
21568 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) {
21569         LDKThirtyTwoBytes channel_id_arg_ref;
21570         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
21571         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
21572         LDKThirtyTwoBytes payment_preimage_arg_ref;
21573         CHECK((*env)->GetArrayLength(env, payment_preimage_arg) == 32);
21574         (*env)->GetByteArrayRegion(env, payment_preimage_arg, 0, 32, payment_preimage_arg_ref.data);
21575         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_new(channel_id_arg_ref, htlc_id_arg, payment_preimage_arg_ref);
21576         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21577         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21578         uint64_t ret_ref = (uint64_t)ret_var.inner;
21579         if (ret_var.is_owned) {
21580                 ret_ref |= 1;
21581         }
21582         return ret_ref;
21583 }
21584
21585 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21586         LDKUpdateFulfillHTLC orig_conv;
21587         orig_conv.inner = (void*)(orig & (~1));
21588         orig_conv.is_owned = false;
21589         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(&orig_conv);
21590         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21591         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21592         uint64_t ret_ref = (uint64_t)ret_var.inner;
21593         if (ret_var.is_owned) {
21594                 ret_ref |= 1;
21595         }
21596         return ret_ref;
21597 }
21598
21599 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
21600         LDKUpdateFailHTLC this_obj_conv;
21601         this_obj_conv.inner = (void*)(this_obj & (~1));
21602         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21603         UpdateFailHTLC_free(this_obj_conv);
21604 }
21605
21606 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
21607         LDKUpdateFailHTLC this_ptr_conv;
21608         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21609         this_ptr_conv.is_owned = false;
21610         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
21611         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFailHTLC_get_channel_id(&this_ptr_conv));
21612         return ret_arr;
21613 }
21614
21615 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21616         LDKUpdateFailHTLC this_ptr_conv;
21617         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21618         this_ptr_conv.is_owned = false;
21619         LDKThirtyTwoBytes val_ref;
21620         CHECK((*env)->GetArrayLength(env, val) == 32);
21621         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
21622         UpdateFailHTLC_set_channel_id(&this_ptr_conv, val_ref);
21623 }
21624
21625 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
21626         LDKUpdateFailHTLC this_ptr_conv;
21627         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21628         this_ptr_conv.is_owned = false;
21629         int64_t ret_val = UpdateFailHTLC_get_htlc_id(&this_ptr_conv);
21630         return ret_val;
21631 }
21632
21633 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
21634         LDKUpdateFailHTLC this_ptr_conv;
21635         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21636         this_ptr_conv.is_owned = false;
21637         UpdateFailHTLC_set_htlc_id(&this_ptr_conv, val);
21638 }
21639
21640 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21641         LDKUpdateFailHTLC orig_conv;
21642         orig_conv.inner = (void*)(orig & (~1));
21643         orig_conv.is_owned = false;
21644         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(&orig_conv);
21645         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21646         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21647         uint64_t ret_ref = (uint64_t)ret_var.inner;
21648         if (ret_var.is_owned) {
21649                 ret_ref |= 1;
21650         }
21651         return ret_ref;
21652 }
21653
21654 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
21655         LDKUpdateFailMalformedHTLC this_obj_conv;
21656         this_obj_conv.inner = (void*)(this_obj & (~1));
21657         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21658         UpdateFailMalformedHTLC_free(this_obj_conv);
21659 }
21660
21661 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
21662         LDKUpdateFailMalformedHTLC this_ptr_conv;
21663         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21664         this_ptr_conv.is_owned = false;
21665         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
21666         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFailMalformedHTLC_get_channel_id(&this_ptr_conv));
21667         return ret_arr;
21668 }
21669
21670 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21671         LDKUpdateFailMalformedHTLC this_ptr_conv;
21672         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21673         this_ptr_conv.is_owned = false;
21674         LDKThirtyTwoBytes val_ref;
21675         CHECK((*env)->GetArrayLength(env, val) == 32);
21676         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
21677         UpdateFailMalformedHTLC_set_channel_id(&this_ptr_conv, val_ref);
21678 }
21679
21680 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
21681         LDKUpdateFailMalformedHTLC this_ptr_conv;
21682         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21683         this_ptr_conv.is_owned = false;
21684         int64_t ret_val = UpdateFailMalformedHTLC_get_htlc_id(&this_ptr_conv);
21685         return ret_val;
21686 }
21687
21688 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
21689         LDKUpdateFailMalformedHTLC this_ptr_conv;
21690         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21691         this_ptr_conv.is_owned = false;
21692         UpdateFailMalformedHTLC_set_htlc_id(&this_ptr_conv, val);
21693 }
21694
21695 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1failure_1code(JNIEnv *env, jclass clz, int64_t this_ptr) {
21696         LDKUpdateFailMalformedHTLC this_ptr_conv;
21697         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21698         this_ptr_conv.is_owned = false;
21699         int16_t ret_val = UpdateFailMalformedHTLC_get_failure_code(&this_ptr_conv);
21700         return ret_val;
21701 }
21702
21703 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1failure_1code(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
21704         LDKUpdateFailMalformedHTLC this_ptr_conv;
21705         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21706         this_ptr_conv.is_owned = false;
21707         UpdateFailMalformedHTLC_set_failure_code(&this_ptr_conv, val);
21708 }
21709
21710 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21711         LDKUpdateFailMalformedHTLC orig_conv;
21712         orig_conv.inner = (void*)(orig & (~1));
21713         orig_conv.is_owned = false;
21714         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(&orig_conv);
21715         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21716         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21717         uint64_t ret_ref = (uint64_t)ret_var.inner;
21718         if (ret_var.is_owned) {
21719                 ret_ref |= 1;
21720         }
21721         return ret_ref;
21722 }
21723
21724 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
21725         LDKCommitmentSigned this_obj_conv;
21726         this_obj_conv.inner = (void*)(this_obj & (~1));
21727         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21728         CommitmentSigned_free(this_obj_conv);
21729 }
21730
21731 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
21732         LDKCommitmentSigned this_ptr_conv;
21733         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21734         this_ptr_conv.is_owned = false;
21735         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
21736         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *CommitmentSigned_get_channel_id(&this_ptr_conv));
21737         return ret_arr;
21738 }
21739
21740 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21741         LDKCommitmentSigned this_ptr_conv;
21742         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21743         this_ptr_conv.is_owned = false;
21744         LDKThirtyTwoBytes val_ref;
21745         CHECK((*env)->GetArrayLength(env, val) == 32);
21746         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
21747         CommitmentSigned_set_channel_id(&this_ptr_conv, val_ref);
21748 }
21749
21750 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
21751         LDKCommitmentSigned this_ptr_conv;
21752         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21753         this_ptr_conv.is_owned = false;
21754         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
21755         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, CommitmentSigned_get_signature(&this_ptr_conv).compact_form);
21756         return ret_arr;
21757 }
21758
21759 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21760         LDKCommitmentSigned this_ptr_conv;
21761         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21762         this_ptr_conv.is_owned = false;
21763         LDKSignature val_ref;
21764         CHECK((*env)->GetArrayLength(env, val) == 64);
21765         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
21766         CommitmentSigned_set_signature(&this_ptr_conv, val_ref);
21767 }
21768
21769 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1htlc_1signatures(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
21770         LDKCommitmentSigned this_ptr_conv;
21771         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21772         this_ptr_conv.is_owned = false;
21773         LDKCVec_SignatureZ val_constr;
21774         val_constr.datalen = (*env)->GetArrayLength(env, val);
21775         if (val_constr.datalen > 0)
21776                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
21777         else
21778                 val_constr.data = NULL;
21779         for (size_t i = 0; i < val_constr.datalen; i++) {
21780                 int8_tArray val_conv_8 = (*env)->GetObjectArrayElement(env, val, i);
21781                 LDKSignature val_conv_8_ref;
21782                 CHECK((*env)->GetArrayLength(env, val_conv_8) == 64);
21783                 (*env)->GetByteArrayRegion(env, val_conv_8, 0, 64, val_conv_8_ref.compact_form);
21784                 val_constr.data[i] = val_conv_8_ref;
21785         }
21786         CommitmentSigned_set_htlc_signatures(&this_ptr_conv, val_constr);
21787 }
21788
21789 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) {
21790         LDKThirtyTwoBytes channel_id_arg_ref;
21791         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
21792         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
21793         LDKSignature signature_arg_ref;
21794         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
21795         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
21796         LDKCVec_SignatureZ htlc_signatures_arg_constr;
21797         htlc_signatures_arg_constr.datalen = (*env)->GetArrayLength(env, htlc_signatures_arg);
21798         if (htlc_signatures_arg_constr.datalen > 0)
21799                 htlc_signatures_arg_constr.data = MALLOC(htlc_signatures_arg_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
21800         else
21801                 htlc_signatures_arg_constr.data = NULL;
21802         for (size_t i = 0; i < htlc_signatures_arg_constr.datalen; i++) {
21803                 int8_tArray htlc_signatures_arg_conv_8 = (*env)->GetObjectArrayElement(env, htlc_signatures_arg, i);
21804                 LDKSignature htlc_signatures_arg_conv_8_ref;
21805                 CHECK((*env)->GetArrayLength(env, htlc_signatures_arg_conv_8) == 64);
21806                 (*env)->GetByteArrayRegion(env, htlc_signatures_arg_conv_8, 0, 64, htlc_signatures_arg_conv_8_ref.compact_form);
21807                 htlc_signatures_arg_constr.data[i] = htlc_signatures_arg_conv_8_ref;
21808         }
21809         LDKCommitmentSigned ret_var = CommitmentSigned_new(channel_id_arg_ref, signature_arg_ref, htlc_signatures_arg_constr);
21810         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21811         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21812         uint64_t ret_ref = (uint64_t)ret_var.inner;
21813         if (ret_var.is_owned) {
21814                 ret_ref |= 1;
21815         }
21816         return ret_ref;
21817 }
21818
21819 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21820         LDKCommitmentSigned orig_conv;
21821         orig_conv.inner = (void*)(orig & (~1));
21822         orig_conv.is_owned = false;
21823         LDKCommitmentSigned ret_var = CommitmentSigned_clone(&orig_conv);
21824         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21825         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21826         uint64_t ret_ref = (uint64_t)ret_var.inner;
21827         if (ret_var.is_owned) {
21828                 ret_ref |= 1;
21829         }
21830         return ret_ref;
21831 }
21832
21833 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
21834         LDKRevokeAndACK this_obj_conv;
21835         this_obj_conv.inner = (void*)(this_obj & (~1));
21836         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21837         RevokeAndACK_free(this_obj_conv);
21838 }
21839
21840 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
21841         LDKRevokeAndACK this_ptr_conv;
21842         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21843         this_ptr_conv.is_owned = false;
21844         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
21845         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *RevokeAndACK_get_channel_id(&this_ptr_conv));
21846         return ret_arr;
21847 }
21848
21849 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21850         LDKRevokeAndACK this_ptr_conv;
21851         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21852         this_ptr_conv.is_owned = false;
21853         LDKThirtyTwoBytes val_ref;
21854         CHECK((*env)->GetArrayLength(env, val) == 32);
21855         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
21856         RevokeAndACK_set_channel_id(&this_ptr_conv, val_ref);
21857 }
21858
21859 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr) {
21860         LDKRevokeAndACK this_ptr_conv;
21861         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21862         this_ptr_conv.is_owned = false;
21863         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
21864         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *RevokeAndACK_get_per_commitment_secret(&this_ptr_conv));
21865         return ret_arr;
21866 }
21867
21868 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1set_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21869         LDKRevokeAndACK this_ptr_conv;
21870         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21871         this_ptr_conv.is_owned = false;
21872         LDKThirtyTwoBytes val_ref;
21873         CHECK((*env)->GetArrayLength(env, val) == 32);
21874         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
21875         RevokeAndACK_set_per_commitment_secret(&this_ptr_conv, val_ref);
21876 }
21877
21878 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1next_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
21879         LDKRevokeAndACK this_ptr_conv;
21880         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21881         this_ptr_conv.is_owned = false;
21882         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
21883         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RevokeAndACK_get_next_per_commitment_point(&this_ptr_conv).compressed_form);
21884         return ret_arr;
21885 }
21886
21887 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) {
21888         LDKRevokeAndACK this_ptr_conv;
21889         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21890         this_ptr_conv.is_owned = false;
21891         LDKPublicKey val_ref;
21892         CHECK((*env)->GetArrayLength(env, val) == 33);
21893         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
21894         RevokeAndACK_set_next_per_commitment_point(&this_ptr_conv, val_ref);
21895 }
21896
21897 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) {
21898         LDKThirtyTwoBytes channel_id_arg_ref;
21899         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
21900         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
21901         LDKThirtyTwoBytes per_commitment_secret_arg_ref;
21902         CHECK((*env)->GetArrayLength(env, per_commitment_secret_arg) == 32);
21903         (*env)->GetByteArrayRegion(env, per_commitment_secret_arg, 0, 32, per_commitment_secret_arg_ref.data);
21904         LDKPublicKey next_per_commitment_point_arg_ref;
21905         CHECK((*env)->GetArrayLength(env, next_per_commitment_point_arg) == 33);
21906         (*env)->GetByteArrayRegion(env, next_per_commitment_point_arg, 0, 33, next_per_commitment_point_arg_ref.compressed_form);
21907         LDKRevokeAndACK ret_var = RevokeAndACK_new(channel_id_arg_ref, per_commitment_secret_arg_ref, next_per_commitment_point_arg_ref);
21908         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21909         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21910         uint64_t ret_ref = (uint64_t)ret_var.inner;
21911         if (ret_var.is_owned) {
21912                 ret_ref |= 1;
21913         }
21914         return ret_ref;
21915 }
21916
21917 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21918         LDKRevokeAndACK orig_conv;
21919         orig_conv.inner = (void*)(orig & (~1));
21920         orig_conv.is_owned = false;
21921         LDKRevokeAndACK ret_var = RevokeAndACK_clone(&orig_conv);
21922         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21923         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21924         uint64_t ret_ref = (uint64_t)ret_var.inner;
21925         if (ret_var.is_owned) {
21926                 ret_ref |= 1;
21927         }
21928         return ret_ref;
21929 }
21930
21931 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
21932         LDKUpdateFee this_obj_conv;
21933         this_obj_conv.inner = (void*)(this_obj & (~1));
21934         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21935         UpdateFee_free(this_obj_conv);
21936 }
21937
21938 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFee_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
21939         LDKUpdateFee this_ptr_conv;
21940         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21941         this_ptr_conv.is_owned = false;
21942         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
21943         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFee_get_channel_id(&this_ptr_conv));
21944         return ret_arr;
21945 }
21946
21947 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21948         LDKUpdateFee this_ptr_conv;
21949         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21950         this_ptr_conv.is_owned = false;
21951         LDKThirtyTwoBytes val_ref;
21952         CHECK((*env)->GetArrayLength(env, val) == 32);
21953         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
21954         UpdateFee_set_channel_id(&this_ptr_conv, val_ref);
21955 }
21956
21957 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1get_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr) {
21958         LDKUpdateFee this_ptr_conv;
21959         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21960         this_ptr_conv.is_owned = false;
21961         int32_t ret_val = UpdateFee_get_feerate_per_kw(&this_ptr_conv);
21962         return ret_val;
21963 }
21964
21965 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1set_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
21966         LDKUpdateFee this_ptr_conv;
21967         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21968         this_ptr_conv.is_owned = false;
21969         UpdateFee_set_feerate_per_kw(&this_ptr_conv, val);
21970 }
21971
21972 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) {
21973         LDKThirtyTwoBytes channel_id_arg_ref;
21974         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
21975         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
21976         LDKUpdateFee ret_var = UpdateFee_new(channel_id_arg_ref, feerate_per_kw_arg);
21977         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21978         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21979         uint64_t ret_ref = (uint64_t)ret_var.inner;
21980         if (ret_var.is_owned) {
21981                 ret_ref |= 1;
21982         }
21983         return ret_ref;
21984 }
21985
21986 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21987         LDKUpdateFee orig_conv;
21988         orig_conv.inner = (void*)(orig & (~1));
21989         orig_conv.is_owned = false;
21990         LDKUpdateFee ret_var = UpdateFee_clone(&orig_conv);
21991         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21992         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21993         uint64_t ret_ref = (uint64_t)ret_var.inner;
21994         if (ret_var.is_owned) {
21995                 ret_ref |= 1;
21996         }
21997         return ret_ref;
21998 }
21999
22000 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22001         LDKDataLossProtect this_obj_conv;
22002         this_obj_conv.inner = (void*)(this_obj & (~1));
22003         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22004         DataLossProtect_free(this_obj_conv);
22005 }
22006
22007 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1get_1your_1last_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr) {
22008         LDKDataLossProtect this_ptr_conv;
22009         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22010         this_ptr_conv.is_owned = false;
22011         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
22012         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *DataLossProtect_get_your_last_per_commitment_secret(&this_ptr_conv));
22013         return ret_arr;
22014 }
22015
22016 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) {
22017         LDKDataLossProtect this_ptr_conv;
22018         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22019         this_ptr_conv.is_owned = false;
22020         LDKThirtyTwoBytes val_ref;
22021         CHECK((*env)->GetArrayLength(env, val) == 32);
22022         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
22023         DataLossProtect_set_your_last_per_commitment_secret(&this_ptr_conv, val_ref);
22024 }
22025
22026 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1get_1my_1current_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
22027         LDKDataLossProtect this_ptr_conv;
22028         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22029         this_ptr_conv.is_owned = false;
22030         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
22031         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DataLossProtect_get_my_current_per_commitment_point(&this_ptr_conv).compressed_form);
22032         return ret_arr;
22033 }
22034
22035 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) {
22036         LDKDataLossProtect this_ptr_conv;
22037         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22038         this_ptr_conv.is_owned = false;
22039         LDKPublicKey val_ref;
22040         CHECK((*env)->GetArrayLength(env, val) == 33);
22041         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
22042         DataLossProtect_set_my_current_per_commitment_point(&this_ptr_conv, val_ref);
22043 }
22044
22045 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) {
22046         LDKThirtyTwoBytes your_last_per_commitment_secret_arg_ref;
22047         CHECK((*env)->GetArrayLength(env, your_last_per_commitment_secret_arg) == 32);
22048         (*env)->GetByteArrayRegion(env, your_last_per_commitment_secret_arg, 0, 32, your_last_per_commitment_secret_arg_ref.data);
22049         LDKPublicKey my_current_per_commitment_point_arg_ref;
22050         CHECK((*env)->GetArrayLength(env, my_current_per_commitment_point_arg) == 33);
22051         (*env)->GetByteArrayRegion(env, my_current_per_commitment_point_arg, 0, 33, my_current_per_commitment_point_arg_ref.compressed_form);
22052         LDKDataLossProtect ret_var = DataLossProtect_new(your_last_per_commitment_secret_arg_ref, my_current_per_commitment_point_arg_ref);
22053         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22054         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22055         uint64_t ret_ref = (uint64_t)ret_var.inner;
22056         if (ret_var.is_owned) {
22057                 ret_ref |= 1;
22058         }
22059         return ret_ref;
22060 }
22061
22062 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22063         LDKDataLossProtect orig_conv;
22064         orig_conv.inner = (void*)(orig & (~1));
22065         orig_conv.is_owned = false;
22066         LDKDataLossProtect ret_var = DataLossProtect_clone(&orig_conv);
22067         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22068         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22069         uint64_t ret_ref = (uint64_t)ret_var.inner;
22070         if (ret_var.is_owned) {
22071                 ret_ref |= 1;
22072         }
22073         return ret_ref;
22074 }
22075
22076 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22077         LDKChannelReestablish this_obj_conv;
22078         this_obj_conv.inner = (void*)(this_obj & (~1));
22079         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22080         ChannelReestablish_free(this_obj_conv);
22081 }
22082
22083 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
22084         LDKChannelReestablish this_ptr_conv;
22085         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22086         this_ptr_conv.is_owned = false;
22087         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
22088         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ChannelReestablish_get_channel_id(&this_ptr_conv));
22089         return ret_arr;
22090 }
22091
22092 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22093         LDKChannelReestablish this_ptr_conv;
22094         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22095         this_ptr_conv.is_owned = false;
22096         LDKThirtyTwoBytes val_ref;
22097         CHECK((*env)->GetArrayLength(env, val) == 32);
22098         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
22099         ChannelReestablish_set_channel_id(&this_ptr_conv, val_ref);
22100 }
22101
22102 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1next_1local_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_ptr) {
22103         LDKChannelReestablish this_ptr_conv;
22104         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22105         this_ptr_conv.is_owned = false;
22106         int64_t ret_val = ChannelReestablish_get_next_local_commitment_number(&this_ptr_conv);
22107         return ret_val;
22108 }
22109
22110 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) {
22111         LDKChannelReestablish this_ptr_conv;
22112         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22113         this_ptr_conv.is_owned = false;
22114         ChannelReestablish_set_next_local_commitment_number(&this_ptr_conv, val);
22115 }
22116
22117 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1next_1remote_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_ptr) {
22118         LDKChannelReestablish this_ptr_conv;
22119         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22120         this_ptr_conv.is_owned = false;
22121         int64_t ret_val = ChannelReestablish_get_next_remote_commitment_number(&this_ptr_conv);
22122         return ret_val;
22123 }
22124
22125 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) {
22126         LDKChannelReestablish this_ptr_conv;
22127         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22128         this_ptr_conv.is_owned = false;
22129         ChannelReestablish_set_next_remote_commitment_number(&this_ptr_conv, val);
22130 }
22131
22132 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22133         LDKChannelReestablish orig_conv;
22134         orig_conv.inner = (void*)(orig & (~1));
22135         orig_conv.is_owned = false;
22136         LDKChannelReestablish ret_var = ChannelReestablish_clone(&orig_conv);
22137         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22138         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22139         uint64_t ret_ref = (uint64_t)ret_var.inner;
22140         if (ret_var.is_owned) {
22141                 ret_ref |= 1;
22142         }
22143         return ret_ref;
22144 }
22145
22146 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22147         LDKAnnouncementSignatures this_obj_conv;
22148         this_obj_conv.inner = (void*)(this_obj & (~1));
22149         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22150         AnnouncementSignatures_free(this_obj_conv);
22151 }
22152
22153 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
22154         LDKAnnouncementSignatures this_ptr_conv;
22155         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22156         this_ptr_conv.is_owned = false;
22157         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
22158         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *AnnouncementSignatures_get_channel_id(&this_ptr_conv));
22159         return ret_arr;
22160 }
22161
22162 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22163         LDKAnnouncementSignatures this_ptr_conv;
22164         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22165         this_ptr_conv.is_owned = false;
22166         LDKThirtyTwoBytes val_ref;
22167         CHECK((*env)->GetArrayLength(env, val) == 32);
22168         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
22169         AnnouncementSignatures_set_channel_id(&this_ptr_conv, val_ref);
22170 }
22171
22172 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
22173         LDKAnnouncementSignatures this_ptr_conv;
22174         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22175         this_ptr_conv.is_owned = false;
22176         int64_t ret_val = AnnouncementSignatures_get_short_channel_id(&this_ptr_conv);
22177         return ret_val;
22178 }
22179
22180 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
22181         LDKAnnouncementSignatures this_ptr_conv;
22182         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22183         this_ptr_conv.is_owned = false;
22184         AnnouncementSignatures_set_short_channel_id(&this_ptr_conv, val);
22185 }
22186
22187 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1node_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
22188         LDKAnnouncementSignatures this_ptr_conv;
22189         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22190         this_ptr_conv.is_owned = false;
22191         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
22192         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, AnnouncementSignatures_get_node_signature(&this_ptr_conv).compact_form);
22193         return ret_arr;
22194 }
22195
22196 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1node_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22197         LDKAnnouncementSignatures this_ptr_conv;
22198         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22199         this_ptr_conv.is_owned = false;
22200         LDKSignature val_ref;
22201         CHECK((*env)->GetArrayLength(env, val) == 64);
22202         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
22203         AnnouncementSignatures_set_node_signature(&this_ptr_conv, val_ref);
22204 }
22205
22206 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1bitcoin_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
22207         LDKAnnouncementSignatures this_ptr_conv;
22208         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22209         this_ptr_conv.is_owned = false;
22210         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
22211         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, AnnouncementSignatures_get_bitcoin_signature(&this_ptr_conv).compact_form);
22212         return ret_arr;
22213 }
22214
22215 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1bitcoin_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22216         LDKAnnouncementSignatures this_ptr_conv;
22217         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22218         this_ptr_conv.is_owned = false;
22219         LDKSignature val_ref;
22220         CHECK((*env)->GetArrayLength(env, val) == 64);
22221         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
22222         AnnouncementSignatures_set_bitcoin_signature(&this_ptr_conv, val_ref);
22223 }
22224
22225 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) {
22226         LDKThirtyTwoBytes channel_id_arg_ref;
22227         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
22228         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
22229         LDKSignature node_signature_arg_ref;
22230         CHECK((*env)->GetArrayLength(env, node_signature_arg) == 64);
22231         (*env)->GetByteArrayRegion(env, node_signature_arg, 0, 64, node_signature_arg_ref.compact_form);
22232         LDKSignature bitcoin_signature_arg_ref;
22233         CHECK((*env)->GetArrayLength(env, bitcoin_signature_arg) == 64);
22234         (*env)->GetByteArrayRegion(env, bitcoin_signature_arg, 0, 64, bitcoin_signature_arg_ref.compact_form);
22235         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_new(channel_id_arg_ref, short_channel_id_arg, node_signature_arg_ref, bitcoin_signature_arg_ref);
22236         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22237         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22238         uint64_t ret_ref = (uint64_t)ret_var.inner;
22239         if (ret_var.is_owned) {
22240                 ret_ref |= 1;
22241         }
22242         return ret_ref;
22243 }
22244
22245 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22246         LDKAnnouncementSignatures orig_conv;
22247         orig_conv.inner = (void*)(orig & (~1));
22248         orig_conv.is_owned = false;
22249         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(&orig_conv);
22250         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22251         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22252         uint64_t ret_ref = (uint64_t)ret_var.inner;
22253         if (ret_var.is_owned) {
22254                 ret_ref |= 1;
22255         }
22256         return ret_ref;
22257 }
22258
22259 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetAddress_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
22260         if ((this_ptr & 1) != 0) return;
22261         LDKNetAddress this_ptr_conv = *(LDKNetAddress*)(((uint64_t)this_ptr) & ~1);
22262         FREE((void*)this_ptr);
22263         NetAddress_free(this_ptr_conv);
22264 }
22265
22266 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22267         LDKNetAddress* orig_conv = (LDKNetAddress*)orig;
22268         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
22269         *ret_copy = NetAddress_clone(orig_conv);
22270         uint64_t ret_ref = (uint64_t)ret_copy;
22271         return ret_ref;
22272 }
22273
22274 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1ipv4(JNIEnv *env, jclass clz, int8_tArray addr, int16_t port) {
22275         LDKFourBytes addr_ref;
22276         CHECK((*env)->GetArrayLength(env, addr) == 4);
22277         (*env)->GetByteArrayRegion(env, addr, 0, 4, addr_ref.data);
22278         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
22279         *ret_copy = NetAddress_ipv4(addr_ref, port);
22280         uint64_t ret_ref = (uint64_t)ret_copy;
22281         return ret_ref;
22282 }
22283
22284 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1ipv6(JNIEnv *env, jclass clz, int8_tArray addr, int16_t port) {
22285         LDKSixteenBytes addr_ref;
22286         CHECK((*env)->GetArrayLength(env, addr) == 16);
22287         (*env)->GetByteArrayRegion(env, addr, 0, 16, addr_ref.data);
22288         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
22289         *ret_copy = NetAddress_ipv6(addr_ref, port);
22290         uint64_t ret_ref = (uint64_t)ret_copy;
22291         return ret_ref;
22292 }
22293
22294 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1onion_1v2(JNIEnv *env, jclass clz, int8_tArray addr, int16_t port) {
22295         LDKTenBytes addr_ref;
22296         CHECK((*env)->GetArrayLength(env, addr) == 10);
22297         (*env)->GetByteArrayRegion(env, addr, 0, 10, addr_ref.data);
22298         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
22299         *ret_copy = NetAddress_onion_v2(addr_ref, port);
22300         uint64_t ret_ref = (uint64_t)ret_copy;
22301         return ret_ref;
22302 }
22303
22304 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) {
22305         LDKThirtyTwoBytes ed25519_pubkey_ref;
22306         CHECK((*env)->GetArrayLength(env, ed25519_pubkey) == 32);
22307         (*env)->GetByteArrayRegion(env, ed25519_pubkey, 0, 32, ed25519_pubkey_ref.data);
22308         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
22309         *ret_copy = NetAddress_onion_v3(ed25519_pubkey_ref, checksum, version, port);
22310         uint64_t ret_ref = (uint64_t)ret_copy;
22311         return ret_ref;
22312 }
22313
22314 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetAddress_1write(JNIEnv *env, jclass clz, int64_t obj) {
22315         LDKNetAddress* obj_conv = (LDKNetAddress*)obj;
22316         LDKCVec_u8Z ret_var = NetAddress_write(obj_conv);
22317         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22318         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22319         CVec_u8Z_free(ret_var);
22320         return ret_arr;
22321 }
22322
22323 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Result_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
22324         LDKu8slice ser_ref;
22325         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
22326         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
22327         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
22328         *ret_conv = Result_read(ser_ref);
22329         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
22330         return (uint64_t)ret_conv;
22331 }
22332
22333 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
22334         LDKu8slice ser_ref;
22335         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
22336         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
22337         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
22338         *ret_conv = NetAddress_read(ser_ref);
22339         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
22340         return (uint64_t)ret_conv;
22341 }
22342
22343 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22344         LDKUnsignedNodeAnnouncement this_obj_conv;
22345         this_obj_conv.inner = (void*)(this_obj & (~1));
22346         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22347         UnsignedNodeAnnouncement_free(this_obj_conv);
22348 }
22349
22350 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
22351         LDKUnsignedNodeAnnouncement this_ptr_conv;
22352         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22353         this_ptr_conv.is_owned = false;
22354         LDKNodeFeatures ret_var = UnsignedNodeAnnouncement_get_features(&this_ptr_conv);
22355         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22356         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22357         uint64_t ret_ref = (uint64_t)ret_var.inner;
22358         if (ret_var.is_owned) {
22359                 ret_ref |= 1;
22360         }
22361         return ret_ref;
22362 }
22363
22364 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
22365         LDKUnsignedNodeAnnouncement this_ptr_conv;
22366         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22367         this_ptr_conv.is_owned = false;
22368         LDKNodeFeatures val_conv;
22369         val_conv.inner = (void*)(val & (~1));
22370         val_conv.is_owned = (val & 1) || (val == 0);
22371         val_conv = NodeFeatures_clone(&val_conv);
22372         UnsignedNodeAnnouncement_set_features(&this_ptr_conv, val_conv);
22373 }
22374
22375 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
22376         LDKUnsignedNodeAnnouncement this_ptr_conv;
22377         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22378         this_ptr_conv.is_owned = false;
22379         int32_t ret_val = UnsignedNodeAnnouncement_get_timestamp(&this_ptr_conv);
22380         return ret_val;
22381 }
22382
22383 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
22384         LDKUnsignedNodeAnnouncement this_ptr_conv;
22385         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22386         this_ptr_conv.is_owned = false;
22387         UnsignedNodeAnnouncement_set_timestamp(&this_ptr_conv, val);
22388 }
22389
22390 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
22391         LDKUnsignedNodeAnnouncement this_ptr_conv;
22392         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22393         this_ptr_conv.is_owned = false;
22394         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
22395         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedNodeAnnouncement_get_node_id(&this_ptr_conv).compressed_form);
22396         return ret_arr;
22397 }
22398
22399 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22400         LDKUnsignedNodeAnnouncement this_ptr_conv;
22401         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22402         this_ptr_conv.is_owned = false;
22403         LDKPublicKey val_ref;
22404         CHECK((*env)->GetArrayLength(env, val) == 33);
22405         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
22406         UnsignedNodeAnnouncement_set_node_id(&this_ptr_conv, val_ref);
22407 }
22408
22409 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr) {
22410         LDKUnsignedNodeAnnouncement this_ptr_conv;
22411         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22412         this_ptr_conv.is_owned = false;
22413         int8_tArray ret_arr = (*env)->NewByteArray(env, 3);
22414         (*env)->SetByteArrayRegion(env, ret_arr, 0, 3, *UnsignedNodeAnnouncement_get_rgb(&this_ptr_conv));
22415         return ret_arr;
22416 }
22417
22418 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22419         LDKUnsignedNodeAnnouncement this_ptr_conv;
22420         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22421         this_ptr_conv.is_owned = false;
22422         LDKThreeBytes val_ref;
22423         CHECK((*env)->GetArrayLength(env, val) == 3);
22424         (*env)->GetByteArrayRegion(env, val, 0, 3, val_ref.data);
22425         UnsignedNodeAnnouncement_set_rgb(&this_ptr_conv, val_ref);
22426 }
22427
22428 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
22429         LDKUnsignedNodeAnnouncement this_ptr_conv;
22430         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22431         this_ptr_conv.is_owned = false;
22432         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
22433         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedNodeAnnouncement_get_alias(&this_ptr_conv));
22434         return ret_arr;
22435 }
22436
22437 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22438         LDKUnsignedNodeAnnouncement this_ptr_conv;
22439         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22440         this_ptr_conv.is_owned = false;
22441         LDKThirtyTwoBytes val_ref;
22442         CHECK((*env)->GetArrayLength(env, val) == 32);
22443         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
22444         UnsignedNodeAnnouncement_set_alias(&this_ptr_conv, val_ref);
22445 }
22446
22447 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1addresses(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
22448         LDKUnsignedNodeAnnouncement this_ptr_conv;
22449         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22450         this_ptr_conv.is_owned = false;
22451         LDKCVec_NetAddressZ val_constr;
22452         val_constr.datalen = (*env)->GetArrayLength(env, val);
22453         if (val_constr.datalen > 0)
22454                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
22455         else
22456                 val_constr.data = NULL;
22457         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
22458         for (size_t m = 0; m < val_constr.datalen; m++) {
22459                 int64_t val_conv_12 = val_vals[m];
22460                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(((uint64_t)val_conv_12) & ~1);
22461                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)val_conv_12) & ~1));
22462                 val_constr.data[m] = val_conv_12_conv;
22463         }
22464         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
22465         UnsignedNodeAnnouncement_set_addresses(&this_ptr_conv, val_constr);
22466 }
22467
22468 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22469         LDKUnsignedNodeAnnouncement orig_conv;
22470         orig_conv.inner = (void*)(orig & (~1));
22471         orig_conv.is_owned = false;
22472         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(&orig_conv);
22473         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22474         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22475         uint64_t ret_ref = (uint64_t)ret_var.inner;
22476         if (ret_var.is_owned) {
22477                 ret_ref |= 1;
22478         }
22479         return ret_ref;
22480 }
22481
22482 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22483         LDKNodeAnnouncement this_obj_conv;
22484         this_obj_conv.inner = (void*)(this_obj & (~1));
22485         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22486         NodeAnnouncement_free(this_obj_conv);
22487 }
22488
22489 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
22490         LDKNodeAnnouncement this_ptr_conv;
22491         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22492         this_ptr_conv.is_owned = false;
22493         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
22494         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, NodeAnnouncement_get_signature(&this_ptr_conv).compact_form);
22495         return ret_arr;
22496 }
22497
22498 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22499         LDKNodeAnnouncement this_ptr_conv;
22500         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22501         this_ptr_conv.is_owned = false;
22502         LDKSignature val_ref;
22503         CHECK((*env)->GetArrayLength(env, val) == 64);
22504         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
22505         NodeAnnouncement_set_signature(&this_ptr_conv, val_ref);
22506 }
22507
22508 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
22509         LDKNodeAnnouncement this_ptr_conv;
22510         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22511         this_ptr_conv.is_owned = false;
22512         LDKUnsignedNodeAnnouncement ret_var = NodeAnnouncement_get_contents(&this_ptr_conv);
22513         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22514         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22515         uint64_t ret_ref = (uint64_t)ret_var.inner;
22516         if (ret_var.is_owned) {
22517                 ret_ref |= 1;
22518         }
22519         return ret_ref;
22520 }
22521
22522 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
22523         LDKNodeAnnouncement this_ptr_conv;
22524         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22525         this_ptr_conv.is_owned = false;
22526         LDKUnsignedNodeAnnouncement val_conv;
22527         val_conv.inner = (void*)(val & (~1));
22528         val_conv.is_owned = (val & 1) || (val == 0);
22529         val_conv = UnsignedNodeAnnouncement_clone(&val_conv);
22530         NodeAnnouncement_set_contents(&this_ptr_conv, val_conv);
22531 }
22532
22533 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1new(JNIEnv *env, jclass clz, int8_tArray signature_arg, int64_t contents_arg) {
22534         LDKSignature signature_arg_ref;
22535         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
22536         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
22537         LDKUnsignedNodeAnnouncement contents_arg_conv;
22538         contents_arg_conv.inner = (void*)(contents_arg & (~1));
22539         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
22540         contents_arg_conv = UnsignedNodeAnnouncement_clone(&contents_arg_conv);
22541         LDKNodeAnnouncement ret_var = NodeAnnouncement_new(signature_arg_ref, contents_arg_conv);
22542         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22543         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22544         uint64_t ret_ref = (uint64_t)ret_var.inner;
22545         if (ret_var.is_owned) {
22546                 ret_ref |= 1;
22547         }
22548         return ret_ref;
22549 }
22550
22551 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22552         LDKNodeAnnouncement orig_conv;
22553         orig_conv.inner = (void*)(orig & (~1));
22554         orig_conv.is_owned = false;
22555         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(&orig_conv);
22556         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22557         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22558         uint64_t ret_ref = (uint64_t)ret_var.inner;
22559         if (ret_var.is_owned) {
22560                 ret_ref |= 1;
22561         }
22562         return ret_ref;
22563 }
22564
22565 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22566         LDKUnsignedChannelAnnouncement this_obj_conv;
22567         this_obj_conv.inner = (void*)(this_obj & (~1));
22568         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22569         UnsignedChannelAnnouncement_free(this_obj_conv);
22570 }
22571
22572 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
22573         LDKUnsignedChannelAnnouncement this_ptr_conv;
22574         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22575         this_ptr_conv.is_owned = false;
22576         LDKChannelFeatures ret_var = UnsignedChannelAnnouncement_get_features(&this_ptr_conv);
22577         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22578         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22579         uint64_t ret_ref = (uint64_t)ret_var.inner;
22580         if (ret_var.is_owned) {
22581                 ret_ref |= 1;
22582         }
22583         return ret_ref;
22584 }
22585
22586 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
22587         LDKUnsignedChannelAnnouncement this_ptr_conv;
22588         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22589         this_ptr_conv.is_owned = false;
22590         LDKChannelFeatures val_conv;
22591         val_conv.inner = (void*)(val & (~1));
22592         val_conv.is_owned = (val & 1) || (val == 0);
22593         val_conv = ChannelFeatures_clone(&val_conv);
22594         UnsignedChannelAnnouncement_set_features(&this_ptr_conv, val_conv);
22595 }
22596
22597 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
22598         LDKUnsignedChannelAnnouncement this_ptr_conv;
22599         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22600         this_ptr_conv.is_owned = false;
22601         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
22602         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedChannelAnnouncement_get_chain_hash(&this_ptr_conv));
22603         return ret_arr;
22604 }
22605
22606 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22607         LDKUnsignedChannelAnnouncement this_ptr_conv;
22608         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22609         this_ptr_conv.is_owned = false;
22610         LDKThirtyTwoBytes val_ref;
22611         CHECK((*env)->GetArrayLength(env, val) == 32);
22612         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
22613         UnsignedChannelAnnouncement_set_chain_hash(&this_ptr_conv, val_ref);
22614 }
22615
22616 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
22617         LDKUnsignedChannelAnnouncement this_ptr_conv;
22618         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22619         this_ptr_conv.is_owned = false;
22620         int64_t ret_val = UnsignedChannelAnnouncement_get_short_channel_id(&this_ptr_conv);
22621         return ret_val;
22622 }
22623
22624 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
22625         LDKUnsignedChannelAnnouncement this_ptr_conv;
22626         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22627         this_ptr_conv.is_owned = false;
22628         UnsignedChannelAnnouncement_set_short_channel_id(&this_ptr_conv, val);
22629 }
22630
22631 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1node_1id_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
22632         LDKUnsignedChannelAnnouncement this_ptr_conv;
22633         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22634         this_ptr_conv.is_owned = false;
22635         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
22636         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_node_id_1(&this_ptr_conv).compressed_form);
22637         return ret_arr;
22638 }
22639
22640 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1node_1id_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22641         LDKUnsignedChannelAnnouncement this_ptr_conv;
22642         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22643         this_ptr_conv.is_owned = false;
22644         LDKPublicKey val_ref;
22645         CHECK((*env)->GetArrayLength(env, val) == 33);
22646         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
22647         UnsignedChannelAnnouncement_set_node_id_1(&this_ptr_conv, val_ref);
22648 }
22649
22650 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1node_1id_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
22651         LDKUnsignedChannelAnnouncement this_ptr_conv;
22652         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22653         this_ptr_conv.is_owned = false;
22654         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
22655         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_node_id_2(&this_ptr_conv).compressed_form);
22656         return ret_arr;
22657 }
22658
22659 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1node_1id_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22660         LDKUnsignedChannelAnnouncement this_ptr_conv;
22661         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22662         this_ptr_conv.is_owned = false;
22663         LDKPublicKey val_ref;
22664         CHECK((*env)->GetArrayLength(env, val) == 33);
22665         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
22666         UnsignedChannelAnnouncement_set_node_id_2(&this_ptr_conv, val_ref);
22667 }
22668
22669 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1bitcoin_1key_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
22670         LDKUnsignedChannelAnnouncement this_ptr_conv;
22671         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22672         this_ptr_conv.is_owned = false;
22673         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
22674         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_bitcoin_key_1(&this_ptr_conv).compressed_form);
22675         return ret_arr;
22676 }
22677
22678 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1bitcoin_1key_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22679         LDKUnsignedChannelAnnouncement this_ptr_conv;
22680         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22681         this_ptr_conv.is_owned = false;
22682         LDKPublicKey val_ref;
22683         CHECK((*env)->GetArrayLength(env, val) == 33);
22684         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
22685         UnsignedChannelAnnouncement_set_bitcoin_key_1(&this_ptr_conv, val_ref);
22686 }
22687
22688 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1bitcoin_1key_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
22689         LDKUnsignedChannelAnnouncement this_ptr_conv;
22690         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22691         this_ptr_conv.is_owned = false;
22692         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
22693         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_bitcoin_key_2(&this_ptr_conv).compressed_form);
22694         return ret_arr;
22695 }
22696
22697 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1bitcoin_1key_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22698         LDKUnsignedChannelAnnouncement this_ptr_conv;
22699         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22700         this_ptr_conv.is_owned = false;
22701         LDKPublicKey val_ref;
22702         CHECK((*env)->GetArrayLength(env, val) == 33);
22703         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
22704         UnsignedChannelAnnouncement_set_bitcoin_key_2(&this_ptr_conv, val_ref);
22705 }
22706
22707 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22708         LDKUnsignedChannelAnnouncement orig_conv;
22709         orig_conv.inner = (void*)(orig & (~1));
22710         orig_conv.is_owned = false;
22711         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(&orig_conv);
22712         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22713         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22714         uint64_t ret_ref = (uint64_t)ret_var.inner;
22715         if (ret_var.is_owned) {
22716                 ret_ref |= 1;
22717         }
22718         return ret_ref;
22719 }
22720
22721 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22722         LDKChannelAnnouncement this_obj_conv;
22723         this_obj_conv.inner = (void*)(this_obj & (~1));
22724         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22725         ChannelAnnouncement_free(this_obj_conv);
22726 }
22727
22728 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1node_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
22729         LDKChannelAnnouncement this_ptr_conv;
22730         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22731         this_ptr_conv.is_owned = false;
22732         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
22733         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_node_signature_1(&this_ptr_conv).compact_form);
22734         return ret_arr;
22735 }
22736
22737 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1node_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22738         LDKChannelAnnouncement this_ptr_conv;
22739         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22740         this_ptr_conv.is_owned = false;
22741         LDKSignature val_ref;
22742         CHECK((*env)->GetArrayLength(env, val) == 64);
22743         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
22744         ChannelAnnouncement_set_node_signature_1(&this_ptr_conv, val_ref);
22745 }
22746
22747 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1node_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
22748         LDKChannelAnnouncement this_ptr_conv;
22749         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22750         this_ptr_conv.is_owned = false;
22751         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
22752         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_node_signature_2(&this_ptr_conv).compact_form);
22753         return ret_arr;
22754 }
22755
22756 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1node_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22757         LDKChannelAnnouncement this_ptr_conv;
22758         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22759         this_ptr_conv.is_owned = false;
22760         LDKSignature val_ref;
22761         CHECK((*env)->GetArrayLength(env, val) == 64);
22762         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
22763         ChannelAnnouncement_set_node_signature_2(&this_ptr_conv, val_ref);
22764 }
22765
22766 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1bitcoin_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
22767         LDKChannelAnnouncement this_ptr_conv;
22768         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22769         this_ptr_conv.is_owned = false;
22770         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
22771         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_bitcoin_signature_1(&this_ptr_conv).compact_form);
22772         return ret_arr;
22773 }
22774
22775 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1bitcoin_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22776         LDKChannelAnnouncement this_ptr_conv;
22777         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22778         this_ptr_conv.is_owned = false;
22779         LDKSignature val_ref;
22780         CHECK((*env)->GetArrayLength(env, val) == 64);
22781         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
22782         ChannelAnnouncement_set_bitcoin_signature_1(&this_ptr_conv, val_ref);
22783 }
22784
22785 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1bitcoin_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
22786         LDKChannelAnnouncement this_ptr_conv;
22787         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22788         this_ptr_conv.is_owned = false;
22789         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
22790         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_bitcoin_signature_2(&this_ptr_conv).compact_form);
22791         return ret_arr;
22792 }
22793
22794 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1bitcoin_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22795         LDKChannelAnnouncement this_ptr_conv;
22796         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22797         this_ptr_conv.is_owned = false;
22798         LDKSignature val_ref;
22799         CHECK((*env)->GetArrayLength(env, val) == 64);
22800         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
22801         ChannelAnnouncement_set_bitcoin_signature_2(&this_ptr_conv, val_ref);
22802 }
22803
22804 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
22805         LDKChannelAnnouncement this_ptr_conv;
22806         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22807         this_ptr_conv.is_owned = false;
22808         LDKUnsignedChannelAnnouncement ret_var = ChannelAnnouncement_get_contents(&this_ptr_conv);
22809         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22810         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22811         uint64_t ret_ref = (uint64_t)ret_var.inner;
22812         if (ret_var.is_owned) {
22813                 ret_ref |= 1;
22814         }
22815         return ret_ref;
22816 }
22817
22818 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
22819         LDKChannelAnnouncement this_ptr_conv;
22820         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22821         this_ptr_conv.is_owned = false;
22822         LDKUnsignedChannelAnnouncement val_conv;
22823         val_conv.inner = (void*)(val & (~1));
22824         val_conv.is_owned = (val & 1) || (val == 0);
22825         val_conv = UnsignedChannelAnnouncement_clone(&val_conv);
22826         ChannelAnnouncement_set_contents(&this_ptr_conv, val_conv);
22827 }
22828
22829 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) {
22830         LDKSignature node_signature_1_arg_ref;
22831         CHECK((*env)->GetArrayLength(env, node_signature_1_arg) == 64);
22832         (*env)->GetByteArrayRegion(env, node_signature_1_arg, 0, 64, node_signature_1_arg_ref.compact_form);
22833         LDKSignature node_signature_2_arg_ref;
22834         CHECK((*env)->GetArrayLength(env, node_signature_2_arg) == 64);
22835         (*env)->GetByteArrayRegion(env, node_signature_2_arg, 0, 64, node_signature_2_arg_ref.compact_form);
22836         LDKSignature bitcoin_signature_1_arg_ref;
22837         CHECK((*env)->GetArrayLength(env, bitcoin_signature_1_arg) == 64);
22838         (*env)->GetByteArrayRegion(env, bitcoin_signature_1_arg, 0, 64, bitcoin_signature_1_arg_ref.compact_form);
22839         LDKSignature bitcoin_signature_2_arg_ref;
22840         CHECK((*env)->GetArrayLength(env, bitcoin_signature_2_arg) == 64);
22841         (*env)->GetByteArrayRegion(env, bitcoin_signature_2_arg, 0, 64, bitcoin_signature_2_arg_ref.compact_form);
22842         LDKUnsignedChannelAnnouncement contents_arg_conv;
22843         contents_arg_conv.inner = (void*)(contents_arg & (~1));
22844         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
22845         contents_arg_conv = UnsignedChannelAnnouncement_clone(&contents_arg_conv);
22846         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);
22847         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22848         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22849         uint64_t ret_ref = (uint64_t)ret_var.inner;
22850         if (ret_var.is_owned) {
22851                 ret_ref |= 1;
22852         }
22853         return ret_ref;
22854 }
22855
22856 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22857         LDKChannelAnnouncement orig_conv;
22858         orig_conv.inner = (void*)(orig & (~1));
22859         orig_conv.is_owned = false;
22860         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(&orig_conv);
22861         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22862         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22863         uint64_t ret_ref = (uint64_t)ret_var.inner;
22864         if (ret_var.is_owned) {
22865                 ret_ref |= 1;
22866         }
22867         return ret_ref;
22868 }
22869
22870 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22871         LDKUnsignedChannelUpdate this_obj_conv;
22872         this_obj_conv.inner = (void*)(this_obj & (~1));
22873         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22874         UnsignedChannelUpdate_free(this_obj_conv);
22875 }
22876
22877 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
22878         LDKUnsignedChannelUpdate this_ptr_conv;
22879         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22880         this_ptr_conv.is_owned = false;
22881         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
22882         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedChannelUpdate_get_chain_hash(&this_ptr_conv));
22883         return ret_arr;
22884 }
22885
22886 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22887         LDKUnsignedChannelUpdate this_ptr_conv;
22888         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22889         this_ptr_conv.is_owned = false;
22890         LDKThirtyTwoBytes val_ref;
22891         CHECK((*env)->GetArrayLength(env, val) == 32);
22892         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
22893         UnsignedChannelUpdate_set_chain_hash(&this_ptr_conv, val_ref);
22894 }
22895
22896 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
22897         LDKUnsignedChannelUpdate this_ptr_conv;
22898         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22899         this_ptr_conv.is_owned = false;
22900         int64_t ret_val = UnsignedChannelUpdate_get_short_channel_id(&this_ptr_conv);
22901         return ret_val;
22902 }
22903
22904 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
22905         LDKUnsignedChannelUpdate this_ptr_conv;
22906         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22907         this_ptr_conv.is_owned = false;
22908         UnsignedChannelUpdate_set_short_channel_id(&this_ptr_conv, val);
22909 }
22910
22911 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
22912         LDKUnsignedChannelUpdate this_ptr_conv;
22913         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22914         this_ptr_conv.is_owned = false;
22915         int32_t ret_val = UnsignedChannelUpdate_get_timestamp(&this_ptr_conv);
22916         return ret_val;
22917 }
22918
22919 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
22920         LDKUnsignedChannelUpdate this_ptr_conv;
22921         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22922         this_ptr_conv.is_owned = false;
22923         UnsignedChannelUpdate_set_timestamp(&this_ptr_conv, val);
22924 }
22925
22926 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1flags(JNIEnv *env, jclass clz, int64_t this_ptr) {
22927         LDKUnsignedChannelUpdate this_ptr_conv;
22928         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22929         this_ptr_conv.is_owned = false;
22930         int8_t ret_val = UnsignedChannelUpdate_get_flags(&this_ptr_conv);
22931         return ret_val;
22932 }
22933
22934 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1flags(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
22935         LDKUnsignedChannelUpdate this_ptr_conv;
22936         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22937         this_ptr_conv.is_owned = false;
22938         UnsignedChannelUpdate_set_flags(&this_ptr_conv, val);
22939 }
22940
22941 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
22942         LDKUnsignedChannelUpdate this_ptr_conv;
22943         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22944         this_ptr_conv.is_owned = false;
22945         int16_t ret_val = UnsignedChannelUpdate_get_cltv_expiry_delta(&this_ptr_conv);
22946         return ret_val;
22947 }
22948
22949 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
22950         LDKUnsignedChannelUpdate this_ptr_conv;
22951         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22952         this_ptr_conv.is_owned = false;
22953         UnsignedChannelUpdate_set_cltv_expiry_delta(&this_ptr_conv, val);
22954 }
22955
22956 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
22957         LDKUnsignedChannelUpdate this_ptr_conv;
22958         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22959         this_ptr_conv.is_owned = false;
22960         int64_t ret_val = UnsignedChannelUpdate_get_htlc_minimum_msat(&this_ptr_conv);
22961         return ret_val;
22962 }
22963
22964 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
22965         LDKUnsignedChannelUpdate this_ptr_conv;
22966         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22967         this_ptr_conv.is_owned = false;
22968         UnsignedChannelUpdate_set_htlc_minimum_msat(&this_ptr_conv, val);
22969 }
22970
22971 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
22972         LDKUnsignedChannelUpdate this_ptr_conv;
22973         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22974         this_ptr_conv.is_owned = false;
22975         int32_t ret_val = UnsignedChannelUpdate_get_fee_base_msat(&this_ptr_conv);
22976         return ret_val;
22977 }
22978
22979 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
22980         LDKUnsignedChannelUpdate this_ptr_conv;
22981         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22982         this_ptr_conv.is_owned = false;
22983         UnsignedChannelUpdate_set_fee_base_msat(&this_ptr_conv, val);
22984 }
22985
22986 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
22987         LDKUnsignedChannelUpdate this_ptr_conv;
22988         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22989         this_ptr_conv.is_owned = false;
22990         int32_t ret_val = UnsignedChannelUpdate_get_fee_proportional_millionths(&this_ptr_conv);
22991         return ret_val;
22992 }
22993
22994 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
22995         LDKUnsignedChannelUpdate this_ptr_conv;
22996         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22997         this_ptr_conv.is_owned = false;
22998         UnsignedChannelUpdate_set_fee_proportional_millionths(&this_ptr_conv, val);
22999 }
23000
23001 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23002         LDKUnsignedChannelUpdate orig_conv;
23003         orig_conv.inner = (void*)(orig & (~1));
23004         orig_conv.is_owned = false;
23005         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(&orig_conv);
23006         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23007         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23008         uint64_t ret_ref = (uint64_t)ret_var.inner;
23009         if (ret_var.is_owned) {
23010                 ret_ref |= 1;
23011         }
23012         return ret_ref;
23013 }
23014
23015 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23016         LDKChannelUpdate this_obj_conv;
23017         this_obj_conv.inner = (void*)(this_obj & (~1));
23018         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23019         ChannelUpdate_free(this_obj_conv);
23020 }
23021
23022 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
23023         LDKChannelUpdate this_ptr_conv;
23024         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23025         this_ptr_conv.is_owned = false;
23026         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
23027         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelUpdate_get_signature(&this_ptr_conv).compact_form);
23028         return ret_arr;
23029 }
23030
23031 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
23032         LDKChannelUpdate this_ptr_conv;
23033         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23034         this_ptr_conv.is_owned = false;
23035         LDKSignature val_ref;
23036         CHECK((*env)->GetArrayLength(env, val) == 64);
23037         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
23038         ChannelUpdate_set_signature(&this_ptr_conv, val_ref);
23039 }
23040
23041 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
23042         LDKChannelUpdate this_ptr_conv;
23043         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23044         this_ptr_conv.is_owned = false;
23045         LDKUnsignedChannelUpdate ret_var = ChannelUpdate_get_contents(&this_ptr_conv);
23046         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23047         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23048         uint64_t ret_ref = (uint64_t)ret_var.inner;
23049         if (ret_var.is_owned) {
23050                 ret_ref |= 1;
23051         }
23052         return ret_ref;
23053 }
23054
23055 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23056         LDKChannelUpdate this_ptr_conv;
23057         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23058         this_ptr_conv.is_owned = false;
23059         LDKUnsignedChannelUpdate val_conv;
23060         val_conv.inner = (void*)(val & (~1));
23061         val_conv.is_owned = (val & 1) || (val == 0);
23062         val_conv = UnsignedChannelUpdate_clone(&val_conv);
23063         ChannelUpdate_set_contents(&this_ptr_conv, val_conv);
23064 }
23065
23066 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1new(JNIEnv *env, jclass clz, int8_tArray signature_arg, int64_t contents_arg) {
23067         LDKSignature signature_arg_ref;
23068         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
23069         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
23070         LDKUnsignedChannelUpdate contents_arg_conv;
23071         contents_arg_conv.inner = (void*)(contents_arg & (~1));
23072         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
23073         contents_arg_conv = UnsignedChannelUpdate_clone(&contents_arg_conv);
23074         LDKChannelUpdate ret_var = ChannelUpdate_new(signature_arg_ref, contents_arg_conv);
23075         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23076         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23077         uint64_t ret_ref = (uint64_t)ret_var.inner;
23078         if (ret_var.is_owned) {
23079                 ret_ref |= 1;
23080         }
23081         return ret_ref;
23082 }
23083
23084 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23085         LDKChannelUpdate orig_conv;
23086         orig_conv.inner = (void*)(orig & (~1));
23087         orig_conv.is_owned = false;
23088         LDKChannelUpdate ret_var = ChannelUpdate_clone(&orig_conv);
23089         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23090         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23091         uint64_t ret_ref = (uint64_t)ret_var.inner;
23092         if (ret_var.is_owned) {
23093                 ret_ref |= 1;
23094         }
23095         return ret_ref;
23096 }
23097
23098 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23099         LDKQueryChannelRange this_obj_conv;
23100         this_obj_conv.inner = (void*)(this_obj & (~1));
23101         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23102         QueryChannelRange_free(this_obj_conv);
23103 }
23104
23105 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
23106         LDKQueryChannelRange this_ptr_conv;
23107         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23108         this_ptr_conv.is_owned = false;
23109         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
23110         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *QueryChannelRange_get_chain_hash(&this_ptr_conv));
23111         return ret_arr;
23112 }
23113
23114 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
23115         LDKQueryChannelRange this_ptr_conv;
23116         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23117         this_ptr_conv.is_owned = false;
23118         LDKThirtyTwoBytes val_ref;
23119         CHECK((*env)->GetArrayLength(env, val) == 32);
23120         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
23121         QueryChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
23122 }
23123
23124 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr) {
23125         LDKQueryChannelRange this_ptr_conv;
23126         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23127         this_ptr_conv.is_owned = false;
23128         int32_t ret_val = QueryChannelRange_get_first_blocknum(&this_ptr_conv);
23129         return ret_val;
23130 }
23131
23132 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
23133         LDKQueryChannelRange this_ptr_conv;
23134         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23135         this_ptr_conv.is_owned = false;
23136         QueryChannelRange_set_first_blocknum(&this_ptr_conv, val);
23137 }
23138
23139 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr) {
23140         LDKQueryChannelRange this_ptr_conv;
23141         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23142         this_ptr_conv.is_owned = false;
23143         int32_t ret_val = QueryChannelRange_get_number_of_blocks(&this_ptr_conv);
23144         return ret_val;
23145 }
23146
23147 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
23148         LDKQueryChannelRange this_ptr_conv;
23149         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23150         this_ptr_conv.is_owned = false;
23151         QueryChannelRange_set_number_of_blocks(&this_ptr_conv, val);
23152 }
23153
23154 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) {
23155         LDKThirtyTwoBytes chain_hash_arg_ref;
23156         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
23157         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
23158         LDKQueryChannelRange ret_var = QueryChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg);
23159         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23160         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23161         uint64_t ret_ref = (uint64_t)ret_var.inner;
23162         if (ret_var.is_owned) {
23163                 ret_ref |= 1;
23164         }
23165         return ret_ref;
23166 }
23167
23168 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23169         LDKQueryChannelRange orig_conv;
23170         orig_conv.inner = (void*)(orig & (~1));
23171         orig_conv.is_owned = false;
23172         LDKQueryChannelRange ret_var = QueryChannelRange_clone(&orig_conv);
23173         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23174         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23175         uint64_t ret_ref = (uint64_t)ret_var.inner;
23176         if (ret_var.is_owned) {
23177                 ret_ref |= 1;
23178         }
23179         return ret_ref;
23180 }
23181
23182 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23183         LDKReplyChannelRange this_obj_conv;
23184         this_obj_conv.inner = (void*)(this_obj & (~1));
23185         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23186         ReplyChannelRange_free(this_obj_conv);
23187 }
23188
23189 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
23190         LDKReplyChannelRange this_ptr_conv;
23191         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23192         this_ptr_conv.is_owned = false;
23193         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
23194         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ReplyChannelRange_get_chain_hash(&this_ptr_conv));
23195         return ret_arr;
23196 }
23197
23198 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
23199         LDKReplyChannelRange this_ptr_conv;
23200         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23201         this_ptr_conv.is_owned = false;
23202         LDKThirtyTwoBytes val_ref;
23203         CHECK((*env)->GetArrayLength(env, val) == 32);
23204         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
23205         ReplyChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
23206 }
23207
23208 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr) {
23209         LDKReplyChannelRange this_ptr_conv;
23210         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23211         this_ptr_conv.is_owned = false;
23212         int32_t ret_val = ReplyChannelRange_get_first_blocknum(&this_ptr_conv);
23213         return ret_val;
23214 }
23215
23216 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
23217         LDKReplyChannelRange this_ptr_conv;
23218         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23219         this_ptr_conv.is_owned = false;
23220         ReplyChannelRange_set_first_blocknum(&this_ptr_conv, val);
23221 }
23222
23223 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr) {
23224         LDKReplyChannelRange this_ptr_conv;
23225         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23226         this_ptr_conv.is_owned = false;
23227         int32_t ret_val = ReplyChannelRange_get_number_of_blocks(&this_ptr_conv);
23228         return ret_val;
23229 }
23230
23231 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
23232         LDKReplyChannelRange this_ptr_conv;
23233         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23234         this_ptr_conv.is_owned = false;
23235         ReplyChannelRange_set_number_of_blocks(&this_ptr_conv, val);
23236 }
23237
23238 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1sync_1complete(JNIEnv *env, jclass clz, int64_t this_ptr) {
23239         LDKReplyChannelRange this_ptr_conv;
23240         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23241         this_ptr_conv.is_owned = false;
23242         jboolean ret_val = ReplyChannelRange_get_sync_complete(&this_ptr_conv);
23243         return ret_val;
23244 }
23245
23246 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1sync_1complete(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
23247         LDKReplyChannelRange this_ptr_conv;
23248         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23249         this_ptr_conv.is_owned = false;
23250         ReplyChannelRange_set_sync_complete(&this_ptr_conv, val);
23251 }
23252
23253 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
23254         LDKReplyChannelRange this_ptr_conv;
23255         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23256         this_ptr_conv.is_owned = false;
23257         LDKCVec_u64Z val_constr;
23258         val_constr.datalen = (*env)->GetArrayLength(env, val);
23259         if (val_constr.datalen > 0)
23260                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
23261         else
23262                 val_constr.data = NULL;
23263         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
23264         for (size_t g = 0; g < val_constr.datalen; g++) {
23265                 int64_t val_conv_6 = val_vals[g];
23266                 val_constr.data[g] = val_conv_6;
23267         }
23268         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
23269         ReplyChannelRange_set_short_channel_ids(&this_ptr_conv, val_constr);
23270 }
23271
23272 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) {
23273         LDKThirtyTwoBytes chain_hash_arg_ref;
23274         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
23275         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
23276         LDKCVec_u64Z short_channel_ids_arg_constr;
23277         short_channel_ids_arg_constr.datalen = (*env)->GetArrayLength(env, short_channel_ids_arg);
23278         if (short_channel_ids_arg_constr.datalen > 0)
23279                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
23280         else
23281                 short_channel_ids_arg_constr.data = NULL;
23282         int64_t* short_channel_ids_arg_vals = (*env)->GetLongArrayElements (env, short_channel_ids_arg, NULL);
23283         for (size_t g = 0; g < short_channel_ids_arg_constr.datalen; g++) {
23284                 int64_t short_channel_ids_arg_conv_6 = short_channel_ids_arg_vals[g];
23285                 short_channel_ids_arg_constr.data[g] = short_channel_ids_arg_conv_6;
23286         }
23287         (*env)->ReleaseLongArrayElements(env, short_channel_ids_arg, short_channel_ids_arg_vals, 0);
23288         LDKReplyChannelRange ret_var = ReplyChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg, sync_complete_arg, short_channel_ids_arg_constr);
23289         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23290         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23291         uint64_t ret_ref = (uint64_t)ret_var.inner;
23292         if (ret_var.is_owned) {
23293                 ret_ref |= 1;
23294         }
23295         return ret_ref;
23296 }
23297
23298 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23299         LDKReplyChannelRange orig_conv;
23300         orig_conv.inner = (void*)(orig & (~1));
23301         orig_conv.is_owned = false;
23302         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(&orig_conv);
23303         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23304         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23305         uint64_t ret_ref = (uint64_t)ret_var.inner;
23306         if (ret_var.is_owned) {
23307                 ret_ref |= 1;
23308         }
23309         return ret_ref;
23310 }
23311
23312 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23313         LDKQueryShortChannelIds this_obj_conv;
23314         this_obj_conv.inner = (void*)(this_obj & (~1));
23315         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23316         QueryShortChannelIds_free(this_obj_conv);
23317 }
23318
23319 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
23320         LDKQueryShortChannelIds this_ptr_conv;
23321         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23322         this_ptr_conv.is_owned = false;
23323         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
23324         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *QueryShortChannelIds_get_chain_hash(&this_ptr_conv));
23325         return ret_arr;
23326 }
23327
23328 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
23329         LDKQueryShortChannelIds this_ptr_conv;
23330         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23331         this_ptr_conv.is_owned = false;
23332         LDKThirtyTwoBytes val_ref;
23333         CHECK((*env)->GetArrayLength(env, val) == 32);
23334         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
23335         QueryShortChannelIds_set_chain_hash(&this_ptr_conv, val_ref);
23336 }
23337
23338 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1set_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
23339         LDKQueryShortChannelIds this_ptr_conv;
23340         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23341         this_ptr_conv.is_owned = false;
23342         LDKCVec_u64Z val_constr;
23343         val_constr.datalen = (*env)->GetArrayLength(env, val);
23344         if (val_constr.datalen > 0)
23345                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
23346         else
23347                 val_constr.data = NULL;
23348         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
23349         for (size_t g = 0; g < val_constr.datalen; g++) {
23350                 int64_t val_conv_6 = val_vals[g];
23351                 val_constr.data[g] = val_conv_6;
23352         }
23353         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
23354         QueryShortChannelIds_set_short_channel_ids(&this_ptr_conv, val_constr);
23355 }
23356
23357 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) {
23358         LDKThirtyTwoBytes chain_hash_arg_ref;
23359         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
23360         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
23361         LDKCVec_u64Z short_channel_ids_arg_constr;
23362         short_channel_ids_arg_constr.datalen = (*env)->GetArrayLength(env, short_channel_ids_arg);
23363         if (short_channel_ids_arg_constr.datalen > 0)
23364                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
23365         else
23366                 short_channel_ids_arg_constr.data = NULL;
23367         int64_t* short_channel_ids_arg_vals = (*env)->GetLongArrayElements (env, short_channel_ids_arg, NULL);
23368         for (size_t g = 0; g < short_channel_ids_arg_constr.datalen; g++) {
23369                 int64_t short_channel_ids_arg_conv_6 = short_channel_ids_arg_vals[g];
23370                 short_channel_ids_arg_constr.data[g] = short_channel_ids_arg_conv_6;
23371         }
23372         (*env)->ReleaseLongArrayElements(env, short_channel_ids_arg, short_channel_ids_arg_vals, 0);
23373         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_new(chain_hash_arg_ref, short_channel_ids_arg_constr);
23374         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23375         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23376         uint64_t ret_ref = (uint64_t)ret_var.inner;
23377         if (ret_var.is_owned) {
23378                 ret_ref |= 1;
23379         }
23380         return ret_ref;
23381 }
23382
23383 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23384         LDKQueryShortChannelIds orig_conv;
23385         orig_conv.inner = (void*)(orig & (~1));
23386         orig_conv.is_owned = false;
23387         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(&orig_conv);
23388         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23389         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23390         uint64_t ret_ref = (uint64_t)ret_var.inner;
23391         if (ret_var.is_owned) {
23392                 ret_ref |= 1;
23393         }
23394         return ret_ref;
23395 }
23396
23397 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23398         LDKReplyShortChannelIdsEnd this_obj_conv;
23399         this_obj_conv.inner = (void*)(this_obj & (~1));
23400         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23401         ReplyShortChannelIdsEnd_free(this_obj_conv);
23402 }
23403
23404 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
23405         LDKReplyShortChannelIdsEnd this_ptr_conv;
23406         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23407         this_ptr_conv.is_owned = false;
23408         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
23409         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ReplyShortChannelIdsEnd_get_chain_hash(&this_ptr_conv));
23410         return ret_arr;
23411 }
23412
23413 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
23414         LDKReplyShortChannelIdsEnd this_ptr_conv;
23415         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23416         this_ptr_conv.is_owned = false;
23417         LDKThirtyTwoBytes val_ref;
23418         CHECK((*env)->GetArrayLength(env, val) == 32);
23419         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
23420         ReplyShortChannelIdsEnd_set_chain_hash(&this_ptr_conv, val_ref);
23421 }
23422
23423 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1get_1full_1information(JNIEnv *env, jclass clz, int64_t this_ptr) {
23424         LDKReplyShortChannelIdsEnd this_ptr_conv;
23425         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23426         this_ptr_conv.is_owned = false;
23427         jboolean ret_val = ReplyShortChannelIdsEnd_get_full_information(&this_ptr_conv);
23428         return ret_val;
23429 }
23430
23431 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1set_1full_1information(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
23432         LDKReplyShortChannelIdsEnd this_ptr_conv;
23433         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23434         this_ptr_conv.is_owned = false;
23435         ReplyShortChannelIdsEnd_set_full_information(&this_ptr_conv, val);
23436 }
23437
23438 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1new(JNIEnv *env, jclass clz, int8_tArray chain_hash_arg, jboolean full_information_arg) {
23439         LDKThirtyTwoBytes chain_hash_arg_ref;
23440         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
23441         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
23442         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_new(chain_hash_arg_ref, full_information_arg);
23443         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23444         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23445         uint64_t ret_ref = (uint64_t)ret_var.inner;
23446         if (ret_var.is_owned) {
23447                 ret_ref |= 1;
23448         }
23449         return ret_ref;
23450 }
23451
23452 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23453         LDKReplyShortChannelIdsEnd orig_conv;
23454         orig_conv.inner = (void*)(orig & (~1));
23455         orig_conv.is_owned = false;
23456         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(&orig_conv);
23457         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23458         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23459         uint64_t ret_ref = (uint64_t)ret_var.inner;
23460         if (ret_var.is_owned) {
23461                 ret_ref |= 1;
23462         }
23463         return ret_ref;
23464 }
23465
23466 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23467         LDKGossipTimestampFilter this_obj_conv;
23468         this_obj_conv.inner = (void*)(this_obj & (~1));
23469         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23470         GossipTimestampFilter_free(this_obj_conv);
23471 }
23472
23473 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
23474         LDKGossipTimestampFilter this_ptr_conv;
23475         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23476         this_ptr_conv.is_owned = false;
23477         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
23478         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *GossipTimestampFilter_get_chain_hash(&this_ptr_conv));
23479         return ret_arr;
23480 }
23481
23482 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
23483         LDKGossipTimestampFilter this_ptr_conv;
23484         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23485         this_ptr_conv.is_owned = false;
23486         LDKThirtyTwoBytes val_ref;
23487         CHECK((*env)->GetArrayLength(env, val) == 32);
23488         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
23489         GossipTimestampFilter_set_chain_hash(&this_ptr_conv, val_ref);
23490 }
23491
23492 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1first_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
23493         LDKGossipTimestampFilter this_ptr_conv;
23494         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23495         this_ptr_conv.is_owned = false;
23496         int32_t ret_val = GossipTimestampFilter_get_first_timestamp(&this_ptr_conv);
23497         return ret_val;
23498 }
23499
23500 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1first_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
23501         LDKGossipTimestampFilter this_ptr_conv;
23502         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23503         this_ptr_conv.is_owned = false;
23504         GossipTimestampFilter_set_first_timestamp(&this_ptr_conv, val);
23505 }
23506
23507 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1timestamp_1range(JNIEnv *env, jclass clz, int64_t this_ptr) {
23508         LDKGossipTimestampFilter this_ptr_conv;
23509         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23510         this_ptr_conv.is_owned = false;
23511         int32_t ret_val = GossipTimestampFilter_get_timestamp_range(&this_ptr_conv);
23512         return ret_val;
23513 }
23514
23515 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1timestamp_1range(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
23516         LDKGossipTimestampFilter this_ptr_conv;
23517         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23518         this_ptr_conv.is_owned = false;
23519         GossipTimestampFilter_set_timestamp_range(&this_ptr_conv, val);
23520 }
23521
23522 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) {
23523         LDKThirtyTwoBytes chain_hash_arg_ref;
23524         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
23525         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
23526         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_new(chain_hash_arg_ref, first_timestamp_arg, timestamp_range_arg);
23527         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23528         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23529         uint64_t ret_ref = (uint64_t)ret_var.inner;
23530         if (ret_var.is_owned) {
23531                 ret_ref |= 1;
23532         }
23533         return ret_ref;
23534 }
23535
23536 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23537         LDKGossipTimestampFilter orig_conv;
23538         orig_conv.inner = (void*)(orig & (~1));
23539         orig_conv.is_owned = false;
23540         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(&orig_conv);
23541         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23542         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23543         uint64_t ret_ref = (uint64_t)ret_var.inner;
23544         if (ret_var.is_owned) {
23545                 ret_ref |= 1;
23546         }
23547         return ret_ref;
23548 }
23549
23550 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorAction_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
23551         if ((this_ptr & 1) != 0) return;
23552         LDKErrorAction this_ptr_conv = *(LDKErrorAction*)(((uint64_t)this_ptr) & ~1);
23553         FREE((void*)this_ptr);
23554         ErrorAction_free(this_ptr_conv);
23555 }
23556
23557 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23558         LDKErrorAction* orig_conv = (LDKErrorAction*)orig;
23559         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
23560         *ret_copy = ErrorAction_clone(orig_conv);
23561         uint64_t ret_ref = (uint64_t)ret_copy;
23562         return ret_ref;
23563 }
23564
23565 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1disconnect_1peer(JNIEnv *env, jclass clz, int64_t msg) {
23566         LDKErrorMessage msg_conv;
23567         msg_conv.inner = (void*)(msg & (~1));
23568         msg_conv.is_owned = (msg & 1) || (msg == 0);
23569         msg_conv = ErrorMessage_clone(&msg_conv);
23570         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
23571         *ret_copy = ErrorAction_disconnect_peer(msg_conv);
23572         uint64_t ret_ref = (uint64_t)ret_copy;
23573         return ret_ref;
23574 }
23575
23576 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1ignore_1error(JNIEnv *env, jclass clz) {
23577         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
23578         *ret_copy = ErrorAction_ignore_error();
23579         uint64_t ret_ref = (uint64_t)ret_copy;
23580         return ret_ref;
23581 }
23582
23583 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1ignore_1and_1log(JNIEnv *env, jclass clz, jclass a) {
23584         LDKLevel a_conv = LDKLevel_from_java(env, a);
23585         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
23586         *ret_copy = ErrorAction_ignore_and_log(a_conv);
23587         uint64_t ret_ref = (uint64_t)ret_copy;
23588         return ret_ref;
23589 }
23590
23591 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1send_1error_1message(JNIEnv *env, jclass clz, int64_t msg) {
23592         LDKErrorMessage msg_conv;
23593         msg_conv.inner = (void*)(msg & (~1));
23594         msg_conv.is_owned = (msg & 1) || (msg == 0);
23595         msg_conv = ErrorMessage_clone(&msg_conv);
23596         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
23597         *ret_copy = ErrorAction_send_error_message(msg_conv);
23598         uint64_t ret_ref = (uint64_t)ret_copy;
23599         return ret_ref;
23600 }
23601
23602 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23603         LDKLightningError this_obj_conv;
23604         this_obj_conv.inner = (void*)(this_obj & (~1));
23605         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23606         LightningError_free(this_obj_conv);
23607 }
23608
23609 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_LightningError_1get_1err(JNIEnv *env, jclass clz, int64_t this_ptr) {
23610         LDKLightningError this_ptr_conv;
23611         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23612         this_ptr_conv.is_owned = false;
23613         LDKStr ret_str = LightningError_get_err(&this_ptr_conv);
23614         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
23615         Str_free(ret_str);
23616         return ret_conv;
23617 }
23618
23619 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1set_1err(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
23620         LDKLightningError this_ptr_conv;
23621         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23622         this_ptr_conv.is_owned = false;
23623         LDKStr val_conv = java_to_owned_str(env, val);
23624         LightningError_set_err(&this_ptr_conv, val_conv);
23625 }
23626
23627 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1get_1action(JNIEnv *env, jclass clz, int64_t this_ptr) {
23628         LDKLightningError this_ptr_conv;
23629         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23630         this_ptr_conv.is_owned = false;
23631         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
23632         *ret_copy = LightningError_get_action(&this_ptr_conv);
23633         uint64_t ret_ref = (uint64_t)ret_copy;
23634         return ret_ref;
23635 }
23636
23637 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1set_1action(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23638         LDKLightningError this_ptr_conv;
23639         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23640         this_ptr_conv.is_owned = false;
23641         LDKErrorAction val_conv = *(LDKErrorAction*)(((uint64_t)val) & ~1);
23642         val_conv = ErrorAction_clone((LDKErrorAction*)(((uint64_t)val) & ~1));
23643         LightningError_set_action(&this_ptr_conv, val_conv);
23644 }
23645
23646 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1new(JNIEnv *env, jclass clz, jstring err_arg, int64_t action_arg) {
23647         LDKStr err_arg_conv = java_to_owned_str(env, err_arg);
23648         LDKErrorAction action_arg_conv = *(LDKErrorAction*)(((uint64_t)action_arg) & ~1);
23649         action_arg_conv = ErrorAction_clone((LDKErrorAction*)(((uint64_t)action_arg) & ~1));
23650         LDKLightningError ret_var = LightningError_new(err_arg_conv, action_arg_conv);
23651         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23652         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23653         uint64_t ret_ref = (uint64_t)ret_var.inner;
23654         if (ret_var.is_owned) {
23655                 ret_ref |= 1;
23656         }
23657         return ret_ref;
23658 }
23659
23660 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23661         LDKLightningError orig_conv;
23662         orig_conv.inner = (void*)(orig & (~1));
23663         orig_conv.is_owned = false;
23664         LDKLightningError ret_var = LightningError_clone(&orig_conv);
23665         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23666         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23667         uint64_t ret_ref = (uint64_t)ret_var.inner;
23668         if (ret_var.is_owned) {
23669                 ret_ref |= 1;
23670         }
23671         return ret_ref;
23672 }
23673
23674 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23675         LDKCommitmentUpdate this_obj_conv;
23676         this_obj_conv.inner = (void*)(this_obj & (~1));
23677         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23678         CommitmentUpdate_free(this_obj_conv);
23679 }
23680
23681 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1add_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
23682         LDKCommitmentUpdate this_ptr_conv;
23683         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23684         this_ptr_conv.is_owned = false;
23685         LDKCVec_UpdateAddHTLCZ ret_var = CommitmentUpdate_get_update_add_htlcs(&this_ptr_conv);
23686         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
23687         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
23688         for (size_t p = 0; p < ret_var.datalen; p++) {
23689                 LDKUpdateAddHTLC ret_conv_15_var = ret_var.data[p];
23690                 CHECK((((uint64_t)ret_conv_15_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23691                 CHECK((((uint64_t)&ret_conv_15_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23692                 uint64_t ret_conv_15_ref = (uint64_t)ret_conv_15_var.inner;
23693                 if (ret_conv_15_var.is_owned) {
23694                         ret_conv_15_ref |= 1;
23695                 }
23696                 ret_arr_ptr[p] = ret_conv_15_ref;
23697         }
23698         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
23699         FREE(ret_var.data);
23700         return ret_arr;
23701 }
23702
23703 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1add_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
23704         LDKCommitmentUpdate this_ptr_conv;
23705         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23706         this_ptr_conv.is_owned = false;
23707         LDKCVec_UpdateAddHTLCZ val_constr;
23708         val_constr.datalen = (*env)->GetArrayLength(env, val);
23709         if (val_constr.datalen > 0)
23710                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
23711         else
23712                 val_constr.data = NULL;
23713         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
23714         for (size_t p = 0; p < val_constr.datalen; p++) {
23715                 int64_t val_conv_15 = val_vals[p];
23716                 LDKUpdateAddHTLC val_conv_15_conv;
23717                 val_conv_15_conv.inner = (void*)(val_conv_15 & (~1));
23718                 val_conv_15_conv.is_owned = (val_conv_15 & 1) || (val_conv_15 == 0);
23719                 val_conv_15_conv = UpdateAddHTLC_clone(&val_conv_15_conv);
23720                 val_constr.data[p] = val_conv_15_conv;
23721         }
23722         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
23723         CommitmentUpdate_set_update_add_htlcs(&this_ptr_conv, val_constr);
23724 }
23725
23726 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fulfill_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
23727         LDKCommitmentUpdate this_ptr_conv;
23728         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23729         this_ptr_conv.is_owned = false;
23730         LDKCVec_UpdateFulfillHTLCZ ret_var = CommitmentUpdate_get_update_fulfill_htlcs(&this_ptr_conv);
23731         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
23732         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
23733         for (size_t t = 0; t < ret_var.datalen; t++) {
23734                 LDKUpdateFulfillHTLC ret_conv_19_var = ret_var.data[t];
23735                 CHECK((((uint64_t)ret_conv_19_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23736                 CHECK((((uint64_t)&ret_conv_19_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23737                 uint64_t ret_conv_19_ref = (uint64_t)ret_conv_19_var.inner;
23738                 if (ret_conv_19_var.is_owned) {
23739                         ret_conv_19_ref |= 1;
23740                 }
23741                 ret_arr_ptr[t] = ret_conv_19_ref;
23742         }
23743         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
23744         FREE(ret_var.data);
23745         return ret_arr;
23746 }
23747
23748 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fulfill_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
23749         LDKCommitmentUpdate this_ptr_conv;
23750         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23751         this_ptr_conv.is_owned = false;
23752         LDKCVec_UpdateFulfillHTLCZ val_constr;
23753         val_constr.datalen = (*env)->GetArrayLength(env, val);
23754         if (val_constr.datalen > 0)
23755                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
23756         else
23757                 val_constr.data = NULL;
23758         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
23759         for (size_t t = 0; t < val_constr.datalen; t++) {
23760                 int64_t val_conv_19 = val_vals[t];
23761                 LDKUpdateFulfillHTLC val_conv_19_conv;
23762                 val_conv_19_conv.inner = (void*)(val_conv_19 & (~1));
23763                 val_conv_19_conv.is_owned = (val_conv_19 & 1) || (val_conv_19 == 0);
23764                 val_conv_19_conv = UpdateFulfillHTLC_clone(&val_conv_19_conv);
23765                 val_constr.data[t] = val_conv_19_conv;
23766         }
23767         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
23768         CommitmentUpdate_set_update_fulfill_htlcs(&this_ptr_conv, val_constr);
23769 }
23770
23771 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fail_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
23772         LDKCommitmentUpdate this_ptr_conv;
23773         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23774         this_ptr_conv.is_owned = false;
23775         LDKCVec_UpdateFailHTLCZ ret_var = CommitmentUpdate_get_update_fail_htlcs(&this_ptr_conv);
23776         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
23777         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
23778         for (size_t q = 0; q < ret_var.datalen; q++) {
23779                 LDKUpdateFailHTLC ret_conv_16_var = ret_var.data[q];
23780                 CHECK((((uint64_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23781                 CHECK((((uint64_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23782                 uint64_t ret_conv_16_ref = (uint64_t)ret_conv_16_var.inner;
23783                 if (ret_conv_16_var.is_owned) {
23784                         ret_conv_16_ref |= 1;
23785                 }
23786                 ret_arr_ptr[q] = ret_conv_16_ref;
23787         }
23788         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
23789         FREE(ret_var.data);
23790         return ret_arr;
23791 }
23792
23793 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fail_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
23794         LDKCommitmentUpdate this_ptr_conv;
23795         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23796         this_ptr_conv.is_owned = false;
23797         LDKCVec_UpdateFailHTLCZ val_constr;
23798         val_constr.datalen = (*env)->GetArrayLength(env, val);
23799         if (val_constr.datalen > 0)
23800                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
23801         else
23802                 val_constr.data = NULL;
23803         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
23804         for (size_t q = 0; q < val_constr.datalen; q++) {
23805                 int64_t val_conv_16 = val_vals[q];
23806                 LDKUpdateFailHTLC val_conv_16_conv;
23807                 val_conv_16_conv.inner = (void*)(val_conv_16 & (~1));
23808                 val_conv_16_conv.is_owned = (val_conv_16 & 1) || (val_conv_16 == 0);
23809                 val_conv_16_conv = UpdateFailHTLC_clone(&val_conv_16_conv);
23810                 val_constr.data[q] = val_conv_16_conv;
23811         }
23812         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
23813         CommitmentUpdate_set_update_fail_htlcs(&this_ptr_conv, val_constr);
23814 }
23815
23816 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fail_1malformed_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
23817         LDKCommitmentUpdate this_ptr_conv;
23818         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23819         this_ptr_conv.is_owned = false;
23820         LDKCVec_UpdateFailMalformedHTLCZ ret_var = CommitmentUpdate_get_update_fail_malformed_htlcs(&this_ptr_conv);
23821         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
23822         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
23823         for (size_t z = 0; z < ret_var.datalen; z++) {
23824                 LDKUpdateFailMalformedHTLC ret_conv_25_var = ret_var.data[z];
23825                 CHECK((((uint64_t)ret_conv_25_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23826                 CHECK((((uint64_t)&ret_conv_25_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23827                 uint64_t ret_conv_25_ref = (uint64_t)ret_conv_25_var.inner;
23828                 if (ret_conv_25_var.is_owned) {
23829                         ret_conv_25_ref |= 1;
23830                 }
23831                 ret_arr_ptr[z] = ret_conv_25_ref;
23832         }
23833         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
23834         FREE(ret_var.data);
23835         return ret_arr;
23836 }
23837
23838 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) {
23839         LDKCommitmentUpdate this_ptr_conv;
23840         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23841         this_ptr_conv.is_owned = false;
23842         LDKCVec_UpdateFailMalformedHTLCZ val_constr;
23843         val_constr.datalen = (*env)->GetArrayLength(env, val);
23844         if (val_constr.datalen > 0)
23845                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
23846         else
23847                 val_constr.data = NULL;
23848         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
23849         for (size_t z = 0; z < val_constr.datalen; z++) {
23850                 int64_t val_conv_25 = val_vals[z];
23851                 LDKUpdateFailMalformedHTLC val_conv_25_conv;
23852                 val_conv_25_conv.inner = (void*)(val_conv_25 & (~1));
23853                 val_conv_25_conv.is_owned = (val_conv_25 & 1) || (val_conv_25 == 0);
23854                 val_conv_25_conv = UpdateFailMalformedHTLC_clone(&val_conv_25_conv);
23855                 val_constr.data[z] = val_conv_25_conv;
23856         }
23857         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
23858         CommitmentUpdate_set_update_fail_malformed_htlcs(&this_ptr_conv, val_constr);
23859 }
23860
23861 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fee(JNIEnv *env, jclass clz, int64_t this_ptr) {
23862         LDKCommitmentUpdate this_ptr_conv;
23863         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23864         this_ptr_conv.is_owned = false;
23865         LDKUpdateFee ret_var = CommitmentUpdate_get_update_fee(&this_ptr_conv);
23866         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23867         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23868         uint64_t ret_ref = (uint64_t)ret_var.inner;
23869         if (ret_var.is_owned) {
23870                 ret_ref |= 1;
23871         }
23872         return ret_ref;
23873 }
23874
23875 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fee(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23876         LDKCommitmentUpdate this_ptr_conv;
23877         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23878         this_ptr_conv.is_owned = false;
23879         LDKUpdateFee val_conv;
23880         val_conv.inner = (void*)(val & (~1));
23881         val_conv.is_owned = (val & 1) || (val == 0);
23882         val_conv = UpdateFee_clone(&val_conv);
23883         CommitmentUpdate_set_update_fee(&this_ptr_conv, val_conv);
23884 }
23885
23886 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1commitment_1signed(JNIEnv *env, jclass clz, int64_t this_ptr) {
23887         LDKCommitmentUpdate this_ptr_conv;
23888         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23889         this_ptr_conv.is_owned = false;
23890         LDKCommitmentSigned ret_var = CommitmentUpdate_get_commitment_signed(&this_ptr_conv);
23891         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23892         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23893         uint64_t ret_ref = (uint64_t)ret_var.inner;
23894         if (ret_var.is_owned) {
23895                 ret_ref |= 1;
23896         }
23897         return ret_ref;
23898 }
23899
23900 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1commitment_1signed(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23901         LDKCommitmentUpdate this_ptr_conv;
23902         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23903         this_ptr_conv.is_owned = false;
23904         LDKCommitmentSigned val_conv;
23905         val_conv.inner = (void*)(val & (~1));
23906         val_conv.is_owned = (val & 1) || (val == 0);
23907         val_conv = CommitmentSigned_clone(&val_conv);
23908         CommitmentUpdate_set_commitment_signed(&this_ptr_conv, val_conv);
23909 }
23910
23911 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) {
23912         LDKCVec_UpdateAddHTLCZ update_add_htlcs_arg_constr;
23913         update_add_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_add_htlcs_arg);
23914         if (update_add_htlcs_arg_constr.datalen > 0)
23915                 update_add_htlcs_arg_constr.data = MALLOC(update_add_htlcs_arg_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
23916         else
23917                 update_add_htlcs_arg_constr.data = NULL;
23918         int64_t* update_add_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_add_htlcs_arg, NULL);
23919         for (size_t p = 0; p < update_add_htlcs_arg_constr.datalen; p++) {
23920                 int64_t update_add_htlcs_arg_conv_15 = update_add_htlcs_arg_vals[p];
23921                 LDKUpdateAddHTLC update_add_htlcs_arg_conv_15_conv;
23922                 update_add_htlcs_arg_conv_15_conv.inner = (void*)(update_add_htlcs_arg_conv_15 & (~1));
23923                 update_add_htlcs_arg_conv_15_conv.is_owned = (update_add_htlcs_arg_conv_15 & 1) || (update_add_htlcs_arg_conv_15 == 0);
23924                 update_add_htlcs_arg_conv_15_conv = UpdateAddHTLC_clone(&update_add_htlcs_arg_conv_15_conv);
23925                 update_add_htlcs_arg_constr.data[p] = update_add_htlcs_arg_conv_15_conv;
23926         }
23927         (*env)->ReleaseLongArrayElements(env, update_add_htlcs_arg, update_add_htlcs_arg_vals, 0);
23928         LDKCVec_UpdateFulfillHTLCZ update_fulfill_htlcs_arg_constr;
23929         update_fulfill_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fulfill_htlcs_arg);
23930         if (update_fulfill_htlcs_arg_constr.datalen > 0)
23931                 update_fulfill_htlcs_arg_constr.data = MALLOC(update_fulfill_htlcs_arg_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
23932         else
23933                 update_fulfill_htlcs_arg_constr.data = NULL;
23934         int64_t* update_fulfill_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fulfill_htlcs_arg, NULL);
23935         for (size_t t = 0; t < update_fulfill_htlcs_arg_constr.datalen; t++) {
23936                 int64_t update_fulfill_htlcs_arg_conv_19 = update_fulfill_htlcs_arg_vals[t];
23937                 LDKUpdateFulfillHTLC update_fulfill_htlcs_arg_conv_19_conv;
23938                 update_fulfill_htlcs_arg_conv_19_conv.inner = (void*)(update_fulfill_htlcs_arg_conv_19 & (~1));
23939                 update_fulfill_htlcs_arg_conv_19_conv.is_owned = (update_fulfill_htlcs_arg_conv_19 & 1) || (update_fulfill_htlcs_arg_conv_19 == 0);
23940                 update_fulfill_htlcs_arg_conv_19_conv = UpdateFulfillHTLC_clone(&update_fulfill_htlcs_arg_conv_19_conv);
23941                 update_fulfill_htlcs_arg_constr.data[t] = update_fulfill_htlcs_arg_conv_19_conv;
23942         }
23943         (*env)->ReleaseLongArrayElements(env, update_fulfill_htlcs_arg, update_fulfill_htlcs_arg_vals, 0);
23944         LDKCVec_UpdateFailHTLCZ update_fail_htlcs_arg_constr;
23945         update_fail_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fail_htlcs_arg);
23946         if (update_fail_htlcs_arg_constr.datalen > 0)
23947                 update_fail_htlcs_arg_constr.data = MALLOC(update_fail_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
23948         else
23949                 update_fail_htlcs_arg_constr.data = NULL;
23950         int64_t* update_fail_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fail_htlcs_arg, NULL);
23951         for (size_t q = 0; q < update_fail_htlcs_arg_constr.datalen; q++) {
23952                 int64_t update_fail_htlcs_arg_conv_16 = update_fail_htlcs_arg_vals[q];
23953                 LDKUpdateFailHTLC update_fail_htlcs_arg_conv_16_conv;
23954                 update_fail_htlcs_arg_conv_16_conv.inner = (void*)(update_fail_htlcs_arg_conv_16 & (~1));
23955                 update_fail_htlcs_arg_conv_16_conv.is_owned = (update_fail_htlcs_arg_conv_16 & 1) || (update_fail_htlcs_arg_conv_16 == 0);
23956                 update_fail_htlcs_arg_conv_16_conv = UpdateFailHTLC_clone(&update_fail_htlcs_arg_conv_16_conv);
23957                 update_fail_htlcs_arg_constr.data[q] = update_fail_htlcs_arg_conv_16_conv;
23958         }
23959         (*env)->ReleaseLongArrayElements(env, update_fail_htlcs_arg, update_fail_htlcs_arg_vals, 0);
23960         LDKCVec_UpdateFailMalformedHTLCZ update_fail_malformed_htlcs_arg_constr;
23961         update_fail_malformed_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fail_malformed_htlcs_arg);
23962         if (update_fail_malformed_htlcs_arg_constr.datalen > 0)
23963                 update_fail_malformed_htlcs_arg_constr.data = MALLOC(update_fail_malformed_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
23964         else
23965                 update_fail_malformed_htlcs_arg_constr.data = NULL;
23966         int64_t* update_fail_malformed_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fail_malformed_htlcs_arg, NULL);
23967         for (size_t z = 0; z < update_fail_malformed_htlcs_arg_constr.datalen; z++) {
23968                 int64_t update_fail_malformed_htlcs_arg_conv_25 = update_fail_malformed_htlcs_arg_vals[z];
23969                 LDKUpdateFailMalformedHTLC update_fail_malformed_htlcs_arg_conv_25_conv;
23970                 update_fail_malformed_htlcs_arg_conv_25_conv.inner = (void*)(update_fail_malformed_htlcs_arg_conv_25 & (~1));
23971                 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);
23972                 update_fail_malformed_htlcs_arg_conv_25_conv = UpdateFailMalformedHTLC_clone(&update_fail_malformed_htlcs_arg_conv_25_conv);
23973                 update_fail_malformed_htlcs_arg_constr.data[z] = update_fail_malformed_htlcs_arg_conv_25_conv;
23974         }
23975         (*env)->ReleaseLongArrayElements(env, update_fail_malformed_htlcs_arg, update_fail_malformed_htlcs_arg_vals, 0);
23976         LDKUpdateFee update_fee_arg_conv;
23977         update_fee_arg_conv.inner = (void*)(update_fee_arg & (~1));
23978         update_fee_arg_conv.is_owned = (update_fee_arg & 1) || (update_fee_arg == 0);
23979         update_fee_arg_conv = UpdateFee_clone(&update_fee_arg_conv);
23980         LDKCommitmentSigned commitment_signed_arg_conv;
23981         commitment_signed_arg_conv.inner = (void*)(commitment_signed_arg & (~1));
23982         commitment_signed_arg_conv.is_owned = (commitment_signed_arg & 1) || (commitment_signed_arg == 0);
23983         commitment_signed_arg_conv = CommitmentSigned_clone(&commitment_signed_arg_conv);
23984         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);
23985         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23986         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23987         uint64_t ret_ref = (uint64_t)ret_var.inner;
23988         if (ret_var.is_owned) {
23989                 ret_ref |= 1;
23990         }
23991         return ret_ref;
23992 }
23993
23994 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23995         LDKCommitmentUpdate orig_conv;
23996         orig_conv.inner = (void*)(orig & (~1));
23997         orig_conv.is_owned = false;
23998         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(&orig_conv);
23999         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24000         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24001         uint64_t ret_ref = (uint64_t)ret_var.inner;
24002         if (ret_var.is_owned) {
24003                 ret_ref |= 1;
24004         }
24005         return ret_ref;
24006 }
24007
24008 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
24009         if ((this_ptr & 1) != 0) return;
24010         LDKChannelMessageHandler this_ptr_conv = *(LDKChannelMessageHandler*)(((uint64_t)this_ptr) & ~1);
24011         FREE((void*)this_ptr);
24012         ChannelMessageHandler_free(this_ptr_conv);
24013 }
24014
24015 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
24016         if ((this_ptr & 1) != 0) return;
24017         LDKRoutingMessageHandler this_ptr_conv = *(LDKRoutingMessageHandler*)(((uint64_t)this_ptr) & ~1);
24018         FREE((void*)this_ptr);
24019         RoutingMessageHandler_free(this_ptr_conv);
24020 }
24021
24022 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1write(JNIEnv *env, jclass clz, int64_t obj) {
24023         LDKAcceptChannel obj_conv;
24024         obj_conv.inner = (void*)(obj & (~1));
24025         obj_conv.is_owned = false;
24026         LDKCVec_u8Z ret_var = AcceptChannel_write(&obj_conv);
24027         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24028         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24029         CVec_u8Z_free(ret_var);
24030         return ret_arr;
24031 }
24032
24033 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24034         LDKu8slice ser_ref;
24035         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24036         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24037         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
24038         *ret_conv = AcceptChannel_read(ser_ref);
24039         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24040         return (uint64_t)ret_conv;
24041 }
24042
24043 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
24044         LDKAnnouncementSignatures obj_conv;
24045         obj_conv.inner = (void*)(obj & (~1));
24046         obj_conv.is_owned = false;
24047         LDKCVec_u8Z ret_var = AnnouncementSignatures_write(&obj_conv);
24048         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24049         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24050         CVec_u8Z_free(ret_var);
24051         return ret_arr;
24052 }
24053
24054 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24055         LDKu8slice ser_ref;
24056         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24057         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24058         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
24059         *ret_conv = AnnouncementSignatures_read(ser_ref);
24060         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24061         return (uint64_t)ret_conv;
24062 }
24063
24064 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1write(JNIEnv *env, jclass clz, int64_t obj) {
24065         LDKChannelReestablish obj_conv;
24066         obj_conv.inner = (void*)(obj & (~1));
24067         obj_conv.is_owned = false;
24068         LDKCVec_u8Z ret_var = ChannelReestablish_write(&obj_conv);
24069         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24070         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24071         CVec_u8Z_free(ret_var);
24072         return ret_arr;
24073 }
24074
24075 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24076         LDKu8slice ser_ref;
24077         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24078         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24079         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
24080         *ret_conv = ChannelReestablish_read(ser_ref);
24081         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24082         return (uint64_t)ret_conv;
24083 }
24084
24085 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
24086         LDKClosingSigned obj_conv;
24087         obj_conv.inner = (void*)(obj & (~1));
24088         obj_conv.is_owned = false;
24089         LDKCVec_u8Z ret_var = ClosingSigned_write(&obj_conv);
24090         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24091         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24092         CVec_u8Z_free(ret_var);
24093         return ret_arr;
24094 }
24095
24096 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24097         LDKu8slice ser_ref;
24098         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24099         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24100         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
24101         *ret_conv = ClosingSigned_read(ser_ref);
24102         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24103         return (uint64_t)ret_conv;
24104 }
24105
24106 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
24107         LDKClosingSignedFeeRange obj_conv;
24108         obj_conv.inner = (void*)(obj & (~1));
24109         obj_conv.is_owned = false;
24110         LDKCVec_u8Z ret_var = ClosingSignedFeeRange_write(&obj_conv);
24111         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24112         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24113         CVec_u8Z_free(ret_var);
24114         return ret_arr;
24115 }
24116
24117 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24118         LDKu8slice ser_ref;
24119         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24120         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24121         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
24122         *ret_conv = ClosingSignedFeeRange_read(ser_ref);
24123         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24124         return (uint64_t)ret_conv;
24125 }
24126
24127 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
24128         LDKCommitmentSigned obj_conv;
24129         obj_conv.inner = (void*)(obj & (~1));
24130         obj_conv.is_owned = false;
24131         LDKCVec_u8Z ret_var = CommitmentSigned_write(&obj_conv);
24132         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24133         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24134         CVec_u8Z_free(ret_var);
24135         return ret_arr;
24136 }
24137
24138 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24139         LDKu8slice ser_ref;
24140         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24141         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24142         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
24143         *ret_conv = CommitmentSigned_read(ser_ref);
24144         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24145         return (uint64_t)ret_conv;
24146 }
24147
24148 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1write(JNIEnv *env, jclass clz, int64_t obj) {
24149         LDKFundingCreated obj_conv;
24150         obj_conv.inner = (void*)(obj & (~1));
24151         obj_conv.is_owned = false;
24152         LDKCVec_u8Z ret_var = FundingCreated_write(&obj_conv);
24153         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24154         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24155         CVec_u8Z_free(ret_var);
24156         return ret_arr;
24157 }
24158
24159 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24160         LDKu8slice ser_ref;
24161         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24162         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24163         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
24164         *ret_conv = FundingCreated_read(ser_ref);
24165         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24166         return (uint64_t)ret_conv;
24167 }
24168
24169 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
24170         LDKFundingSigned obj_conv;
24171         obj_conv.inner = (void*)(obj & (~1));
24172         obj_conv.is_owned = false;
24173         LDKCVec_u8Z ret_var = FundingSigned_write(&obj_conv);
24174         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24175         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24176         CVec_u8Z_free(ret_var);
24177         return ret_arr;
24178 }
24179
24180 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24181         LDKu8slice ser_ref;
24182         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24183         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24184         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
24185         *ret_conv = FundingSigned_read(ser_ref);
24186         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24187         return (uint64_t)ret_conv;
24188 }
24189
24190 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingLocked_1write(JNIEnv *env, jclass clz, int64_t obj) {
24191         LDKFundingLocked obj_conv;
24192         obj_conv.inner = (void*)(obj & (~1));
24193         obj_conv.is_owned = false;
24194         LDKCVec_u8Z ret_var = FundingLocked_write(&obj_conv);
24195         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24196         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24197         CVec_u8Z_free(ret_var);
24198         return ret_arr;
24199 }
24200
24201 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingLocked_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24202         LDKu8slice ser_ref;
24203         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24204         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24205         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
24206         *ret_conv = FundingLocked_read(ser_ref);
24207         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24208         return (uint64_t)ret_conv;
24209 }
24210
24211 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Init_1write(JNIEnv *env, jclass clz, int64_t obj) {
24212         LDKInit obj_conv;
24213         obj_conv.inner = (void*)(obj & (~1));
24214         obj_conv.is_owned = false;
24215         LDKCVec_u8Z ret_var = Init_write(&obj_conv);
24216         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24217         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24218         CVec_u8Z_free(ret_var);
24219         return ret_arr;
24220 }
24221
24222 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24223         LDKu8slice ser_ref;
24224         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24225         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24226         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
24227         *ret_conv = Init_read(ser_ref);
24228         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24229         return (uint64_t)ret_conv;
24230 }
24231
24232 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1write(JNIEnv *env, jclass clz, int64_t obj) {
24233         LDKOpenChannel obj_conv;
24234         obj_conv.inner = (void*)(obj & (~1));
24235         obj_conv.is_owned = false;
24236         LDKCVec_u8Z ret_var = OpenChannel_write(&obj_conv);
24237         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24238         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24239         CVec_u8Z_free(ret_var);
24240         return ret_arr;
24241 }
24242
24243 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24244         LDKu8slice ser_ref;
24245         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24246         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24247         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
24248         *ret_conv = OpenChannel_read(ser_ref);
24249         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24250         return (uint64_t)ret_conv;
24251 }
24252
24253 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1write(JNIEnv *env, jclass clz, int64_t obj) {
24254         LDKRevokeAndACK obj_conv;
24255         obj_conv.inner = (void*)(obj & (~1));
24256         obj_conv.is_owned = false;
24257         LDKCVec_u8Z ret_var = RevokeAndACK_write(&obj_conv);
24258         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24259         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24260         CVec_u8Z_free(ret_var);
24261         return ret_arr;
24262 }
24263
24264 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24265         LDKu8slice ser_ref;
24266         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24267         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24268         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
24269         *ret_conv = RevokeAndACK_read(ser_ref);
24270         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24271         return (uint64_t)ret_conv;
24272 }
24273
24274 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1write(JNIEnv *env, jclass clz, int64_t obj) {
24275         LDKShutdown obj_conv;
24276         obj_conv.inner = (void*)(obj & (~1));
24277         obj_conv.is_owned = false;
24278         LDKCVec_u8Z ret_var = Shutdown_write(&obj_conv);
24279         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24280         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24281         CVec_u8Z_free(ret_var);
24282         return ret_arr;
24283 }
24284
24285 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24286         LDKu8slice ser_ref;
24287         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24288         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24289         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
24290         *ret_conv = Shutdown_read(ser_ref);
24291         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24292         return (uint64_t)ret_conv;
24293 }
24294
24295 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
24296         LDKUpdateFailHTLC obj_conv;
24297         obj_conv.inner = (void*)(obj & (~1));
24298         obj_conv.is_owned = false;
24299         LDKCVec_u8Z ret_var = UpdateFailHTLC_write(&obj_conv);
24300         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24301         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24302         CVec_u8Z_free(ret_var);
24303         return ret_arr;
24304 }
24305
24306 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24307         LDKu8slice ser_ref;
24308         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24309         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24310         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
24311         *ret_conv = UpdateFailHTLC_read(ser_ref);
24312         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24313         return (uint64_t)ret_conv;
24314 }
24315
24316 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
24317         LDKUpdateFailMalformedHTLC obj_conv;
24318         obj_conv.inner = (void*)(obj & (~1));
24319         obj_conv.is_owned = false;
24320         LDKCVec_u8Z ret_var = UpdateFailMalformedHTLC_write(&obj_conv);
24321         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24322         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24323         CVec_u8Z_free(ret_var);
24324         return ret_arr;
24325 }
24326
24327 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24328         LDKu8slice ser_ref;
24329         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24330         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24331         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
24332         *ret_conv = UpdateFailMalformedHTLC_read(ser_ref);
24333         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24334         return (uint64_t)ret_conv;
24335 }
24336
24337 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFee_1write(JNIEnv *env, jclass clz, int64_t obj) {
24338         LDKUpdateFee obj_conv;
24339         obj_conv.inner = (void*)(obj & (~1));
24340         obj_conv.is_owned = false;
24341         LDKCVec_u8Z ret_var = UpdateFee_write(&obj_conv);
24342         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24343         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24344         CVec_u8Z_free(ret_var);
24345         return ret_arr;
24346 }
24347
24348 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24349         LDKu8slice ser_ref;
24350         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24351         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24352         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
24353         *ret_conv = UpdateFee_read(ser_ref);
24354         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24355         return (uint64_t)ret_conv;
24356 }
24357
24358 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
24359         LDKUpdateFulfillHTLC obj_conv;
24360         obj_conv.inner = (void*)(obj & (~1));
24361         obj_conv.is_owned = false;
24362         LDKCVec_u8Z ret_var = UpdateFulfillHTLC_write(&obj_conv);
24363         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24364         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24365         CVec_u8Z_free(ret_var);
24366         return ret_arr;
24367 }
24368
24369 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24370         LDKu8slice ser_ref;
24371         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24372         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24373         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
24374         *ret_conv = UpdateFulfillHTLC_read(ser_ref);
24375         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24376         return (uint64_t)ret_conv;
24377 }
24378
24379 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
24380         LDKUpdateAddHTLC obj_conv;
24381         obj_conv.inner = (void*)(obj & (~1));
24382         obj_conv.is_owned = false;
24383         LDKCVec_u8Z ret_var = UpdateAddHTLC_write(&obj_conv);
24384         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24385         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24386         CVec_u8Z_free(ret_var);
24387         return ret_arr;
24388 }
24389
24390 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24391         LDKu8slice ser_ref;
24392         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24393         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24394         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
24395         *ret_conv = UpdateAddHTLC_read(ser_ref);
24396         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24397         return (uint64_t)ret_conv;
24398 }
24399
24400 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Ping_1write(JNIEnv *env, jclass clz, int64_t obj) {
24401         LDKPing obj_conv;
24402         obj_conv.inner = (void*)(obj & (~1));
24403         obj_conv.is_owned = false;
24404         LDKCVec_u8Z ret_var = Ping_write(&obj_conv);
24405         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24406         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24407         CVec_u8Z_free(ret_var);
24408         return ret_arr;
24409 }
24410
24411 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24412         LDKu8slice ser_ref;
24413         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24414         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24415         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
24416         *ret_conv = Ping_read(ser_ref);
24417         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24418         return (uint64_t)ret_conv;
24419 }
24420
24421 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Pong_1write(JNIEnv *env, jclass clz, int64_t obj) {
24422         LDKPong obj_conv;
24423         obj_conv.inner = (void*)(obj & (~1));
24424         obj_conv.is_owned = false;
24425         LDKCVec_u8Z ret_var = Pong_write(&obj_conv);
24426         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24427         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24428         CVec_u8Z_free(ret_var);
24429         return ret_arr;
24430 }
24431
24432 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24433         LDKu8slice ser_ref;
24434         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24435         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24436         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
24437         *ret_conv = Pong_read(ser_ref);
24438         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24439         return (uint64_t)ret_conv;
24440 }
24441
24442 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
24443         LDKUnsignedChannelAnnouncement obj_conv;
24444         obj_conv.inner = (void*)(obj & (~1));
24445         obj_conv.is_owned = false;
24446         LDKCVec_u8Z ret_var = UnsignedChannelAnnouncement_write(&obj_conv);
24447         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24448         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24449         CVec_u8Z_free(ret_var);
24450         return ret_arr;
24451 }
24452
24453 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24454         LDKu8slice ser_ref;
24455         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24456         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24457         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
24458         *ret_conv = UnsignedChannelAnnouncement_read(ser_ref);
24459         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24460         return (uint64_t)ret_conv;
24461 }
24462
24463 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
24464         LDKChannelAnnouncement obj_conv;
24465         obj_conv.inner = (void*)(obj & (~1));
24466         obj_conv.is_owned = false;
24467         LDKCVec_u8Z ret_var = ChannelAnnouncement_write(&obj_conv);
24468         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24469         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24470         CVec_u8Z_free(ret_var);
24471         return ret_arr;
24472 }
24473
24474 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24475         LDKu8slice ser_ref;
24476         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24477         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24478         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
24479         *ret_conv = ChannelAnnouncement_read(ser_ref);
24480         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24481         return (uint64_t)ret_conv;
24482 }
24483
24484 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
24485         LDKUnsignedChannelUpdate obj_conv;
24486         obj_conv.inner = (void*)(obj & (~1));
24487         obj_conv.is_owned = false;
24488         LDKCVec_u8Z ret_var = UnsignedChannelUpdate_write(&obj_conv);
24489         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24490         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24491         CVec_u8Z_free(ret_var);
24492         return ret_arr;
24493 }
24494
24495 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24496         LDKu8slice ser_ref;
24497         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24498         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24499         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
24500         *ret_conv = UnsignedChannelUpdate_read(ser_ref);
24501         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24502         return (uint64_t)ret_conv;
24503 }
24504
24505 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
24506         LDKChannelUpdate obj_conv;
24507         obj_conv.inner = (void*)(obj & (~1));
24508         obj_conv.is_owned = false;
24509         LDKCVec_u8Z ret_var = ChannelUpdate_write(&obj_conv);
24510         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24511         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24512         CVec_u8Z_free(ret_var);
24513         return ret_arr;
24514 }
24515
24516 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24517         LDKu8slice ser_ref;
24518         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24519         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24520         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
24521         *ret_conv = ChannelUpdate_read(ser_ref);
24522         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24523         return (uint64_t)ret_conv;
24524 }
24525
24526 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1write(JNIEnv *env, jclass clz, int64_t obj) {
24527         LDKErrorMessage obj_conv;
24528         obj_conv.inner = (void*)(obj & (~1));
24529         obj_conv.is_owned = false;
24530         LDKCVec_u8Z ret_var = ErrorMessage_write(&obj_conv);
24531         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24532         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24533         CVec_u8Z_free(ret_var);
24534         return ret_arr;
24535 }
24536
24537 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24538         LDKu8slice ser_ref;
24539         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24540         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24541         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
24542         *ret_conv = ErrorMessage_read(ser_ref);
24543         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24544         return (uint64_t)ret_conv;
24545 }
24546
24547 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
24548         LDKUnsignedNodeAnnouncement obj_conv;
24549         obj_conv.inner = (void*)(obj & (~1));
24550         obj_conv.is_owned = false;
24551         LDKCVec_u8Z ret_var = UnsignedNodeAnnouncement_write(&obj_conv);
24552         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24553         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24554         CVec_u8Z_free(ret_var);
24555         return ret_arr;
24556 }
24557
24558 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24559         LDKu8slice ser_ref;
24560         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24561         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24562         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
24563         *ret_conv = UnsignedNodeAnnouncement_read(ser_ref);
24564         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24565         return (uint64_t)ret_conv;
24566 }
24567
24568 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
24569         LDKNodeAnnouncement obj_conv;
24570         obj_conv.inner = (void*)(obj & (~1));
24571         obj_conv.is_owned = false;
24572         LDKCVec_u8Z ret_var = NodeAnnouncement_write(&obj_conv);
24573         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24574         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24575         CVec_u8Z_free(ret_var);
24576         return ret_arr;
24577 }
24578
24579 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24580         LDKu8slice ser_ref;
24581         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24582         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24583         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
24584         *ret_conv = NodeAnnouncement_read(ser_ref);
24585         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24586         return (uint64_t)ret_conv;
24587 }
24588
24589 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24590         LDKu8slice ser_ref;
24591         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24592         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24593         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
24594         *ret_conv = QueryShortChannelIds_read(ser_ref);
24595         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24596         return (uint64_t)ret_conv;
24597 }
24598
24599 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1write(JNIEnv *env, jclass clz, int64_t obj) {
24600         LDKQueryShortChannelIds obj_conv;
24601         obj_conv.inner = (void*)(obj & (~1));
24602         obj_conv.is_owned = false;
24603         LDKCVec_u8Z ret_var = QueryShortChannelIds_write(&obj_conv);
24604         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24605         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24606         CVec_u8Z_free(ret_var);
24607         return ret_arr;
24608 }
24609
24610 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1write(JNIEnv *env, jclass clz, int64_t obj) {
24611         LDKReplyShortChannelIdsEnd obj_conv;
24612         obj_conv.inner = (void*)(obj & (~1));
24613         obj_conv.is_owned = false;
24614         LDKCVec_u8Z ret_var = ReplyShortChannelIdsEnd_write(&obj_conv);
24615         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24616         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24617         CVec_u8Z_free(ret_var);
24618         return ret_arr;
24619 }
24620
24621 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24622         LDKu8slice ser_ref;
24623         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24624         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24625         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
24626         *ret_conv = ReplyShortChannelIdsEnd_read(ser_ref);
24627         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24628         return (uint64_t)ret_conv;
24629 }
24630
24631 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1end_1blocknum(JNIEnv *env, jclass clz, int64_t this_arg) {
24632         LDKQueryChannelRange this_arg_conv;
24633         this_arg_conv.inner = (void*)(this_arg & (~1));
24634         this_arg_conv.is_owned = false;
24635         int32_t ret_val = QueryChannelRange_end_blocknum(&this_arg_conv);
24636         return ret_val;
24637 }
24638
24639 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
24640         LDKQueryChannelRange obj_conv;
24641         obj_conv.inner = (void*)(obj & (~1));
24642         obj_conv.is_owned = false;
24643         LDKCVec_u8Z ret_var = QueryChannelRange_write(&obj_conv);
24644         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24645         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24646         CVec_u8Z_free(ret_var);
24647         return ret_arr;
24648 }
24649
24650 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24651         LDKu8slice ser_ref;
24652         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24653         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24654         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
24655         *ret_conv = QueryChannelRange_read(ser_ref);
24656         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24657         return (uint64_t)ret_conv;
24658 }
24659
24660 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24661         LDKu8slice ser_ref;
24662         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24663         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24664         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
24665         *ret_conv = ReplyChannelRange_read(ser_ref);
24666         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24667         return (uint64_t)ret_conv;
24668 }
24669
24670 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
24671         LDKReplyChannelRange obj_conv;
24672         obj_conv.inner = (void*)(obj & (~1));
24673         obj_conv.is_owned = false;
24674         LDKCVec_u8Z ret_var = ReplyChannelRange_write(&obj_conv);
24675         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24676         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24677         CVec_u8Z_free(ret_var);
24678         return ret_arr;
24679 }
24680
24681 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1write(JNIEnv *env, jclass clz, int64_t obj) {
24682         LDKGossipTimestampFilter obj_conv;
24683         obj_conv.inner = (void*)(obj & (~1));
24684         obj_conv.is_owned = false;
24685         LDKCVec_u8Z ret_var = GossipTimestampFilter_write(&obj_conv);
24686         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24687         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24688         CVec_u8Z_free(ret_var);
24689         return ret_arr;
24690 }
24691
24692 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24693         LDKu8slice ser_ref;
24694         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24695         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24696         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
24697         *ret_conv = GossipTimestampFilter_read(ser_ref);
24698         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24699         return (uint64_t)ret_conv;
24700 }
24701
24702 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CustomMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
24703         if ((this_ptr & 1) != 0) return;
24704         LDKCustomMessageHandler this_ptr_conv = *(LDKCustomMessageHandler*)(((uint64_t)this_ptr) & ~1);
24705         FREE((void*)this_ptr);
24706         CustomMessageHandler_free(this_ptr_conv);
24707 }
24708
24709 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24710         LDKIgnoringMessageHandler this_obj_conv;
24711         this_obj_conv.inner = (void*)(this_obj & (~1));
24712         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24713         IgnoringMessageHandler_free(this_obj_conv);
24714 }
24715
24716 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1new(JNIEnv *env, jclass clz) {
24717         LDKIgnoringMessageHandler ret_var = IgnoringMessageHandler_new();
24718         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24719         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24720         uint64_t ret_ref = (uint64_t)ret_var.inner;
24721         if (ret_var.is_owned) {
24722                 ret_ref |= 1;
24723         }
24724         return ret_ref;
24725 }
24726
24727 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
24728         LDKIgnoringMessageHandler this_arg_conv;
24729         this_arg_conv.inner = (void*)(this_arg & (~1));
24730         this_arg_conv.is_owned = false;
24731         LDKMessageSendEventsProvider* ret_ret =MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
24732         *ret_ret = IgnoringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
24733         return (uint64_t)ret_ret;
24734 }
24735
24736 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1RoutingMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
24737         LDKIgnoringMessageHandler this_arg_conv;
24738         this_arg_conv.inner = (void*)(this_arg & (~1));
24739         this_arg_conv.is_owned = false;
24740         LDKRoutingMessageHandler* ret_ret =MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
24741         *ret_ret = IgnoringMessageHandler_as_RoutingMessageHandler(&this_arg_conv);
24742         return (uint64_t)ret_ret;
24743 }
24744
24745 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1CustomMessageReader(JNIEnv *env, jclass clz, int64_t this_arg) {
24746         LDKIgnoringMessageHandler this_arg_conv;
24747         this_arg_conv.inner = (void*)(this_arg & (~1));
24748         this_arg_conv.is_owned = false;
24749         LDKCustomMessageReader* ret_ret =MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader");
24750         *ret_ret = IgnoringMessageHandler_as_CustomMessageReader(&this_arg_conv);
24751         return (uint64_t)ret_ret;
24752 }
24753
24754 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1CustomMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
24755         LDKIgnoringMessageHandler this_arg_conv;
24756         this_arg_conv.inner = (void*)(this_arg & (~1));
24757         this_arg_conv.is_owned = false;
24758         LDKCustomMessageHandler* ret_ret =MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler");
24759         *ret_ret = IgnoringMessageHandler_as_CustomMessageHandler(&this_arg_conv);
24760         return (uint64_t)ret_ret;
24761 }
24762
24763 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24764         LDKErroringMessageHandler this_obj_conv;
24765         this_obj_conv.inner = (void*)(this_obj & (~1));
24766         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24767         ErroringMessageHandler_free(this_obj_conv);
24768 }
24769
24770 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1new(JNIEnv *env, jclass clz) {
24771         LDKErroringMessageHandler ret_var = ErroringMessageHandler_new();
24772         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24773         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24774         uint64_t ret_ref = (uint64_t)ret_var.inner;
24775         if (ret_var.is_owned) {
24776                 ret_ref |= 1;
24777         }
24778         return ret_ref;
24779 }
24780
24781 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
24782         LDKErroringMessageHandler this_arg_conv;
24783         this_arg_conv.inner = (void*)(this_arg & (~1));
24784         this_arg_conv.is_owned = false;
24785         LDKMessageSendEventsProvider* ret_ret =MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
24786         *ret_ret = ErroringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
24787         return (uint64_t)ret_ret;
24788 }
24789
24790 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1as_1ChannelMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
24791         LDKErroringMessageHandler this_arg_conv;
24792         this_arg_conv.inner = (void*)(this_arg & (~1));
24793         this_arg_conv.is_owned = false;
24794         LDKChannelMessageHandler* ret_ret =MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
24795         *ret_ret = ErroringMessageHandler_as_ChannelMessageHandler(&this_arg_conv);
24796         return (uint64_t)ret_ret;
24797 }
24798
24799 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24800         LDKMessageHandler this_obj_conv;
24801         this_obj_conv.inner = (void*)(this_obj & (~1));
24802         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24803         MessageHandler_free(this_obj_conv);
24804 }
24805
24806 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1chan_1handler(JNIEnv *env, jclass clz, int64_t this_ptr) {
24807         LDKMessageHandler this_ptr_conv;
24808         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24809         this_ptr_conv.is_owned = false;
24810         uint64_t ret_ret = (uint64_t)MessageHandler_get_chan_handler(&this_ptr_conv);
24811         return ret_ret;
24812 }
24813
24814 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1chan_1handler(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24815         LDKMessageHandler this_ptr_conv;
24816         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24817         this_ptr_conv.is_owned = false;
24818         LDKChannelMessageHandler val_conv = *(LDKChannelMessageHandler*)(((uint64_t)val) & ~1);
24819         if (val_conv.free == LDKChannelMessageHandler_JCalls_free) {
24820                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24821                 LDKChannelMessageHandler_JCalls_cloned(&val_conv);
24822         }
24823         MessageHandler_set_chan_handler(&this_ptr_conv, val_conv);
24824 }
24825
24826 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1route_1handler(JNIEnv *env, jclass clz, int64_t this_ptr) {
24827         LDKMessageHandler this_ptr_conv;
24828         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24829         this_ptr_conv.is_owned = false;
24830         uint64_t ret_ret = (uint64_t)MessageHandler_get_route_handler(&this_ptr_conv);
24831         return ret_ret;
24832 }
24833
24834 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1route_1handler(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24835         LDKMessageHandler this_ptr_conv;
24836         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24837         this_ptr_conv.is_owned = false;
24838         LDKRoutingMessageHandler val_conv = *(LDKRoutingMessageHandler*)(((uint64_t)val) & ~1);
24839         if (val_conv.free == LDKRoutingMessageHandler_JCalls_free) {
24840                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24841                 LDKRoutingMessageHandler_JCalls_cloned(&val_conv);
24842         }
24843         MessageHandler_set_route_handler(&this_ptr_conv, val_conv);
24844 }
24845
24846 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) {
24847         LDKChannelMessageHandler chan_handler_arg_conv = *(LDKChannelMessageHandler*)(((uint64_t)chan_handler_arg) & ~1);
24848         if (chan_handler_arg_conv.free == LDKChannelMessageHandler_JCalls_free) {
24849                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24850                 LDKChannelMessageHandler_JCalls_cloned(&chan_handler_arg_conv);
24851         }
24852         LDKRoutingMessageHandler route_handler_arg_conv = *(LDKRoutingMessageHandler*)(((uint64_t)route_handler_arg) & ~1);
24853         if (route_handler_arg_conv.free == LDKRoutingMessageHandler_JCalls_free) {
24854                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24855                 LDKRoutingMessageHandler_JCalls_cloned(&route_handler_arg_conv);
24856         }
24857         LDKMessageHandler ret_var = MessageHandler_new(chan_handler_arg_conv, route_handler_arg_conv);
24858         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24859         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24860         uint64_t ret_ref = (uint64_t)ret_var.inner;
24861         if (ret_var.is_owned) {
24862                 ret_ref |= 1;
24863         }
24864         return ret_ref;
24865 }
24866
24867 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24868         LDKSocketDescriptor* orig_conv = (LDKSocketDescriptor*)(((uint64_t)orig) & ~1);
24869         LDKSocketDescriptor* ret_ret =MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
24870         *ret_ret = SocketDescriptor_clone(orig_conv);
24871         return (uint64_t)ret_ret;
24872 }
24873
24874 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
24875         if ((this_ptr & 1) != 0) return;
24876         LDKSocketDescriptor this_ptr_conv = *(LDKSocketDescriptor*)(((uint64_t)this_ptr) & ~1);
24877         FREE((void*)this_ptr);
24878         SocketDescriptor_free(this_ptr_conv);
24879 }
24880
24881 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24882         LDKPeerHandleError this_obj_conv;
24883         this_obj_conv.inner = (void*)(this_obj & (~1));
24884         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24885         PeerHandleError_free(this_obj_conv);
24886 }
24887
24888 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1get_1no_1connection_1possible(JNIEnv *env, jclass clz, int64_t this_ptr) {
24889         LDKPeerHandleError this_ptr_conv;
24890         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24891         this_ptr_conv.is_owned = false;
24892         jboolean ret_val = PeerHandleError_get_no_connection_possible(&this_ptr_conv);
24893         return ret_val;
24894 }
24895
24896 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1set_1no_1connection_1possible(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
24897         LDKPeerHandleError this_ptr_conv;
24898         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24899         this_ptr_conv.is_owned = false;
24900         PeerHandleError_set_no_connection_possible(&this_ptr_conv, val);
24901 }
24902
24903 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1new(JNIEnv *env, jclass clz, jboolean no_connection_possible_arg) {
24904         LDKPeerHandleError ret_var = PeerHandleError_new(no_connection_possible_arg);
24905         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24906         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24907         uint64_t ret_ref = (uint64_t)ret_var.inner;
24908         if (ret_var.is_owned) {
24909                 ret_ref |= 1;
24910         }
24911         return ret_ref;
24912 }
24913
24914 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24915         LDKPeerHandleError orig_conv;
24916         orig_conv.inner = (void*)(orig & (~1));
24917         orig_conv.is_owned = false;
24918         LDKPeerHandleError ret_var = PeerHandleError_clone(&orig_conv);
24919         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24920         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24921         uint64_t ret_ref = (uint64_t)ret_var.inner;
24922         if (ret_var.is_owned) {
24923                 ret_ref |= 1;
24924         }
24925         return ret_ref;
24926 }
24927
24928 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24929         LDKPeerManager this_obj_conv;
24930         this_obj_conv.inner = (void*)(this_obj & (~1));
24931         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24932         PeerManager_free(this_obj_conv);
24933 }
24934
24935 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) {
24936         LDKMessageHandler message_handler_conv;
24937         message_handler_conv.inner = (void*)(message_handler & (~1));
24938         message_handler_conv.is_owned = (message_handler & 1) || (message_handler == 0);
24939         // Warning: we need a move here but no clone is available for LDKMessageHandler
24940         LDKSecretKey our_node_secret_ref;
24941         CHECK((*env)->GetArrayLength(env, our_node_secret) == 32);
24942         (*env)->GetByteArrayRegion(env, our_node_secret, 0, 32, our_node_secret_ref.bytes);
24943         unsigned char ephemeral_random_data_arr[32];
24944         CHECK((*env)->GetArrayLength(env, ephemeral_random_data) == 32);
24945         (*env)->GetByteArrayRegion(env, ephemeral_random_data, 0, 32, ephemeral_random_data_arr);
24946         unsigned char (*ephemeral_random_data_ref)[32] = &ephemeral_random_data_arr;
24947         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
24948         if (logger_conv.free == LDKLogger_JCalls_free) {
24949                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24950                 LDKLogger_JCalls_cloned(&logger_conv);
24951         }
24952         LDKCustomMessageHandler custom_message_handler_conv = *(LDKCustomMessageHandler*)(((uint64_t)custom_message_handler) & ~1);
24953         if (custom_message_handler_conv.free == LDKCustomMessageHandler_JCalls_free) {
24954                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24955                 LDKCustomMessageHandler_JCalls_cloned(&custom_message_handler_conv);
24956         }
24957         LDKPeerManager ret_var = PeerManager_new(message_handler_conv, our_node_secret_ref, ephemeral_random_data_ref, logger_conv, custom_message_handler_conv);
24958         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24959         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24960         uint64_t ret_ref = (uint64_t)ret_var.inner;
24961         if (ret_var.is_owned) {
24962                 ret_ref |= 1;
24963         }
24964         return ret_ref;
24965 }
24966
24967 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_PeerManager_1get_1peer_1node_1ids(JNIEnv *env, jclass clz, int64_t this_arg) {
24968         LDKPeerManager this_arg_conv;
24969         this_arg_conv.inner = (void*)(this_arg & (~1));
24970         this_arg_conv.is_owned = false;
24971         LDKCVec_PublicKeyZ ret_var = PeerManager_get_peer_node_ids(&this_arg_conv);
24972         jobjectArray ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
24973         ;
24974         for (size_t i = 0; i < ret_var.datalen; i++) {
24975                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 33);
24976                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 33, ret_var.data[i].compressed_form);
24977                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
24978         }
24979         FREE(ret_var.data);
24980         return ret_arr;
24981 }
24982
24983 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) {
24984         LDKPeerManager this_arg_conv;
24985         this_arg_conv.inner = (void*)(this_arg & (~1));
24986         this_arg_conv.is_owned = false;
24987         LDKPublicKey their_node_id_ref;
24988         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
24989         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
24990         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
24991         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
24992                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24993                 LDKSocketDescriptor_JCalls_cloned(&descriptor_conv);
24994         }
24995         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
24996         *ret_conv = PeerManager_new_outbound_connection(&this_arg_conv, their_node_id_ref, descriptor_conv);
24997         return (uint64_t)ret_conv;
24998 }
24999
25000 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerManager_1new_1inbound_1connection(JNIEnv *env, jclass clz, int64_t this_arg, int64_t descriptor) {
25001         LDKPeerManager this_arg_conv;
25002         this_arg_conv.inner = (void*)(this_arg & (~1));
25003         this_arg_conv.is_owned = false;
25004         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
25005         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
25006                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25007                 LDKSocketDescriptor_JCalls_cloned(&descriptor_conv);
25008         }
25009         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
25010         *ret_conv = PeerManager_new_inbound_connection(&this_arg_conv, descriptor_conv);
25011         return (uint64_t)ret_conv;
25012 }
25013
25014 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) {
25015         LDKPeerManager this_arg_conv;
25016         this_arg_conv.inner = (void*)(this_arg & (~1));
25017         this_arg_conv.is_owned = false;
25018         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
25019         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
25020         *ret_conv = PeerManager_write_buffer_space_avail(&this_arg_conv, descriptor_conv);
25021         return (uint64_t)ret_conv;
25022 }
25023
25024 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) {
25025         LDKPeerManager this_arg_conv;
25026         this_arg_conv.inner = (void*)(this_arg & (~1));
25027         this_arg_conv.is_owned = false;
25028         LDKSocketDescriptor* peer_descriptor_conv = (LDKSocketDescriptor*)(((uint64_t)peer_descriptor) & ~1);
25029         LDKu8slice data_ref;
25030         data_ref.datalen = (*env)->GetArrayLength(env, data);
25031         data_ref.data = (*env)->GetByteArrayElements (env, data, NULL);
25032         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
25033         *ret_conv = PeerManager_read_event(&this_arg_conv, peer_descriptor_conv, data_ref);
25034         (*env)->ReleaseByteArrayElements(env, data, (int8_t*)data_ref.data, 0);
25035         return (uint64_t)ret_conv;
25036 }
25037
25038 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1process_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
25039         LDKPeerManager this_arg_conv;
25040         this_arg_conv.inner = (void*)(this_arg & (~1));
25041         this_arg_conv.is_owned = false;
25042         PeerManager_process_events(&this_arg_conv);
25043 }
25044
25045 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1socket_1disconnected(JNIEnv *env, jclass clz, int64_t this_arg, int64_t descriptor) {
25046         LDKPeerManager this_arg_conv;
25047         this_arg_conv.inner = (void*)(this_arg & (~1));
25048         this_arg_conv.is_owned = false;
25049         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
25050         PeerManager_socket_disconnected(&this_arg_conv, descriptor_conv);
25051 }
25052
25053 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) {
25054         LDKPeerManager this_arg_conv;
25055         this_arg_conv.inner = (void*)(this_arg & (~1));
25056         this_arg_conv.is_owned = false;
25057         LDKPublicKey node_id_ref;
25058         CHECK((*env)->GetArrayLength(env, node_id) == 33);
25059         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
25060         PeerManager_disconnect_by_node_id(&this_arg_conv, node_id_ref, no_connection_possible);
25061 }
25062
25063 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1timer_1tick_1occurred(JNIEnv *env, jclass clz, int64_t this_arg) {
25064         LDKPeerManager this_arg_conv;
25065         this_arg_conv.inner = (void*)(this_arg & (~1));
25066         this_arg_conv.is_owned = false;
25067         PeerManager_timer_tick_occurred(&this_arg_conv);
25068 }
25069
25070 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_build_1commitment_1secret(JNIEnv *env, jclass clz, int8_tArray commitment_seed, int64_t idx) {
25071         unsigned char commitment_seed_arr[32];
25072         CHECK((*env)->GetArrayLength(env, commitment_seed) == 32);
25073         (*env)->GetByteArrayRegion(env, commitment_seed, 0, 32, commitment_seed_arr);
25074         unsigned char (*commitment_seed_ref)[32] = &commitment_seed_arr;
25075         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
25076         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, build_commitment_secret(commitment_seed_ref, idx).data);
25077         return ret_arr;
25078 }
25079
25080 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) {
25081         LDKCVec_u8Z to_holder_script_ref;
25082         to_holder_script_ref.datalen = (*env)->GetArrayLength(env, to_holder_script);
25083         to_holder_script_ref.data = MALLOC(to_holder_script_ref.datalen, "LDKCVec_u8Z Bytes");
25084         (*env)->GetByteArrayRegion(env, to_holder_script, 0, to_holder_script_ref.datalen, to_holder_script_ref.data);
25085         LDKCVec_u8Z to_counterparty_script_ref;
25086         to_counterparty_script_ref.datalen = (*env)->GetArrayLength(env, to_counterparty_script);
25087         to_counterparty_script_ref.data = MALLOC(to_counterparty_script_ref.datalen, "LDKCVec_u8Z Bytes");
25088         (*env)->GetByteArrayRegion(env, to_counterparty_script, 0, to_counterparty_script_ref.datalen, to_counterparty_script_ref.data);
25089         LDKOutPoint funding_outpoint_conv;
25090         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
25091         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
25092         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
25093         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);
25094         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
25095         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
25096         Transaction_free(ret_var);
25097         return ret_arr;
25098 }
25099
25100 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) {
25101         LDKPublicKey per_commitment_point_ref;
25102         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
25103         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
25104         unsigned char base_secret_arr[32];
25105         CHECK((*env)->GetArrayLength(env, base_secret) == 32);
25106         (*env)->GetByteArrayRegion(env, base_secret, 0, 32, base_secret_arr);
25107         unsigned char (*base_secret_ref)[32] = &base_secret_arr;
25108         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
25109         *ret_conv = derive_private_key(per_commitment_point_ref, base_secret_ref);
25110         return (uint64_t)ret_conv;
25111 }
25112
25113 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) {
25114         LDKPublicKey per_commitment_point_ref;
25115         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
25116         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
25117         LDKPublicKey base_point_ref;
25118         CHECK((*env)->GetArrayLength(env, base_point) == 33);
25119         (*env)->GetByteArrayRegion(env, base_point, 0, 33, base_point_ref.compressed_form);
25120         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
25121         *ret_conv = derive_public_key(per_commitment_point_ref, base_point_ref);
25122         return (uint64_t)ret_conv;
25123 }
25124
25125 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) {
25126         unsigned char per_commitment_secret_arr[32];
25127         CHECK((*env)->GetArrayLength(env, per_commitment_secret) == 32);
25128         (*env)->GetByteArrayRegion(env, per_commitment_secret, 0, 32, per_commitment_secret_arr);
25129         unsigned char (*per_commitment_secret_ref)[32] = &per_commitment_secret_arr;
25130         unsigned char countersignatory_revocation_base_secret_arr[32];
25131         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base_secret) == 32);
25132         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base_secret, 0, 32, countersignatory_revocation_base_secret_arr);
25133         unsigned char (*countersignatory_revocation_base_secret_ref)[32] = &countersignatory_revocation_base_secret_arr;
25134         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
25135         *ret_conv = derive_private_revocation_key(per_commitment_secret_ref, countersignatory_revocation_base_secret_ref);
25136         return (uint64_t)ret_conv;
25137 }
25138
25139 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) {
25140         LDKPublicKey per_commitment_point_ref;
25141         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
25142         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
25143         LDKPublicKey countersignatory_revocation_base_point_ref;
25144         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base_point) == 33);
25145         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base_point, 0, 33, countersignatory_revocation_base_point_ref.compressed_form);
25146         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
25147         *ret_conv = derive_public_revocation_key(per_commitment_point_ref, countersignatory_revocation_base_point_ref);
25148         return (uint64_t)ret_conv;
25149 }
25150
25151 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25152         LDKTxCreationKeys this_obj_conv;
25153         this_obj_conv.inner = (void*)(this_obj & (~1));
25154         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25155         TxCreationKeys_free(this_obj_conv);
25156 }
25157
25158 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
25159         LDKTxCreationKeys this_ptr_conv;
25160         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25161         this_ptr_conv.is_owned = false;
25162         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
25163         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_per_commitment_point(&this_ptr_conv).compressed_form);
25164         return ret_arr;
25165 }
25166
25167 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
25168         LDKTxCreationKeys this_ptr_conv;
25169         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25170         this_ptr_conv.is_owned = false;
25171         LDKPublicKey val_ref;
25172         CHECK((*env)->GetArrayLength(env, val) == 33);
25173         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
25174         TxCreationKeys_set_per_commitment_point(&this_ptr_conv, val_ref);
25175 }
25176
25177 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1revocation_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
25178         LDKTxCreationKeys this_ptr_conv;
25179         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25180         this_ptr_conv.is_owned = false;
25181         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
25182         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_revocation_key(&this_ptr_conv).compressed_form);
25183         return ret_arr;
25184 }
25185
25186 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1revocation_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
25187         LDKTxCreationKeys this_ptr_conv;
25188         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25189         this_ptr_conv.is_owned = false;
25190         LDKPublicKey val_ref;
25191         CHECK((*env)->GetArrayLength(env, val) == 33);
25192         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
25193         TxCreationKeys_set_revocation_key(&this_ptr_conv, val_ref);
25194 }
25195
25196 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1broadcaster_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
25197         LDKTxCreationKeys this_ptr_conv;
25198         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25199         this_ptr_conv.is_owned = false;
25200         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
25201         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_broadcaster_htlc_key(&this_ptr_conv).compressed_form);
25202         return ret_arr;
25203 }
25204
25205 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1broadcaster_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
25206         LDKTxCreationKeys this_ptr_conv;
25207         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25208         this_ptr_conv.is_owned = false;
25209         LDKPublicKey val_ref;
25210         CHECK((*env)->GetArrayLength(env, val) == 33);
25211         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
25212         TxCreationKeys_set_broadcaster_htlc_key(&this_ptr_conv, val_ref);
25213 }
25214
25215 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1countersignatory_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
25216         LDKTxCreationKeys this_ptr_conv;
25217         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25218         this_ptr_conv.is_owned = false;
25219         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
25220         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_countersignatory_htlc_key(&this_ptr_conv).compressed_form);
25221         return ret_arr;
25222 }
25223
25224 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1countersignatory_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
25225         LDKTxCreationKeys this_ptr_conv;
25226         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25227         this_ptr_conv.is_owned = false;
25228         LDKPublicKey val_ref;
25229         CHECK((*env)->GetArrayLength(env, val) == 33);
25230         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
25231         TxCreationKeys_set_countersignatory_htlc_key(&this_ptr_conv, val_ref);
25232 }
25233
25234 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1broadcaster_1delayed_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
25235         LDKTxCreationKeys this_ptr_conv;
25236         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25237         this_ptr_conv.is_owned = false;
25238         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
25239         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_broadcaster_delayed_payment_key(&this_ptr_conv).compressed_form);
25240         return ret_arr;
25241 }
25242
25243 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) {
25244         LDKTxCreationKeys this_ptr_conv;
25245         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25246         this_ptr_conv.is_owned = false;
25247         LDKPublicKey val_ref;
25248         CHECK((*env)->GetArrayLength(env, val) == 33);
25249         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
25250         TxCreationKeys_set_broadcaster_delayed_payment_key(&this_ptr_conv, val_ref);
25251 }
25252
25253 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) {
25254         LDKPublicKey per_commitment_point_arg_ref;
25255         CHECK((*env)->GetArrayLength(env, per_commitment_point_arg) == 33);
25256         (*env)->GetByteArrayRegion(env, per_commitment_point_arg, 0, 33, per_commitment_point_arg_ref.compressed_form);
25257         LDKPublicKey revocation_key_arg_ref;
25258         CHECK((*env)->GetArrayLength(env, revocation_key_arg) == 33);
25259         (*env)->GetByteArrayRegion(env, revocation_key_arg, 0, 33, revocation_key_arg_ref.compressed_form);
25260         LDKPublicKey broadcaster_htlc_key_arg_ref;
25261         CHECK((*env)->GetArrayLength(env, broadcaster_htlc_key_arg) == 33);
25262         (*env)->GetByteArrayRegion(env, broadcaster_htlc_key_arg, 0, 33, broadcaster_htlc_key_arg_ref.compressed_form);
25263         LDKPublicKey countersignatory_htlc_key_arg_ref;
25264         CHECK((*env)->GetArrayLength(env, countersignatory_htlc_key_arg) == 33);
25265         (*env)->GetByteArrayRegion(env, countersignatory_htlc_key_arg, 0, 33, countersignatory_htlc_key_arg_ref.compressed_form);
25266         LDKPublicKey broadcaster_delayed_payment_key_arg_ref;
25267         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key_arg) == 33);
25268         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key_arg, 0, 33, broadcaster_delayed_payment_key_arg_ref.compressed_form);
25269         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);
25270         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25271         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25272         uint64_t ret_ref = (uint64_t)ret_var.inner;
25273         if (ret_var.is_owned) {
25274                 ret_ref |= 1;
25275         }
25276         return ret_ref;
25277 }
25278
25279 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25280         LDKTxCreationKeys orig_conv;
25281         orig_conv.inner = (void*)(orig & (~1));
25282         orig_conv.is_owned = false;
25283         LDKTxCreationKeys ret_var = TxCreationKeys_clone(&orig_conv);
25284         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25285         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25286         uint64_t ret_ref = (uint64_t)ret_var.inner;
25287         if (ret_var.is_owned) {
25288                 ret_ref |= 1;
25289         }
25290         return ret_ref;
25291 }
25292
25293 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1write(JNIEnv *env, jclass clz, int64_t obj) {
25294         LDKTxCreationKeys obj_conv;
25295         obj_conv.inner = (void*)(obj & (~1));
25296         obj_conv.is_owned = false;
25297         LDKCVec_u8Z ret_var = TxCreationKeys_write(&obj_conv);
25298         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
25299         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
25300         CVec_u8Z_free(ret_var);
25301         return ret_arr;
25302 }
25303
25304 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
25305         LDKu8slice ser_ref;
25306         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
25307         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
25308         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
25309         *ret_conv = TxCreationKeys_read(ser_ref);
25310         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
25311         return (uint64_t)ret_conv;
25312 }
25313
25314 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25315         LDKChannelPublicKeys this_obj_conv;
25316         this_obj_conv.inner = (void*)(this_obj & (~1));
25317         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25318         ChannelPublicKeys_free(this_obj_conv);
25319 }
25320
25321 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
25322         LDKChannelPublicKeys this_ptr_conv;
25323         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25324         this_ptr_conv.is_owned = false;
25325         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
25326         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_funding_pubkey(&this_ptr_conv).compressed_form);
25327         return ret_arr;
25328 }
25329
25330 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
25331         LDKChannelPublicKeys this_ptr_conv;
25332         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25333         this_ptr_conv.is_owned = false;
25334         LDKPublicKey val_ref;
25335         CHECK((*env)->GetArrayLength(env, val) == 33);
25336         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
25337         ChannelPublicKeys_set_funding_pubkey(&this_ptr_conv, val_ref);
25338 }
25339
25340 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
25341         LDKChannelPublicKeys this_ptr_conv;
25342         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25343         this_ptr_conv.is_owned = false;
25344         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
25345         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_revocation_basepoint(&this_ptr_conv).compressed_form);
25346         return ret_arr;
25347 }
25348
25349 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
25350         LDKChannelPublicKeys this_ptr_conv;
25351         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25352         this_ptr_conv.is_owned = false;
25353         LDKPublicKey val_ref;
25354         CHECK((*env)->GetArrayLength(env, val) == 33);
25355         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
25356         ChannelPublicKeys_set_revocation_basepoint(&this_ptr_conv, val_ref);
25357 }
25358
25359 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
25360         LDKChannelPublicKeys this_ptr_conv;
25361         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25362         this_ptr_conv.is_owned = false;
25363         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
25364         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_payment_point(&this_ptr_conv).compressed_form);
25365         return ret_arr;
25366 }
25367
25368 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
25369         LDKChannelPublicKeys this_ptr_conv;
25370         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25371         this_ptr_conv.is_owned = false;
25372         LDKPublicKey val_ref;
25373         CHECK((*env)->GetArrayLength(env, val) == 33);
25374         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
25375         ChannelPublicKeys_set_payment_point(&this_ptr_conv, val_ref);
25376 }
25377
25378 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
25379         LDKChannelPublicKeys this_ptr_conv;
25380         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25381         this_ptr_conv.is_owned = false;
25382         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
25383         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
25384         return ret_arr;
25385 }
25386
25387 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
25388         LDKChannelPublicKeys this_ptr_conv;
25389         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25390         this_ptr_conv.is_owned = false;
25391         LDKPublicKey val_ref;
25392         CHECK((*env)->GetArrayLength(env, val) == 33);
25393         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
25394         ChannelPublicKeys_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
25395 }
25396
25397 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
25398         LDKChannelPublicKeys this_ptr_conv;
25399         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25400         this_ptr_conv.is_owned = false;
25401         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
25402         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_htlc_basepoint(&this_ptr_conv).compressed_form);
25403         return ret_arr;
25404 }
25405
25406 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
25407         LDKChannelPublicKeys this_ptr_conv;
25408         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25409         this_ptr_conv.is_owned = false;
25410         LDKPublicKey val_ref;
25411         CHECK((*env)->GetArrayLength(env, val) == 33);
25412         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
25413         ChannelPublicKeys_set_htlc_basepoint(&this_ptr_conv, val_ref);
25414 }
25415
25416 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) {
25417         LDKPublicKey funding_pubkey_arg_ref;
25418         CHECK((*env)->GetArrayLength(env, funding_pubkey_arg) == 33);
25419         (*env)->GetByteArrayRegion(env, funding_pubkey_arg, 0, 33, funding_pubkey_arg_ref.compressed_form);
25420         LDKPublicKey revocation_basepoint_arg_ref;
25421         CHECK((*env)->GetArrayLength(env, revocation_basepoint_arg) == 33);
25422         (*env)->GetByteArrayRegion(env, revocation_basepoint_arg, 0, 33, revocation_basepoint_arg_ref.compressed_form);
25423         LDKPublicKey payment_point_arg_ref;
25424         CHECK((*env)->GetArrayLength(env, payment_point_arg) == 33);
25425         (*env)->GetByteArrayRegion(env, payment_point_arg, 0, 33, payment_point_arg_ref.compressed_form);
25426         LDKPublicKey delayed_payment_basepoint_arg_ref;
25427         CHECK((*env)->GetArrayLength(env, delayed_payment_basepoint_arg) == 33);
25428         (*env)->GetByteArrayRegion(env, delayed_payment_basepoint_arg, 0, 33, delayed_payment_basepoint_arg_ref.compressed_form);
25429         LDKPublicKey htlc_basepoint_arg_ref;
25430         CHECK((*env)->GetArrayLength(env, htlc_basepoint_arg) == 33);
25431         (*env)->GetByteArrayRegion(env, htlc_basepoint_arg, 0, 33, htlc_basepoint_arg_ref.compressed_form);
25432         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);
25433         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25434         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25435         uint64_t ret_ref = (uint64_t)ret_var.inner;
25436         if (ret_var.is_owned) {
25437                 ret_ref |= 1;
25438         }
25439         return ret_ref;
25440 }
25441
25442 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25443         LDKChannelPublicKeys orig_conv;
25444         orig_conv.inner = (void*)(orig & (~1));
25445         orig_conv.is_owned = false;
25446         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(&orig_conv);
25447         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25448         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25449         uint64_t ret_ref = (uint64_t)ret_var.inner;
25450         if (ret_var.is_owned) {
25451                 ret_ref |= 1;
25452         }
25453         return ret_ref;
25454 }
25455
25456 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1write(JNIEnv *env, jclass clz, int64_t obj) {
25457         LDKChannelPublicKeys obj_conv;
25458         obj_conv.inner = (void*)(obj & (~1));
25459         obj_conv.is_owned = false;
25460         LDKCVec_u8Z ret_var = ChannelPublicKeys_write(&obj_conv);
25461         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
25462         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
25463         CVec_u8Z_free(ret_var);
25464         return ret_arr;
25465 }
25466
25467 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
25468         LDKu8slice ser_ref;
25469         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
25470         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
25471         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
25472         *ret_conv = ChannelPublicKeys_read(ser_ref);
25473         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
25474         return (uint64_t)ret_conv;
25475 }
25476
25477 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) {
25478         LDKPublicKey per_commitment_point_ref;
25479         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
25480         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
25481         LDKPublicKey broadcaster_delayed_payment_base_ref;
25482         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_base) == 33);
25483         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_base, 0, 33, broadcaster_delayed_payment_base_ref.compressed_form);
25484         LDKPublicKey broadcaster_htlc_base_ref;
25485         CHECK((*env)->GetArrayLength(env, broadcaster_htlc_base) == 33);
25486         (*env)->GetByteArrayRegion(env, broadcaster_htlc_base, 0, 33, broadcaster_htlc_base_ref.compressed_form);
25487         LDKPublicKey countersignatory_revocation_base_ref;
25488         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base) == 33);
25489         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base, 0, 33, countersignatory_revocation_base_ref.compressed_form);
25490         LDKPublicKey countersignatory_htlc_base_ref;
25491         CHECK((*env)->GetArrayLength(env, countersignatory_htlc_base) == 33);
25492         (*env)->GetByteArrayRegion(env, countersignatory_htlc_base, 0, 33, countersignatory_htlc_base_ref.compressed_form);
25493         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
25494         *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);
25495         return (uint64_t)ret_conv;
25496 }
25497
25498 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) {
25499         LDKPublicKey per_commitment_point_ref;
25500         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
25501         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
25502         LDKChannelPublicKeys broadcaster_keys_conv;
25503         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
25504         broadcaster_keys_conv.is_owned = false;
25505         LDKChannelPublicKeys countersignatory_keys_conv;
25506         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
25507         countersignatory_keys_conv.is_owned = false;
25508         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
25509         *ret_conv = TxCreationKeys_from_channel_static_keys(per_commitment_point_ref, &broadcaster_keys_conv, &countersignatory_keys_conv);
25510         return (uint64_t)ret_conv;
25511 }
25512
25513 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) {
25514         LDKPublicKey revocation_key_ref;
25515         CHECK((*env)->GetArrayLength(env, revocation_key) == 33);
25516         (*env)->GetByteArrayRegion(env, revocation_key, 0, 33, revocation_key_ref.compressed_form);
25517         LDKPublicKey broadcaster_delayed_payment_key_ref;
25518         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key) == 33);
25519         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key, 0, 33, broadcaster_delayed_payment_key_ref.compressed_form);
25520         LDKCVec_u8Z ret_var = get_revokeable_redeemscript(revocation_key_ref, contest_delay, broadcaster_delayed_payment_key_ref);
25521         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
25522         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
25523         CVec_u8Z_free(ret_var);
25524         return ret_arr;
25525 }
25526
25527 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25528         LDKHTLCOutputInCommitment this_obj_conv;
25529         this_obj_conv.inner = (void*)(this_obj & (~1));
25530         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25531         HTLCOutputInCommitment_free(this_obj_conv);
25532 }
25533
25534 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1offered(JNIEnv *env, jclass clz, int64_t this_ptr) {
25535         LDKHTLCOutputInCommitment this_ptr_conv;
25536         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25537         this_ptr_conv.is_owned = false;
25538         jboolean ret_val = HTLCOutputInCommitment_get_offered(&this_ptr_conv);
25539         return ret_val;
25540 }
25541
25542 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1offered(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
25543         LDKHTLCOutputInCommitment this_ptr_conv;
25544         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25545         this_ptr_conv.is_owned = false;
25546         HTLCOutputInCommitment_set_offered(&this_ptr_conv, val);
25547 }
25548
25549 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
25550         LDKHTLCOutputInCommitment this_ptr_conv;
25551         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25552         this_ptr_conv.is_owned = false;
25553         int64_t ret_val = HTLCOutputInCommitment_get_amount_msat(&this_ptr_conv);
25554         return ret_val;
25555 }
25556
25557 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25558         LDKHTLCOutputInCommitment this_ptr_conv;
25559         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25560         this_ptr_conv.is_owned = false;
25561         HTLCOutputInCommitment_set_amount_msat(&this_ptr_conv, val);
25562 }
25563
25564 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr) {
25565         LDKHTLCOutputInCommitment this_ptr_conv;
25566         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25567         this_ptr_conv.is_owned = false;
25568         int32_t ret_val = HTLCOutputInCommitment_get_cltv_expiry(&this_ptr_conv);
25569         return ret_val;
25570 }
25571
25572 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
25573         LDKHTLCOutputInCommitment this_ptr_conv;
25574         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25575         this_ptr_conv.is_owned = false;
25576         HTLCOutputInCommitment_set_cltv_expiry(&this_ptr_conv, val);
25577 }
25578
25579 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
25580         LDKHTLCOutputInCommitment this_ptr_conv;
25581         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25582         this_ptr_conv.is_owned = false;
25583         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
25584         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *HTLCOutputInCommitment_get_payment_hash(&this_ptr_conv));
25585         return ret_arr;
25586 }
25587
25588 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
25589         LDKHTLCOutputInCommitment this_ptr_conv;
25590         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25591         this_ptr_conv.is_owned = false;
25592         LDKThirtyTwoBytes val_ref;
25593         CHECK((*env)->GetArrayLength(env, val) == 32);
25594         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
25595         HTLCOutputInCommitment_set_payment_hash(&this_ptr_conv, val_ref);
25596 }
25597
25598 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1transaction_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
25599         LDKHTLCOutputInCommitment this_ptr_conv;
25600         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25601         this_ptr_conv.is_owned = false;
25602         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
25603         *ret_copy = HTLCOutputInCommitment_get_transaction_output_index(&this_ptr_conv);
25604         uint64_t ret_ref = (uint64_t)ret_copy;
25605         return ret_ref;
25606 }
25607
25608 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1transaction_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25609         LDKHTLCOutputInCommitment this_ptr_conv;
25610         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25611         this_ptr_conv.is_owned = false;
25612         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(((uint64_t)val) & ~1);
25613         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uint64_t)val) & ~1));
25614         HTLCOutputInCommitment_set_transaction_output_index(&this_ptr_conv, val_conv);
25615 }
25616
25617 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) {
25618         LDKThirtyTwoBytes payment_hash_arg_ref;
25619         CHECK((*env)->GetArrayLength(env, payment_hash_arg) == 32);
25620         (*env)->GetByteArrayRegion(env, payment_hash_arg, 0, 32, payment_hash_arg_ref.data);
25621         LDKCOption_u32Z transaction_output_index_arg_conv = *(LDKCOption_u32Z*)(((uint64_t)transaction_output_index_arg) & ~1);
25622         transaction_output_index_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uint64_t)transaction_output_index_arg) & ~1));
25623         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_new(offered_arg, amount_msat_arg, cltv_expiry_arg, payment_hash_arg_ref, transaction_output_index_arg_conv);
25624         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25625         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25626         uint64_t ret_ref = (uint64_t)ret_var.inner;
25627         if (ret_var.is_owned) {
25628                 ret_ref |= 1;
25629         }
25630         return ret_ref;
25631 }
25632
25633 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25634         LDKHTLCOutputInCommitment orig_conv;
25635         orig_conv.inner = (void*)(orig & (~1));
25636         orig_conv.is_owned = false;
25637         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(&orig_conv);
25638         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25639         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25640         uint64_t ret_ref = (uint64_t)ret_var.inner;
25641         if (ret_var.is_owned) {
25642                 ret_ref |= 1;
25643         }
25644         return ret_ref;
25645 }
25646
25647 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1write(JNIEnv *env, jclass clz, int64_t obj) {
25648         LDKHTLCOutputInCommitment obj_conv;
25649         obj_conv.inner = (void*)(obj & (~1));
25650         obj_conv.is_owned = false;
25651         LDKCVec_u8Z ret_var = HTLCOutputInCommitment_write(&obj_conv);
25652         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
25653         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
25654         CVec_u8Z_free(ret_var);
25655         return ret_arr;
25656 }
25657
25658 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
25659         LDKu8slice ser_ref;
25660         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
25661         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
25662         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
25663         *ret_conv = HTLCOutputInCommitment_read(ser_ref);
25664         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
25665         return (uint64_t)ret_conv;
25666 }
25667
25668 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_get_1htlc_1redeemscript(JNIEnv *env, jclass clz, int64_t htlc, int64_t keys) {
25669         LDKHTLCOutputInCommitment htlc_conv;
25670         htlc_conv.inner = (void*)(htlc & (~1));
25671         htlc_conv.is_owned = false;
25672         LDKTxCreationKeys keys_conv;
25673         keys_conv.inner = (void*)(keys & (~1));
25674         keys_conv.is_owned = false;
25675         LDKCVec_u8Z ret_var = get_htlc_redeemscript(&htlc_conv, &keys_conv);
25676         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
25677         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
25678         CVec_u8Z_free(ret_var);
25679         return ret_arr;
25680 }
25681
25682 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_make_1funding_1redeemscript(JNIEnv *env, jclass clz, int8_tArray broadcaster, int8_tArray countersignatory) {
25683         LDKPublicKey broadcaster_ref;
25684         CHECK((*env)->GetArrayLength(env, broadcaster) == 33);
25685         (*env)->GetByteArrayRegion(env, broadcaster, 0, 33, broadcaster_ref.compressed_form);
25686         LDKPublicKey countersignatory_ref;
25687         CHECK((*env)->GetArrayLength(env, countersignatory) == 33);
25688         (*env)->GetByteArrayRegion(env, countersignatory, 0, 33, countersignatory_ref.compressed_form);
25689         LDKCVec_u8Z ret_var = make_funding_redeemscript(broadcaster_ref, countersignatory_ref);
25690         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
25691         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
25692         CVec_u8Z_free(ret_var);
25693         return ret_arr;
25694 }
25695
25696 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) {
25697         unsigned char commitment_txid_arr[32];
25698         CHECK((*env)->GetArrayLength(env, commitment_txid) == 32);
25699         (*env)->GetByteArrayRegion(env, commitment_txid, 0, 32, commitment_txid_arr);
25700         unsigned char (*commitment_txid_ref)[32] = &commitment_txid_arr;
25701         LDKHTLCOutputInCommitment htlc_conv;
25702         htlc_conv.inner = (void*)(htlc & (~1));
25703         htlc_conv.is_owned = false;
25704         LDKPublicKey broadcaster_delayed_payment_key_ref;
25705         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key) == 33);
25706         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key, 0, 33, broadcaster_delayed_payment_key_ref.compressed_form);
25707         LDKPublicKey revocation_key_ref;
25708         CHECK((*env)->GetArrayLength(env, revocation_key) == 33);
25709         (*env)->GetByteArrayRegion(env, revocation_key, 0, 33, revocation_key_ref.compressed_form);
25710         LDKTransaction ret_var = build_htlc_transaction(commitment_txid_ref, feerate_per_kw, contest_delay, &htlc_conv, broadcaster_delayed_payment_key_ref, revocation_key_ref);
25711         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
25712         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
25713         Transaction_free(ret_var);
25714         return ret_arr;
25715 }
25716
25717 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25718         LDKChannelTransactionParameters this_obj_conv;
25719         this_obj_conv.inner = (void*)(this_obj & (~1));
25720         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25721         ChannelTransactionParameters_free(this_obj_conv);
25722 }
25723
25724 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1holder_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr) {
25725         LDKChannelTransactionParameters this_ptr_conv;
25726         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25727         this_ptr_conv.is_owned = false;
25728         LDKChannelPublicKeys ret_var = ChannelTransactionParameters_get_holder_pubkeys(&this_ptr_conv);
25729         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25730         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25731         uint64_t ret_ref = (uint64_t)ret_var.inner;
25732         if (ret_var.is_owned) {
25733                 ret_ref |= 1;
25734         }
25735         return ret_ref;
25736 }
25737
25738 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1holder_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25739         LDKChannelTransactionParameters this_ptr_conv;
25740         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25741         this_ptr_conv.is_owned = false;
25742         LDKChannelPublicKeys val_conv;
25743         val_conv.inner = (void*)(val & (~1));
25744         val_conv.is_owned = (val & 1) || (val == 0);
25745         val_conv = ChannelPublicKeys_clone(&val_conv);
25746         ChannelTransactionParameters_set_holder_pubkeys(&this_ptr_conv, val_conv);
25747 }
25748
25749 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1holder_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
25750         LDKChannelTransactionParameters this_ptr_conv;
25751         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25752         this_ptr_conv.is_owned = false;
25753         int16_t ret_val = ChannelTransactionParameters_get_holder_selected_contest_delay(&this_ptr_conv);
25754         return ret_val;
25755 }
25756
25757 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) {
25758         LDKChannelTransactionParameters this_ptr_conv;
25759         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25760         this_ptr_conv.is_owned = false;
25761         ChannelTransactionParameters_set_holder_selected_contest_delay(&this_ptr_conv, val);
25762 }
25763
25764 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1is_1outbound_1from_1holder(JNIEnv *env, jclass clz, int64_t this_ptr) {
25765         LDKChannelTransactionParameters this_ptr_conv;
25766         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25767         this_ptr_conv.is_owned = false;
25768         jboolean ret_val = ChannelTransactionParameters_get_is_outbound_from_holder(&this_ptr_conv);
25769         return ret_val;
25770 }
25771
25772 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1is_1outbound_1from_1holder(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
25773         LDKChannelTransactionParameters this_ptr_conv;
25774         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25775         this_ptr_conv.is_owned = false;
25776         ChannelTransactionParameters_set_is_outbound_from_holder(&this_ptr_conv, val);
25777 }
25778
25779 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1counterparty_1parameters(JNIEnv *env, jclass clz, int64_t this_ptr) {
25780         LDKChannelTransactionParameters this_ptr_conv;
25781         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25782         this_ptr_conv.is_owned = false;
25783         LDKCounterpartyChannelTransactionParameters ret_var = ChannelTransactionParameters_get_counterparty_parameters(&this_ptr_conv);
25784         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25785         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25786         uint64_t ret_ref = (uint64_t)ret_var.inner;
25787         if (ret_var.is_owned) {
25788                 ret_ref |= 1;
25789         }
25790         return ret_ref;
25791 }
25792
25793 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1counterparty_1parameters(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25794         LDKChannelTransactionParameters this_ptr_conv;
25795         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25796         this_ptr_conv.is_owned = false;
25797         LDKCounterpartyChannelTransactionParameters val_conv;
25798         val_conv.inner = (void*)(val & (~1));
25799         val_conv.is_owned = (val & 1) || (val == 0);
25800         val_conv = CounterpartyChannelTransactionParameters_clone(&val_conv);
25801         ChannelTransactionParameters_set_counterparty_parameters(&this_ptr_conv, val_conv);
25802 }
25803
25804 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
25805         LDKChannelTransactionParameters this_ptr_conv;
25806         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25807         this_ptr_conv.is_owned = false;
25808         LDKOutPoint ret_var = ChannelTransactionParameters_get_funding_outpoint(&this_ptr_conv);
25809         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25810         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25811         uint64_t ret_ref = (uint64_t)ret_var.inner;
25812         if (ret_var.is_owned) {
25813                 ret_ref |= 1;
25814         }
25815         return ret_ref;
25816 }
25817
25818 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25819         LDKChannelTransactionParameters this_ptr_conv;
25820         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25821         this_ptr_conv.is_owned = false;
25822         LDKOutPoint val_conv;
25823         val_conv.inner = (void*)(val & (~1));
25824         val_conv.is_owned = (val & 1) || (val == 0);
25825         val_conv = OutPoint_clone(&val_conv);
25826         ChannelTransactionParameters_set_funding_outpoint(&this_ptr_conv, val_conv);
25827 }
25828
25829 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) {
25830         LDKChannelPublicKeys holder_pubkeys_arg_conv;
25831         holder_pubkeys_arg_conv.inner = (void*)(holder_pubkeys_arg & (~1));
25832         holder_pubkeys_arg_conv.is_owned = (holder_pubkeys_arg & 1) || (holder_pubkeys_arg == 0);
25833         holder_pubkeys_arg_conv = ChannelPublicKeys_clone(&holder_pubkeys_arg_conv);
25834         LDKCounterpartyChannelTransactionParameters counterparty_parameters_arg_conv;
25835         counterparty_parameters_arg_conv.inner = (void*)(counterparty_parameters_arg & (~1));
25836         counterparty_parameters_arg_conv.is_owned = (counterparty_parameters_arg & 1) || (counterparty_parameters_arg == 0);
25837         counterparty_parameters_arg_conv = CounterpartyChannelTransactionParameters_clone(&counterparty_parameters_arg_conv);
25838         LDKOutPoint funding_outpoint_arg_conv;
25839         funding_outpoint_arg_conv.inner = (void*)(funding_outpoint_arg & (~1));
25840         funding_outpoint_arg_conv.is_owned = (funding_outpoint_arg & 1) || (funding_outpoint_arg == 0);
25841         funding_outpoint_arg_conv = OutPoint_clone(&funding_outpoint_arg_conv);
25842         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);
25843         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25844         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25845         uint64_t ret_ref = (uint64_t)ret_var.inner;
25846         if (ret_var.is_owned) {
25847                 ret_ref |= 1;
25848         }
25849         return ret_ref;
25850 }
25851
25852 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25853         LDKChannelTransactionParameters orig_conv;
25854         orig_conv.inner = (void*)(orig & (~1));
25855         orig_conv.is_owned = false;
25856         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(&orig_conv);
25857         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25858         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25859         uint64_t ret_ref = (uint64_t)ret_var.inner;
25860         if (ret_var.is_owned) {
25861                 ret_ref |= 1;
25862         }
25863         return ret_ref;
25864 }
25865
25866 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25867         LDKCounterpartyChannelTransactionParameters this_obj_conv;
25868         this_obj_conv.inner = (void*)(this_obj & (~1));
25869         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25870         CounterpartyChannelTransactionParameters_free(this_obj_conv);
25871 }
25872
25873 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1get_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr) {
25874         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
25875         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25876         this_ptr_conv.is_owned = false;
25877         LDKChannelPublicKeys ret_var = CounterpartyChannelTransactionParameters_get_pubkeys(&this_ptr_conv);
25878         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25879         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25880         uint64_t ret_ref = (uint64_t)ret_var.inner;
25881         if (ret_var.is_owned) {
25882                 ret_ref |= 1;
25883         }
25884         return ret_ref;
25885 }
25886
25887 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1set_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25888         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
25889         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25890         this_ptr_conv.is_owned = false;
25891         LDKChannelPublicKeys val_conv;
25892         val_conv.inner = (void*)(val & (~1));
25893         val_conv.is_owned = (val & 1) || (val == 0);
25894         val_conv = ChannelPublicKeys_clone(&val_conv);
25895         CounterpartyChannelTransactionParameters_set_pubkeys(&this_ptr_conv, val_conv);
25896 }
25897
25898 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1get_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
25899         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
25900         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25901         this_ptr_conv.is_owned = false;
25902         int16_t ret_val = CounterpartyChannelTransactionParameters_get_selected_contest_delay(&this_ptr_conv);
25903         return ret_val;
25904 }
25905
25906 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1set_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
25907         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
25908         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25909         this_ptr_conv.is_owned = false;
25910         CounterpartyChannelTransactionParameters_set_selected_contest_delay(&this_ptr_conv, val);
25911 }
25912
25913 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) {
25914         LDKChannelPublicKeys pubkeys_arg_conv;
25915         pubkeys_arg_conv.inner = (void*)(pubkeys_arg & (~1));
25916         pubkeys_arg_conv.is_owned = (pubkeys_arg & 1) || (pubkeys_arg == 0);
25917         pubkeys_arg_conv = ChannelPublicKeys_clone(&pubkeys_arg_conv);
25918         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_new(pubkeys_arg_conv, selected_contest_delay_arg);
25919         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25920         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25921         uint64_t ret_ref = (uint64_t)ret_var.inner;
25922         if (ret_var.is_owned) {
25923                 ret_ref |= 1;
25924         }
25925         return ret_ref;
25926 }
25927
25928 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25929         LDKCounterpartyChannelTransactionParameters orig_conv;
25930         orig_conv.inner = (void*)(orig & (~1));
25931         orig_conv.is_owned = false;
25932         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(&orig_conv);
25933         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25934         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25935         uint64_t ret_ref = (uint64_t)ret_var.inner;
25936         if (ret_var.is_owned) {
25937                 ret_ref |= 1;
25938         }
25939         return ret_ref;
25940 }
25941
25942 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1is_1populated(JNIEnv *env, jclass clz, int64_t this_arg) {
25943         LDKChannelTransactionParameters this_arg_conv;
25944         this_arg_conv.inner = (void*)(this_arg & (~1));
25945         this_arg_conv.is_owned = false;
25946         jboolean ret_val = ChannelTransactionParameters_is_populated(&this_arg_conv);
25947         return ret_val;
25948 }
25949
25950 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1as_1holder_1broadcastable(JNIEnv *env, jclass clz, int64_t this_arg) {
25951         LDKChannelTransactionParameters this_arg_conv;
25952         this_arg_conv.inner = (void*)(this_arg & (~1));
25953         this_arg_conv.is_owned = false;
25954         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_holder_broadcastable(&this_arg_conv);
25955         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25956         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25957         uint64_t ret_ref = (uint64_t)ret_var.inner;
25958         if (ret_var.is_owned) {
25959                 ret_ref |= 1;
25960         }
25961         return ret_ref;
25962 }
25963
25964 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1as_1counterparty_1broadcastable(JNIEnv *env, jclass clz, int64_t this_arg) {
25965         LDKChannelTransactionParameters this_arg_conv;
25966         this_arg_conv.inner = (void*)(this_arg & (~1));
25967         this_arg_conv.is_owned = false;
25968         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_counterparty_broadcastable(&this_arg_conv);
25969         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25970         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25971         uint64_t ret_ref = (uint64_t)ret_var.inner;
25972         if (ret_var.is_owned) {
25973                 ret_ref |= 1;
25974         }
25975         return ret_ref;
25976 }
25977
25978 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
25979         LDKCounterpartyChannelTransactionParameters obj_conv;
25980         obj_conv.inner = (void*)(obj & (~1));
25981         obj_conv.is_owned = false;
25982         LDKCVec_u8Z ret_var = CounterpartyChannelTransactionParameters_write(&obj_conv);
25983         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
25984         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
25985         CVec_u8Z_free(ret_var);
25986         return ret_arr;
25987 }
25988
25989 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
25990         LDKu8slice ser_ref;
25991         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
25992         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
25993         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
25994         *ret_conv = CounterpartyChannelTransactionParameters_read(ser_ref);
25995         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
25996         return (uint64_t)ret_conv;
25997 }
25998
25999 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
26000         LDKChannelTransactionParameters obj_conv;
26001         obj_conv.inner = (void*)(obj & (~1));
26002         obj_conv.is_owned = false;
26003         LDKCVec_u8Z ret_var = ChannelTransactionParameters_write(&obj_conv);
26004         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26005         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26006         CVec_u8Z_free(ret_var);
26007         return ret_arr;
26008 }
26009
26010 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
26011         LDKu8slice ser_ref;
26012         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
26013         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
26014         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
26015         *ret_conv = ChannelTransactionParameters_read(ser_ref);
26016         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
26017         return (uint64_t)ret_conv;
26018 }
26019
26020 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26021         LDKDirectedChannelTransactionParameters this_obj_conv;
26022         this_obj_conv.inner = (void*)(this_obj & (~1));
26023         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26024         DirectedChannelTransactionParameters_free(this_obj_conv);
26025 }
26026
26027 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1broadcaster_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
26028         LDKDirectedChannelTransactionParameters this_arg_conv;
26029         this_arg_conv.inner = (void*)(this_arg & (~1));
26030         this_arg_conv.is_owned = false;
26031         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_broadcaster_pubkeys(&this_arg_conv);
26032         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26033         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26034         uint64_t ret_ref = (uint64_t)ret_var.inner;
26035         if (ret_var.is_owned) {
26036                 ret_ref |= 1;
26037         }
26038         return ret_ref;
26039 }
26040
26041 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1countersignatory_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
26042         LDKDirectedChannelTransactionParameters this_arg_conv;
26043         this_arg_conv.inner = (void*)(this_arg & (~1));
26044         this_arg_conv.is_owned = false;
26045         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_countersignatory_pubkeys(&this_arg_conv);
26046         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26047         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26048         uint64_t ret_ref = (uint64_t)ret_var.inner;
26049         if (ret_var.is_owned) {
26050                 ret_ref |= 1;
26051         }
26052         return ret_ref;
26053 }
26054
26055 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
26056         LDKDirectedChannelTransactionParameters this_arg_conv;
26057         this_arg_conv.inner = (void*)(this_arg & (~1));
26058         this_arg_conv.is_owned = false;
26059         int16_t ret_val = DirectedChannelTransactionParameters_contest_delay(&this_arg_conv);
26060         return ret_val;
26061 }
26062
26063 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_arg) {
26064         LDKDirectedChannelTransactionParameters this_arg_conv;
26065         this_arg_conv.inner = (void*)(this_arg & (~1));
26066         this_arg_conv.is_owned = false;
26067         jboolean ret_val = DirectedChannelTransactionParameters_is_outbound(&this_arg_conv);
26068         return ret_val;
26069 }
26070
26071 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_arg) {
26072         LDKDirectedChannelTransactionParameters this_arg_conv;
26073         this_arg_conv.inner = (void*)(this_arg & (~1));
26074         this_arg_conv.is_owned = false;
26075         LDKOutPoint ret_var = DirectedChannelTransactionParameters_funding_outpoint(&this_arg_conv);
26076         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26077         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26078         uint64_t ret_ref = (uint64_t)ret_var.inner;
26079         if (ret_var.is_owned) {
26080                 ret_ref |= 1;
26081         }
26082         return ret_ref;
26083 }
26084
26085 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26086         LDKHolderCommitmentTransaction this_obj_conv;
26087         this_obj_conv.inner = (void*)(this_obj & (~1));
26088         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26089         HolderCommitmentTransaction_free(this_obj_conv);
26090 }
26091
26092 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1get_1counterparty_1sig(JNIEnv *env, jclass clz, int64_t this_ptr) {
26093         LDKHolderCommitmentTransaction this_ptr_conv;
26094         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26095         this_ptr_conv.is_owned = false;
26096         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
26097         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, HolderCommitmentTransaction_get_counterparty_sig(&this_ptr_conv).compact_form);
26098         return ret_arr;
26099 }
26100
26101 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1counterparty_1sig(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
26102         LDKHolderCommitmentTransaction this_ptr_conv;
26103         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26104         this_ptr_conv.is_owned = false;
26105         LDKSignature val_ref;
26106         CHECK((*env)->GetArrayLength(env, val) == 64);
26107         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
26108         HolderCommitmentTransaction_set_counterparty_sig(&this_ptr_conv, val_ref);
26109 }
26110
26111 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1counterparty_1htlc_1sigs(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
26112         LDKHolderCommitmentTransaction this_ptr_conv;
26113         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26114         this_ptr_conv.is_owned = false;
26115         LDKCVec_SignatureZ val_constr;
26116         val_constr.datalen = (*env)->GetArrayLength(env, val);
26117         if (val_constr.datalen > 0)
26118                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
26119         else
26120                 val_constr.data = NULL;
26121         for (size_t i = 0; i < val_constr.datalen; i++) {
26122                 int8_tArray val_conv_8 = (*env)->GetObjectArrayElement(env, val, i);
26123                 LDKSignature val_conv_8_ref;
26124                 CHECK((*env)->GetArrayLength(env, val_conv_8) == 64);
26125                 (*env)->GetByteArrayRegion(env, val_conv_8, 0, 64, val_conv_8_ref.compact_form);
26126                 val_constr.data[i] = val_conv_8_ref;
26127         }
26128         HolderCommitmentTransaction_set_counterparty_htlc_sigs(&this_ptr_conv, val_constr);
26129 }
26130
26131 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26132         LDKHolderCommitmentTransaction orig_conv;
26133         orig_conv.inner = (void*)(orig & (~1));
26134         orig_conv.is_owned = false;
26135         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(&orig_conv);
26136         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26137         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26138         uint64_t ret_ref = (uint64_t)ret_var.inner;
26139         if (ret_var.is_owned) {
26140                 ret_ref |= 1;
26141         }
26142         return ret_ref;
26143 }
26144
26145 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
26146         LDKHolderCommitmentTransaction obj_conv;
26147         obj_conv.inner = (void*)(obj & (~1));
26148         obj_conv.is_owned = false;
26149         LDKCVec_u8Z ret_var = HolderCommitmentTransaction_write(&obj_conv);
26150         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26151         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26152         CVec_u8Z_free(ret_var);
26153         return ret_arr;
26154 }
26155
26156 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
26157         LDKu8slice ser_ref;
26158         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
26159         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
26160         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
26161         *ret_conv = HolderCommitmentTransaction_read(ser_ref);
26162         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
26163         return (uint64_t)ret_conv;
26164 }
26165
26166 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) {
26167         LDKCommitmentTransaction commitment_tx_conv;
26168         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
26169         commitment_tx_conv.is_owned = (commitment_tx & 1) || (commitment_tx == 0);
26170         commitment_tx_conv = CommitmentTransaction_clone(&commitment_tx_conv);
26171         LDKSignature counterparty_sig_ref;
26172         CHECK((*env)->GetArrayLength(env, counterparty_sig) == 64);
26173         (*env)->GetByteArrayRegion(env, counterparty_sig, 0, 64, counterparty_sig_ref.compact_form);
26174         LDKCVec_SignatureZ counterparty_htlc_sigs_constr;
26175         counterparty_htlc_sigs_constr.datalen = (*env)->GetArrayLength(env, counterparty_htlc_sigs);
26176         if (counterparty_htlc_sigs_constr.datalen > 0)
26177                 counterparty_htlc_sigs_constr.data = MALLOC(counterparty_htlc_sigs_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
26178         else
26179                 counterparty_htlc_sigs_constr.data = NULL;
26180         for (size_t i = 0; i < counterparty_htlc_sigs_constr.datalen; i++) {
26181                 int8_tArray counterparty_htlc_sigs_conv_8 = (*env)->GetObjectArrayElement(env, counterparty_htlc_sigs, i);
26182                 LDKSignature counterparty_htlc_sigs_conv_8_ref;
26183                 CHECK((*env)->GetArrayLength(env, counterparty_htlc_sigs_conv_8) == 64);
26184                 (*env)->GetByteArrayRegion(env, counterparty_htlc_sigs_conv_8, 0, 64, counterparty_htlc_sigs_conv_8_ref.compact_form);
26185                 counterparty_htlc_sigs_constr.data[i] = counterparty_htlc_sigs_conv_8_ref;
26186         }
26187         LDKPublicKey holder_funding_key_ref;
26188         CHECK((*env)->GetArrayLength(env, holder_funding_key) == 33);
26189         (*env)->GetByteArrayRegion(env, holder_funding_key, 0, 33, holder_funding_key_ref.compressed_form);
26190         LDKPublicKey counterparty_funding_key_ref;
26191         CHECK((*env)->GetArrayLength(env, counterparty_funding_key) == 33);
26192         (*env)->GetByteArrayRegion(env, counterparty_funding_key, 0, 33, counterparty_funding_key_ref.compressed_form);
26193         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_new(commitment_tx_conv, counterparty_sig_ref, counterparty_htlc_sigs_constr, holder_funding_key_ref, counterparty_funding_key_ref);
26194         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26195         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26196         uint64_t ret_ref = (uint64_t)ret_var.inner;
26197         if (ret_var.is_owned) {
26198                 ret_ref |= 1;
26199         }
26200         return ret_ref;
26201 }
26202
26203 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26204         LDKBuiltCommitmentTransaction this_obj_conv;
26205         this_obj_conv.inner = (void*)(this_obj & (~1));
26206         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26207         BuiltCommitmentTransaction_free(this_obj_conv);
26208 }
26209
26210 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1get_1transaction(JNIEnv *env, jclass clz, int64_t this_ptr) {
26211         LDKBuiltCommitmentTransaction this_ptr_conv;
26212         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26213         this_ptr_conv.is_owned = false;
26214         LDKTransaction ret_var = BuiltCommitmentTransaction_get_transaction(&this_ptr_conv);
26215         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26216         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26217         Transaction_free(ret_var);
26218         return ret_arr;
26219 }
26220
26221 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1set_1transaction(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
26222         LDKBuiltCommitmentTransaction this_ptr_conv;
26223         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26224         this_ptr_conv.is_owned = false;
26225         LDKTransaction val_ref;
26226         val_ref.datalen = (*env)->GetArrayLength(env, val);
26227         val_ref.data = MALLOC(val_ref.datalen, "LDKTransaction Bytes");
26228         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
26229         val_ref.data_is_owned = true;
26230         BuiltCommitmentTransaction_set_transaction(&this_ptr_conv, val_ref);
26231 }
26232
26233 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1get_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
26234         LDKBuiltCommitmentTransaction this_ptr_conv;
26235         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26236         this_ptr_conv.is_owned = false;
26237         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
26238         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *BuiltCommitmentTransaction_get_txid(&this_ptr_conv));
26239         return ret_arr;
26240 }
26241
26242 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1set_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
26243         LDKBuiltCommitmentTransaction this_ptr_conv;
26244         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26245         this_ptr_conv.is_owned = false;
26246         LDKThirtyTwoBytes val_ref;
26247         CHECK((*env)->GetArrayLength(env, val) == 32);
26248         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
26249         BuiltCommitmentTransaction_set_txid(&this_ptr_conv, val_ref);
26250 }
26251
26252 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1new(JNIEnv *env, jclass clz, int8_tArray transaction_arg, int8_tArray txid_arg) {
26253         LDKTransaction transaction_arg_ref;
26254         transaction_arg_ref.datalen = (*env)->GetArrayLength(env, transaction_arg);
26255         transaction_arg_ref.data = MALLOC(transaction_arg_ref.datalen, "LDKTransaction Bytes");
26256         (*env)->GetByteArrayRegion(env, transaction_arg, 0, transaction_arg_ref.datalen, transaction_arg_ref.data);
26257         transaction_arg_ref.data_is_owned = true;
26258         LDKThirtyTwoBytes txid_arg_ref;
26259         CHECK((*env)->GetArrayLength(env, txid_arg) == 32);
26260         (*env)->GetByteArrayRegion(env, txid_arg, 0, 32, txid_arg_ref.data);
26261         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_new(transaction_arg_ref, txid_arg_ref);
26262         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26263         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26264         uint64_t ret_ref = (uint64_t)ret_var.inner;
26265         if (ret_var.is_owned) {
26266                 ret_ref |= 1;
26267         }
26268         return ret_ref;
26269 }
26270
26271 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26272         LDKBuiltCommitmentTransaction orig_conv;
26273         orig_conv.inner = (void*)(orig & (~1));
26274         orig_conv.is_owned = false;
26275         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(&orig_conv);
26276         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26277         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26278         uint64_t ret_ref = (uint64_t)ret_var.inner;
26279         if (ret_var.is_owned) {
26280                 ret_ref |= 1;
26281         }
26282         return ret_ref;
26283 }
26284
26285 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
26286         LDKBuiltCommitmentTransaction obj_conv;
26287         obj_conv.inner = (void*)(obj & (~1));
26288         obj_conv.is_owned = false;
26289         LDKCVec_u8Z ret_var = BuiltCommitmentTransaction_write(&obj_conv);
26290         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26291         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26292         CVec_u8Z_free(ret_var);
26293         return ret_arr;
26294 }
26295
26296 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
26297         LDKu8slice ser_ref;
26298         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
26299         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
26300         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
26301         *ret_conv = BuiltCommitmentTransaction_read(ser_ref);
26302         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
26303         return (uint64_t)ret_conv;
26304 }
26305
26306 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) {
26307         LDKBuiltCommitmentTransaction this_arg_conv;
26308         this_arg_conv.inner = (void*)(this_arg & (~1));
26309         this_arg_conv.is_owned = false;
26310         LDKu8slice funding_redeemscript_ref;
26311         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
26312         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
26313         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
26314         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, BuiltCommitmentTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data);
26315         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
26316         return ret_arr;
26317 }
26318
26319 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) {
26320         LDKBuiltCommitmentTransaction this_arg_conv;
26321         this_arg_conv.inner = (void*)(this_arg & (~1));
26322         this_arg_conv.is_owned = false;
26323         unsigned char funding_key_arr[32];
26324         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
26325         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_arr);
26326         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
26327         LDKu8slice funding_redeemscript_ref;
26328         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
26329         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
26330         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
26331         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, BuiltCommitmentTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form);
26332         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
26333         return ret_arr;
26334 }
26335
26336 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26337         LDKClosingTransaction this_obj_conv;
26338         this_obj_conv.inner = (void*)(this_obj & (~1));
26339         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26340         ClosingTransaction_free(this_obj_conv);
26341 }
26342
26343 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) {
26344         LDKCVec_u8Z to_holder_script_ref;
26345         to_holder_script_ref.datalen = (*env)->GetArrayLength(env, to_holder_script);
26346         to_holder_script_ref.data = MALLOC(to_holder_script_ref.datalen, "LDKCVec_u8Z Bytes");
26347         (*env)->GetByteArrayRegion(env, to_holder_script, 0, to_holder_script_ref.datalen, to_holder_script_ref.data);
26348         LDKCVec_u8Z to_counterparty_script_ref;
26349         to_counterparty_script_ref.datalen = (*env)->GetArrayLength(env, to_counterparty_script);
26350         to_counterparty_script_ref.data = MALLOC(to_counterparty_script_ref.datalen, "LDKCVec_u8Z Bytes");
26351         (*env)->GetByteArrayRegion(env, to_counterparty_script, 0, to_counterparty_script_ref.datalen, to_counterparty_script_ref.data);
26352         LDKOutPoint funding_outpoint_conv;
26353         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
26354         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
26355         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
26356         LDKClosingTransaction ret_var = ClosingTransaction_new(to_holder_value_sat, to_counterparty_value_sat, to_holder_script_ref, to_counterparty_script_ref, funding_outpoint_conv);
26357         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26358         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26359         uint64_t ret_ref = (uint64_t)ret_var.inner;
26360         if (ret_var.is_owned) {
26361                 ret_ref |= 1;
26362         }
26363         return ret_ref;
26364 }
26365
26366 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1trust(JNIEnv *env, jclass clz, int64_t this_arg) {
26367         LDKClosingTransaction this_arg_conv;
26368         this_arg_conv.inner = (void*)(this_arg & (~1));
26369         this_arg_conv.is_owned = false;
26370         LDKTrustedClosingTransaction ret_var = ClosingTransaction_trust(&this_arg_conv);
26371         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26372         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26373         uint64_t ret_ref = (uint64_t)ret_var.inner;
26374         if (ret_var.is_owned) {
26375                 ret_ref |= 1;
26376         }
26377         return ret_ref;
26378 }
26379
26380 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1verify(JNIEnv *env, jclass clz, int64_t this_arg, int64_t funding_outpoint) {
26381         LDKClosingTransaction this_arg_conv;
26382         this_arg_conv.inner = (void*)(this_arg & (~1));
26383         this_arg_conv.is_owned = false;
26384         LDKOutPoint funding_outpoint_conv;
26385         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
26386         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
26387         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
26388         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
26389         *ret_conv = ClosingTransaction_verify(&this_arg_conv, funding_outpoint_conv);
26390         return (uint64_t)ret_conv;
26391 }
26392
26393 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1holder_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
26394         LDKClosingTransaction this_arg_conv;
26395         this_arg_conv.inner = (void*)(this_arg & (~1));
26396         this_arg_conv.is_owned = false;
26397         int64_t ret_val = ClosingTransaction_to_holder_value_sat(&this_arg_conv);
26398         return ret_val;
26399 }
26400
26401 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1counterparty_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
26402         LDKClosingTransaction this_arg_conv;
26403         this_arg_conv.inner = (void*)(this_arg & (~1));
26404         this_arg_conv.is_owned = false;
26405         int64_t ret_val = ClosingTransaction_to_counterparty_value_sat(&this_arg_conv);
26406         return ret_val;
26407 }
26408
26409 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1holder_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
26410         LDKClosingTransaction this_arg_conv;
26411         this_arg_conv.inner = (void*)(this_arg & (~1));
26412         this_arg_conv.is_owned = false;
26413         LDKu8slice ret_var = ClosingTransaction_to_holder_script(&this_arg_conv);
26414         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26415         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26416         return ret_arr;
26417 }
26418
26419 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1counterparty_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
26420         LDKClosingTransaction this_arg_conv;
26421         this_arg_conv.inner = (void*)(this_arg & (~1));
26422         this_arg_conv.is_owned = false;
26423         LDKu8slice ret_var = ClosingTransaction_to_counterparty_script(&this_arg_conv);
26424         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26425         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26426         return ret_arr;
26427 }
26428
26429 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TrustedClosingTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26430         LDKTrustedClosingTransaction this_obj_conv;
26431         this_obj_conv.inner = (void*)(this_obj & (~1));
26432         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26433         TrustedClosingTransaction_free(this_obj_conv);
26434 }
26435
26436 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TrustedClosingTransaction_1built_1transaction(JNIEnv *env, jclass clz, int64_t this_arg) {
26437         LDKTrustedClosingTransaction this_arg_conv;
26438         this_arg_conv.inner = (void*)(this_arg & (~1));
26439         this_arg_conv.is_owned = false;
26440         LDKTransaction ret_var = TrustedClosingTransaction_built_transaction(&this_arg_conv);
26441         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26442         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26443         Transaction_free(ret_var);
26444         return ret_arr;
26445 }
26446
26447 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) {
26448         LDKTrustedClosingTransaction this_arg_conv;
26449         this_arg_conv.inner = (void*)(this_arg & (~1));
26450         this_arg_conv.is_owned = false;
26451         LDKu8slice funding_redeemscript_ref;
26452         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
26453         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
26454         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
26455         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, TrustedClosingTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data);
26456         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
26457         return ret_arr;
26458 }
26459
26460 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) {
26461         LDKTrustedClosingTransaction this_arg_conv;
26462         this_arg_conv.inner = (void*)(this_arg & (~1));
26463         this_arg_conv.is_owned = false;
26464         unsigned char funding_key_arr[32];
26465         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
26466         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_arr);
26467         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
26468         LDKu8slice funding_redeemscript_ref;
26469         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
26470         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
26471         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
26472         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, TrustedClosingTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form);
26473         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
26474         return ret_arr;
26475 }
26476
26477 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26478         LDKCommitmentTransaction this_obj_conv;
26479         this_obj_conv.inner = (void*)(this_obj & (~1));
26480         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26481         CommitmentTransaction_free(this_obj_conv);
26482 }
26483
26484 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26485         LDKCommitmentTransaction orig_conv;
26486         orig_conv.inner = (void*)(orig & (~1));
26487         orig_conv.is_owned = false;
26488         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(&orig_conv);
26489         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26490         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26491         uint64_t ret_ref = (uint64_t)ret_var.inner;
26492         if (ret_var.is_owned) {
26493                 ret_ref |= 1;
26494         }
26495         return ret_ref;
26496 }
26497
26498 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
26499         LDKCommitmentTransaction obj_conv;
26500         obj_conv.inner = (void*)(obj & (~1));
26501         obj_conv.is_owned = false;
26502         LDKCVec_u8Z ret_var = CommitmentTransaction_write(&obj_conv);
26503         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26504         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26505         CVec_u8Z_free(ret_var);
26506         return ret_arr;
26507 }
26508
26509 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
26510         LDKu8slice ser_ref;
26511         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
26512         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
26513         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
26514         *ret_conv = CommitmentTransaction_read(ser_ref);
26515         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
26516         return (uint64_t)ret_conv;
26517 }
26518
26519 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_arg) {
26520         LDKCommitmentTransaction this_arg_conv;
26521         this_arg_conv.inner = (void*)(this_arg & (~1));
26522         this_arg_conv.is_owned = false;
26523         int64_t ret_val = CommitmentTransaction_commitment_number(&this_arg_conv);
26524         return ret_val;
26525 }
26526
26527 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1to_1broadcaster_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
26528         LDKCommitmentTransaction this_arg_conv;
26529         this_arg_conv.inner = (void*)(this_arg & (~1));
26530         this_arg_conv.is_owned = false;
26531         int64_t ret_val = CommitmentTransaction_to_broadcaster_value_sat(&this_arg_conv);
26532         return ret_val;
26533 }
26534
26535 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1to_1countersignatory_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
26536         LDKCommitmentTransaction this_arg_conv;
26537         this_arg_conv.inner = (void*)(this_arg & (~1));
26538         this_arg_conv.is_owned = false;
26539         int64_t ret_val = CommitmentTransaction_to_countersignatory_value_sat(&this_arg_conv);
26540         return ret_val;
26541 }
26542
26543 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_arg) {
26544         LDKCommitmentTransaction this_arg_conv;
26545         this_arg_conv.inner = (void*)(this_arg & (~1));
26546         this_arg_conv.is_owned = false;
26547         int32_t ret_val = CommitmentTransaction_feerate_per_kw(&this_arg_conv);
26548         return ret_val;
26549 }
26550
26551 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1trust(JNIEnv *env, jclass clz, int64_t this_arg) {
26552         LDKCommitmentTransaction this_arg_conv;
26553         this_arg_conv.inner = (void*)(this_arg & (~1));
26554         this_arg_conv.is_owned = false;
26555         LDKTrustedCommitmentTransaction ret_var = CommitmentTransaction_trust(&this_arg_conv);
26556         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26557         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26558         uint64_t ret_ref = (uint64_t)ret_var.inner;
26559         if (ret_var.is_owned) {
26560                 ret_ref |= 1;
26561         }
26562         return ret_ref;
26563 }
26564
26565 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) {
26566         LDKCommitmentTransaction this_arg_conv;
26567         this_arg_conv.inner = (void*)(this_arg & (~1));
26568         this_arg_conv.is_owned = false;
26569         LDKDirectedChannelTransactionParameters channel_parameters_conv;
26570         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
26571         channel_parameters_conv.is_owned = false;
26572         LDKChannelPublicKeys broadcaster_keys_conv;
26573         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
26574         broadcaster_keys_conv.is_owned = false;
26575         LDKChannelPublicKeys countersignatory_keys_conv;
26576         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
26577         countersignatory_keys_conv.is_owned = false;
26578         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
26579         *ret_conv = CommitmentTransaction_verify(&this_arg_conv, &channel_parameters_conv, &broadcaster_keys_conv, &countersignatory_keys_conv);
26580         return (uint64_t)ret_conv;
26581 }
26582
26583 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26584         LDKTrustedCommitmentTransaction this_obj_conv;
26585         this_obj_conv.inner = (void*)(this_obj & (~1));
26586         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26587         TrustedCommitmentTransaction_free(this_obj_conv);
26588 }
26589
26590 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1txid(JNIEnv *env, jclass clz, int64_t this_arg) {
26591         LDKTrustedCommitmentTransaction this_arg_conv;
26592         this_arg_conv.inner = (void*)(this_arg & (~1));
26593         this_arg_conv.is_owned = false;
26594         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
26595         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, TrustedCommitmentTransaction_txid(&this_arg_conv).data);
26596         return ret_arr;
26597 }
26598
26599 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1built_1transaction(JNIEnv *env, jclass clz, int64_t this_arg) {
26600         LDKTrustedCommitmentTransaction this_arg_conv;
26601         this_arg_conv.inner = (void*)(this_arg & (~1));
26602         this_arg_conv.is_owned = false;
26603         LDKBuiltCommitmentTransaction ret_var = TrustedCommitmentTransaction_built_transaction(&this_arg_conv);
26604         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26605         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26606         uint64_t ret_ref = (uint64_t)ret_var.inner;
26607         if (ret_var.is_owned) {
26608                 ret_ref |= 1;
26609         }
26610         return ret_ref;
26611 }
26612
26613 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1keys(JNIEnv *env, jclass clz, int64_t this_arg) {
26614         LDKTrustedCommitmentTransaction this_arg_conv;
26615         this_arg_conv.inner = (void*)(this_arg & (~1));
26616         this_arg_conv.is_owned = false;
26617         LDKTxCreationKeys ret_var = TrustedCommitmentTransaction_keys(&this_arg_conv);
26618         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26619         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26620         uint64_t ret_ref = (uint64_t)ret_var.inner;
26621         if (ret_var.is_owned) {
26622                 ret_ref |= 1;
26623         }
26624         return ret_ref;
26625 }
26626
26627 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) {
26628         LDKTrustedCommitmentTransaction this_arg_conv;
26629         this_arg_conv.inner = (void*)(this_arg & (~1));
26630         this_arg_conv.is_owned = false;
26631         unsigned char htlc_base_key_arr[32];
26632         CHECK((*env)->GetArrayLength(env, htlc_base_key) == 32);
26633         (*env)->GetByteArrayRegion(env, htlc_base_key, 0, 32, htlc_base_key_arr);
26634         unsigned char (*htlc_base_key_ref)[32] = &htlc_base_key_arr;
26635         LDKDirectedChannelTransactionParameters channel_parameters_conv;
26636         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
26637         channel_parameters_conv.is_owned = false;
26638         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
26639         *ret_conv = TrustedCommitmentTransaction_get_htlc_sigs(&this_arg_conv, htlc_base_key_ref, &channel_parameters_conv);
26640         return (uint64_t)ret_conv;
26641 }
26642
26643 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) {
26644         LDKPublicKey broadcaster_payment_basepoint_ref;
26645         CHECK((*env)->GetArrayLength(env, broadcaster_payment_basepoint) == 33);
26646         (*env)->GetByteArrayRegion(env, broadcaster_payment_basepoint, 0, 33, broadcaster_payment_basepoint_ref.compressed_form);
26647         LDKPublicKey countersignatory_payment_basepoint_ref;
26648         CHECK((*env)->GetArrayLength(env, countersignatory_payment_basepoint) == 33);
26649         (*env)->GetByteArrayRegion(env, countersignatory_payment_basepoint, 0, 33, countersignatory_payment_basepoint_ref.compressed_form);
26650         int64_t ret_val = get_commitment_transaction_number_obscure_factor(broadcaster_payment_basepoint_ref, countersignatory_payment_basepoint_ref, outbound_from_broadcaster);
26651         return ret_val;
26652 }
26653
26654 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
26655         LDKInitFeatures a_conv;
26656         a_conv.inner = (void*)(a & (~1));
26657         a_conv.is_owned = false;
26658         LDKInitFeatures b_conv;
26659         b_conv.inner = (void*)(b & (~1));
26660         b_conv.is_owned = false;
26661         jboolean ret_val = InitFeatures_eq(&a_conv, &b_conv);
26662         return ret_val;
26663 }
26664
26665 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
26666         LDKNodeFeatures a_conv;
26667         a_conv.inner = (void*)(a & (~1));
26668         a_conv.is_owned = false;
26669         LDKNodeFeatures b_conv;
26670         b_conv.inner = (void*)(b & (~1));
26671         b_conv.is_owned = false;
26672         jboolean ret_val = NodeFeatures_eq(&a_conv, &b_conv);
26673         return ret_val;
26674 }
26675
26676 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
26677         LDKChannelFeatures a_conv;
26678         a_conv.inner = (void*)(a & (~1));
26679         a_conv.is_owned = false;
26680         LDKChannelFeatures b_conv;
26681         b_conv.inner = (void*)(b & (~1));
26682         b_conv.is_owned = false;
26683         jboolean ret_val = ChannelFeatures_eq(&a_conv, &b_conv);
26684         return ret_val;
26685 }
26686
26687 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
26688         LDKInvoiceFeatures a_conv;
26689         a_conv.inner = (void*)(a & (~1));
26690         a_conv.is_owned = false;
26691         LDKInvoiceFeatures b_conv;
26692         b_conv.inner = (void*)(b & (~1));
26693         b_conv.is_owned = false;
26694         jboolean ret_val = InvoiceFeatures_eq(&a_conv, &b_conv);
26695         return ret_val;
26696 }
26697
26698 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26699         LDKInitFeatures orig_conv;
26700         orig_conv.inner = (void*)(orig & (~1));
26701         orig_conv.is_owned = false;
26702         LDKInitFeatures ret_var = InitFeatures_clone(&orig_conv);
26703         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26704         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26705         uint64_t ret_ref = (uint64_t)ret_var.inner;
26706         if (ret_var.is_owned) {
26707                 ret_ref |= 1;
26708         }
26709         return ret_ref;
26710 }
26711
26712 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26713         LDKNodeFeatures orig_conv;
26714         orig_conv.inner = (void*)(orig & (~1));
26715         orig_conv.is_owned = false;
26716         LDKNodeFeatures ret_var = NodeFeatures_clone(&orig_conv);
26717         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26718         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26719         uint64_t ret_ref = (uint64_t)ret_var.inner;
26720         if (ret_var.is_owned) {
26721                 ret_ref |= 1;
26722         }
26723         return ret_ref;
26724 }
26725
26726 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26727         LDKChannelFeatures orig_conv;
26728         orig_conv.inner = (void*)(orig & (~1));
26729         orig_conv.is_owned = false;
26730         LDKChannelFeatures ret_var = ChannelFeatures_clone(&orig_conv);
26731         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26732         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26733         uint64_t ret_ref = (uint64_t)ret_var.inner;
26734         if (ret_var.is_owned) {
26735                 ret_ref |= 1;
26736         }
26737         return ret_ref;
26738 }
26739
26740 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26741         LDKInvoiceFeatures orig_conv;
26742         orig_conv.inner = (void*)(orig & (~1));
26743         orig_conv.is_owned = false;
26744         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(&orig_conv);
26745         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26746         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26747         uint64_t ret_ref = (uint64_t)ret_var.inner;
26748         if (ret_var.is_owned) {
26749                 ret_ref |= 1;
26750         }
26751         return ret_ref;
26752 }
26753
26754 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26755         LDKInitFeatures this_obj_conv;
26756         this_obj_conv.inner = (void*)(this_obj & (~1));
26757         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26758         InitFeatures_free(this_obj_conv);
26759 }
26760
26761 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26762         LDKNodeFeatures this_obj_conv;
26763         this_obj_conv.inner = (void*)(this_obj & (~1));
26764         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26765         NodeFeatures_free(this_obj_conv);
26766 }
26767
26768 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26769         LDKChannelFeatures this_obj_conv;
26770         this_obj_conv.inner = (void*)(this_obj & (~1));
26771         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26772         ChannelFeatures_free(this_obj_conv);
26773 }
26774
26775 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26776         LDKInvoiceFeatures this_obj_conv;
26777         this_obj_conv.inner = (void*)(this_obj & (~1));
26778         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26779         InvoiceFeatures_free(this_obj_conv);
26780 }
26781
26782 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1empty(JNIEnv *env, jclass clz) {
26783         LDKInitFeatures ret_var = InitFeatures_empty();
26784         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26785         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26786         uint64_t ret_ref = (uint64_t)ret_var.inner;
26787         if (ret_var.is_owned) {
26788                 ret_ref |= 1;
26789         }
26790         return ret_ref;
26791 }
26792
26793 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1known(JNIEnv *env, jclass clz) {
26794         LDKInitFeatures ret_var = InitFeatures_known();
26795         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26796         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26797         uint64_t ret_ref = (uint64_t)ret_var.inner;
26798         if (ret_var.is_owned) {
26799                 ret_ref |= 1;
26800         }
26801         return ret_ref;
26802 }
26803
26804 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
26805         LDKInitFeatures this_arg_conv;
26806         this_arg_conv.inner = (void*)(this_arg & (~1));
26807         this_arg_conv.is_owned = false;
26808         jboolean ret_val = InitFeatures_requires_unknown_bits(&this_arg_conv);
26809         return ret_val;
26810 }
26811
26812 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1empty(JNIEnv *env, jclass clz) {
26813         LDKNodeFeatures ret_var = NodeFeatures_empty();
26814         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26815         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26816         uint64_t ret_ref = (uint64_t)ret_var.inner;
26817         if (ret_var.is_owned) {
26818                 ret_ref |= 1;
26819         }
26820         return ret_ref;
26821 }
26822
26823 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1known(JNIEnv *env, jclass clz) {
26824         LDKNodeFeatures ret_var = NodeFeatures_known();
26825         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26826         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26827         uint64_t ret_ref = (uint64_t)ret_var.inner;
26828         if (ret_var.is_owned) {
26829                 ret_ref |= 1;
26830         }
26831         return ret_ref;
26832 }
26833
26834 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
26835         LDKNodeFeatures this_arg_conv;
26836         this_arg_conv.inner = (void*)(this_arg & (~1));
26837         this_arg_conv.is_owned = false;
26838         jboolean ret_val = NodeFeatures_requires_unknown_bits(&this_arg_conv);
26839         return ret_val;
26840 }
26841
26842 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1empty(JNIEnv *env, jclass clz) {
26843         LDKChannelFeatures ret_var = ChannelFeatures_empty();
26844         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26845         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26846         uint64_t ret_ref = (uint64_t)ret_var.inner;
26847         if (ret_var.is_owned) {
26848                 ret_ref |= 1;
26849         }
26850         return ret_ref;
26851 }
26852
26853 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1known(JNIEnv *env, jclass clz) {
26854         LDKChannelFeatures ret_var = ChannelFeatures_known();
26855         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26856         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26857         uint64_t ret_ref = (uint64_t)ret_var.inner;
26858         if (ret_var.is_owned) {
26859                 ret_ref |= 1;
26860         }
26861         return ret_ref;
26862 }
26863
26864 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
26865         LDKChannelFeatures this_arg_conv;
26866         this_arg_conv.inner = (void*)(this_arg & (~1));
26867         this_arg_conv.is_owned = false;
26868         jboolean ret_val = ChannelFeatures_requires_unknown_bits(&this_arg_conv);
26869         return ret_val;
26870 }
26871
26872 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1empty(JNIEnv *env, jclass clz) {
26873         LDKInvoiceFeatures ret_var = InvoiceFeatures_empty();
26874         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26875         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26876         uint64_t ret_ref = (uint64_t)ret_var.inner;
26877         if (ret_var.is_owned) {
26878                 ret_ref |= 1;
26879         }
26880         return ret_ref;
26881 }
26882
26883 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1known(JNIEnv *env, jclass clz) {
26884         LDKInvoiceFeatures ret_var = InvoiceFeatures_known();
26885         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26886         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26887         uint64_t ret_ref = (uint64_t)ret_var.inner;
26888         if (ret_var.is_owned) {
26889                 ret_ref |= 1;
26890         }
26891         return ret_ref;
26892 }
26893
26894 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
26895         LDKInvoiceFeatures this_arg_conv;
26896         this_arg_conv.inner = (void*)(this_arg & (~1));
26897         this_arg_conv.is_owned = false;
26898         jboolean ret_val = InvoiceFeatures_requires_unknown_bits(&this_arg_conv);
26899         return ret_val;
26900 }
26901
26902 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
26903         LDKInitFeatures this_arg_conv;
26904         this_arg_conv.inner = (void*)(this_arg & (~1));
26905         this_arg_conv.is_owned = false;
26906         jboolean ret_val = InitFeatures_supports_payment_secret(&this_arg_conv);
26907         return ret_val;
26908 }
26909
26910 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
26911         LDKNodeFeatures this_arg_conv;
26912         this_arg_conv.inner = (void*)(this_arg & (~1));
26913         this_arg_conv.is_owned = false;
26914         jboolean ret_val = NodeFeatures_supports_payment_secret(&this_arg_conv);
26915         return ret_val;
26916 }
26917
26918 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1supports_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
26919         LDKInvoiceFeatures this_arg_conv;
26920         this_arg_conv.inner = (void*)(this_arg & (~1));
26921         this_arg_conv.is_owned = false;
26922         jboolean ret_val = InvoiceFeatures_supports_payment_secret(&this_arg_conv);
26923         return ret_val;
26924 }
26925
26926 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InitFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
26927         LDKInitFeatures obj_conv;
26928         obj_conv.inner = (void*)(obj & (~1));
26929         obj_conv.is_owned = false;
26930         LDKCVec_u8Z ret_var = InitFeatures_write(&obj_conv);
26931         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26932         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26933         CVec_u8Z_free(ret_var);
26934         return ret_arr;
26935 }
26936
26937 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
26938         LDKNodeFeatures obj_conv;
26939         obj_conv.inner = (void*)(obj & (~1));
26940         obj_conv.is_owned = false;
26941         LDKCVec_u8Z ret_var = NodeFeatures_write(&obj_conv);
26942         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26943         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26944         CVec_u8Z_free(ret_var);
26945         return ret_arr;
26946 }
26947
26948 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
26949         LDKChannelFeatures obj_conv;
26950         obj_conv.inner = (void*)(obj & (~1));
26951         obj_conv.is_owned = false;
26952         LDKCVec_u8Z ret_var = ChannelFeatures_write(&obj_conv);
26953         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26954         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26955         CVec_u8Z_free(ret_var);
26956         return ret_arr;
26957 }
26958
26959 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
26960         LDKInvoiceFeatures obj_conv;
26961         obj_conv.inner = (void*)(obj & (~1));
26962         obj_conv.is_owned = false;
26963         LDKCVec_u8Z ret_var = InvoiceFeatures_write(&obj_conv);
26964         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26965         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26966         CVec_u8Z_free(ret_var);
26967         return ret_arr;
26968 }
26969
26970 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
26971         LDKu8slice ser_ref;
26972         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
26973         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
26974         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
26975         *ret_conv = InitFeatures_read(ser_ref);
26976         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
26977         return (uint64_t)ret_conv;
26978 }
26979
26980 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
26981         LDKu8slice ser_ref;
26982         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
26983         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
26984         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
26985         *ret_conv = NodeFeatures_read(ser_ref);
26986         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
26987         return (uint64_t)ret_conv;
26988 }
26989
26990 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
26991         LDKu8slice ser_ref;
26992         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
26993         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
26994         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
26995         *ret_conv = ChannelFeatures_read(ser_ref);
26996         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
26997         return (uint64_t)ret_conv;
26998 }
26999
27000 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
27001         LDKu8slice ser_ref;
27002         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
27003         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
27004         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
27005         *ret_conv = InvoiceFeatures_read(ser_ref);
27006         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
27007         return (uint64_t)ret_conv;
27008 }
27009
27010 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27011         LDKShutdownScript this_obj_conv;
27012         this_obj_conv.inner = (void*)(this_obj & (~1));
27013         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27014         ShutdownScript_free(this_obj_conv);
27015 }
27016
27017 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27018         LDKShutdownScript orig_conv;
27019         orig_conv.inner = (void*)(orig & (~1));
27020         orig_conv.is_owned = false;
27021         LDKShutdownScript ret_var = ShutdownScript_clone(&orig_conv);
27022         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27023         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27024         uint64_t ret_ref = (uint64_t)ret_var.inner;
27025         if (ret_var.is_owned) {
27026                 ret_ref |= 1;
27027         }
27028         return ret_ref;
27029 }
27030
27031 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27032         LDKInvalidShutdownScript this_obj_conv;
27033         this_obj_conv.inner = (void*)(this_obj & (~1));
27034         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27035         InvalidShutdownScript_free(this_obj_conv);
27036 }
27037
27038 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1get_1script(JNIEnv *env, jclass clz, int64_t this_ptr) {
27039         LDKInvalidShutdownScript this_ptr_conv;
27040         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27041         this_ptr_conv.is_owned = false;
27042         LDKu8slice ret_var = InvalidShutdownScript_get_script(&this_ptr_conv);
27043         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
27044         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
27045         return ret_arr;
27046 }
27047
27048 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1set_1script(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
27049         LDKInvalidShutdownScript this_ptr_conv;
27050         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27051         this_ptr_conv.is_owned = false;
27052         LDKCVec_u8Z val_ref;
27053         val_ref.datalen = (*env)->GetArrayLength(env, val);
27054         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
27055         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
27056         InvalidShutdownScript_set_script(&this_ptr_conv, val_ref);
27057 }
27058
27059 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1new(JNIEnv *env, jclass clz, int8_tArray script_arg) {
27060         LDKCVec_u8Z script_arg_ref;
27061         script_arg_ref.datalen = (*env)->GetArrayLength(env, script_arg);
27062         script_arg_ref.data = MALLOC(script_arg_ref.datalen, "LDKCVec_u8Z Bytes");
27063         (*env)->GetByteArrayRegion(env, script_arg, 0, script_arg_ref.datalen, script_arg_ref.data);
27064         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_new(script_arg_ref);
27065         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27066         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27067         uint64_t ret_ref = (uint64_t)ret_var.inner;
27068         if (ret_var.is_owned) {
27069                 ret_ref |= 1;
27070         }
27071         return ret_ref;
27072 }
27073
27074 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1write(JNIEnv *env, jclass clz, int64_t obj) {
27075         LDKShutdownScript obj_conv;
27076         obj_conv.inner = (void*)(obj & (~1));
27077         obj_conv.is_owned = false;
27078         LDKCVec_u8Z ret_var = ShutdownScript_write(&obj_conv);
27079         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
27080         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
27081         CVec_u8Z_free(ret_var);
27082         return ret_arr;
27083 }
27084
27085 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
27086         LDKu8slice ser_ref;
27087         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
27088         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
27089         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
27090         *ret_conv = ShutdownScript_read(ser_ref);
27091         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
27092         return (uint64_t)ret_conv;
27093 }
27094
27095 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1new_1p2wpkh(JNIEnv *env, jclass clz, int8_tArray pubkey_hash) {
27096         unsigned char pubkey_hash_arr[20];
27097         CHECK((*env)->GetArrayLength(env, pubkey_hash) == 20);
27098         (*env)->GetByteArrayRegion(env, pubkey_hash, 0, 20, pubkey_hash_arr);
27099         unsigned char (*pubkey_hash_ref)[20] = &pubkey_hash_arr;
27100         LDKShutdownScript ret_var = ShutdownScript_new_p2wpkh(pubkey_hash_ref);
27101         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27102         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27103         uint64_t ret_ref = (uint64_t)ret_var.inner;
27104         if (ret_var.is_owned) {
27105                 ret_ref |= 1;
27106         }
27107         return ret_ref;
27108 }
27109
27110 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1new_1p2wsh(JNIEnv *env, jclass clz, int8_tArray script_hash) {
27111         unsigned char script_hash_arr[32];
27112         CHECK((*env)->GetArrayLength(env, script_hash) == 32);
27113         (*env)->GetByteArrayRegion(env, script_hash, 0, 32, script_hash_arr);
27114         unsigned char (*script_hash_ref)[32] = &script_hash_arr;
27115         LDKShutdownScript ret_var = ShutdownScript_new_p2wsh(script_hash_ref);
27116         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27117         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27118         uint64_t ret_ref = (uint64_t)ret_var.inner;
27119         if (ret_var.is_owned) {
27120                 ret_ref |= 1;
27121         }
27122         return ret_ref;
27123 }
27124
27125 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1new_1witness_1program(JNIEnv *env, jclass clz, int8_t version, int8_tArray program) {
27126         LDKu8slice program_ref;
27127         program_ref.datalen = (*env)->GetArrayLength(env, program);
27128         program_ref.data = (*env)->GetByteArrayElements (env, program, NULL);
27129         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
27130         *ret_conv = ShutdownScript_new_witness_program(version, program_ref);
27131         (*env)->ReleaseByteArrayElements(env, program, (int8_t*)program_ref.data, 0);
27132         return (uint64_t)ret_conv;
27133 }
27134
27135 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1into_1inner(JNIEnv *env, jclass clz, int64_t this_arg) {
27136         LDKShutdownScript this_arg_conv;
27137         this_arg_conv.inner = (void*)(this_arg & (~1));
27138         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
27139         this_arg_conv = ShutdownScript_clone(&this_arg_conv);
27140         LDKCVec_u8Z ret_var = ShutdownScript_into_inner(this_arg_conv);
27141         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
27142         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
27143         CVec_u8Z_free(ret_var);
27144         return ret_arr;
27145 }
27146
27147 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1as_1legacy_1pubkey(JNIEnv *env, jclass clz, int64_t this_arg) {
27148         LDKShutdownScript this_arg_conv;
27149         this_arg_conv.inner = (void*)(this_arg & (~1));
27150         this_arg_conv.is_owned = false;
27151         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
27152         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ShutdownScript_as_legacy_pubkey(&this_arg_conv).compressed_form);
27153         return ret_arr;
27154 }
27155
27156 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1is_1compatible(JNIEnv *env, jclass clz, int64_t this_arg, int64_t features) {
27157         LDKShutdownScript this_arg_conv;
27158         this_arg_conv.inner = (void*)(this_arg & (~1));
27159         this_arg_conv.is_owned = false;
27160         LDKInitFeatures features_conv;
27161         features_conv.inner = (void*)(features & (~1));
27162         features_conv.is_owned = false;
27163         jboolean ret_val = ShutdownScript_is_compatible(&this_arg_conv, &features_conv);
27164         return ret_val;
27165 }
27166
27167 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CustomMessageReader_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
27168         if ((this_ptr & 1) != 0) return;
27169         LDKCustomMessageReader this_ptr_conv = *(LDKCustomMessageReader*)(((uint64_t)this_ptr) & ~1);
27170         FREE((void*)this_ptr);
27171         CustomMessageReader_free(this_ptr_conv);
27172 }
27173
27174 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Type_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27175         LDKType* orig_conv = (LDKType*)(((uint64_t)orig) & ~1);
27176         LDKType* ret_ret =MALLOC(sizeof(LDKType), "LDKType");
27177         *ret_ret = Type_clone(orig_conv);
27178         return (uint64_t)ret_ret;
27179 }
27180
27181 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Type_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
27182         if ((this_ptr & 1) != 0) return;
27183         LDKType this_ptr_conv = *(LDKType*)(((uint64_t)this_ptr) & ~1);
27184         FREE((void*)this_ptr);
27185         Type_free(this_ptr_conv);
27186 }
27187
27188 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Score_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
27189         if ((this_ptr & 1) != 0) return;
27190         LDKScore this_ptr_conv = *(LDKScore*)(((uint64_t)this_ptr) & ~1);
27191         FREE((void*)this_ptr);
27192         Score_free(this_ptr_conv);
27193 }
27194
27195 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeId_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27196         LDKNodeId this_obj_conv;
27197         this_obj_conv.inner = (void*)(this_obj & (~1));
27198         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27199         NodeId_free(this_obj_conv);
27200 }
27201
27202 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27203         LDKNodeId orig_conv;
27204         orig_conv.inner = (void*)(orig & (~1));
27205         orig_conv.is_owned = false;
27206         LDKNodeId ret_var = NodeId_clone(&orig_conv);
27207         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27208         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27209         uint64_t ret_ref = (uint64_t)ret_var.inner;
27210         if (ret_var.is_owned) {
27211                 ret_ref |= 1;
27212         }
27213         return ret_ref;
27214 }
27215
27216 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1from_1pubkey(JNIEnv *env, jclass clz, int8_tArray pubkey) {
27217         LDKPublicKey pubkey_ref;
27218         CHECK((*env)->GetArrayLength(env, pubkey) == 33);
27219         (*env)->GetByteArrayRegion(env, pubkey, 0, 33, pubkey_ref.compressed_form);
27220         LDKNodeId ret_var = NodeId_from_pubkey(pubkey_ref);
27221         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27222         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27223         uint64_t ret_ref = (uint64_t)ret_var.inner;
27224         if (ret_var.is_owned) {
27225                 ret_ref |= 1;
27226         }
27227         return ret_ref;
27228 }
27229
27230 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeId_1as_1slice(JNIEnv *env, jclass clz, int64_t this_arg) {
27231         LDKNodeId this_arg_conv;
27232         this_arg_conv.inner = (void*)(this_arg & (~1));
27233         this_arg_conv.is_owned = false;
27234         LDKu8slice ret_var = NodeId_as_slice(&this_arg_conv);
27235         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
27236         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
27237         return ret_arr;
27238 }
27239
27240 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1hash(JNIEnv *env, jclass clz, int64_t o) {
27241         LDKNodeId o_conv;
27242         o_conv.inner = (void*)(o & (~1));
27243         o_conv.is_owned = false;
27244         int64_t ret_val = NodeId_hash(&o_conv);
27245         return ret_val;
27246 }
27247
27248 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeId_1write(JNIEnv *env, jclass clz, int64_t obj) {
27249         LDKNodeId obj_conv;
27250         obj_conv.inner = (void*)(obj & (~1));
27251         obj_conv.is_owned = false;
27252         LDKCVec_u8Z ret_var = NodeId_write(&obj_conv);
27253         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
27254         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
27255         CVec_u8Z_free(ret_var);
27256         return ret_arr;
27257 }
27258
27259 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
27260         LDKu8slice ser_ref;
27261         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
27262         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
27263         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
27264         *ret_conv = NodeId_read(ser_ref);
27265         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
27266         return (uint64_t)ret_conv;
27267 }
27268
27269 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27270         LDKNetworkGraph this_obj_conv;
27271         this_obj_conv.inner = (void*)(this_obj & (~1));
27272         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27273         NetworkGraph_free(this_obj_conv);
27274 }
27275
27276 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27277         LDKNetworkGraph orig_conv;
27278         orig_conv.inner = (void*)(orig & (~1));
27279         orig_conv.is_owned = false;
27280         LDKNetworkGraph ret_var = NetworkGraph_clone(&orig_conv);
27281         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27282         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27283         uint64_t ret_ref = (uint64_t)ret_var.inner;
27284         if (ret_var.is_owned) {
27285                 ret_ref |= 1;
27286         }
27287         return ret_ref;
27288 }
27289
27290 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReadOnlyNetworkGraph_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27291         LDKReadOnlyNetworkGraph this_obj_conv;
27292         this_obj_conv.inner = (void*)(this_obj & (~1));
27293         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27294         ReadOnlyNetworkGraph_free(this_obj_conv);
27295 }
27296
27297 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
27298         if ((this_ptr & 1) != 0) return;
27299         LDKNetworkUpdate this_ptr_conv = *(LDKNetworkUpdate*)(((uint64_t)this_ptr) & ~1);
27300         FREE((void*)this_ptr);
27301         NetworkUpdate_free(this_ptr_conv);
27302 }
27303
27304 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27305         LDKNetworkUpdate* orig_conv = (LDKNetworkUpdate*)orig;
27306         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
27307         *ret_copy = NetworkUpdate_clone(orig_conv);
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_1channel_1update_1message(JNIEnv *env, jclass clz, int64_t msg) {
27313         LDKChannelUpdate msg_conv;
27314         msg_conv.inner = (void*)(msg & (~1));
27315         msg_conv.is_owned = (msg & 1) || (msg == 0);
27316         msg_conv = ChannelUpdate_clone(&msg_conv);
27317         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
27318         *ret_copy = NetworkUpdate_channel_update_message(msg_conv);
27319         uint64_t ret_ref = (uint64_t)ret_copy;
27320         return ret_ref;
27321 }
27322
27323 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1channel_1closed(JNIEnv *env, jclass clz, int64_t short_channel_id, jboolean is_permanent) {
27324         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
27325         *ret_copy = NetworkUpdate_channel_closed(short_channel_id, is_permanent);
27326         uint64_t ret_ref = (uint64_t)ret_copy;
27327         return ret_ref;
27328 }
27329
27330 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1node_1failure(JNIEnv *env, jclass clz, int8_tArray node_id, jboolean is_permanent) {
27331         LDKPublicKey node_id_ref;
27332         CHECK((*env)->GetArrayLength(env, node_id) == 33);
27333         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
27334         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
27335         *ret_copy = NetworkUpdate_node_failure(node_id_ref, is_permanent);
27336         uint64_t ret_ref = (uint64_t)ret_copy;
27337         return ret_ref;
27338 }
27339
27340 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
27341         LDKNetworkUpdate* obj_conv = (LDKNetworkUpdate*)obj;
27342         LDKCVec_u8Z ret_var = NetworkUpdate_write(obj_conv);
27343         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
27344         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
27345         CVec_u8Z_free(ret_var);
27346         return ret_arr;
27347 }
27348
27349 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1as_1EventHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
27350         LDKNetGraphMsgHandler this_arg_conv;
27351         this_arg_conv.inner = (void*)(this_arg & (~1));
27352         this_arg_conv.is_owned = false;
27353         LDKEventHandler* ret_ret =MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
27354         *ret_ret = NetGraphMsgHandler_as_EventHandler(&this_arg_conv);
27355         return (uint64_t)ret_ret;
27356 }
27357
27358 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27359         LDKNetGraphMsgHandler this_obj_conv;
27360         this_obj_conv.inner = (void*)(this_obj & (~1));
27361         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27362         NetGraphMsgHandler_free(this_obj_conv);
27363 }
27364
27365 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1get_1network_1graph(JNIEnv *env, jclass clz, int64_t this_ptr) {
27366         LDKNetGraphMsgHandler this_ptr_conv;
27367         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27368         this_ptr_conv.is_owned = false;
27369         LDKNetworkGraph ret_var = NetGraphMsgHandler_get_network_graph(&this_ptr_conv);
27370         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27371         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27372         uint64_t ret_ref = (uint64_t)ret_var.inner;
27373         if (ret_var.is_owned) {
27374                 ret_ref |= 1;
27375         }
27376         return ret_ref;
27377 }
27378
27379 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1set_1network_1graph(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27380         LDKNetGraphMsgHandler this_ptr_conv;
27381         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27382         this_ptr_conv.is_owned = false;
27383         LDKNetworkGraph val_conv;
27384         val_conv.inner = (void*)(val & (~1));
27385         val_conv.is_owned = (val & 1) || (val == 0);
27386         val_conv = NetworkGraph_clone(&val_conv);
27387         NetGraphMsgHandler_set_network_graph(&this_ptr_conv, val_conv);
27388 }
27389
27390 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) {
27391         LDKNetworkGraph network_graph_conv;
27392         network_graph_conv.inner = (void*)(network_graph & (~1));
27393         network_graph_conv.is_owned = (network_graph & 1) || (network_graph == 0);
27394         network_graph_conv = NetworkGraph_clone(&network_graph_conv);
27395         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(((uint64_t)chain_access) & ~1);
27396         // Warning: we may need a move here but no clone is available for LDKCOption_AccessZ
27397         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
27398                 // Manually implement clone for Java trait instances
27399                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
27400                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27401                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
27402                 }
27403         }
27404         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
27405         if (logger_conv.free == LDKLogger_JCalls_free) {
27406                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27407                 LDKLogger_JCalls_cloned(&logger_conv);
27408         }
27409         LDKNetGraphMsgHandler ret_var = NetGraphMsgHandler_new(network_graph_conv, chain_access_conv, logger_conv);
27410         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27411         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27412         uint64_t ret_ref = (uint64_t)ret_var.inner;
27413         if (ret_var.is_owned) {
27414                 ret_ref |= 1;
27415         }
27416         return ret_ref;
27417 }
27418
27419 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1add_1chain_1access(JNIEnv *env, jclass clz, int64_t this_arg, int64_t chain_access) {
27420         LDKNetGraphMsgHandler this_arg_conv;
27421         this_arg_conv.inner = (void*)(this_arg & (~1));
27422         this_arg_conv.is_owned = false;
27423         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(((uint64_t)chain_access) & ~1);
27424         // Warning: we may need a move here but no clone is available for LDKCOption_AccessZ
27425         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
27426                 // Manually implement clone for Java trait instances
27427                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
27428                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27429                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
27430                 }
27431         }
27432         NetGraphMsgHandler_add_chain_access(&this_arg_conv, chain_access_conv);
27433 }
27434
27435 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1as_1RoutingMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
27436         LDKNetGraphMsgHandler this_arg_conv;
27437         this_arg_conv.inner = (void*)(this_arg & (~1));
27438         this_arg_conv.is_owned = false;
27439         LDKRoutingMessageHandler* ret_ret =MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
27440         *ret_ret = NetGraphMsgHandler_as_RoutingMessageHandler(&this_arg_conv);
27441         return (uint64_t)ret_ret;
27442 }
27443
27444 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
27445         LDKNetGraphMsgHandler this_arg_conv;
27446         this_arg_conv.inner = (void*)(this_arg & (~1));
27447         this_arg_conv.is_owned = false;
27448         LDKMessageSendEventsProvider* ret_ret =MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
27449         *ret_ret = NetGraphMsgHandler_as_MessageSendEventsProvider(&this_arg_conv);
27450         return (uint64_t)ret_ret;
27451 }
27452
27453 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27454         LDKDirectionalChannelInfo this_obj_conv;
27455         this_obj_conv.inner = (void*)(this_obj & (~1));
27456         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27457         DirectionalChannelInfo_free(this_obj_conv);
27458 }
27459
27460 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr) {
27461         LDKDirectionalChannelInfo this_ptr_conv;
27462         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27463         this_ptr_conv.is_owned = false;
27464         int32_t ret_val = DirectionalChannelInfo_get_last_update(&this_ptr_conv);
27465         return ret_val;
27466 }
27467
27468 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
27469         LDKDirectionalChannelInfo this_ptr_conv;
27470         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27471         this_ptr_conv.is_owned = false;
27472         DirectionalChannelInfo_set_last_update(&this_ptr_conv, val);
27473 }
27474
27475 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1enabled(JNIEnv *env, jclass clz, int64_t this_ptr) {
27476         LDKDirectionalChannelInfo this_ptr_conv;
27477         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27478         this_ptr_conv.is_owned = false;
27479         jboolean ret_val = DirectionalChannelInfo_get_enabled(&this_ptr_conv);
27480         return ret_val;
27481 }
27482
27483 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1enabled(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
27484         LDKDirectionalChannelInfo this_ptr_conv;
27485         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27486         this_ptr_conv.is_owned = false;
27487         DirectionalChannelInfo_set_enabled(&this_ptr_conv, val);
27488 }
27489
27490 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
27491         LDKDirectionalChannelInfo this_ptr_conv;
27492         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27493         this_ptr_conv.is_owned = false;
27494         int16_t ret_val = DirectionalChannelInfo_get_cltv_expiry_delta(&this_ptr_conv);
27495         return ret_val;
27496 }
27497
27498 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
27499         LDKDirectionalChannelInfo this_ptr_conv;
27500         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27501         this_ptr_conv.is_owned = false;
27502         DirectionalChannelInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
27503 }
27504
27505 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
27506         LDKDirectionalChannelInfo this_ptr_conv;
27507         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27508         this_ptr_conv.is_owned = false;
27509         int64_t ret_val = DirectionalChannelInfo_get_htlc_minimum_msat(&this_ptr_conv);
27510         return ret_val;
27511 }
27512
27513 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27514         LDKDirectionalChannelInfo this_ptr_conv;
27515         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27516         this_ptr_conv.is_owned = false;
27517         DirectionalChannelInfo_set_htlc_minimum_msat(&this_ptr_conv, val);
27518 }
27519
27520 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
27521         LDKDirectionalChannelInfo this_ptr_conv;
27522         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27523         this_ptr_conv.is_owned = false;
27524         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
27525         *ret_copy = DirectionalChannelInfo_get_htlc_maximum_msat(&this_ptr_conv);
27526         uint64_t ret_ref = (uint64_t)ret_copy;
27527         return ret_ref;
27528 }
27529
27530 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27531         LDKDirectionalChannelInfo this_ptr_conv;
27532         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27533         this_ptr_conv.is_owned = false;
27534         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
27535         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1));
27536         DirectionalChannelInfo_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
27537 }
27538
27539 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
27540         LDKDirectionalChannelInfo this_ptr_conv;
27541         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27542         this_ptr_conv.is_owned = false;
27543         LDKRoutingFees ret_var = DirectionalChannelInfo_get_fees(&this_ptr_conv);
27544         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27545         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27546         uint64_t ret_ref = (uint64_t)ret_var.inner;
27547         if (ret_var.is_owned) {
27548                 ret_ref |= 1;
27549         }
27550         return ret_ref;
27551 }
27552
27553 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1fees(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27554         LDKDirectionalChannelInfo this_ptr_conv;
27555         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27556         this_ptr_conv.is_owned = false;
27557         LDKRoutingFees val_conv;
27558         val_conv.inner = (void*)(val & (~1));
27559         val_conv.is_owned = (val & 1) || (val == 0);
27560         val_conv = RoutingFees_clone(&val_conv);
27561         DirectionalChannelInfo_set_fees(&this_ptr_conv, val_conv);
27562 }
27563
27564 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1last_1update_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
27565         LDKDirectionalChannelInfo this_ptr_conv;
27566         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27567         this_ptr_conv.is_owned = false;
27568         LDKChannelUpdate ret_var = DirectionalChannelInfo_get_last_update_message(&this_ptr_conv);
27569         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27570         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27571         uint64_t ret_ref = (uint64_t)ret_var.inner;
27572         if (ret_var.is_owned) {
27573                 ret_ref |= 1;
27574         }
27575         return ret_ref;
27576 }
27577
27578 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1last_1update_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27579         LDKDirectionalChannelInfo this_ptr_conv;
27580         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27581         this_ptr_conv.is_owned = false;
27582         LDKChannelUpdate val_conv;
27583         val_conv.inner = (void*)(val & (~1));
27584         val_conv.is_owned = (val & 1) || (val == 0);
27585         val_conv = ChannelUpdate_clone(&val_conv);
27586         DirectionalChannelInfo_set_last_update_message(&this_ptr_conv, val_conv);
27587 }
27588
27589 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) {
27590         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)htlc_maximum_msat_arg) & ~1);
27591         htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)htlc_maximum_msat_arg) & ~1));
27592         LDKRoutingFees fees_arg_conv;
27593         fees_arg_conv.inner = (void*)(fees_arg & (~1));
27594         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
27595         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
27596         LDKChannelUpdate last_update_message_arg_conv;
27597         last_update_message_arg_conv.inner = (void*)(last_update_message_arg & (~1));
27598         last_update_message_arg_conv.is_owned = (last_update_message_arg & 1) || (last_update_message_arg == 0);
27599         last_update_message_arg_conv = ChannelUpdate_clone(&last_update_message_arg_conv);
27600         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);
27601         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27602         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27603         uint64_t ret_ref = (uint64_t)ret_var.inner;
27604         if (ret_var.is_owned) {
27605                 ret_ref |= 1;
27606         }
27607         return ret_ref;
27608 }
27609
27610 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27611         LDKDirectionalChannelInfo orig_conv;
27612         orig_conv.inner = (void*)(orig & (~1));
27613         orig_conv.is_owned = false;
27614         LDKDirectionalChannelInfo ret_var = DirectionalChannelInfo_clone(&orig_conv);
27615         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27616         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27617         uint64_t ret_ref = (uint64_t)ret_var.inner;
27618         if (ret_var.is_owned) {
27619                 ret_ref |= 1;
27620         }
27621         return ret_ref;
27622 }
27623
27624 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
27625         LDKDirectionalChannelInfo obj_conv;
27626         obj_conv.inner = (void*)(obj & (~1));
27627         obj_conv.is_owned = false;
27628         LDKCVec_u8Z ret_var = DirectionalChannelInfo_write(&obj_conv);
27629         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
27630         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
27631         CVec_u8Z_free(ret_var);
27632         return ret_arr;
27633 }
27634
27635 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
27636         LDKu8slice ser_ref;
27637         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
27638         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
27639         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
27640         *ret_conv = DirectionalChannelInfo_read(ser_ref);
27641         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
27642         return (uint64_t)ret_conv;
27643 }
27644
27645 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27646         LDKChannelInfo this_obj_conv;
27647         this_obj_conv.inner = (void*)(this_obj & (~1));
27648         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27649         ChannelInfo_free(this_obj_conv);
27650 }
27651
27652 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
27653         LDKChannelInfo this_ptr_conv;
27654         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27655         this_ptr_conv.is_owned = false;
27656         LDKChannelFeatures ret_var = ChannelInfo_get_features(&this_ptr_conv);
27657         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27658         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27659         uint64_t ret_ref = (uint64_t)ret_var.inner;
27660         if (ret_var.is_owned) {
27661                 ret_ref |= 1;
27662         }
27663         return ret_ref;
27664 }
27665
27666 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27667         LDKChannelInfo this_ptr_conv;
27668         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27669         this_ptr_conv.is_owned = false;
27670         LDKChannelFeatures val_conv;
27671         val_conv.inner = (void*)(val & (~1));
27672         val_conv.is_owned = (val & 1) || (val == 0);
27673         val_conv = ChannelFeatures_clone(&val_conv);
27674         ChannelInfo_set_features(&this_ptr_conv, val_conv);
27675 }
27676
27677 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1node_1one(JNIEnv *env, jclass clz, int64_t this_ptr) {
27678         LDKChannelInfo this_ptr_conv;
27679         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27680         this_ptr_conv.is_owned = false;
27681         LDKNodeId ret_var = ChannelInfo_get_node_one(&this_ptr_conv);
27682         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27683         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27684         uint64_t ret_ref = (uint64_t)ret_var.inner;
27685         if (ret_var.is_owned) {
27686                 ret_ref |= 1;
27687         }
27688         return ret_ref;
27689 }
27690
27691 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1node_1one(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27692         LDKChannelInfo this_ptr_conv;
27693         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27694         this_ptr_conv.is_owned = false;
27695         LDKNodeId val_conv;
27696         val_conv.inner = (void*)(val & (~1));
27697         val_conv.is_owned = (val & 1) || (val == 0);
27698         val_conv = NodeId_clone(&val_conv);
27699         ChannelInfo_set_node_one(&this_ptr_conv, val_conv);
27700 }
27701
27702 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1one_1to_1two(JNIEnv *env, jclass clz, int64_t this_ptr) {
27703         LDKChannelInfo this_ptr_conv;
27704         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27705         this_ptr_conv.is_owned = false;
27706         LDKDirectionalChannelInfo ret_var = ChannelInfo_get_one_to_two(&this_ptr_conv);
27707         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27708         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27709         uint64_t ret_ref = (uint64_t)ret_var.inner;
27710         if (ret_var.is_owned) {
27711                 ret_ref |= 1;
27712         }
27713         return ret_ref;
27714 }
27715
27716 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1one_1to_1two(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27717         LDKChannelInfo this_ptr_conv;
27718         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27719         this_ptr_conv.is_owned = false;
27720         LDKDirectionalChannelInfo val_conv;
27721         val_conv.inner = (void*)(val & (~1));
27722         val_conv.is_owned = (val & 1) || (val == 0);
27723         val_conv = DirectionalChannelInfo_clone(&val_conv);
27724         ChannelInfo_set_one_to_two(&this_ptr_conv, val_conv);
27725 }
27726
27727 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1node_1two(JNIEnv *env, jclass clz, int64_t this_ptr) {
27728         LDKChannelInfo this_ptr_conv;
27729         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27730         this_ptr_conv.is_owned = false;
27731         LDKNodeId ret_var = ChannelInfo_get_node_two(&this_ptr_conv);
27732         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27733         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27734         uint64_t ret_ref = (uint64_t)ret_var.inner;
27735         if (ret_var.is_owned) {
27736                 ret_ref |= 1;
27737         }
27738         return ret_ref;
27739 }
27740
27741 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1node_1two(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27742         LDKChannelInfo this_ptr_conv;
27743         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27744         this_ptr_conv.is_owned = false;
27745         LDKNodeId val_conv;
27746         val_conv.inner = (void*)(val & (~1));
27747         val_conv.is_owned = (val & 1) || (val == 0);
27748         val_conv = NodeId_clone(&val_conv);
27749         ChannelInfo_set_node_two(&this_ptr_conv, val_conv);
27750 }
27751
27752 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1two_1to_1one(JNIEnv *env, jclass clz, int64_t this_ptr) {
27753         LDKChannelInfo this_ptr_conv;
27754         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27755         this_ptr_conv.is_owned = false;
27756         LDKDirectionalChannelInfo ret_var = ChannelInfo_get_two_to_one(&this_ptr_conv);
27757         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27758         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27759         uint64_t ret_ref = (uint64_t)ret_var.inner;
27760         if (ret_var.is_owned) {
27761                 ret_ref |= 1;
27762         }
27763         return ret_ref;
27764 }
27765
27766 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1two_1to_1one(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27767         LDKChannelInfo this_ptr_conv;
27768         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27769         this_ptr_conv.is_owned = false;
27770         LDKDirectionalChannelInfo val_conv;
27771         val_conv.inner = (void*)(val & (~1));
27772         val_conv.is_owned = (val & 1) || (val == 0);
27773         val_conv = DirectionalChannelInfo_clone(&val_conv);
27774         ChannelInfo_set_two_to_one(&this_ptr_conv, val_conv);
27775 }
27776
27777 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1capacity_1sats(JNIEnv *env, jclass clz, int64_t this_ptr) {
27778         LDKChannelInfo this_ptr_conv;
27779         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27780         this_ptr_conv.is_owned = false;
27781         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
27782         *ret_copy = ChannelInfo_get_capacity_sats(&this_ptr_conv);
27783         uint64_t ret_ref = (uint64_t)ret_copy;
27784         return ret_ref;
27785 }
27786
27787 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1capacity_1sats(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27788         LDKChannelInfo this_ptr_conv;
27789         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27790         this_ptr_conv.is_owned = false;
27791         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
27792         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1));
27793         ChannelInfo_set_capacity_sats(&this_ptr_conv, val_conv);
27794 }
27795
27796 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
27797         LDKChannelInfo this_ptr_conv;
27798         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27799         this_ptr_conv.is_owned = false;
27800         LDKChannelAnnouncement ret_var = ChannelInfo_get_announcement_message(&this_ptr_conv);
27801         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27802         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27803         uint64_t ret_ref = (uint64_t)ret_var.inner;
27804         if (ret_var.is_owned) {
27805                 ret_ref |= 1;
27806         }
27807         return ret_ref;
27808 }
27809
27810 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27811         LDKChannelInfo this_ptr_conv;
27812         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27813         this_ptr_conv.is_owned = false;
27814         LDKChannelAnnouncement val_conv;
27815         val_conv.inner = (void*)(val & (~1));
27816         val_conv.is_owned = (val & 1) || (val == 0);
27817         val_conv = ChannelAnnouncement_clone(&val_conv);
27818         ChannelInfo_set_announcement_message(&this_ptr_conv, val_conv);
27819 }
27820
27821 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1new(JNIEnv *env, jclass clz, int64_t features_arg, int64_t node_one_arg, int64_t one_to_two_arg, int64_t node_two_arg, int64_t two_to_one_arg, int64_t capacity_sats_arg, int64_t announcement_message_arg) {
27822         LDKChannelFeatures features_arg_conv;
27823         features_arg_conv.inner = (void*)(features_arg & (~1));
27824         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
27825         features_arg_conv = ChannelFeatures_clone(&features_arg_conv);
27826         LDKNodeId node_one_arg_conv;
27827         node_one_arg_conv.inner = (void*)(node_one_arg & (~1));
27828         node_one_arg_conv.is_owned = (node_one_arg & 1) || (node_one_arg == 0);
27829         node_one_arg_conv = NodeId_clone(&node_one_arg_conv);
27830         LDKDirectionalChannelInfo one_to_two_arg_conv;
27831         one_to_two_arg_conv.inner = (void*)(one_to_two_arg & (~1));
27832         one_to_two_arg_conv.is_owned = (one_to_two_arg & 1) || (one_to_two_arg == 0);
27833         one_to_two_arg_conv = DirectionalChannelInfo_clone(&one_to_two_arg_conv);
27834         LDKNodeId node_two_arg_conv;
27835         node_two_arg_conv.inner = (void*)(node_two_arg & (~1));
27836         node_two_arg_conv.is_owned = (node_two_arg & 1) || (node_two_arg == 0);
27837         node_two_arg_conv = NodeId_clone(&node_two_arg_conv);
27838         LDKDirectionalChannelInfo two_to_one_arg_conv;
27839         two_to_one_arg_conv.inner = (void*)(two_to_one_arg & (~1));
27840         two_to_one_arg_conv.is_owned = (two_to_one_arg & 1) || (two_to_one_arg == 0);
27841         two_to_one_arg_conv = DirectionalChannelInfo_clone(&two_to_one_arg_conv);
27842         LDKCOption_u64Z capacity_sats_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)capacity_sats_arg) & ~1);
27843         capacity_sats_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)capacity_sats_arg) & ~1));
27844         LDKChannelAnnouncement announcement_message_arg_conv;
27845         announcement_message_arg_conv.inner = (void*)(announcement_message_arg & (~1));
27846         announcement_message_arg_conv.is_owned = (announcement_message_arg & 1) || (announcement_message_arg == 0);
27847         announcement_message_arg_conv = ChannelAnnouncement_clone(&announcement_message_arg_conv);
27848         LDKChannelInfo ret_var = ChannelInfo_new(features_arg_conv, node_one_arg_conv, one_to_two_arg_conv, node_two_arg_conv, two_to_one_arg_conv, capacity_sats_arg_conv, announcement_message_arg_conv);
27849         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27850         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27851         uint64_t ret_ref = (uint64_t)ret_var.inner;
27852         if (ret_var.is_owned) {
27853                 ret_ref |= 1;
27854         }
27855         return ret_ref;
27856 }
27857
27858 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27859         LDKChannelInfo orig_conv;
27860         orig_conv.inner = (void*)(orig & (~1));
27861         orig_conv.is_owned = false;
27862         LDKChannelInfo ret_var = ChannelInfo_clone(&orig_conv);
27863         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27864         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27865         uint64_t ret_ref = (uint64_t)ret_var.inner;
27866         if (ret_var.is_owned) {
27867                 ret_ref |= 1;
27868         }
27869         return ret_ref;
27870 }
27871
27872 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
27873         LDKChannelInfo obj_conv;
27874         obj_conv.inner = (void*)(obj & (~1));
27875         obj_conv.is_owned = false;
27876         LDKCVec_u8Z ret_var = ChannelInfo_write(&obj_conv);
27877         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
27878         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
27879         CVec_u8Z_free(ret_var);
27880         return ret_arr;
27881 }
27882
27883 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
27884         LDKu8slice ser_ref;
27885         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
27886         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
27887         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
27888         *ret_conv = ChannelInfo_read(ser_ref);
27889         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
27890         return (uint64_t)ret_conv;
27891 }
27892
27893 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27894         LDKRoutingFees this_obj_conv;
27895         this_obj_conv.inner = (void*)(this_obj & (~1));
27896         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27897         RoutingFees_free(this_obj_conv);
27898 }
27899
27900 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1get_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
27901         LDKRoutingFees this_ptr_conv;
27902         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27903         this_ptr_conv.is_owned = false;
27904         int32_t ret_val = RoutingFees_get_base_msat(&this_ptr_conv);
27905         return ret_val;
27906 }
27907
27908 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1set_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
27909         LDKRoutingFees this_ptr_conv;
27910         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27911         this_ptr_conv.is_owned = false;
27912         RoutingFees_set_base_msat(&this_ptr_conv, val);
27913 }
27914
27915 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1get_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
27916         LDKRoutingFees this_ptr_conv;
27917         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27918         this_ptr_conv.is_owned = false;
27919         int32_t ret_val = RoutingFees_get_proportional_millionths(&this_ptr_conv);
27920         return ret_val;
27921 }
27922
27923 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1set_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
27924         LDKRoutingFees this_ptr_conv;
27925         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27926         this_ptr_conv.is_owned = false;
27927         RoutingFees_set_proportional_millionths(&this_ptr_conv, val);
27928 }
27929
27930 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) {
27931         LDKRoutingFees ret_var = RoutingFees_new(base_msat_arg, proportional_millionths_arg);
27932         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27933         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27934         uint64_t ret_ref = (uint64_t)ret_var.inner;
27935         if (ret_var.is_owned) {
27936                 ret_ref |= 1;
27937         }
27938         return ret_ref;
27939 }
27940
27941 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RoutingFees_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
27942         LDKRoutingFees a_conv;
27943         a_conv.inner = (void*)(a & (~1));
27944         a_conv.is_owned = false;
27945         LDKRoutingFees b_conv;
27946         b_conv.inner = (void*)(b & (~1));
27947         b_conv.is_owned = false;
27948         jboolean ret_val = RoutingFees_eq(&a_conv, &b_conv);
27949         return ret_val;
27950 }
27951
27952 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27953         LDKRoutingFees orig_conv;
27954         orig_conv.inner = (void*)(orig & (~1));
27955         orig_conv.is_owned = false;
27956         LDKRoutingFees ret_var = RoutingFees_clone(&orig_conv);
27957         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27958         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27959         uint64_t ret_ref = (uint64_t)ret_var.inner;
27960         if (ret_var.is_owned) {
27961                 ret_ref |= 1;
27962         }
27963         return ret_ref;
27964 }
27965
27966 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1hash(JNIEnv *env, jclass clz, int64_t o) {
27967         LDKRoutingFees o_conv;
27968         o_conv.inner = (void*)(o & (~1));
27969         o_conv.is_owned = false;
27970         int64_t ret_val = RoutingFees_hash(&o_conv);
27971         return ret_val;
27972 }
27973
27974 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RoutingFees_1write(JNIEnv *env, jclass clz, int64_t obj) {
27975         LDKRoutingFees obj_conv;
27976         obj_conv.inner = (void*)(obj & (~1));
27977         obj_conv.is_owned = false;
27978         LDKCVec_u8Z ret_var = RoutingFees_write(&obj_conv);
27979         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
27980         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
27981         CVec_u8Z_free(ret_var);
27982         return ret_arr;
27983 }
27984
27985 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
27986         LDKu8slice ser_ref;
27987         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
27988         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
27989         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
27990         *ret_conv = RoutingFees_read(ser_ref);
27991         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
27992         return (uint64_t)ret_conv;
27993 }
27994
27995 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27996         LDKNodeAnnouncementInfo this_obj_conv;
27997         this_obj_conv.inner = (void*)(this_obj & (~1));
27998         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27999         NodeAnnouncementInfo_free(this_obj_conv);
28000 }
28001
28002 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
28003         LDKNodeAnnouncementInfo this_ptr_conv;
28004         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28005         this_ptr_conv.is_owned = false;
28006         LDKNodeFeatures ret_var = NodeAnnouncementInfo_get_features(&this_ptr_conv);
28007         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28008         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28009         uint64_t ret_ref = (uint64_t)ret_var.inner;
28010         if (ret_var.is_owned) {
28011                 ret_ref |= 1;
28012         }
28013         return ret_ref;
28014 }
28015
28016 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28017         LDKNodeAnnouncementInfo this_ptr_conv;
28018         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28019         this_ptr_conv.is_owned = false;
28020         LDKNodeFeatures val_conv;
28021         val_conv.inner = (void*)(val & (~1));
28022         val_conv.is_owned = (val & 1) || (val == 0);
28023         val_conv = NodeFeatures_clone(&val_conv);
28024         NodeAnnouncementInfo_set_features(&this_ptr_conv, val_conv);
28025 }
28026
28027 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr) {
28028         LDKNodeAnnouncementInfo this_ptr_conv;
28029         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28030         this_ptr_conv.is_owned = false;
28031         int32_t ret_val = NodeAnnouncementInfo_get_last_update(&this_ptr_conv);
28032         return ret_val;
28033 }
28034
28035 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
28036         LDKNodeAnnouncementInfo this_ptr_conv;
28037         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28038         this_ptr_conv.is_owned = false;
28039         NodeAnnouncementInfo_set_last_update(&this_ptr_conv, val);
28040 }
28041
28042 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr) {
28043         LDKNodeAnnouncementInfo this_ptr_conv;
28044         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28045         this_ptr_conv.is_owned = false;
28046         int8_tArray ret_arr = (*env)->NewByteArray(env, 3);
28047         (*env)->SetByteArrayRegion(env, ret_arr, 0, 3, *NodeAnnouncementInfo_get_rgb(&this_ptr_conv));
28048         return ret_arr;
28049 }
28050
28051 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28052         LDKNodeAnnouncementInfo this_ptr_conv;
28053         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28054         this_ptr_conv.is_owned = false;
28055         LDKThreeBytes val_ref;
28056         CHECK((*env)->GetArrayLength(env, val) == 3);
28057         (*env)->GetByteArrayRegion(env, val, 0, 3, val_ref.data);
28058         NodeAnnouncementInfo_set_rgb(&this_ptr_conv, val_ref);
28059 }
28060
28061 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
28062         LDKNodeAnnouncementInfo this_ptr_conv;
28063         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28064         this_ptr_conv.is_owned = false;
28065         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
28066         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *NodeAnnouncementInfo_get_alias(&this_ptr_conv));
28067         return ret_arr;
28068 }
28069
28070 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28071         LDKNodeAnnouncementInfo this_ptr_conv;
28072         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28073         this_ptr_conv.is_owned = false;
28074         LDKThirtyTwoBytes val_ref;
28075         CHECK((*env)->GetArrayLength(env, val) == 32);
28076         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
28077         NodeAnnouncementInfo_set_alias(&this_ptr_conv, val_ref);
28078 }
28079
28080 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1addresses(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
28081         LDKNodeAnnouncementInfo this_ptr_conv;
28082         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28083         this_ptr_conv.is_owned = false;
28084         LDKCVec_NetAddressZ val_constr;
28085         val_constr.datalen = (*env)->GetArrayLength(env, val);
28086         if (val_constr.datalen > 0)
28087                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
28088         else
28089                 val_constr.data = NULL;
28090         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
28091         for (size_t m = 0; m < val_constr.datalen; m++) {
28092                 int64_t val_conv_12 = val_vals[m];
28093                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(((uint64_t)val_conv_12) & ~1);
28094                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)val_conv_12) & ~1));
28095                 val_constr.data[m] = val_conv_12_conv;
28096         }
28097         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
28098         NodeAnnouncementInfo_set_addresses(&this_ptr_conv, val_constr);
28099 }
28100
28101 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
28102         LDKNodeAnnouncementInfo this_ptr_conv;
28103         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28104         this_ptr_conv.is_owned = false;
28105         LDKNodeAnnouncement ret_var = NodeAnnouncementInfo_get_announcement_message(&this_ptr_conv);
28106         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28107         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28108         uint64_t ret_ref = (uint64_t)ret_var.inner;
28109         if (ret_var.is_owned) {
28110                 ret_ref |= 1;
28111         }
28112         return ret_ref;
28113 }
28114
28115 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28116         LDKNodeAnnouncementInfo this_ptr_conv;
28117         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28118         this_ptr_conv.is_owned = false;
28119         LDKNodeAnnouncement val_conv;
28120         val_conv.inner = (void*)(val & (~1));
28121         val_conv.is_owned = (val & 1) || (val == 0);
28122         val_conv = NodeAnnouncement_clone(&val_conv);
28123         NodeAnnouncementInfo_set_announcement_message(&this_ptr_conv, val_conv);
28124 }
28125
28126 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) {
28127         LDKNodeFeatures features_arg_conv;
28128         features_arg_conv.inner = (void*)(features_arg & (~1));
28129         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
28130         features_arg_conv = NodeFeatures_clone(&features_arg_conv);
28131         LDKThreeBytes rgb_arg_ref;
28132         CHECK((*env)->GetArrayLength(env, rgb_arg) == 3);
28133         (*env)->GetByteArrayRegion(env, rgb_arg, 0, 3, rgb_arg_ref.data);
28134         LDKThirtyTwoBytes alias_arg_ref;
28135         CHECK((*env)->GetArrayLength(env, alias_arg) == 32);
28136         (*env)->GetByteArrayRegion(env, alias_arg, 0, 32, alias_arg_ref.data);
28137         LDKCVec_NetAddressZ addresses_arg_constr;
28138         addresses_arg_constr.datalen = (*env)->GetArrayLength(env, addresses_arg);
28139         if (addresses_arg_constr.datalen > 0)
28140                 addresses_arg_constr.data = MALLOC(addresses_arg_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
28141         else
28142                 addresses_arg_constr.data = NULL;
28143         int64_t* addresses_arg_vals = (*env)->GetLongArrayElements (env, addresses_arg, NULL);
28144         for (size_t m = 0; m < addresses_arg_constr.datalen; m++) {
28145                 int64_t addresses_arg_conv_12 = addresses_arg_vals[m];
28146                 LDKNetAddress addresses_arg_conv_12_conv = *(LDKNetAddress*)(((uint64_t)addresses_arg_conv_12) & ~1);
28147                 addresses_arg_constr.data[m] = addresses_arg_conv_12_conv;
28148         }
28149         (*env)->ReleaseLongArrayElements(env, addresses_arg, addresses_arg_vals, 0);
28150         LDKNodeAnnouncement announcement_message_arg_conv;
28151         announcement_message_arg_conv.inner = (void*)(announcement_message_arg & (~1));
28152         announcement_message_arg_conv.is_owned = (announcement_message_arg & 1) || (announcement_message_arg == 0);
28153         announcement_message_arg_conv = NodeAnnouncement_clone(&announcement_message_arg_conv);
28154         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_new(features_arg_conv, last_update_arg, rgb_arg_ref, alias_arg_ref, addresses_arg_constr, announcement_message_arg_conv);
28155         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28156         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28157         uint64_t ret_ref = (uint64_t)ret_var.inner;
28158         if (ret_var.is_owned) {
28159                 ret_ref |= 1;
28160         }
28161         return ret_ref;
28162 }
28163
28164 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28165         LDKNodeAnnouncementInfo orig_conv;
28166         orig_conv.inner = (void*)(orig & (~1));
28167         orig_conv.is_owned = false;
28168         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(&orig_conv);
28169         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28170         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28171         uint64_t ret_ref = (uint64_t)ret_var.inner;
28172         if (ret_var.is_owned) {
28173                 ret_ref |= 1;
28174         }
28175         return ret_ref;
28176 }
28177
28178 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
28179         LDKNodeAnnouncementInfo obj_conv;
28180         obj_conv.inner = (void*)(obj & (~1));
28181         obj_conv.is_owned = false;
28182         LDKCVec_u8Z ret_var = NodeAnnouncementInfo_write(&obj_conv);
28183         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
28184         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
28185         CVec_u8Z_free(ret_var);
28186         return ret_arr;
28187 }
28188
28189 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
28190         LDKu8slice ser_ref;
28191         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
28192         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
28193         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
28194         *ret_conv = NodeAnnouncementInfo_read(ser_ref);
28195         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
28196         return (uint64_t)ret_conv;
28197 }
28198
28199 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28200         LDKNodeInfo this_obj_conv;
28201         this_obj_conv.inner = (void*)(this_obj & (~1));
28202         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28203         NodeInfo_free(this_obj_conv);
28204 }
28205
28206 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
28207         LDKNodeInfo this_ptr_conv;
28208         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28209         this_ptr_conv.is_owned = false;
28210         LDKCVec_u64Z val_constr;
28211         val_constr.datalen = (*env)->GetArrayLength(env, val);
28212         if (val_constr.datalen > 0)
28213                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
28214         else
28215                 val_constr.data = NULL;
28216         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
28217         for (size_t g = 0; g < val_constr.datalen; g++) {
28218                 int64_t val_conv_6 = val_vals[g];
28219                 val_constr.data[g] = val_conv_6;
28220         }
28221         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
28222         NodeInfo_set_channels(&this_ptr_conv, val_constr);
28223 }
28224
28225 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1lowest_1inbound_1channel_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
28226         LDKNodeInfo this_ptr_conv;
28227         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28228         this_ptr_conv.is_owned = false;
28229         LDKRoutingFees ret_var = NodeInfo_get_lowest_inbound_channel_fees(&this_ptr_conv);
28230         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28231         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28232         uint64_t ret_ref = (uint64_t)ret_var.inner;
28233         if (ret_var.is_owned) {
28234                 ret_ref |= 1;
28235         }
28236         return ret_ref;
28237 }
28238
28239 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) {
28240         LDKNodeInfo this_ptr_conv;
28241         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28242         this_ptr_conv.is_owned = false;
28243         LDKRoutingFees val_conv;
28244         val_conv.inner = (void*)(val & (~1));
28245         val_conv.is_owned = (val & 1) || (val == 0);
28246         val_conv = RoutingFees_clone(&val_conv);
28247         NodeInfo_set_lowest_inbound_channel_fees(&this_ptr_conv, val_conv);
28248 }
28249
28250 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1announcement_1info(JNIEnv *env, jclass clz, int64_t this_ptr) {
28251         LDKNodeInfo this_ptr_conv;
28252         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28253         this_ptr_conv.is_owned = false;
28254         LDKNodeAnnouncementInfo ret_var = NodeInfo_get_announcement_info(&this_ptr_conv);
28255         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28256         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28257         uint64_t ret_ref = (uint64_t)ret_var.inner;
28258         if (ret_var.is_owned) {
28259                 ret_ref |= 1;
28260         }
28261         return ret_ref;
28262 }
28263
28264 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1announcement_1info(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28265         LDKNodeInfo this_ptr_conv;
28266         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28267         this_ptr_conv.is_owned = false;
28268         LDKNodeAnnouncementInfo val_conv;
28269         val_conv.inner = (void*)(val & (~1));
28270         val_conv.is_owned = (val & 1) || (val == 0);
28271         val_conv = NodeAnnouncementInfo_clone(&val_conv);
28272         NodeInfo_set_announcement_info(&this_ptr_conv, val_conv);
28273 }
28274
28275 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) {
28276         LDKCVec_u64Z channels_arg_constr;
28277         channels_arg_constr.datalen = (*env)->GetArrayLength(env, channels_arg);
28278         if (channels_arg_constr.datalen > 0)
28279                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
28280         else
28281                 channels_arg_constr.data = NULL;
28282         int64_t* channels_arg_vals = (*env)->GetLongArrayElements (env, channels_arg, NULL);
28283         for (size_t g = 0; g < channels_arg_constr.datalen; g++) {
28284                 int64_t channels_arg_conv_6 = channels_arg_vals[g];
28285                 channels_arg_constr.data[g] = channels_arg_conv_6;
28286         }
28287         (*env)->ReleaseLongArrayElements(env, channels_arg, channels_arg_vals, 0);
28288         LDKRoutingFees lowest_inbound_channel_fees_arg_conv;
28289         lowest_inbound_channel_fees_arg_conv.inner = (void*)(lowest_inbound_channel_fees_arg & (~1));
28290         lowest_inbound_channel_fees_arg_conv.is_owned = (lowest_inbound_channel_fees_arg & 1) || (lowest_inbound_channel_fees_arg == 0);
28291         lowest_inbound_channel_fees_arg_conv = RoutingFees_clone(&lowest_inbound_channel_fees_arg_conv);
28292         LDKNodeAnnouncementInfo announcement_info_arg_conv;
28293         announcement_info_arg_conv.inner = (void*)(announcement_info_arg & (~1));
28294         announcement_info_arg_conv.is_owned = (announcement_info_arg & 1) || (announcement_info_arg == 0);
28295         announcement_info_arg_conv = NodeAnnouncementInfo_clone(&announcement_info_arg_conv);
28296         LDKNodeInfo ret_var = NodeInfo_new(channels_arg_constr, lowest_inbound_channel_fees_arg_conv, announcement_info_arg_conv);
28297         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28298         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28299         uint64_t ret_ref = (uint64_t)ret_var.inner;
28300         if (ret_var.is_owned) {
28301                 ret_ref |= 1;
28302         }
28303         return ret_ref;
28304 }
28305
28306 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28307         LDKNodeInfo orig_conv;
28308         orig_conv.inner = (void*)(orig & (~1));
28309         orig_conv.is_owned = false;
28310         LDKNodeInfo ret_var = NodeInfo_clone(&orig_conv);
28311         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28312         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28313         uint64_t ret_ref = (uint64_t)ret_var.inner;
28314         if (ret_var.is_owned) {
28315                 ret_ref |= 1;
28316         }
28317         return ret_ref;
28318 }
28319
28320 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
28321         LDKNodeInfo obj_conv;
28322         obj_conv.inner = (void*)(obj & (~1));
28323         obj_conv.is_owned = false;
28324         LDKCVec_u8Z ret_var = NodeInfo_write(&obj_conv);
28325         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
28326         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
28327         CVec_u8Z_free(ret_var);
28328         return ret_arr;
28329 }
28330
28331 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
28332         LDKu8slice ser_ref;
28333         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
28334         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
28335         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
28336         *ret_conv = NodeInfo_read(ser_ref);
28337         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
28338         return (uint64_t)ret_conv;
28339 }
28340
28341 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1write(JNIEnv *env, jclass clz, int64_t obj) {
28342         LDKNetworkGraph obj_conv;
28343         obj_conv.inner = (void*)(obj & (~1));
28344         obj_conv.is_owned = false;
28345         LDKCVec_u8Z ret_var = NetworkGraph_write(&obj_conv);
28346         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
28347         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
28348         CVec_u8Z_free(ret_var);
28349         return ret_arr;
28350 }
28351
28352 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
28353         LDKu8slice ser_ref;
28354         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
28355         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
28356         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
28357         *ret_conv = NetworkGraph_read(ser_ref);
28358         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
28359         return (uint64_t)ret_conv;
28360 }
28361
28362 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1new(JNIEnv *env, jclass clz, int8_tArray genesis_hash) {
28363         LDKThirtyTwoBytes genesis_hash_ref;
28364         CHECK((*env)->GetArrayLength(env, genesis_hash) == 32);
28365         (*env)->GetByteArrayRegion(env, genesis_hash, 0, 32, genesis_hash_ref.data);
28366         LDKNetworkGraph ret_var = NetworkGraph_new(genesis_hash_ref);
28367         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28368         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28369         uint64_t ret_ref = (uint64_t)ret_var.inner;
28370         if (ret_var.is_owned) {
28371                 ret_ref |= 1;
28372         }
28373         return ret_ref;
28374 }
28375
28376 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1read_1only(JNIEnv *env, jclass clz, int64_t this_arg) {
28377         LDKNetworkGraph this_arg_conv;
28378         this_arg_conv.inner = (void*)(this_arg & (~1));
28379         this_arg_conv.is_owned = false;
28380         LDKReadOnlyNetworkGraph ret_var = NetworkGraph_read_only(&this_arg_conv);
28381         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28382         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28383         uint64_t ret_ref = (uint64_t)ret_var.inner;
28384         if (ret_var.is_owned) {
28385                 ret_ref |= 1;
28386         }
28387         return ret_ref;
28388 }
28389
28390 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) {
28391         LDKNetworkGraph this_arg_conv;
28392         this_arg_conv.inner = (void*)(this_arg & (~1));
28393         this_arg_conv.is_owned = false;
28394         LDKNodeAnnouncement msg_conv;
28395         msg_conv.inner = (void*)(msg & (~1));
28396         msg_conv.is_owned = false;
28397         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
28398         *ret_conv = NetworkGraph_update_node_from_announcement(&this_arg_conv, &msg_conv);
28399         return (uint64_t)ret_conv;
28400 }
28401
28402 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) {
28403         LDKNetworkGraph this_arg_conv;
28404         this_arg_conv.inner = (void*)(this_arg & (~1));
28405         this_arg_conv.is_owned = false;
28406         LDKUnsignedNodeAnnouncement msg_conv;
28407         msg_conv.inner = (void*)(msg & (~1));
28408         msg_conv.is_owned = false;
28409         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
28410         *ret_conv = NetworkGraph_update_node_from_unsigned_announcement(&this_arg_conv, &msg_conv);
28411         return (uint64_t)ret_conv;
28412 }
28413
28414 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) {
28415         LDKNetworkGraph this_arg_conv;
28416         this_arg_conv.inner = (void*)(this_arg & (~1));
28417         this_arg_conv.is_owned = false;
28418         LDKChannelAnnouncement msg_conv;
28419         msg_conv.inner = (void*)(msg & (~1));
28420         msg_conv.is_owned = false;
28421         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(((uint64_t)chain_access) & ~1);
28422         // Warning: we may need a move here but no clone is available for LDKCOption_AccessZ
28423         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
28424                 // Manually implement clone for Java trait instances
28425                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
28426                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
28427                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
28428                 }
28429         }
28430         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
28431         *ret_conv = NetworkGraph_update_channel_from_announcement(&this_arg_conv, &msg_conv, chain_access_conv);
28432         return (uint64_t)ret_conv;
28433 }
28434
28435 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) {
28436         LDKNetworkGraph this_arg_conv;
28437         this_arg_conv.inner = (void*)(this_arg & (~1));
28438         this_arg_conv.is_owned = false;
28439         LDKUnsignedChannelAnnouncement msg_conv;
28440         msg_conv.inner = (void*)(msg & (~1));
28441         msg_conv.is_owned = false;
28442         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(((uint64_t)chain_access) & ~1);
28443         // Warning: we may need a move here but no clone is available for LDKCOption_AccessZ
28444         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
28445                 // Manually implement clone for Java trait instances
28446                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
28447                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
28448                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
28449                 }
28450         }
28451         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
28452         *ret_conv = NetworkGraph_update_channel_from_unsigned_announcement(&this_arg_conv, &msg_conv, chain_access_conv);
28453         return (uint64_t)ret_conv;
28454 }
28455
28456 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) {
28457         LDKNetworkGraph this_arg_conv;
28458         this_arg_conv.inner = (void*)(this_arg & (~1));
28459         this_arg_conv.is_owned = false;
28460         NetworkGraph_close_channel_from_update(&this_arg_conv, short_channel_id, is_permanent);
28461 }
28462
28463 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) {
28464         LDKNetworkGraph this_arg_conv;
28465         this_arg_conv.inner = (void*)(this_arg & (~1));
28466         this_arg_conv.is_owned = false;
28467         LDKPublicKey _node_id_ref;
28468         CHECK((*env)->GetArrayLength(env, _node_id) == 33);
28469         (*env)->GetByteArrayRegion(env, _node_id, 0, 33, _node_id_ref.compressed_form);
28470         NetworkGraph_fail_node(&this_arg_conv, _node_id_ref, is_permanent);
28471 }
28472
28473 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1update_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
28474         LDKNetworkGraph this_arg_conv;
28475         this_arg_conv.inner = (void*)(this_arg & (~1));
28476         this_arg_conv.is_owned = false;
28477         LDKChannelUpdate msg_conv;
28478         msg_conv.inner = (void*)(msg & (~1));
28479         msg_conv.is_owned = false;
28480         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
28481         *ret_conv = NetworkGraph_update_channel(&this_arg_conv, &msg_conv);
28482         return (uint64_t)ret_conv;
28483 }
28484
28485 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1update_1channel_1unsigned(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
28486         LDKNetworkGraph this_arg_conv;
28487         this_arg_conv.inner = (void*)(this_arg & (~1));
28488         this_arg_conv.is_owned = false;
28489         LDKUnsignedChannelUpdate msg_conv;
28490         msg_conv.inner = (void*)(msg & (~1));
28491         msg_conv.is_owned = false;
28492         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
28493         *ret_conv = NetworkGraph_update_channel_unsigned(&this_arg_conv, &msg_conv);
28494         return (uint64_t)ret_conv;
28495 }
28496
28497 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReadOnlyNetworkGraph_1get_1addresses(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray pubkey) {
28498         LDKReadOnlyNetworkGraph this_arg_conv;
28499         this_arg_conv.inner = (void*)(this_arg & (~1));
28500         this_arg_conv.is_owned = false;
28501         LDKPublicKey pubkey_ref;
28502         CHECK((*env)->GetArrayLength(env, pubkey) == 33);
28503         (*env)->GetByteArrayRegion(env, pubkey, 0, 33, pubkey_ref.compressed_form);
28504         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
28505         *ret_copy = ReadOnlyNetworkGraph_get_addresses(&this_arg_conv, pubkey_ref);
28506         uint64_t ret_ref = (uint64_t)ret_copy;
28507         return ret_ref;
28508 }
28509
28510 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28511         LDKRouteHop this_obj_conv;
28512         this_obj_conv.inner = (void*)(this_obj & (~1));
28513         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28514         RouteHop_free(this_obj_conv);
28515 }
28516
28517 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
28518         LDKRouteHop this_ptr_conv;
28519         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28520         this_ptr_conv.is_owned = false;
28521         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
28522         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RouteHop_get_pubkey(&this_ptr_conv).compressed_form);
28523         return ret_arr;
28524 }
28525
28526 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28527         LDKRouteHop this_ptr_conv;
28528         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28529         this_ptr_conv.is_owned = false;
28530         LDKPublicKey val_ref;
28531         CHECK((*env)->GetArrayLength(env, val) == 33);
28532         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
28533         RouteHop_set_pubkey(&this_ptr_conv, val_ref);
28534 }
28535
28536 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1node_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
28537         LDKRouteHop this_ptr_conv;
28538         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28539         this_ptr_conv.is_owned = false;
28540         LDKNodeFeatures ret_var = RouteHop_get_node_features(&this_ptr_conv);
28541         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28542         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28543         uint64_t ret_ref = (uint64_t)ret_var.inner;
28544         if (ret_var.is_owned) {
28545                 ret_ref |= 1;
28546         }
28547         return ret_ref;
28548 }
28549
28550 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1node_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28551         LDKRouteHop this_ptr_conv;
28552         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28553         this_ptr_conv.is_owned = false;
28554         LDKNodeFeatures val_conv;
28555         val_conv.inner = (void*)(val & (~1));
28556         val_conv.is_owned = (val & 1) || (val == 0);
28557         val_conv = NodeFeatures_clone(&val_conv);
28558         RouteHop_set_node_features(&this_ptr_conv, val_conv);
28559 }
28560
28561 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
28562         LDKRouteHop this_ptr_conv;
28563         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28564         this_ptr_conv.is_owned = false;
28565         int64_t ret_val = RouteHop_get_short_channel_id(&this_ptr_conv);
28566         return ret_val;
28567 }
28568
28569 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28570         LDKRouteHop this_ptr_conv;
28571         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28572         this_ptr_conv.is_owned = false;
28573         RouteHop_set_short_channel_id(&this_ptr_conv, val);
28574 }
28575
28576 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1channel_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
28577         LDKRouteHop this_ptr_conv;
28578         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28579         this_ptr_conv.is_owned = false;
28580         LDKChannelFeatures ret_var = RouteHop_get_channel_features(&this_ptr_conv);
28581         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28582         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28583         uint64_t ret_ref = (uint64_t)ret_var.inner;
28584         if (ret_var.is_owned) {
28585                 ret_ref |= 1;
28586         }
28587         return ret_ref;
28588 }
28589
28590 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1channel_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28591         LDKRouteHop this_ptr_conv;
28592         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28593         this_ptr_conv.is_owned = false;
28594         LDKChannelFeatures val_conv;
28595         val_conv.inner = (void*)(val & (~1));
28596         val_conv.is_owned = (val & 1) || (val == 0);
28597         val_conv = ChannelFeatures_clone(&val_conv);
28598         RouteHop_set_channel_features(&this_ptr_conv, val_conv);
28599 }
28600
28601 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1fee_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
28602         LDKRouteHop this_ptr_conv;
28603         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28604         this_ptr_conv.is_owned = false;
28605         int64_t ret_val = RouteHop_get_fee_msat(&this_ptr_conv);
28606         return ret_val;
28607 }
28608
28609 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1fee_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28610         LDKRouteHop this_ptr_conv;
28611         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28612         this_ptr_conv.is_owned = false;
28613         RouteHop_set_fee_msat(&this_ptr_conv, val);
28614 }
28615
28616 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
28617         LDKRouteHop this_ptr_conv;
28618         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28619         this_ptr_conv.is_owned = false;
28620         int32_t ret_val = RouteHop_get_cltv_expiry_delta(&this_ptr_conv);
28621         return ret_val;
28622 }
28623
28624 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
28625         LDKRouteHop this_ptr_conv;
28626         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28627         this_ptr_conv.is_owned = false;
28628         RouteHop_set_cltv_expiry_delta(&this_ptr_conv, val);
28629 }
28630
28631 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) {
28632         LDKPublicKey pubkey_arg_ref;
28633         CHECK((*env)->GetArrayLength(env, pubkey_arg) == 33);
28634         (*env)->GetByteArrayRegion(env, pubkey_arg, 0, 33, pubkey_arg_ref.compressed_form);
28635         LDKNodeFeatures node_features_arg_conv;
28636         node_features_arg_conv.inner = (void*)(node_features_arg & (~1));
28637         node_features_arg_conv.is_owned = (node_features_arg & 1) || (node_features_arg == 0);
28638         node_features_arg_conv = NodeFeatures_clone(&node_features_arg_conv);
28639         LDKChannelFeatures channel_features_arg_conv;
28640         channel_features_arg_conv.inner = (void*)(channel_features_arg & (~1));
28641         channel_features_arg_conv.is_owned = (channel_features_arg & 1) || (channel_features_arg == 0);
28642         channel_features_arg_conv = ChannelFeatures_clone(&channel_features_arg_conv);
28643         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);
28644         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28645         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28646         uint64_t ret_ref = (uint64_t)ret_var.inner;
28647         if (ret_var.is_owned) {
28648                 ret_ref |= 1;
28649         }
28650         return ret_ref;
28651 }
28652
28653 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28654         LDKRouteHop orig_conv;
28655         orig_conv.inner = (void*)(orig & (~1));
28656         orig_conv.is_owned = false;
28657         LDKRouteHop ret_var = RouteHop_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 int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1hash(JNIEnv *env, jclass clz, int64_t o) {
28668         LDKRouteHop o_conv;
28669         o_conv.inner = (void*)(o & (~1));
28670         o_conv.is_owned = false;
28671         int64_t ret_val = RouteHop_hash(&o_conv);
28672         return ret_val;
28673 }
28674
28675 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHop_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
28676         LDKRouteHop a_conv;
28677         a_conv.inner = (void*)(a & (~1));
28678         a_conv.is_owned = false;
28679         LDKRouteHop b_conv;
28680         b_conv.inner = (void*)(b & (~1));
28681         b_conv.is_owned = false;
28682         jboolean ret_val = RouteHop_eq(&a_conv, &b_conv);
28683         return ret_val;
28684 }
28685
28686 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHop_1write(JNIEnv *env, jclass clz, int64_t obj) {
28687         LDKRouteHop obj_conv;
28688         obj_conv.inner = (void*)(obj & (~1));
28689         obj_conv.is_owned = false;
28690         LDKCVec_u8Z ret_var = RouteHop_write(&obj_conv);
28691         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
28692         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
28693         CVec_u8Z_free(ret_var);
28694         return ret_arr;
28695 }
28696
28697 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
28698         LDKu8slice ser_ref;
28699         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
28700         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
28701         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
28702         *ret_conv = RouteHop_read(ser_ref);
28703         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
28704         return (uint64_t)ret_conv;
28705 }
28706
28707 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28708         LDKRoute this_obj_conv;
28709         this_obj_conv.inner = (void*)(this_obj & (~1));
28710         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28711         Route_free(this_obj_conv);
28712 }
28713
28714 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_Route_1get_1paths(JNIEnv *env, jclass clz, int64_t this_ptr) {
28715         LDKRoute this_ptr_conv;
28716         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28717         this_ptr_conv.is_owned = false;
28718         LDKCVec_CVec_RouteHopZZ ret_var = Route_get_paths(&this_ptr_conv);
28719         jobjectArray ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_J_clz, NULL);
28720         ;
28721         for (size_t m = 0; m < ret_var.datalen; m++) {
28722                 LDKCVec_RouteHopZ ret_conv_12_var = ret_var.data[m];
28723                 int64_tArray ret_conv_12_arr = (*env)->NewLongArray(env, ret_conv_12_var.datalen);
28724                 int64_t *ret_conv_12_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_conv_12_arr, NULL);
28725                 for (size_t k = 0; k < ret_conv_12_var.datalen; k++) {
28726                         LDKRouteHop ret_conv_12_conv_10_var = ret_conv_12_var.data[k];
28727                         CHECK((((uint64_t)ret_conv_12_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28728                         CHECK((((uint64_t)&ret_conv_12_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28729                         uint64_t ret_conv_12_conv_10_ref = (uint64_t)ret_conv_12_conv_10_var.inner;
28730                         if (ret_conv_12_conv_10_var.is_owned) {
28731                                 ret_conv_12_conv_10_ref |= 1;
28732                         }
28733                         ret_conv_12_arr_ptr[k] = ret_conv_12_conv_10_ref;
28734                 }
28735                 (*env)->ReleasePrimitiveArrayCritical(env, ret_conv_12_arr, ret_conv_12_arr_ptr, 0);
28736                 FREE(ret_conv_12_var.data);
28737                 (*env)->SetObjectArrayElement(env, ret_arr, m, ret_conv_12_arr);
28738         }
28739         FREE(ret_var.data);
28740         return ret_arr;
28741 }
28742
28743 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1set_1paths(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
28744         LDKRoute this_ptr_conv;
28745         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28746         this_ptr_conv.is_owned = false;
28747         LDKCVec_CVec_RouteHopZZ val_constr;
28748         val_constr.datalen = (*env)->GetArrayLength(env, val);
28749         if (val_constr.datalen > 0)
28750                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
28751         else
28752                 val_constr.data = NULL;
28753         for (size_t m = 0; m < val_constr.datalen; m++) {
28754                 int64_tArray val_conv_12 = (*env)->GetObjectArrayElement(env, val, m);
28755                 LDKCVec_RouteHopZ val_conv_12_constr;
28756                 val_conv_12_constr.datalen = (*env)->GetArrayLength(env, val_conv_12);
28757                 if (val_conv_12_constr.datalen > 0)
28758                         val_conv_12_constr.data = MALLOC(val_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
28759                 else
28760                         val_conv_12_constr.data = NULL;
28761                 int64_t* val_conv_12_vals = (*env)->GetLongArrayElements (env, val_conv_12, NULL);
28762                 for (size_t k = 0; k < val_conv_12_constr.datalen; k++) {
28763                         int64_t val_conv_12_conv_10 = val_conv_12_vals[k];
28764                         LDKRouteHop val_conv_12_conv_10_conv;
28765                         val_conv_12_conv_10_conv.inner = (void*)(val_conv_12_conv_10 & (~1));
28766                         val_conv_12_conv_10_conv.is_owned = (val_conv_12_conv_10 & 1) || (val_conv_12_conv_10 == 0);
28767                         val_conv_12_conv_10_conv = RouteHop_clone(&val_conv_12_conv_10_conv);
28768                         val_conv_12_constr.data[k] = val_conv_12_conv_10_conv;
28769                 }
28770                 (*env)->ReleaseLongArrayElements(env, val_conv_12, val_conv_12_vals, 0);
28771                 val_constr.data[m] = val_conv_12_constr;
28772         }
28773         Route_set_paths(&this_ptr_conv, val_constr);
28774 }
28775
28776 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1new(JNIEnv *env, jclass clz, jobjectArray paths_arg) {
28777         LDKCVec_CVec_RouteHopZZ paths_arg_constr;
28778         paths_arg_constr.datalen = (*env)->GetArrayLength(env, paths_arg);
28779         if (paths_arg_constr.datalen > 0)
28780                 paths_arg_constr.data = MALLOC(paths_arg_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
28781         else
28782                 paths_arg_constr.data = NULL;
28783         for (size_t m = 0; m < paths_arg_constr.datalen; m++) {
28784                 int64_tArray paths_arg_conv_12 = (*env)->GetObjectArrayElement(env, paths_arg, m);
28785                 LDKCVec_RouteHopZ paths_arg_conv_12_constr;
28786                 paths_arg_conv_12_constr.datalen = (*env)->GetArrayLength(env, paths_arg_conv_12);
28787                 if (paths_arg_conv_12_constr.datalen > 0)
28788                         paths_arg_conv_12_constr.data = MALLOC(paths_arg_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
28789                 else
28790                         paths_arg_conv_12_constr.data = NULL;
28791                 int64_t* paths_arg_conv_12_vals = (*env)->GetLongArrayElements (env, paths_arg_conv_12, NULL);
28792                 for (size_t k = 0; k < paths_arg_conv_12_constr.datalen; k++) {
28793                         int64_t paths_arg_conv_12_conv_10 = paths_arg_conv_12_vals[k];
28794                         LDKRouteHop paths_arg_conv_12_conv_10_conv;
28795                         paths_arg_conv_12_conv_10_conv.inner = (void*)(paths_arg_conv_12_conv_10 & (~1));
28796                         paths_arg_conv_12_conv_10_conv.is_owned = (paths_arg_conv_12_conv_10 & 1) || (paths_arg_conv_12_conv_10 == 0);
28797                         paths_arg_conv_12_conv_10_conv = RouteHop_clone(&paths_arg_conv_12_conv_10_conv);
28798                         paths_arg_conv_12_constr.data[k] = paths_arg_conv_12_conv_10_conv;
28799                 }
28800                 (*env)->ReleaseLongArrayElements(env, paths_arg_conv_12, paths_arg_conv_12_vals, 0);
28801                 paths_arg_constr.data[m] = paths_arg_conv_12_constr;
28802         }
28803         LDKRoute ret_var = Route_new(paths_arg_constr);
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 int64_t JNICALL Java_org_ldk_impl_bindings_Route_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28814         LDKRoute orig_conv;
28815         orig_conv.inner = (void*)(orig & (~1));
28816         orig_conv.is_owned = false;
28817         LDKRoute ret_var = Route_clone(&orig_conv);
28818         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28819         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28820         uint64_t ret_ref = (uint64_t)ret_var.inner;
28821         if (ret_var.is_owned) {
28822                 ret_ref |= 1;
28823         }
28824         return ret_ref;
28825 }
28826
28827 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1hash(JNIEnv *env, jclass clz, int64_t o) {
28828         LDKRoute o_conv;
28829         o_conv.inner = (void*)(o & (~1));
28830         o_conv.is_owned = false;
28831         int64_t ret_val = Route_hash(&o_conv);
28832         return ret_val;
28833 }
28834
28835 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Route_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
28836         LDKRoute a_conv;
28837         a_conv.inner = (void*)(a & (~1));
28838         a_conv.is_owned = false;
28839         LDKRoute b_conv;
28840         b_conv.inner = (void*)(b & (~1));
28841         b_conv.is_owned = false;
28842         jboolean ret_val = Route_eq(&a_conv, &b_conv);
28843         return ret_val;
28844 }
28845
28846 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1get_1total_1fees(JNIEnv *env, jclass clz, int64_t this_arg) {
28847         LDKRoute this_arg_conv;
28848         this_arg_conv.inner = (void*)(this_arg & (~1));
28849         this_arg_conv.is_owned = false;
28850         int64_t ret_val = Route_get_total_fees(&this_arg_conv);
28851         return ret_val;
28852 }
28853
28854 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1get_1total_1amount(JNIEnv *env, jclass clz, int64_t this_arg) {
28855         LDKRoute this_arg_conv;
28856         this_arg_conv.inner = (void*)(this_arg & (~1));
28857         this_arg_conv.is_owned = false;
28858         int64_t ret_val = Route_get_total_amount(&this_arg_conv);
28859         return ret_val;
28860 }
28861
28862 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Route_1write(JNIEnv *env, jclass clz, int64_t obj) {
28863         LDKRoute obj_conv;
28864         obj_conv.inner = (void*)(obj & (~1));
28865         obj_conv.is_owned = false;
28866         LDKCVec_u8Z ret_var = Route_write(&obj_conv);
28867         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
28868         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
28869         CVec_u8Z_free(ret_var);
28870         return ret_arr;
28871 }
28872
28873 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
28874         LDKu8slice ser_ref;
28875         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
28876         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
28877         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
28878         *ret_conv = Route_read(ser_ref);
28879         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
28880         return (uint64_t)ret_conv;
28881 }
28882
28883 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28884         LDKRouteHint this_obj_conv;
28885         this_obj_conv.inner = (void*)(this_obj & (~1));
28886         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28887         RouteHint_free(this_obj_conv);
28888 }
28889
28890 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28891         LDKRouteHint orig_conv;
28892         orig_conv.inner = (void*)(orig & (~1));
28893         orig_conv.is_owned = false;
28894         LDKRouteHint ret_var = RouteHint_clone(&orig_conv);
28895         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28896         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28897         uint64_t ret_ref = (uint64_t)ret_var.inner;
28898         if (ret_var.is_owned) {
28899                 ret_ref |= 1;
28900         }
28901         return ret_ref;
28902 }
28903
28904 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1hash(JNIEnv *env, jclass clz, int64_t o) {
28905         LDKRouteHint o_conv;
28906         o_conv.inner = (void*)(o & (~1));
28907         o_conv.is_owned = false;
28908         int64_t ret_val = RouteHint_hash(&o_conv);
28909         return ret_val;
28910 }
28911
28912 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHint_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
28913         LDKRouteHint a_conv;
28914         a_conv.inner = (void*)(a & (~1));
28915         a_conv.is_owned = false;
28916         LDKRouteHint b_conv;
28917         b_conv.inner = (void*)(b & (~1));
28918         b_conv.is_owned = false;
28919         jboolean ret_val = RouteHint_eq(&a_conv, &b_conv);
28920         return ret_val;
28921 }
28922
28923 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28924         LDKRouteHintHop this_obj_conv;
28925         this_obj_conv.inner = (void*)(this_obj & (~1));
28926         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28927         RouteHintHop_free(this_obj_conv);
28928 }
28929
28930 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1src_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
28931         LDKRouteHintHop this_ptr_conv;
28932         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28933         this_ptr_conv.is_owned = false;
28934         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
28935         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RouteHintHop_get_src_node_id(&this_ptr_conv).compressed_form);
28936         return ret_arr;
28937 }
28938
28939 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1src_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28940         LDKRouteHintHop this_ptr_conv;
28941         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28942         this_ptr_conv.is_owned = false;
28943         LDKPublicKey val_ref;
28944         CHECK((*env)->GetArrayLength(env, val) == 33);
28945         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
28946         RouteHintHop_set_src_node_id(&this_ptr_conv, val_ref);
28947 }
28948
28949 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
28950         LDKRouteHintHop this_ptr_conv;
28951         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28952         this_ptr_conv.is_owned = false;
28953         int64_t ret_val = RouteHintHop_get_short_channel_id(&this_ptr_conv);
28954         return ret_val;
28955 }
28956
28957 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28958         LDKRouteHintHop this_ptr_conv;
28959         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28960         this_ptr_conv.is_owned = false;
28961         RouteHintHop_set_short_channel_id(&this_ptr_conv, val);
28962 }
28963
28964 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
28965         LDKRouteHintHop this_ptr_conv;
28966         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28967         this_ptr_conv.is_owned = false;
28968         LDKRoutingFees ret_var = RouteHintHop_get_fees(&this_ptr_conv);
28969         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28970         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28971         uint64_t ret_ref = (uint64_t)ret_var.inner;
28972         if (ret_var.is_owned) {
28973                 ret_ref |= 1;
28974         }
28975         return ret_ref;
28976 }
28977
28978 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1fees(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28979         LDKRouteHintHop this_ptr_conv;
28980         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28981         this_ptr_conv.is_owned = false;
28982         LDKRoutingFees val_conv;
28983         val_conv.inner = (void*)(val & (~1));
28984         val_conv.is_owned = (val & 1) || (val == 0);
28985         val_conv = RoutingFees_clone(&val_conv);
28986         RouteHintHop_set_fees(&this_ptr_conv, val_conv);
28987 }
28988
28989 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
28990         LDKRouteHintHop this_ptr_conv;
28991         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28992         this_ptr_conv.is_owned = false;
28993         int16_t ret_val = RouteHintHop_get_cltv_expiry_delta(&this_ptr_conv);
28994         return ret_val;
28995 }
28996
28997 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
28998         LDKRouteHintHop this_ptr_conv;
28999         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29000         this_ptr_conv.is_owned = false;
29001         RouteHintHop_set_cltv_expiry_delta(&this_ptr_conv, val);
29002 }
29003
29004 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
29005         LDKRouteHintHop this_ptr_conv;
29006         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29007         this_ptr_conv.is_owned = false;
29008         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
29009         *ret_copy = RouteHintHop_get_htlc_minimum_msat(&this_ptr_conv);
29010         uint64_t ret_ref = (uint64_t)ret_copy;
29011         return ret_ref;
29012 }
29013
29014 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29015         LDKRouteHintHop this_ptr_conv;
29016         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29017         this_ptr_conv.is_owned = false;
29018         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
29019         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1));
29020         RouteHintHop_set_htlc_minimum_msat(&this_ptr_conv, val_conv);
29021 }
29022
29023 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
29024         LDKRouteHintHop this_ptr_conv;
29025         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29026         this_ptr_conv.is_owned = false;
29027         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
29028         *ret_copy = RouteHintHop_get_htlc_maximum_msat(&this_ptr_conv);
29029         uint64_t ret_ref = (uint64_t)ret_copy;
29030         return ret_ref;
29031 }
29032
29033 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29034         LDKRouteHintHop this_ptr_conv;
29035         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29036         this_ptr_conv.is_owned = false;
29037         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
29038         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1));
29039         RouteHintHop_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
29040 }
29041
29042 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) {
29043         LDKPublicKey src_node_id_arg_ref;
29044         CHECK((*env)->GetArrayLength(env, src_node_id_arg) == 33);
29045         (*env)->GetByteArrayRegion(env, src_node_id_arg, 0, 33, src_node_id_arg_ref.compressed_form);
29046         LDKRoutingFees fees_arg_conv;
29047         fees_arg_conv.inner = (void*)(fees_arg & (~1));
29048         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
29049         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
29050         LDKCOption_u64Z htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)htlc_minimum_msat_arg) & ~1);
29051         htlc_minimum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)htlc_minimum_msat_arg) & ~1));
29052         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)htlc_maximum_msat_arg) & ~1);
29053         htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)htlc_maximum_msat_arg) & ~1));
29054         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);
29055         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29056         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29057         uint64_t ret_ref = (uint64_t)ret_var.inner;
29058         if (ret_var.is_owned) {
29059                 ret_ref |= 1;
29060         }
29061         return ret_ref;
29062 }
29063
29064 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29065         LDKRouteHintHop orig_conv;
29066         orig_conv.inner = (void*)(orig & (~1));
29067         orig_conv.is_owned = false;
29068         LDKRouteHintHop ret_var = RouteHintHop_clone(&orig_conv);
29069         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29070         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29071         uint64_t ret_ref = (uint64_t)ret_var.inner;
29072         if (ret_var.is_owned) {
29073                 ret_ref |= 1;
29074         }
29075         return ret_ref;
29076 }
29077
29078 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1hash(JNIEnv *env, jclass clz, int64_t o) {
29079         LDKRouteHintHop o_conv;
29080         o_conv.inner = (void*)(o & (~1));
29081         o_conv.is_owned = false;
29082         int64_t ret_val = RouteHintHop_hash(&o_conv);
29083         return ret_val;
29084 }
29085
29086 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
29087         LDKRouteHintHop a_conv;
29088         a_conv.inner = (void*)(a & (~1));
29089         a_conv.is_owned = false;
29090         LDKRouteHintHop b_conv;
29091         b_conv.inner = (void*)(b & (~1));
29092         b_conv.is_owned = false;
29093         jboolean ret_val = RouteHintHop_eq(&a_conv, &b_conv);
29094         return ret_val;
29095 }
29096
29097 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_get_1keysend_1route(JNIEnv *env, jclass clz, int8_tArray our_node_pubkey, 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, int64_t scorer) {
29098         LDKPublicKey our_node_pubkey_ref;
29099         CHECK((*env)->GetArrayLength(env, our_node_pubkey) == 33);
29100         (*env)->GetByteArrayRegion(env, our_node_pubkey, 0, 33, our_node_pubkey_ref.compressed_form);
29101         LDKNetworkGraph network_conv;
29102         network_conv.inner = (void*)(network & (~1));
29103         network_conv.is_owned = false;
29104         LDKPublicKey payee_ref;
29105         CHECK((*env)->GetArrayLength(env, payee) == 33);
29106         (*env)->GetByteArrayRegion(env, payee, 0, 33, payee_ref.compressed_form);
29107         LDKCVec_ChannelDetailsZ first_hops_constr;
29108         LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
29109         if (first_hops != NULL) {
29110                 first_hops_constr.datalen = (*env)->GetArrayLength(env, first_hops);
29111                 if (first_hops_constr.datalen > 0)
29112                         first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
29113                 else
29114                         first_hops_constr.data = NULL;
29115                 int64_t* first_hops_vals = (*env)->GetLongArrayElements (env, first_hops, NULL);
29116                 for (size_t q = 0; q < first_hops_constr.datalen; q++) {
29117                         int64_t first_hops_conv_16 = first_hops_vals[q];
29118                         LDKChannelDetails first_hops_conv_16_conv;
29119                         first_hops_conv_16_conv.inner = (void*)(first_hops_conv_16 & (~1));
29120                         first_hops_conv_16_conv.is_owned = (first_hops_conv_16 & 1) || (first_hops_conv_16 == 0);
29121                         first_hops_constr.data[q] = first_hops_conv_16_conv;
29122                 }
29123                 (*env)->ReleaseLongArrayElements(env, first_hops, first_hops_vals, 0);
29124                 first_hops_ptr = &first_hops_constr;
29125         }
29126         LDKCVec_RouteHintZ last_hops_constr;
29127         last_hops_constr.datalen = (*env)->GetArrayLength(env, last_hops);
29128         if (last_hops_constr.datalen > 0)
29129                 last_hops_constr.data = MALLOC(last_hops_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
29130         else
29131                 last_hops_constr.data = NULL;
29132         int64_t* last_hops_vals = (*env)->GetLongArrayElements (env, last_hops, NULL);
29133         for (size_t l = 0; l < last_hops_constr.datalen; l++) {
29134                 int64_t last_hops_conv_11 = last_hops_vals[l];
29135                 LDKRouteHint last_hops_conv_11_conv;
29136                 last_hops_conv_11_conv.inner = (void*)(last_hops_conv_11 & (~1));
29137                 last_hops_conv_11_conv.is_owned = (last_hops_conv_11 & 1) || (last_hops_conv_11 == 0);
29138                 last_hops_conv_11_conv = RouteHint_clone(&last_hops_conv_11_conv);
29139                 last_hops_constr.data[l] = last_hops_conv_11_conv;
29140         }
29141         (*env)->ReleaseLongArrayElements(env, last_hops, last_hops_vals, 0);
29142         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
29143         if (logger_conv.free == LDKLogger_JCalls_free) {
29144                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29145                 LDKLogger_JCalls_cloned(&logger_conv);
29146         }
29147         LDKScore* scorer_conv = (LDKScore*)(((uint64_t)scorer) & ~1);
29148         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
29149         *ret_conv = get_keysend_route(our_node_pubkey_ref, &network_conv, payee_ref, first_hops_ptr, last_hops_constr, final_value_msat, final_cltv, logger_conv, scorer_conv);
29150         if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
29151         return (uint64_t)ret_conv;
29152 }
29153
29154 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_get_1route(JNIEnv *env, jclass clz, int8_tArray our_node_pubkey, 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, int64_t scorer) {
29155         LDKPublicKey our_node_pubkey_ref;
29156         CHECK((*env)->GetArrayLength(env, our_node_pubkey) == 33);
29157         (*env)->GetByteArrayRegion(env, our_node_pubkey, 0, 33, our_node_pubkey_ref.compressed_form);
29158         LDKNetworkGraph network_conv;
29159         network_conv.inner = (void*)(network & (~1));
29160         network_conv.is_owned = false;
29161         LDKPublicKey payee_ref;
29162         CHECK((*env)->GetArrayLength(env, payee) == 33);
29163         (*env)->GetByteArrayRegion(env, payee, 0, 33, payee_ref.compressed_form);
29164         LDKInvoiceFeatures payee_features_conv;
29165         payee_features_conv.inner = (void*)(payee_features & (~1));
29166         payee_features_conv.is_owned = (payee_features & 1) || (payee_features == 0);
29167         payee_features_conv = InvoiceFeatures_clone(&payee_features_conv);
29168         LDKCVec_ChannelDetailsZ first_hops_constr;
29169         LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
29170         if (first_hops != NULL) {
29171                 first_hops_constr.datalen = (*env)->GetArrayLength(env, first_hops);
29172                 if (first_hops_constr.datalen > 0)
29173                         first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
29174                 else
29175                         first_hops_constr.data = NULL;
29176                 int64_t* first_hops_vals = (*env)->GetLongArrayElements (env, first_hops, NULL);
29177                 for (size_t q = 0; q < first_hops_constr.datalen; q++) {
29178                         int64_t first_hops_conv_16 = first_hops_vals[q];
29179                         LDKChannelDetails first_hops_conv_16_conv;
29180                         first_hops_conv_16_conv.inner = (void*)(first_hops_conv_16 & (~1));
29181                         first_hops_conv_16_conv.is_owned = (first_hops_conv_16 & 1) || (first_hops_conv_16 == 0);
29182                         first_hops_constr.data[q] = first_hops_conv_16_conv;
29183                 }
29184                 (*env)->ReleaseLongArrayElements(env, first_hops, first_hops_vals, 0);
29185                 first_hops_ptr = &first_hops_constr;
29186         }
29187         LDKCVec_RouteHintZ last_hops_constr;
29188         last_hops_constr.datalen = (*env)->GetArrayLength(env, last_hops);
29189         if (last_hops_constr.datalen > 0)
29190                 last_hops_constr.data = MALLOC(last_hops_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
29191         else
29192                 last_hops_constr.data = NULL;
29193         int64_t* last_hops_vals = (*env)->GetLongArrayElements (env, last_hops, NULL);
29194         for (size_t l = 0; l < last_hops_constr.datalen; l++) {
29195                 int64_t last_hops_conv_11 = last_hops_vals[l];
29196                 LDKRouteHint last_hops_conv_11_conv;
29197                 last_hops_conv_11_conv.inner = (void*)(last_hops_conv_11 & (~1));
29198                 last_hops_conv_11_conv.is_owned = (last_hops_conv_11 & 1) || (last_hops_conv_11 == 0);
29199                 last_hops_conv_11_conv = RouteHint_clone(&last_hops_conv_11_conv);
29200                 last_hops_constr.data[l] = last_hops_conv_11_conv;
29201         }
29202         (*env)->ReleaseLongArrayElements(env, last_hops, last_hops_vals, 0);
29203         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
29204         if (logger_conv.free == LDKLogger_JCalls_free) {
29205                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29206                 LDKLogger_JCalls_cloned(&logger_conv);
29207         }
29208         LDKScore* scorer_conv = (LDKScore*)(((uint64_t)scorer) & ~1);
29209         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
29210         *ret_conv = get_route(our_node_pubkey_ref, &network_conv, payee_ref, payee_features_conv, first_hops_ptr, last_hops_constr, final_value_msat, final_cltv, logger_conv, scorer_conv);
29211         if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
29212         return (uint64_t)ret_conv;
29213 }
29214
29215 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Scorer_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29216         LDKScorer this_obj_conv;
29217         this_obj_conv.inner = (void*)(this_obj & (~1));
29218         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29219         Scorer_free(this_obj_conv);
29220 }
29221
29222 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Scorer_1new(JNIEnv *env, jclass clz, int64_t base_penalty_msat) {
29223         LDKScorer ret_var = Scorer_new(base_penalty_msat);
29224         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29225         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29226         uint64_t ret_ref = (uint64_t)ret_var.inner;
29227         if (ret_var.is_owned) {
29228                 ret_ref |= 1;
29229         }
29230         return ret_ref;
29231 }
29232
29233 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Scorer_1default(JNIEnv *env, jclass clz) {
29234         LDKScorer ret_var = Scorer_default();
29235         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29236         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29237         uint64_t ret_ref = (uint64_t)ret_var.inner;
29238         if (ret_var.is_owned) {
29239                 ret_ref |= 1;
29240         }
29241         return ret_ref;
29242 }
29243
29244 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Scorer_1as_1Score(JNIEnv *env, jclass clz, int64_t this_arg) {
29245         LDKScorer this_arg_conv;
29246         this_arg_conv.inner = (void*)(this_arg & (~1));
29247         this_arg_conv.is_owned = false;
29248         LDKScore* ret_ret =MALLOC(sizeof(LDKScore), "LDKScore");
29249         *ret_ret = Scorer_as_Score(&this_arg_conv);
29250         return (uint64_t)ret_ret;
29251 }
29252
29253 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29254         LDKFilesystemPersister this_obj_conv;
29255         this_obj_conv.inner = (void*)(this_obj & (~1));
29256         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29257         FilesystemPersister_free(this_obj_conv);
29258 }
29259
29260 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1new(JNIEnv *env, jclass clz, jstring path_to_channel_data) {
29261         LDKStr path_to_channel_data_conv = java_to_owned_str(env, path_to_channel_data);
29262         LDKFilesystemPersister ret_var = FilesystemPersister_new(path_to_channel_data_conv);
29263         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29264         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29265         uint64_t ret_ref = (uint64_t)ret_var.inner;
29266         if (ret_var.is_owned) {
29267                 ret_ref |= 1;
29268         }
29269         return ret_ref;
29270 }
29271
29272 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1get_1data_1dir(JNIEnv *env, jclass clz, int64_t this_arg) {
29273         LDKFilesystemPersister this_arg_conv;
29274         this_arg_conv.inner = (void*)(this_arg & (~1));
29275         this_arg_conv.is_owned = false;
29276         LDKStr ret_str = FilesystemPersister_get_data_dir(&this_arg_conv);
29277         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
29278         Str_free(ret_str);
29279         return ret_conv;
29280 }
29281
29282 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1persist_1manager(JNIEnv *env, jclass clz, jstring data_dir, int64_t manager) {
29283         LDKStr data_dir_conv = java_to_owned_str(env, data_dir);
29284         LDKChannelManager manager_conv;
29285         manager_conv.inner = (void*)(manager & (~1));
29286         manager_conv.is_owned = false;
29287         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
29288         *ret_conv = FilesystemPersister_persist_manager(data_dir_conv, &manager_conv);
29289         return (uint64_t)ret_conv;
29290 }
29291
29292 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1read_1channelmonitors(JNIEnv *env, jclass clz, int64_t this_arg, int64_t keys_manager) {
29293         LDKFilesystemPersister this_arg_conv;
29294         this_arg_conv.inner = (void*)(this_arg & (~1));
29295         this_arg_conv.is_owned = false;
29296         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
29297         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
29298                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29299                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
29300         }
29301         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
29302         *ret_conv = FilesystemPersister_read_channelmonitors(&this_arg_conv, keys_manager_conv);
29303         return (uint64_t)ret_conv;
29304 }
29305
29306 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1as_1Persist(JNIEnv *env, jclass clz, int64_t this_arg) {
29307         LDKFilesystemPersister this_arg_conv;
29308         this_arg_conv.inner = (void*)(this_arg & (~1));
29309         this_arg_conv.is_owned = false;
29310         LDKPersist* ret_ret =MALLOC(sizeof(LDKPersist), "LDKPersist");
29311         *ret_ret = FilesystemPersister_as_Persist(&this_arg_conv);
29312         return (uint64_t)ret_ret;
29313 }
29314
29315 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29316         LDKBackgroundProcessor this_obj_conv;
29317         this_obj_conv.inner = (void*)(this_obj & (~1));
29318         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29319         BackgroundProcessor_free(this_obj_conv);
29320 }
29321
29322 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerPersister_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
29323         if ((this_ptr & 1) != 0) return;
29324         LDKChannelManagerPersister this_ptr_conv = *(LDKChannelManagerPersister*)(((uint64_t)this_ptr) & ~1);
29325         FREE((void*)this_ptr);
29326         ChannelManagerPersister_free(this_ptr_conv);
29327 }
29328
29329 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) {
29330         LDKChannelManagerPersister persister_conv = *(LDKChannelManagerPersister*)(((uint64_t)persister) & ~1);
29331         if (persister_conv.free == LDKChannelManagerPersister_JCalls_free) {
29332                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29333                 LDKChannelManagerPersister_JCalls_cloned(&persister_conv);
29334         }
29335         LDKEventHandler event_handler_conv = *(LDKEventHandler*)(((uint64_t)event_handler) & ~1);
29336         if (event_handler_conv.free == LDKEventHandler_JCalls_free) {
29337                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29338                 LDKEventHandler_JCalls_cloned(&event_handler_conv);
29339         }
29340         LDKChainMonitor chain_monitor_conv;
29341         chain_monitor_conv.inner = (void*)(chain_monitor & (~1));
29342         chain_monitor_conv.is_owned = false;
29343         LDKChannelManager channel_manager_conv;
29344         channel_manager_conv.inner = (void*)(channel_manager & (~1));
29345         channel_manager_conv.is_owned = false;
29346         LDKNetGraphMsgHandler net_graph_msg_handler_conv;
29347         net_graph_msg_handler_conv.inner = (void*)(net_graph_msg_handler & (~1));
29348         net_graph_msg_handler_conv.is_owned = (net_graph_msg_handler & 1) || (net_graph_msg_handler == 0);
29349         LDKPeerManager peer_manager_conv;
29350         peer_manager_conv.inner = (void*)(peer_manager & (~1));
29351         peer_manager_conv.is_owned = false;
29352         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
29353         if (logger_conv.free == LDKLogger_JCalls_free) {
29354                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29355                 LDKLogger_JCalls_cloned(&logger_conv);
29356         }
29357         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);
29358         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29359         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29360         uint64_t ret_ref = (uint64_t)ret_var.inner;
29361         if (ret_var.is_owned) {
29362                 ret_ref |= 1;
29363         }
29364         return ret_ref;
29365 }
29366
29367 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1join(JNIEnv *env, jclass clz, int64_t this_arg) {
29368         LDKBackgroundProcessor this_arg_conv;
29369         this_arg_conv.inner = (void*)(this_arg & (~1));
29370         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
29371         // Warning: we need a move here but no clone is available for LDKBackgroundProcessor
29372         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
29373         *ret_conv = BackgroundProcessor_join(this_arg_conv);
29374         return (uint64_t)ret_conv;
29375 }
29376
29377 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1stop(JNIEnv *env, jclass clz, int64_t this_arg) {
29378         LDKBackgroundProcessor this_arg_conv;
29379         this_arg_conv.inner = (void*)(this_arg & (~1));
29380         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
29381         // Warning: we need a move here but no clone is available for LDKBackgroundProcessor
29382         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
29383         *ret_conv = BackgroundProcessor_stop(this_arg_conv);
29384         return (uint64_t)ret_conv;
29385 }
29386
29387 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_check_1platform(JNIEnv *env, jclass clz) {
29388         check_platform();
29389 }
29390
29391 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Invoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29392         LDKInvoice this_obj_conv;
29393         this_obj_conv.inner = (void*)(this_obj & (~1));
29394         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29395         Invoice_free(this_obj_conv);
29396 }
29397
29398 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Invoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
29399         LDKInvoice a_conv;
29400         a_conv.inner = (void*)(a & (~1));
29401         a_conv.is_owned = false;
29402         LDKInvoice b_conv;
29403         b_conv.inner = (void*)(b & (~1));
29404         b_conv.is_owned = false;
29405         jboolean ret_val = Invoice_eq(&a_conv, &b_conv);
29406         return ret_val;
29407 }
29408
29409 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29410         LDKInvoice orig_conv;
29411         orig_conv.inner = (void*)(orig & (~1));
29412         orig_conv.is_owned = false;
29413         LDKInvoice ret_var = Invoice_clone(&orig_conv);
29414         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29415         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29416         uint64_t ret_ref = (uint64_t)ret_var.inner;
29417         if (ret_var.is_owned) {
29418                 ret_ref |= 1;
29419         }
29420         return ret_ref;
29421 }
29422
29423 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29424         LDKSignedRawInvoice this_obj_conv;
29425         this_obj_conv.inner = (void*)(this_obj & (~1));
29426         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29427         SignedRawInvoice_free(this_obj_conv);
29428 }
29429
29430 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
29431         LDKSignedRawInvoice a_conv;
29432         a_conv.inner = (void*)(a & (~1));
29433         a_conv.is_owned = false;
29434         LDKSignedRawInvoice b_conv;
29435         b_conv.inner = (void*)(b & (~1));
29436         b_conv.is_owned = false;
29437         jboolean ret_val = SignedRawInvoice_eq(&a_conv, &b_conv);
29438         return ret_val;
29439 }
29440
29441 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29442         LDKSignedRawInvoice orig_conv;
29443         orig_conv.inner = (void*)(orig & (~1));
29444         orig_conv.is_owned = false;
29445         LDKSignedRawInvoice ret_var = SignedRawInvoice_clone(&orig_conv);
29446         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29447         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29448         uint64_t ret_ref = (uint64_t)ret_var.inner;
29449         if (ret_var.is_owned) {
29450                 ret_ref |= 1;
29451         }
29452         return ret_ref;
29453 }
29454
29455 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawInvoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29456         LDKRawInvoice this_obj_conv;
29457         this_obj_conv.inner = (void*)(this_obj & (~1));
29458         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29459         RawInvoice_free(this_obj_conv);
29460 }
29461
29462 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1get_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
29463         LDKRawInvoice this_ptr_conv;
29464         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29465         this_ptr_conv.is_owned = false;
29466         LDKRawDataPart ret_var = RawInvoice_get_data(&this_ptr_conv);
29467         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29468         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29469         uint64_t ret_ref = (uint64_t)ret_var.inner;
29470         if (ret_var.is_owned) {
29471                 ret_ref |= 1;
29472         }
29473         return ret_ref;
29474 }
29475
29476 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawInvoice_1set_1data(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29477         LDKRawInvoice this_ptr_conv;
29478         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29479         this_ptr_conv.is_owned = false;
29480         LDKRawDataPart val_conv;
29481         val_conv.inner = (void*)(val & (~1));
29482         val_conv.is_owned = (val & 1) || (val == 0);
29483         val_conv = RawDataPart_clone(&val_conv);
29484         RawInvoice_set_data(&this_ptr_conv, val_conv);
29485 }
29486
29487 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RawInvoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
29488         LDKRawInvoice a_conv;
29489         a_conv.inner = (void*)(a & (~1));
29490         a_conv.is_owned = false;
29491         LDKRawInvoice b_conv;
29492         b_conv.inner = (void*)(b & (~1));
29493         b_conv.is_owned = false;
29494         jboolean ret_val = RawInvoice_eq(&a_conv, &b_conv);
29495         return ret_val;
29496 }
29497
29498 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29499         LDKRawInvoice orig_conv;
29500         orig_conv.inner = (void*)(orig & (~1));
29501         orig_conv.is_owned = false;
29502         LDKRawInvoice ret_var = RawInvoice_clone(&orig_conv);
29503         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29504         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29505         uint64_t ret_ref = (uint64_t)ret_var.inner;
29506         if (ret_var.is_owned) {
29507                 ret_ref |= 1;
29508         }
29509         return ret_ref;
29510 }
29511
29512 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawDataPart_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29513         LDKRawDataPart this_obj_conv;
29514         this_obj_conv.inner = (void*)(this_obj & (~1));
29515         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29516         RawDataPart_free(this_obj_conv);
29517 }
29518
29519 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
29520         LDKRawDataPart this_ptr_conv;
29521         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29522         this_ptr_conv.is_owned = false;
29523         LDKPositiveTimestamp ret_var = RawDataPart_get_timestamp(&this_ptr_conv);
29524         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29525         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29526         uint64_t ret_ref = (uint64_t)ret_var.inner;
29527         if (ret_var.is_owned) {
29528                 ret_ref |= 1;
29529         }
29530         return ret_ref;
29531 }
29532
29533 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawDataPart_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29534         LDKRawDataPart this_ptr_conv;
29535         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29536         this_ptr_conv.is_owned = false;
29537         LDKPositiveTimestamp val_conv;
29538         val_conv.inner = (void*)(val & (~1));
29539         val_conv.is_owned = (val & 1) || (val == 0);
29540         val_conv = PositiveTimestamp_clone(&val_conv);
29541         RawDataPart_set_timestamp(&this_ptr_conv, val_conv);
29542 }
29543
29544 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RawDataPart_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
29545         LDKRawDataPart a_conv;
29546         a_conv.inner = (void*)(a & (~1));
29547         a_conv.is_owned = false;
29548         LDKRawDataPart b_conv;
29549         b_conv.inner = (void*)(b & (~1));
29550         b_conv.is_owned = false;
29551         jboolean ret_val = RawDataPart_eq(&a_conv, &b_conv);
29552         return ret_val;
29553 }
29554
29555 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29556         LDKRawDataPart orig_conv;
29557         orig_conv.inner = (void*)(orig & (~1));
29558         orig_conv.is_owned = false;
29559         LDKRawDataPart ret_var = RawDataPart_clone(&orig_conv);
29560         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29561         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29562         uint64_t ret_ref = (uint64_t)ret_var.inner;
29563         if (ret_var.is_owned) {
29564                 ret_ref |= 1;
29565         }
29566         return ret_ref;
29567 }
29568
29569 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29570         LDKPositiveTimestamp this_obj_conv;
29571         this_obj_conv.inner = (void*)(this_obj & (~1));
29572         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29573         PositiveTimestamp_free(this_obj_conv);
29574 }
29575
29576 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
29577         LDKPositiveTimestamp a_conv;
29578         a_conv.inner = (void*)(a & (~1));
29579         a_conv.is_owned = false;
29580         LDKPositiveTimestamp b_conv;
29581         b_conv.inner = (void*)(b & (~1));
29582         b_conv.is_owned = false;
29583         jboolean ret_val = PositiveTimestamp_eq(&a_conv, &b_conv);
29584         return ret_val;
29585 }
29586
29587 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29588         LDKPositiveTimestamp orig_conv;
29589         orig_conv.inner = (void*)(orig & (~1));
29590         orig_conv.is_owned = false;
29591         LDKPositiveTimestamp ret_var = PositiveTimestamp_clone(&orig_conv);
29592         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29593         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29594         uint64_t ret_ref = (uint64_t)ret_var.inner;
29595         if (ret_var.is_owned) {
29596                 ret_ref |= 1;
29597         }
29598         return ret_ref;
29599 }
29600
29601 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29602         LDKSiPrefix* orig_conv = (LDKSiPrefix*)(orig & ~1);
29603         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_clone(orig_conv));
29604         return ret_conv;
29605 }
29606
29607 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1milli(JNIEnv *env, jclass clz) {
29608         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_milli());
29609         return ret_conv;
29610 }
29611
29612 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1micro(JNIEnv *env, jclass clz) {
29613         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_micro());
29614         return ret_conv;
29615 }
29616
29617 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1nano(JNIEnv *env, jclass clz) {
29618         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_nano());
29619         return ret_conv;
29620 }
29621
29622 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1pico(JNIEnv *env, jclass clz) {
29623         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_pico());
29624         return ret_conv;
29625 }
29626
29627 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SiPrefix_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
29628         LDKSiPrefix* a_conv = (LDKSiPrefix*)(a & ~1);
29629         LDKSiPrefix* b_conv = (LDKSiPrefix*)(b & ~1);
29630         jboolean ret_val = SiPrefix_eq(a_conv, b_conv);
29631         return ret_val;
29632 }
29633
29634 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SiPrefix_1multiplier(JNIEnv *env, jclass clz, int64_t this_arg) {
29635         LDKSiPrefix* this_arg_conv = (LDKSiPrefix*)(this_arg & ~1);
29636         int64_t ret_val = SiPrefix_multiplier(this_arg_conv);
29637         return ret_val;
29638 }
29639
29640 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29641         LDKCurrency* orig_conv = (LDKCurrency*)(orig & ~1);
29642         jclass ret_conv = LDKCurrency_to_java(env, Currency_clone(orig_conv));
29643         return ret_conv;
29644 }
29645
29646 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1bitcoin(JNIEnv *env, jclass clz) {
29647         jclass ret_conv = LDKCurrency_to_java(env, Currency_bitcoin());
29648         return ret_conv;
29649 }
29650
29651 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1bitcoin_1testnet(JNIEnv *env, jclass clz) {
29652         jclass ret_conv = LDKCurrency_to_java(env, Currency_bitcoin_testnet());
29653         return ret_conv;
29654 }
29655
29656 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1regtest(JNIEnv *env, jclass clz) {
29657         jclass ret_conv = LDKCurrency_to_java(env, Currency_regtest());
29658         return ret_conv;
29659 }
29660
29661 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1simnet(JNIEnv *env, jclass clz) {
29662         jclass ret_conv = LDKCurrency_to_java(env, Currency_simnet());
29663         return ret_conv;
29664 }
29665
29666 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1signet(JNIEnv *env, jclass clz) {
29667         jclass ret_conv = LDKCurrency_to_java(env, Currency_signet());
29668         return ret_conv;
29669 }
29670
29671 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Currency_1hash(JNIEnv *env, jclass clz, int64_t o) {
29672         LDKCurrency* o_conv = (LDKCurrency*)(o & ~1);
29673         int64_t ret_val = Currency_hash(o_conv);
29674         return ret_val;
29675 }
29676
29677 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Currency_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
29678         LDKCurrency* a_conv = (LDKCurrency*)(a & ~1);
29679         LDKCurrency* b_conv = (LDKCurrency*)(b & ~1);
29680         jboolean ret_val = Currency_eq(a_conv, b_conv);
29681         return ret_val;
29682 }
29683
29684 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Sha256_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29685         LDKSha256 this_obj_conv;
29686         this_obj_conv.inner = (void*)(this_obj & (~1));
29687         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29688         Sha256_free(this_obj_conv);
29689 }
29690
29691 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sha256_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29692         LDKSha256 orig_conv;
29693         orig_conv.inner = (void*)(orig & (~1));
29694         orig_conv.is_owned = false;
29695         LDKSha256 ret_var = Sha256_clone(&orig_conv);
29696         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29697         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29698         uint64_t ret_ref = (uint64_t)ret_var.inner;
29699         if (ret_var.is_owned) {
29700                 ret_ref |= 1;
29701         }
29702         return ret_ref;
29703 }
29704
29705 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sha256_1hash(JNIEnv *env, jclass clz, int64_t o) {
29706         LDKSha256 o_conv;
29707         o_conv.inner = (void*)(o & (~1));
29708         o_conv.is_owned = false;
29709         int64_t ret_val = Sha256_hash(&o_conv);
29710         return ret_val;
29711 }
29712
29713 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Sha256_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
29714         LDKSha256 a_conv;
29715         a_conv.inner = (void*)(a & (~1));
29716         a_conv.is_owned = false;
29717         LDKSha256 b_conv;
29718         b_conv.inner = (void*)(b & (~1));
29719         b_conv.is_owned = false;
29720         jboolean ret_val = Sha256_eq(&a_conv, &b_conv);
29721         return ret_val;
29722 }
29723
29724 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Description_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29725         LDKDescription this_obj_conv;
29726         this_obj_conv.inner = (void*)(this_obj & (~1));
29727         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29728         Description_free(this_obj_conv);
29729 }
29730
29731 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29732         LDKDescription orig_conv;
29733         orig_conv.inner = (void*)(orig & (~1));
29734         orig_conv.is_owned = false;
29735         LDKDescription ret_var = Description_clone(&orig_conv);
29736         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29737         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29738         uint64_t ret_ref = (uint64_t)ret_var.inner;
29739         if (ret_var.is_owned) {
29740                 ret_ref |= 1;
29741         }
29742         return ret_ref;
29743 }
29744
29745 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1hash(JNIEnv *env, jclass clz, int64_t o) {
29746         LDKDescription o_conv;
29747         o_conv.inner = (void*)(o & (~1));
29748         o_conv.is_owned = false;
29749         int64_t ret_val = Description_hash(&o_conv);
29750         return ret_val;
29751 }
29752
29753 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Description_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
29754         LDKDescription a_conv;
29755         a_conv.inner = (void*)(a & (~1));
29756         a_conv.is_owned = false;
29757         LDKDescription b_conv;
29758         b_conv.inner = (void*)(b & (~1));
29759         b_conv.is_owned = false;
29760         jboolean ret_val = Description_eq(&a_conv, &b_conv);
29761         return ret_val;
29762 }
29763
29764 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29765         LDKPayeePubKey this_obj_conv;
29766         this_obj_conv.inner = (void*)(this_obj & (~1));
29767         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29768         PayeePubKey_free(this_obj_conv);
29769 }
29770
29771 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29772         LDKPayeePubKey orig_conv;
29773         orig_conv.inner = (void*)(orig & (~1));
29774         orig_conv.is_owned = false;
29775         LDKPayeePubKey ret_var = PayeePubKey_clone(&orig_conv);
29776         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29777         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29778         uint64_t ret_ref = (uint64_t)ret_var.inner;
29779         if (ret_var.is_owned) {
29780                 ret_ref |= 1;
29781         }
29782         return ret_ref;
29783 }
29784
29785 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1hash(JNIEnv *env, jclass clz, int64_t o) {
29786         LDKPayeePubKey o_conv;
29787         o_conv.inner = (void*)(o & (~1));
29788         o_conv.is_owned = false;
29789         int64_t ret_val = PayeePubKey_hash(&o_conv);
29790         return ret_val;
29791 }
29792
29793 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
29794         LDKPayeePubKey a_conv;
29795         a_conv.inner = (void*)(a & (~1));
29796         a_conv.is_owned = false;
29797         LDKPayeePubKey b_conv;
29798         b_conv.inner = (void*)(b & (~1));
29799         b_conv.is_owned = false;
29800         jboolean ret_val = PayeePubKey_eq(&a_conv, &b_conv);
29801         return ret_val;
29802 }
29803
29804 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29805         LDKExpiryTime this_obj_conv;
29806         this_obj_conv.inner = (void*)(this_obj & (~1));
29807         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29808         ExpiryTime_free(this_obj_conv);
29809 }
29810
29811 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29812         LDKExpiryTime orig_conv;
29813         orig_conv.inner = (void*)(orig & (~1));
29814         orig_conv.is_owned = false;
29815         LDKExpiryTime ret_var = ExpiryTime_clone(&orig_conv);
29816         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29817         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29818         uint64_t ret_ref = (uint64_t)ret_var.inner;
29819         if (ret_var.is_owned) {
29820                 ret_ref |= 1;
29821         }
29822         return ret_ref;
29823 }
29824
29825 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1hash(JNIEnv *env, jclass clz, int64_t o) {
29826         LDKExpiryTime o_conv;
29827         o_conv.inner = (void*)(o & (~1));
29828         o_conv.is_owned = false;
29829         int64_t ret_val = ExpiryTime_hash(&o_conv);
29830         return ret_val;
29831 }
29832
29833 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
29834         LDKExpiryTime a_conv;
29835         a_conv.inner = (void*)(a & (~1));
29836         a_conv.is_owned = false;
29837         LDKExpiryTime b_conv;
29838         b_conv.inner = (void*)(b & (~1));
29839         b_conv.is_owned = false;
29840         jboolean ret_val = ExpiryTime_eq(&a_conv, &b_conv);
29841         return ret_val;
29842 }
29843
29844 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29845         LDKMinFinalCltvExpiry this_obj_conv;
29846         this_obj_conv.inner = (void*)(this_obj & (~1));
29847         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29848         MinFinalCltvExpiry_free(this_obj_conv);
29849 }
29850
29851 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29852         LDKMinFinalCltvExpiry orig_conv;
29853         orig_conv.inner = (void*)(orig & (~1));
29854         orig_conv.is_owned = false;
29855         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_clone(&orig_conv);
29856         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29857         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29858         uint64_t ret_ref = (uint64_t)ret_var.inner;
29859         if (ret_var.is_owned) {
29860                 ret_ref |= 1;
29861         }
29862         return ret_ref;
29863 }
29864
29865 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1hash(JNIEnv *env, jclass clz, int64_t o) {
29866         LDKMinFinalCltvExpiry o_conv;
29867         o_conv.inner = (void*)(o & (~1));
29868         o_conv.is_owned = false;
29869         int64_t ret_val = MinFinalCltvExpiry_hash(&o_conv);
29870         return ret_val;
29871 }
29872
29873 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
29874         LDKMinFinalCltvExpiry a_conv;
29875         a_conv.inner = (void*)(a & (~1));
29876         a_conv.is_owned = false;
29877         LDKMinFinalCltvExpiry b_conv;
29878         b_conv.inner = (void*)(b & (~1));
29879         b_conv.is_owned = false;
29880         jboolean ret_val = MinFinalCltvExpiry_eq(&a_conv, &b_conv);
29881         return ret_val;
29882 }
29883
29884 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Fallback_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
29885         if ((this_ptr & 1) != 0) return;
29886         LDKFallback this_ptr_conv = *(LDKFallback*)(((uint64_t)this_ptr) & ~1);
29887         FREE((void*)this_ptr);
29888         Fallback_free(this_ptr_conv);
29889 }
29890
29891 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29892         LDKFallback* orig_conv = (LDKFallback*)orig;
29893         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
29894         *ret_copy = Fallback_clone(orig_conv);
29895         uint64_t ret_ref = (uint64_t)ret_copy;
29896         return ret_ref;
29897 }
29898
29899 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1seg_1wit_1program(JNIEnv *env, jclass clz, int8_t version, int8_tArray program) {
29900         
29901         LDKCVec_u8Z program_ref;
29902         program_ref.datalen = (*env)->GetArrayLength(env, program);
29903         program_ref.data = MALLOC(program_ref.datalen, "LDKCVec_u8Z Bytes");
29904         (*env)->GetByteArrayRegion(env, program, 0, program_ref.datalen, program_ref.data);
29905         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
29906         *ret_copy = Fallback_seg_wit_program((LDKu5){ ._0 = version }, program_ref);
29907         uint64_t ret_ref = (uint64_t)ret_copy;
29908         return ret_ref;
29909 }
29910
29911 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1pub_1key_1hash(JNIEnv *env, jclass clz, int8_tArray a) {
29912         LDKTwentyBytes a_ref;
29913         CHECK((*env)->GetArrayLength(env, a) == 20);
29914         (*env)->GetByteArrayRegion(env, a, 0, 20, a_ref.data);
29915         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
29916         *ret_copy = Fallback_pub_key_hash(a_ref);
29917         uint64_t ret_ref = (uint64_t)ret_copy;
29918         return ret_ref;
29919 }
29920
29921 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1script_1hash(JNIEnv *env, jclass clz, int8_tArray a) {
29922         LDKTwentyBytes a_ref;
29923         CHECK((*env)->GetArrayLength(env, a) == 20);
29924         (*env)->GetByteArrayRegion(env, a, 0, 20, a_ref.data);
29925         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
29926         *ret_copy = Fallback_script_hash(a_ref);
29927         uint64_t ret_ref = (uint64_t)ret_copy;
29928         return ret_ref;
29929 }
29930
29931 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1hash(JNIEnv *env, jclass clz, int64_t o) {
29932         LDKFallback* o_conv = (LDKFallback*)o;
29933         int64_t ret_val = Fallback_hash(o_conv);
29934         return ret_val;
29935 }
29936
29937 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Fallback_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
29938         LDKFallback* a_conv = (LDKFallback*)a;
29939         LDKFallback* b_conv = (LDKFallback*)b;
29940         jboolean ret_val = Fallback_eq(a_conv, b_conv);
29941         return ret_val;
29942 }
29943
29944 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29945         LDKInvoiceSignature this_obj_conv;
29946         this_obj_conv.inner = (void*)(this_obj & (~1));
29947         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29948         InvoiceSignature_free(this_obj_conv);
29949 }
29950
29951 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29952         LDKInvoiceSignature orig_conv;
29953         orig_conv.inner = (void*)(orig & (~1));
29954         orig_conv.is_owned = false;
29955         LDKInvoiceSignature ret_var = InvoiceSignature_clone(&orig_conv);
29956         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29957         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29958         uint64_t ret_ref = (uint64_t)ret_var.inner;
29959         if (ret_var.is_owned) {
29960                 ret_ref |= 1;
29961         }
29962         return ret_ref;
29963 }
29964
29965 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
29966         LDKInvoiceSignature a_conv;
29967         a_conv.inner = (void*)(a & (~1));
29968         a_conv.is_owned = false;
29969         LDKInvoiceSignature b_conv;
29970         b_conv.inner = (void*)(b & (~1));
29971         b_conv.is_owned = false;
29972         jboolean ret_val = InvoiceSignature_eq(&a_conv, &b_conv);
29973         return ret_val;
29974 }
29975
29976 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29977         LDKPrivateRoute this_obj_conv;
29978         this_obj_conv.inner = (void*)(this_obj & (~1));
29979         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29980         PrivateRoute_free(this_obj_conv);
29981 }
29982
29983 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29984         LDKPrivateRoute orig_conv;
29985         orig_conv.inner = (void*)(orig & (~1));
29986         orig_conv.is_owned = false;
29987         LDKPrivateRoute ret_var = PrivateRoute_clone(&orig_conv);
29988         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29989         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29990         uint64_t ret_ref = (uint64_t)ret_var.inner;
29991         if (ret_var.is_owned) {
29992                 ret_ref |= 1;
29993         }
29994         return ret_ref;
29995 }
29996
29997 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1hash(JNIEnv *env, jclass clz, int64_t o) {
29998         LDKPrivateRoute o_conv;
29999         o_conv.inner = (void*)(o & (~1));
30000         o_conv.is_owned = false;
30001         int64_t ret_val = PrivateRoute_hash(&o_conv);
30002         return ret_val;
30003 }
30004
30005 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
30006         LDKPrivateRoute a_conv;
30007         a_conv.inner = (void*)(a & (~1));
30008         a_conv.is_owned = false;
30009         LDKPrivateRoute b_conv;
30010         b_conv.inner = (void*)(b & (~1));
30011         b_conv.is_owned = false;
30012         jboolean ret_val = PrivateRoute_eq(&a_conv, &b_conv);
30013         return ret_val;
30014 }
30015
30016 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1into_1parts(JNIEnv *env, jclass clz, int64_t this_arg) {
30017         LDKSignedRawInvoice this_arg_conv;
30018         this_arg_conv.inner = (void*)(this_arg & (~1));
30019         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
30020         this_arg_conv = SignedRawInvoice_clone(&this_arg_conv);
30021         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
30022         *ret_conv = SignedRawInvoice_into_parts(this_arg_conv);
30023         return ((uint64_t)ret_conv);
30024 }
30025
30026 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1raw_1invoice(JNIEnv *env, jclass clz, int64_t this_arg) {
30027         LDKSignedRawInvoice this_arg_conv;
30028         this_arg_conv.inner = (void*)(this_arg & (~1));
30029         this_arg_conv.is_owned = false;
30030         LDKRawInvoice ret_var = SignedRawInvoice_raw_invoice(&this_arg_conv);
30031         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30032         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30033         uint64_t ret_ref = (uint64_t)ret_var.inner;
30034         if (ret_var.is_owned) {
30035                 ret_ref |= 1;
30036         }
30037         return ret_ref;
30038 }
30039
30040 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
30041         LDKSignedRawInvoice this_arg_conv;
30042         this_arg_conv.inner = (void*)(this_arg & (~1));
30043         this_arg_conv.is_owned = false;
30044         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
30045         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *SignedRawInvoice_hash(&this_arg_conv));
30046         return ret_arr;
30047 }
30048
30049 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
30050         LDKSignedRawInvoice this_arg_conv;
30051         this_arg_conv.inner = (void*)(this_arg & (~1));
30052         this_arg_conv.is_owned = false;
30053         LDKInvoiceSignature ret_var = SignedRawInvoice_signature(&this_arg_conv);
30054         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30055         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30056         uint64_t ret_ref = (uint64_t)ret_var.inner;
30057         if (ret_var.is_owned) {
30058                 ret_ref |= 1;
30059         }
30060         return ret_ref;
30061 }
30062
30063 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1recover_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
30064         LDKSignedRawInvoice this_arg_conv;
30065         this_arg_conv.inner = (void*)(this_arg & (~1));
30066         this_arg_conv.is_owned = false;
30067         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
30068         *ret_conv = SignedRawInvoice_recover_payee_pub_key(&this_arg_conv);
30069         return (uint64_t)ret_conv;
30070 }
30071
30072 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1check_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
30073         LDKSignedRawInvoice this_arg_conv;
30074         this_arg_conv.inner = (void*)(this_arg & (~1));
30075         this_arg_conv.is_owned = false;
30076         jboolean ret_val = SignedRawInvoice_check_signature(&this_arg_conv);
30077         return ret_val;
30078 }
30079
30080 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
30081         LDKRawInvoice this_arg_conv;
30082         this_arg_conv.inner = (void*)(this_arg & (~1));
30083         this_arg_conv.is_owned = false;
30084         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
30085         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, RawInvoice_hash(&this_arg_conv).data);
30086         return ret_arr;
30087 }
30088
30089 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
30090         LDKRawInvoice this_arg_conv;
30091         this_arg_conv.inner = (void*)(this_arg & (~1));
30092         this_arg_conv.is_owned = false;
30093         LDKSha256 ret_var = RawInvoice_payment_hash(&this_arg_conv);
30094         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30095         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30096         uint64_t ret_ref = (uint64_t)ret_var.inner;
30097         if (ret_var.is_owned) {
30098                 ret_ref |= 1;
30099         }
30100         return ret_ref;
30101 }
30102
30103 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1description(JNIEnv *env, jclass clz, int64_t this_arg) {
30104         LDKRawInvoice this_arg_conv;
30105         this_arg_conv.inner = (void*)(this_arg & (~1));
30106         this_arg_conv.is_owned = false;
30107         LDKDescription ret_var = RawInvoice_description(&this_arg_conv);
30108         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30109         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30110         uint64_t ret_ref = (uint64_t)ret_var.inner;
30111         if (ret_var.is_owned) {
30112                 ret_ref |= 1;
30113         }
30114         return ret_ref;
30115 }
30116
30117 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
30118         LDKRawInvoice this_arg_conv;
30119         this_arg_conv.inner = (void*)(this_arg & (~1));
30120         this_arg_conv.is_owned = false;
30121         LDKPayeePubKey ret_var = RawInvoice_payee_pub_key(&this_arg_conv);
30122         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30123         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30124         uint64_t ret_ref = (uint64_t)ret_var.inner;
30125         if (ret_var.is_owned) {
30126                 ret_ref |= 1;
30127         }
30128         return ret_ref;
30129 }
30130
30131 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1description_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
30132         LDKRawInvoice this_arg_conv;
30133         this_arg_conv.inner = (void*)(this_arg & (~1));
30134         this_arg_conv.is_owned = false;
30135         LDKSha256 ret_var = RawInvoice_description_hash(&this_arg_conv);
30136         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30137         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30138         uint64_t ret_ref = (uint64_t)ret_var.inner;
30139         if (ret_var.is_owned) {
30140                 ret_ref |= 1;
30141         }
30142         return ret_ref;
30143 }
30144
30145 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
30146         LDKRawInvoice this_arg_conv;
30147         this_arg_conv.inner = (void*)(this_arg & (~1));
30148         this_arg_conv.is_owned = false;
30149         LDKExpiryTime ret_var = RawInvoice_expiry_time(&this_arg_conv);
30150         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30151         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30152         uint64_t ret_ref = (uint64_t)ret_var.inner;
30153         if (ret_var.is_owned) {
30154                 ret_ref |= 1;
30155         }
30156         return ret_ref;
30157 }
30158
30159 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1min_1final_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_arg) {
30160         LDKRawInvoice this_arg_conv;
30161         this_arg_conv.inner = (void*)(this_arg & (~1));
30162         this_arg_conv.is_owned = false;
30163         LDKMinFinalCltvExpiry ret_var = RawInvoice_min_final_cltv_expiry(&this_arg_conv);
30164         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30165         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30166         uint64_t ret_ref = (uint64_t)ret_var.inner;
30167         if (ret_var.is_owned) {
30168                 ret_ref |= 1;
30169         }
30170         return ret_ref;
30171 }
30172
30173 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
30174         LDKRawInvoice this_arg_conv;
30175         this_arg_conv.inner = (void*)(this_arg & (~1));
30176         this_arg_conv.is_owned = false;
30177         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
30178         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, RawInvoice_payment_secret(&this_arg_conv).data);
30179         return ret_arr;
30180 }
30181
30182 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
30183         LDKRawInvoice this_arg_conv;
30184         this_arg_conv.inner = (void*)(this_arg & (~1));
30185         this_arg_conv.is_owned = false;
30186         LDKInvoiceFeatures ret_var = RawInvoice_features(&this_arg_conv);
30187         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30188         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30189         uint64_t ret_ref = (uint64_t)ret_var.inner;
30190         if (ret_var.is_owned) {
30191                 ret_ref |= 1;
30192         }
30193         return ret_ref;
30194 }
30195
30196 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1private_1routes(JNIEnv *env, jclass clz, int64_t this_arg) {
30197         LDKRawInvoice this_arg_conv;
30198         this_arg_conv.inner = (void*)(this_arg & (~1));
30199         this_arg_conv.is_owned = false;
30200         LDKCVec_PrivateRouteZ ret_var = RawInvoice_private_routes(&this_arg_conv);
30201         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
30202         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
30203         for (size_t o = 0; o < ret_var.datalen; o++) {
30204                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
30205                 CHECK((((uint64_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30206                 CHECK((((uint64_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30207                 uint64_t ret_conv_14_ref = (uint64_t)ret_conv_14_var.inner;
30208                 if (ret_conv_14_var.is_owned) {
30209                         ret_conv_14_ref |= 1;
30210                 }
30211                 ret_arr_ptr[o] = ret_conv_14_ref;
30212         }
30213         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
30214         FREE(ret_var.data);
30215         return ret_arr;
30216 }
30217
30218 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1amount_1pico_1btc(JNIEnv *env, jclass clz, int64_t this_arg) {
30219         LDKRawInvoice this_arg_conv;
30220         this_arg_conv.inner = (void*)(this_arg & (~1));
30221         this_arg_conv.is_owned = false;
30222         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
30223         *ret_copy = RawInvoice_amount_pico_btc(&this_arg_conv);
30224         uint64_t ret_ref = (uint64_t)ret_copy;
30225         return ret_ref;
30226 }
30227
30228 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_RawInvoice_1currency(JNIEnv *env, jclass clz, int64_t this_arg) {
30229         LDKRawInvoice this_arg_conv;
30230         this_arg_conv.inner = (void*)(this_arg & (~1));
30231         this_arg_conv.is_owned = false;
30232         jclass ret_conv = LDKCurrency_to_java(env, RawInvoice_currency(&this_arg_conv));
30233         return ret_conv;
30234 }
30235
30236 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1from_1unix_1timestamp(JNIEnv *env, jclass clz, int64_t unix_seconds) {
30237         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
30238         *ret_conv = PositiveTimestamp_from_unix_timestamp(unix_seconds);
30239         return (uint64_t)ret_conv;
30240 }
30241
30242 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1from_1system_1time(JNIEnv *env, jclass clz, int64_t time) {
30243         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
30244         *ret_conv = PositiveTimestamp_from_system_time(time);
30245         return (uint64_t)ret_conv;
30246 }
30247
30248 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1as_1unix_1timestamp(JNIEnv *env, jclass clz, int64_t this_arg) {
30249         LDKPositiveTimestamp this_arg_conv;
30250         this_arg_conv.inner = (void*)(this_arg & (~1));
30251         this_arg_conv.is_owned = false;
30252         int64_t ret_val = PositiveTimestamp_as_unix_timestamp(&this_arg_conv);
30253         return ret_val;
30254 }
30255
30256 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1as_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
30257         LDKPositiveTimestamp this_arg_conv;
30258         this_arg_conv.inner = (void*)(this_arg & (~1));
30259         this_arg_conv.is_owned = false;
30260         int64_t ret_val = PositiveTimestamp_as_time(&this_arg_conv);
30261         return ret_val;
30262 }
30263
30264 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1into_1signed_1raw(JNIEnv *env, jclass clz, int64_t this_arg) {
30265         LDKInvoice this_arg_conv;
30266         this_arg_conv.inner = (void*)(this_arg & (~1));
30267         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
30268         this_arg_conv = Invoice_clone(&this_arg_conv);
30269         LDKSignedRawInvoice ret_var = Invoice_into_signed_raw(this_arg_conv);
30270         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30271         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30272         uint64_t ret_ref = (uint64_t)ret_var.inner;
30273         if (ret_var.is_owned) {
30274                 ret_ref |= 1;
30275         }
30276         return ret_ref;
30277 }
30278
30279 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1check_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
30280         LDKInvoice this_arg_conv;
30281         this_arg_conv.inner = (void*)(this_arg & (~1));
30282         this_arg_conv.is_owned = false;
30283         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
30284         *ret_conv = Invoice_check_signature(&this_arg_conv);
30285         return (uint64_t)ret_conv;
30286 }
30287
30288 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1from_1signed(JNIEnv *env, jclass clz, int64_t signed_invoice) {
30289         LDKSignedRawInvoice signed_invoice_conv;
30290         signed_invoice_conv.inner = (void*)(signed_invoice & (~1));
30291         signed_invoice_conv.is_owned = (signed_invoice & 1) || (signed_invoice == 0);
30292         signed_invoice_conv = SignedRawInvoice_clone(&signed_invoice_conv);
30293         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
30294         *ret_conv = Invoice_from_signed(signed_invoice_conv);
30295         return (uint64_t)ret_conv;
30296 }
30297
30298 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1timestamp(JNIEnv *env, jclass clz, int64_t this_arg) {
30299         LDKInvoice this_arg_conv;
30300         this_arg_conv.inner = (void*)(this_arg & (~1));
30301         this_arg_conv.is_owned = false;
30302         int64_t ret_val = Invoice_timestamp(&this_arg_conv);
30303         return ret_val;
30304 }
30305
30306 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
30307         LDKInvoice this_arg_conv;
30308         this_arg_conv.inner = (void*)(this_arg & (~1));
30309         this_arg_conv.is_owned = false;
30310         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
30311         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *Invoice_payment_hash(&this_arg_conv));
30312         return ret_arr;
30313 }
30314
30315 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
30316         LDKInvoice this_arg_conv;
30317         this_arg_conv.inner = (void*)(this_arg & (~1));
30318         this_arg_conv.is_owned = false;
30319         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
30320         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, Invoice_payee_pub_key(&this_arg_conv).compressed_form);
30321         return ret_arr;
30322 }
30323
30324 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
30325         LDKInvoice this_arg_conv;
30326         this_arg_conv.inner = (void*)(this_arg & (~1));
30327         this_arg_conv.is_owned = false;
30328         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
30329         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, Invoice_payment_secret(&this_arg_conv).data);
30330         return ret_arr;
30331 }
30332
30333 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
30334         LDKInvoice this_arg_conv;
30335         this_arg_conv.inner = (void*)(this_arg & (~1));
30336         this_arg_conv.is_owned = false;
30337         LDKInvoiceFeatures ret_var = Invoice_features(&this_arg_conv);
30338         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30339         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30340         uint64_t ret_ref = (uint64_t)ret_var.inner;
30341         if (ret_var.is_owned) {
30342                 ret_ref |= 1;
30343         }
30344         return ret_ref;
30345 }
30346
30347 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1recover_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
30348         LDKInvoice this_arg_conv;
30349         this_arg_conv.inner = (void*)(this_arg & (~1));
30350         this_arg_conv.is_owned = false;
30351         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
30352         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, Invoice_recover_payee_pub_key(&this_arg_conv).compressed_form);
30353         return ret_arr;
30354 }
30355
30356 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
30357         LDKInvoice this_arg_conv;
30358         this_arg_conv.inner = (void*)(this_arg & (~1));
30359         this_arg_conv.is_owned = false;
30360         int64_t ret_val = Invoice_expiry_time(&this_arg_conv);
30361         return ret_val;
30362 }
30363
30364 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1min_1final_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_arg) {
30365         LDKInvoice this_arg_conv;
30366         this_arg_conv.inner = (void*)(this_arg & (~1));
30367         this_arg_conv.is_owned = false;
30368         int64_t ret_val = Invoice_min_final_cltv_expiry(&this_arg_conv);
30369         return ret_val;
30370 }
30371
30372 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1private_1routes(JNIEnv *env, jclass clz, int64_t this_arg) {
30373         LDKInvoice this_arg_conv;
30374         this_arg_conv.inner = (void*)(this_arg & (~1));
30375         this_arg_conv.is_owned = false;
30376         LDKCVec_PrivateRouteZ ret_var = Invoice_private_routes(&this_arg_conv);
30377         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
30378         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
30379         for (size_t o = 0; o < ret_var.datalen; o++) {
30380                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
30381                 CHECK((((uint64_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30382                 CHECK((((uint64_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30383                 uint64_t ret_conv_14_ref = (uint64_t)ret_conv_14_var.inner;
30384                 if (ret_conv_14_var.is_owned) {
30385                         ret_conv_14_ref |= 1;
30386                 }
30387                 ret_arr_ptr[o] = ret_conv_14_ref;
30388         }
30389         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
30390         FREE(ret_var.data);
30391         return ret_arr;
30392 }
30393
30394 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1route_1hints(JNIEnv *env, jclass clz, int64_t this_arg) {
30395         LDKInvoice this_arg_conv;
30396         this_arg_conv.inner = (void*)(this_arg & (~1));
30397         this_arg_conv.is_owned = false;
30398         LDKCVec_RouteHintZ ret_var = Invoice_route_hints(&this_arg_conv);
30399         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
30400         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
30401         for (size_t l = 0; l < ret_var.datalen; l++) {
30402                 LDKRouteHint ret_conv_11_var = ret_var.data[l];
30403                 CHECK((((uint64_t)ret_conv_11_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30404                 CHECK((((uint64_t)&ret_conv_11_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30405                 uint64_t ret_conv_11_ref = (uint64_t)ret_conv_11_var.inner;
30406                 if (ret_conv_11_var.is_owned) {
30407                         ret_conv_11_ref |= 1;
30408                 }
30409                 ret_arr_ptr[l] = ret_conv_11_ref;
30410         }
30411         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
30412         FREE(ret_var.data);
30413         return ret_arr;
30414 }
30415
30416 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Invoice_1currency(JNIEnv *env, jclass clz, int64_t this_arg) {
30417         LDKInvoice this_arg_conv;
30418         this_arg_conv.inner = (void*)(this_arg & (~1));
30419         this_arg_conv.is_owned = false;
30420         jclass ret_conv = LDKCurrency_to_java(env, Invoice_currency(&this_arg_conv));
30421         return ret_conv;
30422 }
30423
30424 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1amount_1pico_1btc(JNIEnv *env, jclass clz, int64_t this_arg) {
30425         LDKInvoice this_arg_conv;
30426         this_arg_conv.inner = (void*)(this_arg & (~1));
30427         this_arg_conv.is_owned = false;
30428         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
30429         *ret_copy = Invoice_amount_pico_btc(&this_arg_conv);
30430         uint64_t ret_ref = (uint64_t)ret_copy;
30431         return ret_ref;
30432 }
30433
30434 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1new(JNIEnv *env, jclass clz, jstring description) {
30435         LDKStr description_conv = java_to_owned_str(env, description);
30436         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
30437         *ret_conv = Description_new(description_conv);
30438         return (uint64_t)ret_conv;
30439 }
30440
30441 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Description_1into_1inner(JNIEnv *env, jclass clz, int64_t this_arg) {
30442         LDKDescription this_arg_conv;
30443         this_arg_conv.inner = (void*)(this_arg & (~1));
30444         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
30445         this_arg_conv = Description_clone(&this_arg_conv);
30446         LDKStr ret_str = Description_into_inner(this_arg_conv);
30447         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
30448         Str_free(ret_str);
30449         return ret_conv;
30450 }
30451
30452 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1from_1seconds(JNIEnv *env, jclass clz, int64_t seconds) {
30453         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
30454         *ret_conv = ExpiryTime_from_seconds(seconds);
30455         return (uint64_t)ret_conv;
30456 }
30457
30458 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1from_1duration(JNIEnv *env, jclass clz, int64_t duration) {
30459         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
30460         *ret_conv = ExpiryTime_from_duration(duration);
30461         return (uint64_t)ret_conv;
30462 }
30463
30464 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1as_1seconds(JNIEnv *env, jclass clz, int64_t this_arg) {
30465         LDKExpiryTime this_arg_conv;
30466         this_arg_conv.inner = (void*)(this_arg & (~1));
30467         this_arg_conv.is_owned = false;
30468         int64_t ret_val = ExpiryTime_as_seconds(&this_arg_conv);
30469         return ret_val;
30470 }
30471
30472 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1as_1duration(JNIEnv *env, jclass clz, int64_t this_arg) {
30473         LDKExpiryTime this_arg_conv;
30474         this_arg_conv.inner = (void*)(this_arg & (~1));
30475         this_arg_conv.is_owned = false;
30476         int64_t ret_val = ExpiryTime_as_duration(&this_arg_conv);
30477         return ret_val;
30478 }
30479
30480 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1new(JNIEnv *env, jclass clz, int64_t hops) {
30481         LDKRouteHint hops_conv;
30482         hops_conv.inner = (void*)(hops & (~1));
30483         hops_conv.is_owned = (hops & 1) || (hops == 0);
30484         hops_conv = RouteHint_clone(&hops_conv);
30485         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
30486         *ret_conv = PrivateRoute_new(hops_conv);
30487         return (uint64_t)ret_conv;
30488 }
30489
30490 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1into_1inner(JNIEnv *env, jclass clz, int64_t this_arg) {
30491         LDKPrivateRoute this_arg_conv;
30492         this_arg_conv.inner = (void*)(this_arg & (~1));
30493         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
30494         this_arg_conv = PrivateRoute_clone(&this_arg_conv);
30495         LDKRouteHint ret_var = PrivateRoute_into_inner(this_arg_conv);
30496         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30497         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30498         uint64_t ret_ref = (uint64_t)ret_var.inner;
30499         if (ret_var.is_owned) {
30500                 ret_ref |= 1;
30501         }
30502         return ret_ref;
30503 }
30504
30505 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30506         LDKCreationError* orig_conv = (LDKCreationError*)(orig & ~1);
30507         jclass ret_conv = LDKCreationError_to_java(env, CreationError_clone(orig_conv));
30508         return ret_conv;
30509 }
30510
30511 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1description_1too_1long(JNIEnv *env, jclass clz) {
30512         jclass ret_conv = LDKCreationError_to_java(env, CreationError_description_too_long());
30513         return ret_conv;
30514 }
30515
30516 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1route_1too_1long(JNIEnv *env, jclass clz) {
30517         jclass ret_conv = LDKCreationError_to_java(env, CreationError_route_too_long());
30518         return ret_conv;
30519 }
30520
30521 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1timestamp_1out_1of_1bounds(JNIEnv *env, jclass clz) {
30522         jclass ret_conv = LDKCreationError_to_java(env, CreationError_timestamp_out_of_bounds());
30523         return ret_conv;
30524 }
30525
30526 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1expiry_1time_1out_1of_1bounds(JNIEnv *env, jclass clz) {
30527         jclass ret_conv = LDKCreationError_to_java(env, CreationError_expiry_time_out_of_bounds());
30528         return ret_conv;
30529 }
30530
30531 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CreationError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
30532         LDKCreationError* a_conv = (LDKCreationError*)(a & ~1);
30533         LDKCreationError* b_conv = (LDKCreationError*)(b & ~1);
30534         jboolean ret_val = CreationError_eq(a_conv, b_conv);
30535         return ret_val;
30536 }
30537
30538 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_CreationError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
30539         LDKCreationError* o_conv = (LDKCreationError*)(o & ~1);
30540         LDKStr ret_str = CreationError_to_str(o_conv);
30541         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
30542         Str_free(ret_str);
30543         return ret_conv;
30544 }
30545
30546 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30547         LDKSemanticError* orig_conv = (LDKSemanticError*)(orig & ~1);
30548         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_clone(orig_conv));
30549         return ret_conv;
30550 }
30551
30552 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1no_1payment_1hash(JNIEnv *env, jclass clz) {
30553         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_no_payment_hash());
30554         return ret_conv;
30555 }
30556
30557 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1multiple_1payment_1hashes(JNIEnv *env, jclass clz) {
30558         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_multiple_payment_hashes());
30559         return ret_conv;
30560 }
30561
30562 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1no_1description(JNIEnv *env, jclass clz) {
30563         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_no_description());
30564         return ret_conv;
30565 }
30566
30567 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1multiple_1descriptions(JNIEnv *env, jclass clz) {
30568         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_multiple_descriptions());
30569         return ret_conv;
30570 }
30571
30572 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1no_1payment_1secret(JNIEnv *env, jclass clz) {
30573         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_no_payment_secret());
30574         return ret_conv;
30575 }
30576
30577 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1multiple_1payment_1secrets(JNIEnv *env, jclass clz) {
30578         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_multiple_payment_secrets());
30579         return ret_conv;
30580 }
30581
30582 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1invalid_1features(JNIEnv *env, jclass clz) {
30583         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_invalid_features());
30584         return ret_conv;
30585 }
30586
30587 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1invalid_1recovery_1id(JNIEnv *env, jclass clz) {
30588         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_invalid_recovery_id());
30589         return ret_conv;
30590 }
30591
30592 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1invalid_1signature(JNIEnv *env, jclass clz) {
30593         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_invalid_signature());
30594         return ret_conv;
30595 }
30596
30597 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1imprecise_1amount(JNIEnv *env, jclass clz) {
30598         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_imprecise_amount());
30599         return ret_conv;
30600 }
30601
30602 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SemanticError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
30603         LDKSemanticError* a_conv = (LDKSemanticError*)(a & ~1);
30604         LDKSemanticError* b_conv = (LDKSemanticError*)(b & ~1);
30605         jboolean ret_val = SemanticError_eq(a_conv, b_conv);
30606         return ret_val;
30607 }
30608
30609 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SemanticError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
30610         LDKSemanticError* o_conv = (LDKSemanticError*)(o & ~1);
30611         LDKStr ret_str = SemanticError_to_str(o_conv);
30612         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
30613         Str_free(ret_str);
30614         return ret_conv;
30615 }
30616
30617 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
30618         if ((this_ptr & 1) != 0) return;
30619         LDKSignOrCreationError this_ptr_conv = *(LDKSignOrCreationError*)(((uint64_t)this_ptr) & ~1);
30620         FREE((void*)this_ptr);
30621         SignOrCreationError_free(this_ptr_conv);
30622 }
30623
30624 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30625         LDKSignOrCreationError* orig_conv = (LDKSignOrCreationError*)orig;
30626         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
30627         *ret_copy = SignOrCreationError_clone(orig_conv);
30628         uint64_t ret_ref = (uint64_t)ret_copy;
30629         return ret_ref;
30630 }
30631
30632 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1sign_1error(JNIEnv *env, jclass clz) {
30633         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
30634         *ret_copy = SignOrCreationError_sign_error();
30635         uint64_t ret_ref = (uint64_t)ret_copy;
30636         return ret_ref;
30637 }
30638
30639 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1creation_1error(JNIEnv *env, jclass clz, jclass a) {
30640         LDKCreationError a_conv = LDKCreationError_from_java(env, a);
30641         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
30642         *ret_copy = SignOrCreationError_creation_error(a_conv);
30643         uint64_t ret_ref = (uint64_t)ret_copy;
30644         return ret_ref;
30645 }
30646
30647 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
30648         LDKSignOrCreationError* a_conv = (LDKSignOrCreationError*)a;
30649         LDKSignOrCreationError* b_conv = (LDKSignOrCreationError*)b;
30650         jboolean ret_val = SignOrCreationError_eq(a_conv, b_conv);
30651         return ret_val;
30652 }
30653
30654 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
30655         LDKSignOrCreationError* o_conv = (LDKSignOrCreationError*)o;
30656         LDKStr ret_str = SignOrCreationError_to_str(o_conv);
30657         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
30658         Str_free(ret_str);
30659         return ret_conv;
30660 }
30661
30662 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) {
30663         LDKChannelManager channelmanager_conv;
30664         channelmanager_conv.inner = (void*)(channelmanager & (~1));
30665         channelmanager_conv.is_owned = false;
30666         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
30667         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
30668                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30669                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
30670         }
30671         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
30672         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(((uint64_t)amt_msat) & ~1);
30673         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)amt_msat) & ~1));
30674         LDKStr description_conv = java_to_owned_str(env, description);
30675         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
30676         *ret_conv = create_invoice_from_channelmanager(&channelmanager_conv, keys_manager_conv, network_conv, amt_msat_conv, description_conv);
30677         return (uint64_t)ret_conv;
30678 }
30679
30680 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SiPrefix_1from_1str(JNIEnv *env, jclass clz, jstring s) {
30681         LDKStr s_conv = java_to_owned_str(env, s);
30682         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
30683         *ret_conv = SiPrefix_from_str(s_conv);
30684         return (uint64_t)ret_conv;
30685 }
30686
30687 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1from_1str(JNIEnv *env, jclass clz, jstring s) {
30688         LDKStr s_conv = java_to_owned_str(env, s);
30689         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
30690         *ret_conv = Invoice_from_str(s_conv);
30691         return (uint64_t)ret_conv;
30692 }
30693
30694 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1from_1str(JNIEnv *env, jclass clz, jstring s) {
30695         LDKStr s_conv = java_to_owned_str(env, s);
30696         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
30697         *ret_conv = SignedRawInvoice_from_str(s_conv);
30698         return (uint64_t)ret_conv;
30699 }
30700
30701 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Invoice_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
30702         LDKInvoice o_conv;
30703         o_conv.inner = (void*)(o & (~1));
30704         o_conv.is_owned = false;
30705         LDKStr ret_str = Invoice_to_str(&o_conv);
30706         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
30707         Str_free(ret_str);
30708         return ret_conv;
30709 }
30710
30711 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
30712         LDKSignedRawInvoice o_conv;
30713         o_conv.inner = (void*)(o & (~1));
30714         o_conv.is_owned = false;
30715         LDKStr ret_str = SignedRawInvoice_to_str(&o_conv);
30716         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
30717         Str_free(ret_str);
30718         return ret_conv;
30719 }
30720
30721 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Currency_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
30722         LDKCurrency* o_conv = (LDKCurrency*)(o & ~1);
30723         LDKStr ret_str = Currency_to_str(o_conv);
30724         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
30725         Str_free(ret_str);
30726         return ret_conv;
30727 }
30728
30729 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SiPrefix_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
30730         LDKSiPrefix* o_conv = (LDKSiPrefix*)(o & ~1);
30731         LDKStr ret_str = SiPrefix_to_str(o_conv);
30732         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
30733         Str_free(ret_str);
30734         return ret_conv;
30735 }
30736