Update auto-generate bindings (incl new RL clone methods)
[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 CHECK_ACCESS(p)
16 #define DO_ASSERT(a) (void)(a)
17 #define CHECK(a)
18
19 static jmethodID ordinal_meth = NULL;
20 static jmethodID slicedef_meth = NULL;
21 static jclass slicedef_cls = NULL;
22 JNIEXPORT void Java_org_ldk_impl_bindings_init(JNIEnv * env, jclass _b, jclass enum_class, jclass slicedef_class) {
23         ordinal_meth = (*env)->GetMethodID(env, enum_class, "ordinal", "()I");
24         CHECK(ordinal_meth != NULL);
25         slicedef_meth = (*env)->GetMethodID(env, slicedef_class, "<init>", "(JJJ)V");
26         CHECK(slicedef_meth != NULL);
27         slicedef_cls = (*env)->NewGlobalRef(env, slicedef_class);
28         CHECK(slicedef_cls != NULL);
29 }
30
31 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_deref_1bool (JNIEnv * env, jclass _a, jlong ptr) {
32         return *((bool*)ptr);
33 }
34 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_deref_1long (JNIEnv * env, jclass _a, jlong ptr) {
35         return *((long*)ptr);
36 }
37 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_free_1heap_1ptr (JNIEnv * env, jclass _a, jlong ptr) {
38         FREE((void*)ptr);
39 }
40 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_read_1bytes (JNIEnv * env, jclass _b, jlong ptr, jlong len) {
41         jbyteArray ret_arr = (*env)->NewByteArray(env, len);
42         (*env)->SetByteArrayRegion(env, ret_arr, 0, len, (unsigned char*)ptr);
43         return ret_arr;
44 }
45 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_get_1u8_1slice_1bytes (JNIEnv * env, jclass _b, jlong slice_ptr) {
46         LDKu8slice *slice = (LDKu8slice*)slice_ptr;
47         jbyteArray ret_arr = (*env)->NewByteArray(env, slice->datalen);
48         (*env)->SetByteArrayRegion(env, ret_arr, 0, slice->datalen, slice->data);
49         return ret_arr;
50 }
51 JNIEXPORT int64_t impl_bindings_bytes_1to_1u8_1vec (JNIEnv * env, jclass _b, jbyteArray bytes) {
52         LDKCVec_u8Z *vec = (LDKCVec_u8Z*)MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8");
53         vec->datalen = (*env)->GetArrayLength(env, bytes);
54         vec->data = (uint8_t*)MALLOC(vec->datalen, "LDKCVec_u8Z Bytes");
55         (*env)->GetByteArrayRegion (env, bytes, 0, vec->datalen, vec->data);
56         return (uint64_t)vec;
57 }
58 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_txpointer_1get_1buffer (JNIEnv * env, jclass _b, jlong ptr) {
59         LDKTransaction *txdata = (LDKTransaction*)ptr;
60         LDKu8slice slice;
61         slice.data = txdata->data;
62         slice.datalen = txdata->datalen;
63         return Java_org_ldk_impl_bindings_get_1u8_1slice_1bytes(env, _b, (uint64_t)&slice);
64 }
65 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_new_1txpointer_1copy_1data (JNIEnv * env, jclass _b, jbyteArray bytes) {
66         LDKTransaction *txdata = (LDKTransaction*)MALLOC(sizeof(LDKTransaction), "LDKTransaction");
67         txdata->datalen = (*env)->GetArrayLength(env, bytes);
68         txdata->data = (uint8_t*)MALLOC(txdata->datalen, "Tx Data Bytes");
69         txdata->data_is_owned = false;
70         (*env)->GetByteArrayRegion (env, bytes, 0, txdata->datalen, txdata->data);
71         return (uint64_t)txdata;
72 }
73 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_txpointer_1free (JNIEnv * env, jclass _b, jlong ptr) {
74         LDKTransaction *tx = (LDKTransaction*)ptr;
75         tx->data_is_owned = true;
76         Transaction_free(*tx);
77         FREE((void*)ptr);
78 }
79 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_vec_1slice_1len (JNIEnv * env, jclass _a, jlong ptr) {
80         // Check offsets of a few Vec types are all consistent as we're meant to be generic across types
81         _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_SignatureZ, datalen), "Vec<*> needs to be mapped identically");
82         _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_MessageSendEventZ, datalen), "Vec<*> needs to be mapped identically");
83         _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_EventZ, datalen), "Vec<*> needs to be mapped identically");
84         _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_C2Tuple_usizeTransactionZZ, datalen), "Vec<*> needs to be mapped identically");
85         LDKCVec_u8Z *vec = (LDKCVec_u8Z*)ptr;
86         return (uint64_t)vec->datalen;
87 }
88 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_new_1empty_1slice_1vec (JNIEnv * env, jclass _b) {
89         // Check sizes of a few Vec types are all consistent as we're meant to be generic across types
90         _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_SignatureZ), "Vec<*> needs to be mapped identically");
91         _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_MessageSendEventZ), "Vec<*> needs to be mapped identically");
92         _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_EventZ), "Vec<*> needs to be mapped identically");
93         _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_C2Tuple_usizeTransactionZZ), "Vec<*> needs to be mapped identically");
94         LDKCVec_u8Z *vec = (LDKCVec_u8Z*)MALLOC(sizeof(LDKCVec_u8Z), "Empty LDKCVec");
95         vec->data = NULL;
96         vec->datalen = 0;
97         return (uint64_t)vec;
98 }
99
100 // We assume that CVec_u8Z and u8slice are the same size and layout (and thus pointers to the two can be mixed)
101 _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKu8slice), "Vec<u8> and [u8] need to have been mapped identically");
102 _Static_assert(offsetof(LDKCVec_u8Z, data) == offsetof(LDKu8slice, data), "Vec<u8> and [u8] need to have been mapped identically");
103 _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKu8slice, datalen), "Vec<u8> and [u8] need to have been mapped identically");
104
105 _Static_assert(sizeof(jlong) == sizeof(int64_t), "We assume that j-types are the same as C types");
106 _Static_assert(sizeof(jbyte) == sizeof(char), "We assume that j-types are the same as C types");
107 _Static_assert(sizeof(void*) <= 8, "Pointers must fit into 64 bits");
108
109 typedef jlongArray int64_tArray;
110 typedef jbyteArray int8_tArray;
111
112 static inline jstring str_ref_to_java(JNIEnv *env, const char* chars, size_t len) {
113         // Sadly we need to create a temporary because Java can't accept a char* without a 0-terminator
114         char* conv_buf = MALLOC(len + 1, "str conv buf");
115         memcpy(conv_buf, chars, len);
116         conv_buf[len] = 0;
117         jstring ret = (*env)->NewStringUTF(env, conv_buf);
118         FREE(conv_buf);
119         return ret;
120 }
121 static inline LDKStr java_to_owned_str(JNIEnv *env, jstring str) {
122         uint64_t str_len = (*env)->GetStringUTFLength(env, str);
123         char* newchars = MALLOC(str_len + 1, "String chars");
124         const char* jchars = (*env)->GetStringUTFChars(env, str, NULL);
125         memcpy(newchars, jchars, str_len);
126         newchars[str_len] = 0;
127         (*env)->ReleaseStringUTFChars(env, str, jchars);
128         LDKStr res = {
129                 .chars = newchars,
130                 .len = str_len,
131                 .chars_is_owned = true
132         };
133         return res;
134 }
135
136 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_get_1ldk_1c_1bindings_1version(JNIEnv *env, jclass _c) {
137         return str_ref_to_java(env, check_get_ldk_bindings_version(), strlen(check_get_ldk_bindings_version()));
138 }
139 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_get_1ldk_1version(JNIEnv *env, jclass _c) {
140         return str_ref_to_java(env, check_get_ldk_version(), strlen(check_get_ldk_version()));
141 }
142 #include "version.c"
143 static jclass arr_of_B_clz = NULL;
144 static jclass arr_of_J_clz = NULL;
145 JNIEXPORT void Java_org_ldk_impl_bindings_init_1class_1cache(JNIEnv * env, jclass clz) {
146         arr_of_B_clz = (*env)->FindClass(env, "[B");
147         CHECK(arr_of_B_clz != NULL);
148         arr_of_B_clz = (*env)->NewGlobalRef(env, arr_of_B_clz);
149         arr_of_J_clz = (*env)->FindClass(env, "[J");
150         CHECK(arr_of_J_clz != NULL);
151         arr_of_J_clz = (*env)->NewGlobalRef(env, arr_of_J_clz);
152 }
153 static inline struct LDKThirtyTwoBytes ThirtyTwoBytes_clone(const struct LDKThirtyTwoBytes *orig) { struct LDKThirtyTwoBytes ret; memcpy(ret.data, orig->data, 32); return ret; }
154 static inline LDKAccessError LDKAccessError_from_java(JNIEnv *env, jclass clz) {
155         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
156                 case 0: return LDKAccessError_UnknownChain;
157                 case 1: return LDKAccessError_UnknownTx;
158         }
159         abort();
160 }
161 static jclass AccessError_class = NULL;
162 static jfieldID AccessError_LDKAccessError_UnknownChain = NULL;
163 static jfieldID AccessError_LDKAccessError_UnknownTx = NULL;
164 JNIEXPORT void JNICALL Java_org_ldk_enums_AccessError_init (JNIEnv *env, jclass clz) {
165         AccessError_class = (*env)->NewGlobalRef(env, clz);
166         CHECK(AccessError_class != NULL);
167         AccessError_LDKAccessError_UnknownChain = (*env)->GetStaticFieldID(env, AccessError_class, "LDKAccessError_UnknownChain", "Lorg/ldk/enums/AccessError;");
168         CHECK(AccessError_LDKAccessError_UnknownChain != NULL);
169         AccessError_LDKAccessError_UnknownTx = (*env)->GetStaticFieldID(env, AccessError_class, "LDKAccessError_UnknownTx", "Lorg/ldk/enums/AccessError;");
170         CHECK(AccessError_LDKAccessError_UnknownTx != NULL);
171 }
172 static inline jclass LDKAccessError_to_java(JNIEnv *env, LDKAccessError val) {
173         switch (val) {
174                 case LDKAccessError_UnknownChain:
175                         return (*env)->GetStaticObjectField(env, AccessError_class, AccessError_LDKAccessError_UnknownChain);
176                 case LDKAccessError_UnknownTx:
177                         return (*env)->GetStaticObjectField(env, AccessError_class, AccessError_LDKAccessError_UnknownTx);
178                 default: abort();
179         }
180 }
181
182 static inline LDKChannelMonitorUpdateErr LDKChannelMonitorUpdateErr_from_java(JNIEnv *env, jclass clz) {
183         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
184                 case 0: return LDKChannelMonitorUpdateErr_TemporaryFailure;
185                 case 1: return LDKChannelMonitorUpdateErr_PermanentFailure;
186         }
187         abort();
188 }
189 static jclass ChannelMonitorUpdateErr_class = NULL;
190 static jfieldID ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_TemporaryFailure = NULL;
191 static jfieldID ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_PermanentFailure = NULL;
192 JNIEXPORT void JNICALL Java_org_ldk_enums_ChannelMonitorUpdateErr_init (JNIEnv *env, jclass clz) {
193         ChannelMonitorUpdateErr_class = (*env)->NewGlobalRef(env, clz);
194         CHECK(ChannelMonitorUpdateErr_class != NULL);
195         ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_TemporaryFailure = (*env)->GetStaticFieldID(env, ChannelMonitorUpdateErr_class, "LDKChannelMonitorUpdateErr_TemporaryFailure", "Lorg/ldk/enums/ChannelMonitorUpdateErr;");
196         CHECK(ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_TemporaryFailure != NULL);
197         ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_PermanentFailure = (*env)->GetStaticFieldID(env, ChannelMonitorUpdateErr_class, "LDKChannelMonitorUpdateErr_PermanentFailure", "Lorg/ldk/enums/ChannelMonitorUpdateErr;");
198         CHECK(ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_PermanentFailure != NULL);
199 }
200 static inline jclass LDKChannelMonitorUpdateErr_to_java(JNIEnv *env, LDKChannelMonitorUpdateErr val) {
201         switch (val) {
202                 case LDKChannelMonitorUpdateErr_TemporaryFailure:
203                         return (*env)->GetStaticObjectField(env, ChannelMonitorUpdateErr_class, ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_TemporaryFailure);
204                 case LDKChannelMonitorUpdateErr_PermanentFailure:
205                         return (*env)->GetStaticObjectField(env, ChannelMonitorUpdateErr_class, ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_PermanentFailure);
206                 default: abort();
207         }
208 }
209
210 static inline LDKConfirmationTarget LDKConfirmationTarget_from_java(JNIEnv *env, jclass clz) {
211         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
212                 case 0: return LDKConfirmationTarget_Background;
213                 case 1: return LDKConfirmationTarget_Normal;
214                 case 2: return LDKConfirmationTarget_HighPriority;
215         }
216         abort();
217 }
218 static jclass ConfirmationTarget_class = NULL;
219 static jfieldID ConfirmationTarget_LDKConfirmationTarget_Background = NULL;
220 static jfieldID ConfirmationTarget_LDKConfirmationTarget_Normal = NULL;
221 static jfieldID ConfirmationTarget_LDKConfirmationTarget_HighPriority = NULL;
222 JNIEXPORT void JNICALL Java_org_ldk_enums_ConfirmationTarget_init (JNIEnv *env, jclass clz) {
223         ConfirmationTarget_class = (*env)->NewGlobalRef(env, clz);
224         CHECK(ConfirmationTarget_class != NULL);
225         ConfirmationTarget_LDKConfirmationTarget_Background = (*env)->GetStaticFieldID(env, ConfirmationTarget_class, "LDKConfirmationTarget_Background", "Lorg/ldk/enums/ConfirmationTarget;");
226         CHECK(ConfirmationTarget_LDKConfirmationTarget_Background != NULL);
227         ConfirmationTarget_LDKConfirmationTarget_Normal = (*env)->GetStaticFieldID(env, ConfirmationTarget_class, "LDKConfirmationTarget_Normal", "Lorg/ldk/enums/ConfirmationTarget;");
228         CHECK(ConfirmationTarget_LDKConfirmationTarget_Normal != NULL);
229         ConfirmationTarget_LDKConfirmationTarget_HighPriority = (*env)->GetStaticFieldID(env, ConfirmationTarget_class, "LDKConfirmationTarget_HighPriority", "Lorg/ldk/enums/ConfirmationTarget;");
230         CHECK(ConfirmationTarget_LDKConfirmationTarget_HighPriority != NULL);
231 }
232 static inline jclass LDKConfirmationTarget_to_java(JNIEnv *env, LDKConfirmationTarget val) {
233         switch (val) {
234                 case LDKConfirmationTarget_Background:
235                         return (*env)->GetStaticObjectField(env, ConfirmationTarget_class, ConfirmationTarget_LDKConfirmationTarget_Background);
236                 case LDKConfirmationTarget_Normal:
237                         return (*env)->GetStaticObjectField(env, ConfirmationTarget_class, ConfirmationTarget_LDKConfirmationTarget_Normal);
238                 case LDKConfirmationTarget_HighPriority:
239                         return (*env)->GetStaticObjectField(env, ConfirmationTarget_class, ConfirmationTarget_LDKConfirmationTarget_HighPriority);
240                 default: abort();
241         }
242 }
243
244 static inline LDKCreationError LDKCreationError_from_java(JNIEnv *env, jclass clz) {
245         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
246                 case 0: return LDKCreationError_DescriptionTooLong;
247                 case 1: return LDKCreationError_RouteTooLong;
248                 case 2: return LDKCreationError_TimestampOutOfBounds;
249                 case 3: return LDKCreationError_ExpiryTimeOutOfBounds;
250         }
251         abort();
252 }
253 static jclass CreationError_class = NULL;
254 static jfieldID CreationError_LDKCreationError_DescriptionTooLong = NULL;
255 static jfieldID CreationError_LDKCreationError_RouteTooLong = NULL;
256 static jfieldID CreationError_LDKCreationError_TimestampOutOfBounds = NULL;
257 static jfieldID CreationError_LDKCreationError_ExpiryTimeOutOfBounds = NULL;
258 JNIEXPORT void JNICALL Java_org_ldk_enums_CreationError_init (JNIEnv *env, jclass clz) {
259         CreationError_class = (*env)->NewGlobalRef(env, clz);
260         CHECK(CreationError_class != NULL);
261         CreationError_LDKCreationError_DescriptionTooLong = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_DescriptionTooLong", "Lorg/ldk/enums/CreationError;");
262         CHECK(CreationError_LDKCreationError_DescriptionTooLong != NULL);
263         CreationError_LDKCreationError_RouteTooLong = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_RouteTooLong", "Lorg/ldk/enums/CreationError;");
264         CHECK(CreationError_LDKCreationError_RouteTooLong != NULL);
265         CreationError_LDKCreationError_TimestampOutOfBounds = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_TimestampOutOfBounds", "Lorg/ldk/enums/CreationError;");
266         CHECK(CreationError_LDKCreationError_TimestampOutOfBounds != NULL);
267         CreationError_LDKCreationError_ExpiryTimeOutOfBounds = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_ExpiryTimeOutOfBounds", "Lorg/ldk/enums/CreationError;");
268         CHECK(CreationError_LDKCreationError_ExpiryTimeOutOfBounds != NULL);
269 }
270 static inline jclass LDKCreationError_to_java(JNIEnv *env, LDKCreationError val) {
271         switch (val) {
272                 case LDKCreationError_DescriptionTooLong:
273                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_DescriptionTooLong);
274                 case LDKCreationError_RouteTooLong:
275                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_RouteTooLong);
276                 case LDKCreationError_TimestampOutOfBounds:
277                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_TimestampOutOfBounds);
278                 case LDKCreationError_ExpiryTimeOutOfBounds:
279                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_ExpiryTimeOutOfBounds);
280                 default: abort();
281         }
282 }
283
284 static inline LDKCurrency LDKCurrency_from_java(JNIEnv *env, jclass clz) {
285         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
286                 case 0: return LDKCurrency_Bitcoin;
287                 case 1: return LDKCurrency_BitcoinTestnet;
288                 case 2: return LDKCurrency_Regtest;
289                 case 3: return LDKCurrency_Simnet;
290                 case 4: return LDKCurrency_Signet;
291         }
292         abort();
293 }
294 static jclass Currency_class = NULL;
295 static jfieldID Currency_LDKCurrency_Bitcoin = NULL;
296 static jfieldID Currency_LDKCurrency_BitcoinTestnet = NULL;
297 static jfieldID Currency_LDKCurrency_Regtest = NULL;
298 static jfieldID Currency_LDKCurrency_Simnet = NULL;
299 static jfieldID Currency_LDKCurrency_Signet = NULL;
300 JNIEXPORT void JNICALL Java_org_ldk_enums_Currency_init (JNIEnv *env, jclass clz) {
301         Currency_class = (*env)->NewGlobalRef(env, clz);
302         CHECK(Currency_class != NULL);
303         Currency_LDKCurrency_Bitcoin = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_Bitcoin", "Lorg/ldk/enums/Currency;");
304         CHECK(Currency_LDKCurrency_Bitcoin != NULL);
305         Currency_LDKCurrency_BitcoinTestnet = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_BitcoinTestnet", "Lorg/ldk/enums/Currency;");
306         CHECK(Currency_LDKCurrency_BitcoinTestnet != NULL);
307         Currency_LDKCurrency_Regtest = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_Regtest", "Lorg/ldk/enums/Currency;");
308         CHECK(Currency_LDKCurrency_Regtest != NULL);
309         Currency_LDKCurrency_Simnet = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_Simnet", "Lorg/ldk/enums/Currency;");
310         CHECK(Currency_LDKCurrency_Simnet != NULL);
311         Currency_LDKCurrency_Signet = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_Signet", "Lorg/ldk/enums/Currency;");
312         CHECK(Currency_LDKCurrency_Signet != NULL);
313 }
314 static inline jclass LDKCurrency_to_java(JNIEnv *env, LDKCurrency val) {
315         switch (val) {
316                 case LDKCurrency_Bitcoin:
317                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_Bitcoin);
318                 case LDKCurrency_BitcoinTestnet:
319                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_BitcoinTestnet);
320                 case LDKCurrency_Regtest:
321                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_Regtest);
322                 case LDKCurrency_Simnet:
323                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_Simnet);
324                 case LDKCurrency_Signet:
325                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_Signet);
326                 default: abort();
327         }
328 }
329
330 static inline LDKIOError LDKIOError_from_java(JNIEnv *env, jclass clz) {
331         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
332                 case 0: return LDKIOError_NotFound;
333                 case 1: return LDKIOError_PermissionDenied;
334                 case 2: return LDKIOError_ConnectionRefused;
335                 case 3: return LDKIOError_ConnectionReset;
336                 case 4: return LDKIOError_ConnectionAborted;
337                 case 5: return LDKIOError_NotConnected;
338                 case 6: return LDKIOError_AddrInUse;
339                 case 7: return LDKIOError_AddrNotAvailable;
340                 case 8: return LDKIOError_BrokenPipe;
341                 case 9: return LDKIOError_AlreadyExists;
342                 case 10: return LDKIOError_WouldBlock;
343                 case 11: return LDKIOError_InvalidInput;
344                 case 12: return LDKIOError_InvalidData;
345                 case 13: return LDKIOError_TimedOut;
346                 case 14: return LDKIOError_WriteZero;
347                 case 15: return LDKIOError_Interrupted;
348                 case 16: return LDKIOError_Other;
349                 case 17: return LDKIOError_UnexpectedEof;
350         }
351         abort();
352 }
353 static jclass IOError_class = NULL;
354 static jfieldID IOError_LDKIOError_NotFound = NULL;
355 static jfieldID IOError_LDKIOError_PermissionDenied = NULL;
356 static jfieldID IOError_LDKIOError_ConnectionRefused = NULL;
357 static jfieldID IOError_LDKIOError_ConnectionReset = NULL;
358 static jfieldID IOError_LDKIOError_ConnectionAborted = NULL;
359 static jfieldID IOError_LDKIOError_NotConnected = NULL;
360 static jfieldID IOError_LDKIOError_AddrInUse = NULL;
361 static jfieldID IOError_LDKIOError_AddrNotAvailable = NULL;
362 static jfieldID IOError_LDKIOError_BrokenPipe = NULL;
363 static jfieldID IOError_LDKIOError_AlreadyExists = NULL;
364 static jfieldID IOError_LDKIOError_WouldBlock = NULL;
365 static jfieldID IOError_LDKIOError_InvalidInput = NULL;
366 static jfieldID IOError_LDKIOError_InvalidData = NULL;
367 static jfieldID IOError_LDKIOError_TimedOut = NULL;
368 static jfieldID IOError_LDKIOError_WriteZero = NULL;
369 static jfieldID IOError_LDKIOError_Interrupted = NULL;
370 static jfieldID IOError_LDKIOError_Other = NULL;
371 static jfieldID IOError_LDKIOError_UnexpectedEof = NULL;
372 JNIEXPORT void JNICALL Java_org_ldk_enums_IOError_init (JNIEnv *env, jclass clz) {
373         IOError_class = (*env)->NewGlobalRef(env, clz);
374         CHECK(IOError_class != NULL);
375         IOError_LDKIOError_NotFound = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_NotFound", "Lorg/ldk/enums/IOError;");
376         CHECK(IOError_LDKIOError_NotFound != NULL);
377         IOError_LDKIOError_PermissionDenied = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_PermissionDenied", "Lorg/ldk/enums/IOError;");
378         CHECK(IOError_LDKIOError_PermissionDenied != NULL);
379         IOError_LDKIOError_ConnectionRefused = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_ConnectionRefused", "Lorg/ldk/enums/IOError;");
380         CHECK(IOError_LDKIOError_ConnectionRefused != NULL);
381         IOError_LDKIOError_ConnectionReset = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_ConnectionReset", "Lorg/ldk/enums/IOError;");
382         CHECK(IOError_LDKIOError_ConnectionReset != NULL);
383         IOError_LDKIOError_ConnectionAborted = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_ConnectionAborted", "Lorg/ldk/enums/IOError;");
384         CHECK(IOError_LDKIOError_ConnectionAborted != NULL);
385         IOError_LDKIOError_NotConnected = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_NotConnected", "Lorg/ldk/enums/IOError;");
386         CHECK(IOError_LDKIOError_NotConnected != NULL);
387         IOError_LDKIOError_AddrInUse = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_AddrInUse", "Lorg/ldk/enums/IOError;");
388         CHECK(IOError_LDKIOError_AddrInUse != NULL);
389         IOError_LDKIOError_AddrNotAvailable = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_AddrNotAvailable", "Lorg/ldk/enums/IOError;");
390         CHECK(IOError_LDKIOError_AddrNotAvailable != NULL);
391         IOError_LDKIOError_BrokenPipe = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_BrokenPipe", "Lorg/ldk/enums/IOError;");
392         CHECK(IOError_LDKIOError_BrokenPipe != NULL);
393         IOError_LDKIOError_AlreadyExists = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_AlreadyExists", "Lorg/ldk/enums/IOError;");
394         CHECK(IOError_LDKIOError_AlreadyExists != NULL);
395         IOError_LDKIOError_WouldBlock = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_WouldBlock", "Lorg/ldk/enums/IOError;");
396         CHECK(IOError_LDKIOError_WouldBlock != NULL);
397         IOError_LDKIOError_InvalidInput = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_InvalidInput", "Lorg/ldk/enums/IOError;");
398         CHECK(IOError_LDKIOError_InvalidInput != NULL);
399         IOError_LDKIOError_InvalidData = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_InvalidData", "Lorg/ldk/enums/IOError;");
400         CHECK(IOError_LDKIOError_InvalidData != NULL);
401         IOError_LDKIOError_TimedOut = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_TimedOut", "Lorg/ldk/enums/IOError;");
402         CHECK(IOError_LDKIOError_TimedOut != NULL);
403         IOError_LDKIOError_WriteZero = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_WriteZero", "Lorg/ldk/enums/IOError;");
404         CHECK(IOError_LDKIOError_WriteZero != NULL);
405         IOError_LDKIOError_Interrupted = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_Interrupted", "Lorg/ldk/enums/IOError;");
406         CHECK(IOError_LDKIOError_Interrupted != NULL);
407         IOError_LDKIOError_Other = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_Other", "Lorg/ldk/enums/IOError;");
408         CHECK(IOError_LDKIOError_Other != NULL);
409         IOError_LDKIOError_UnexpectedEof = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_UnexpectedEof", "Lorg/ldk/enums/IOError;");
410         CHECK(IOError_LDKIOError_UnexpectedEof != NULL);
411 }
412 static inline jclass LDKIOError_to_java(JNIEnv *env, LDKIOError val) {
413         switch (val) {
414                 case LDKIOError_NotFound:
415                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_NotFound);
416                 case LDKIOError_PermissionDenied:
417                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_PermissionDenied);
418                 case LDKIOError_ConnectionRefused:
419                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_ConnectionRefused);
420                 case LDKIOError_ConnectionReset:
421                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_ConnectionReset);
422                 case LDKIOError_ConnectionAborted:
423                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_ConnectionAborted);
424                 case LDKIOError_NotConnected:
425                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_NotConnected);
426                 case LDKIOError_AddrInUse:
427                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_AddrInUse);
428                 case LDKIOError_AddrNotAvailable:
429                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_AddrNotAvailable);
430                 case LDKIOError_BrokenPipe:
431                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_BrokenPipe);
432                 case LDKIOError_AlreadyExists:
433                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_AlreadyExists);
434                 case LDKIOError_WouldBlock:
435                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_WouldBlock);
436                 case LDKIOError_InvalidInput:
437                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_InvalidInput);
438                 case LDKIOError_InvalidData:
439                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_InvalidData);
440                 case LDKIOError_TimedOut:
441                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_TimedOut);
442                 case LDKIOError_WriteZero:
443                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_WriteZero);
444                 case LDKIOError_Interrupted:
445                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_Interrupted);
446                 case LDKIOError_Other:
447                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_Other);
448                 case LDKIOError_UnexpectedEof:
449                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_UnexpectedEof);
450                 default: abort();
451         }
452 }
453
454 static inline LDKLevel LDKLevel_from_java(JNIEnv *env, jclass clz) {
455         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
456                 case 0: return LDKLevel_Trace;
457                 case 1: return LDKLevel_Debug;
458                 case 2: return LDKLevel_Info;
459                 case 3: return LDKLevel_Warn;
460                 case 4: return LDKLevel_Error;
461         }
462         abort();
463 }
464 static jclass Level_class = NULL;
465 static jfieldID Level_LDKLevel_Trace = NULL;
466 static jfieldID Level_LDKLevel_Debug = NULL;
467 static jfieldID Level_LDKLevel_Info = NULL;
468 static jfieldID Level_LDKLevel_Warn = NULL;
469 static jfieldID Level_LDKLevel_Error = NULL;
470 JNIEXPORT void JNICALL Java_org_ldk_enums_Level_init (JNIEnv *env, jclass clz) {
471         Level_class = (*env)->NewGlobalRef(env, clz);
472         CHECK(Level_class != NULL);
473         Level_LDKLevel_Trace = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Trace", "Lorg/ldk/enums/Level;");
474         CHECK(Level_LDKLevel_Trace != NULL);
475         Level_LDKLevel_Debug = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Debug", "Lorg/ldk/enums/Level;");
476         CHECK(Level_LDKLevel_Debug != NULL);
477         Level_LDKLevel_Info = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Info", "Lorg/ldk/enums/Level;");
478         CHECK(Level_LDKLevel_Info != NULL);
479         Level_LDKLevel_Warn = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Warn", "Lorg/ldk/enums/Level;");
480         CHECK(Level_LDKLevel_Warn != NULL);
481         Level_LDKLevel_Error = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Error", "Lorg/ldk/enums/Level;");
482         CHECK(Level_LDKLevel_Error != NULL);
483 }
484 static inline jclass LDKLevel_to_java(JNIEnv *env, LDKLevel val) {
485         switch (val) {
486                 case LDKLevel_Trace:
487                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Trace);
488                 case LDKLevel_Debug:
489                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Debug);
490                 case LDKLevel_Info:
491                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Info);
492                 case LDKLevel_Warn:
493                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Warn);
494                 case LDKLevel_Error:
495                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Error);
496                 default: abort();
497         }
498 }
499
500 static inline LDKNetwork LDKNetwork_from_java(JNIEnv *env, jclass clz) {
501         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
502                 case 0: return LDKNetwork_Bitcoin;
503                 case 1: return LDKNetwork_Testnet;
504                 case 2: return LDKNetwork_Regtest;
505                 case 3: return LDKNetwork_Signet;
506         }
507         abort();
508 }
509 static jclass Network_class = NULL;
510 static jfieldID Network_LDKNetwork_Bitcoin = NULL;
511 static jfieldID Network_LDKNetwork_Testnet = NULL;
512 static jfieldID Network_LDKNetwork_Regtest = NULL;
513 static jfieldID Network_LDKNetwork_Signet = NULL;
514 JNIEXPORT void JNICALL Java_org_ldk_enums_Network_init (JNIEnv *env, jclass clz) {
515         Network_class = (*env)->NewGlobalRef(env, clz);
516         CHECK(Network_class != NULL);
517         Network_LDKNetwork_Bitcoin = (*env)->GetStaticFieldID(env, Network_class, "LDKNetwork_Bitcoin", "Lorg/ldk/enums/Network;");
518         CHECK(Network_LDKNetwork_Bitcoin != NULL);
519         Network_LDKNetwork_Testnet = (*env)->GetStaticFieldID(env, Network_class, "LDKNetwork_Testnet", "Lorg/ldk/enums/Network;");
520         CHECK(Network_LDKNetwork_Testnet != NULL);
521         Network_LDKNetwork_Regtest = (*env)->GetStaticFieldID(env, Network_class, "LDKNetwork_Regtest", "Lorg/ldk/enums/Network;");
522         CHECK(Network_LDKNetwork_Regtest != NULL);
523         Network_LDKNetwork_Signet = (*env)->GetStaticFieldID(env, Network_class, "LDKNetwork_Signet", "Lorg/ldk/enums/Network;");
524         CHECK(Network_LDKNetwork_Signet != NULL);
525 }
526 static inline jclass LDKNetwork_to_java(JNIEnv *env, LDKNetwork val) {
527         switch (val) {
528                 case LDKNetwork_Bitcoin:
529                         return (*env)->GetStaticObjectField(env, Network_class, Network_LDKNetwork_Bitcoin);
530                 case LDKNetwork_Testnet:
531                         return (*env)->GetStaticObjectField(env, Network_class, Network_LDKNetwork_Testnet);
532                 case LDKNetwork_Regtest:
533                         return (*env)->GetStaticObjectField(env, Network_class, Network_LDKNetwork_Regtest);
534                 case LDKNetwork_Signet:
535                         return (*env)->GetStaticObjectField(env, Network_class, Network_LDKNetwork_Signet);
536                 default: abort();
537         }
538 }
539
540 static inline LDKSecp256k1Error LDKSecp256k1Error_from_java(JNIEnv *env, jclass clz) {
541         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
542                 case 0: return LDKSecp256k1Error_IncorrectSignature;
543                 case 1: return LDKSecp256k1Error_InvalidMessage;
544                 case 2: return LDKSecp256k1Error_InvalidPublicKey;
545                 case 3: return LDKSecp256k1Error_InvalidSignature;
546                 case 4: return LDKSecp256k1Error_InvalidSecretKey;
547                 case 5: return LDKSecp256k1Error_InvalidRecoveryId;
548                 case 6: return LDKSecp256k1Error_InvalidTweak;
549                 case 7: return LDKSecp256k1Error_TweakCheckFailed;
550                 case 8: return LDKSecp256k1Error_NotEnoughMemory;
551         }
552         abort();
553 }
554 static jclass Secp256k1Error_class = NULL;
555 static jfieldID Secp256k1Error_LDKSecp256k1Error_IncorrectSignature = NULL;
556 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidMessage = NULL;
557 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey = NULL;
558 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidSignature = NULL;
559 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey = NULL;
560 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId = NULL;
561 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidTweak = NULL;
562 static jfieldID Secp256k1Error_LDKSecp256k1Error_TweakCheckFailed = NULL;
563 static jfieldID Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory = NULL;
564 JNIEXPORT void JNICALL Java_org_ldk_enums_Secp256k1Error_init (JNIEnv *env, jclass clz) {
565         Secp256k1Error_class = (*env)->NewGlobalRef(env, clz);
566         CHECK(Secp256k1Error_class != NULL);
567         Secp256k1Error_LDKSecp256k1Error_IncorrectSignature = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_IncorrectSignature", "Lorg/ldk/enums/Secp256k1Error;");
568         CHECK(Secp256k1Error_LDKSecp256k1Error_IncorrectSignature != NULL);
569         Secp256k1Error_LDKSecp256k1Error_InvalidMessage = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidMessage", "Lorg/ldk/enums/Secp256k1Error;");
570         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidMessage != NULL);
571         Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidPublicKey", "Lorg/ldk/enums/Secp256k1Error;");
572         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey != NULL);
573         Secp256k1Error_LDKSecp256k1Error_InvalidSignature = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidSignature", "Lorg/ldk/enums/Secp256k1Error;");
574         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidSignature != NULL);
575         Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidSecretKey", "Lorg/ldk/enums/Secp256k1Error;");
576         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey != NULL);
577         Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidRecoveryId", "Lorg/ldk/enums/Secp256k1Error;");
578         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId != NULL);
579         Secp256k1Error_LDKSecp256k1Error_InvalidTweak = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidTweak", "Lorg/ldk/enums/Secp256k1Error;");
580         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidTweak != NULL);
581         Secp256k1Error_LDKSecp256k1Error_TweakCheckFailed = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_TweakCheckFailed", "Lorg/ldk/enums/Secp256k1Error;");
582         CHECK(Secp256k1Error_LDKSecp256k1Error_TweakCheckFailed != NULL);
583         Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_NotEnoughMemory", "Lorg/ldk/enums/Secp256k1Error;");
584         CHECK(Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory != NULL);
585 }
586 static inline jclass LDKSecp256k1Error_to_java(JNIEnv *env, LDKSecp256k1Error val) {
587         switch (val) {
588                 case LDKSecp256k1Error_IncorrectSignature:
589                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_IncorrectSignature);
590                 case LDKSecp256k1Error_InvalidMessage:
591                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidMessage);
592                 case LDKSecp256k1Error_InvalidPublicKey:
593                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey);
594                 case LDKSecp256k1Error_InvalidSignature:
595                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidSignature);
596                 case LDKSecp256k1Error_InvalidSecretKey:
597                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey);
598                 case LDKSecp256k1Error_InvalidRecoveryId:
599                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId);
600                 case LDKSecp256k1Error_InvalidTweak:
601                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidTweak);
602                 case LDKSecp256k1Error_TweakCheckFailed:
603                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_TweakCheckFailed);
604                 case LDKSecp256k1Error_NotEnoughMemory:
605                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory);
606                 default: abort();
607         }
608 }
609
610 static inline LDKSemanticError LDKSemanticError_from_java(JNIEnv *env, jclass clz) {
611         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
612                 case 0: return LDKSemanticError_NoPaymentHash;
613                 case 1: return LDKSemanticError_MultiplePaymentHashes;
614                 case 2: return LDKSemanticError_NoDescription;
615                 case 3: return LDKSemanticError_MultipleDescriptions;
616                 case 4: return LDKSemanticError_NoPaymentSecret;
617                 case 5: return LDKSemanticError_MultiplePaymentSecrets;
618                 case 6: return LDKSemanticError_InvalidFeatures;
619                 case 7: return LDKSemanticError_InvalidRecoveryId;
620                 case 8: return LDKSemanticError_InvalidSignature;
621                 case 9: return LDKSemanticError_ImpreciseAmount;
622         }
623         abort();
624 }
625 static jclass SemanticError_class = NULL;
626 static jfieldID SemanticError_LDKSemanticError_NoPaymentHash = NULL;
627 static jfieldID SemanticError_LDKSemanticError_MultiplePaymentHashes = NULL;
628 static jfieldID SemanticError_LDKSemanticError_NoDescription = NULL;
629 static jfieldID SemanticError_LDKSemanticError_MultipleDescriptions = NULL;
630 static jfieldID SemanticError_LDKSemanticError_NoPaymentSecret = NULL;
631 static jfieldID SemanticError_LDKSemanticError_MultiplePaymentSecrets = NULL;
632 static jfieldID SemanticError_LDKSemanticError_InvalidFeatures = NULL;
633 static jfieldID SemanticError_LDKSemanticError_InvalidRecoveryId = NULL;
634 static jfieldID SemanticError_LDKSemanticError_InvalidSignature = NULL;
635 static jfieldID SemanticError_LDKSemanticError_ImpreciseAmount = NULL;
636 JNIEXPORT void JNICALL Java_org_ldk_enums_SemanticError_init (JNIEnv *env, jclass clz) {
637         SemanticError_class = (*env)->NewGlobalRef(env, clz);
638         CHECK(SemanticError_class != NULL);
639         SemanticError_LDKSemanticError_NoPaymentHash = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_NoPaymentHash", "Lorg/ldk/enums/SemanticError;");
640         CHECK(SemanticError_LDKSemanticError_NoPaymentHash != NULL);
641         SemanticError_LDKSemanticError_MultiplePaymentHashes = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_MultiplePaymentHashes", "Lorg/ldk/enums/SemanticError;");
642         CHECK(SemanticError_LDKSemanticError_MultiplePaymentHashes != NULL);
643         SemanticError_LDKSemanticError_NoDescription = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_NoDescription", "Lorg/ldk/enums/SemanticError;");
644         CHECK(SemanticError_LDKSemanticError_NoDescription != NULL);
645         SemanticError_LDKSemanticError_MultipleDescriptions = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_MultipleDescriptions", "Lorg/ldk/enums/SemanticError;");
646         CHECK(SemanticError_LDKSemanticError_MultipleDescriptions != NULL);
647         SemanticError_LDKSemanticError_NoPaymentSecret = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_NoPaymentSecret", "Lorg/ldk/enums/SemanticError;");
648         CHECK(SemanticError_LDKSemanticError_NoPaymentSecret != NULL);
649         SemanticError_LDKSemanticError_MultiplePaymentSecrets = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_MultiplePaymentSecrets", "Lorg/ldk/enums/SemanticError;");
650         CHECK(SemanticError_LDKSemanticError_MultiplePaymentSecrets != NULL);
651         SemanticError_LDKSemanticError_InvalidFeatures = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_InvalidFeatures", "Lorg/ldk/enums/SemanticError;");
652         CHECK(SemanticError_LDKSemanticError_InvalidFeatures != NULL);
653         SemanticError_LDKSemanticError_InvalidRecoveryId = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_InvalidRecoveryId", "Lorg/ldk/enums/SemanticError;");
654         CHECK(SemanticError_LDKSemanticError_InvalidRecoveryId != NULL);
655         SemanticError_LDKSemanticError_InvalidSignature = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_InvalidSignature", "Lorg/ldk/enums/SemanticError;");
656         CHECK(SemanticError_LDKSemanticError_InvalidSignature != NULL);
657         SemanticError_LDKSemanticError_ImpreciseAmount = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_ImpreciseAmount", "Lorg/ldk/enums/SemanticError;");
658         CHECK(SemanticError_LDKSemanticError_ImpreciseAmount != NULL);
659 }
660 static inline jclass LDKSemanticError_to_java(JNIEnv *env, LDKSemanticError val) {
661         switch (val) {
662                 case LDKSemanticError_NoPaymentHash:
663                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_NoPaymentHash);
664                 case LDKSemanticError_MultiplePaymentHashes:
665                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_MultiplePaymentHashes);
666                 case LDKSemanticError_NoDescription:
667                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_NoDescription);
668                 case LDKSemanticError_MultipleDescriptions:
669                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_MultipleDescriptions);
670                 case LDKSemanticError_NoPaymentSecret:
671                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_NoPaymentSecret);
672                 case LDKSemanticError_MultiplePaymentSecrets:
673                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_MultiplePaymentSecrets);
674                 case LDKSemanticError_InvalidFeatures:
675                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_InvalidFeatures);
676                 case LDKSemanticError_InvalidRecoveryId:
677                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_InvalidRecoveryId);
678                 case LDKSemanticError_InvalidSignature:
679                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_InvalidSignature);
680                 case LDKSemanticError_ImpreciseAmount:
681                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_ImpreciseAmount);
682                 default: abort();
683         }
684 }
685
686 static inline LDKSiPrefix LDKSiPrefix_from_java(JNIEnv *env, jclass clz) {
687         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
688                 case 0: return LDKSiPrefix_Milli;
689                 case 1: return LDKSiPrefix_Micro;
690                 case 2: return LDKSiPrefix_Nano;
691                 case 3: return LDKSiPrefix_Pico;
692         }
693         abort();
694 }
695 static jclass SiPrefix_class = NULL;
696 static jfieldID SiPrefix_LDKSiPrefix_Milli = NULL;
697 static jfieldID SiPrefix_LDKSiPrefix_Micro = NULL;
698 static jfieldID SiPrefix_LDKSiPrefix_Nano = NULL;
699 static jfieldID SiPrefix_LDKSiPrefix_Pico = NULL;
700 JNIEXPORT void JNICALL Java_org_ldk_enums_SiPrefix_init (JNIEnv *env, jclass clz) {
701         SiPrefix_class = (*env)->NewGlobalRef(env, clz);
702         CHECK(SiPrefix_class != NULL);
703         SiPrefix_LDKSiPrefix_Milli = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Milli", "Lorg/ldk/enums/SiPrefix;");
704         CHECK(SiPrefix_LDKSiPrefix_Milli != NULL);
705         SiPrefix_LDKSiPrefix_Micro = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Micro", "Lorg/ldk/enums/SiPrefix;");
706         CHECK(SiPrefix_LDKSiPrefix_Micro != NULL);
707         SiPrefix_LDKSiPrefix_Nano = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Nano", "Lorg/ldk/enums/SiPrefix;");
708         CHECK(SiPrefix_LDKSiPrefix_Nano != NULL);
709         SiPrefix_LDKSiPrefix_Pico = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Pico", "Lorg/ldk/enums/SiPrefix;");
710         CHECK(SiPrefix_LDKSiPrefix_Pico != NULL);
711 }
712 static inline jclass LDKSiPrefix_to_java(JNIEnv *env, LDKSiPrefix val) {
713         switch (val) {
714                 case LDKSiPrefix_Milli:
715                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Milli);
716                 case LDKSiPrefix_Micro:
717                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Micro);
718                 case LDKSiPrefix_Nano:
719                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Nano);
720                 case LDKSiPrefix_Pico:
721                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Pico);
722                 default: abort();
723         }
724 }
725
726 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1u8Z_1new(JNIEnv *env, jclass clz, int8_tArray elems) {
727         LDKCVec_u8Z *ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
728         ret->datalen = (*env)->GetArrayLength(env, elems);
729         if (ret->datalen == 0) {
730                 ret->data = NULL;
731         } else {
732                 ret->data = MALLOC(sizeof(uint8_t) * ret->datalen, "LDKCVec_u8Z Data");
733                 int8_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
734                 for (size_t i = 0; i < ret->datalen; i++) {
735                         ret->data[i] = java_elems[i];
736                 }
737                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
738         }
739         return (uint64_t)ret;
740 }
741 static inline LDKCVec_u8Z CVec_u8Z_clone(const LDKCVec_u8Z *orig) {
742         LDKCVec_u8Z ret = { .data = MALLOC(sizeof(int8_t) * orig->datalen, "LDKCVec_u8Z clone bytes"), .datalen = orig->datalen };
743         memcpy(ret.data, orig->data, sizeof(int8_t) * ret.datalen);
744         return ret;
745 }
746 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) {
747         LDKTxOut* thing_conv = (LDKTxOut*)(thing & ~1);
748         LDKCVec_u8Z ret_var = TxOut_get_script_pubkey(thing_conv);
749         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
750         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
751         CVec_u8Z_free(ret_var);
752         return ret_arr;
753 }
754
755 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) {
756         LDKTxOut* thing_conv = (LDKTxOut*)(thing & ~1);
757         int64_t ret_val = TxOut_get_value(thing_conv);
758         return ret_val;
759 }
760
761 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SecretKeyErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
762         return ((LDKCResult_SecretKeyErrorZ*)arg)->result_ok;
763 }
764 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SecretKeyErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
765         LDKCResult_SecretKeyErrorZ *val = (LDKCResult_SecretKeyErrorZ*)(arg & ~1);
766         CHECK(val->result_ok);
767         int8_tArray res_arr = (*env)->NewByteArray(env, 32);
768         (*env)->SetByteArrayRegion(env, res_arr, 0, 32, (*val->contents.result).bytes);
769         return res_arr;
770 }
771 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SecretKeyErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
772         LDKCResult_SecretKeyErrorZ *val = (LDKCResult_SecretKeyErrorZ*)(arg & ~1);
773         CHECK(!val->result_ok);
774         jclass err_conv = LDKSecp256k1Error_to_java(env, (*val->contents.err));
775         return err_conv;
776 }
777 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PublicKeyErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
778         return ((LDKCResult_PublicKeyErrorZ*)arg)->result_ok;
779 }
780 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PublicKeyErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
781         LDKCResult_PublicKeyErrorZ *val = (LDKCResult_PublicKeyErrorZ*)(arg & ~1);
782         CHECK(val->result_ok);
783         int8_tArray res_arr = (*env)->NewByteArray(env, 33);
784         (*env)->SetByteArrayRegion(env, res_arr, 0, 33, (*val->contents.result).compressed_form);
785         return res_arr;
786 }
787 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PublicKeyErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
788         LDKCResult_PublicKeyErrorZ *val = (LDKCResult_PublicKeyErrorZ*)(arg & ~1);
789         CHECK(!val->result_ok);
790         jclass err_conv = LDKSecp256k1Error_to_java(env, (*val->contents.err));
791         return err_conv;
792 }
793 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
794         return ((LDKCResult_TxCreationKeysDecodeErrorZ*)arg)->result_ok;
795 }
796 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
797         LDKCResult_TxCreationKeysDecodeErrorZ *val = (LDKCResult_TxCreationKeysDecodeErrorZ*)(arg & ~1);
798         CHECK(val->result_ok);
799         LDKTxCreationKeys res_var = (*val->contents.result);
800         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
801         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
802         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
803         return res_ref;
804 }
805 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
806         LDKCResult_TxCreationKeysDecodeErrorZ *val = (LDKCResult_TxCreationKeysDecodeErrorZ*)(arg & ~1);
807         CHECK(!val->result_ok);
808         LDKDecodeError err_var = (*val->contents.err);
809         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
810         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
811         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
812         return err_ref;
813 }
814 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelPublicKeysDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
815         return ((LDKCResult_ChannelPublicKeysDecodeErrorZ*)arg)->result_ok;
816 }
817 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelPublicKeysDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
818         LDKCResult_ChannelPublicKeysDecodeErrorZ *val = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(arg & ~1);
819         CHECK(val->result_ok);
820         LDKChannelPublicKeys res_var = (*val->contents.result);
821         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
822         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
823         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
824         return res_ref;
825 }
826 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelPublicKeysDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
827         LDKCResult_ChannelPublicKeysDecodeErrorZ *val = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(arg & ~1);
828         CHECK(!val->result_ok);
829         LDKDecodeError err_var = (*val->contents.err);
830         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
831         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
832         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
833         return err_ref;
834 }
835 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
836         return ((LDKCResult_TxCreationKeysErrorZ*)arg)->result_ok;
837 }
838 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
839         LDKCResult_TxCreationKeysErrorZ *val = (LDKCResult_TxCreationKeysErrorZ*)(arg & ~1);
840         CHECK(val->result_ok);
841         LDKTxCreationKeys res_var = (*val->contents.result);
842         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
843         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
844         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
845         return res_ref;
846 }
847 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
848         LDKCResult_TxCreationKeysErrorZ *val = (LDKCResult_TxCreationKeysErrorZ*)(arg & ~1);
849         CHECK(!val->result_ok);
850         jclass err_conv = LDKSecp256k1Error_to_java(env, (*val->contents.err));
851         return err_conv;
852 }
853 static jclass LDKCOption_u32Z_Some_class = NULL;
854 static jmethodID LDKCOption_u32Z_Some_meth = NULL;
855 static jclass LDKCOption_u32Z_None_class = NULL;
856 static jmethodID LDKCOption_u32Z_None_meth = NULL;
857 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u32Z_init (JNIEnv *env, jclass clz) {
858         LDKCOption_u32Z_Some_class =
859                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_u32Z$Some;"));
860         CHECK(LDKCOption_u32Z_Some_class != NULL);
861         LDKCOption_u32Z_Some_meth = (*env)->GetMethodID(env, LDKCOption_u32Z_Some_class, "<init>", "(I)V");
862         CHECK(LDKCOption_u32Z_Some_meth != NULL);
863         LDKCOption_u32Z_None_class =
864                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_u32Z$None;"));
865         CHECK(LDKCOption_u32Z_None_class != NULL);
866         LDKCOption_u32Z_None_meth = (*env)->GetMethodID(env, LDKCOption_u32Z_None_class, "<init>", "()V");
867         CHECK(LDKCOption_u32Z_None_meth != NULL);
868 }
869 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u32Z_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
870         LDKCOption_u32Z *obj = (LDKCOption_u32Z*)(ptr & ~1);
871         switch(obj->tag) {
872                 case LDKCOption_u32Z_Some: {
873                         return (*env)->NewObject(env, LDKCOption_u32Z_Some_class, LDKCOption_u32Z_Some_meth, obj->some);
874                 }
875                 case LDKCOption_u32Z_None: {
876                         return (*env)->NewObject(env, LDKCOption_u32Z_None_class, LDKCOption_u32Z_None_meth);
877                 }
878                 default: abort();
879         }
880 }
881 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCOutputInCommitmentDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
882         return ((LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)arg)->result_ok;
883 }
884 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCOutputInCommitmentDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
885         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *val = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(arg & ~1);
886         CHECK(val->result_ok);
887         LDKHTLCOutputInCommitment res_var = (*val->contents.result);
888         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
889         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
890         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
891         return res_ref;
892 }
893 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCOutputInCommitmentDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
894         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *val = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(arg & ~1);
895         CHECK(!val->result_ok);
896         LDKDecodeError err_var = (*val->contents.err);
897         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
898         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
899         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
900         return err_ref;
901 }
902 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
903         return ((LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)arg)->result_ok;
904 }
905 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
906         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
907         CHECK(val->result_ok);
908         LDKCounterpartyChannelTransactionParameters res_var = (*val->contents.result);
909         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
910         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
911         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
912         return res_ref;
913 }
914 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
915         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
916         CHECK(!val->result_ok);
917         LDKDecodeError err_var = (*val->contents.err);
918         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
919         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
920         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
921         return err_ref;
922 }
923 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelTransactionParametersDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
924         return ((LDKCResult_ChannelTransactionParametersDecodeErrorZ*)arg)->result_ok;
925 }
926 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelTransactionParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
927         LDKCResult_ChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
928         CHECK(val->result_ok);
929         LDKChannelTransactionParameters res_var = (*val->contents.result);
930         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
931         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
932         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
933         return res_ref;
934 }
935 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelTransactionParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
936         LDKCResult_ChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
937         CHECK(!val->result_ok);
938         LDKDecodeError err_var = (*val->contents.err);
939         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
940         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
941         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
942         return err_ref;
943 }
944 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HolderCommitmentTransactionDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
945         return ((LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)arg)->result_ok;
946 }
947 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HolderCommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
948         LDKCResult_HolderCommitmentTransactionDecodeErrorZ *val = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(arg & ~1);
949         CHECK(val->result_ok);
950         LDKHolderCommitmentTransaction res_var = (*val->contents.result);
951         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
952         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
953         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
954         return res_ref;
955 }
956 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HolderCommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
957         LDKCResult_HolderCommitmentTransactionDecodeErrorZ *val = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(arg & ~1);
958         CHECK(!val->result_ok);
959         LDKDecodeError err_var = (*val->contents.err);
960         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
961         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
962         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
963         return err_ref;
964 }
965 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1BuiltCommitmentTransactionDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
966         return ((LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)arg)->result_ok;
967 }
968 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1BuiltCommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
969         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *val = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(arg & ~1);
970         CHECK(val->result_ok);
971         LDKBuiltCommitmentTransaction res_var = (*val->contents.result);
972         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
973         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
974         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
975         return res_ref;
976 }
977 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1BuiltCommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
978         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *val = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(arg & ~1);
979         CHECK(!val->result_ok);
980         LDKDecodeError err_var = (*val->contents.err);
981         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
982         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
983         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
984         return err_ref;
985 }
986 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TrustedClosingTransactionNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
987         return ((LDKCResult_TrustedClosingTransactionNoneZ*)arg)->result_ok;
988 }
989 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TrustedClosingTransactionNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
990         LDKCResult_TrustedClosingTransactionNoneZ *val = (LDKCResult_TrustedClosingTransactionNoneZ*)(arg & ~1);
991         CHECK(val->result_ok);
992         LDKTrustedClosingTransaction res_var = (*val->contents.result);
993         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
994         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
995         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
996         return res_ref;
997 }
998 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TrustedClosingTransactionNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
999         LDKCResult_TrustedClosingTransactionNoneZ *val = (LDKCResult_TrustedClosingTransactionNoneZ*)(arg & ~1);
1000         CHECK(!val->result_ok);
1001         return *val->contents.err;
1002 }
1003 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentTransactionDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1004         return ((LDKCResult_CommitmentTransactionDecodeErrorZ*)arg)->result_ok;
1005 }
1006 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1007         LDKCResult_CommitmentTransactionDecodeErrorZ *val = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(arg & ~1);
1008         CHECK(val->result_ok);
1009         LDKCommitmentTransaction res_var = (*val->contents.result);
1010         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1011         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1012         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1013         return res_ref;
1014 }
1015 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1016         LDKCResult_CommitmentTransactionDecodeErrorZ *val = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(arg & ~1);
1017         CHECK(!val->result_ok);
1018         LDKDecodeError err_var = (*val->contents.err);
1019         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1020         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1021         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1022         return err_ref;
1023 }
1024 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TrustedCommitmentTransactionNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1025         return ((LDKCResult_TrustedCommitmentTransactionNoneZ*)arg)->result_ok;
1026 }
1027 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TrustedCommitmentTransactionNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1028         LDKCResult_TrustedCommitmentTransactionNoneZ *val = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(arg & ~1);
1029         CHECK(val->result_ok);
1030         LDKTrustedCommitmentTransaction res_var = (*val->contents.result);
1031         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1032         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1033         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1034         return res_ref;
1035 }
1036 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TrustedCommitmentTransactionNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1037         LDKCResult_TrustedCommitmentTransactionNoneZ *val = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(arg & ~1);
1038         CHECK(!val->result_ok);
1039         return *val->contents.err;
1040 }
1041 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1SignatureZNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1042         return ((LDKCResult_CVec_SignatureZNoneZ*)arg)->result_ok;
1043 }
1044 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1SignatureZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1045         LDKCResult_CVec_SignatureZNoneZ *val = (LDKCResult_CVec_SignatureZNoneZ*)(arg & ~1);
1046         CHECK(val->result_ok);
1047         LDKCVec_SignatureZ res_var = (*val->contents.result);
1048         jobjectArray res_arr = (*env)->NewObjectArray(env, res_var.datalen, arr_of_B_clz, NULL);
1049         ;
1050         for (size_t i = 0; i < res_var.datalen; i++) {
1051                 int8_tArray res_conv_8_arr = (*env)->NewByteArray(env, 64);
1052                 (*env)->SetByteArrayRegion(env, res_conv_8_arr, 0, 64, res_var.data[i].compact_form);
1053                 (*env)->SetObjectArrayElement(env, res_arr, i, res_conv_8_arr);
1054         }
1055         return res_arr;
1056 }
1057 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1SignatureZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1058         LDKCResult_CVec_SignatureZNoneZ *val = (LDKCResult_CVec_SignatureZNoneZ*)(arg & ~1);
1059         CHECK(!val->result_ok);
1060         return *val->contents.err;
1061 }
1062 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownScriptDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1063         return ((LDKCResult_ShutdownScriptDecodeErrorZ*)arg)->result_ok;
1064 }
1065 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownScriptDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1066         LDKCResult_ShutdownScriptDecodeErrorZ *val = (LDKCResult_ShutdownScriptDecodeErrorZ*)(arg & ~1);
1067         CHECK(val->result_ok);
1068         LDKShutdownScript res_var = (*val->contents.result);
1069         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1070         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1071         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1072         return res_ref;
1073 }
1074 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownScriptDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1075         LDKCResult_ShutdownScriptDecodeErrorZ *val = (LDKCResult_ShutdownScriptDecodeErrorZ*)(arg & ~1);
1076         CHECK(!val->result_ok);
1077         LDKDecodeError err_var = (*val->contents.err);
1078         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1079         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1080         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1081         return err_ref;
1082 }
1083 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownScriptInvalidShutdownScriptZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1084         return ((LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)arg)->result_ok;
1085 }
1086 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownScriptInvalidShutdownScriptZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1087         LDKCResult_ShutdownScriptInvalidShutdownScriptZ *val = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(arg & ~1);
1088         CHECK(val->result_ok);
1089         LDKShutdownScript res_var = (*val->contents.result);
1090         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1091         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1092         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1093         return res_ref;
1094 }
1095 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownScriptInvalidShutdownScriptZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1096         LDKCResult_ShutdownScriptInvalidShutdownScriptZ *val = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(arg & ~1);
1097         CHECK(!val->result_ok);
1098         LDKInvalidShutdownScript err_var = (*val->contents.err);
1099         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1100         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1101         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1102         return err_ref;
1103 }
1104 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1105         return ((LDKCResult_NoneErrorZ*)arg)->result_ok;
1106 }
1107 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1108         LDKCResult_NoneErrorZ *val = (LDKCResult_NoneErrorZ*)(arg & ~1);
1109         CHECK(val->result_ok);
1110         return *val->contents.result;
1111 }
1112 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1113         LDKCResult_NoneErrorZ *val = (LDKCResult_NoneErrorZ*)(arg & ~1);
1114         CHECK(!val->result_ok);
1115         jclass err_conv = LDKIOError_to_java(env, (*val->contents.err));
1116         return err_conv;
1117 }
1118 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteHopDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1119         return ((LDKCResult_RouteHopDecodeErrorZ*)arg)->result_ok;
1120 }
1121 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteHopDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1122         LDKCResult_RouteHopDecodeErrorZ *val = (LDKCResult_RouteHopDecodeErrorZ*)(arg & ~1);
1123         CHECK(val->result_ok);
1124         LDKRouteHop res_var = (*val->contents.result);
1125         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1126         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1127         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1128         return res_ref;
1129 }
1130 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteHopDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1131         LDKCResult_RouteHopDecodeErrorZ *val = (LDKCResult_RouteHopDecodeErrorZ*)(arg & ~1);
1132         CHECK(!val->result_ok);
1133         LDKDecodeError err_var = (*val->contents.err);
1134         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1135         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1136         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1137         return err_ref;
1138 }
1139 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1RouteHopZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1140         LDKCVec_RouteHopZ *ret = MALLOC(sizeof(LDKCVec_RouteHopZ), "LDKCVec_RouteHopZ");
1141         ret->datalen = (*env)->GetArrayLength(env, elems);
1142         if (ret->datalen == 0) {
1143                 ret->data = NULL;
1144         } else {
1145                 ret->data = MALLOC(sizeof(LDKRouteHop) * ret->datalen, "LDKCVec_RouteHopZ Data");
1146                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1147                 for (size_t i = 0; i < ret->datalen; i++) {
1148                         int64_t arr_elem = java_elems[i];
1149                         LDKRouteHop arr_elem_conv;
1150                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
1151                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
1152                         arr_elem_conv = RouteHop_clone(&arr_elem_conv);
1153                         ret->data[i] = arr_elem_conv;
1154                 }
1155                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1156         }
1157         return (uint64_t)ret;
1158 }
1159 static inline LDKCVec_RouteHopZ CVec_RouteHopZ_clone(const LDKCVec_RouteHopZ *orig) {
1160         LDKCVec_RouteHopZ ret = { .data = MALLOC(sizeof(LDKRouteHop) * orig->datalen, "LDKCVec_RouteHopZ clone bytes"), .datalen = orig->datalen };
1161         for (size_t i = 0; i < ret.datalen; i++) {
1162                 ret.data[i] = RouteHop_clone(&orig->data[i]);
1163         }
1164         return ret;
1165 }
1166 static inline LDKCVec_CVec_RouteHopZZ CVec_CVec_RouteHopZZ_clone(const LDKCVec_CVec_RouteHopZZ *orig) {
1167         LDKCVec_CVec_RouteHopZZ ret = { .data = MALLOC(sizeof(LDKCVec_RouteHopZ) * orig->datalen, "LDKCVec_CVec_RouteHopZZ clone bytes"), .datalen = orig->datalen };
1168         for (size_t i = 0; i < ret.datalen; i++) {
1169                 ret.data[i] = CVec_RouteHopZ_clone(&orig->data[i]);
1170         }
1171         return ret;
1172 }
1173 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1174         return ((LDKCResult_RouteDecodeErrorZ*)arg)->result_ok;
1175 }
1176 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1177         LDKCResult_RouteDecodeErrorZ *val = (LDKCResult_RouteDecodeErrorZ*)(arg & ~1);
1178         CHECK(val->result_ok);
1179         LDKRoute res_var = (*val->contents.result);
1180         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1181         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1182         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1183         return res_ref;
1184 }
1185 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1186         LDKCResult_RouteDecodeErrorZ *val = (LDKCResult_RouteDecodeErrorZ*)(arg & ~1);
1187         CHECK(!val->result_ok);
1188         LDKDecodeError err_var = (*val->contents.err);
1189         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1190         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1191         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1192         return err_ref;
1193 }
1194 static jclass LDKCOption_u64Z_Some_class = NULL;
1195 static jmethodID LDKCOption_u64Z_Some_meth = NULL;
1196 static jclass LDKCOption_u64Z_None_class = NULL;
1197 static jmethodID LDKCOption_u64Z_None_meth = NULL;
1198 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u64Z_init (JNIEnv *env, jclass clz) {
1199         LDKCOption_u64Z_Some_class =
1200                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_u64Z$Some;"));
1201         CHECK(LDKCOption_u64Z_Some_class != NULL);
1202         LDKCOption_u64Z_Some_meth = (*env)->GetMethodID(env, LDKCOption_u64Z_Some_class, "<init>", "(J)V");
1203         CHECK(LDKCOption_u64Z_Some_meth != NULL);
1204         LDKCOption_u64Z_None_class =
1205                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_u64Z$None;"));
1206         CHECK(LDKCOption_u64Z_None_class != NULL);
1207         LDKCOption_u64Z_None_meth = (*env)->GetMethodID(env, LDKCOption_u64Z_None_class, "<init>", "()V");
1208         CHECK(LDKCOption_u64Z_None_meth != NULL);
1209 }
1210 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u64Z_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1211         LDKCOption_u64Z *obj = (LDKCOption_u64Z*)(ptr & ~1);
1212         switch(obj->tag) {
1213                 case LDKCOption_u64Z_Some: {
1214                         return (*env)->NewObject(env, LDKCOption_u64Z_Some_class, LDKCOption_u64Z_Some_meth, obj->some);
1215                 }
1216                 case LDKCOption_u64Z_None: {
1217                         return (*env)->NewObject(env, LDKCOption_u64Z_None_class, LDKCOption_u64Z_None_meth);
1218                 }
1219                 default: abort();
1220         }
1221 }
1222 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1ChannelDetailsZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1223         LDKCVec_ChannelDetailsZ *ret = MALLOC(sizeof(LDKCVec_ChannelDetailsZ), "LDKCVec_ChannelDetailsZ");
1224         ret->datalen = (*env)->GetArrayLength(env, elems);
1225         if (ret->datalen == 0) {
1226                 ret->data = NULL;
1227         } else {
1228                 ret->data = MALLOC(sizeof(LDKChannelDetails) * ret->datalen, "LDKCVec_ChannelDetailsZ Data");
1229                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1230                 for (size_t i = 0; i < ret->datalen; i++) {
1231                         int64_t arr_elem = java_elems[i];
1232                         LDKChannelDetails arr_elem_conv;
1233                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
1234                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
1235                         arr_elem_conv = ChannelDetails_clone(&arr_elem_conv);
1236                         ret->data[i] = arr_elem_conv;
1237                 }
1238                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1239         }
1240         return (uint64_t)ret;
1241 }
1242 static inline LDKCVec_ChannelDetailsZ CVec_ChannelDetailsZ_clone(const LDKCVec_ChannelDetailsZ *orig) {
1243         LDKCVec_ChannelDetailsZ ret = { .data = MALLOC(sizeof(LDKChannelDetails) * orig->datalen, "LDKCVec_ChannelDetailsZ clone bytes"), .datalen = orig->datalen };
1244         for (size_t i = 0; i < ret.datalen; i++) {
1245                 ret.data[i] = ChannelDetails_clone(&orig->data[i]);
1246         }
1247         return ret;
1248 }
1249 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1RouteHintZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1250         LDKCVec_RouteHintZ *ret = MALLOC(sizeof(LDKCVec_RouteHintZ), "LDKCVec_RouteHintZ");
1251         ret->datalen = (*env)->GetArrayLength(env, elems);
1252         if (ret->datalen == 0) {
1253                 ret->data = NULL;
1254         } else {
1255                 ret->data = MALLOC(sizeof(LDKRouteHint) * ret->datalen, "LDKCVec_RouteHintZ Data");
1256                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1257                 for (size_t i = 0; i < ret->datalen; i++) {
1258                         int64_t arr_elem = java_elems[i];
1259                         LDKRouteHint arr_elem_conv;
1260                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
1261                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
1262                         arr_elem_conv = RouteHint_clone(&arr_elem_conv);
1263                         ret->data[i] = arr_elem_conv;
1264                 }
1265                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1266         }
1267         return (uint64_t)ret;
1268 }
1269 static inline LDKCVec_RouteHintZ CVec_RouteHintZ_clone(const LDKCVec_RouteHintZ *orig) {
1270         LDKCVec_RouteHintZ ret = { .data = MALLOC(sizeof(LDKRouteHint) * orig->datalen, "LDKCVec_RouteHintZ clone bytes"), .datalen = orig->datalen };
1271         for (size_t i = 0; i < ret.datalen; i++) {
1272                 ret.data[i] = RouteHint_clone(&orig->data[i]);
1273         }
1274         return ret;
1275 }
1276 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteLightningErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1277         return ((LDKCResult_RouteLightningErrorZ*)arg)->result_ok;
1278 }
1279 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1280         LDKCResult_RouteLightningErrorZ *val = (LDKCResult_RouteLightningErrorZ*)(arg & ~1);
1281         CHECK(val->result_ok);
1282         LDKRoute res_var = (*val->contents.result);
1283         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1284         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1285         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1286         return res_ref;
1287 }
1288 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1289         LDKCResult_RouteLightningErrorZ *val = (LDKCResult_RouteLightningErrorZ*)(arg & ~1);
1290         CHECK(!val->result_ok);
1291         LDKLightningError err_var = (*val->contents.err);
1292         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1293         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1294         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1295         return err_ref;
1296 }
1297 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxOutAccessErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1298         return ((LDKCResult_TxOutAccessErrorZ*)arg)->result_ok;
1299 }
1300 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxOutAccessErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1301         LDKCResult_TxOutAccessErrorZ *val = (LDKCResult_TxOutAccessErrorZ*)(arg & ~1);
1302         CHECK(val->result_ok);
1303         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
1304         return (uint64_t)res_ref;
1305 }
1306 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxOutAccessErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1307         LDKCResult_TxOutAccessErrorZ *val = (LDKCResult_TxOutAccessErrorZ*)(arg & ~1);
1308         CHECK(!val->result_ok);
1309         jclass err_conv = LDKAccessError_to_java(env, (*val->contents.err));
1310         return err_conv;
1311 }
1312 static inline uintptr_t C2Tuple_usizeTransactionZ_get_a(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR tuple){
1313         return tuple->a;
1314 }
1315 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1get_1a(JNIEnv *env, jclass clz, int64_t tuple) {
1316         LDKC2Tuple_usizeTransactionZ* tuple_conv = (LDKC2Tuple_usizeTransactionZ*)(tuple & ~1);
1317         int64_t ret_val = C2Tuple_usizeTransactionZ_get_a(tuple_conv);
1318         return ret_val;
1319 }
1320
1321 static inline struct LDKTransaction C2Tuple_usizeTransactionZ_get_b(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR tuple){
1322         return tuple->b;
1323 }
1324 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1get_1b(JNIEnv *env, jclass clz, int64_t tuple) {
1325         LDKC2Tuple_usizeTransactionZ* tuple_conv = (LDKC2Tuple_usizeTransactionZ*)(tuple & ~1);
1326         LDKTransaction ret_var = C2Tuple_usizeTransactionZ_get_b(tuple_conv);
1327         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
1328         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
1329         Transaction_free(ret_var);
1330         return ret_arr;
1331 }
1332
1333 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1usizeTransactionZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1334         LDKCVec_C2Tuple_usizeTransactionZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_usizeTransactionZZ), "LDKCVec_C2Tuple_usizeTransactionZZ");
1335         ret->datalen = (*env)->GetArrayLength(env, elems);
1336         if (ret->datalen == 0) {
1337                 ret->data = NULL;
1338         } else {
1339                 ret->data = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ) * ret->datalen, "LDKCVec_C2Tuple_usizeTransactionZZ Data");
1340                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1341                 for (size_t i = 0; i < ret->datalen; i++) {
1342                         int64_t arr_elem = java_elems[i];
1343                         void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
1344                         CHECK_ACCESS(arr_elem_ptr);
1345                         LDKC2Tuple_usizeTransactionZ arr_elem_conv = *(LDKC2Tuple_usizeTransactionZ*)(arr_elem_ptr);
1346                         arr_elem_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)arr_elem) & ~1));
1347                         ret->data[i] = arr_elem_conv;
1348                 }
1349                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1350         }
1351         return (uint64_t)ret;
1352 }
1353 static inline LDKCVec_C2Tuple_usizeTransactionZZ CVec_C2Tuple_usizeTransactionZZ_clone(const LDKCVec_C2Tuple_usizeTransactionZZ *orig) {
1354         LDKCVec_C2Tuple_usizeTransactionZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ) * orig->datalen, "LDKCVec_C2Tuple_usizeTransactionZZ clone bytes"), .datalen = orig->datalen };
1355         for (size_t i = 0; i < ret.datalen; i++) {
1356                 ret.data[i] = C2Tuple_usizeTransactionZ_clone(&orig->data[i]);
1357         }
1358         return ret;
1359 }
1360 static inline LDKCVec_TxidZ CVec_ThirtyTwoBytesZ_clone(const LDKCVec_TxidZ *orig) {
1361         LDKCVec_TxidZ ret = { .data = MALLOC(sizeof(LDKThirtyTwoBytes) * orig->datalen, "LDKCVec_TxidZ clone bytes"), .datalen = orig->datalen };
1362         for (size_t i = 0; i < ret.datalen; i++) {
1363                 ret.data[i] = ThirtyTwoBytes_clone(&orig->data[i]);
1364         }
1365         return ret;
1366 }
1367 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneChannelMonitorUpdateErrZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1368         return ((LDKCResult_NoneChannelMonitorUpdateErrZ*)arg)->result_ok;
1369 }
1370 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneChannelMonitorUpdateErrZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1371         LDKCResult_NoneChannelMonitorUpdateErrZ *val = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(arg & ~1);
1372         CHECK(val->result_ok);
1373         return *val->contents.result;
1374 }
1375 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneChannelMonitorUpdateErrZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1376         LDKCResult_NoneChannelMonitorUpdateErrZ *val = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(arg & ~1);
1377         CHECK(!val->result_ok);
1378         jclass err_conv = LDKChannelMonitorUpdateErr_to_java(env, (*val->contents.err));
1379         return err_conv;
1380 }
1381 static jclass LDKMonitorEvent_HTLCEvent_class = NULL;
1382 static jmethodID LDKMonitorEvent_HTLCEvent_meth = NULL;
1383 static jclass LDKMonitorEvent_CommitmentTxConfirmed_class = NULL;
1384 static jmethodID LDKMonitorEvent_CommitmentTxConfirmed_meth = NULL;
1385 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKMonitorEvent_init (JNIEnv *env, jclass clz) {
1386         LDKMonitorEvent_HTLCEvent_class =
1387                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMonitorEvent$HTLCEvent;"));
1388         CHECK(LDKMonitorEvent_HTLCEvent_class != NULL);
1389         LDKMonitorEvent_HTLCEvent_meth = (*env)->GetMethodID(env, LDKMonitorEvent_HTLCEvent_class, "<init>", "(J)V");
1390         CHECK(LDKMonitorEvent_HTLCEvent_meth != NULL);
1391         LDKMonitorEvent_CommitmentTxConfirmed_class =
1392                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMonitorEvent$CommitmentTxConfirmed;"));
1393         CHECK(LDKMonitorEvent_CommitmentTxConfirmed_class != NULL);
1394         LDKMonitorEvent_CommitmentTxConfirmed_meth = (*env)->GetMethodID(env, LDKMonitorEvent_CommitmentTxConfirmed_class, "<init>", "(J)V");
1395         CHECK(LDKMonitorEvent_CommitmentTxConfirmed_meth != NULL);
1396 }
1397 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKMonitorEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1398         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
1399         switch(obj->tag) {
1400                 case LDKMonitorEvent_HTLCEvent: {
1401                         LDKHTLCUpdate htlc_event_var = obj->htlc_event;
1402                         CHECK((((uint64_t)htlc_event_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1403                         CHECK((((uint64_t)&htlc_event_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1404                         uint64_t htlc_event_ref = (uint64_t)htlc_event_var.inner & ~1;
1405                         return (*env)->NewObject(env, LDKMonitorEvent_HTLCEvent_class, LDKMonitorEvent_HTLCEvent_meth, htlc_event_ref);
1406                 }
1407                 case LDKMonitorEvent_CommitmentTxConfirmed: {
1408                         LDKOutPoint commitment_tx_confirmed_var = obj->commitment_tx_confirmed;
1409                         CHECK((((uint64_t)commitment_tx_confirmed_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1410                         CHECK((((uint64_t)&commitment_tx_confirmed_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1411                         uint64_t commitment_tx_confirmed_ref = (uint64_t)commitment_tx_confirmed_var.inner & ~1;
1412                         return (*env)->NewObject(env, LDKMonitorEvent_CommitmentTxConfirmed_class, LDKMonitorEvent_CommitmentTxConfirmed_meth, commitment_tx_confirmed_ref);
1413                 }
1414                 default: abort();
1415         }
1416 }
1417 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1MonitorEventZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1418         LDKCVec_MonitorEventZ *ret = MALLOC(sizeof(LDKCVec_MonitorEventZ), "LDKCVec_MonitorEventZ");
1419         ret->datalen = (*env)->GetArrayLength(env, elems);
1420         if (ret->datalen == 0) {
1421                 ret->data = NULL;
1422         } else {
1423                 ret->data = MALLOC(sizeof(LDKMonitorEvent) * ret->datalen, "LDKCVec_MonitorEventZ Data");
1424                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1425                 for (size_t i = 0; i < ret->datalen; i++) {
1426                         int64_t arr_elem = java_elems[i];
1427                         void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
1428                         CHECK_ACCESS(arr_elem_ptr);
1429                         LDKMonitorEvent arr_elem_conv = *(LDKMonitorEvent*)(arr_elem_ptr);
1430                         arr_elem_conv = MonitorEvent_clone((LDKMonitorEvent*)(((uint64_t)arr_elem) & ~1));
1431                         ret->data[i] = arr_elem_conv;
1432                 }
1433                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1434         }
1435         return (uint64_t)ret;
1436 }
1437 static inline LDKCVec_MonitorEventZ CVec_MonitorEventZ_clone(const LDKCVec_MonitorEventZ *orig) {
1438         LDKCVec_MonitorEventZ ret = { .data = MALLOC(sizeof(LDKMonitorEvent) * orig->datalen, "LDKCVec_MonitorEventZ clone bytes"), .datalen = orig->datalen };
1439         for (size_t i = 0; i < ret.datalen; i++) {
1440                 ret.data[i] = MonitorEvent_clone(&orig->data[i]);
1441         }
1442         return ret;
1443 }
1444 static jclass LDKCOption_C2Tuple_usizeTransactionZZ_Some_class = NULL;
1445 static jmethodID LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth = NULL;
1446 static jclass LDKCOption_C2Tuple_usizeTransactionZZ_None_class = NULL;
1447 static jmethodID LDKCOption_C2Tuple_usizeTransactionZZ_None_meth = NULL;
1448 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1C2Tuple_1usizeTransactionZZ_init (JNIEnv *env, jclass clz) {
1449         LDKCOption_C2Tuple_usizeTransactionZZ_Some_class =
1450                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_C2Tuple_usizeTransactionZZ$Some;"));
1451         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_Some_class != NULL);
1452         LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_C2Tuple_usizeTransactionZZ_Some_class, "<init>", "(J)V");
1453         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth != NULL);
1454         LDKCOption_C2Tuple_usizeTransactionZZ_None_class =
1455                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_C2Tuple_usizeTransactionZZ$None;"));
1456         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_None_class != NULL);
1457         LDKCOption_C2Tuple_usizeTransactionZZ_None_meth = (*env)->GetMethodID(env, LDKCOption_C2Tuple_usizeTransactionZZ_None_class, "<init>", "()V");
1458         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_None_meth != NULL);
1459 }
1460 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1C2Tuple_1usizeTransactionZZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1461         LDKCOption_C2Tuple_usizeTransactionZZ *obj = (LDKCOption_C2Tuple_usizeTransactionZZ*)(ptr & ~1);
1462         switch(obj->tag) {
1463                 case LDKCOption_C2Tuple_usizeTransactionZZ_Some: {
1464                         LDKC2Tuple_usizeTransactionZ* some_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
1465                         *some_conv = obj->some;
1466                         *some_conv = C2Tuple_usizeTransactionZ_clone(some_conv);
1467                         return (*env)->NewObject(env, LDKCOption_C2Tuple_usizeTransactionZZ_Some_class, LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth, ((uint64_t)some_conv));
1468                 }
1469                 case LDKCOption_C2Tuple_usizeTransactionZZ_None: {
1470                         return (*env)->NewObject(env, LDKCOption_C2Tuple_usizeTransactionZZ_None_class, LDKCOption_C2Tuple_usizeTransactionZZ_None_meth);
1471                 }
1472                 default: abort();
1473         }
1474 }
1475 static jclass LDKNetworkUpdate_ChannelUpdateMessage_class = NULL;
1476 static jmethodID LDKNetworkUpdate_ChannelUpdateMessage_meth = NULL;
1477 static jclass LDKNetworkUpdate_ChannelClosed_class = NULL;
1478 static jmethodID LDKNetworkUpdate_ChannelClosed_meth = NULL;
1479 static jclass LDKNetworkUpdate_NodeFailure_class = NULL;
1480 static jmethodID LDKNetworkUpdate_NodeFailure_meth = NULL;
1481 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKNetworkUpdate_init (JNIEnv *env, jclass clz) {
1482         LDKNetworkUpdate_ChannelUpdateMessage_class =
1483                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetworkUpdate$ChannelUpdateMessage;"));
1484         CHECK(LDKNetworkUpdate_ChannelUpdateMessage_class != NULL);
1485         LDKNetworkUpdate_ChannelUpdateMessage_meth = (*env)->GetMethodID(env, LDKNetworkUpdate_ChannelUpdateMessage_class, "<init>", "(J)V");
1486         CHECK(LDKNetworkUpdate_ChannelUpdateMessage_meth != NULL);
1487         LDKNetworkUpdate_ChannelClosed_class =
1488                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetworkUpdate$ChannelClosed;"));
1489         CHECK(LDKNetworkUpdate_ChannelClosed_class != NULL);
1490         LDKNetworkUpdate_ChannelClosed_meth = (*env)->GetMethodID(env, LDKNetworkUpdate_ChannelClosed_class, "<init>", "(JZ)V");
1491         CHECK(LDKNetworkUpdate_ChannelClosed_meth != NULL);
1492         LDKNetworkUpdate_NodeFailure_class =
1493                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetworkUpdate$NodeFailure;"));
1494         CHECK(LDKNetworkUpdate_NodeFailure_class != NULL);
1495         LDKNetworkUpdate_NodeFailure_meth = (*env)->GetMethodID(env, LDKNetworkUpdate_NodeFailure_class, "<init>", "([BZ)V");
1496         CHECK(LDKNetworkUpdate_NodeFailure_meth != NULL);
1497 }
1498 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKNetworkUpdate_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1499         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)(ptr & ~1);
1500         switch(obj->tag) {
1501                 case LDKNetworkUpdate_ChannelUpdateMessage: {
1502                         LDKChannelUpdate msg_var = obj->channel_update_message.msg;
1503                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1504                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1505                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1506                         return (*env)->NewObject(env, LDKNetworkUpdate_ChannelUpdateMessage_class, LDKNetworkUpdate_ChannelUpdateMessage_meth, msg_ref);
1507                 }
1508                 case LDKNetworkUpdate_ChannelClosed: {
1509                         return (*env)->NewObject(env, LDKNetworkUpdate_ChannelClosed_class, LDKNetworkUpdate_ChannelClosed_meth, obj->channel_closed.short_channel_id, obj->channel_closed.is_permanent);
1510                 }
1511                 case LDKNetworkUpdate_NodeFailure: {
1512                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1513                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->node_failure.node_id.compressed_form);
1514                         return (*env)->NewObject(env, LDKNetworkUpdate_NodeFailure_class, LDKNetworkUpdate_NodeFailure_meth, node_id_arr, obj->node_failure.is_permanent);
1515                 }
1516                 default: abort();
1517         }
1518 }
1519 static jclass LDKCOption_NetworkUpdateZ_Some_class = NULL;
1520 static jmethodID LDKCOption_NetworkUpdateZ_Some_meth = NULL;
1521 static jclass LDKCOption_NetworkUpdateZ_None_class = NULL;
1522 static jmethodID LDKCOption_NetworkUpdateZ_None_meth = NULL;
1523 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1NetworkUpdateZ_init (JNIEnv *env, jclass clz) {
1524         LDKCOption_NetworkUpdateZ_Some_class =
1525                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_NetworkUpdateZ$Some;"));
1526         CHECK(LDKCOption_NetworkUpdateZ_Some_class != NULL);
1527         LDKCOption_NetworkUpdateZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_NetworkUpdateZ_Some_class, "<init>", "(J)V");
1528         CHECK(LDKCOption_NetworkUpdateZ_Some_meth != NULL);
1529         LDKCOption_NetworkUpdateZ_None_class =
1530                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_NetworkUpdateZ$None;"));
1531         CHECK(LDKCOption_NetworkUpdateZ_None_class != NULL);
1532         LDKCOption_NetworkUpdateZ_None_meth = (*env)->GetMethodID(env, LDKCOption_NetworkUpdateZ_None_class, "<init>", "()V");
1533         CHECK(LDKCOption_NetworkUpdateZ_None_meth != NULL);
1534 }
1535 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1NetworkUpdateZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1536         LDKCOption_NetworkUpdateZ *obj = (LDKCOption_NetworkUpdateZ*)(ptr & ~1);
1537         switch(obj->tag) {
1538                 case LDKCOption_NetworkUpdateZ_Some: {
1539                         uint64_t some_ref = ((uint64_t)&obj->some) | 1;
1540                         return (*env)->NewObject(env, LDKCOption_NetworkUpdateZ_Some_class, LDKCOption_NetworkUpdateZ_Some_meth, some_ref);
1541                 }
1542                 case LDKCOption_NetworkUpdateZ_None: {
1543                         return (*env)->NewObject(env, LDKCOption_NetworkUpdateZ_None_class, LDKCOption_NetworkUpdateZ_None_meth);
1544                 }
1545                 default: abort();
1546         }
1547 }
1548 static jclass LDKSpendableOutputDescriptor_StaticOutput_class = NULL;
1549 static jmethodID LDKSpendableOutputDescriptor_StaticOutput_meth = NULL;
1550 static jclass LDKSpendableOutputDescriptor_DelayedPaymentOutput_class = NULL;
1551 static jmethodID LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth = NULL;
1552 static jclass LDKSpendableOutputDescriptor_StaticPaymentOutput_class = NULL;
1553 static jmethodID LDKSpendableOutputDescriptor_StaticPaymentOutput_meth = NULL;
1554 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKSpendableOutputDescriptor_init (JNIEnv *env, jclass clz) {
1555         LDKSpendableOutputDescriptor_StaticOutput_class =
1556                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKSpendableOutputDescriptor$StaticOutput;"));
1557         CHECK(LDKSpendableOutputDescriptor_StaticOutput_class != NULL);
1558         LDKSpendableOutputDescriptor_StaticOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_StaticOutput_class, "<init>", "(JJ)V");
1559         CHECK(LDKSpendableOutputDescriptor_StaticOutput_meth != NULL);
1560         LDKSpendableOutputDescriptor_DelayedPaymentOutput_class =
1561                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKSpendableOutputDescriptor$DelayedPaymentOutput;"));
1562         CHECK(LDKSpendableOutputDescriptor_DelayedPaymentOutput_class != NULL);
1563         LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_DelayedPaymentOutput_class, "<init>", "(J)V");
1564         CHECK(LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth != NULL);
1565         LDKSpendableOutputDescriptor_StaticPaymentOutput_class =
1566                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKSpendableOutputDescriptor$StaticPaymentOutput;"));
1567         CHECK(LDKSpendableOutputDescriptor_StaticPaymentOutput_class != NULL);
1568         LDKSpendableOutputDescriptor_StaticPaymentOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_StaticPaymentOutput_class, "<init>", "(J)V");
1569         CHECK(LDKSpendableOutputDescriptor_StaticPaymentOutput_meth != NULL);
1570 }
1571 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKSpendableOutputDescriptor_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1572         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)(ptr & ~1);
1573         switch(obj->tag) {
1574                 case LDKSpendableOutputDescriptor_StaticOutput: {
1575                         LDKOutPoint outpoint_var = obj->static_output.outpoint;
1576                         CHECK((((uint64_t)outpoint_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1577                         CHECK((((uint64_t)&outpoint_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1578                         uint64_t outpoint_ref = (uint64_t)outpoint_var.inner & ~1;
1579                         uint64_t output_ref = ((uint64_t)&obj->static_output.output) | 1;
1580                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_StaticOutput_class, LDKSpendableOutputDescriptor_StaticOutput_meth, outpoint_ref, (uint64_t)output_ref);
1581                 }
1582                 case LDKSpendableOutputDescriptor_DelayedPaymentOutput: {
1583                         LDKDelayedPaymentOutputDescriptor delayed_payment_output_var = obj->delayed_payment_output;
1584                         CHECK((((uint64_t)delayed_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1585                         CHECK((((uint64_t)&delayed_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1586                         uint64_t delayed_payment_output_ref = (uint64_t)delayed_payment_output_var.inner & ~1;
1587                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_DelayedPaymentOutput_class, LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth, delayed_payment_output_ref);
1588                 }
1589                 case LDKSpendableOutputDescriptor_StaticPaymentOutput: {
1590                         LDKStaticPaymentOutputDescriptor static_payment_output_var = obj->static_payment_output;
1591                         CHECK((((uint64_t)static_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1592                         CHECK((((uint64_t)&static_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1593                         uint64_t static_payment_output_ref = (uint64_t)static_payment_output_var.inner & ~1;
1594                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_StaticPaymentOutput_class, LDKSpendableOutputDescriptor_StaticPaymentOutput_meth, static_payment_output_ref);
1595                 }
1596                 default: abort();
1597         }
1598 }
1599 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1SpendableOutputDescriptorZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1600         LDKCVec_SpendableOutputDescriptorZ *ret = MALLOC(sizeof(LDKCVec_SpendableOutputDescriptorZ), "LDKCVec_SpendableOutputDescriptorZ");
1601         ret->datalen = (*env)->GetArrayLength(env, elems);
1602         if (ret->datalen == 0) {
1603                 ret->data = NULL;
1604         } else {
1605                 ret->data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * ret->datalen, "LDKCVec_SpendableOutputDescriptorZ Data");
1606                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1607                 for (size_t i = 0; i < ret->datalen; i++) {
1608                         int64_t arr_elem = java_elems[i];
1609                         void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
1610                         CHECK_ACCESS(arr_elem_ptr);
1611                         LDKSpendableOutputDescriptor arr_elem_conv = *(LDKSpendableOutputDescriptor*)(arr_elem_ptr);
1612                         arr_elem_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uint64_t)arr_elem) & ~1));
1613                         ret->data[i] = arr_elem_conv;
1614                 }
1615                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1616         }
1617         return (uint64_t)ret;
1618 }
1619 static inline LDKCVec_SpendableOutputDescriptorZ CVec_SpendableOutputDescriptorZ_clone(const LDKCVec_SpendableOutputDescriptorZ *orig) {
1620         LDKCVec_SpendableOutputDescriptorZ ret = { .data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * orig->datalen, "LDKCVec_SpendableOutputDescriptorZ clone bytes"), .datalen = orig->datalen };
1621         for (size_t i = 0; i < ret.datalen; i++) {
1622                 ret.data[i] = SpendableOutputDescriptor_clone(&orig->data[i]);
1623         }
1624         return ret;
1625 }
1626 static jclass LDKErrorAction_DisconnectPeer_class = NULL;
1627 static jmethodID LDKErrorAction_DisconnectPeer_meth = NULL;
1628 static jclass LDKErrorAction_IgnoreError_class = NULL;
1629 static jmethodID LDKErrorAction_IgnoreError_meth = NULL;
1630 static jclass LDKErrorAction_IgnoreAndLog_class = NULL;
1631 static jmethodID LDKErrorAction_IgnoreAndLog_meth = NULL;
1632 static jclass LDKErrorAction_SendErrorMessage_class = NULL;
1633 static jmethodID LDKErrorAction_SendErrorMessage_meth = NULL;
1634 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKErrorAction_init (JNIEnv *env, jclass clz) {
1635         LDKErrorAction_DisconnectPeer_class =
1636                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKErrorAction$DisconnectPeer;"));
1637         CHECK(LDKErrorAction_DisconnectPeer_class != NULL);
1638         LDKErrorAction_DisconnectPeer_meth = (*env)->GetMethodID(env, LDKErrorAction_DisconnectPeer_class, "<init>", "(J)V");
1639         CHECK(LDKErrorAction_DisconnectPeer_meth != NULL);
1640         LDKErrorAction_IgnoreError_class =
1641                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKErrorAction$IgnoreError;"));
1642         CHECK(LDKErrorAction_IgnoreError_class != NULL);
1643         LDKErrorAction_IgnoreError_meth = (*env)->GetMethodID(env, LDKErrorAction_IgnoreError_class, "<init>", "()V");
1644         CHECK(LDKErrorAction_IgnoreError_meth != NULL);
1645         LDKErrorAction_IgnoreAndLog_class =
1646                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKErrorAction$IgnoreAndLog;"));
1647         CHECK(LDKErrorAction_IgnoreAndLog_class != NULL);
1648         LDKErrorAction_IgnoreAndLog_meth = (*env)->GetMethodID(env, LDKErrorAction_IgnoreAndLog_class, "<init>", "(Lorg/ldk/enums/Level;)V");
1649         CHECK(LDKErrorAction_IgnoreAndLog_meth != NULL);
1650         LDKErrorAction_SendErrorMessage_class =
1651                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKErrorAction$SendErrorMessage;"));
1652         CHECK(LDKErrorAction_SendErrorMessage_class != NULL);
1653         LDKErrorAction_SendErrorMessage_meth = (*env)->GetMethodID(env, LDKErrorAction_SendErrorMessage_class, "<init>", "(J)V");
1654         CHECK(LDKErrorAction_SendErrorMessage_meth != NULL);
1655 }
1656 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKErrorAction_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1657         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
1658         switch(obj->tag) {
1659                 case LDKErrorAction_DisconnectPeer: {
1660                         LDKErrorMessage msg_var = obj->disconnect_peer.msg;
1661                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1662                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1663                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1664                         return (*env)->NewObject(env, LDKErrorAction_DisconnectPeer_class, LDKErrorAction_DisconnectPeer_meth, msg_ref);
1665                 }
1666                 case LDKErrorAction_IgnoreError: {
1667                         return (*env)->NewObject(env, LDKErrorAction_IgnoreError_class, LDKErrorAction_IgnoreError_meth);
1668                 }
1669                 case LDKErrorAction_IgnoreAndLog: {
1670                         jclass ignore_and_log_conv = LDKLevel_to_java(env, obj->ignore_and_log);
1671                         return (*env)->NewObject(env, LDKErrorAction_IgnoreAndLog_class, LDKErrorAction_IgnoreAndLog_meth, ignore_and_log_conv);
1672                 }
1673                 case LDKErrorAction_SendErrorMessage: {
1674                         LDKErrorMessage msg_var = obj->send_error_message.msg;
1675                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1676                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1677                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1678                         return (*env)->NewObject(env, LDKErrorAction_SendErrorMessage_class, LDKErrorAction_SendErrorMessage_meth, msg_ref);
1679                 }
1680                 default: abort();
1681         }
1682 }
1683 static jclass LDKMessageSendEvent_SendAcceptChannel_class = NULL;
1684 static jmethodID LDKMessageSendEvent_SendAcceptChannel_meth = NULL;
1685 static jclass LDKMessageSendEvent_SendOpenChannel_class = NULL;
1686 static jmethodID LDKMessageSendEvent_SendOpenChannel_meth = NULL;
1687 static jclass LDKMessageSendEvent_SendFundingCreated_class = NULL;
1688 static jmethodID LDKMessageSendEvent_SendFundingCreated_meth = NULL;
1689 static jclass LDKMessageSendEvent_SendFundingSigned_class = NULL;
1690 static jmethodID LDKMessageSendEvent_SendFundingSigned_meth = NULL;
1691 static jclass LDKMessageSendEvent_SendFundingLocked_class = NULL;
1692 static jmethodID LDKMessageSendEvent_SendFundingLocked_meth = NULL;
1693 static jclass LDKMessageSendEvent_SendAnnouncementSignatures_class = NULL;
1694 static jmethodID LDKMessageSendEvent_SendAnnouncementSignatures_meth = NULL;
1695 static jclass LDKMessageSendEvent_UpdateHTLCs_class = NULL;
1696 static jmethodID LDKMessageSendEvent_UpdateHTLCs_meth = NULL;
1697 static jclass LDKMessageSendEvent_SendRevokeAndACK_class = NULL;
1698 static jmethodID LDKMessageSendEvent_SendRevokeAndACK_meth = NULL;
1699 static jclass LDKMessageSendEvent_SendClosingSigned_class = NULL;
1700 static jmethodID LDKMessageSendEvent_SendClosingSigned_meth = NULL;
1701 static jclass LDKMessageSendEvent_SendShutdown_class = NULL;
1702 static jmethodID LDKMessageSendEvent_SendShutdown_meth = NULL;
1703 static jclass LDKMessageSendEvent_SendChannelReestablish_class = NULL;
1704 static jmethodID LDKMessageSendEvent_SendChannelReestablish_meth = NULL;
1705 static jclass LDKMessageSendEvent_BroadcastChannelAnnouncement_class = NULL;
1706 static jmethodID LDKMessageSendEvent_BroadcastChannelAnnouncement_meth = NULL;
1707 static jclass LDKMessageSendEvent_BroadcastNodeAnnouncement_class = NULL;
1708 static jmethodID LDKMessageSendEvent_BroadcastNodeAnnouncement_meth = NULL;
1709 static jclass LDKMessageSendEvent_BroadcastChannelUpdate_class = NULL;
1710 static jmethodID LDKMessageSendEvent_BroadcastChannelUpdate_meth = NULL;
1711 static jclass LDKMessageSendEvent_SendChannelUpdate_class = NULL;
1712 static jmethodID LDKMessageSendEvent_SendChannelUpdate_meth = NULL;
1713 static jclass LDKMessageSendEvent_HandleError_class = NULL;
1714 static jmethodID LDKMessageSendEvent_HandleError_meth = NULL;
1715 static jclass LDKMessageSendEvent_SendChannelRangeQuery_class = NULL;
1716 static jmethodID LDKMessageSendEvent_SendChannelRangeQuery_meth = NULL;
1717 static jclass LDKMessageSendEvent_SendShortIdsQuery_class = NULL;
1718 static jmethodID LDKMessageSendEvent_SendShortIdsQuery_meth = NULL;
1719 static jclass LDKMessageSendEvent_SendReplyChannelRange_class = NULL;
1720 static jmethodID LDKMessageSendEvent_SendReplyChannelRange_meth = NULL;
1721 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKMessageSendEvent_init (JNIEnv *env, jclass clz) {
1722         LDKMessageSendEvent_SendAcceptChannel_class =
1723                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendAcceptChannel;"));
1724         CHECK(LDKMessageSendEvent_SendAcceptChannel_class != NULL);
1725         LDKMessageSendEvent_SendAcceptChannel_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendAcceptChannel_class, "<init>", "([BJ)V");
1726         CHECK(LDKMessageSendEvent_SendAcceptChannel_meth != NULL);
1727         LDKMessageSendEvent_SendOpenChannel_class =
1728                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendOpenChannel;"));
1729         CHECK(LDKMessageSendEvent_SendOpenChannel_class != NULL);
1730         LDKMessageSendEvent_SendOpenChannel_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendOpenChannel_class, "<init>", "([BJ)V");
1731         CHECK(LDKMessageSendEvent_SendOpenChannel_meth != NULL);
1732         LDKMessageSendEvent_SendFundingCreated_class =
1733                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendFundingCreated;"));
1734         CHECK(LDKMessageSendEvent_SendFundingCreated_class != NULL);
1735         LDKMessageSendEvent_SendFundingCreated_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingCreated_class, "<init>", "([BJ)V");
1736         CHECK(LDKMessageSendEvent_SendFundingCreated_meth != NULL);
1737         LDKMessageSendEvent_SendFundingSigned_class =
1738                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendFundingSigned;"));
1739         CHECK(LDKMessageSendEvent_SendFundingSigned_class != NULL);
1740         LDKMessageSendEvent_SendFundingSigned_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingSigned_class, "<init>", "([BJ)V");
1741         CHECK(LDKMessageSendEvent_SendFundingSigned_meth != NULL);
1742         LDKMessageSendEvent_SendFundingLocked_class =
1743                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendFundingLocked;"));
1744         CHECK(LDKMessageSendEvent_SendFundingLocked_class != NULL);
1745         LDKMessageSendEvent_SendFundingLocked_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingLocked_class, "<init>", "([BJ)V");
1746         CHECK(LDKMessageSendEvent_SendFundingLocked_meth != NULL);
1747         LDKMessageSendEvent_SendAnnouncementSignatures_class =
1748                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendAnnouncementSignatures;"));
1749         CHECK(LDKMessageSendEvent_SendAnnouncementSignatures_class != NULL);
1750         LDKMessageSendEvent_SendAnnouncementSignatures_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendAnnouncementSignatures_class, "<init>", "([BJ)V");
1751         CHECK(LDKMessageSendEvent_SendAnnouncementSignatures_meth != NULL);
1752         LDKMessageSendEvent_UpdateHTLCs_class =
1753                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$UpdateHTLCs;"));
1754         CHECK(LDKMessageSendEvent_UpdateHTLCs_class != NULL);
1755         LDKMessageSendEvent_UpdateHTLCs_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_UpdateHTLCs_class, "<init>", "([BJ)V");
1756         CHECK(LDKMessageSendEvent_UpdateHTLCs_meth != NULL);
1757         LDKMessageSendEvent_SendRevokeAndACK_class =
1758                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendRevokeAndACK;"));
1759         CHECK(LDKMessageSendEvent_SendRevokeAndACK_class != NULL);
1760         LDKMessageSendEvent_SendRevokeAndACK_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendRevokeAndACK_class, "<init>", "([BJ)V");
1761         CHECK(LDKMessageSendEvent_SendRevokeAndACK_meth != NULL);
1762         LDKMessageSendEvent_SendClosingSigned_class =
1763                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendClosingSigned;"));
1764         CHECK(LDKMessageSendEvent_SendClosingSigned_class != NULL);
1765         LDKMessageSendEvent_SendClosingSigned_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendClosingSigned_class, "<init>", "([BJ)V");
1766         CHECK(LDKMessageSendEvent_SendClosingSigned_meth != NULL);
1767         LDKMessageSendEvent_SendShutdown_class =
1768                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendShutdown;"));
1769         CHECK(LDKMessageSendEvent_SendShutdown_class != NULL);
1770         LDKMessageSendEvent_SendShutdown_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendShutdown_class, "<init>", "([BJ)V");
1771         CHECK(LDKMessageSendEvent_SendShutdown_meth != NULL);
1772         LDKMessageSendEvent_SendChannelReestablish_class =
1773                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendChannelReestablish;"));
1774         CHECK(LDKMessageSendEvent_SendChannelReestablish_class != NULL);
1775         LDKMessageSendEvent_SendChannelReestablish_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelReestablish_class, "<init>", "([BJ)V");
1776         CHECK(LDKMessageSendEvent_SendChannelReestablish_meth != NULL);
1777         LDKMessageSendEvent_BroadcastChannelAnnouncement_class =
1778                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$BroadcastChannelAnnouncement;"));
1779         CHECK(LDKMessageSendEvent_BroadcastChannelAnnouncement_class != NULL);
1780         LDKMessageSendEvent_BroadcastChannelAnnouncement_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastChannelAnnouncement_class, "<init>", "(JJ)V");
1781         CHECK(LDKMessageSendEvent_BroadcastChannelAnnouncement_meth != NULL);
1782         LDKMessageSendEvent_BroadcastNodeAnnouncement_class =
1783                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$BroadcastNodeAnnouncement;"));
1784         CHECK(LDKMessageSendEvent_BroadcastNodeAnnouncement_class != NULL);
1785         LDKMessageSendEvent_BroadcastNodeAnnouncement_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastNodeAnnouncement_class, "<init>", "(J)V");
1786         CHECK(LDKMessageSendEvent_BroadcastNodeAnnouncement_meth != NULL);
1787         LDKMessageSendEvent_BroadcastChannelUpdate_class =
1788                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$BroadcastChannelUpdate;"));
1789         CHECK(LDKMessageSendEvent_BroadcastChannelUpdate_class != NULL);
1790         LDKMessageSendEvent_BroadcastChannelUpdate_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastChannelUpdate_class, "<init>", "(J)V");
1791         CHECK(LDKMessageSendEvent_BroadcastChannelUpdate_meth != NULL);
1792         LDKMessageSendEvent_SendChannelUpdate_class =
1793                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendChannelUpdate;"));
1794         CHECK(LDKMessageSendEvent_SendChannelUpdate_class != NULL);
1795         LDKMessageSendEvent_SendChannelUpdate_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelUpdate_class, "<init>", "([BJ)V");
1796         CHECK(LDKMessageSendEvent_SendChannelUpdate_meth != NULL);
1797         LDKMessageSendEvent_HandleError_class =
1798                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$HandleError;"));
1799         CHECK(LDKMessageSendEvent_HandleError_class != NULL);
1800         LDKMessageSendEvent_HandleError_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_HandleError_class, "<init>", "([BJ)V");
1801         CHECK(LDKMessageSendEvent_HandleError_meth != NULL);
1802         LDKMessageSendEvent_SendChannelRangeQuery_class =
1803                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendChannelRangeQuery;"));
1804         CHECK(LDKMessageSendEvent_SendChannelRangeQuery_class != NULL);
1805         LDKMessageSendEvent_SendChannelRangeQuery_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelRangeQuery_class, "<init>", "([BJ)V");
1806         CHECK(LDKMessageSendEvent_SendChannelRangeQuery_meth != NULL);
1807         LDKMessageSendEvent_SendShortIdsQuery_class =
1808                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendShortIdsQuery;"));
1809         CHECK(LDKMessageSendEvent_SendShortIdsQuery_class != NULL);
1810         LDKMessageSendEvent_SendShortIdsQuery_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendShortIdsQuery_class, "<init>", "([BJ)V");
1811         CHECK(LDKMessageSendEvent_SendShortIdsQuery_meth != NULL);
1812         LDKMessageSendEvent_SendReplyChannelRange_class =
1813                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendReplyChannelRange;"));
1814         CHECK(LDKMessageSendEvent_SendReplyChannelRange_class != NULL);
1815         LDKMessageSendEvent_SendReplyChannelRange_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendReplyChannelRange_class, "<init>", "([BJ)V");
1816         CHECK(LDKMessageSendEvent_SendReplyChannelRange_meth != NULL);
1817 }
1818 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1819         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
1820         switch(obj->tag) {
1821                 case LDKMessageSendEvent_SendAcceptChannel: {
1822                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1823                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_accept_channel.node_id.compressed_form);
1824                         LDKAcceptChannel msg_var = obj->send_accept_channel.msg;
1825                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1826                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1827                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1828                         return (*env)->NewObject(env, LDKMessageSendEvent_SendAcceptChannel_class, LDKMessageSendEvent_SendAcceptChannel_meth, node_id_arr, msg_ref);
1829                 }
1830                 case LDKMessageSendEvent_SendOpenChannel: {
1831                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1832                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_open_channel.node_id.compressed_form);
1833                         LDKOpenChannel msg_var = obj->send_open_channel.msg;
1834                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1835                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1836                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1837                         return (*env)->NewObject(env, LDKMessageSendEvent_SendOpenChannel_class, LDKMessageSendEvent_SendOpenChannel_meth, node_id_arr, msg_ref);
1838                 }
1839                 case LDKMessageSendEvent_SendFundingCreated: {
1840                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1841                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_created.node_id.compressed_form);
1842                         LDKFundingCreated msg_var = obj->send_funding_created.msg;
1843                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1844                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1845                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1846                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingCreated_class, LDKMessageSendEvent_SendFundingCreated_meth, node_id_arr, msg_ref);
1847                 }
1848                 case LDKMessageSendEvent_SendFundingSigned: {
1849                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1850                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_signed.node_id.compressed_form);
1851                         LDKFundingSigned msg_var = obj->send_funding_signed.msg;
1852                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1853                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1854                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1855                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingSigned_class, LDKMessageSendEvent_SendFundingSigned_meth, node_id_arr, msg_ref);
1856                 }
1857                 case LDKMessageSendEvent_SendFundingLocked: {
1858                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1859                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_locked.node_id.compressed_form);
1860                         LDKFundingLocked msg_var = obj->send_funding_locked.msg;
1861                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1862                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1863                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1864                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingLocked_class, LDKMessageSendEvent_SendFundingLocked_meth, node_id_arr, msg_ref);
1865                 }
1866                 case LDKMessageSendEvent_SendAnnouncementSignatures: {
1867                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1868                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_announcement_signatures.node_id.compressed_form);
1869                         LDKAnnouncementSignatures msg_var = obj->send_announcement_signatures.msg;
1870                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1871                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1872                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1873                         return (*env)->NewObject(env, LDKMessageSendEvent_SendAnnouncementSignatures_class, LDKMessageSendEvent_SendAnnouncementSignatures_meth, node_id_arr, msg_ref);
1874                 }
1875                 case LDKMessageSendEvent_UpdateHTLCs: {
1876                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1877                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->update_htl_cs.node_id.compressed_form);
1878                         LDKCommitmentUpdate updates_var = obj->update_htl_cs.updates;
1879                         CHECK((((uint64_t)updates_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1880                         CHECK((((uint64_t)&updates_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1881                         uint64_t updates_ref = (uint64_t)updates_var.inner & ~1;
1882                         return (*env)->NewObject(env, LDKMessageSendEvent_UpdateHTLCs_class, LDKMessageSendEvent_UpdateHTLCs_meth, node_id_arr, updates_ref);
1883                 }
1884                 case LDKMessageSendEvent_SendRevokeAndACK: {
1885                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1886                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_revoke_and_ack.node_id.compressed_form);
1887                         LDKRevokeAndACK msg_var = obj->send_revoke_and_ack.msg;
1888                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1889                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1890                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1891                         return (*env)->NewObject(env, LDKMessageSendEvent_SendRevokeAndACK_class, LDKMessageSendEvent_SendRevokeAndACK_meth, node_id_arr, msg_ref);
1892                 }
1893                 case LDKMessageSendEvent_SendClosingSigned: {
1894                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1895                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_closing_signed.node_id.compressed_form);
1896                         LDKClosingSigned msg_var = obj->send_closing_signed.msg;
1897                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1898                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1899                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1900                         return (*env)->NewObject(env, LDKMessageSendEvent_SendClosingSigned_class, LDKMessageSendEvent_SendClosingSigned_meth, node_id_arr, msg_ref);
1901                 }
1902                 case LDKMessageSendEvent_SendShutdown: {
1903                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1904                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_shutdown.node_id.compressed_form);
1905                         LDKShutdown msg_var = obj->send_shutdown.msg;
1906                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1907                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1908                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1909                         return (*env)->NewObject(env, LDKMessageSendEvent_SendShutdown_class, LDKMessageSendEvent_SendShutdown_meth, node_id_arr, msg_ref);
1910                 }
1911                 case LDKMessageSendEvent_SendChannelReestablish: {
1912                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1913                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_reestablish.node_id.compressed_form);
1914                         LDKChannelReestablish msg_var = obj->send_channel_reestablish.msg;
1915                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1916                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1917                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1918                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelReestablish_class, LDKMessageSendEvent_SendChannelReestablish_meth, node_id_arr, msg_ref);
1919                 }
1920                 case LDKMessageSendEvent_BroadcastChannelAnnouncement: {
1921                         LDKChannelAnnouncement msg_var = obj->broadcast_channel_announcement.msg;
1922                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1923                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1924                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1925                         LDKChannelUpdate update_msg_var = obj->broadcast_channel_announcement.update_msg;
1926                         CHECK((((uint64_t)update_msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1927                         CHECK((((uint64_t)&update_msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1928                         uint64_t update_msg_ref = (uint64_t)update_msg_var.inner & ~1;
1929                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastChannelAnnouncement_class, LDKMessageSendEvent_BroadcastChannelAnnouncement_meth, msg_ref, update_msg_ref);
1930                 }
1931                 case LDKMessageSendEvent_BroadcastNodeAnnouncement: {
1932                         LDKNodeAnnouncement msg_var = obj->broadcast_node_announcement.msg;
1933                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1934                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1935                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1936                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastNodeAnnouncement_class, LDKMessageSendEvent_BroadcastNodeAnnouncement_meth, msg_ref);
1937                 }
1938                 case LDKMessageSendEvent_BroadcastChannelUpdate: {
1939                         LDKChannelUpdate msg_var = obj->broadcast_channel_update.msg;
1940                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1941                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1942                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1943                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastChannelUpdate_class, LDKMessageSendEvent_BroadcastChannelUpdate_meth, msg_ref);
1944                 }
1945                 case LDKMessageSendEvent_SendChannelUpdate: {
1946                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1947                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_update.node_id.compressed_form);
1948                         LDKChannelUpdate msg_var = obj->send_channel_update.msg;
1949                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1950                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1951                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1952                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelUpdate_class, LDKMessageSendEvent_SendChannelUpdate_meth, node_id_arr, msg_ref);
1953                 }
1954                 case LDKMessageSendEvent_HandleError: {
1955                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1956                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->handle_error.node_id.compressed_form);
1957                         uint64_t action_ref = ((uint64_t)&obj->handle_error.action) | 1;
1958                         return (*env)->NewObject(env, LDKMessageSendEvent_HandleError_class, LDKMessageSendEvent_HandleError_meth, node_id_arr, action_ref);
1959                 }
1960                 case LDKMessageSendEvent_SendChannelRangeQuery: {
1961                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1962                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_range_query.node_id.compressed_form);
1963                         LDKQueryChannelRange msg_var = obj->send_channel_range_query.msg;
1964                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1965                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1966                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1967                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelRangeQuery_class, LDKMessageSendEvent_SendChannelRangeQuery_meth, node_id_arr, msg_ref);
1968                 }
1969                 case LDKMessageSendEvent_SendShortIdsQuery: {
1970                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1971                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_short_ids_query.node_id.compressed_form);
1972                         LDKQueryShortChannelIds msg_var = obj->send_short_ids_query.msg;
1973                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1974                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1975                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1976                         return (*env)->NewObject(env, LDKMessageSendEvent_SendShortIdsQuery_class, LDKMessageSendEvent_SendShortIdsQuery_meth, node_id_arr, msg_ref);
1977                 }
1978                 case LDKMessageSendEvent_SendReplyChannelRange: {
1979                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1980                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_reply_channel_range.node_id.compressed_form);
1981                         LDKReplyChannelRange msg_var = obj->send_reply_channel_range.msg;
1982                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1983                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1984                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1985                         return (*env)->NewObject(env, LDKMessageSendEvent_SendReplyChannelRange_class, LDKMessageSendEvent_SendReplyChannelRange_meth, node_id_arr, msg_ref);
1986                 }
1987                 default: abort();
1988         }
1989 }
1990 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1MessageSendEventZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1991         LDKCVec_MessageSendEventZ *ret = MALLOC(sizeof(LDKCVec_MessageSendEventZ), "LDKCVec_MessageSendEventZ");
1992         ret->datalen = (*env)->GetArrayLength(env, elems);
1993         if (ret->datalen == 0) {
1994                 ret->data = NULL;
1995         } else {
1996                 ret->data = MALLOC(sizeof(LDKMessageSendEvent) * ret->datalen, "LDKCVec_MessageSendEventZ Data");
1997                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1998                 for (size_t i = 0; i < ret->datalen; i++) {
1999                         int64_t arr_elem = java_elems[i];
2000                         void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
2001                         CHECK_ACCESS(arr_elem_ptr);
2002                         LDKMessageSendEvent arr_elem_conv = *(LDKMessageSendEvent*)(arr_elem_ptr);
2003                         arr_elem_conv = MessageSendEvent_clone((LDKMessageSendEvent*)(((uint64_t)arr_elem) & ~1));
2004                         ret->data[i] = arr_elem_conv;
2005                 }
2006                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
2007         }
2008         return (uint64_t)ret;
2009 }
2010 static inline LDKCVec_MessageSendEventZ CVec_MessageSendEventZ_clone(const LDKCVec_MessageSendEventZ *orig) {
2011         LDKCVec_MessageSendEventZ ret = { .data = MALLOC(sizeof(LDKMessageSendEvent) * orig->datalen, "LDKCVec_MessageSendEventZ clone bytes"), .datalen = orig->datalen };
2012         for (size_t i = 0; i < ret.datalen; i++) {
2013                 ret.data[i] = MessageSendEvent_clone(&orig->data[i]);
2014         }
2015         return ret;
2016 }
2017 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitFeaturesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2018         return ((LDKCResult_InitFeaturesDecodeErrorZ*)arg)->result_ok;
2019 }
2020 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2021         LDKCResult_InitFeaturesDecodeErrorZ *val = (LDKCResult_InitFeaturesDecodeErrorZ*)(arg & ~1);
2022         CHECK(val->result_ok);
2023         LDKInitFeatures res_var = (*val->contents.result);
2024         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2025         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2026         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
2027         return res_ref;
2028 }
2029 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2030         LDKCResult_InitFeaturesDecodeErrorZ *val = (LDKCResult_InitFeaturesDecodeErrorZ*)(arg & ~1);
2031         CHECK(!val->result_ok);
2032         LDKDecodeError err_var = (*val->contents.err);
2033         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2034         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2035         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
2036         return err_ref;
2037 }
2038 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeFeaturesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2039         return ((LDKCResult_NodeFeaturesDecodeErrorZ*)arg)->result_ok;
2040 }
2041 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2042         LDKCResult_NodeFeaturesDecodeErrorZ *val = (LDKCResult_NodeFeaturesDecodeErrorZ*)(arg & ~1);
2043         CHECK(val->result_ok);
2044         LDKNodeFeatures res_var = (*val->contents.result);
2045         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2046         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2047         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
2048         return res_ref;
2049 }
2050 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2051         LDKCResult_NodeFeaturesDecodeErrorZ *val = (LDKCResult_NodeFeaturesDecodeErrorZ*)(arg & ~1);
2052         CHECK(!val->result_ok);
2053         LDKDecodeError err_var = (*val->contents.err);
2054         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2055         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2056         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
2057         return err_ref;
2058 }
2059 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelFeaturesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2060         return ((LDKCResult_ChannelFeaturesDecodeErrorZ*)arg)->result_ok;
2061 }
2062 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2063         LDKCResult_ChannelFeaturesDecodeErrorZ *val = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(arg & ~1);
2064         CHECK(val->result_ok);
2065         LDKChannelFeatures res_var = (*val->contents.result);
2066         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2067         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2068         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
2069         return res_ref;
2070 }
2071 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2072         LDKCResult_ChannelFeaturesDecodeErrorZ *val = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(arg & ~1);
2073         CHECK(!val->result_ok);
2074         LDKDecodeError err_var = (*val->contents.err);
2075         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2076         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2077         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
2078         return err_ref;
2079 }
2080 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceFeaturesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2081         return ((LDKCResult_InvoiceFeaturesDecodeErrorZ*)arg)->result_ok;
2082 }
2083 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2084         LDKCResult_InvoiceFeaturesDecodeErrorZ *val = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(arg & ~1);
2085         CHECK(val->result_ok);
2086         LDKInvoiceFeatures res_var = (*val->contents.result);
2087         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2088         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2089         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
2090         return res_ref;
2091 }
2092 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2093         LDKCResult_InvoiceFeaturesDecodeErrorZ *val = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(arg & ~1);
2094         CHECK(!val->result_ok);
2095         LDKDecodeError err_var = (*val->contents.err);
2096         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2097         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2098         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
2099         return err_ref;
2100 }
2101 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2102         return ((LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)arg)->result_ok;
2103 }
2104 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2105         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
2106         CHECK(val->result_ok);
2107         LDKDelayedPaymentOutputDescriptor res_var = (*val->contents.result);
2108         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2109         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2110         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
2111         return res_ref;
2112 }
2113 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2114         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
2115         CHECK(!val->result_ok);
2116         LDKDecodeError err_var = (*val->contents.err);
2117         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2118         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2119         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
2120         return err_ref;
2121 }
2122 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2123         return ((LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)arg)->result_ok;
2124 }
2125 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2126         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
2127         CHECK(val->result_ok);
2128         LDKStaticPaymentOutputDescriptor res_var = (*val->contents.result);
2129         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2130         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2131         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
2132         return res_ref;
2133 }
2134 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2135         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
2136         CHECK(!val->result_ok);
2137         LDKDecodeError err_var = (*val->contents.err);
2138         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2139         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2140         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
2141         return err_ref;
2142 }
2143 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SpendableOutputDescriptorDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2144         return ((LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)arg)->result_ok;
2145 }
2146 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SpendableOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2147         LDKCResult_SpendableOutputDescriptorDecodeErrorZ *val = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(arg & ~1);
2148         CHECK(val->result_ok);
2149         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
2150         return res_ref;
2151 }
2152 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SpendableOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2153         LDKCResult_SpendableOutputDescriptorDecodeErrorZ *val = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(arg & ~1);
2154         CHECK(!val->result_ok);
2155         LDKDecodeError err_var = (*val->contents.err);
2156         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2157         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2158         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
2159         return err_ref;
2160 }
2161 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2162         return ((LDKCResult_NoneNoneZ*)arg)->result_ok;
2163 }
2164 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2165         LDKCResult_NoneNoneZ *val = (LDKCResult_NoneNoneZ*)(arg & ~1);
2166         CHECK(val->result_ok);
2167         return *val->contents.result;
2168 }
2169 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2170         LDKCResult_NoneNoneZ *val = (LDKCResult_NoneNoneZ*)(arg & ~1);
2171         CHECK(!val->result_ok);
2172         return *val->contents.err;
2173 }
2174 static inline struct LDKSignature C2Tuple_SignatureCVec_SignatureZZ_get_a(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR tuple){
2175         return tuple->a;
2176 }
2177 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1get_1a(JNIEnv *env, jclass clz, int64_t tuple) {
2178         LDKC2Tuple_SignatureCVec_SignatureZZ* tuple_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(tuple & ~1);
2179         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
2180         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, C2Tuple_SignatureCVec_SignatureZZ_get_a(tuple_conv).compact_form);
2181         return ret_arr;
2182 }
2183
2184 static inline struct LDKCVec_SignatureZ C2Tuple_SignatureCVec_SignatureZZ_get_b(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR tuple){
2185         return tuple->b;
2186 }
2187 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1get_1b(JNIEnv *env, jclass clz, int64_t tuple) {
2188         LDKC2Tuple_SignatureCVec_SignatureZZ* tuple_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(tuple & ~1);
2189         LDKCVec_SignatureZ ret_var = C2Tuple_SignatureCVec_SignatureZZ_get_b(tuple_conv);
2190         jobjectArray ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
2191         ;
2192         for (size_t i = 0; i < ret_var.datalen; i++) {
2193                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 64);
2194                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 64, ret_var.data[i].compact_form);
2195                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
2196         }
2197         FREE(ret_var.data);
2198         return ret_arr;
2199 }
2200
2201 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2202         return ((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)arg)->result_ok;
2203 }
2204 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2205         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *val = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(arg & ~1);
2206         CHECK(val->result_ok);
2207         LDKC2Tuple_SignatureCVec_SignatureZZ* res_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
2208         *res_conv = (*val->contents.result);
2209         *res_conv = C2Tuple_SignatureCVec_SignatureZZ_clone(res_conv);
2210         return ((uint64_t)res_conv);
2211 }
2212 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2213         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *val = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(arg & ~1);
2214         CHECK(!val->result_ok);
2215         return *val->contents.err;
2216 }
2217 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignatureNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2218         return ((LDKCResult_SignatureNoneZ*)arg)->result_ok;
2219 }
2220 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignatureNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2221         LDKCResult_SignatureNoneZ *val = (LDKCResult_SignatureNoneZ*)(arg & ~1);
2222         CHECK(val->result_ok);
2223         int8_tArray res_arr = (*env)->NewByteArray(env, 64);
2224         (*env)->SetByteArrayRegion(env, res_arr, 0, 64, (*val->contents.result).compact_form);
2225         return res_arr;
2226 }
2227 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignatureNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2228         LDKCResult_SignatureNoneZ *val = (LDKCResult_SignatureNoneZ*)(arg & ~1);
2229         CHECK(!val->result_ok);
2230         return *val->contents.err;
2231 }
2232 typedef struct LDKBaseSign_JCalls {
2233         atomic_size_t refcnt;
2234         JavaVM *vm;
2235         jweak o;
2236         jmethodID get_per_commitment_point_meth;
2237         jmethodID release_commitment_secret_meth;
2238         jmethodID validate_holder_commitment_meth;
2239         jmethodID channel_keys_id_meth;
2240         jmethodID sign_counterparty_commitment_meth;
2241         jmethodID validate_counterparty_revocation_meth;
2242         jmethodID sign_holder_commitment_and_htlcs_meth;
2243         jmethodID sign_justice_revoked_output_meth;
2244         jmethodID sign_justice_revoked_htlc_meth;
2245         jmethodID sign_counterparty_htlc_transaction_meth;
2246         jmethodID sign_closing_transaction_meth;
2247         jmethodID sign_channel_announcement_meth;
2248         jmethodID ready_channel_meth;
2249 } LDKBaseSign_JCalls;
2250 static void LDKBaseSign_JCalls_free(void* this_arg) {
2251         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2252         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2253                 JNIEnv *env;
2254                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2255                 if (get_jenv_res == JNI_EDETACHED) {
2256                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2257                 } else {
2258                         DO_ASSERT(get_jenv_res == JNI_OK);
2259                 }
2260                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
2261                 if (get_jenv_res == JNI_EDETACHED) {
2262                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2263                 }
2264                 FREE(j_calls);
2265         }
2266 }
2267 LDKPublicKey get_per_commitment_point_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
2268         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2269         JNIEnv *env;
2270         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2271         if (get_jenv_res == JNI_EDETACHED) {
2272                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2273         } else {
2274                 DO_ASSERT(get_jenv_res == JNI_OK);
2275         }
2276         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2277         CHECK(obj != NULL);
2278         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_per_commitment_point_meth, idx);
2279         if ((*env)->ExceptionCheck(env)) {
2280                 (*env)->ExceptionDescribe(env);
2281                 (*env)->FatalError(env, "A call to get_per_commitment_point in LDKBaseSign from rust threw an exception.");
2282         }
2283         LDKPublicKey ret_ref;
2284         CHECK((*env)->GetArrayLength(env, ret) == 33);
2285         (*env)->GetByteArrayRegion(env, ret, 0, 33, ret_ref.compressed_form);
2286         if (get_jenv_res == JNI_EDETACHED) {
2287                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2288         }
2289         return ret_ref;
2290 }
2291 LDKThirtyTwoBytes release_commitment_secret_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->release_commitment_secret_meth, idx);
2303         if ((*env)->ExceptionCheck(env)) {
2304                 (*env)->ExceptionDescribe(env);
2305                 (*env)->FatalError(env, "A call to release_commitment_secret in LDKBaseSign from rust threw an exception.");
2306         }
2307         LDKThirtyTwoBytes ret_ref;
2308         CHECK((*env)->GetArrayLength(env, ret) == 32);
2309         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
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 LDKCResult_NoneNoneZ validate_holder_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * holder_tx) {
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         LDKHolderCommitmentTransaction holder_tx_var = *holder_tx;
2325         holder_tx_var = HolderCommitmentTransaction_clone(holder_tx);
2326         CHECK((((uint64_t)holder_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2327         CHECK((((uint64_t)&holder_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2328         uint64_t holder_tx_ref = (uint64_t)holder_tx_var.inner;
2329         if (holder_tx_var.is_owned) {
2330                 holder_tx_ref |= 1;
2331         }
2332         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2333         CHECK(obj != NULL);
2334         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->validate_holder_commitment_meth, holder_tx_ref);
2335         if ((*env)->ExceptionCheck(env)) {
2336                 (*env)->ExceptionDescribe(env);
2337                 (*env)->FatalError(env, "A call to validate_holder_commitment in LDKBaseSign from rust threw an exception.");
2338         }
2339         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
2340         CHECK_ACCESS(ret_ptr);
2341         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
2342         ret_conv = CResult_NoneNoneZ_clone((LDKCResult_NoneNoneZ*)(((uint64_t)ret) & ~1));
2343         if (get_jenv_res == JNI_EDETACHED) {
2344                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2345         }
2346         return ret_conv;
2347 }
2348 LDKThirtyTwoBytes channel_keys_id_LDKBaseSign_jcall(const void* this_arg) {
2349         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2350         JNIEnv *env;
2351         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2352         if (get_jenv_res == JNI_EDETACHED) {
2353                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2354         } else {
2355                 DO_ASSERT(get_jenv_res == JNI_OK);
2356         }
2357         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2358         CHECK(obj != NULL);
2359         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->channel_keys_id_meth);
2360         if ((*env)->ExceptionCheck(env)) {
2361                 (*env)->ExceptionDescribe(env);
2362                 (*env)->FatalError(env, "A call to channel_keys_id in LDKBaseSign from rust threw an exception.");
2363         }
2364         LDKThirtyTwoBytes ret_ref;
2365         CHECK((*env)->GetArrayLength(env, ret) == 32);
2366         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
2367         if (get_jenv_res == JNI_EDETACHED) {
2368                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2369         }
2370         return ret_ref;
2371 }
2372 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKCommitmentTransaction * commitment_tx) {
2373         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2374         JNIEnv *env;
2375         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2376         if (get_jenv_res == JNI_EDETACHED) {
2377                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2378         } else {
2379                 DO_ASSERT(get_jenv_res == JNI_OK);
2380         }
2381         LDKCommitmentTransaction commitment_tx_var = *commitment_tx;
2382         commitment_tx_var = CommitmentTransaction_clone(commitment_tx);
2383         CHECK((((uint64_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2384         CHECK((((uint64_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2385         uint64_t commitment_tx_ref = (uint64_t)commitment_tx_var.inner;
2386         if (commitment_tx_var.is_owned) {
2387                 commitment_tx_ref |= 1;
2388         }
2389         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2390         CHECK(obj != NULL);
2391         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_counterparty_commitment_meth, commitment_tx_ref);
2392         if ((*env)->ExceptionCheck(env)) {
2393                 (*env)->ExceptionDescribe(env);
2394                 (*env)->FatalError(env, "A call to sign_counterparty_commitment in LDKBaseSign from rust threw an exception.");
2395         }
2396         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
2397         CHECK_ACCESS(ret_ptr);
2398         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(ret_ptr);
2399         ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1));
2400         if (get_jenv_res == JNI_EDETACHED) {
2401                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2402         }
2403         return ret_conv;
2404 }
2405 LDKCResult_NoneNoneZ validate_counterparty_revocation_LDKBaseSign_jcall(const void* this_arg, uint64_t idx, const uint8_t (* secret)[32]) {
2406         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2407         JNIEnv *env;
2408         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2409         if (get_jenv_res == JNI_EDETACHED) {
2410                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2411         } else {
2412                 DO_ASSERT(get_jenv_res == JNI_OK);
2413         }
2414         int8_tArray secret_arr = (*env)->NewByteArray(env, 32);
2415         (*env)->SetByteArrayRegion(env, secret_arr, 0, 32, *secret);
2416         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2417         CHECK(obj != NULL);
2418         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->validate_counterparty_revocation_meth, idx, secret_arr);
2419         if ((*env)->ExceptionCheck(env)) {
2420                 (*env)->ExceptionDescribe(env);
2421                 (*env)->FatalError(env, "A call to validate_counterparty_revocation in LDKBaseSign from rust threw an exception.");
2422         }
2423         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
2424         CHECK_ACCESS(ret_ptr);
2425         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
2426         ret_conv = CResult_NoneNoneZ_clone((LDKCResult_NoneNoneZ*)(((uint64_t)ret) & ~1));
2427         if (get_jenv_res == JNI_EDETACHED) {
2428                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2429         }
2430         return ret_conv;
2431 }
2432 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_holder_commitment_and_htlcs_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * commitment_tx) {
2433         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2434         JNIEnv *env;
2435         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2436         if (get_jenv_res == JNI_EDETACHED) {
2437                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2438         } else {
2439                 DO_ASSERT(get_jenv_res == JNI_OK);
2440         }
2441         LDKHolderCommitmentTransaction commitment_tx_var = *commitment_tx;
2442         commitment_tx_var = HolderCommitmentTransaction_clone(commitment_tx);
2443         CHECK((((uint64_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2444         CHECK((((uint64_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2445         uint64_t commitment_tx_ref = (uint64_t)commitment_tx_var.inner;
2446         if (commitment_tx_var.is_owned) {
2447                 commitment_tx_ref |= 1;
2448         }
2449         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2450         CHECK(obj != NULL);
2451         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_holder_commitment_and_htlcs_meth, commitment_tx_ref);
2452         if ((*env)->ExceptionCheck(env)) {
2453                 (*env)->ExceptionDescribe(env);
2454                 (*env)->FatalError(env, "A call to sign_holder_commitment_and_htlcs in LDKBaseSign from rust threw an exception.");
2455         }
2456         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
2457         CHECK_ACCESS(ret_ptr);
2458         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(ret_ptr);
2459         ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1));
2460         if (get_jenv_res == JNI_EDETACHED) {
2461                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2462         }
2463         return ret_conv;
2464 }
2465 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]) {
2466         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2467         JNIEnv *env;
2468         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2469         if (get_jenv_res == JNI_EDETACHED) {
2470                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2471         } else {
2472                 DO_ASSERT(get_jenv_res == JNI_OK);
2473         }
2474         LDKTransaction justice_tx_var = justice_tx;
2475         int8_tArray justice_tx_arr = (*env)->NewByteArray(env, justice_tx_var.datalen);
2476         (*env)->SetByteArrayRegion(env, justice_tx_arr, 0, justice_tx_var.datalen, justice_tx_var.data);
2477         Transaction_free(justice_tx_var);
2478         int8_tArray per_commitment_key_arr = (*env)->NewByteArray(env, 32);
2479         (*env)->SetByteArrayRegion(env, per_commitment_key_arr, 0, 32, *per_commitment_key);
2480         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2481         CHECK(obj != NULL);
2482         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_justice_revoked_output_meth, justice_tx_arr, input, amount, per_commitment_key_arr);
2483         if ((*env)->ExceptionCheck(env)) {
2484                 (*env)->ExceptionDescribe(env);
2485                 (*env)->FatalError(env, "A call to sign_justice_revoked_output in LDKBaseSign from rust threw an exception.");
2486         }
2487         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
2488         CHECK_ACCESS(ret_ptr);
2489         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
2490         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
2491         if (get_jenv_res == JNI_EDETACHED) {
2492                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2493         }
2494         return ret_conv;
2495 }
2496 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) {
2497         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2498         JNIEnv *env;
2499         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2500         if (get_jenv_res == JNI_EDETACHED) {
2501                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2502         } else {
2503                 DO_ASSERT(get_jenv_res == JNI_OK);
2504         }
2505         LDKTransaction justice_tx_var = justice_tx;
2506         int8_tArray justice_tx_arr = (*env)->NewByteArray(env, justice_tx_var.datalen);
2507         (*env)->SetByteArrayRegion(env, justice_tx_arr, 0, justice_tx_var.datalen, justice_tx_var.data);
2508         Transaction_free(justice_tx_var);
2509         int8_tArray per_commitment_key_arr = (*env)->NewByteArray(env, 32);
2510         (*env)->SetByteArrayRegion(env, per_commitment_key_arr, 0, 32, *per_commitment_key);
2511         LDKHTLCOutputInCommitment htlc_var = *htlc;
2512         htlc_var = HTLCOutputInCommitment_clone(htlc);
2513         CHECK((((uint64_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2514         CHECK((((uint64_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2515         uint64_t htlc_ref = (uint64_t)htlc_var.inner;
2516         if (htlc_var.is_owned) {
2517                 htlc_ref |= 1;
2518         }
2519         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2520         CHECK(obj != NULL);
2521         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);
2522         if ((*env)->ExceptionCheck(env)) {
2523                 (*env)->ExceptionDescribe(env);
2524                 (*env)->FatalError(env, "A call to sign_justice_revoked_htlc in LDKBaseSign from rust threw an exception.");
2525         }
2526         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
2527         CHECK_ACCESS(ret_ptr);
2528         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
2529         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
2530         if (get_jenv_res == JNI_EDETACHED) {
2531                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2532         }
2533         return ret_conv;
2534 }
2535 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) {
2536         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2537         JNIEnv *env;
2538         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2539         if (get_jenv_res == JNI_EDETACHED) {
2540                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2541         } else {
2542                 DO_ASSERT(get_jenv_res == JNI_OK);
2543         }
2544         LDKTransaction htlc_tx_var = htlc_tx;
2545         int8_tArray htlc_tx_arr = (*env)->NewByteArray(env, htlc_tx_var.datalen);
2546         (*env)->SetByteArrayRegion(env, htlc_tx_arr, 0, htlc_tx_var.datalen, htlc_tx_var.data);
2547         Transaction_free(htlc_tx_var);
2548         int8_tArray per_commitment_point_arr = (*env)->NewByteArray(env, 33);
2549         (*env)->SetByteArrayRegion(env, per_commitment_point_arr, 0, 33, per_commitment_point.compressed_form);
2550         LDKHTLCOutputInCommitment htlc_var = *htlc;
2551         htlc_var = HTLCOutputInCommitment_clone(htlc);
2552         CHECK((((uint64_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2553         CHECK((((uint64_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2554         uint64_t htlc_ref = (uint64_t)htlc_var.inner;
2555         if (htlc_var.is_owned) {
2556                 htlc_ref |= 1;
2557         }
2558         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2559         CHECK(obj != NULL);
2560         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);
2561         if ((*env)->ExceptionCheck(env)) {
2562                 (*env)->ExceptionDescribe(env);
2563                 (*env)->FatalError(env, "A call to sign_counterparty_htlc_transaction in LDKBaseSign from rust threw an exception.");
2564         }
2565         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
2566         CHECK_ACCESS(ret_ptr);
2567         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
2568         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
2569         if (get_jenv_res == JNI_EDETACHED) {
2570                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2571         }
2572         return ret_conv;
2573 }
2574 LDKCResult_SignatureNoneZ sign_closing_transaction_LDKBaseSign_jcall(const void* this_arg, const LDKClosingTransaction * closing_tx) {
2575         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2576         JNIEnv *env;
2577         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2578         if (get_jenv_res == JNI_EDETACHED) {
2579                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2580         } else {
2581                 DO_ASSERT(get_jenv_res == JNI_OK);
2582         }
2583         LDKClosingTransaction closing_tx_var = *closing_tx;
2584         closing_tx_var = ClosingTransaction_clone(closing_tx);
2585         CHECK((((uint64_t)closing_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2586         CHECK((((uint64_t)&closing_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2587         uint64_t closing_tx_ref = (uint64_t)closing_tx_var.inner;
2588         if (closing_tx_var.is_owned) {
2589                 closing_tx_ref |= 1;
2590         }
2591         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2592         CHECK(obj != NULL);
2593         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_closing_transaction_meth, closing_tx_ref);
2594         if ((*env)->ExceptionCheck(env)) {
2595                 (*env)->ExceptionDescribe(env);
2596                 (*env)->FatalError(env, "A call to sign_closing_transaction in LDKBaseSign from rust threw an exception.");
2597         }
2598         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
2599         CHECK_ACCESS(ret_ptr);
2600         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
2601         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
2602         if (get_jenv_res == JNI_EDETACHED) {
2603                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2604         }
2605         return ret_conv;
2606 }
2607 LDKCResult_SignatureNoneZ sign_channel_announcement_LDKBaseSign_jcall(const void* this_arg, const LDKUnsignedChannelAnnouncement * msg) {
2608         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2609         JNIEnv *env;
2610         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2611         if (get_jenv_res == JNI_EDETACHED) {
2612                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2613         } else {
2614                 DO_ASSERT(get_jenv_res == JNI_OK);
2615         }
2616         LDKUnsignedChannelAnnouncement msg_var = *msg;
2617         msg_var = UnsignedChannelAnnouncement_clone(msg);
2618         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2619         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2620         uint64_t msg_ref = (uint64_t)msg_var.inner;
2621         if (msg_var.is_owned) {
2622                 msg_ref |= 1;
2623         }
2624         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2625         CHECK(obj != NULL);
2626         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_channel_announcement_meth, msg_ref);
2627         if ((*env)->ExceptionCheck(env)) {
2628                 (*env)->ExceptionDescribe(env);
2629                 (*env)->FatalError(env, "A call to sign_channel_announcement in LDKBaseSign from rust threw an exception.");
2630         }
2631         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
2632         CHECK_ACCESS(ret_ptr);
2633         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
2634         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
2635         if (get_jenv_res == JNI_EDETACHED) {
2636                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2637         }
2638         return ret_conv;
2639 }
2640 void ready_channel_LDKBaseSign_jcall(void* this_arg, const LDKChannelTransactionParameters * channel_parameters) {
2641         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2642         JNIEnv *env;
2643         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2644         if (get_jenv_res == JNI_EDETACHED) {
2645                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2646         } else {
2647                 DO_ASSERT(get_jenv_res == JNI_OK);
2648         }
2649         LDKChannelTransactionParameters channel_parameters_var = *channel_parameters;
2650         channel_parameters_var = ChannelTransactionParameters_clone(channel_parameters);
2651         CHECK((((uint64_t)channel_parameters_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2652         CHECK((((uint64_t)&channel_parameters_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2653         uint64_t channel_parameters_ref = (uint64_t)channel_parameters_var.inner;
2654         if (channel_parameters_var.is_owned) {
2655                 channel_parameters_ref |= 1;
2656         }
2657         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2658         CHECK(obj != NULL);
2659         (*env)->CallVoidMethod(env, obj, j_calls->ready_channel_meth, channel_parameters_ref);
2660         if ((*env)->ExceptionCheck(env)) {
2661                 (*env)->ExceptionDescribe(env);
2662                 (*env)->FatalError(env, "A call to ready_channel in LDKBaseSign from rust threw an exception.");
2663         }
2664         if (get_jenv_res == JNI_EDETACHED) {
2665                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2666         }
2667 }
2668 static inline LDKBaseSign LDKBaseSign_init (JNIEnv *env, jclass clz, jobject o, int64_t pubkeys) {
2669         jclass c = (*env)->GetObjectClass(env, o);
2670         CHECK(c != NULL);
2671         LDKBaseSign_JCalls *calls = MALLOC(sizeof(LDKBaseSign_JCalls), "LDKBaseSign_JCalls");
2672         atomic_init(&calls->refcnt, 1);
2673         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
2674         calls->o = (*env)->NewWeakGlobalRef(env, o);
2675         calls->get_per_commitment_point_meth = (*env)->GetMethodID(env, c, "get_per_commitment_point", "(J)[B");
2676         CHECK(calls->get_per_commitment_point_meth != NULL);
2677         calls->release_commitment_secret_meth = (*env)->GetMethodID(env, c, "release_commitment_secret", "(J)[B");
2678         CHECK(calls->release_commitment_secret_meth != NULL);
2679         calls->validate_holder_commitment_meth = (*env)->GetMethodID(env, c, "validate_holder_commitment", "(J)J");
2680         CHECK(calls->validate_holder_commitment_meth != NULL);
2681         calls->channel_keys_id_meth = (*env)->GetMethodID(env, c, "channel_keys_id", "()[B");
2682         CHECK(calls->channel_keys_id_meth != NULL);
2683         calls->sign_counterparty_commitment_meth = (*env)->GetMethodID(env, c, "sign_counterparty_commitment", "(J)J");
2684         CHECK(calls->sign_counterparty_commitment_meth != NULL);
2685         calls->validate_counterparty_revocation_meth = (*env)->GetMethodID(env, c, "validate_counterparty_revocation", "(J[B)J");
2686         CHECK(calls->validate_counterparty_revocation_meth != NULL);
2687         calls->sign_holder_commitment_and_htlcs_meth = (*env)->GetMethodID(env, c, "sign_holder_commitment_and_htlcs", "(J)J");
2688         CHECK(calls->sign_holder_commitment_and_htlcs_meth != NULL);
2689         calls->sign_justice_revoked_output_meth = (*env)->GetMethodID(env, c, "sign_justice_revoked_output", "([BJJ[B)J");
2690         CHECK(calls->sign_justice_revoked_output_meth != NULL);
2691         calls->sign_justice_revoked_htlc_meth = (*env)->GetMethodID(env, c, "sign_justice_revoked_htlc", "([BJJ[BJ)J");
2692         CHECK(calls->sign_justice_revoked_htlc_meth != NULL);
2693         calls->sign_counterparty_htlc_transaction_meth = (*env)->GetMethodID(env, c, "sign_counterparty_htlc_transaction", "([BJJ[BJ)J");
2694         CHECK(calls->sign_counterparty_htlc_transaction_meth != NULL);
2695         calls->sign_closing_transaction_meth = (*env)->GetMethodID(env, c, "sign_closing_transaction", "(J)J");
2696         CHECK(calls->sign_closing_transaction_meth != NULL);
2697         calls->sign_channel_announcement_meth = (*env)->GetMethodID(env, c, "sign_channel_announcement", "(J)J");
2698         CHECK(calls->sign_channel_announcement_meth != NULL);
2699         calls->ready_channel_meth = (*env)->GetMethodID(env, c, "ready_channel", "(J)V");
2700         CHECK(calls->ready_channel_meth != NULL);
2701
2702         LDKChannelPublicKeys pubkeys_conv;
2703         pubkeys_conv.inner = (void*)(pubkeys & (~1));
2704         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
2705         pubkeys_conv = ChannelPublicKeys_clone(&pubkeys_conv);
2706
2707         LDKBaseSign ret = {
2708                 .this_arg = (void*) calls,
2709                 .get_per_commitment_point = get_per_commitment_point_LDKBaseSign_jcall,
2710                 .release_commitment_secret = release_commitment_secret_LDKBaseSign_jcall,
2711                 .validate_holder_commitment = validate_holder_commitment_LDKBaseSign_jcall,
2712                 .channel_keys_id = channel_keys_id_LDKBaseSign_jcall,
2713                 .sign_counterparty_commitment = sign_counterparty_commitment_LDKBaseSign_jcall,
2714                 .validate_counterparty_revocation = validate_counterparty_revocation_LDKBaseSign_jcall,
2715                 .sign_holder_commitment_and_htlcs = sign_holder_commitment_and_htlcs_LDKBaseSign_jcall,
2716                 .sign_justice_revoked_output = sign_justice_revoked_output_LDKBaseSign_jcall,
2717                 .sign_justice_revoked_htlc = sign_justice_revoked_htlc_LDKBaseSign_jcall,
2718                 .sign_counterparty_htlc_transaction = sign_counterparty_htlc_transaction_LDKBaseSign_jcall,
2719                 .sign_closing_transaction = sign_closing_transaction_LDKBaseSign_jcall,
2720                 .sign_channel_announcement = sign_channel_announcement_LDKBaseSign_jcall,
2721                 .ready_channel = ready_channel_LDKBaseSign_jcall,
2722                 .free = LDKBaseSign_JCalls_free,
2723                 .pubkeys = pubkeys_conv,
2724                 .set_pubkeys = NULL,
2725         };
2726         return ret;
2727 }
2728 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKBaseSign_1new(JNIEnv *env, jclass clz, jobject o, int64_t pubkeys) {
2729         LDKBaseSign *res_ptr = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
2730         *res_ptr = LDKBaseSign_init(env, clz, o, pubkeys);
2731         return (uint64_t)res_ptr;
2732 }
2733 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) {
2734         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
2735         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
2736         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
2737         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
2738         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, (this_arg_conv->get_per_commitment_point)(this_arg_conv->this_arg, idx).compressed_form);
2739         return ret_arr;
2740 }
2741
2742 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BaseSign_1release_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_arg, int64_t idx) {
2743         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
2744         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
2745         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
2746         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
2747         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->release_commitment_secret)(this_arg_conv->this_arg, idx).data);
2748         return ret_arr;
2749 }
2750
2751 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) {
2752         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
2753         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
2754         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
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         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
2765         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
2766         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
2767         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
2768         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->channel_keys_id)(this_arg_conv->this_arg).data);
2769         return ret_arr;
2770 }
2771
2772 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) {
2773         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
2774         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
2775         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
2776         LDKCommitmentTransaction commitment_tx_conv;
2777         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
2778         commitment_tx_conv.is_owned = false;
2779         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
2780         *ret_conv = (this_arg_conv->sign_counterparty_commitment)(this_arg_conv->this_arg, &commitment_tx_conv);
2781         return (uint64_t)ret_conv;
2782 }
2783
2784 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) {
2785         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
2786         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
2787         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
2788         unsigned char secret_arr[32];
2789         CHECK((*env)->GetArrayLength(env, secret) == 32);
2790         (*env)->GetByteArrayRegion(env, secret, 0, 32, secret_arr);
2791         unsigned char (*secret_ref)[32] = &secret_arr;
2792         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
2793         *ret_conv = (this_arg_conv->validate_counterparty_revocation)(this_arg_conv->this_arg, idx, secret_ref);
2794         return (uint64_t)ret_conv;
2795 }
2796
2797 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) {
2798         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
2799         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
2800         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
2801         LDKHolderCommitmentTransaction commitment_tx_conv;
2802         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
2803         commitment_tx_conv.is_owned = false;
2804         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
2805         *ret_conv = (this_arg_conv->sign_holder_commitment_and_htlcs)(this_arg_conv->this_arg, &commitment_tx_conv);
2806         return (uint64_t)ret_conv;
2807 }
2808
2809 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) {
2810         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
2811         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
2812         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
2813         LDKTransaction justice_tx_ref;
2814         justice_tx_ref.datalen = (*env)->GetArrayLength(env, justice_tx);
2815         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
2816         (*env)->GetByteArrayRegion(env, justice_tx, 0, justice_tx_ref.datalen, justice_tx_ref.data);
2817         justice_tx_ref.data_is_owned = true;
2818         unsigned char per_commitment_key_arr[32];
2819         CHECK((*env)->GetArrayLength(env, per_commitment_key) == 32);
2820         (*env)->GetByteArrayRegion(env, per_commitment_key, 0, 32, per_commitment_key_arr);
2821         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
2822         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2823         *ret_conv = (this_arg_conv->sign_justice_revoked_output)(this_arg_conv->this_arg, justice_tx_ref, input, amount, per_commitment_key_ref);
2824         return (uint64_t)ret_conv;
2825 }
2826
2827 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) {
2828         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
2829         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
2830         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
2831         LDKTransaction justice_tx_ref;
2832         justice_tx_ref.datalen = (*env)->GetArrayLength(env, justice_tx);
2833         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
2834         (*env)->GetByteArrayRegion(env, justice_tx, 0, justice_tx_ref.datalen, justice_tx_ref.data);
2835         justice_tx_ref.data_is_owned = true;
2836         unsigned char per_commitment_key_arr[32];
2837         CHECK((*env)->GetArrayLength(env, per_commitment_key) == 32);
2838         (*env)->GetByteArrayRegion(env, per_commitment_key, 0, 32, per_commitment_key_arr);
2839         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
2840         LDKHTLCOutputInCommitment htlc_conv;
2841         htlc_conv.inner = (void*)(htlc & (~1));
2842         htlc_conv.is_owned = false;
2843         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2844         *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);
2845         return (uint64_t)ret_conv;
2846 }
2847
2848 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) {
2849         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
2850         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
2851         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
2852         LDKTransaction htlc_tx_ref;
2853         htlc_tx_ref.datalen = (*env)->GetArrayLength(env, htlc_tx);
2854         htlc_tx_ref.data = MALLOC(htlc_tx_ref.datalen, "LDKTransaction Bytes");
2855         (*env)->GetByteArrayRegion(env, htlc_tx, 0, htlc_tx_ref.datalen, htlc_tx_ref.data);
2856         htlc_tx_ref.data_is_owned = true;
2857         LDKPublicKey per_commitment_point_ref;
2858         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
2859         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
2860         LDKHTLCOutputInCommitment htlc_conv;
2861         htlc_conv.inner = (void*)(htlc & (~1));
2862         htlc_conv.is_owned = false;
2863         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2864         *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);
2865         return (uint64_t)ret_conv;
2866 }
2867
2868 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) {
2869         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
2870         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
2871         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
2872         LDKClosingTransaction closing_tx_conv;
2873         closing_tx_conv.inner = (void*)(closing_tx & (~1));
2874         closing_tx_conv.is_owned = false;
2875         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2876         *ret_conv = (this_arg_conv->sign_closing_transaction)(this_arg_conv->this_arg, &closing_tx_conv);
2877         return (uint64_t)ret_conv;
2878 }
2879
2880 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1sign_1channel_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
2881         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
2882         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
2883         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
2884         LDKUnsignedChannelAnnouncement msg_conv;
2885         msg_conv.inner = (void*)(msg & (~1));
2886         msg_conv.is_owned = false;
2887         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2888         *ret_conv = (this_arg_conv->sign_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
2889         return (uint64_t)ret_conv;
2890 }
2891
2892 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BaseSign_1ready_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t channel_parameters) {
2893         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
2894         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
2895         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
2896         LDKChannelTransactionParameters channel_parameters_conv;
2897         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
2898         channel_parameters_conv.is_owned = false;
2899         (this_arg_conv->ready_channel)(this_arg_conv->this_arg, &channel_parameters_conv);
2900 }
2901
2902 LDKChannelPublicKeys LDKBaseSign_set_get_pubkeys(LDKBaseSign* this_arg) {
2903         if (this_arg->set_pubkeys != NULL)
2904                 this_arg->set_pubkeys(this_arg);
2905         return this_arg->pubkeys;
2906 }
2907 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1get_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
2908         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
2909         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
2910         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
2911         LDKChannelPublicKeys ret_var = LDKBaseSign_set_get_pubkeys(this_arg_conv);
2912         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2913         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2914         uint64_t ret_ref = (uint64_t)ret_var.inner;
2915         if (ret_var.is_owned) {
2916                 ret_ref |= 1;
2917         }
2918         return ret_ref;
2919 }
2920
2921 typedef struct LDKSign_JCalls {
2922         atomic_size_t refcnt;
2923         JavaVM *vm;
2924         jweak o;
2925         LDKBaseSign_JCalls* BaseSign;
2926         jmethodID write_meth;
2927 } LDKSign_JCalls;
2928 static void LDKSign_JCalls_free(void* this_arg) {
2929         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
2930         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2931                 JNIEnv *env;
2932                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2933                 if (get_jenv_res == JNI_EDETACHED) {
2934                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2935                 } else {
2936                         DO_ASSERT(get_jenv_res == JNI_OK);
2937                 }
2938                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
2939                 if (get_jenv_res == JNI_EDETACHED) {
2940                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2941                 }
2942                 FREE(j_calls);
2943         }
2944 }
2945 LDKCVec_u8Z write_LDKSign_jcall(const void* this_arg) {
2946         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
2947         JNIEnv *env;
2948         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2949         if (get_jenv_res == JNI_EDETACHED) {
2950                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2951         } else {
2952                 DO_ASSERT(get_jenv_res == JNI_OK);
2953         }
2954         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2955         CHECK(obj != NULL);
2956         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->write_meth);
2957         if ((*env)->ExceptionCheck(env)) {
2958                 (*env)->ExceptionDescribe(env);
2959                 (*env)->FatalError(env, "A call to write in LDKSign from rust threw an exception.");
2960         }
2961         LDKCVec_u8Z ret_ref;
2962         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
2963         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
2964         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
2965         if (get_jenv_res == JNI_EDETACHED) {
2966                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2967         }
2968         return ret_ref;
2969 }
2970 static void LDKSign_JCalls_cloned(LDKSign* new_obj) {
2971         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) new_obj->this_arg;
2972         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2973         atomic_fetch_add_explicit(&j_calls->BaseSign->refcnt, 1, memory_order_release);
2974 }
2975 static inline LDKSign LDKSign_init (JNIEnv *env, jclass clz, jobject o, jobject BaseSign, int64_t pubkeys) {
2976         jclass c = (*env)->GetObjectClass(env, o);
2977         CHECK(c != NULL);
2978         LDKSign_JCalls *calls = MALLOC(sizeof(LDKSign_JCalls), "LDKSign_JCalls");
2979         atomic_init(&calls->refcnt, 1);
2980         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
2981         calls->o = (*env)->NewWeakGlobalRef(env, o);
2982         calls->write_meth = (*env)->GetMethodID(env, c, "write", "()[B");
2983         CHECK(calls->write_meth != NULL);
2984
2985         LDKChannelPublicKeys pubkeys_conv;
2986         pubkeys_conv.inner = (void*)(pubkeys & (~1));
2987         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
2988         pubkeys_conv = ChannelPublicKeys_clone(&pubkeys_conv);
2989
2990         LDKSign ret = {
2991                 .this_arg = (void*) calls,
2992                 .write = write_LDKSign_jcall,
2993                 .cloned = LDKSign_JCalls_cloned,
2994                 .free = LDKSign_JCalls_free,
2995                 .BaseSign = LDKBaseSign_init(env, clz, BaseSign, pubkeys),
2996         };
2997         calls->BaseSign = ret.BaseSign.this_arg;
2998         return ret;
2999 }
3000 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSign_1new(JNIEnv *env, jclass clz, jobject o, jobject BaseSign, int64_t pubkeys) {
3001         LDKSign *res_ptr = MALLOC(sizeof(LDKSign), "LDKSign");
3002         *res_ptr = LDKSign_init(env, clz, o, BaseSign, pubkeys);
3003         return (uint64_t)res_ptr;
3004 }
3005 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSign_1get_1BaseSign(JNIEnv *env, jclass clz, int64_t arg) {
3006         LDKSign *inp = (LDKSign *)(arg & ~1);
3007         uint64_t res_ptr = (uint64_t)&inp->BaseSign;
3008         DO_ASSERT((res_ptr & 1) == 0);
3009         return (int64_t)(res_ptr | 1);
3010 }
3011 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Sign_1write(JNIEnv *env, jclass clz, int64_t this_arg) {
3012         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
3013         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3014         LDKSign* this_arg_conv = (LDKSign*)this_arg_ptr;
3015         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
3016         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
3017         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
3018         CVec_u8Z_free(ret_var);
3019         return ret_arr;
3020 }
3021
3022 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3023         return ((LDKCResult_SignDecodeErrorZ*)arg)->result_ok;
3024 }
3025 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3026         LDKCResult_SignDecodeErrorZ *val = (LDKCResult_SignDecodeErrorZ*)(arg & ~1);
3027         CHECK(val->result_ok);
3028         LDKSign* res_ret =MALLOC(sizeof(LDKSign), "LDKSign");
3029         *res_ret = Sign_clone(&(*val->contents.result));
3030         return (uint64_t)res_ret;
3031 }
3032 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3033         LDKCResult_SignDecodeErrorZ *val = (LDKCResult_SignDecodeErrorZ*)(arg & ~1);
3034         CHECK(!val->result_ok);
3035         LDKDecodeError err_var = (*val->contents.err);
3036         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3037         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3038         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
3039         return err_ref;
3040 }
3041 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RecoverableSignatureNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3042         return ((LDKCResult_RecoverableSignatureNoneZ*)arg)->result_ok;
3043 }
3044 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RecoverableSignatureNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3045         LDKCResult_RecoverableSignatureNoneZ *val = (LDKCResult_RecoverableSignatureNoneZ*)(arg & ~1);
3046         CHECK(val->result_ok);
3047         int8_tArray es_arr = (*env)->NewByteArray(env, 68);
3048         (*env)->SetByteArrayRegion(env, es_arr, 0, 68, (*val->contents.result).serialized_form);
3049         return es_arr;
3050 }
3051 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RecoverableSignatureNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3052         LDKCResult_RecoverableSignatureNoneZ *val = (LDKCResult_RecoverableSignatureNoneZ*)(arg & ~1);
3053         CHECK(!val->result_ok);
3054         return *val->contents.err;
3055 }
3056 static inline LDKCVec_CVec_u8ZZ CVec_CVec_u8ZZ_clone(const LDKCVec_CVec_u8ZZ *orig) {
3057         LDKCVec_CVec_u8ZZ ret = { .data = MALLOC(sizeof(LDKCVec_u8Z) * orig->datalen, "LDKCVec_CVec_u8ZZ clone bytes"), .datalen = orig->datalen };
3058         for (size_t i = 0; i < ret.datalen; i++) {
3059                 ret.data[i] = CVec_u8Z_clone(&orig->data[i]);
3060         }
3061         return ret;
3062 }
3063 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1CVec_1u8ZZNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3064         return ((LDKCResult_CVec_CVec_u8ZZNoneZ*)arg)->result_ok;
3065 }
3066 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1CVec_1u8ZZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3067         LDKCResult_CVec_CVec_u8ZZNoneZ *val = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(arg & ~1);
3068         CHECK(val->result_ok);
3069         LDKCVec_CVec_u8ZZ res_var = (*val->contents.result);
3070         jobjectArray res_arr = (*env)->NewObjectArray(env, res_var.datalen, arr_of_B_clz, NULL);
3071         ;
3072         for (size_t i = 0; i < res_var.datalen; i++) {
3073                 LDKCVec_u8Z res_conv_8_var = res_var.data[i];
3074                 int8_tArray res_conv_8_arr = (*env)->NewByteArray(env, res_conv_8_var.datalen);
3075                 (*env)->SetByteArrayRegion(env, res_conv_8_arr, 0, res_conv_8_var.datalen, res_conv_8_var.data);
3076                 (*env)->SetObjectArrayElement(env, res_arr, i, res_conv_8_arr);
3077         }
3078         return res_arr;
3079 }
3080 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1CVec_1u8ZZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3081         LDKCResult_CVec_CVec_u8ZZNoneZ *val = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(arg & ~1);
3082         CHECK(!val->result_ok);
3083         return *val->contents.err;
3084 }
3085 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InMemorySignerDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3086         return ((LDKCResult_InMemorySignerDecodeErrorZ*)arg)->result_ok;
3087 }
3088 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InMemorySignerDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3089         LDKCResult_InMemorySignerDecodeErrorZ *val = (LDKCResult_InMemorySignerDecodeErrorZ*)(arg & ~1);
3090         CHECK(val->result_ok);
3091         LDKInMemorySigner res_var = (*val->contents.result);
3092         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3093         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3094         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
3095         return res_ref;
3096 }
3097 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InMemorySignerDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3098         LDKCResult_InMemorySignerDecodeErrorZ *val = (LDKCResult_InMemorySignerDecodeErrorZ*)(arg & ~1);
3099         CHECK(!val->result_ok);
3100         LDKDecodeError err_var = (*val->contents.err);
3101         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3102         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3103         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
3104         return err_ref;
3105 }
3106 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1TxOutZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
3107         LDKCVec_TxOutZ *ret = MALLOC(sizeof(LDKCVec_TxOutZ), "LDKCVec_TxOutZ");
3108         ret->datalen = (*env)->GetArrayLength(env, elems);
3109         if (ret->datalen == 0) {
3110                 ret->data = NULL;
3111         } else {
3112                 ret->data = MALLOC(sizeof(LDKTxOut) * ret->datalen, "LDKCVec_TxOutZ Data");
3113                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3114                 for (size_t i = 0; i < ret->datalen; i++) {
3115                         int64_t arr_elem = java_elems[i];
3116                         void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
3117                         CHECK_ACCESS(arr_elem_ptr);
3118                         LDKTxOut arr_elem_conv = *(LDKTxOut*)(arr_elem_ptr);
3119                         arr_elem_conv = TxOut_clone((LDKTxOut*)(((uint64_t)arr_elem) & ~1));
3120                         ret->data[i] = arr_elem_conv;
3121                 }
3122                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3123         }
3124         return (uint64_t)ret;
3125 }
3126 static inline LDKCVec_TxOutZ CVec_TxOutZ_clone(const LDKCVec_TxOutZ *orig) {
3127         LDKCVec_TxOutZ ret = { .data = MALLOC(sizeof(LDKTxOut) * orig->datalen, "LDKCVec_TxOutZ clone bytes"), .datalen = orig->datalen };
3128         for (size_t i = 0; i < ret.datalen; i++) {
3129                 ret.data[i] = TxOut_clone(&orig->data[i]);
3130         }
3131         return ret;
3132 }
3133 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TransactionNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3134         return ((LDKCResult_TransactionNoneZ*)arg)->result_ok;
3135 }
3136 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TransactionNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3137         LDKCResult_TransactionNoneZ *val = (LDKCResult_TransactionNoneZ*)(arg & ~1);
3138         CHECK(val->result_ok);
3139         LDKTransaction res_var = (*val->contents.result);
3140         int8_tArray res_arr = (*env)->NewByteArray(env, res_var.datalen);
3141         (*env)->SetByteArrayRegion(env, res_arr, 0, res_var.datalen, res_var.data);
3142         return res_arr;
3143 }
3144 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TransactionNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3145         LDKCResult_TransactionNoneZ *val = (LDKCResult_TransactionNoneZ*)(arg & ~1);
3146         CHECK(!val->result_ok);
3147         return *val->contents.err;
3148 }
3149 static inline struct LDKThirtyTwoBytes C2Tuple_BlockHashChannelMonitorZ_get_a(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR tuple){
3150         return ThirtyTwoBytes_clone(&tuple->a);
3151 }
3152 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1get_1a(JNIEnv *env, jclass clz, int64_t tuple) {
3153         LDKC2Tuple_BlockHashChannelMonitorZ* tuple_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(tuple & ~1);
3154         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
3155         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_BlockHashChannelMonitorZ_get_a(tuple_conv).data);
3156         return ret_arr;
3157 }
3158
3159 static inline struct LDKChannelMonitor C2Tuple_BlockHashChannelMonitorZ_get_b(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR tuple){
3160         return ChannelMonitor_clone(&tuple->b);
3161 }
3162 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1get_1b(JNIEnv *env, jclass clz, int64_t tuple) {
3163         LDKC2Tuple_BlockHashChannelMonitorZ* tuple_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(tuple & ~1);
3164         LDKChannelMonitor ret_var = C2Tuple_BlockHashChannelMonitorZ_get_b(tuple_conv);
3165         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3166         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3167         uint64_t ret_ref = (uint64_t)ret_var.inner;
3168         if (ret_var.is_owned) {
3169                 ret_ref |= 1;
3170         }
3171         return ret_ref;
3172 }
3173
3174 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1BlockHashChannelMonitorZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
3175         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_BlockHashChannelMonitorZZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ");
3176         ret->datalen = (*env)->GetArrayLength(env, elems);
3177         if (ret->datalen == 0) {
3178                 ret->data = NULL;
3179         } else {
3180                 ret->data = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ) * ret->datalen, "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Data");
3181                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3182                 for (size_t i = 0; i < ret->datalen; i++) {
3183                         int64_t arr_elem = java_elems[i];
3184                         void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
3185                         CHECK_ACCESS(arr_elem_ptr);
3186                         LDKC2Tuple_BlockHashChannelMonitorZ arr_elem_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(arr_elem_ptr);
3187                         arr_elem_conv = C2Tuple_BlockHashChannelMonitorZ_clone((LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)arr_elem) & ~1));
3188                         ret->data[i] = arr_elem_conv;
3189                 }
3190                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3191         }
3192         return (uint64_t)ret;
3193 }
3194 static inline LDKCVec_C2Tuple_BlockHashChannelMonitorZZ CVec_C2Tuple_BlockHashChannelMonitorZZ_clone(const LDKCVec_C2Tuple_BlockHashChannelMonitorZZ *orig) {
3195         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ) * orig->datalen, "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ clone bytes"), .datalen = orig->datalen };
3196         for (size_t i = 0; i < ret.datalen; i++) {
3197                 ret.data[i] = C2Tuple_BlockHashChannelMonitorZ_clone(&orig->data[i]);
3198         }
3199         return ret;
3200 }
3201 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3202         return ((LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)arg)->result_ok;
3203 }
3204 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1get_1ok(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         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ res_var = (*val->contents.result);
3208         int64_tArray res_arr = (*env)->NewLongArray(env, res_var.datalen);
3209         int64_t *res_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, res_arr, NULL);
3210         for (size_t j = 0; j < res_var.datalen; j++) {
3211                 LDKC2Tuple_BlockHashChannelMonitorZ* res_conv_35_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
3212                 *res_conv_35_conv = res_var.data[j];
3213                 *res_conv_35_conv = C2Tuple_BlockHashChannelMonitorZ_clone(res_conv_35_conv);
3214                 res_arr_ptr[j] = ((uint64_t)res_conv_35_conv);
3215         }
3216         (*env)->ReleasePrimitiveArrayCritical(env, res_arr, res_arr_ptr, 0);
3217         return res_arr;
3218 }
3219 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3220         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *val = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(arg & ~1);
3221         CHECK(!val->result_ok);
3222         jclass err_conv = LDKIOError_to_java(env, (*val->contents.err));
3223         return err_conv;
3224 }
3225 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentIdDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3226         return ((LDKCResult_PaymentIdDecodeErrorZ*)arg)->result_ok;
3227 }
3228 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentIdDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3229         LDKCResult_PaymentIdDecodeErrorZ *val = (LDKCResult_PaymentIdDecodeErrorZ*)(arg & ~1);
3230         CHECK(val->result_ok);
3231         LDKPaymentId res_var = (*val->contents.result);
3232         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3233         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3234         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
3235         return res_ref;
3236 }
3237 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentIdDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3238         LDKCResult_PaymentIdDecodeErrorZ *val = (LDKCResult_PaymentIdDecodeErrorZ*)(arg & ~1);
3239         CHECK(!val->result_ok);
3240         LDKDecodeError err_var = (*val->contents.err);
3241         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3242         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3243         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
3244         return err_ref;
3245 }
3246 static jclass LDKCOption_u16Z_Some_class = NULL;
3247 static jmethodID LDKCOption_u16Z_Some_meth = NULL;
3248 static jclass LDKCOption_u16Z_None_class = NULL;
3249 static jmethodID LDKCOption_u16Z_None_meth = NULL;
3250 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u16Z_init (JNIEnv *env, jclass clz) {
3251         LDKCOption_u16Z_Some_class =
3252                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_u16Z$Some;"));
3253         CHECK(LDKCOption_u16Z_Some_class != NULL);
3254         LDKCOption_u16Z_Some_meth = (*env)->GetMethodID(env, LDKCOption_u16Z_Some_class, "<init>", "(S)V");
3255         CHECK(LDKCOption_u16Z_Some_meth != NULL);
3256         LDKCOption_u16Z_None_class =
3257                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_u16Z$None;"));
3258         CHECK(LDKCOption_u16Z_None_class != NULL);
3259         LDKCOption_u16Z_None_meth = (*env)->GetMethodID(env, LDKCOption_u16Z_None_class, "<init>", "()V");
3260         CHECK(LDKCOption_u16Z_None_meth != NULL);
3261 }
3262 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u16Z_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3263         LDKCOption_u16Z *obj = (LDKCOption_u16Z*)(ptr & ~1);
3264         switch(obj->tag) {
3265                 case LDKCOption_u16Z_Some: {
3266                         return (*env)->NewObject(env, LDKCOption_u16Z_Some_class, LDKCOption_u16Z_Some_meth, obj->some);
3267                 }
3268                 case LDKCOption_u16Z_None: {
3269                         return (*env)->NewObject(env, LDKCOption_u16Z_None_class, LDKCOption_u16Z_None_meth);
3270                 }
3271                 default: abort();
3272         }
3273 }
3274 static jclass LDKAPIError_APIMisuseError_class = NULL;
3275 static jmethodID LDKAPIError_APIMisuseError_meth = NULL;
3276 static jclass LDKAPIError_FeeRateTooHigh_class = NULL;
3277 static jmethodID LDKAPIError_FeeRateTooHigh_meth = NULL;
3278 static jclass LDKAPIError_RouteError_class = NULL;
3279 static jmethodID LDKAPIError_RouteError_meth = NULL;
3280 static jclass LDKAPIError_ChannelUnavailable_class = NULL;
3281 static jmethodID LDKAPIError_ChannelUnavailable_meth = NULL;
3282 static jclass LDKAPIError_MonitorUpdateFailed_class = NULL;
3283 static jmethodID LDKAPIError_MonitorUpdateFailed_meth = NULL;
3284 static jclass LDKAPIError_IncompatibleShutdownScript_class = NULL;
3285 static jmethodID LDKAPIError_IncompatibleShutdownScript_meth = NULL;
3286 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKAPIError_init (JNIEnv *env, jclass clz) {
3287         LDKAPIError_APIMisuseError_class =
3288                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$APIMisuseError;"));
3289         CHECK(LDKAPIError_APIMisuseError_class != NULL);
3290         LDKAPIError_APIMisuseError_meth = (*env)->GetMethodID(env, LDKAPIError_APIMisuseError_class, "<init>", "(Ljava/lang/String;)V");
3291         CHECK(LDKAPIError_APIMisuseError_meth != NULL);
3292         LDKAPIError_FeeRateTooHigh_class =
3293                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$FeeRateTooHigh;"));
3294         CHECK(LDKAPIError_FeeRateTooHigh_class != NULL);
3295         LDKAPIError_FeeRateTooHigh_meth = (*env)->GetMethodID(env, LDKAPIError_FeeRateTooHigh_class, "<init>", "(Ljava/lang/String;I)V");
3296         CHECK(LDKAPIError_FeeRateTooHigh_meth != NULL);
3297         LDKAPIError_RouteError_class =
3298                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$RouteError;"));
3299         CHECK(LDKAPIError_RouteError_class != NULL);
3300         LDKAPIError_RouteError_meth = (*env)->GetMethodID(env, LDKAPIError_RouteError_class, "<init>", "(Ljava/lang/String;)V");
3301         CHECK(LDKAPIError_RouteError_meth != NULL);
3302         LDKAPIError_ChannelUnavailable_class =
3303                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$ChannelUnavailable;"));
3304         CHECK(LDKAPIError_ChannelUnavailable_class != NULL);
3305         LDKAPIError_ChannelUnavailable_meth = (*env)->GetMethodID(env, LDKAPIError_ChannelUnavailable_class, "<init>", "(Ljava/lang/String;)V");
3306         CHECK(LDKAPIError_ChannelUnavailable_meth != NULL);
3307         LDKAPIError_MonitorUpdateFailed_class =
3308                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$MonitorUpdateFailed;"));
3309         CHECK(LDKAPIError_MonitorUpdateFailed_class != NULL);
3310         LDKAPIError_MonitorUpdateFailed_meth = (*env)->GetMethodID(env, LDKAPIError_MonitorUpdateFailed_class, "<init>", "()V");
3311         CHECK(LDKAPIError_MonitorUpdateFailed_meth != NULL);
3312         LDKAPIError_IncompatibleShutdownScript_class =
3313                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$IncompatibleShutdownScript;"));
3314         CHECK(LDKAPIError_IncompatibleShutdownScript_class != NULL);
3315         LDKAPIError_IncompatibleShutdownScript_meth = (*env)->GetMethodID(env, LDKAPIError_IncompatibleShutdownScript_class, "<init>", "(J)V");
3316         CHECK(LDKAPIError_IncompatibleShutdownScript_meth != NULL);
3317 }
3318 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKAPIError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3319         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
3320         switch(obj->tag) {
3321                 case LDKAPIError_APIMisuseError: {
3322                         LDKStr err_str = obj->api_misuse_error.err;
3323                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
3324                         return (*env)->NewObject(env, LDKAPIError_APIMisuseError_class, LDKAPIError_APIMisuseError_meth, err_conv);
3325                 }
3326                 case LDKAPIError_FeeRateTooHigh: {
3327                         LDKStr err_str = obj->fee_rate_too_high.err;
3328                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
3329                         return (*env)->NewObject(env, LDKAPIError_FeeRateTooHigh_class, LDKAPIError_FeeRateTooHigh_meth, err_conv, obj->fee_rate_too_high.feerate);
3330                 }
3331                 case LDKAPIError_RouteError: {
3332                         LDKStr err_str = obj->route_error.err;
3333                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
3334                         return (*env)->NewObject(env, LDKAPIError_RouteError_class, LDKAPIError_RouteError_meth, err_conv);
3335                 }
3336                 case LDKAPIError_ChannelUnavailable: {
3337                         LDKStr err_str = obj->channel_unavailable.err;
3338                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
3339                         return (*env)->NewObject(env, LDKAPIError_ChannelUnavailable_class, LDKAPIError_ChannelUnavailable_meth, err_conv);
3340                 }
3341                 case LDKAPIError_MonitorUpdateFailed: {
3342                         return (*env)->NewObject(env, LDKAPIError_MonitorUpdateFailed_class, LDKAPIError_MonitorUpdateFailed_meth);
3343                 }
3344                 case LDKAPIError_IncompatibleShutdownScript: {
3345                         LDKShutdownScript script_var = obj->incompatible_shutdown_script.script;
3346                         CHECK((((uint64_t)script_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3347                         CHECK((((uint64_t)&script_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3348                         uint64_t script_ref = (uint64_t)script_var.inner & ~1;
3349                         return (*env)->NewObject(env, LDKAPIError_IncompatibleShutdownScript_class, LDKAPIError_IncompatibleShutdownScript_meth, script_ref);
3350                 }
3351                 default: abort();
3352         }
3353 }
3354 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneAPIErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3355         return ((LDKCResult_NoneAPIErrorZ*)arg)->result_ok;
3356 }
3357 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3358         LDKCResult_NoneAPIErrorZ *val = (LDKCResult_NoneAPIErrorZ*)(arg & ~1);
3359         CHECK(val->result_ok);
3360         return *val->contents.result;
3361 }
3362 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3363         LDKCResult_NoneAPIErrorZ *val = (LDKCResult_NoneAPIErrorZ*)(arg & ~1);
3364         CHECK(!val->result_ok);
3365         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
3366         return err_ref;
3367 }
3368 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1CResult_1NoneAPIErrorZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
3369         LDKCVec_CResult_NoneAPIErrorZZ *ret = MALLOC(sizeof(LDKCVec_CResult_NoneAPIErrorZZ), "LDKCVec_CResult_NoneAPIErrorZZ");
3370         ret->datalen = (*env)->GetArrayLength(env, elems);
3371         if (ret->datalen == 0) {
3372                 ret->data = NULL;
3373         } else {
3374                 ret->data = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ) * ret->datalen, "LDKCVec_CResult_NoneAPIErrorZZ Data");
3375                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3376                 for (size_t i = 0; i < ret->datalen; i++) {
3377                         int64_t arr_elem = java_elems[i];
3378                         void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
3379                         CHECK_ACCESS(arr_elem_ptr);
3380                         LDKCResult_NoneAPIErrorZ arr_elem_conv = *(LDKCResult_NoneAPIErrorZ*)(arr_elem_ptr);
3381                         arr_elem_conv = CResult_NoneAPIErrorZ_clone((LDKCResult_NoneAPIErrorZ*)(((uint64_t)arr_elem) & ~1));
3382                         ret->data[i] = arr_elem_conv;
3383                 }
3384                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3385         }
3386         return (uint64_t)ret;
3387 }
3388 static inline LDKCVec_CResult_NoneAPIErrorZZ CVec_CResult_NoneAPIErrorZZ_clone(const LDKCVec_CResult_NoneAPIErrorZZ *orig) {
3389         LDKCVec_CResult_NoneAPIErrorZZ ret = { .data = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ) * orig->datalen, "LDKCVec_CResult_NoneAPIErrorZZ clone bytes"), .datalen = orig->datalen };
3390         for (size_t i = 0; i < ret.datalen; i++) {
3391                 ret.data[i] = CResult_NoneAPIErrorZ_clone(&orig->data[i]);
3392         }
3393         return ret;
3394 }
3395 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1APIErrorZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
3396         LDKCVec_APIErrorZ *ret = MALLOC(sizeof(LDKCVec_APIErrorZ), "LDKCVec_APIErrorZ");
3397         ret->datalen = (*env)->GetArrayLength(env, elems);
3398         if (ret->datalen == 0) {
3399                 ret->data = NULL;
3400         } else {
3401                 ret->data = MALLOC(sizeof(LDKAPIError) * ret->datalen, "LDKCVec_APIErrorZ Data");
3402                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3403                 for (size_t i = 0; i < ret->datalen; i++) {
3404                         int64_t arr_elem = java_elems[i];
3405                         void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
3406                         CHECK_ACCESS(arr_elem_ptr);
3407                         LDKAPIError arr_elem_conv = *(LDKAPIError*)(arr_elem_ptr);
3408                         arr_elem_conv = APIError_clone((LDKAPIError*)(((uint64_t)arr_elem) & ~1));
3409                         ret->data[i] = arr_elem_conv;
3410                 }
3411                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3412         }
3413         return (uint64_t)ret;
3414 }
3415 static inline LDKCVec_APIErrorZ CVec_APIErrorZ_clone(const LDKCVec_APIErrorZ *orig) {
3416         LDKCVec_APIErrorZ ret = { .data = MALLOC(sizeof(LDKAPIError) * orig->datalen, "LDKCVec_APIErrorZ clone bytes"), .datalen = orig->datalen };
3417         for (size_t i = 0; i < ret.datalen; i++) {
3418                 ret.data[i] = APIError_clone(&orig->data[i]);
3419         }
3420         return ret;
3421 }
3422 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1_1u832APIErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3423         return ((LDKCResult__u832APIErrorZ*)arg)->result_ok;
3424 }
3425 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1_1u832APIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3426         LDKCResult__u832APIErrorZ *val = (LDKCResult__u832APIErrorZ*)(arg & ~1);
3427         CHECK(val->result_ok);
3428         int8_tArray res_arr = (*env)->NewByteArray(env, 32);
3429         (*env)->SetByteArrayRegion(env, res_arr, 0, 32, (*val->contents.result).data);
3430         return res_arr;
3431 }
3432 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1_1u832APIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3433         LDKCResult__u832APIErrorZ *val = (LDKCResult__u832APIErrorZ*)(arg & ~1);
3434         CHECK(!val->result_ok);
3435         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
3436         return err_ref;
3437 }
3438 static jclass LDKPaymentSendFailure_ParameterError_class = NULL;
3439 static jmethodID LDKPaymentSendFailure_ParameterError_meth = NULL;
3440 static jclass LDKPaymentSendFailure_PathParameterError_class = NULL;
3441 static jmethodID LDKPaymentSendFailure_PathParameterError_meth = NULL;
3442 static jclass LDKPaymentSendFailure_AllFailedRetrySafe_class = NULL;
3443 static jmethodID LDKPaymentSendFailure_AllFailedRetrySafe_meth = NULL;
3444 static jclass LDKPaymentSendFailure_PartialFailure_class = NULL;
3445 static jmethodID LDKPaymentSendFailure_PartialFailure_meth = NULL;
3446 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKPaymentSendFailure_init (JNIEnv *env, jclass clz) {
3447         LDKPaymentSendFailure_ParameterError_class =
3448                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentSendFailure$ParameterError;"));
3449         CHECK(LDKPaymentSendFailure_ParameterError_class != NULL);
3450         LDKPaymentSendFailure_ParameterError_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_ParameterError_class, "<init>", "(J)V");
3451         CHECK(LDKPaymentSendFailure_ParameterError_meth != NULL);
3452         LDKPaymentSendFailure_PathParameterError_class =
3453                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentSendFailure$PathParameterError;"));
3454         CHECK(LDKPaymentSendFailure_PathParameterError_class != NULL);
3455         LDKPaymentSendFailure_PathParameterError_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_PathParameterError_class, "<init>", "([J)V");
3456         CHECK(LDKPaymentSendFailure_PathParameterError_meth != NULL);
3457         LDKPaymentSendFailure_AllFailedRetrySafe_class =
3458                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentSendFailure$AllFailedRetrySafe;"));
3459         CHECK(LDKPaymentSendFailure_AllFailedRetrySafe_class != NULL);
3460         LDKPaymentSendFailure_AllFailedRetrySafe_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_AllFailedRetrySafe_class, "<init>", "([J)V");
3461         CHECK(LDKPaymentSendFailure_AllFailedRetrySafe_meth != NULL);
3462         LDKPaymentSendFailure_PartialFailure_class =
3463                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentSendFailure$PartialFailure;"));
3464         CHECK(LDKPaymentSendFailure_PartialFailure_class != NULL);
3465         LDKPaymentSendFailure_PartialFailure_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_PartialFailure_class, "<init>", "([J)V");
3466         CHECK(LDKPaymentSendFailure_PartialFailure_meth != NULL);
3467 }
3468 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPaymentSendFailure_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3469         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
3470         switch(obj->tag) {
3471                 case LDKPaymentSendFailure_ParameterError: {
3472                         uint64_t parameter_error_ref = ((uint64_t)&obj->parameter_error) | 1;
3473                         return (*env)->NewObject(env, LDKPaymentSendFailure_ParameterError_class, LDKPaymentSendFailure_ParameterError_meth, parameter_error_ref);
3474                 }
3475                 case LDKPaymentSendFailure_PathParameterError: {
3476                         LDKCVec_CResult_NoneAPIErrorZZ path_parameter_error_var = obj->path_parameter_error;
3477                         int64_tArray path_parameter_error_arr = (*env)->NewLongArray(env, path_parameter_error_var.datalen);
3478                         int64_t *path_parameter_error_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_parameter_error_arr, NULL);
3479                         for (size_t w = 0; w < path_parameter_error_var.datalen; w++) {
3480                                 LDKCResult_NoneAPIErrorZ* path_parameter_error_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
3481                                 *path_parameter_error_conv_22_conv = path_parameter_error_var.data[w];
3482                                 *path_parameter_error_conv_22_conv = CResult_NoneAPIErrorZ_clone(path_parameter_error_conv_22_conv);
3483                                 path_parameter_error_arr_ptr[w] = (uint64_t)path_parameter_error_conv_22_conv;
3484                         }
3485                         (*env)->ReleasePrimitiveArrayCritical(env, path_parameter_error_arr, path_parameter_error_arr_ptr, 0);
3486                         return (*env)->NewObject(env, LDKPaymentSendFailure_PathParameterError_class, LDKPaymentSendFailure_PathParameterError_meth, path_parameter_error_arr);
3487                 }
3488                 case LDKPaymentSendFailure_AllFailedRetrySafe: {
3489                         LDKCVec_APIErrorZ all_failed_retry_safe_var = obj->all_failed_retry_safe;
3490                         int64_tArray all_failed_retry_safe_arr = (*env)->NewLongArray(env, all_failed_retry_safe_var.datalen);
3491                         int64_t *all_failed_retry_safe_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, all_failed_retry_safe_arr, NULL);
3492                         for (size_t k = 0; k < all_failed_retry_safe_var.datalen; k++) {
3493                                 uint64_t all_failed_retry_safe_conv_10_ref = ((uint64_t)&all_failed_retry_safe_var.data[k]) | 1;
3494                                 all_failed_retry_safe_arr_ptr[k] = all_failed_retry_safe_conv_10_ref;
3495                         }
3496                         (*env)->ReleasePrimitiveArrayCritical(env, all_failed_retry_safe_arr, all_failed_retry_safe_arr_ptr, 0);
3497                         return (*env)->NewObject(env, LDKPaymentSendFailure_AllFailedRetrySafe_class, LDKPaymentSendFailure_AllFailedRetrySafe_meth, all_failed_retry_safe_arr);
3498                 }
3499                 case LDKPaymentSendFailure_PartialFailure: {
3500                         LDKCVec_CResult_NoneAPIErrorZZ partial_failure_var = obj->partial_failure;
3501                         int64_tArray partial_failure_arr = (*env)->NewLongArray(env, partial_failure_var.datalen);
3502                         int64_t *partial_failure_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, partial_failure_arr, NULL);
3503                         for (size_t w = 0; w < partial_failure_var.datalen; w++) {
3504                                 LDKCResult_NoneAPIErrorZ* partial_failure_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
3505                                 *partial_failure_conv_22_conv = partial_failure_var.data[w];
3506                                 *partial_failure_conv_22_conv = CResult_NoneAPIErrorZ_clone(partial_failure_conv_22_conv);
3507                                 partial_failure_arr_ptr[w] = (uint64_t)partial_failure_conv_22_conv;
3508                         }
3509                         (*env)->ReleasePrimitiveArrayCritical(env, partial_failure_arr, partial_failure_arr_ptr, 0);
3510                         return (*env)->NewObject(env, LDKPaymentSendFailure_PartialFailure_class, LDKPaymentSendFailure_PartialFailure_meth, partial_failure_arr);
3511                 }
3512                 default: abort();
3513         }
3514 }
3515 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentIdPaymentSendFailureZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3516         return ((LDKCResult_PaymentIdPaymentSendFailureZ*)arg)->result_ok;
3517 }
3518 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentIdPaymentSendFailureZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3519         LDKCResult_PaymentIdPaymentSendFailureZ *val = (LDKCResult_PaymentIdPaymentSendFailureZ*)(arg & ~1);
3520         CHECK(val->result_ok);
3521         LDKPaymentId res_var = (*val->contents.result);
3522         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3523         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3524         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
3525         return res_ref;
3526 }
3527 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentIdPaymentSendFailureZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3528         LDKCResult_PaymentIdPaymentSendFailureZ *val = (LDKCResult_PaymentIdPaymentSendFailureZ*)(arg & ~1);
3529         CHECK(!val->result_ok);
3530         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
3531         return err_ref;
3532 }
3533 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePaymentSendFailureZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3534         return ((LDKCResult_NonePaymentSendFailureZ*)arg)->result_ok;
3535 }
3536 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePaymentSendFailureZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3537         LDKCResult_NonePaymentSendFailureZ *val = (LDKCResult_NonePaymentSendFailureZ*)(arg & ~1);
3538         CHECK(val->result_ok);
3539         return *val->contents.result;
3540 }
3541 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePaymentSendFailureZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3542         LDKCResult_NonePaymentSendFailureZ *val = (LDKCResult_NonePaymentSendFailureZ*)(arg & ~1);
3543         CHECK(!val->result_ok);
3544         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
3545         return err_ref;
3546 }
3547 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentIdZ_get_a(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR tuple){
3548         return ThirtyTwoBytes_clone(&tuple->a);
3549 }
3550 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1get_1a(JNIEnv *env, jclass clz, int64_t tuple) {
3551         LDKC2Tuple_PaymentHashPaymentIdZ* tuple_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(tuple & ~1);
3552         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
3553         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_PaymentHashPaymentIdZ_get_a(tuple_conv).data);
3554         return ret_arr;
3555 }
3556
3557 static inline struct LDKPaymentId C2Tuple_PaymentHashPaymentIdZ_get_b(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR tuple){
3558         return PaymentId_clone(&tuple->b);
3559 }
3560 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1get_1b(JNIEnv *env, jclass clz, int64_t tuple) {
3561         LDKC2Tuple_PaymentHashPaymentIdZ* tuple_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(tuple & ~1);
3562         LDKPaymentId ret_var = C2Tuple_PaymentHashPaymentIdZ_get_b(tuple_conv);
3563         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3564         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3565         uint64_t ret_ref = (uint64_t)ret_var.inner;
3566         if (ret_var.is_owned) {
3567                 ret_ref |= 1;
3568         }
3569         return ret_ref;
3570 }
3571
3572 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3573         return ((LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)arg)->result_ok;
3574 }
3575 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3576         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *val = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(arg & ~1);
3577         CHECK(val->result_ok);
3578         LDKC2Tuple_PaymentHashPaymentIdZ* res_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
3579         *res_conv = (*val->contents.result);
3580         *res_conv = C2Tuple_PaymentHashPaymentIdZ_clone(res_conv);
3581         return ((uint64_t)res_conv);
3582 }
3583 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3584         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *val = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(arg & ~1);
3585         CHECK(!val->result_ok);
3586         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
3587         return err_ref;
3588 }
3589 static jclass LDKNetAddress_IPv4_class = NULL;
3590 static jmethodID LDKNetAddress_IPv4_meth = NULL;
3591 static jclass LDKNetAddress_IPv6_class = NULL;
3592 static jmethodID LDKNetAddress_IPv6_meth = NULL;
3593 static jclass LDKNetAddress_OnionV2_class = NULL;
3594 static jmethodID LDKNetAddress_OnionV2_meth = NULL;
3595 static jclass LDKNetAddress_OnionV3_class = NULL;
3596 static jmethodID LDKNetAddress_OnionV3_meth = NULL;
3597 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKNetAddress_init (JNIEnv *env, jclass clz) {
3598         LDKNetAddress_IPv4_class =
3599                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$IPv4;"));
3600         CHECK(LDKNetAddress_IPv4_class != NULL);
3601         LDKNetAddress_IPv4_meth = (*env)->GetMethodID(env, LDKNetAddress_IPv4_class, "<init>", "([BS)V");
3602         CHECK(LDKNetAddress_IPv4_meth != NULL);
3603         LDKNetAddress_IPv6_class =
3604                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$IPv6;"));
3605         CHECK(LDKNetAddress_IPv6_class != NULL);
3606         LDKNetAddress_IPv6_meth = (*env)->GetMethodID(env, LDKNetAddress_IPv6_class, "<init>", "([BS)V");
3607         CHECK(LDKNetAddress_IPv6_meth != NULL);
3608         LDKNetAddress_OnionV2_class =
3609                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$OnionV2;"));
3610         CHECK(LDKNetAddress_OnionV2_class != NULL);
3611         LDKNetAddress_OnionV2_meth = (*env)->GetMethodID(env, LDKNetAddress_OnionV2_class, "<init>", "([BS)V");
3612         CHECK(LDKNetAddress_OnionV2_meth != NULL);
3613         LDKNetAddress_OnionV3_class =
3614                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$OnionV3;"));
3615         CHECK(LDKNetAddress_OnionV3_class != NULL);
3616         LDKNetAddress_OnionV3_meth = (*env)->GetMethodID(env, LDKNetAddress_OnionV3_class, "<init>", "([BSBS)V");
3617         CHECK(LDKNetAddress_OnionV3_meth != NULL);
3618 }
3619 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKNetAddress_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3620         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3621         switch(obj->tag) {
3622                 case LDKNetAddress_IPv4: {
3623                         int8_tArray addr_arr = (*env)->NewByteArray(env, 4);
3624                         (*env)->SetByteArrayRegion(env, addr_arr, 0, 4, obj->i_pv4.addr.data);
3625                         return (*env)->NewObject(env, LDKNetAddress_IPv4_class, LDKNetAddress_IPv4_meth, addr_arr, obj->i_pv4.port);
3626                 }
3627                 case LDKNetAddress_IPv6: {
3628                         int8_tArray addr_arr = (*env)->NewByteArray(env, 16);
3629                         (*env)->SetByteArrayRegion(env, addr_arr, 0, 16, obj->i_pv6.addr.data);
3630                         return (*env)->NewObject(env, LDKNetAddress_IPv6_class, LDKNetAddress_IPv6_meth, addr_arr, obj->i_pv6.port);
3631                 }
3632                 case LDKNetAddress_OnionV2: {
3633                         int8_tArray addr_arr = (*env)->NewByteArray(env, 10);
3634                         (*env)->SetByteArrayRegion(env, addr_arr, 0, 10, obj->onion_v2.addr.data);
3635                         return (*env)->NewObject(env, LDKNetAddress_OnionV2_class, LDKNetAddress_OnionV2_meth, addr_arr, obj->onion_v2.port);
3636                 }
3637                 case LDKNetAddress_OnionV3: {
3638                         int8_tArray ed25519_pubkey_arr = (*env)->NewByteArray(env, 32);
3639                         (*env)->SetByteArrayRegion(env, ed25519_pubkey_arr, 0, 32, obj->onion_v3.ed25519_pubkey.data);
3640                         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);
3641                 }
3642                 default: abort();
3643         }
3644 }
3645 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1NetAddressZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
3646         LDKCVec_NetAddressZ *ret = MALLOC(sizeof(LDKCVec_NetAddressZ), "LDKCVec_NetAddressZ");
3647         ret->datalen = (*env)->GetArrayLength(env, elems);
3648         if (ret->datalen == 0) {
3649                 ret->data = NULL;
3650         } else {
3651                 ret->data = MALLOC(sizeof(LDKNetAddress) * ret->datalen, "LDKCVec_NetAddressZ Data");
3652                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3653                 for (size_t i = 0; i < ret->datalen; i++) {
3654                         int64_t arr_elem = java_elems[i];
3655                         void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
3656                         CHECK_ACCESS(arr_elem_ptr);
3657                         LDKNetAddress arr_elem_conv = *(LDKNetAddress*)(arr_elem_ptr);
3658                         arr_elem_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)arr_elem) & ~1));
3659                         ret->data[i] = arr_elem_conv;
3660                 }
3661                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3662         }
3663         return (uint64_t)ret;
3664 }
3665 static inline LDKCVec_NetAddressZ CVec_NetAddressZ_clone(const LDKCVec_NetAddressZ *orig) {
3666         LDKCVec_NetAddressZ ret = { .data = MALLOC(sizeof(LDKNetAddress) * orig->datalen, "LDKCVec_NetAddressZ clone bytes"), .datalen = orig->datalen };
3667         for (size_t i = 0; i < ret.datalen; i++) {
3668                 ret.data[i] = NetAddress_clone(&orig->data[i]);
3669         }
3670         return ret;
3671 }
3672 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentSecretZ_get_a(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR tuple){
3673         return ThirtyTwoBytes_clone(&tuple->a);
3674 }
3675 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1get_1a(JNIEnv *env, jclass clz, int64_t tuple) {
3676         LDKC2Tuple_PaymentHashPaymentSecretZ* tuple_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(tuple & ~1);
3677         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
3678         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_PaymentHashPaymentSecretZ_get_a(tuple_conv).data);
3679         return ret_arr;
3680 }
3681
3682 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentSecretZ_get_b(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR tuple){
3683         return ThirtyTwoBytes_clone(&tuple->b);
3684 }
3685 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1get_1b(JNIEnv *env, jclass clz, int64_t tuple) {
3686         LDKC2Tuple_PaymentHashPaymentSecretZ* tuple_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(tuple & ~1);
3687         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
3688         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_PaymentHashPaymentSecretZ_get_b(tuple_conv).data);
3689         return ret_arr;
3690 }
3691
3692 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentSecretAPIErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3693         return ((LDKCResult_PaymentSecretAPIErrorZ*)arg)->result_ok;
3694 }
3695 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentSecretAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3696         LDKCResult_PaymentSecretAPIErrorZ *val = (LDKCResult_PaymentSecretAPIErrorZ*)(arg & ~1);
3697         CHECK(val->result_ok);
3698         int8_tArray res_arr = (*env)->NewByteArray(env, 32);
3699         (*env)->SetByteArrayRegion(env, res_arr, 0, 32, (*val->contents.result).data);
3700         return res_arr;
3701 }
3702 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentSecretAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3703         LDKCResult_PaymentSecretAPIErrorZ *val = (LDKCResult_PaymentSecretAPIErrorZ*)(arg & ~1);
3704         CHECK(!val->result_ok);
3705         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
3706         return err_ref;
3707 }
3708 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1ChannelMonitorZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
3709         LDKCVec_ChannelMonitorZ *ret = MALLOC(sizeof(LDKCVec_ChannelMonitorZ), "LDKCVec_ChannelMonitorZ");
3710         ret->datalen = (*env)->GetArrayLength(env, elems);
3711         if (ret->datalen == 0) {
3712                 ret->data = NULL;
3713         } else {
3714                 ret->data = MALLOC(sizeof(LDKChannelMonitor) * ret->datalen, "LDKCVec_ChannelMonitorZ Data");
3715                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3716                 for (size_t i = 0; i < ret->datalen; i++) {
3717                         int64_t arr_elem = java_elems[i];
3718                         LDKChannelMonitor arr_elem_conv;
3719                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3720                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3721                         arr_elem_conv = ChannelMonitor_clone(&arr_elem_conv);
3722                         ret->data[i] = arr_elem_conv;
3723                 }
3724                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3725         }
3726         return (uint64_t)ret;
3727 }
3728 static inline LDKCVec_ChannelMonitorZ CVec_ChannelMonitorZ_clone(const LDKCVec_ChannelMonitorZ *orig) {
3729         LDKCVec_ChannelMonitorZ ret = { .data = MALLOC(sizeof(LDKChannelMonitor) * orig->datalen, "LDKCVec_ChannelMonitorZ clone bytes"), .datalen = orig->datalen };
3730         for (size_t i = 0; i < ret.datalen; i++) {
3731                 ret.data[i] = ChannelMonitor_clone(&orig->data[i]);
3732         }
3733         return ret;
3734 }
3735 typedef struct LDKWatch_JCalls {
3736         atomic_size_t refcnt;
3737         JavaVM *vm;
3738         jweak o;
3739         jmethodID watch_channel_meth;
3740         jmethodID update_channel_meth;
3741         jmethodID release_pending_monitor_events_meth;
3742 } LDKWatch_JCalls;
3743 static void LDKWatch_JCalls_free(void* this_arg) {
3744         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
3745         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3746                 JNIEnv *env;
3747                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3748                 if (get_jenv_res == JNI_EDETACHED) {
3749                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3750                 } else {
3751                         DO_ASSERT(get_jenv_res == JNI_OK);
3752                 }
3753                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
3754                 if (get_jenv_res == JNI_EDETACHED) {
3755                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3756                 }
3757                 FREE(j_calls);
3758         }
3759 }
3760 LDKCResult_NoneChannelMonitorUpdateErrZ watch_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitor monitor) {
3761         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
3762         JNIEnv *env;
3763         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3764         if (get_jenv_res == JNI_EDETACHED) {
3765                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3766         } else {
3767                 DO_ASSERT(get_jenv_res == JNI_OK);
3768         }
3769         LDKOutPoint funding_txo_var = funding_txo;
3770         CHECK((((uint64_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3771         CHECK((((uint64_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3772         uint64_t funding_txo_ref = (uint64_t)funding_txo_var.inner;
3773         if (funding_txo_var.is_owned) {
3774                 funding_txo_ref |= 1;
3775         }
3776         LDKChannelMonitor monitor_var = monitor;
3777         CHECK((((uint64_t)monitor_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3778         CHECK((((uint64_t)&monitor_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3779         uint64_t monitor_ref = (uint64_t)monitor_var.inner;
3780         if (monitor_var.is_owned) {
3781                 monitor_ref |= 1;
3782         }
3783         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3784         CHECK(obj != NULL);
3785         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->watch_channel_meth, funding_txo_ref, monitor_ref);
3786         if ((*env)->ExceptionCheck(env)) {
3787                 (*env)->ExceptionDescribe(env);
3788                 (*env)->FatalError(env, "A call to watch_channel in LDKWatch from rust threw an exception.");
3789         }
3790         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
3791         CHECK_ACCESS(ret_ptr);
3792         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
3793         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
3794         if (get_jenv_res == JNI_EDETACHED) {
3795                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3796         }
3797         return ret_conv;
3798 }
3799 LDKCResult_NoneChannelMonitorUpdateErrZ update_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitorUpdate update) {
3800         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
3801         JNIEnv *env;
3802         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3803         if (get_jenv_res == JNI_EDETACHED) {
3804                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3805         } else {
3806                 DO_ASSERT(get_jenv_res == JNI_OK);
3807         }
3808         LDKOutPoint funding_txo_var = funding_txo;
3809         CHECK((((uint64_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3810         CHECK((((uint64_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3811         uint64_t funding_txo_ref = (uint64_t)funding_txo_var.inner;
3812         if (funding_txo_var.is_owned) {
3813                 funding_txo_ref |= 1;
3814         }
3815         LDKChannelMonitorUpdate update_var = update;
3816         CHECK((((uint64_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3817         CHECK((((uint64_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3818         uint64_t update_ref = (uint64_t)update_var.inner;
3819         if (update_var.is_owned) {
3820                 update_ref |= 1;
3821         }
3822         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3823         CHECK(obj != NULL);
3824         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->update_channel_meth, funding_txo_ref, update_ref);
3825         if ((*env)->ExceptionCheck(env)) {
3826                 (*env)->ExceptionDescribe(env);
3827                 (*env)->FatalError(env, "A call to update_channel in LDKWatch from rust threw an exception.");
3828         }
3829         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
3830         CHECK_ACCESS(ret_ptr);
3831         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
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                 void* ret_conv_14_ptr = (void*)(((uint64_t)ret_conv_14) & ~1);
3864                 CHECK_ACCESS(ret_conv_14_ptr);
3865                 LDKMonitorEvent ret_conv_14_conv = *(LDKMonitorEvent*)(ret_conv_14_ptr);
3866                 ret_conv_14_conv = MonitorEvent_clone((LDKMonitorEvent*)(((uint64_t)ret_conv_14) & ~1));
3867                 ret_constr.data[o] = ret_conv_14_conv;
3868         }
3869         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
3870         if (get_jenv_res == JNI_EDETACHED) {
3871                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3872         }
3873         return ret_constr;
3874 }
3875 static void LDKWatch_JCalls_cloned(LDKWatch* new_obj) {
3876         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) new_obj->this_arg;
3877         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3878 }
3879 static inline LDKWatch LDKWatch_init (JNIEnv *env, jclass clz, jobject o) {
3880         jclass c = (*env)->GetObjectClass(env, o);
3881         CHECK(c != NULL);
3882         LDKWatch_JCalls *calls = MALLOC(sizeof(LDKWatch_JCalls), "LDKWatch_JCalls");
3883         atomic_init(&calls->refcnt, 1);
3884         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
3885         calls->o = (*env)->NewWeakGlobalRef(env, o);
3886         calls->watch_channel_meth = (*env)->GetMethodID(env, c, "watch_channel", "(JJ)J");
3887         CHECK(calls->watch_channel_meth != NULL);
3888         calls->update_channel_meth = (*env)->GetMethodID(env, c, "update_channel", "(JJ)J");
3889         CHECK(calls->update_channel_meth != NULL);
3890         calls->release_pending_monitor_events_meth = (*env)->GetMethodID(env, c, "release_pending_monitor_events", "()[J");
3891         CHECK(calls->release_pending_monitor_events_meth != NULL);
3892
3893         LDKWatch ret = {
3894                 .this_arg = (void*) calls,
3895                 .watch_channel = watch_channel_LDKWatch_jcall,
3896                 .update_channel = update_channel_LDKWatch_jcall,
3897                 .release_pending_monitor_events = release_pending_monitor_events_LDKWatch_jcall,
3898                 .free = LDKWatch_JCalls_free,
3899         };
3900         return ret;
3901 }
3902 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKWatch_1new(JNIEnv *env, jclass clz, jobject o) {
3903         LDKWatch *res_ptr = MALLOC(sizeof(LDKWatch), "LDKWatch");
3904         *res_ptr = LDKWatch_init(env, clz, o);
3905         return (uint64_t)res_ptr;
3906 }
3907 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) {
3908         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
3909         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3910         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
3911         LDKOutPoint funding_txo_conv;
3912         funding_txo_conv.inner = (void*)(funding_txo & (~1));
3913         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
3914         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
3915         LDKChannelMonitor monitor_conv;
3916         monitor_conv.inner = (void*)(monitor & (~1));
3917         monitor_conv.is_owned = (monitor & 1) || (monitor == 0);
3918         monitor_conv = ChannelMonitor_clone(&monitor_conv);
3919         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
3920         *ret_conv = (this_arg_conv->watch_channel)(this_arg_conv->this_arg, funding_txo_conv, monitor_conv);
3921         return (uint64_t)ret_conv;
3922 }
3923
3924 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) {
3925         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
3926         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3927         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
3928         LDKOutPoint funding_txo_conv;
3929         funding_txo_conv.inner = (void*)(funding_txo & (~1));
3930         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
3931         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
3932         LDKChannelMonitorUpdate update_conv;
3933         update_conv.inner = (void*)(update & (~1));
3934         update_conv.is_owned = (update & 1) || (update == 0);
3935         update_conv = ChannelMonitorUpdate_clone(&update_conv);
3936         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
3937         *ret_conv = (this_arg_conv->update_channel)(this_arg_conv->this_arg, funding_txo_conv, update_conv);
3938         return (uint64_t)ret_conv;
3939 }
3940
3941 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Watch_1release_1pending_1monitor_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
3942         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
3943         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3944         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
3945         LDKCVec_MonitorEventZ ret_var = (this_arg_conv->release_pending_monitor_events)(this_arg_conv->this_arg);
3946         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
3947         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
3948         for (size_t o = 0; o < ret_var.datalen; o++) {
3949                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
3950                 *ret_conv_14_copy = ret_var.data[o];
3951                 uint64_t ret_conv_14_ref = (uint64_t)ret_conv_14_copy;
3952                 ret_arr_ptr[o] = ret_conv_14_ref;
3953         }
3954         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
3955         FREE(ret_var.data);
3956         return ret_arr;
3957 }
3958
3959 typedef struct LDKBroadcasterInterface_JCalls {
3960         atomic_size_t refcnt;
3961         JavaVM *vm;
3962         jweak o;
3963         jmethodID broadcast_transaction_meth;
3964 } LDKBroadcasterInterface_JCalls;
3965 static void LDKBroadcasterInterface_JCalls_free(void* this_arg) {
3966         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
3967         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3968                 JNIEnv *env;
3969                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3970                 if (get_jenv_res == JNI_EDETACHED) {
3971                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3972                 } else {
3973                         DO_ASSERT(get_jenv_res == JNI_OK);
3974                 }
3975                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
3976                 if (get_jenv_res == JNI_EDETACHED) {
3977                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3978                 }
3979                 FREE(j_calls);
3980         }
3981 }
3982 void broadcast_transaction_LDKBroadcasterInterface_jcall(const void* this_arg, LDKTransaction tx) {
3983         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
3984         JNIEnv *env;
3985         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3986         if (get_jenv_res == JNI_EDETACHED) {
3987                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3988         } else {
3989                 DO_ASSERT(get_jenv_res == JNI_OK);
3990         }
3991         LDKTransaction tx_var = tx;
3992         int8_tArray tx_arr = (*env)->NewByteArray(env, tx_var.datalen);
3993         (*env)->SetByteArrayRegion(env, tx_arr, 0, tx_var.datalen, tx_var.data);
3994         Transaction_free(tx_var);
3995         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3996         CHECK(obj != NULL);
3997         (*env)->CallVoidMethod(env, obj, j_calls->broadcast_transaction_meth, tx_arr);
3998         if ((*env)->ExceptionCheck(env)) {
3999                 (*env)->ExceptionDescribe(env);
4000                 (*env)->FatalError(env, "A call to broadcast_transaction in LDKBroadcasterInterface from rust threw an exception.");
4001         }
4002         if (get_jenv_res == JNI_EDETACHED) {
4003                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4004         }
4005 }
4006 static void LDKBroadcasterInterface_JCalls_cloned(LDKBroadcasterInterface* new_obj) {
4007         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) new_obj->this_arg;
4008         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4009 }
4010 static inline LDKBroadcasterInterface LDKBroadcasterInterface_init (JNIEnv *env, jclass clz, jobject o) {
4011         jclass c = (*env)->GetObjectClass(env, o);
4012         CHECK(c != NULL);
4013         LDKBroadcasterInterface_JCalls *calls = MALLOC(sizeof(LDKBroadcasterInterface_JCalls), "LDKBroadcasterInterface_JCalls");
4014         atomic_init(&calls->refcnt, 1);
4015         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
4016         calls->o = (*env)->NewWeakGlobalRef(env, o);
4017         calls->broadcast_transaction_meth = (*env)->GetMethodID(env, c, "broadcast_transaction", "([B)V");
4018         CHECK(calls->broadcast_transaction_meth != NULL);
4019
4020         LDKBroadcasterInterface ret = {
4021                 .this_arg = (void*) calls,
4022                 .broadcast_transaction = broadcast_transaction_LDKBroadcasterInterface_jcall,
4023                 .free = LDKBroadcasterInterface_JCalls_free,
4024         };
4025         return ret;
4026 }
4027 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKBroadcasterInterface_1new(JNIEnv *env, jclass clz, jobject o) {
4028         LDKBroadcasterInterface *res_ptr = MALLOC(sizeof(LDKBroadcasterInterface), "LDKBroadcasterInterface");
4029         *res_ptr = LDKBroadcasterInterface_init(env, clz, o);
4030         return (uint64_t)res_ptr;
4031 }
4032 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BroadcasterInterface_1broadcast_1transaction(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray tx) {
4033         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
4034         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4035         LDKBroadcasterInterface* this_arg_conv = (LDKBroadcasterInterface*)this_arg_ptr;
4036         LDKTransaction tx_ref;
4037         tx_ref.datalen = (*env)->GetArrayLength(env, tx);
4038         tx_ref.data = MALLOC(tx_ref.datalen, "LDKTransaction Bytes");
4039         (*env)->GetByteArrayRegion(env, tx, 0, tx_ref.datalen, tx_ref.data);
4040         tx_ref.data_is_owned = true;
4041         (this_arg_conv->broadcast_transaction)(this_arg_conv->this_arg, tx_ref);
4042 }
4043
4044 typedef struct LDKKeysInterface_JCalls {
4045         atomic_size_t refcnt;
4046         JavaVM *vm;
4047         jweak o;
4048         jmethodID get_node_secret_meth;
4049         jmethodID get_destination_script_meth;
4050         jmethodID get_shutdown_scriptpubkey_meth;
4051         jmethodID get_channel_signer_meth;
4052         jmethodID get_secure_random_bytes_meth;
4053         jmethodID read_chan_signer_meth;
4054         jmethodID sign_invoice_meth;
4055 } LDKKeysInterface_JCalls;
4056 static void LDKKeysInterface_JCalls_free(void* this_arg) {
4057         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4058         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4059                 JNIEnv *env;
4060                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4061                 if (get_jenv_res == JNI_EDETACHED) {
4062                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4063                 } else {
4064                         DO_ASSERT(get_jenv_res == JNI_OK);
4065                 }
4066                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
4067                 if (get_jenv_res == JNI_EDETACHED) {
4068                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4069                 }
4070                 FREE(j_calls);
4071         }
4072 }
4073 LDKSecretKey get_node_secret_LDKKeysInterface_jcall(const void* this_arg) {
4074         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4075         JNIEnv *env;
4076         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4077         if (get_jenv_res == JNI_EDETACHED) {
4078                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4079         } else {
4080                 DO_ASSERT(get_jenv_res == JNI_OK);
4081         }
4082         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4083         CHECK(obj != NULL);
4084         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_node_secret_meth);
4085         if ((*env)->ExceptionCheck(env)) {
4086                 (*env)->ExceptionDescribe(env);
4087                 (*env)->FatalError(env, "A call to get_node_secret in LDKKeysInterface from rust threw an exception.");
4088         }
4089         LDKSecretKey ret_ref;
4090         CHECK((*env)->GetArrayLength(env, ret) == 32);
4091         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.bytes);
4092         if (get_jenv_res == JNI_EDETACHED) {
4093                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4094         }
4095         return ret_ref;
4096 }
4097 LDKCVec_u8Z get_destination_script_LDKKeysInterface_jcall(const void* this_arg) {
4098         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4099         JNIEnv *env;
4100         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4101         if (get_jenv_res == JNI_EDETACHED) {
4102                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4103         } else {
4104                 DO_ASSERT(get_jenv_res == JNI_OK);
4105         }
4106         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4107         CHECK(obj != NULL);
4108         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_destination_script_meth);
4109         if ((*env)->ExceptionCheck(env)) {
4110                 (*env)->ExceptionDescribe(env);
4111                 (*env)->FatalError(env, "A call to get_destination_script in LDKKeysInterface from rust threw an exception.");
4112         }
4113         LDKCVec_u8Z ret_ref;
4114         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
4115         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
4116         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
4117         if (get_jenv_res == JNI_EDETACHED) {
4118                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4119         }
4120         return ret_ref;
4121 }
4122 LDKShutdownScript get_shutdown_scriptpubkey_LDKKeysInterface_jcall(const void* this_arg) {
4123         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4124         JNIEnv *env;
4125         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4126         if (get_jenv_res == JNI_EDETACHED) {
4127                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4128         } else {
4129                 DO_ASSERT(get_jenv_res == JNI_OK);
4130         }
4131         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4132         CHECK(obj != NULL);
4133         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_shutdown_scriptpubkey_meth);
4134         if ((*env)->ExceptionCheck(env)) {
4135                 (*env)->ExceptionDescribe(env);
4136                 (*env)->FatalError(env, "A call to get_shutdown_scriptpubkey in LDKKeysInterface from rust threw an exception.");
4137         }
4138         LDKShutdownScript ret_conv;
4139         ret_conv.inner = (void*)(ret & (~1));
4140         ret_conv.is_owned = (ret & 1) || (ret == 0);
4141         ret_conv = ShutdownScript_clone(&ret_conv);
4142         if (get_jenv_res == JNI_EDETACHED) {
4143                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4144         }
4145         return ret_conv;
4146 }
4147 LDKSign get_channel_signer_LDKKeysInterface_jcall(const void* this_arg, bool inbound, uint64_t channel_value_satoshis) {
4148         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4149         JNIEnv *env;
4150         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4151         if (get_jenv_res == JNI_EDETACHED) {
4152                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4153         } else {
4154                 DO_ASSERT(get_jenv_res == JNI_OK);
4155         }
4156         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4157         CHECK(obj != NULL);
4158         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_channel_signer_meth, inbound, channel_value_satoshis);
4159         if ((*env)->ExceptionCheck(env)) {
4160                 (*env)->ExceptionDescribe(env);
4161                 (*env)->FatalError(env, "A call to get_channel_signer in LDKKeysInterface from rust threw an exception.");
4162         }
4163         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
4164         CHECK_ACCESS(ret_ptr);
4165         LDKSign ret_conv = *(LDKSign*)(ret_ptr);
4166         ret_conv = Sign_clone(&ret_conv);
4167         if (get_jenv_res == JNI_EDETACHED) {
4168                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4169         }
4170         return ret_conv;
4171 }
4172 LDKThirtyTwoBytes get_secure_random_bytes_LDKKeysInterface_jcall(const void* this_arg) {
4173         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4174         JNIEnv *env;
4175         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4176         if (get_jenv_res == JNI_EDETACHED) {
4177                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4178         } else {
4179                 DO_ASSERT(get_jenv_res == JNI_OK);
4180         }
4181         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4182         CHECK(obj != NULL);
4183         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_secure_random_bytes_meth);
4184         if ((*env)->ExceptionCheck(env)) {
4185                 (*env)->ExceptionDescribe(env);
4186                 (*env)->FatalError(env, "A call to get_secure_random_bytes in LDKKeysInterface from rust threw an exception.");
4187         }
4188         LDKThirtyTwoBytes ret_ref;
4189         CHECK((*env)->GetArrayLength(env, ret) == 32);
4190         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
4191         if (get_jenv_res == JNI_EDETACHED) {
4192                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4193         }
4194         return ret_ref;
4195 }
4196 LDKCResult_SignDecodeErrorZ read_chan_signer_LDKKeysInterface_jcall(const void* this_arg, LDKu8slice reader) {
4197         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4198         JNIEnv *env;
4199         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4200         if (get_jenv_res == JNI_EDETACHED) {
4201                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4202         } else {
4203                 DO_ASSERT(get_jenv_res == JNI_OK);
4204         }
4205         LDKu8slice reader_var = reader;
4206         int8_tArray reader_arr = (*env)->NewByteArray(env, reader_var.datalen);
4207         (*env)->SetByteArrayRegion(env, reader_arr, 0, reader_var.datalen, reader_var.data);
4208         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4209         CHECK(obj != NULL);
4210         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->read_chan_signer_meth, reader_arr);
4211         if ((*env)->ExceptionCheck(env)) {
4212                 (*env)->ExceptionDescribe(env);
4213                 (*env)->FatalError(env, "A call to read_chan_signer in LDKKeysInterface from rust threw an exception.");
4214         }
4215         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
4216         CHECK_ACCESS(ret_ptr);
4217         LDKCResult_SignDecodeErrorZ ret_conv = *(LDKCResult_SignDecodeErrorZ*)(ret_ptr);
4218         ret_conv = CResult_SignDecodeErrorZ_clone((LDKCResult_SignDecodeErrorZ*)(((uint64_t)ret) & ~1));
4219         if (get_jenv_res == JNI_EDETACHED) {
4220                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4221         }
4222         return ret_conv;
4223 }
4224 LDKCResult_RecoverableSignatureNoneZ sign_invoice_LDKKeysInterface_jcall(const void* this_arg, LDKCVec_u8Z invoice_preimage) {
4225         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4226         JNIEnv *env;
4227         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4228         if (get_jenv_res == JNI_EDETACHED) {
4229                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4230         } else {
4231                 DO_ASSERT(get_jenv_res == JNI_OK);
4232         }
4233         LDKCVec_u8Z invoice_preimage_var = invoice_preimage;
4234         int8_tArray invoice_preimage_arr = (*env)->NewByteArray(env, invoice_preimage_var.datalen);
4235         (*env)->SetByteArrayRegion(env, invoice_preimage_arr, 0, invoice_preimage_var.datalen, invoice_preimage_var.data);
4236         CVec_u8Z_free(invoice_preimage_var);
4237         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4238         CHECK(obj != NULL);
4239         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_invoice_meth, invoice_preimage_arr);
4240         if ((*env)->ExceptionCheck(env)) {
4241                 (*env)->ExceptionDescribe(env);
4242                 (*env)->FatalError(env, "A call to sign_invoice in LDKKeysInterface from rust threw an exception.");
4243         }
4244         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
4245         CHECK_ACCESS(ret_ptr);
4246         LDKCResult_RecoverableSignatureNoneZ ret_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(ret_ptr);
4247         ret_conv = CResult_RecoverableSignatureNoneZ_clone((LDKCResult_RecoverableSignatureNoneZ*)(((uint64_t)ret) & ~1));
4248         if (get_jenv_res == JNI_EDETACHED) {
4249                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4250         }
4251         return ret_conv;
4252 }
4253 static void LDKKeysInterface_JCalls_cloned(LDKKeysInterface* new_obj) {
4254         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) new_obj->this_arg;
4255         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4256 }
4257 static inline LDKKeysInterface LDKKeysInterface_init (JNIEnv *env, jclass clz, jobject o) {
4258         jclass c = (*env)->GetObjectClass(env, o);
4259         CHECK(c != NULL);
4260         LDKKeysInterface_JCalls *calls = MALLOC(sizeof(LDKKeysInterface_JCalls), "LDKKeysInterface_JCalls");
4261         atomic_init(&calls->refcnt, 1);
4262         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
4263         calls->o = (*env)->NewWeakGlobalRef(env, o);
4264         calls->get_node_secret_meth = (*env)->GetMethodID(env, c, "get_node_secret", "()[B");
4265         CHECK(calls->get_node_secret_meth != NULL);
4266         calls->get_destination_script_meth = (*env)->GetMethodID(env, c, "get_destination_script", "()[B");
4267         CHECK(calls->get_destination_script_meth != NULL);
4268         calls->get_shutdown_scriptpubkey_meth = (*env)->GetMethodID(env, c, "get_shutdown_scriptpubkey", "()J");
4269         CHECK(calls->get_shutdown_scriptpubkey_meth != NULL);
4270         calls->get_channel_signer_meth = (*env)->GetMethodID(env, c, "get_channel_signer", "(ZJ)J");
4271         CHECK(calls->get_channel_signer_meth != NULL);
4272         calls->get_secure_random_bytes_meth = (*env)->GetMethodID(env, c, "get_secure_random_bytes", "()[B");
4273         CHECK(calls->get_secure_random_bytes_meth != NULL);
4274         calls->read_chan_signer_meth = (*env)->GetMethodID(env, c, "read_chan_signer", "([B)J");
4275         CHECK(calls->read_chan_signer_meth != NULL);
4276         calls->sign_invoice_meth = (*env)->GetMethodID(env, c, "sign_invoice", "([B)J");
4277         CHECK(calls->sign_invoice_meth != NULL);
4278
4279         LDKKeysInterface ret = {
4280                 .this_arg = (void*) calls,
4281                 .get_node_secret = get_node_secret_LDKKeysInterface_jcall,
4282                 .get_destination_script = get_destination_script_LDKKeysInterface_jcall,
4283                 .get_shutdown_scriptpubkey = get_shutdown_scriptpubkey_LDKKeysInterface_jcall,
4284                 .get_channel_signer = get_channel_signer_LDKKeysInterface_jcall,
4285                 .get_secure_random_bytes = get_secure_random_bytes_LDKKeysInterface_jcall,
4286                 .read_chan_signer = read_chan_signer_LDKKeysInterface_jcall,
4287                 .sign_invoice = sign_invoice_LDKKeysInterface_jcall,
4288                 .free = LDKKeysInterface_JCalls_free,
4289         };
4290         return ret;
4291 }
4292 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKKeysInterface_1new(JNIEnv *env, jclass clz, jobject o) {
4293         LDKKeysInterface *res_ptr = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
4294         *res_ptr = LDKKeysInterface_init(env, clz, o);
4295         return (uint64_t)res_ptr;
4296 }
4297 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1node_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
4298         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
4299         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4300         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
4301         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
4302         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->get_node_secret)(this_arg_conv->this_arg).bytes);
4303         return ret_arr;
4304 }
4305
4306 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1destination_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
4307         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
4308         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4309         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
4310         LDKCVec_u8Z ret_var = (this_arg_conv->get_destination_script)(this_arg_conv->this_arg);
4311         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
4312         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
4313         CVec_u8Z_free(ret_var);
4314         return ret_arr;
4315 }
4316
4317 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1shutdown_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_arg) {
4318         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
4319         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4320         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
4321         LDKShutdownScript ret_var = (this_arg_conv->get_shutdown_scriptpubkey)(this_arg_conv->this_arg);
4322         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4323         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4324         uint64_t ret_ref = (uint64_t)ret_var.inner;
4325         if (ret_var.is_owned) {
4326                 ret_ref |= 1;
4327         }
4328         return ret_ref;
4329 }
4330
4331 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) {
4332         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
4333         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4334         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
4335         LDKSign* ret_ret =MALLOC(sizeof(LDKSign), "LDKSign");
4336         *ret_ret = (this_arg_conv->get_channel_signer)(this_arg_conv->this_arg, inbound, channel_value_satoshis);
4337         return (uint64_t)ret_ret;
4338 }
4339
4340 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1secure_1random_1bytes(JNIEnv *env, jclass clz, int64_t this_arg) {
4341         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
4342         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4343         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
4344         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
4345         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->get_secure_random_bytes)(this_arg_conv->this_arg).data);
4346         return ret_arr;
4347 }
4348
4349 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1read_1chan_1signer(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray reader) {
4350         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
4351         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4352         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
4353         LDKu8slice reader_ref;
4354         reader_ref.datalen = (*env)->GetArrayLength(env, reader);
4355         reader_ref.data = (*env)->GetByteArrayElements (env, reader, NULL);
4356         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
4357         *ret_conv = (this_arg_conv->read_chan_signer)(this_arg_conv->this_arg, reader_ref);
4358         (*env)->ReleaseByteArrayElements(env, reader, (int8_t*)reader_ref.data, 0);
4359         return (uint64_t)ret_conv;
4360 }
4361
4362 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1sign_1invoice(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray invoice_preimage) {
4363         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
4364         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4365         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
4366         LDKCVec_u8Z invoice_preimage_ref;
4367         invoice_preimage_ref.datalen = (*env)->GetArrayLength(env, invoice_preimage);
4368         invoice_preimage_ref.data = MALLOC(invoice_preimage_ref.datalen, "LDKCVec_u8Z Bytes");
4369         (*env)->GetByteArrayRegion(env, invoice_preimage, 0, invoice_preimage_ref.datalen, invoice_preimage_ref.data);
4370         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
4371         *ret_conv = (this_arg_conv->sign_invoice)(this_arg_conv->this_arg, invoice_preimage_ref);
4372         return (uint64_t)ret_conv;
4373 }
4374
4375 typedef struct LDKFeeEstimator_JCalls {
4376         atomic_size_t refcnt;
4377         JavaVM *vm;
4378         jweak o;
4379         jmethodID get_est_sat_per_1000_weight_meth;
4380 } LDKFeeEstimator_JCalls;
4381 static void LDKFeeEstimator_JCalls_free(void* this_arg) {
4382         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
4383         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4384                 JNIEnv *env;
4385                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4386                 if (get_jenv_res == JNI_EDETACHED) {
4387                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4388                 } else {
4389                         DO_ASSERT(get_jenv_res == JNI_OK);
4390                 }
4391                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
4392                 if (get_jenv_res == JNI_EDETACHED) {
4393                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4394                 }
4395                 FREE(j_calls);
4396         }
4397 }
4398 uint32_t get_est_sat_per_1000_weight_LDKFeeEstimator_jcall(const void* this_arg, LDKConfirmationTarget confirmation_target) {
4399         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
4400         JNIEnv *env;
4401         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4402         if (get_jenv_res == JNI_EDETACHED) {
4403                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4404         } else {
4405                 DO_ASSERT(get_jenv_res == JNI_OK);
4406         }
4407         jclass confirmation_target_conv = LDKConfirmationTarget_to_java(env, confirmation_target);
4408         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4409         CHECK(obj != NULL);
4410         int32_t ret = (*env)->CallIntMethod(env, obj, j_calls->get_est_sat_per_1000_weight_meth, confirmation_target_conv);
4411         if ((*env)->ExceptionCheck(env)) {
4412                 (*env)->ExceptionDescribe(env);
4413                 (*env)->FatalError(env, "A call to get_est_sat_per_1000_weight in LDKFeeEstimator from rust threw an exception.");
4414         }
4415         if (get_jenv_res == JNI_EDETACHED) {
4416                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4417         }
4418         return ret;
4419 }
4420 static void LDKFeeEstimator_JCalls_cloned(LDKFeeEstimator* new_obj) {
4421         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) new_obj->this_arg;
4422         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4423 }
4424 static inline LDKFeeEstimator LDKFeeEstimator_init (JNIEnv *env, jclass clz, jobject o) {
4425         jclass c = (*env)->GetObjectClass(env, o);
4426         CHECK(c != NULL);
4427         LDKFeeEstimator_JCalls *calls = MALLOC(sizeof(LDKFeeEstimator_JCalls), "LDKFeeEstimator_JCalls");
4428         atomic_init(&calls->refcnt, 1);
4429         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
4430         calls->o = (*env)->NewWeakGlobalRef(env, o);
4431         calls->get_est_sat_per_1000_weight_meth = (*env)->GetMethodID(env, c, "get_est_sat_per_1000_weight", "(Lorg/ldk/enums/ConfirmationTarget;)I");
4432         CHECK(calls->get_est_sat_per_1000_weight_meth != NULL);
4433
4434         LDKFeeEstimator ret = {
4435                 .this_arg = (void*) calls,
4436                 .get_est_sat_per_1000_weight = get_est_sat_per_1000_weight_LDKFeeEstimator_jcall,
4437                 .free = LDKFeeEstimator_JCalls_free,
4438         };
4439         return ret;
4440 }
4441 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKFeeEstimator_1new(JNIEnv *env, jclass clz, jobject o) {
4442         LDKFeeEstimator *res_ptr = MALLOC(sizeof(LDKFeeEstimator), "LDKFeeEstimator");
4443         *res_ptr = LDKFeeEstimator_init(env, clz, o);
4444         return (uint64_t)res_ptr;
4445 }
4446 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) {
4447         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
4448         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4449         LDKFeeEstimator* this_arg_conv = (LDKFeeEstimator*)this_arg_ptr;
4450         LDKConfirmationTarget confirmation_target_conv = LDKConfirmationTarget_from_java(env, confirmation_target);
4451         int32_t ret_val = (this_arg_conv->get_est_sat_per_1000_weight)(this_arg_conv->this_arg, confirmation_target_conv);
4452         return ret_val;
4453 }
4454
4455 typedef struct LDKLogger_JCalls {
4456         atomic_size_t refcnt;
4457         JavaVM *vm;
4458         jweak o;
4459         jmethodID log_meth;
4460 } LDKLogger_JCalls;
4461 static void LDKLogger_JCalls_free(void* this_arg) {
4462         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
4463         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4464                 JNIEnv *env;
4465                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4466                 if (get_jenv_res == JNI_EDETACHED) {
4467                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4468                 } else {
4469                         DO_ASSERT(get_jenv_res == JNI_OK);
4470                 }
4471                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
4472                 if (get_jenv_res == JNI_EDETACHED) {
4473                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4474                 }
4475                 FREE(j_calls);
4476         }
4477 }
4478 void log_LDKLogger_jcall(const void* this_arg, const char* record) {
4479         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
4480         JNIEnv *env;
4481         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4482         if (get_jenv_res == JNI_EDETACHED) {
4483                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4484         } else {
4485                 DO_ASSERT(get_jenv_res == JNI_OK);
4486         }
4487         const char* record_str = record;
4488         jstring record_conv = str_ref_to_java(env, record_str, strlen(record_str));
4489         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4490         CHECK(obj != NULL);
4491         (*env)->CallVoidMethod(env, obj, j_calls->log_meth, record_conv);
4492         if ((*env)->ExceptionCheck(env)) {
4493                 (*env)->ExceptionDescribe(env);
4494                 (*env)->FatalError(env, "A call to log in LDKLogger from rust threw an exception.");
4495         }
4496         if (get_jenv_res == JNI_EDETACHED) {
4497                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4498         }
4499 }
4500 static void LDKLogger_JCalls_cloned(LDKLogger* new_obj) {
4501         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) new_obj->this_arg;
4502         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4503 }
4504 static inline LDKLogger LDKLogger_init (JNIEnv *env, jclass clz, jobject o) {
4505         jclass c = (*env)->GetObjectClass(env, o);
4506         CHECK(c != NULL);
4507         LDKLogger_JCalls *calls = MALLOC(sizeof(LDKLogger_JCalls), "LDKLogger_JCalls");
4508         atomic_init(&calls->refcnt, 1);
4509         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
4510         calls->o = (*env)->NewWeakGlobalRef(env, o);
4511         calls->log_meth = (*env)->GetMethodID(env, c, "log", "(Ljava/lang/String;)V");
4512         CHECK(calls->log_meth != NULL);
4513
4514         LDKLogger ret = {
4515                 .this_arg = (void*) calls,
4516                 .log = log_LDKLogger_jcall,
4517                 .free = LDKLogger_JCalls_free,
4518         };
4519         return ret;
4520 }
4521 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKLogger_1new(JNIEnv *env, jclass clz, jobject o) {
4522         LDKLogger *res_ptr = MALLOC(sizeof(LDKLogger), "LDKLogger");
4523         *res_ptr = LDKLogger_init(env, clz, o);
4524         return (uint64_t)res_ptr;
4525 }
4526 static inline struct LDKThirtyTwoBytes C2Tuple_BlockHashChannelManagerZ_get_a(LDKC2Tuple_BlockHashChannelManagerZ *NONNULL_PTR tuple){
4527         return ThirtyTwoBytes_clone(&tuple->a);
4528 }
4529 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1get_1a(JNIEnv *env, jclass clz, int64_t tuple) {
4530         LDKC2Tuple_BlockHashChannelManagerZ* tuple_conv = (LDKC2Tuple_BlockHashChannelManagerZ*)(tuple & ~1);
4531         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
4532         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_BlockHashChannelManagerZ_get_a(tuple_conv).data);
4533         return ret_arr;
4534 }
4535
4536 static inline struct LDKChannelManager *C2Tuple_BlockHashChannelManagerZ_get_b(LDKC2Tuple_BlockHashChannelManagerZ *NONNULL_PTR tuple){
4537         return &tuple->b;
4538 }
4539 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1get_1b(JNIEnv *env, jclass clz, int64_t tuple) {
4540         LDKC2Tuple_BlockHashChannelManagerZ* tuple_conv = (LDKC2Tuple_BlockHashChannelManagerZ*)(tuple & ~1);
4541         LDKChannelManager ret_var = *C2Tuple_BlockHashChannelManagerZ_get_b(tuple_conv);
4542         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4543         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4544         uint64_t ret_ref = (uint64_t)ret_var.inner & ~1;
4545         return ret_ref;
4546 }
4547
4548 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4549         return ((LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)arg)->result_ok;
4550 }
4551 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4552         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(arg & ~1);
4553         CHECK(val->result_ok);
4554         LDKC2Tuple_BlockHashChannelManagerZ* res_conv = &(*val->contents.result);
4555         // Warning: we really need to clone here, but no clone is available for LDKC2Tuple_BlockHashChannelManagerZ
4556         return ((uint64_t)res_conv) | 1;
4557 }
4558 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4559         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(arg & ~1);
4560         CHECK(!val->result_ok);
4561         LDKDecodeError err_var = (*val->contents.err);
4562         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4563         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4564         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4565         return err_ref;
4566 }
4567 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelConfigDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4568         return ((LDKCResult_ChannelConfigDecodeErrorZ*)arg)->result_ok;
4569 }
4570 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelConfigDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4571         LDKCResult_ChannelConfigDecodeErrorZ *val = (LDKCResult_ChannelConfigDecodeErrorZ*)(arg & ~1);
4572         CHECK(val->result_ok);
4573         LDKChannelConfig res_var = (*val->contents.result);
4574         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4575         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4576         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4577         return res_ref;
4578 }
4579 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelConfigDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4580         LDKCResult_ChannelConfigDecodeErrorZ *val = (LDKCResult_ChannelConfigDecodeErrorZ*)(arg & ~1);
4581         CHECK(!val->result_ok);
4582         LDKDecodeError err_var = (*val->contents.err);
4583         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4584         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4585         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4586         return err_ref;
4587 }
4588 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OutPointDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4589         return ((LDKCResult_OutPointDecodeErrorZ*)arg)->result_ok;
4590 }
4591 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OutPointDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4592         LDKCResult_OutPointDecodeErrorZ *val = (LDKCResult_OutPointDecodeErrorZ*)(arg & ~1);
4593         CHECK(val->result_ok);
4594         LDKOutPoint res_var = (*val->contents.result);
4595         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4596         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4597         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4598         return res_ref;
4599 }
4600 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OutPointDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4601         LDKCResult_OutPointDecodeErrorZ *val = (LDKCResult_OutPointDecodeErrorZ*)(arg & ~1);
4602         CHECK(!val->result_ok);
4603         LDKDecodeError err_var = (*val->contents.err);
4604         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4605         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4606         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4607         return err_ref;
4608 }
4609 typedef struct LDKType_JCalls {
4610         atomic_size_t refcnt;
4611         JavaVM *vm;
4612         jweak o;
4613         jmethodID type_id_meth;
4614         jmethodID debug_str_meth;
4615         jmethodID write_meth;
4616 } LDKType_JCalls;
4617 static void LDKType_JCalls_free(void* this_arg) {
4618         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
4619         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4620                 JNIEnv *env;
4621                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4622                 if (get_jenv_res == JNI_EDETACHED) {
4623                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4624                 } else {
4625                         DO_ASSERT(get_jenv_res == JNI_OK);
4626                 }
4627                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
4628                 if (get_jenv_res == JNI_EDETACHED) {
4629                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4630                 }
4631                 FREE(j_calls);
4632         }
4633 }
4634 uint16_t type_id_LDKType_jcall(const void* this_arg) {
4635         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
4636         JNIEnv *env;
4637         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4638         if (get_jenv_res == JNI_EDETACHED) {
4639                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4640         } else {
4641                 DO_ASSERT(get_jenv_res == JNI_OK);
4642         }
4643         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4644         CHECK(obj != NULL);
4645         int16_t ret = (*env)->CallShortMethod(env, obj, j_calls->type_id_meth);
4646         if ((*env)->ExceptionCheck(env)) {
4647                 (*env)->ExceptionDescribe(env);
4648                 (*env)->FatalError(env, "A call to type_id in LDKType from rust threw an exception.");
4649         }
4650         if (get_jenv_res == JNI_EDETACHED) {
4651                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4652         }
4653         return ret;
4654 }
4655 LDKStr debug_str_LDKType_jcall(const void* this_arg) {
4656         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
4657         JNIEnv *env;
4658         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4659         if (get_jenv_res == JNI_EDETACHED) {
4660                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4661         } else {
4662                 DO_ASSERT(get_jenv_res == JNI_OK);
4663         }
4664         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4665         CHECK(obj != NULL);
4666         jstring ret = (*env)->CallObjectMethod(env, obj, j_calls->debug_str_meth);
4667         if ((*env)->ExceptionCheck(env)) {
4668                 (*env)->ExceptionDescribe(env);
4669                 (*env)->FatalError(env, "A call to debug_str in LDKType from rust threw an exception.");
4670         }
4671         LDKStr ret_conv = java_to_owned_str(env, ret);
4672         if (get_jenv_res == JNI_EDETACHED) {
4673                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4674         }
4675         return ret_conv;
4676 }
4677 LDKCVec_u8Z write_LDKType_jcall(const void* this_arg) {
4678         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
4679         JNIEnv *env;
4680         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4681         if (get_jenv_res == JNI_EDETACHED) {
4682                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4683         } else {
4684                 DO_ASSERT(get_jenv_res == JNI_OK);
4685         }
4686         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4687         CHECK(obj != NULL);
4688         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->write_meth);
4689         if ((*env)->ExceptionCheck(env)) {
4690                 (*env)->ExceptionDescribe(env);
4691                 (*env)->FatalError(env, "A call to write in LDKType from rust threw an exception.");
4692         }
4693         LDKCVec_u8Z ret_ref;
4694         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
4695         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
4696         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
4697         if (get_jenv_res == JNI_EDETACHED) {
4698                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4699         }
4700         return ret_ref;
4701 }
4702 static void LDKType_JCalls_cloned(LDKType* new_obj) {
4703         LDKType_JCalls *j_calls = (LDKType_JCalls*) new_obj->this_arg;
4704         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4705 }
4706 static inline LDKType LDKType_init (JNIEnv *env, jclass clz, jobject o) {
4707         jclass c = (*env)->GetObjectClass(env, o);
4708         CHECK(c != NULL);
4709         LDKType_JCalls *calls = MALLOC(sizeof(LDKType_JCalls), "LDKType_JCalls");
4710         atomic_init(&calls->refcnt, 1);
4711         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
4712         calls->o = (*env)->NewWeakGlobalRef(env, o);
4713         calls->type_id_meth = (*env)->GetMethodID(env, c, "type_id", "()S");
4714         CHECK(calls->type_id_meth != NULL);
4715         calls->debug_str_meth = (*env)->GetMethodID(env, c, "debug_str", "()Ljava/lang/String;");
4716         CHECK(calls->debug_str_meth != NULL);
4717         calls->write_meth = (*env)->GetMethodID(env, c, "write", "()[B");
4718         CHECK(calls->write_meth != NULL);
4719
4720         LDKType ret = {
4721                 .this_arg = (void*) calls,
4722                 .type_id = type_id_LDKType_jcall,
4723                 .debug_str = debug_str_LDKType_jcall,
4724                 .write = write_LDKType_jcall,
4725                 .cloned = LDKType_JCalls_cloned,
4726                 .free = LDKType_JCalls_free,
4727         };
4728         return ret;
4729 }
4730 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKType_1new(JNIEnv *env, jclass clz, jobject o) {
4731         LDKType *res_ptr = MALLOC(sizeof(LDKType), "LDKType");
4732         *res_ptr = LDKType_init(env, clz, o);
4733         return (uint64_t)res_ptr;
4734 }
4735 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Type_1type_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
4736         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
4737         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4738         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
4739         int16_t ret_val = (this_arg_conv->type_id)(this_arg_conv->this_arg);
4740         return ret_val;
4741 }
4742
4743 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Type_1debug_1str(JNIEnv *env, jclass clz, int64_t this_arg) {
4744         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
4745         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4746         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
4747         LDKStr ret_str = (this_arg_conv->debug_str)(this_arg_conv->this_arg);
4748         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
4749         Str_free(ret_str);
4750         return ret_conv;
4751 }
4752
4753 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Type_1write(JNIEnv *env, jclass clz, int64_t this_arg) {
4754         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
4755         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4756         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
4757         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
4758         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
4759         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
4760         CVec_u8Z_free(ret_var);
4761         return ret_arr;
4762 }
4763
4764 static jclass LDKCOption_TypeZ_Some_class = NULL;
4765 static jmethodID LDKCOption_TypeZ_Some_meth = NULL;
4766 static jclass LDKCOption_TypeZ_None_class = NULL;
4767 static jmethodID LDKCOption_TypeZ_None_meth = NULL;
4768 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1TypeZ_init (JNIEnv *env, jclass clz) {
4769         LDKCOption_TypeZ_Some_class =
4770                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_TypeZ$Some;"));
4771         CHECK(LDKCOption_TypeZ_Some_class != NULL);
4772         LDKCOption_TypeZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_TypeZ_Some_class, "<init>", "(J)V");
4773         CHECK(LDKCOption_TypeZ_Some_meth != NULL);
4774         LDKCOption_TypeZ_None_class =
4775                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_TypeZ$None;"));
4776         CHECK(LDKCOption_TypeZ_None_class != NULL);
4777         LDKCOption_TypeZ_None_meth = (*env)->GetMethodID(env, LDKCOption_TypeZ_None_class, "<init>", "()V");
4778         CHECK(LDKCOption_TypeZ_None_meth != NULL);
4779 }
4780 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1TypeZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
4781         LDKCOption_TypeZ *obj = (LDKCOption_TypeZ*)(ptr & ~1);
4782         switch(obj->tag) {
4783                 case LDKCOption_TypeZ_Some: {
4784                         LDKType* some_ret =MALLOC(sizeof(LDKType), "LDKType");
4785                         *some_ret = Type_clone(&obj->some);
4786                         return (*env)->NewObject(env, LDKCOption_TypeZ_Some_class, LDKCOption_TypeZ_Some_meth, (uint64_t)some_ret);
4787                 }
4788                 case LDKCOption_TypeZ_None: {
4789                         return (*env)->NewObject(env, LDKCOption_TypeZ_None_class, LDKCOption_TypeZ_None_meth);
4790                 }
4791                 default: abort();
4792         }
4793 }
4794 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1COption_1TypeZDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4795         return ((LDKCResult_COption_TypeZDecodeErrorZ*)arg)->result_ok;
4796 }
4797 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1COption_1TypeZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4798         LDKCResult_COption_TypeZDecodeErrorZ *val = (LDKCResult_COption_TypeZDecodeErrorZ*)(arg & ~1);
4799         CHECK(val->result_ok);
4800         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
4801         return res_ref;
4802 }
4803 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1COption_1TypeZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4804         LDKCResult_COption_TypeZDecodeErrorZ *val = (LDKCResult_COption_TypeZDecodeErrorZ*)(arg & ~1);
4805         CHECK(!val->result_ok);
4806         LDKDecodeError err_var = (*val->contents.err);
4807         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4808         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4809         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4810         return err_ref;
4811 }
4812 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SiPrefixNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4813         return ((LDKCResult_SiPrefixNoneZ*)arg)->result_ok;
4814 }
4815 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SiPrefixNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4816         LDKCResult_SiPrefixNoneZ *val = (LDKCResult_SiPrefixNoneZ*)(arg & ~1);
4817         CHECK(val->result_ok);
4818         jclass res_conv = LDKSiPrefix_to_java(env, (*val->contents.result));
4819         return res_conv;
4820 }
4821 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SiPrefixNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4822         LDKCResult_SiPrefixNoneZ *val = (LDKCResult_SiPrefixNoneZ*)(arg & ~1);
4823         CHECK(!val->result_ok);
4824         return *val->contents.err;
4825 }
4826 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4827         return ((LDKCResult_InvoiceNoneZ*)arg)->result_ok;
4828 }
4829 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4830         LDKCResult_InvoiceNoneZ *val = (LDKCResult_InvoiceNoneZ*)(arg & ~1);
4831         CHECK(val->result_ok);
4832         LDKInvoice res_var = (*val->contents.result);
4833         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4834         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4835         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4836         return res_ref;
4837 }
4838 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4839         LDKCResult_InvoiceNoneZ *val = (LDKCResult_InvoiceNoneZ*)(arg & ~1);
4840         CHECK(!val->result_ok);
4841         return *val->contents.err;
4842 }
4843 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignedRawInvoiceNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4844         return ((LDKCResult_SignedRawInvoiceNoneZ*)arg)->result_ok;
4845 }
4846 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignedRawInvoiceNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4847         LDKCResult_SignedRawInvoiceNoneZ *val = (LDKCResult_SignedRawInvoiceNoneZ*)(arg & ~1);
4848         CHECK(val->result_ok);
4849         LDKSignedRawInvoice res_var = (*val->contents.result);
4850         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4851         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4852         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4853         return res_ref;
4854 }
4855 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignedRawInvoiceNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4856         LDKCResult_SignedRawInvoiceNoneZ *val = (LDKCResult_SignedRawInvoiceNoneZ*)(arg & ~1);
4857         CHECK(!val->result_ok);
4858         return *val->contents.err;
4859 }
4860 static inline struct LDKRawInvoice C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR tuple){
4861         return RawInvoice_clone(&tuple->a);
4862 }
4863 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1a(JNIEnv *env, jclass clz, int64_t tuple) {
4864         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* tuple_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(tuple & ~1);
4865         LDKRawInvoice ret_var = C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(tuple_conv);
4866         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4867         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4868         uint64_t ret_ref = (uint64_t)ret_var.inner;
4869         if (ret_var.is_owned) {
4870                 ret_ref |= 1;
4871         }
4872         return ret_ref;
4873 }
4874
4875 static inline struct LDKThirtyTwoBytes C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR tuple){
4876         return ThirtyTwoBytes_clone(&tuple->b);
4877 }
4878 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1b(JNIEnv *env, jclass clz, int64_t tuple) {
4879         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* tuple_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(tuple & ~1);
4880         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
4881         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(tuple_conv).data);
4882         return ret_arr;
4883 }
4884
4885 static inline struct LDKInvoiceSignature C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR tuple){
4886         return InvoiceSignature_clone(&tuple->c);
4887 }
4888 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1c(JNIEnv *env, jclass clz, int64_t tuple) {
4889         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* tuple_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(tuple & ~1);
4890         LDKInvoiceSignature ret_var = C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(tuple_conv);
4891         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4892         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4893         uint64_t ret_ref = (uint64_t)ret_var.inner;
4894         if (ret_var.is_owned) {
4895                 ret_ref |= 1;
4896         }
4897         return ret_ref;
4898 }
4899
4900 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PayeePubKeyErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4901         return ((LDKCResult_PayeePubKeyErrorZ*)arg)->result_ok;
4902 }
4903 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PayeePubKeyErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4904         LDKCResult_PayeePubKeyErrorZ *val = (LDKCResult_PayeePubKeyErrorZ*)(arg & ~1);
4905         CHECK(val->result_ok);
4906         LDKPayeePubKey res_var = (*val->contents.result);
4907         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4908         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4909         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4910         return res_ref;
4911 }
4912 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PayeePubKeyErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4913         LDKCResult_PayeePubKeyErrorZ *val = (LDKCResult_PayeePubKeyErrorZ*)(arg & ~1);
4914         CHECK(!val->result_ok);
4915         jclass err_conv = LDKSecp256k1Error_to_java(env, (*val->contents.err));
4916         return err_conv;
4917 }
4918 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1PrivateRouteZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
4919         LDKCVec_PrivateRouteZ *ret = MALLOC(sizeof(LDKCVec_PrivateRouteZ), "LDKCVec_PrivateRouteZ");
4920         ret->datalen = (*env)->GetArrayLength(env, elems);
4921         if (ret->datalen == 0) {
4922                 ret->data = NULL;
4923         } else {
4924                 ret->data = MALLOC(sizeof(LDKPrivateRoute) * ret->datalen, "LDKCVec_PrivateRouteZ Data");
4925                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
4926                 for (size_t i = 0; i < ret->datalen; i++) {
4927                         int64_t arr_elem = java_elems[i];
4928                         LDKPrivateRoute arr_elem_conv;
4929                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
4930                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
4931                         arr_elem_conv = PrivateRoute_clone(&arr_elem_conv);
4932                         ret->data[i] = arr_elem_conv;
4933                 }
4934                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
4935         }
4936         return (uint64_t)ret;
4937 }
4938 static inline LDKCVec_PrivateRouteZ CVec_PrivateRouteZ_clone(const LDKCVec_PrivateRouteZ *orig) {
4939         LDKCVec_PrivateRouteZ ret = { .data = MALLOC(sizeof(LDKPrivateRoute) * orig->datalen, "LDKCVec_PrivateRouteZ clone bytes"), .datalen = orig->datalen };
4940         for (size_t i = 0; i < ret.datalen; i++) {
4941                 ret.data[i] = PrivateRoute_clone(&orig->data[i]);
4942         }
4943         return ret;
4944 }
4945 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PositiveTimestampCreationErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4946         return ((LDKCResult_PositiveTimestampCreationErrorZ*)arg)->result_ok;
4947 }
4948 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PositiveTimestampCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4949         LDKCResult_PositiveTimestampCreationErrorZ *val = (LDKCResult_PositiveTimestampCreationErrorZ*)(arg & ~1);
4950         CHECK(val->result_ok);
4951         LDKPositiveTimestamp res_var = (*val->contents.result);
4952         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4953         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4954         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4955         return res_ref;
4956 }
4957 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PositiveTimestampCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4958         LDKCResult_PositiveTimestampCreationErrorZ *val = (LDKCResult_PositiveTimestampCreationErrorZ*)(arg & ~1);
4959         CHECK(!val->result_ok);
4960         jclass err_conv = LDKCreationError_to_java(env, (*val->contents.err));
4961         return err_conv;
4962 }
4963 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneSemanticErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4964         return ((LDKCResult_NoneSemanticErrorZ*)arg)->result_ok;
4965 }
4966 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneSemanticErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4967         LDKCResult_NoneSemanticErrorZ *val = (LDKCResult_NoneSemanticErrorZ*)(arg & ~1);
4968         CHECK(val->result_ok);
4969         return *val->contents.result;
4970 }
4971 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneSemanticErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4972         LDKCResult_NoneSemanticErrorZ *val = (LDKCResult_NoneSemanticErrorZ*)(arg & ~1);
4973         CHECK(!val->result_ok);
4974         jclass err_conv = LDKSemanticError_to_java(env, (*val->contents.err));
4975         return err_conv;
4976 }
4977 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceSemanticErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4978         return ((LDKCResult_InvoiceSemanticErrorZ*)arg)->result_ok;
4979 }
4980 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceSemanticErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4981         LDKCResult_InvoiceSemanticErrorZ *val = (LDKCResult_InvoiceSemanticErrorZ*)(arg & ~1);
4982         CHECK(val->result_ok);
4983         LDKInvoice res_var = (*val->contents.result);
4984         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4985         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4986         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4987         return res_ref;
4988 }
4989 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceSemanticErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4990         LDKCResult_InvoiceSemanticErrorZ *val = (LDKCResult_InvoiceSemanticErrorZ*)(arg & ~1);
4991         CHECK(!val->result_ok);
4992         jclass err_conv = LDKSemanticError_to_java(env, (*val->contents.err));
4993         return err_conv;
4994 }
4995 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DescriptionCreationErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4996         return ((LDKCResult_DescriptionCreationErrorZ*)arg)->result_ok;
4997 }
4998 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DescriptionCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4999         LDKCResult_DescriptionCreationErrorZ *val = (LDKCResult_DescriptionCreationErrorZ*)(arg & ~1);
5000         CHECK(val->result_ok);
5001         LDKDescription res_var = (*val->contents.result);
5002         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5003         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5004         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5005         return res_ref;
5006 }
5007 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DescriptionCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5008         LDKCResult_DescriptionCreationErrorZ *val = (LDKCResult_DescriptionCreationErrorZ*)(arg & ~1);
5009         CHECK(!val->result_ok);
5010         jclass err_conv = LDKCreationError_to_java(env, (*val->contents.err));
5011         return err_conv;
5012 }
5013 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ExpiryTimeCreationErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5014         return ((LDKCResult_ExpiryTimeCreationErrorZ*)arg)->result_ok;
5015 }
5016 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ExpiryTimeCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5017         LDKCResult_ExpiryTimeCreationErrorZ *val = (LDKCResult_ExpiryTimeCreationErrorZ*)(arg & ~1);
5018         CHECK(val->result_ok);
5019         LDKExpiryTime res_var = (*val->contents.result);
5020         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5021         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5022         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5023         return res_ref;
5024 }
5025 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ExpiryTimeCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5026         LDKCResult_ExpiryTimeCreationErrorZ *val = (LDKCResult_ExpiryTimeCreationErrorZ*)(arg & ~1);
5027         CHECK(!val->result_ok);
5028         jclass err_conv = LDKCreationError_to_java(env, (*val->contents.err));
5029         return err_conv;
5030 }
5031 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PrivateRouteCreationErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5032         return ((LDKCResult_PrivateRouteCreationErrorZ*)arg)->result_ok;
5033 }
5034 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PrivateRouteCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5035         LDKCResult_PrivateRouteCreationErrorZ *val = (LDKCResult_PrivateRouteCreationErrorZ*)(arg & ~1);
5036         CHECK(val->result_ok);
5037         LDKPrivateRoute res_var = (*val->contents.result);
5038         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5039         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5040         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5041         return res_ref;
5042 }
5043 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PrivateRouteCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5044         LDKCResult_PrivateRouteCreationErrorZ *val = (LDKCResult_PrivateRouteCreationErrorZ*)(arg & ~1);
5045         CHECK(!val->result_ok);
5046         jclass err_conv = LDKCreationError_to_java(env, (*val->contents.err));
5047         return err_conv;
5048 }
5049 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1StringErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5050         return ((LDKCResult_StringErrorZ*)arg)->result_ok;
5051 }
5052 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_LDKCResult_1StringErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5053         LDKCResult_StringErrorZ *val = (LDKCResult_StringErrorZ*)(arg & ~1);
5054         CHECK(val->result_ok);
5055         LDKStr res_str = (*val->contents.result);
5056         jstring res_conv = str_ref_to_java(env, res_str.chars, res_str.len);
5057         return res_conv;
5058 }
5059 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1StringErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5060         LDKCResult_StringErrorZ *val = (LDKCResult_StringErrorZ*)(arg & ~1);
5061         CHECK(!val->result_ok);
5062         jclass err_conv = LDKSecp256k1Error_to_java(env, (*val->contents.err));
5063         return err_conv;
5064 }
5065 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelMonitorUpdateDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5066         return ((LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)arg)->result_ok;
5067 }
5068 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelMonitorUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5069         LDKCResult_ChannelMonitorUpdateDecodeErrorZ *val = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(arg & ~1);
5070         CHECK(val->result_ok);
5071         LDKChannelMonitorUpdate res_var = (*val->contents.result);
5072         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5073         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5074         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5075         return res_ref;
5076 }
5077 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelMonitorUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5078         LDKCResult_ChannelMonitorUpdateDecodeErrorZ *val = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(arg & ~1);
5079         CHECK(!val->result_ok);
5080         LDKDecodeError err_var = (*val->contents.err);
5081         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5082         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5083         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5084         return err_ref;
5085 }
5086 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCUpdateDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5087         return ((LDKCResult_HTLCUpdateDecodeErrorZ*)arg)->result_ok;
5088 }
5089 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5090         LDKCResult_HTLCUpdateDecodeErrorZ *val = (LDKCResult_HTLCUpdateDecodeErrorZ*)(arg & ~1);
5091         CHECK(val->result_ok);
5092         LDKHTLCUpdate res_var = (*val->contents.result);
5093         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5094         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5095         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5096         return res_ref;
5097 }
5098 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5099         LDKCResult_HTLCUpdateDecodeErrorZ *val = (LDKCResult_HTLCUpdateDecodeErrorZ*)(arg & ~1);
5100         CHECK(!val->result_ok);
5101         LDKDecodeError err_var = (*val->contents.err);
5102         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5103         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5104         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5105         return err_ref;
5106 }
5107 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneMonitorUpdateErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5108         return ((LDKCResult_NoneMonitorUpdateErrorZ*)arg)->result_ok;
5109 }
5110 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneMonitorUpdateErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5111         LDKCResult_NoneMonitorUpdateErrorZ *val = (LDKCResult_NoneMonitorUpdateErrorZ*)(arg & ~1);
5112         CHECK(val->result_ok);
5113         return *val->contents.result;
5114 }
5115 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneMonitorUpdateErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5116         LDKCResult_NoneMonitorUpdateErrorZ *val = (LDKCResult_NoneMonitorUpdateErrorZ*)(arg & ~1);
5117         CHECK(!val->result_ok);
5118         LDKMonitorUpdateError err_var = (*val->contents.err);
5119         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5120         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5121         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5122         return err_ref;
5123 }
5124 static inline struct LDKOutPoint C2Tuple_OutPointScriptZ_get_a(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR tuple){
5125         return OutPoint_clone(&tuple->a);
5126 }
5127 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1get_1a(JNIEnv *env, jclass clz, int64_t tuple) {
5128         LDKC2Tuple_OutPointScriptZ* tuple_conv = (LDKC2Tuple_OutPointScriptZ*)(tuple & ~1);
5129         LDKOutPoint ret_var = C2Tuple_OutPointScriptZ_get_a(tuple_conv);
5130         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5131         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5132         uint64_t ret_ref = (uint64_t)ret_var.inner;
5133         if (ret_var.is_owned) {
5134                 ret_ref |= 1;
5135         }
5136         return ret_ref;
5137 }
5138
5139 static inline struct LDKCVec_u8Z C2Tuple_OutPointScriptZ_get_b(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR tuple){
5140         return CVec_u8Z_clone(&tuple->b);
5141 }
5142 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1get_1b(JNIEnv *env, jclass clz, int64_t tuple) {
5143         LDKC2Tuple_OutPointScriptZ* tuple_conv = (LDKC2Tuple_OutPointScriptZ*)(tuple & ~1);
5144         LDKCVec_u8Z ret_var = C2Tuple_OutPointScriptZ_get_b(tuple_conv);
5145         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
5146         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
5147         CVec_u8Z_free(ret_var);
5148         return ret_arr;
5149 }
5150
5151 static inline uint32_t C2Tuple_u32ScriptZ_get_a(LDKC2Tuple_u32ScriptZ *NONNULL_PTR tuple){
5152         return tuple->a;
5153 }
5154 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1get_1a(JNIEnv *env, jclass clz, int64_t tuple) {
5155         LDKC2Tuple_u32ScriptZ* tuple_conv = (LDKC2Tuple_u32ScriptZ*)(tuple & ~1);
5156         int32_t ret_val = C2Tuple_u32ScriptZ_get_a(tuple_conv);
5157         return ret_val;
5158 }
5159
5160 static inline struct LDKCVec_u8Z C2Tuple_u32ScriptZ_get_b(LDKC2Tuple_u32ScriptZ *NONNULL_PTR tuple){
5161         return CVec_u8Z_clone(&tuple->b);
5162 }
5163 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1get_1b(JNIEnv *env, jclass clz, int64_t tuple) {
5164         LDKC2Tuple_u32ScriptZ* tuple_conv = (LDKC2Tuple_u32ScriptZ*)(tuple & ~1);
5165         LDKCVec_u8Z ret_var = C2Tuple_u32ScriptZ_get_b(tuple_conv);
5166         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
5167         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
5168         CVec_u8Z_free(ret_var);
5169         return ret_arr;
5170 }
5171
5172 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1u32ScriptZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
5173         LDKCVec_C2Tuple_u32ScriptZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_u32ScriptZZ), "LDKCVec_C2Tuple_u32ScriptZZ");
5174         ret->datalen = (*env)->GetArrayLength(env, elems);
5175         if (ret->datalen == 0) {
5176                 ret->data = NULL;
5177         } else {
5178                 ret->data = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ) * ret->datalen, "LDKCVec_C2Tuple_u32ScriptZZ Data");
5179                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
5180                 for (size_t i = 0; i < ret->datalen; i++) {
5181                         int64_t arr_elem = java_elems[i];
5182                         void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
5183                         CHECK_ACCESS(arr_elem_ptr);
5184                         LDKC2Tuple_u32ScriptZ arr_elem_conv = *(LDKC2Tuple_u32ScriptZ*)(arr_elem_ptr);
5185                         arr_elem_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)(((uint64_t)arr_elem) & ~1));
5186                         ret->data[i] = arr_elem_conv;
5187                 }
5188                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
5189         }
5190         return (uint64_t)ret;
5191 }
5192 static inline LDKCVec_C2Tuple_u32ScriptZZ CVec_C2Tuple_u32ScriptZZ_clone(const LDKCVec_C2Tuple_u32ScriptZZ *orig) {
5193         LDKCVec_C2Tuple_u32ScriptZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ) * orig->datalen, "LDKCVec_C2Tuple_u32ScriptZZ clone bytes"), .datalen = orig->datalen };
5194         for (size_t i = 0; i < ret.datalen; i++) {
5195                 ret.data[i] = C2Tuple_u32ScriptZ_clone(&orig->data[i]);
5196         }
5197         return ret;
5198 }
5199 static inline struct LDKThirtyTwoBytes C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR tuple){
5200         return ThirtyTwoBytes_clone(&tuple->a);
5201 }
5202 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1get_1a(JNIEnv *env, jclass clz, int64_t tuple) {
5203         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* tuple_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(tuple & ~1);
5204         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5205         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(tuple_conv).data);
5206         return ret_arr;
5207 }
5208
5209 static inline struct LDKCVec_C2Tuple_u32ScriptZZ C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR tuple){
5210         return CVec_C2Tuple_u32ScriptZZ_clone(&tuple->b);
5211 }
5212 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1get_1b(JNIEnv *env, jclass clz, int64_t tuple) {
5213         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* tuple_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(tuple & ~1);
5214         LDKCVec_C2Tuple_u32ScriptZZ ret_var = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(tuple_conv);
5215         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
5216         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
5217         for (size_t v = 0; v < ret_var.datalen; v++) {
5218                 LDKC2Tuple_u32ScriptZ* ret_conv_21_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
5219                 *ret_conv_21_conv = ret_var.data[v];
5220                 ret_arr_ptr[v] = ((uint64_t)ret_conv_21_conv);
5221         }
5222         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
5223         FREE(ret_var.data);
5224         return ret_arr;
5225 }
5226
5227 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
5228         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ");
5229         ret->datalen = (*env)->GetArrayLength(env, elems);
5230         if (ret->datalen == 0) {
5231                 ret->data = NULL;
5232         } else {
5233                 ret->data = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ) * ret->datalen, "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ Data");
5234                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
5235                 for (size_t i = 0; i < ret->datalen; i++) {
5236                         int64_t arr_elem = java_elems[i];
5237                         void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
5238                         CHECK_ACCESS(arr_elem_ptr);
5239                         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ arr_elem_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(arr_elem_ptr);
5240                         arr_elem_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone((LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)arr_elem) & ~1));
5241                         ret->data[i] = arr_elem_conv;
5242                 }
5243                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
5244         }
5245         return (uint64_t)ret;
5246 }
5247 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ *orig) {
5248         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 };
5249         for (size_t i = 0; i < ret.datalen; i++) {
5250                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(&orig->data[i]);
5251         }
5252         return ret;
5253 }
5254 static jclass LDKPaymentPurpose_InvoicePayment_class = NULL;
5255 static jmethodID LDKPaymentPurpose_InvoicePayment_meth = NULL;
5256 static jclass LDKPaymentPurpose_SpontaneousPayment_class = NULL;
5257 static jmethodID LDKPaymentPurpose_SpontaneousPayment_meth = NULL;
5258 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKPaymentPurpose_init (JNIEnv *env, jclass clz) {
5259         LDKPaymentPurpose_InvoicePayment_class =
5260                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentPurpose$InvoicePayment;"));
5261         CHECK(LDKPaymentPurpose_InvoicePayment_class != NULL);
5262         LDKPaymentPurpose_InvoicePayment_meth = (*env)->GetMethodID(env, LDKPaymentPurpose_InvoicePayment_class, "<init>", "([B[BJ)V");
5263         CHECK(LDKPaymentPurpose_InvoicePayment_meth != NULL);
5264         LDKPaymentPurpose_SpontaneousPayment_class =
5265                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentPurpose$SpontaneousPayment;"));
5266         CHECK(LDKPaymentPurpose_SpontaneousPayment_class != NULL);
5267         LDKPaymentPurpose_SpontaneousPayment_meth = (*env)->GetMethodID(env, LDKPaymentPurpose_SpontaneousPayment_class, "<init>", "([B)V");
5268         CHECK(LDKPaymentPurpose_SpontaneousPayment_meth != NULL);
5269 }
5270 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPaymentPurpose_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
5271         LDKPaymentPurpose *obj = (LDKPaymentPurpose*)(ptr & ~1);
5272         switch(obj->tag) {
5273                 case LDKPaymentPurpose_InvoicePayment: {
5274                         int8_tArray payment_preimage_arr = (*env)->NewByteArray(env, 32);
5275                         (*env)->SetByteArrayRegion(env, payment_preimage_arr, 0, 32, obj->invoice_payment.payment_preimage.data);
5276                         int8_tArray payment_secret_arr = (*env)->NewByteArray(env, 32);
5277                         (*env)->SetByteArrayRegion(env, payment_secret_arr, 0, 32, obj->invoice_payment.payment_secret.data);
5278                         return (*env)->NewObject(env, LDKPaymentPurpose_InvoicePayment_class, LDKPaymentPurpose_InvoicePayment_meth, payment_preimage_arr, payment_secret_arr, obj->invoice_payment.user_payment_id);
5279                 }
5280                 case LDKPaymentPurpose_SpontaneousPayment: {
5281                         int8_tArray spontaneous_payment_arr = (*env)->NewByteArray(env, 32);
5282                         (*env)->SetByteArrayRegion(env, spontaneous_payment_arr, 0, 32, obj->spontaneous_payment.data);
5283                         return (*env)->NewObject(env, LDKPaymentPurpose_SpontaneousPayment_class, LDKPaymentPurpose_SpontaneousPayment_meth, spontaneous_payment_arr);
5284                 }
5285                 default: abort();
5286         }
5287 }
5288 static jclass LDKClosureReason_CounterpartyForceClosed_class = NULL;
5289 static jmethodID LDKClosureReason_CounterpartyForceClosed_meth = NULL;
5290 static jclass LDKClosureReason_HolderForceClosed_class = NULL;
5291 static jmethodID LDKClosureReason_HolderForceClosed_meth = NULL;
5292 static jclass LDKClosureReason_CooperativeClosure_class = NULL;
5293 static jmethodID LDKClosureReason_CooperativeClosure_meth = NULL;
5294 static jclass LDKClosureReason_CommitmentTxConfirmed_class = NULL;
5295 static jmethodID LDKClosureReason_CommitmentTxConfirmed_meth = NULL;
5296 static jclass LDKClosureReason_ProcessingError_class = NULL;
5297 static jmethodID LDKClosureReason_ProcessingError_meth = NULL;
5298 static jclass LDKClosureReason_DisconnectedPeer_class = NULL;
5299 static jmethodID LDKClosureReason_DisconnectedPeer_meth = NULL;
5300 static jclass LDKClosureReason_OutdatedChannelManager_class = NULL;
5301 static jmethodID LDKClosureReason_OutdatedChannelManager_meth = NULL;
5302 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKClosureReason_init (JNIEnv *env, jclass clz) {
5303         LDKClosureReason_CounterpartyForceClosed_class =
5304                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKClosureReason$CounterpartyForceClosed;"));
5305         CHECK(LDKClosureReason_CounterpartyForceClosed_class != NULL);
5306         LDKClosureReason_CounterpartyForceClosed_meth = (*env)->GetMethodID(env, LDKClosureReason_CounterpartyForceClosed_class, "<init>", "(Ljava/lang/String;)V");
5307         CHECK(LDKClosureReason_CounterpartyForceClosed_meth != NULL);
5308         LDKClosureReason_HolderForceClosed_class =
5309                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKClosureReason$HolderForceClosed;"));
5310         CHECK(LDKClosureReason_HolderForceClosed_class != NULL);
5311         LDKClosureReason_HolderForceClosed_meth = (*env)->GetMethodID(env, LDKClosureReason_HolderForceClosed_class, "<init>", "()V");
5312         CHECK(LDKClosureReason_HolderForceClosed_meth != NULL);
5313         LDKClosureReason_CooperativeClosure_class =
5314                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKClosureReason$CooperativeClosure;"));
5315         CHECK(LDKClosureReason_CooperativeClosure_class != NULL);
5316         LDKClosureReason_CooperativeClosure_meth = (*env)->GetMethodID(env, LDKClosureReason_CooperativeClosure_class, "<init>", "()V");
5317         CHECK(LDKClosureReason_CooperativeClosure_meth != NULL);
5318         LDKClosureReason_CommitmentTxConfirmed_class =
5319                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKClosureReason$CommitmentTxConfirmed;"));
5320         CHECK(LDKClosureReason_CommitmentTxConfirmed_class != NULL);
5321         LDKClosureReason_CommitmentTxConfirmed_meth = (*env)->GetMethodID(env, LDKClosureReason_CommitmentTxConfirmed_class, "<init>", "()V");
5322         CHECK(LDKClosureReason_CommitmentTxConfirmed_meth != NULL);
5323         LDKClosureReason_ProcessingError_class =
5324                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKClosureReason$ProcessingError;"));
5325         CHECK(LDKClosureReason_ProcessingError_class != NULL);
5326         LDKClosureReason_ProcessingError_meth = (*env)->GetMethodID(env, LDKClosureReason_ProcessingError_class, "<init>", "(Ljava/lang/String;)V");
5327         CHECK(LDKClosureReason_ProcessingError_meth != NULL);
5328         LDKClosureReason_DisconnectedPeer_class =
5329                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKClosureReason$DisconnectedPeer;"));
5330         CHECK(LDKClosureReason_DisconnectedPeer_class != NULL);
5331         LDKClosureReason_DisconnectedPeer_meth = (*env)->GetMethodID(env, LDKClosureReason_DisconnectedPeer_class, "<init>", "()V");
5332         CHECK(LDKClosureReason_DisconnectedPeer_meth != NULL);
5333         LDKClosureReason_OutdatedChannelManager_class =
5334                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKClosureReason$OutdatedChannelManager;"));
5335         CHECK(LDKClosureReason_OutdatedChannelManager_class != NULL);
5336         LDKClosureReason_OutdatedChannelManager_meth = (*env)->GetMethodID(env, LDKClosureReason_OutdatedChannelManager_class, "<init>", "()V");
5337         CHECK(LDKClosureReason_OutdatedChannelManager_meth != NULL);
5338 }
5339 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKClosureReason_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
5340         LDKClosureReason *obj = (LDKClosureReason*)(ptr & ~1);
5341         switch(obj->tag) {
5342                 case LDKClosureReason_CounterpartyForceClosed: {
5343                         LDKStr peer_msg_str = obj->counterparty_force_closed.peer_msg;
5344                         jstring peer_msg_conv = str_ref_to_java(env, peer_msg_str.chars, peer_msg_str.len);
5345                         return (*env)->NewObject(env, LDKClosureReason_CounterpartyForceClosed_class, LDKClosureReason_CounterpartyForceClosed_meth, peer_msg_conv);
5346                 }
5347                 case LDKClosureReason_HolderForceClosed: {
5348                         return (*env)->NewObject(env, LDKClosureReason_HolderForceClosed_class, LDKClosureReason_HolderForceClosed_meth);
5349                 }
5350                 case LDKClosureReason_CooperativeClosure: {
5351                         return (*env)->NewObject(env, LDKClosureReason_CooperativeClosure_class, LDKClosureReason_CooperativeClosure_meth);
5352                 }
5353                 case LDKClosureReason_CommitmentTxConfirmed: {
5354                         return (*env)->NewObject(env, LDKClosureReason_CommitmentTxConfirmed_class, LDKClosureReason_CommitmentTxConfirmed_meth);
5355                 }
5356                 case LDKClosureReason_ProcessingError: {
5357                         LDKStr err_str = obj->processing_error.err;
5358                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
5359                         return (*env)->NewObject(env, LDKClosureReason_ProcessingError_class, LDKClosureReason_ProcessingError_meth, err_conv);
5360                 }
5361                 case LDKClosureReason_DisconnectedPeer: {
5362                         return (*env)->NewObject(env, LDKClosureReason_DisconnectedPeer_class, LDKClosureReason_DisconnectedPeer_meth);
5363                 }
5364                 case LDKClosureReason_OutdatedChannelManager: {
5365                         return (*env)->NewObject(env, LDKClosureReason_OutdatedChannelManager_class, LDKClosureReason_OutdatedChannelManager_meth);
5366                 }
5367                 default: abort();
5368         }
5369 }
5370 static jclass LDKEvent_FundingGenerationReady_class = NULL;
5371 static jmethodID LDKEvent_FundingGenerationReady_meth = NULL;
5372 static jclass LDKEvent_PaymentReceived_class = NULL;
5373 static jmethodID LDKEvent_PaymentReceived_meth = NULL;
5374 static jclass LDKEvent_PaymentSent_class = NULL;
5375 static jmethodID LDKEvent_PaymentSent_meth = NULL;
5376 static jclass LDKEvent_PaymentPathFailed_class = NULL;
5377 static jmethodID LDKEvent_PaymentPathFailed_meth = NULL;
5378 static jclass LDKEvent_PendingHTLCsForwardable_class = NULL;
5379 static jmethodID LDKEvent_PendingHTLCsForwardable_meth = NULL;
5380 static jclass LDKEvent_SpendableOutputs_class = NULL;
5381 static jmethodID LDKEvent_SpendableOutputs_meth = NULL;
5382 static jclass LDKEvent_PaymentForwarded_class = NULL;
5383 static jmethodID LDKEvent_PaymentForwarded_meth = NULL;
5384 static jclass LDKEvent_ChannelClosed_class = NULL;
5385 static jmethodID LDKEvent_ChannelClosed_meth = NULL;
5386 static jclass LDKEvent_DiscardFunding_class = NULL;
5387 static jmethodID LDKEvent_DiscardFunding_meth = NULL;
5388 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKEvent_init (JNIEnv *env, jclass clz) {
5389         LDKEvent_FundingGenerationReady_class =
5390                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$FundingGenerationReady;"));
5391         CHECK(LDKEvent_FundingGenerationReady_class != NULL);
5392         LDKEvent_FundingGenerationReady_meth = (*env)->GetMethodID(env, LDKEvent_FundingGenerationReady_class, "<init>", "([BJ[BJ)V");
5393         CHECK(LDKEvent_FundingGenerationReady_meth != NULL);
5394         LDKEvent_PaymentReceived_class =
5395                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PaymentReceived;"));
5396         CHECK(LDKEvent_PaymentReceived_class != NULL);
5397         LDKEvent_PaymentReceived_meth = (*env)->GetMethodID(env, LDKEvent_PaymentReceived_class, "<init>", "([BJJ)V");
5398         CHECK(LDKEvent_PaymentReceived_meth != NULL);
5399         LDKEvent_PaymentSent_class =
5400                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PaymentSent;"));
5401         CHECK(LDKEvent_PaymentSent_class != NULL);
5402         LDKEvent_PaymentSent_meth = (*env)->GetMethodID(env, LDKEvent_PaymentSent_class, "<init>", "([B[B)V");
5403         CHECK(LDKEvent_PaymentSent_meth != NULL);
5404         LDKEvent_PaymentPathFailed_class =
5405                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PaymentPathFailed;"));
5406         CHECK(LDKEvent_PaymentPathFailed_class != NULL);
5407         LDKEvent_PaymentPathFailed_meth = (*env)->GetMethodID(env, LDKEvent_PaymentPathFailed_class, "<init>", "([BZJZ[JJ)V");
5408         CHECK(LDKEvent_PaymentPathFailed_meth != NULL);
5409         LDKEvent_PendingHTLCsForwardable_class =
5410                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PendingHTLCsForwardable;"));
5411         CHECK(LDKEvent_PendingHTLCsForwardable_class != NULL);
5412         LDKEvent_PendingHTLCsForwardable_meth = (*env)->GetMethodID(env, LDKEvent_PendingHTLCsForwardable_class, "<init>", "(J)V");
5413         CHECK(LDKEvent_PendingHTLCsForwardable_meth != NULL);
5414         LDKEvent_SpendableOutputs_class =
5415                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$SpendableOutputs;"));
5416         CHECK(LDKEvent_SpendableOutputs_class != NULL);
5417         LDKEvent_SpendableOutputs_meth = (*env)->GetMethodID(env, LDKEvent_SpendableOutputs_class, "<init>", "([J)V");
5418         CHECK(LDKEvent_SpendableOutputs_meth != NULL);
5419         LDKEvent_PaymentForwarded_class =
5420                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PaymentForwarded;"));
5421         CHECK(LDKEvent_PaymentForwarded_class != NULL);
5422         LDKEvent_PaymentForwarded_meth = (*env)->GetMethodID(env, LDKEvent_PaymentForwarded_class, "<init>", "(JZ)V");
5423         CHECK(LDKEvent_PaymentForwarded_meth != NULL);
5424         LDKEvent_ChannelClosed_class =
5425                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$ChannelClosed;"));
5426         CHECK(LDKEvent_ChannelClosed_class != NULL);
5427         LDKEvent_ChannelClosed_meth = (*env)->GetMethodID(env, LDKEvent_ChannelClosed_class, "<init>", "([BJJ)V");
5428         CHECK(LDKEvent_ChannelClosed_meth != NULL);
5429         LDKEvent_DiscardFunding_class =
5430                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$DiscardFunding;"));
5431         CHECK(LDKEvent_DiscardFunding_class != NULL);
5432         LDKEvent_DiscardFunding_meth = (*env)->GetMethodID(env, LDKEvent_DiscardFunding_class, "<init>", "([B[B)V");
5433         CHECK(LDKEvent_DiscardFunding_meth != NULL);
5434 }
5435 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
5436         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
5437         switch(obj->tag) {
5438                 case LDKEvent_FundingGenerationReady: {
5439                         int8_tArray temporary_channel_id_arr = (*env)->NewByteArray(env, 32);
5440                         (*env)->SetByteArrayRegion(env, temporary_channel_id_arr, 0, 32, obj->funding_generation_ready.temporary_channel_id.data);
5441                         LDKCVec_u8Z output_script_var = obj->funding_generation_ready.output_script;
5442                         int8_tArray output_script_arr = (*env)->NewByteArray(env, output_script_var.datalen);
5443                         (*env)->SetByteArrayRegion(env, output_script_arr, 0, output_script_var.datalen, output_script_var.data);
5444                         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);
5445                 }
5446                 case LDKEvent_PaymentReceived: {
5447                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
5448                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_received.payment_hash.data);
5449                         uint64_t purpose_ref = ((uint64_t)&obj->payment_received.purpose) | 1;
5450                         return (*env)->NewObject(env, LDKEvent_PaymentReceived_class, LDKEvent_PaymentReceived_meth, payment_hash_arr, obj->payment_received.amt, purpose_ref);
5451                 }
5452                 case LDKEvent_PaymentSent: {
5453                         int8_tArray payment_preimage_arr = (*env)->NewByteArray(env, 32);
5454                         (*env)->SetByteArrayRegion(env, payment_preimage_arr, 0, 32, obj->payment_sent.payment_preimage.data);
5455                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
5456                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_sent.payment_hash.data);
5457                         return (*env)->NewObject(env, LDKEvent_PaymentSent_class, LDKEvent_PaymentSent_meth, payment_preimage_arr, payment_hash_arr);
5458                 }
5459                 case LDKEvent_PaymentPathFailed: {
5460                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
5461                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_path_failed.payment_hash.data);
5462                         uint64_t network_update_ref = ((uint64_t)&obj->payment_path_failed.network_update) | 1;
5463                         LDKCVec_RouteHopZ path_var = obj->payment_path_failed.path;
5464                         int64_tArray path_arr = (*env)->NewLongArray(env, path_var.datalen);
5465                         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
5466                         for (size_t k = 0; k < path_var.datalen; k++) {
5467                                 LDKRouteHop path_conv_10_var = path_var.data[k];
5468                                 CHECK((((uint64_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5469                                 CHECK((((uint64_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5470                                 uint64_t path_conv_10_ref = (uint64_t)path_conv_10_var.inner & ~1;
5471                                 path_arr_ptr[k] = path_conv_10_ref;
5472                         }
5473                         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
5474                         uint64_t short_channel_id_ref = ((uint64_t)&obj->payment_path_failed.short_channel_id) | 1;
5475                         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);
5476                 }
5477                 case LDKEvent_PendingHTLCsForwardable: {
5478                         return (*env)->NewObject(env, LDKEvent_PendingHTLCsForwardable_class, LDKEvent_PendingHTLCsForwardable_meth, obj->pending_htl_cs_forwardable.time_forwardable);
5479                 }
5480                 case LDKEvent_SpendableOutputs: {
5481                         LDKCVec_SpendableOutputDescriptorZ outputs_var = obj->spendable_outputs.outputs;
5482                         int64_tArray outputs_arr = (*env)->NewLongArray(env, outputs_var.datalen);
5483                         int64_t *outputs_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, outputs_arr, NULL);
5484                         for (size_t b = 0; b < outputs_var.datalen; b++) {
5485                                 uint64_t outputs_conv_27_ref = ((uint64_t)&outputs_var.data[b]) | 1;
5486                                 outputs_arr_ptr[b] = outputs_conv_27_ref;
5487                         }
5488                         (*env)->ReleasePrimitiveArrayCritical(env, outputs_arr, outputs_arr_ptr, 0);
5489                         return (*env)->NewObject(env, LDKEvent_SpendableOutputs_class, LDKEvent_SpendableOutputs_meth, outputs_arr);
5490                 }
5491                 case LDKEvent_PaymentForwarded: {
5492                         uint64_t fee_earned_msat_ref = ((uint64_t)&obj->payment_forwarded.fee_earned_msat) | 1;
5493                         return (*env)->NewObject(env, LDKEvent_PaymentForwarded_class, LDKEvent_PaymentForwarded_meth, fee_earned_msat_ref, obj->payment_forwarded.claim_from_onchain_tx);
5494                 }
5495                 case LDKEvent_ChannelClosed: {
5496                         int8_tArray channel_id_arr = (*env)->NewByteArray(env, 32);
5497                         (*env)->SetByteArrayRegion(env, channel_id_arr, 0, 32, obj->channel_closed.channel_id.data);
5498                         uint64_t reason_ref = ((uint64_t)&obj->channel_closed.reason) | 1;
5499                         return (*env)->NewObject(env, LDKEvent_ChannelClosed_class, LDKEvent_ChannelClosed_meth, channel_id_arr, obj->channel_closed.user_channel_id, reason_ref);
5500                 }
5501                 case LDKEvent_DiscardFunding: {
5502                         int8_tArray channel_id_arr = (*env)->NewByteArray(env, 32);
5503                         (*env)->SetByteArrayRegion(env, channel_id_arr, 0, 32, obj->discard_funding.channel_id.data);
5504                         LDKTransaction transaction_var = obj->discard_funding.transaction;
5505                         int8_tArray transaction_arr = (*env)->NewByteArray(env, transaction_var.datalen);
5506                         (*env)->SetByteArrayRegion(env, transaction_arr, 0, transaction_var.datalen, transaction_var.data);
5507                         return (*env)->NewObject(env, LDKEvent_DiscardFunding_class, LDKEvent_DiscardFunding_meth, channel_id_arr, transaction_arr);
5508                 }
5509                 default: abort();
5510         }
5511 }
5512 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1EventZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
5513         LDKCVec_EventZ *ret = MALLOC(sizeof(LDKCVec_EventZ), "LDKCVec_EventZ");
5514         ret->datalen = (*env)->GetArrayLength(env, elems);
5515         if (ret->datalen == 0) {
5516                 ret->data = NULL;
5517         } else {
5518                 ret->data = MALLOC(sizeof(LDKEvent) * ret->datalen, "LDKCVec_EventZ Data");
5519                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
5520                 for (size_t i = 0; i < ret->datalen; i++) {
5521                         int64_t arr_elem = java_elems[i];
5522                         void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
5523                         CHECK_ACCESS(arr_elem_ptr);
5524                         LDKEvent arr_elem_conv = *(LDKEvent*)(arr_elem_ptr);
5525                         arr_elem_conv = Event_clone((LDKEvent*)(((uint64_t)arr_elem) & ~1));
5526                         ret->data[i] = arr_elem_conv;
5527                 }
5528                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
5529         }
5530         return (uint64_t)ret;
5531 }
5532 static inline LDKCVec_EventZ CVec_EventZ_clone(const LDKCVec_EventZ *orig) {
5533         LDKCVec_EventZ ret = { .data = MALLOC(sizeof(LDKEvent) * orig->datalen, "LDKCVec_EventZ clone bytes"), .datalen = orig->datalen };
5534         for (size_t i = 0; i < ret.datalen; i++) {
5535                 ret.data[i] = Event_clone(&orig->data[i]);
5536         }
5537         return ret;
5538 }
5539 static inline uint32_t C2Tuple_u32TxOutZ_get_a(LDKC2Tuple_u32TxOutZ *NONNULL_PTR tuple){
5540         return tuple->a;
5541 }
5542 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1get_1a(JNIEnv *env, jclass clz, int64_t tuple) {
5543         LDKC2Tuple_u32TxOutZ* tuple_conv = (LDKC2Tuple_u32TxOutZ*)(tuple & ~1);
5544         int32_t ret_val = C2Tuple_u32TxOutZ_get_a(tuple_conv);
5545         return ret_val;
5546 }
5547
5548 static inline struct LDKTxOut C2Tuple_u32TxOutZ_get_b(LDKC2Tuple_u32TxOutZ *NONNULL_PTR tuple){
5549         return TxOut_clone(&tuple->b);
5550 }
5551 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1get_1b(JNIEnv *env, jclass clz, int64_t tuple) {
5552         LDKC2Tuple_u32TxOutZ* tuple_conv = (LDKC2Tuple_u32TxOutZ*)(tuple & ~1);
5553         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
5554         *ret_ref = C2Tuple_u32TxOutZ_get_b(tuple_conv);
5555         return (uint64_t)ret_ref;
5556 }
5557
5558 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1u32TxOutZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
5559         LDKCVec_C2Tuple_u32TxOutZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_u32TxOutZZ), "LDKCVec_C2Tuple_u32TxOutZZ");
5560         ret->datalen = (*env)->GetArrayLength(env, elems);
5561         if (ret->datalen == 0) {
5562                 ret->data = NULL;
5563         } else {
5564                 ret->data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * ret->datalen, "LDKCVec_C2Tuple_u32TxOutZZ Data");
5565                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
5566                 for (size_t i = 0; i < ret->datalen; i++) {
5567                         int64_t arr_elem = java_elems[i];
5568                         void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
5569                         CHECK_ACCESS(arr_elem_ptr);
5570                         LDKC2Tuple_u32TxOutZ arr_elem_conv = *(LDKC2Tuple_u32TxOutZ*)(arr_elem_ptr);
5571                         arr_elem_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uint64_t)arr_elem) & ~1));
5572                         ret->data[i] = arr_elem_conv;
5573                 }
5574                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
5575         }
5576         return (uint64_t)ret;
5577 }
5578 static inline LDKCVec_C2Tuple_u32TxOutZZ CVec_C2Tuple_u32TxOutZZ_clone(const LDKCVec_C2Tuple_u32TxOutZZ *orig) {
5579         LDKCVec_C2Tuple_u32TxOutZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * orig->datalen, "LDKCVec_C2Tuple_u32TxOutZZ clone bytes"), .datalen = orig->datalen };
5580         for (size_t i = 0; i < ret.datalen; i++) {
5581                 ret.data[i] = C2Tuple_u32TxOutZ_clone(&orig->data[i]);
5582         }
5583         return ret;
5584 }
5585 static inline struct LDKThirtyTwoBytes C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR tuple){
5586         return ThirtyTwoBytes_clone(&tuple->a);
5587 }
5588 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1get_1a(JNIEnv *env, jclass clz, int64_t tuple) {
5589         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* tuple_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(tuple & ~1);
5590         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5591         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(tuple_conv).data);
5592         return ret_arr;
5593 }
5594
5595 static inline struct LDKCVec_C2Tuple_u32TxOutZZ C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR tuple){
5596         return CVec_C2Tuple_u32TxOutZZ_clone(&tuple->b);
5597 }
5598 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1get_1b(JNIEnv *env, jclass clz, int64_t tuple) {
5599         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* tuple_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(tuple & ~1);
5600         LDKCVec_C2Tuple_u32TxOutZZ ret_var = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(tuple_conv);
5601         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
5602         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
5603         for (size_t u = 0; u < ret_var.datalen; u++) {
5604                 LDKC2Tuple_u32TxOutZ* ret_conv_20_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
5605                 *ret_conv_20_conv = ret_var.data[u];
5606                 ret_arr_ptr[u] = ((uint64_t)ret_conv_20_conv);
5607         }
5608         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
5609         FREE(ret_var.data);
5610         return ret_arr;
5611 }
5612
5613 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
5614         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ");
5615         ret->datalen = (*env)->GetArrayLength(env, elems);
5616         if (ret->datalen == 0) {
5617                 ret->data = NULL;
5618         } else {
5619                 ret->data = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ) * ret->datalen, "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Data");
5620                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
5621                 for (size_t i = 0; i < ret->datalen; i++) {
5622                         int64_t arr_elem = java_elems[i];
5623                         void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
5624                         CHECK_ACCESS(arr_elem_ptr);
5625                         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ arr_elem_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(arr_elem_ptr);
5626                         arr_elem_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone((LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)arr_elem) & ~1));
5627                         ret->data[i] = arr_elem_conv;
5628                 }
5629                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
5630         }
5631         return (uint64_t)ret;
5632 }
5633 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ *orig) {
5634         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 };
5635         for (size_t i = 0; i < ret.datalen; i++) {
5636                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(&orig->data[i]);
5637         }
5638         return ret;
5639 }
5640 static jclass LDKBalance_ClaimableOnChannelClose_class = NULL;
5641 static jmethodID LDKBalance_ClaimableOnChannelClose_meth = NULL;
5642 static jclass LDKBalance_ClaimableAwaitingConfirmations_class = NULL;
5643 static jmethodID LDKBalance_ClaimableAwaitingConfirmations_meth = NULL;
5644 static jclass LDKBalance_ContentiousClaimable_class = NULL;
5645 static jmethodID LDKBalance_ContentiousClaimable_meth = NULL;
5646 static jclass LDKBalance_MaybeClaimableHTLCAwaitingTimeout_class = NULL;
5647 static jmethodID LDKBalance_MaybeClaimableHTLCAwaitingTimeout_meth = NULL;
5648 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKBalance_init (JNIEnv *env, jclass clz) {
5649         LDKBalance_ClaimableOnChannelClose_class =
5650                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKBalance$ClaimableOnChannelClose;"));
5651         CHECK(LDKBalance_ClaimableOnChannelClose_class != NULL);
5652         LDKBalance_ClaimableOnChannelClose_meth = (*env)->GetMethodID(env, LDKBalance_ClaimableOnChannelClose_class, "<init>", "(J)V");
5653         CHECK(LDKBalance_ClaimableOnChannelClose_meth != NULL);
5654         LDKBalance_ClaimableAwaitingConfirmations_class =
5655                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKBalance$ClaimableAwaitingConfirmations;"));
5656         CHECK(LDKBalance_ClaimableAwaitingConfirmations_class != NULL);
5657         LDKBalance_ClaimableAwaitingConfirmations_meth = (*env)->GetMethodID(env, LDKBalance_ClaimableAwaitingConfirmations_class, "<init>", "(JI)V");
5658         CHECK(LDKBalance_ClaimableAwaitingConfirmations_meth != NULL);
5659         LDKBalance_ContentiousClaimable_class =
5660                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKBalance$ContentiousClaimable;"));
5661         CHECK(LDKBalance_ContentiousClaimable_class != NULL);
5662         LDKBalance_ContentiousClaimable_meth = (*env)->GetMethodID(env, LDKBalance_ContentiousClaimable_class, "<init>", "(JI)V");
5663         CHECK(LDKBalance_ContentiousClaimable_meth != NULL);
5664         LDKBalance_MaybeClaimableHTLCAwaitingTimeout_class =
5665                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKBalance$MaybeClaimableHTLCAwaitingTimeout;"));
5666         CHECK(LDKBalance_MaybeClaimableHTLCAwaitingTimeout_class != NULL);
5667         LDKBalance_MaybeClaimableHTLCAwaitingTimeout_meth = (*env)->GetMethodID(env, LDKBalance_MaybeClaimableHTLCAwaitingTimeout_class, "<init>", "(JI)V");
5668         CHECK(LDKBalance_MaybeClaimableHTLCAwaitingTimeout_meth != NULL);
5669 }
5670 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKBalance_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
5671         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
5672         switch(obj->tag) {
5673                 case LDKBalance_ClaimableOnChannelClose: {
5674                         return (*env)->NewObject(env, LDKBalance_ClaimableOnChannelClose_class, LDKBalance_ClaimableOnChannelClose_meth, obj->claimable_on_channel_close.claimable_amount_satoshis);
5675                 }
5676                 case LDKBalance_ClaimableAwaitingConfirmations: {
5677                         return (*env)->NewObject(env, LDKBalance_ClaimableAwaitingConfirmations_class, LDKBalance_ClaimableAwaitingConfirmations_meth, obj->claimable_awaiting_confirmations.claimable_amount_satoshis, obj->claimable_awaiting_confirmations.confirmation_height);
5678                 }
5679                 case LDKBalance_ContentiousClaimable: {
5680                         return (*env)->NewObject(env, LDKBalance_ContentiousClaimable_class, LDKBalance_ContentiousClaimable_meth, obj->contentious_claimable.claimable_amount_satoshis, obj->contentious_claimable.timeout_height);
5681                 }
5682                 case LDKBalance_MaybeClaimableHTLCAwaitingTimeout: {
5683                         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);
5684                 }
5685                 default: abort();
5686         }
5687 }
5688 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1BalanceZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
5689         LDKCVec_BalanceZ *ret = MALLOC(sizeof(LDKCVec_BalanceZ), "LDKCVec_BalanceZ");
5690         ret->datalen = (*env)->GetArrayLength(env, elems);
5691         if (ret->datalen == 0) {
5692                 ret->data = NULL;
5693         } else {
5694                 ret->data = MALLOC(sizeof(LDKBalance) * ret->datalen, "LDKCVec_BalanceZ Data");
5695                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
5696                 for (size_t i = 0; i < ret->datalen; i++) {
5697                         int64_t arr_elem = java_elems[i];
5698                         void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
5699                         CHECK_ACCESS(arr_elem_ptr);
5700                         LDKBalance arr_elem_conv = *(LDKBalance*)(arr_elem_ptr);
5701                         arr_elem_conv = Balance_clone((LDKBalance*)(((uint64_t)arr_elem) & ~1));
5702                         ret->data[i] = arr_elem_conv;
5703                 }
5704                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
5705         }
5706         return (uint64_t)ret;
5707 }
5708 static inline LDKCVec_BalanceZ CVec_BalanceZ_clone(const LDKCVec_BalanceZ *orig) {
5709         LDKCVec_BalanceZ ret = { .data = MALLOC(sizeof(LDKBalance) * orig->datalen, "LDKCVec_BalanceZ clone bytes"), .datalen = orig->datalen };
5710         for (size_t i = 0; i < ret.datalen; i++) {
5711                 ret.data[i] = Balance_clone(&orig->data[i]);
5712         }
5713         return ret;
5714 }
5715 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5716         return ((LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)arg)->result_ok;
5717 }
5718 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5719         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1);
5720         CHECK(val->result_ok);
5721         LDKC2Tuple_BlockHashChannelMonitorZ* res_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
5722         *res_conv = (*val->contents.result);
5723         *res_conv = C2Tuple_BlockHashChannelMonitorZ_clone(res_conv);
5724         return ((uint64_t)res_conv);
5725 }
5726 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5727         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1);
5728         CHECK(!val->result_ok);
5729         LDKDecodeError err_var = (*val->contents.err);
5730         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5731         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5732         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5733         return err_ref;
5734 }
5735 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneLightningErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5736         return ((LDKCResult_NoneLightningErrorZ*)arg)->result_ok;
5737 }
5738 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5739         LDKCResult_NoneLightningErrorZ *val = (LDKCResult_NoneLightningErrorZ*)(arg & ~1);
5740         CHECK(val->result_ok);
5741         return *val->contents.result;
5742 }
5743 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5744         LDKCResult_NoneLightningErrorZ *val = (LDKCResult_NoneLightningErrorZ*)(arg & ~1);
5745         CHECK(!val->result_ok);
5746         LDKLightningError err_var = (*val->contents.err);
5747         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5748         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5749         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5750         return err_ref;
5751 }
5752 static inline struct LDKPublicKey C2Tuple_PublicKeyTypeZ_get_a(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR tuple){
5753         return tuple->a;
5754 }
5755 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1get_1a(JNIEnv *env, jclass clz, int64_t tuple) {
5756         LDKC2Tuple_PublicKeyTypeZ* tuple_conv = (LDKC2Tuple_PublicKeyTypeZ*)(tuple & ~1);
5757         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
5758         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, C2Tuple_PublicKeyTypeZ_get_a(tuple_conv).compressed_form);
5759         return ret_arr;
5760 }
5761
5762 static inline struct LDKType C2Tuple_PublicKeyTypeZ_get_b(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR tuple){
5763         return Type_clone(&tuple->b);
5764 }
5765 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1get_1b(JNIEnv *env, jclass clz, int64_t tuple) {
5766         LDKC2Tuple_PublicKeyTypeZ* tuple_conv = (LDKC2Tuple_PublicKeyTypeZ*)(tuple & ~1);
5767         LDKType* ret_ret =MALLOC(sizeof(LDKType), "LDKType");
5768         *ret_ret = C2Tuple_PublicKeyTypeZ_get_b(tuple_conv);
5769         return (uint64_t)ret_ret;
5770 }
5771
5772 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1PublicKeyTypeZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
5773         LDKCVec_C2Tuple_PublicKeyTypeZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_PublicKeyTypeZZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ");
5774         ret->datalen = (*env)->GetArrayLength(env, elems);
5775         if (ret->datalen == 0) {
5776                 ret->data = NULL;
5777         } else {
5778                 ret->data = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ) * ret->datalen, "LDKCVec_C2Tuple_PublicKeyTypeZZ Data");
5779                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
5780                 for (size_t i = 0; i < ret->datalen; i++) {
5781                         int64_t arr_elem = java_elems[i];
5782                         void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
5783                         CHECK_ACCESS(arr_elem_ptr);
5784                         LDKC2Tuple_PublicKeyTypeZ arr_elem_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(arr_elem_ptr);
5785                         arr_elem_conv = C2Tuple_PublicKeyTypeZ_clone((LDKC2Tuple_PublicKeyTypeZ*)(((uint64_t)arr_elem) & ~1));
5786                         ret->data[i] = arr_elem_conv;
5787                 }
5788                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
5789         }
5790         return (uint64_t)ret;
5791 }
5792 static inline LDKCVec_C2Tuple_PublicKeyTypeZZ CVec_C2Tuple_PublicKeyTypeZZ_clone(const LDKCVec_C2Tuple_PublicKeyTypeZZ *orig) {
5793         LDKCVec_C2Tuple_PublicKeyTypeZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ) * orig->datalen, "LDKCVec_C2Tuple_PublicKeyTypeZZ clone bytes"), .datalen = orig->datalen };
5794         for (size_t i = 0; i < ret.datalen; i++) {
5795                 ret.data[i] = C2Tuple_PublicKeyTypeZ_clone(&orig->data[i]);
5796         }
5797         return ret;
5798 }
5799 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolLightningErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5800         return ((LDKCResult_boolLightningErrorZ*)arg)->result_ok;
5801 }
5802 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5803         LDKCResult_boolLightningErrorZ *val = (LDKCResult_boolLightningErrorZ*)(arg & ~1);
5804         CHECK(val->result_ok);
5805         return *val->contents.result;
5806 }
5807 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5808         LDKCResult_boolLightningErrorZ *val = (LDKCResult_boolLightningErrorZ*)(arg & ~1);
5809         CHECK(!val->result_ok);
5810         LDKLightningError err_var = (*val->contents.err);
5811         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5812         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5813         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5814         return err_ref;
5815 }
5816 static inline struct LDKChannelAnnouncement C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR tuple){
5817         return ChannelAnnouncement_clone(&tuple->a);
5818 }
5819 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1a(JNIEnv *env, jclass clz, int64_t tuple) {
5820         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* tuple_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(tuple & ~1);
5821         LDKChannelAnnouncement ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(tuple_conv);
5822         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5823         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5824         uint64_t ret_ref = (uint64_t)ret_var.inner;
5825         if (ret_var.is_owned) {
5826                 ret_ref |= 1;
5827         }
5828         return ret_ref;
5829 }
5830
5831 static inline struct LDKChannelUpdate C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR tuple){
5832         return ChannelUpdate_clone(&tuple->b);
5833 }
5834 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1b(JNIEnv *env, jclass clz, int64_t tuple) {
5835         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* tuple_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(tuple & ~1);
5836         LDKChannelUpdate ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(tuple_conv);
5837         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5838         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5839         uint64_t ret_ref = (uint64_t)ret_var.inner;
5840         if (ret_var.is_owned) {
5841                 ret_ref |= 1;
5842         }
5843         return ret_ref;
5844 }
5845
5846 static inline struct LDKChannelUpdate C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR tuple){
5847         return ChannelUpdate_clone(&tuple->c);
5848 }
5849 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1c(JNIEnv *env, jclass clz, int64_t tuple) {
5850         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* tuple_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(tuple & ~1);
5851         LDKChannelUpdate ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(tuple_conv);
5852         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5853         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5854         uint64_t ret_ref = (uint64_t)ret_var.inner;
5855         if (ret_var.is_owned) {
5856                 ret_ref |= 1;
5857         }
5858         return ret_ref;
5859 }
5860
5861 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
5862         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *ret = MALLOC(sizeof(LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ");
5863         ret->datalen = (*env)->GetArrayLength(env, elems);
5864         if (ret->datalen == 0) {
5865                 ret->data = NULL;
5866         } else {
5867                 ret->data = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) * ret->datalen, "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Data");
5868                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
5869                 for (size_t i = 0; i < ret->datalen; i++) {
5870                         int64_t arr_elem = java_elems[i];
5871                         void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
5872                         CHECK_ACCESS(arr_elem_ptr);
5873                         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ arr_elem_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(arr_elem_ptr);
5874                         arr_elem_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone((LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)arr_elem) & ~1));
5875                         ret->data[i] = arr_elem_conv;
5876                 }
5877                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
5878         }
5879         return (uint64_t)ret;
5880 }
5881 static inline LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone(const LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *orig) {
5882         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret = { .data = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) * orig->datalen, "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ clone bytes"), .datalen = orig->datalen };
5883         for (size_t i = 0; i < ret.datalen; i++) {
5884                 ret.data[i] = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(&orig->data[i]);
5885         }
5886         return ret;
5887 }
5888 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1NodeAnnouncementZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
5889         LDKCVec_NodeAnnouncementZ *ret = MALLOC(sizeof(LDKCVec_NodeAnnouncementZ), "LDKCVec_NodeAnnouncementZ");
5890         ret->datalen = (*env)->GetArrayLength(env, elems);
5891         if (ret->datalen == 0) {
5892                 ret->data = NULL;
5893         } else {
5894                 ret->data = MALLOC(sizeof(LDKNodeAnnouncement) * ret->datalen, "LDKCVec_NodeAnnouncementZ Data");
5895                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
5896                 for (size_t i = 0; i < ret->datalen; i++) {
5897                         int64_t arr_elem = java_elems[i];
5898                         LDKNodeAnnouncement arr_elem_conv;
5899                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
5900                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
5901                         arr_elem_conv = NodeAnnouncement_clone(&arr_elem_conv);
5902                         ret->data[i] = arr_elem_conv;
5903                 }
5904                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
5905         }
5906         return (uint64_t)ret;
5907 }
5908 static inline LDKCVec_NodeAnnouncementZ CVec_NodeAnnouncementZ_clone(const LDKCVec_NodeAnnouncementZ *orig) {
5909         LDKCVec_NodeAnnouncementZ ret = { .data = MALLOC(sizeof(LDKNodeAnnouncement) * orig->datalen, "LDKCVec_NodeAnnouncementZ clone bytes"), .datalen = orig->datalen };
5910         for (size_t i = 0; i < ret.datalen; i++) {
5911                 ret.data[i] = NodeAnnouncement_clone(&orig->data[i]);
5912         }
5913         return ret;
5914 }
5915 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1u8ZPeerHandleErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5916         return ((LDKCResult_CVec_u8ZPeerHandleErrorZ*)arg)->result_ok;
5917 }
5918 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1u8ZPeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5919         LDKCResult_CVec_u8ZPeerHandleErrorZ *val = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(arg & ~1);
5920         CHECK(val->result_ok);
5921         LDKCVec_u8Z res_var = (*val->contents.result);
5922         int8_tArray res_arr = (*env)->NewByteArray(env, res_var.datalen);
5923         (*env)->SetByteArrayRegion(env, res_arr, 0, res_var.datalen, res_var.data);
5924         return res_arr;
5925 }
5926 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1u8ZPeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5927         LDKCResult_CVec_u8ZPeerHandleErrorZ *val = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(arg & ~1);
5928         CHECK(!val->result_ok);
5929         LDKPeerHandleError err_var = (*val->contents.err);
5930         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5931         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5932         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5933         return err_ref;
5934 }
5935 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePeerHandleErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5936         return ((LDKCResult_NonePeerHandleErrorZ*)arg)->result_ok;
5937 }
5938 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5939         LDKCResult_NonePeerHandleErrorZ *val = (LDKCResult_NonePeerHandleErrorZ*)(arg & ~1);
5940         CHECK(val->result_ok);
5941         return *val->contents.result;
5942 }
5943 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5944         LDKCResult_NonePeerHandleErrorZ *val = (LDKCResult_NonePeerHandleErrorZ*)(arg & ~1);
5945         CHECK(!val->result_ok);
5946         LDKPeerHandleError err_var = (*val->contents.err);
5947         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5948         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5949         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5950         return err_ref;
5951 }
5952 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolPeerHandleErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5953         return ((LDKCResult_boolPeerHandleErrorZ*)arg)->result_ok;
5954 }
5955 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolPeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5956         LDKCResult_boolPeerHandleErrorZ *val = (LDKCResult_boolPeerHandleErrorZ*)(arg & ~1);
5957         CHECK(val->result_ok);
5958         return *val->contents.result;
5959 }
5960 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolPeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5961         LDKCResult_boolPeerHandleErrorZ *val = (LDKCResult_boolPeerHandleErrorZ*)(arg & ~1);
5962         CHECK(!val->result_ok);
5963         LDKPeerHandleError err_var = (*val->contents.err);
5964         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5965         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5966         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5967         return err_ref;
5968 }
5969 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeIdDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5970         return ((LDKCResult_NodeIdDecodeErrorZ*)arg)->result_ok;
5971 }
5972 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeIdDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5973         LDKCResult_NodeIdDecodeErrorZ *val = (LDKCResult_NodeIdDecodeErrorZ*)(arg & ~1);
5974         CHECK(val->result_ok);
5975         LDKNodeId res_var = (*val->contents.result);
5976         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5977         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5978         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5979         return res_ref;
5980 }
5981 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeIdDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5982         LDKCResult_NodeIdDecodeErrorZ *val = (LDKCResult_NodeIdDecodeErrorZ*)(arg & ~1);
5983         CHECK(!val->result_ok);
5984         LDKDecodeError err_var = (*val->contents.err);
5985         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5986         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5987         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5988         return err_ref;
5989 }
5990 typedef struct LDKAccess_JCalls {
5991         atomic_size_t refcnt;
5992         JavaVM *vm;
5993         jweak o;
5994         jmethodID get_utxo_meth;
5995 } LDKAccess_JCalls;
5996 static void LDKAccess_JCalls_free(void* this_arg) {
5997         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
5998         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5999                 JNIEnv *env;
6000                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6001                 if (get_jenv_res == JNI_EDETACHED) {
6002                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6003                 } else {
6004                         DO_ASSERT(get_jenv_res == JNI_OK);
6005                 }
6006                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6007                 if (get_jenv_res == JNI_EDETACHED) {
6008                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6009                 }
6010                 FREE(j_calls);
6011         }
6012 }
6013 LDKCResult_TxOutAccessErrorZ get_utxo_LDKAccess_jcall(const void* this_arg, const uint8_t (* genesis_hash)[32], uint64_t short_channel_id) {
6014         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
6015         JNIEnv *env;
6016         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6017         if (get_jenv_res == JNI_EDETACHED) {
6018                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6019         } else {
6020                 DO_ASSERT(get_jenv_res == JNI_OK);
6021         }
6022         int8_tArray genesis_hash_arr = (*env)->NewByteArray(env, 32);
6023         (*env)->SetByteArrayRegion(env, genesis_hash_arr, 0, 32, *genesis_hash);
6024         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6025         CHECK(obj != NULL);
6026         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_utxo_meth, genesis_hash_arr, short_channel_id);
6027         if ((*env)->ExceptionCheck(env)) {
6028                 (*env)->ExceptionDescribe(env);
6029                 (*env)->FatalError(env, "A call to get_utxo in LDKAccess from rust threw an exception.");
6030         }
6031         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
6032         CHECK_ACCESS(ret_ptr);
6033         LDKCResult_TxOutAccessErrorZ ret_conv = *(LDKCResult_TxOutAccessErrorZ*)(ret_ptr);
6034         ret_conv = CResult_TxOutAccessErrorZ_clone((LDKCResult_TxOutAccessErrorZ*)(((uint64_t)ret) & ~1));
6035         if (get_jenv_res == JNI_EDETACHED) {
6036                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6037         }
6038         return ret_conv;
6039 }
6040 static void LDKAccess_JCalls_cloned(LDKAccess* new_obj) {
6041         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) new_obj->this_arg;
6042         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6043 }
6044 static inline LDKAccess LDKAccess_init (JNIEnv *env, jclass clz, jobject o) {
6045         jclass c = (*env)->GetObjectClass(env, o);
6046         CHECK(c != NULL);
6047         LDKAccess_JCalls *calls = MALLOC(sizeof(LDKAccess_JCalls), "LDKAccess_JCalls");
6048         atomic_init(&calls->refcnt, 1);
6049         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6050         calls->o = (*env)->NewWeakGlobalRef(env, o);
6051         calls->get_utxo_meth = (*env)->GetMethodID(env, c, "get_utxo", "([BJ)J");
6052         CHECK(calls->get_utxo_meth != NULL);
6053
6054         LDKAccess ret = {
6055                 .this_arg = (void*) calls,
6056                 .get_utxo = get_utxo_LDKAccess_jcall,
6057                 .free = LDKAccess_JCalls_free,
6058         };
6059         return ret;
6060 }
6061 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKAccess_1new(JNIEnv *env, jclass clz, jobject o) {
6062         LDKAccess *res_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
6063         *res_ptr = LDKAccess_init(env, clz, o);
6064         return (uint64_t)res_ptr;
6065 }
6066 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) {
6067         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
6068         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6069         LDKAccess* this_arg_conv = (LDKAccess*)this_arg_ptr;
6070         unsigned char genesis_hash_arr[32];
6071         CHECK((*env)->GetArrayLength(env, genesis_hash) == 32);
6072         (*env)->GetByteArrayRegion(env, genesis_hash, 0, 32, genesis_hash_arr);
6073         unsigned char (*genesis_hash_ref)[32] = &genesis_hash_arr;
6074         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
6075         *ret_conv = (this_arg_conv->get_utxo)(this_arg_conv->this_arg, genesis_hash_ref, short_channel_id);
6076         return (uint64_t)ret_conv;
6077 }
6078
6079 static jclass LDKCOption_AccessZ_Some_class = NULL;
6080 static jmethodID LDKCOption_AccessZ_Some_meth = NULL;
6081 static jclass LDKCOption_AccessZ_None_class = NULL;
6082 static jmethodID LDKCOption_AccessZ_None_meth = NULL;
6083 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1AccessZ_init (JNIEnv *env, jclass clz) {
6084         LDKCOption_AccessZ_Some_class =
6085                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_AccessZ$Some;"));
6086         CHECK(LDKCOption_AccessZ_Some_class != NULL);
6087         LDKCOption_AccessZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_AccessZ_Some_class, "<init>", "(J)V");
6088         CHECK(LDKCOption_AccessZ_Some_meth != NULL);
6089         LDKCOption_AccessZ_None_class =
6090                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_AccessZ$None;"));
6091         CHECK(LDKCOption_AccessZ_None_class != NULL);
6092         LDKCOption_AccessZ_None_meth = (*env)->GetMethodID(env, LDKCOption_AccessZ_None_class, "<init>", "()V");
6093         CHECK(LDKCOption_AccessZ_None_meth != NULL);
6094 }
6095 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1AccessZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
6096         LDKCOption_AccessZ *obj = (LDKCOption_AccessZ*)(ptr & ~1);
6097         switch(obj->tag) {
6098                 case LDKCOption_AccessZ_Some: {
6099                         LDKAccess* some_ret =MALLOC(sizeof(LDKAccess), "LDKAccess");
6100                         *some_ret = obj->some;
6101                         // Warning: We likely need to clone here, but no clone is available, so we just do it for Java instances
6102                         if ((*some_ret).free == LDKAccess_JCalls_free) {
6103                                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
6104                                 LDKAccess_JCalls_cloned(&(*some_ret));
6105                         }
6106                         return (*env)->NewObject(env, LDKCOption_AccessZ_Some_class, LDKCOption_AccessZ_Some_meth, (uint64_t)some_ret);
6107                 }
6108                 case LDKCOption_AccessZ_None: {
6109                         return (*env)->NewObject(env, LDKCOption_AccessZ_None_class, LDKCOption_AccessZ_None_meth);
6110                 }
6111                 default: abort();
6112         }
6113 }
6114 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DirectionalChannelInfoDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6115         return ((LDKCResult_DirectionalChannelInfoDecodeErrorZ*)arg)->result_ok;
6116 }
6117 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DirectionalChannelInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6118         LDKCResult_DirectionalChannelInfoDecodeErrorZ *val = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(arg & ~1);
6119         CHECK(val->result_ok);
6120         LDKDirectionalChannelInfo res_var = (*val->contents.result);
6121         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6122         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6123         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6124         return res_ref;
6125 }
6126 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DirectionalChannelInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6127         LDKCResult_DirectionalChannelInfoDecodeErrorZ *val = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(arg & ~1);
6128         CHECK(!val->result_ok);
6129         LDKDecodeError err_var = (*val->contents.err);
6130         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6131         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6132         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6133         return err_ref;
6134 }
6135 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelInfoDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6136         return ((LDKCResult_ChannelInfoDecodeErrorZ*)arg)->result_ok;
6137 }
6138 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6139         LDKCResult_ChannelInfoDecodeErrorZ *val = (LDKCResult_ChannelInfoDecodeErrorZ*)(arg & ~1);
6140         CHECK(val->result_ok);
6141         LDKChannelInfo res_var = (*val->contents.result);
6142         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6143         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6144         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6145         return res_ref;
6146 }
6147 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6148         LDKCResult_ChannelInfoDecodeErrorZ *val = (LDKCResult_ChannelInfoDecodeErrorZ*)(arg & ~1);
6149         CHECK(!val->result_ok);
6150         LDKDecodeError err_var = (*val->contents.err);
6151         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6152         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6153         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6154         return err_ref;
6155 }
6156 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RoutingFeesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6157         return ((LDKCResult_RoutingFeesDecodeErrorZ*)arg)->result_ok;
6158 }
6159 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RoutingFeesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6160         LDKCResult_RoutingFeesDecodeErrorZ *val = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
6161         CHECK(val->result_ok);
6162         LDKRoutingFees res_var = (*val->contents.result);
6163         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6164         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6165         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6166         return res_ref;
6167 }
6168 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RoutingFeesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6169         LDKCResult_RoutingFeesDecodeErrorZ *val = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
6170         CHECK(!val->result_ok);
6171         LDKDecodeError err_var = (*val->contents.err);
6172         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6173         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6174         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6175         return err_ref;
6176 }
6177 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementInfoDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6178         return ((LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)arg)->result_ok;
6179 }
6180 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6181         LDKCResult_NodeAnnouncementInfoDecodeErrorZ *val = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
6182         CHECK(val->result_ok);
6183         LDKNodeAnnouncementInfo res_var = (*val->contents.result);
6184         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6185         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6186         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6187         return res_ref;
6188 }
6189 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6190         LDKCResult_NodeAnnouncementInfoDecodeErrorZ *val = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
6191         CHECK(!val->result_ok);
6192         LDKDecodeError err_var = (*val->contents.err);
6193         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6194         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6195         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6196         return err_ref;
6197 }
6198 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1u64Z_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
6199         LDKCVec_u64Z *ret = MALLOC(sizeof(LDKCVec_u64Z), "LDKCVec_u64Z");
6200         ret->datalen = (*env)->GetArrayLength(env, elems);
6201         if (ret->datalen == 0) {
6202                 ret->data = NULL;
6203         } else {
6204                 ret->data = MALLOC(sizeof(uint64_t) * ret->datalen, "LDKCVec_u64Z Data");
6205                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
6206                 for (size_t i = 0; i < ret->datalen; i++) {
6207                         ret->data[i] = java_elems[i];
6208                 }
6209                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
6210         }
6211         return (uint64_t)ret;
6212 }
6213 static inline LDKCVec_u64Z CVec_u64Z_clone(const LDKCVec_u64Z *orig) {
6214         LDKCVec_u64Z ret = { .data = MALLOC(sizeof(int64_t) * orig->datalen, "LDKCVec_u64Z clone bytes"), .datalen = orig->datalen };
6215         memcpy(ret.data, orig->data, sizeof(int64_t) * ret.datalen);
6216         return ret;
6217 }
6218 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeInfoDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6219         return ((LDKCResult_NodeInfoDecodeErrorZ*)arg)->result_ok;
6220 }
6221 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6222         LDKCResult_NodeInfoDecodeErrorZ *val = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
6223         CHECK(val->result_ok);
6224         LDKNodeInfo res_var = (*val->contents.result);
6225         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6226         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6227         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6228         return res_ref;
6229 }
6230 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6231         LDKCResult_NodeInfoDecodeErrorZ *val = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
6232         CHECK(!val->result_ok);
6233         LDKDecodeError err_var = (*val->contents.err);
6234         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6235         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6236         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6237         return err_ref;
6238 }
6239 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetworkGraphDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6240         return ((LDKCResult_NetworkGraphDecodeErrorZ*)arg)->result_ok;
6241 }
6242 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetworkGraphDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6243         LDKCResult_NetworkGraphDecodeErrorZ *val = (LDKCResult_NetworkGraphDecodeErrorZ*)(arg & ~1);
6244         CHECK(val->result_ok);
6245         LDKNetworkGraph res_var = (*val->contents.result);
6246         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6247         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6248         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6249         return res_ref;
6250 }
6251 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetworkGraphDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6252         LDKCResult_NetworkGraphDecodeErrorZ *val = (LDKCResult_NetworkGraphDecodeErrorZ*)(arg & ~1);
6253         CHECK(!val->result_ok);
6254         LDKDecodeError err_var = (*val->contents.err);
6255         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6256         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6257         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6258         return err_ref;
6259 }
6260 static jclass LDKCOption_CVec_NetAddressZZ_Some_class = NULL;
6261 static jmethodID LDKCOption_CVec_NetAddressZZ_Some_meth = NULL;
6262 static jclass LDKCOption_CVec_NetAddressZZ_None_class = NULL;
6263 static jmethodID LDKCOption_CVec_NetAddressZZ_None_meth = NULL;
6264 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1CVec_1NetAddressZZ_init (JNIEnv *env, jclass clz) {
6265         LDKCOption_CVec_NetAddressZZ_Some_class =
6266                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_CVec_NetAddressZZ$Some;"));
6267         CHECK(LDKCOption_CVec_NetAddressZZ_Some_class != NULL);
6268         LDKCOption_CVec_NetAddressZZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_CVec_NetAddressZZ_Some_class, "<init>", "([J)V");
6269         CHECK(LDKCOption_CVec_NetAddressZZ_Some_meth != NULL);
6270         LDKCOption_CVec_NetAddressZZ_None_class =
6271                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_CVec_NetAddressZZ$None;"));
6272         CHECK(LDKCOption_CVec_NetAddressZZ_None_class != NULL);
6273         LDKCOption_CVec_NetAddressZZ_None_meth = (*env)->GetMethodID(env, LDKCOption_CVec_NetAddressZZ_None_class, "<init>", "()V");
6274         CHECK(LDKCOption_CVec_NetAddressZZ_None_meth != NULL);
6275 }
6276 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1CVec_1NetAddressZZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
6277         LDKCOption_CVec_NetAddressZZ *obj = (LDKCOption_CVec_NetAddressZZ*)(ptr & ~1);
6278         switch(obj->tag) {
6279                 case LDKCOption_CVec_NetAddressZZ_Some: {
6280                         LDKCVec_NetAddressZ some_var = obj->some;
6281                         int64_tArray some_arr = (*env)->NewLongArray(env, some_var.datalen);
6282                         int64_t *some_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, some_arr, NULL);
6283                         for (size_t m = 0; m < some_var.datalen; m++) {
6284                                 uint64_t some_conv_12_ref = ((uint64_t)&some_var.data[m]) | 1;
6285                                 some_arr_ptr[m] = some_conv_12_ref;
6286                         }
6287                         (*env)->ReleasePrimitiveArrayCritical(env, some_arr, some_arr_ptr, 0);
6288                         return (*env)->NewObject(env, LDKCOption_CVec_NetAddressZZ_Some_class, LDKCOption_CVec_NetAddressZZ_Some_meth, some_arr);
6289                 }
6290                 case LDKCOption_CVec_NetAddressZZ_None: {
6291                         return (*env)->NewObject(env, LDKCOption_CVec_NetAddressZZ_None_class, LDKCOption_CVec_NetAddressZZ_None_meth);
6292                 }
6293                 default: abort();
6294         }
6295 }
6296 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressu8Z_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6297         return ((LDKCResult_NetAddressu8Z*)arg)->result_ok;
6298 }
6299 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressu8Z_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6300         LDKCResult_NetAddressu8Z *val = (LDKCResult_NetAddressu8Z*)(arg & ~1);
6301         CHECK(val->result_ok);
6302         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
6303         return res_ref;
6304 }
6305 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressu8Z_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6306         LDKCResult_NetAddressu8Z *val = (LDKCResult_NetAddressu8Z*)(arg & ~1);
6307         CHECK(!val->result_ok);
6308         return *val->contents.err;
6309 }
6310 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CResult_1NetAddressu8ZDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6311         return ((LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)arg)->result_ok;
6312 }
6313 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CResult_1NetAddressu8ZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6314         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ *val = (LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(arg & ~1);
6315         CHECK(val->result_ok);
6316         LDKCResult_NetAddressu8Z* res_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
6317         *res_conv = (*val->contents.result);
6318         *res_conv = CResult_NetAddressu8Z_clone(res_conv);
6319         return (uint64_t)res_conv;
6320 }
6321 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CResult_1NetAddressu8ZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6322         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ *val = (LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(arg & ~1);
6323         CHECK(!val->result_ok);
6324         LDKDecodeError err_var = (*val->contents.err);
6325         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6326         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6327         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6328         return err_ref;
6329 }
6330 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6331         return ((LDKCResult_NetAddressDecodeErrorZ*)arg)->result_ok;
6332 }
6333 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6334         LDKCResult_NetAddressDecodeErrorZ *val = (LDKCResult_NetAddressDecodeErrorZ*)(arg & ~1);
6335         CHECK(val->result_ok);
6336         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
6337         return res_ref;
6338 }
6339 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6340         LDKCResult_NetAddressDecodeErrorZ *val = (LDKCResult_NetAddressDecodeErrorZ*)(arg & ~1);
6341         CHECK(!val->result_ok);
6342         LDKDecodeError err_var = (*val->contents.err);
6343         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6344         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6345         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6346         return err_ref;
6347 }
6348 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1UpdateAddHTLCZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
6349         LDKCVec_UpdateAddHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateAddHTLCZ), "LDKCVec_UpdateAddHTLCZ");
6350         ret->datalen = (*env)->GetArrayLength(env, elems);
6351         if (ret->datalen == 0) {
6352                 ret->data = NULL;
6353         } else {
6354                 ret->data = MALLOC(sizeof(LDKUpdateAddHTLC) * ret->datalen, "LDKCVec_UpdateAddHTLCZ Data");
6355                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
6356                 for (size_t i = 0; i < ret->datalen; i++) {
6357                         int64_t arr_elem = java_elems[i];
6358                         LDKUpdateAddHTLC arr_elem_conv;
6359                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
6360                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
6361                         arr_elem_conv = UpdateAddHTLC_clone(&arr_elem_conv);
6362                         ret->data[i] = arr_elem_conv;
6363                 }
6364                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
6365         }
6366         return (uint64_t)ret;
6367 }
6368 static inline LDKCVec_UpdateAddHTLCZ CVec_UpdateAddHTLCZ_clone(const LDKCVec_UpdateAddHTLCZ *orig) {
6369         LDKCVec_UpdateAddHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateAddHTLC) * orig->datalen, "LDKCVec_UpdateAddHTLCZ clone bytes"), .datalen = orig->datalen };
6370         for (size_t i = 0; i < ret.datalen; i++) {
6371                 ret.data[i] = UpdateAddHTLC_clone(&orig->data[i]);
6372         }
6373         return ret;
6374 }
6375 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1UpdateFulfillHTLCZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
6376         LDKCVec_UpdateFulfillHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateFulfillHTLCZ), "LDKCVec_UpdateFulfillHTLCZ");
6377         ret->datalen = (*env)->GetArrayLength(env, elems);
6378         if (ret->datalen == 0) {
6379                 ret->data = NULL;
6380         } else {
6381                 ret->data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * ret->datalen, "LDKCVec_UpdateFulfillHTLCZ Data");
6382                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
6383                 for (size_t i = 0; i < ret->datalen; i++) {
6384                         int64_t arr_elem = java_elems[i];
6385                         LDKUpdateFulfillHTLC arr_elem_conv;
6386                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
6387                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
6388                         arr_elem_conv = UpdateFulfillHTLC_clone(&arr_elem_conv);
6389                         ret->data[i] = arr_elem_conv;
6390                 }
6391                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
6392         }
6393         return (uint64_t)ret;
6394 }
6395 static inline LDKCVec_UpdateFulfillHTLCZ CVec_UpdateFulfillHTLCZ_clone(const LDKCVec_UpdateFulfillHTLCZ *orig) {
6396         LDKCVec_UpdateFulfillHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * orig->datalen, "LDKCVec_UpdateFulfillHTLCZ clone bytes"), .datalen = orig->datalen };
6397         for (size_t i = 0; i < ret.datalen; i++) {
6398                 ret.data[i] = UpdateFulfillHTLC_clone(&orig->data[i]);
6399         }
6400         return ret;
6401 }
6402 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1UpdateFailHTLCZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
6403         LDKCVec_UpdateFailHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateFailHTLCZ), "LDKCVec_UpdateFailHTLCZ");
6404         ret->datalen = (*env)->GetArrayLength(env, elems);
6405         if (ret->datalen == 0) {
6406                 ret->data = NULL;
6407         } else {
6408                 ret->data = MALLOC(sizeof(LDKUpdateFailHTLC) * ret->datalen, "LDKCVec_UpdateFailHTLCZ Data");
6409                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
6410                 for (size_t i = 0; i < ret->datalen; i++) {
6411                         int64_t arr_elem = java_elems[i];
6412                         LDKUpdateFailHTLC arr_elem_conv;
6413                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
6414                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
6415                         arr_elem_conv = UpdateFailHTLC_clone(&arr_elem_conv);
6416                         ret->data[i] = arr_elem_conv;
6417                 }
6418                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
6419         }
6420         return (uint64_t)ret;
6421 }
6422 static inline LDKCVec_UpdateFailHTLCZ CVec_UpdateFailHTLCZ_clone(const LDKCVec_UpdateFailHTLCZ *orig) {
6423         LDKCVec_UpdateFailHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailHTLC) * orig->datalen, "LDKCVec_UpdateFailHTLCZ clone bytes"), .datalen = orig->datalen };
6424         for (size_t i = 0; i < ret.datalen; i++) {
6425                 ret.data[i] = UpdateFailHTLC_clone(&orig->data[i]);
6426         }
6427         return ret;
6428 }
6429 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1UpdateFailMalformedHTLCZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
6430         LDKCVec_UpdateFailMalformedHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateFailMalformedHTLCZ), "LDKCVec_UpdateFailMalformedHTLCZ");
6431         ret->datalen = (*env)->GetArrayLength(env, elems);
6432         if (ret->datalen == 0) {
6433                 ret->data = NULL;
6434         } else {
6435                 ret->data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * ret->datalen, "LDKCVec_UpdateFailMalformedHTLCZ Data");
6436                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
6437                 for (size_t i = 0; i < ret->datalen; i++) {
6438                         int64_t arr_elem = java_elems[i];
6439                         LDKUpdateFailMalformedHTLC arr_elem_conv;
6440                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
6441                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
6442                         arr_elem_conv = UpdateFailMalformedHTLC_clone(&arr_elem_conv);
6443                         ret->data[i] = arr_elem_conv;
6444                 }
6445                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
6446         }
6447         return (uint64_t)ret;
6448 }
6449 static inline LDKCVec_UpdateFailMalformedHTLCZ CVec_UpdateFailMalformedHTLCZ_clone(const LDKCVec_UpdateFailMalformedHTLCZ *orig) {
6450         LDKCVec_UpdateFailMalformedHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * orig->datalen, "LDKCVec_UpdateFailMalformedHTLCZ clone bytes"), .datalen = orig->datalen };
6451         for (size_t i = 0; i < ret.datalen; i++) {
6452                 ret.data[i] = UpdateFailMalformedHTLC_clone(&orig->data[i]);
6453         }
6454         return ret;
6455 }
6456 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AcceptChannelDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6457         return ((LDKCResult_AcceptChannelDecodeErrorZ*)arg)->result_ok;
6458 }
6459 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AcceptChannelDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6460         LDKCResult_AcceptChannelDecodeErrorZ *val = (LDKCResult_AcceptChannelDecodeErrorZ*)(arg & ~1);
6461         CHECK(val->result_ok);
6462         LDKAcceptChannel res_var = (*val->contents.result);
6463         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6464         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6465         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6466         return res_ref;
6467 }
6468 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AcceptChannelDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6469         LDKCResult_AcceptChannelDecodeErrorZ *val = (LDKCResult_AcceptChannelDecodeErrorZ*)(arg & ~1);
6470         CHECK(!val->result_ok);
6471         LDKDecodeError err_var = (*val->contents.err);
6472         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6473         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6474         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6475         return err_ref;
6476 }
6477 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AnnouncementSignaturesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6478         return ((LDKCResult_AnnouncementSignaturesDecodeErrorZ*)arg)->result_ok;
6479 }
6480 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AnnouncementSignaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6481         LDKCResult_AnnouncementSignaturesDecodeErrorZ *val = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(arg & ~1);
6482         CHECK(val->result_ok);
6483         LDKAnnouncementSignatures res_var = (*val->contents.result);
6484         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6485         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6486         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6487         return res_ref;
6488 }
6489 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AnnouncementSignaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6490         LDKCResult_AnnouncementSignaturesDecodeErrorZ *val = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(arg & ~1);
6491         CHECK(!val->result_ok);
6492         LDKDecodeError err_var = (*val->contents.err);
6493         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6494         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6495         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6496         return err_ref;
6497 }
6498 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelReestablishDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6499         return ((LDKCResult_ChannelReestablishDecodeErrorZ*)arg)->result_ok;
6500 }
6501 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelReestablishDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6502         LDKCResult_ChannelReestablishDecodeErrorZ *val = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
6503         CHECK(val->result_ok);
6504         LDKChannelReestablish res_var = (*val->contents.result);
6505         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6506         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6507         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6508         return res_ref;
6509 }
6510 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelReestablishDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6511         LDKCResult_ChannelReestablishDecodeErrorZ *val = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
6512         CHECK(!val->result_ok);
6513         LDKDecodeError err_var = (*val->contents.err);
6514         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6515         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6516         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6517         return err_ref;
6518 }
6519 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ClosingSignedDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6520         return ((LDKCResult_ClosingSignedDecodeErrorZ*)arg)->result_ok;
6521 }
6522 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ClosingSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6523         LDKCResult_ClosingSignedDecodeErrorZ *val = (LDKCResult_ClosingSignedDecodeErrorZ*)(arg & ~1);
6524         CHECK(val->result_ok);
6525         LDKClosingSigned res_var = (*val->contents.result);
6526         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6527         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6528         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6529         return res_ref;
6530 }
6531 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ClosingSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6532         LDKCResult_ClosingSignedDecodeErrorZ *val = (LDKCResult_ClosingSignedDecodeErrorZ*)(arg & ~1);
6533         CHECK(!val->result_ok);
6534         LDKDecodeError err_var = (*val->contents.err);
6535         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6536         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6537         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6538         return err_ref;
6539 }
6540 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ClosingSignedFeeRangeDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6541         return ((LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)arg)->result_ok;
6542 }
6543 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ClosingSignedFeeRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6544         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *val = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(arg & ~1);
6545         CHECK(val->result_ok);
6546         LDKClosingSignedFeeRange res_var = (*val->contents.result);
6547         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6548         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6549         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6550         return res_ref;
6551 }
6552 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ClosingSignedFeeRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6553         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *val = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(arg & ~1);
6554         CHECK(!val->result_ok);
6555         LDKDecodeError err_var = (*val->contents.err);
6556         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6557         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6558         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6559         return err_ref;
6560 }
6561 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentSignedDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6562         return ((LDKCResult_CommitmentSignedDecodeErrorZ*)arg)->result_ok;
6563 }
6564 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6565         LDKCResult_CommitmentSignedDecodeErrorZ *val = (LDKCResult_CommitmentSignedDecodeErrorZ*)(arg & ~1);
6566         CHECK(val->result_ok);
6567         LDKCommitmentSigned res_var = (*val->contents.result);
6568         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6569         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6570         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6571         return res_ref;
6572 }
6573 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6574         LDKCResult_CommitmentSignedDecodeErrorZ *val = (LDKCResult_CommitmentSignedDecodeErrorZ*)(arg & ~1);
6575         CHECK(!val->result_ok);
6576         LDKDecodeError err_var = (*val->contents.err);
6577         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6578         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6579         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6580         return err_ref;
6581 }
6582 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingCreatedDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6583         return ((LDKCResult_FundingCreatedDecodeErrorZ*)arg)->result_ok;
6584 }
6585 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingCreatedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6586         LDKCResult_FundingCreatedDecodeErrorZ *val = (LDKCResult_FundingCreatedDecodeErrorZ*)(arg & ~1);
6587         CHECK(val->result_ok);
6588         LDKFundingCreated res_var = (*val->contents.result);
6589         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6590         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6591         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6592         return res_ref;
6593 }
6594 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingCreatedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6595         LDKCResult_FundingCreatedDecodeErrorZ *val = (LDKCResult_FundingCreatedDecodeErrorZ*)(arg & ~1);
6596         CHECK(!val->result_ok);
6597         LDKDecodeError err_var = (*val->contents.err);
6598         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6599         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6600         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6601         return err_ref;
6602 }
6603 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingSignedDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6604         return ((LDKCResult_FundingSignedDecodeErrorZ*)arg)->result_ok;
6605 }
6606 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6607         LDKCResult_FundingSignedDecodeErrorZ *val = (LDKCResult_FundingSignedDecodeErrorZ*)(arg & ~1);
6608         CHECK(val->result_ok);
6609         LDKFundingSigned res_var = (*val->contents.result);
6610         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6611         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6612         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6613         return res_ref;
6614 }
6615 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6616         LDKCResult_FundingSignedDecodeErrorZ *val = (LDKCResult_FundingSignedDecodeErrorZ*)(arg & ~1);
6617         CHECK(!val->result_ok);
6618         LDKDecodeError err_var = (*val->contents.err);
6619         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6620         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6621         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6622         return err_ref;
6623 }
6624 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingLockedDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6625         return ((LDKCResult_FundingLockedDecodeErrorZ*)arg)->result_ok;
6626 }
6627 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingLockedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6628         LDKCResult_FundingLockedDecodeErrorZ *val = (LDKCResult_FundingLockedDecodeErrorZ*)(arg & ~1);
6629         CHECK(val->result_ok);
6630         LDKFundingLocked res_var = (*val->contents.result);
6631         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6632         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6633         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6634         return res_ref;
6635 }
6636 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingLockedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6637         LDKCResult_FundingLockedDecodeErrorZ *val = (LDKCResult_FundingLockedDecodeErrorZ*)(arg & ~1);
6638         CHECK(!val->result_ok);
6639         LDKDecodeError err_var = (*val->contents.err);
6640         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6641         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6642         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6643         return err_ref;
6644 }
6645 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6646         return ((LDKCResult_InitDecodeErrorZ*)arg)->result_ok;
6647 }
6648 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6649         LDKCResult_InitDecodeErrorZ *val = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
6650         CHECK(val->result_ok);
6651         LDKInit res_var = (*val->contents.result);
6652         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6653         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6654         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6655         return res_ref;
6656 }
6657 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6658         LDKCResult_InitDecodeErrorZ *val = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
6659         CHECK(!val->result_ok);
6660         LDKDecodeError err_var = (*val->contents.err);
6661         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6662         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6663         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6664         return err_ref;
6665 }
6666 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OpenChannelDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6667         return ((LDKCResult_OpenChannelDecodeErrorZ*)arg)->result_ok;
6668 }
6669 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OpenChannelDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6670         LDKCResult_OpenChannelDecodeErrorZ *val = (LDKCResult_OpenChannelDecodeErrorZ*)(arg & ~1);
6671         CHECK(val->result_ok);
6672         LDKOpenChannel res_var = (*val->contents.result);
6673         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6674         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6675         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6676         return res_ref;
6677 }
6678 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OpenChannelDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6679         LDKCResult_OpenChannelDecodeErrorZ *val = (LDKCResult_OpenChannelDecodeErrorZ*)(arg & ~1);
6680         CHECK(!val->result_ok);
6681         LDKDecodeError err_var = (*val->contents.err);
6682         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6683         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6684         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6685         return err_ref;
6686 }
6687 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RevokeAndACKDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6688         return ((LDKCResult_RevokeAndACKDecodeErrorZ*)arg)->result_ok;
6689 }
6690 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RevokeAndACKDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6691         LDKCResult_RevokeAndACKDecodeErrorZ *val = (LDKCResult_RevokeAndACKDecodeErrorZ*)(arg & ~1);
6692         CHECK(val->result_ok);
6693         LDKRevokeAndACK res_var = (*val->contents.result);
6694         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6695         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6696         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6697         return res_ref;
6698 }
6699 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RevokeAndACKDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6700         LDKCResult_RevokeAndACKDecodeErrorZ *val = (LDKCResult_RevokeAndACKDecodeErrorZ*)(arg & ~1);
6701         CHECK(!val->result_ok);
6702         LDKDecodeError err_var = (*val->contents.err);
6703         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6704         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6705         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6706         return err_ref;
6707 }
6708 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6709         return ((LDKCResult_ShutdownDecodeErrorZ*)arg)->result_ok;
6710 }
6711 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6712         LDKCResult_ShutdownDecodeErrorZ *val = (LDKCResult_ShutdownDecodeErrorZ*)(arg & ~1);
6713         CHECK(val->result_ok);
6714         LDKShutdown res_var = (*val->contents.result);
6715         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6716         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6717         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6718         return res_ref;
6719 }
6720 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6721         LDKCResult_ShutdownDecodeErrorZ *val = (LDKCResult_ShutdownDecodeErrorZ*)(arg & ~1);
6722         CHECK(!val->result_ok);
6723         LDKDecodeError err_var = (*val->contents.err);
6724         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6725         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6726         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6727         return err_ref;
6728 }
6729 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailHTLCDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6730         return ((LDKCResult_UpdateFailHTLCDecodeErrorZ*)arg)->result_ok;
6731 }
6732 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6733         LDKCResult_UpdateFailHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(arg & ~1);
6734         CHECK(val->result_ok);
6735         LDKUpdateFailHTLC res_var = (*val->contents.result);
6736         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6737         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6738         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6739         return res_ref;
6740 }
6741 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6742         LDKCResult_UpdateFailHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(arg & ~1);
6743         CHECK(!val->result_ok);
6744         LDKDecodeError err_var = (*val->contents.err);
6745         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6746         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6747         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6748         return err_ref;
6749 }
6750 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailMalformedHTLCDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6751         return ((LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)arg)->result_ok;
6752 }
6753 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailMalformedHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6754         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(arg & ~1);
6755         CHECK(val->result_ok);
6756         LDKUpdateFailMalformedHTLC res_var = (*val->contents.result);
6757         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6758         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6759         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6760         return res_ref;
6761 }
6762 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailMalformedHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6763         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(arg & ~1);
6764         CHECK(!val->result_ok);
6765         LDKDecodeError err_var = (*val->contents.err);
6766         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6767         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6768         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6769         return err_ref;
6770 }
6771 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFeeDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6772         return ((LDKCResult_UpdateFeeDecodeErrorZ*)arg)->result_ok;
6773 }
6774 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFeeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6775         LDKCResult_UpdateFeeDecodeErrorZ *val = (LDKCResult_UpdateFeeDecodeErrorZ*)(arg & ~1);
6776         CHECK(val->result_ok);
6777         LDKUpdateFee res_var = (*val->contents.result);
6778         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6779         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6780         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6781         return res_ref;
6782 }
6783 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFeeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6784         LDKCResult_UpdateFeeDecodeErrorZ *val = (LDKCResult_UpdateFeeDecodeErrorZ*)(arg & ~1);
6785         CHECK(!val->result_ok);
6786         LDKDecodeError err_var = (*val->contents.err);
6787         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6788         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6789         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6790         return err_ref;
6791 }
6792 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFulfillHTLCDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6793         return ((LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)arg)->result_ok;
6794 }
6795 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFulfillHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6796         LDKCResult_UpdateFulfillHTLCDecodeErrorZ *val = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(arg & ~1);
6797         CHECK(val->result_ok);
6798         LDKUpdateFulfillHTLC res_var = (*val->contents.result);
6799         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6800         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6801         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6802         return res_ref;
6803 }
6804 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFulfillHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6805         LDKCResult_UpdateFulfillHTLCDecodeErrorZ *val = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(arg & ~1);
6806         CHECK(!val->result_ok);
6807         LDKDecodeError err_var = (*val->contents.err);
6808         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6809         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6810         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6811         return err_ref;
6812 }
6813 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateAddHTLCDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6814         return ((LDKCResult_UpdateAddHTLCDecodeErrorZ*)arg)->result_ok;
6815 }
6816 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateAddHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6817         LDKCResult_UpdateAddHTLCDecodeErrorZ *val = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(arg & ~1);
6818         CHECK(val->result_ok);
6819         LDKUpdateAddHTLC res_var = (*val->contents.result);
6820         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6821         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6822         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6823         return res_ref;
6824 }
6825 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateAddHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6826         LDKCResult_UpdateAddHTLCDecodeErrorZ *val = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(arg & ~1);
6827         CHECK(!val->result_ok);
6828         LDKDecodeError err_var = (*val->contents.err);
6829         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6830         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6831         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6832         return err_ref;
6833 }
6834 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PingDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6835         return ((LDKCResult_PingDecodeErrorZ*)arg)->result_ok;
6836 }
6837 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PingDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6838         LDKCResult_PingDecodeErrorZ *val = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
6839         CHECK(val->result_ok);
6840         LDKPing res_var = (*val->contents.result);
6841         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6842         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6843         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6844         return res_ref;
6845 }
6846 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PingDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6847         LDKCResult_PingDecodeErrorZ *val = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
6848         CHECK(!val->result_ok);
6849         LDKDecodeError err_var = (*val->contents.err);
6850         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6851         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6852         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6853         return err_ref;
6854 }
6855 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PongDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6856         return ((LDKCResult_PongDecodeErrorZ*)arg)->result_ok;
6857 }
6858 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PongDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6859         LDKCResult_PongDecodeErrorZ *val = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
6860         CHECK(val->result_ok);
6861         LDKPong res_var = (*val->contents.result);
6862         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6863         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6864         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6865         return res_ref;
6866 }
6867 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PongDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6868         LDKCResult_PongDecodeErrorZ *val = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
6869         CHECK(!val->result_ok);
6870         LDKDecodeError err_var = (*val->contents.err);
6871         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6872         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6873         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6874         return err_ref;
6875 }
6876 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelAnnouncementDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6877         return ((LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)arg)->result_ok;
6878 }
6879 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6880         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
6881         CHECK(val->result_ok);
6882         LDKUnsignedChannelAnnouncement res_var = (*val->contents.result);
6883         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6884         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6885         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6886         return res_ref;
6887 }
6888 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6889         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
6890         CHECK(!val->result_ok);
6891         LDKDecodeError err_var = (*val->contents.err);
6892         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6893         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6894         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6895         return err_ref;
6896 }
6897 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelAnnouncementDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6898         return ((LDKCResult_ChannelAnnouncementDecodeErrorZ*)arg)->result_ok;
6899 }
6900 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6901         LDKCResult_ChannelAnnouncementDecodeErrorZ *val = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(arg & ~1);
6902         CHECK(val->result_ok);
6903         LDKChannelAnnouncement res_var = (*val->contents.result);
6904         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6905         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6906         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6907         return res_ref;
6908 }
6909 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6910         LDKCResult_ChannelAnnouncementDecodeErrorZ *val = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(arg & ~1);
6911         CHECK(!val->result_ok);
6912         LDKDecodeError err_var = (*val->contents.err);
6913         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6914         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6915         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6916         return err_ref;
6917 }
6918 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelUpdateDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6919         return ((LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)arg)->result_ok;
6920 }
6921 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6922         LDKCResult_UnsignedChannelUpdateDecodeErrorZ *val = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
6923         CHECK(val->result_ok);
6924         LDKUnsignedChannelUpdate res_var = (*val->contents.result);
6925         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6926         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6927         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6928         return res_ref;
6929 }
6930 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6931         LDKCResult_UnsignedChannelUpdateDecodeErrorZ *val = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
6932         CHECK(!val->result_ok);
6933         LDKDecodeError err_var = (*val->contents.err);
6934         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6935         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6936         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6937         return err_ref;
6938 }
6939 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelUpdateDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6940         return ((LDKCResult_ChannelUpdateDecodeErrorZ*)arg)->result_ok;
6941 }
6942 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6943         LDKCResult_ChannelUpdateDecodeErrorZ *val = (LDKCResult_ChannelUpdateDecodeErrorZ*)(arg & ~1);
6944         CHECK(val->result_ok);
6945         LDKChannelUpdate res_var = (*val->contents.result);
6946         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6947         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6948         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6949         return res_ref;
6950 }
6951 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6952         LDKCResult_ChannelUpdateDecodeErrorZ *val = (LDKCResult_ChannelUpdateDecodeErrorZ*)(arg & ~1);
6953         CHECK(!val->result_ok);
6954         LDKDecodeError err_var = (*val->contents.err);
6955         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6956         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6957         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6958         return err_ref;
6959 }
6960 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ErrorMessageDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6961         return ((LDKCResult_ErrorMessageDecodeErrorZ*)arg)->result_ok;
6962 }
6963 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ErrorMessageDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6964         LDKCResult_ErrorMessageDecodeErrorZ *val = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
6965         CHECK(val->result_ok);
6966         LDKErrorMessage res_var = (*val->contents.result);
6967         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6968         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6969         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6970         return res_ref;
6971 }
6972 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ErrorMessageDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6973         LDKCResult_ErrorMessageDecodeErrorZ *val = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
6974         CHECK(!val->result_ok);
6975         LDKDecodeError err_var = (*val->contents.err);
6976         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6977         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6978         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6979         return err_ref;
6980 }
6981 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedNodeAnnouncementDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6982         return ((LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)arg)->result_ok;
6983 }
6984 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedNodeAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6985         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
6986         CHECK(val->result_ok);
6987         LDKUnsignedNodeAnnouncement res_var = (*val->contents.result);
6988         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6989         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6990         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6991         return res_ref;
6992 }
6993 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedNodeAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6994         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
6995         CHECK(!val->result_ok);
6996         LDKDecodeError err_var = (*val->contents.err);
6997         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6998         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6999         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
7000         return err_ref;
7001 }
7002 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
7003         return ((LDKCResult_NodeAnnouncementDecodeErrorZ*)arg)->result_ok;
7004 }
7005 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
7006         LDKCResult_NodeAnnouncementDecodeErrorZ *val = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(arg & ~1);
7007         CHECK(val->result_ok);
7008         LDKNodeAnnouncement res_var = (*val->contents.result);
7009         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7010         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7011         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
7012         return res_ref;
7013 }
7014 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
7015         LDKCResult_NodeAnnouncementDecodeErrorZ *val = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(arg & ~1);
7016         CHECK(!val->result_ok);
7017         LDKDecodeError err_var = (*val->contents.err);
7018         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7019         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7020         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
7021         return err_ref;
7022 }
7023 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryShortChannelIdsDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
7024         return ((LDKCResult_QueryShortChannelIdsDecodeErrorZ*)arg)->result_ok;
7025 }
7026 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryShortChannelIdsDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
7027         LDKCResult_QueryShortChannelIdsDecodeErrorZ *val = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
7028         CHECK(val->result_ok);
7029         LDKQueryShortChannelIds res_var = (*val->contents.result);
7030         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7031         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7032         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
7033         return res_ref;
7034 }
7035 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryShortChannelIdsDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
7036         LDKCResult_QueryShortChannelIdsDecodeErrorZ *val = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
7037         CHECK(!val->result_ok);
7038         LDKDecodeError err_var = (*val->contents.err);
7039         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7040         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7041         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
7042         return err_ref;
7043 }
7044 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyShortChannelIdsEndDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
7045         return ((LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)arg)->result_ok;
7046 }
7047 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyShortChannelIdsEndDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
7048         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *val = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
7049         CHECK(val->result_ok);
7050         LDKReplyShortChannelIdsEnd res_var = (*val->contents.result);
7051         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7052         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7053         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
7054         return res_ref;
7055 }
7056 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyShortChannelIdsEndDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
7057         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *val = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
7058         CHECK(!val->result_ok);
7059         LDKDecodeError err_var = (*val->contents.err);
7060         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7061         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7062         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
7063         return err_ref;
7064 }
7065 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryChannelRangeDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
7066         return ((LDKCResult_QueryChannelRangeDecodeErrorZ*)arg)->result_ok;
7067 }
7068 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryChannelRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
7069         LDKCResult_QueryChannelRangeDecodeErrorZ *val = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
7070         CHECK(val->result_ok);
7071         LDKQueryChannelRange res_var = (*val->contents.result);
7072         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7073         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7074         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
7075         return res_ref;
7076 }
7077 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryChannelRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
7078         LDKCResult_QueryChannelRangeDecodeErrorZ *val = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
7079         CHECK(!val->result_ok);
7080         LDKDecodeError err_var = (*val->contents.err);
7081         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7082         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7083         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
7084         return err_ref;
7085 }
7086 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyChannelRangeDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
7087         return ((LDKCResult_ReplyChannelRangeDecodeErrorZ*)arg)->result_ok;
7088 }
7089 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyChannelRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
7090         LDKCResult_ReplyChannelRangeDecodeErrorZ *val = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
7091         CHECK(val->result_ok);
7092         LDKReplyChannelRange res_var = (*val->contents.result);
7093         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7094         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7095         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
7096         return res_ref;
7097 }
7098 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyChannelRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
7099         LDKCResult_ReplyChannelRangeDecodeErrorZ *val = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
7100         CHECK(!val->result_ok);
7101         LDKDecodeError err_var = (*val->contents.err);
7102         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7103         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7104         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
7105         return err_ref;
7106 }
7107 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1GossipTimestampFilterDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
7108         return ((LDKCResult_GossipTimestampFilterDecodeErrorZ*)arg)->result_ok;
7109 }
7110 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1GossipTimestampFilterDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
7111         LDKCResult_GossipTimestampFilterDecodeErrorZ *val = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
7112         CHECK(val->result_ok);
7113         LDKGossipTimestampFilter res_var = (*val->contents.result);
7114         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7115         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7116         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
7117         return res_ref;
7118 }
7119 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1GossipTimestampFilterDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
7120         LDKCResult_GossipTimestampFilterDecodeErrorZ *val = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
7121         CHECK(!val->result_ok);
7122         LDKDecodeError err_var = (*val->contents.err);
7123         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7124         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7125         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
7126         return err_ref;
7127 }
7128 static jclass LDKSignOrCreationError_SignError_class = NULL;
7129 static jmethodID LDKSignOrCreationError_SignError_meth = NULL;
7130 static jclass LDKSignOrCreationError_CreationError_class = NULL;
7131 static jmethodID LDKSignOrCreationError_CreationError_meth = NULL;
7132 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKSignOrCreationError_init (JNIEnv *env, jclass clz) {
7133         LDKSignOrCreationError_SignError_class =
7134                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKSignOrCreationError$SignError;"));
7135         CHECK(LDKSignOrCreationError_SignError_class != NULL);
7136         LDKSignOrCreationError_SignError_meth = (*env)->GetMethodID(env, LDKSignOrCreationError_SignError_class, "<init>", "()V");
7137         CHECK(LDKSignOrCreationError_SignError_meth != NULL);
7138         LDKSignOrCreationError_CreationError_class =
7139                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKSignOrCreationError$CreationError;"));
7140         CHECK(LDKSignOrCreationError_CreationError_class != NULL);
7141         LDKSignOrCreationError_CreationError_meth = (*env)->GetMethodID(env, LDKSignOrCreationError_CreationError_class, "<init>", "(Lorg/ldk/enums/CreationError;)V");
7142         CHECK(LDKSignOrCreationError_CreationError_meth != NULL);
7143 }
7144 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKSignOrCreationError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
7145         LDKSignOrCreationError *obj = (LDKSignOrCreationError*)(ptr & ~1);
7146         switch(obj->tag) {
7147                 case LDKSignOrCreationError_SignError: {
7148                         return (*env)->NewObject(env, LDKSignOrCreationError_SignError_class, LDKSignOrCreationError_SignError_meth);
7149                 }
7150                 case LDKSignOrCreationError_CreationError: {
7151                         jclass creation_error_conv = LDKCreationError_to_java(env, obj->creation_error);
7152                         return (*env)->NewObject(env, LDKSignOrCreationError_CreationError_class, LDKSignOrCreationError_CreationError_meth, creation_error_conv);
7153                 }
7154                 default: abort();
7155         }
7156 }
7157 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceSignOrCreationErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
7158         return ((LDKCResult_InvoiceSignOrCreationErrorZ*)arg)->result_ok;
7159 }
7160 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceSignOrCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
7161         LDKCResult_InvoiceSignOrCreationErrorZ *val = (LDKCResult_InvoiceSignOrCreationErrorZ*)(arg & ~1);
7162         CHECK(val->result_ok);
7163         LDKInvoice res_var = (*val->contents.result);
7164         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7165         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7166         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
7167         return res_ref;
7168 }
7169 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceSignOrCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
7170         LDKCResult_InvoiceSignOrCreationErrorZ *val = (LDKCResult_InvoiceSignOrCreationErrorZ*)(arg & ~1);
7171         CHECK(!val->result_ok);
7172         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
7173         return err_ref;
7174 }
7175 typedef struct LDKFilter_JCalls {
7176         atomic_size_t refcnt;
7177         JavaVM *vm;
7178         jweak o;
7179         jmethodID register_tx_meth;
7180         jmethodID register_output_meth;
7181 } LDKFilter_JCalls;
7182 static void LDKFilter_JCalls_free(void* this_arg) {
7183         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
7184         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7185                 JNIEnv *env;
7186                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7187                 if (get_jenv_res == JNI_EDETACHED) {
7188                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7189                 } else {
7190                         DO_ASSERT(get_jenv_res == JNI_OK);
7191                 }
7192                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
7193                 if (get_jenv_res == JNI_EDETACHED) {
7194                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7195                 }
7196                 FREE(j_calls);
7197         }
7198 }
7199 void register_tx_LDKFilter_jcall(const void* this_arg, const uint8_t (* txid)[32], LDKu8slice script_pubkey) {
7200         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
7201         JNIEnv *env;
7202         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7203         if (get_jenv_res == JNI_EDETACHED) {
7204                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7205         } else {
7206                 DO_ASSERT(get_jenv_res == JNI_OK);
7207         }
7208         int8_tArray txid_arr = (*env)->NewByteArray(env, 32);
7209         (*env)->SetByteArrayRegion(env, txid_arr, 0, 32, *txid);
7210         LDKu8slice script_pubkey_var = script_pubkey;
7211         int8_tArray script_pubkey_arr = (*env)->NewByteArray(env, script_pubkey_var.datalen);
7212         (*env)->SetByteArrayRegion(env, script_pubkey_arr, 0, script_pubkey_var.datalen, script_pubkey_var.data);
7213         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7214         CHECK(obj != NULL);
7215         (*env)->CallVoidMethod(env, obj, j_calls->register_tx_meth, txid_arr, script_pubkey_arr);
7216         if ((*env)->ExceptionCheck(env)) {
7217                 (*env)->ExceptionDescribe(env);
7218                 (*env)->FatalError(env, "A call to register_tx in LDKFilter from rust threw an exception.");
7219         }
7220         if (get_jenv_res == JNI_EDETACHED) {
7221                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7222         }
7223 }
7224 LDKCOption_C2Tuple_usizeTransactionZZ register_output_LDKFilter_jcall(const void* this_arg, LDKWatchedOutput output) {
7225         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
7226         JNIEnv *env;
7227         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7228         if (get_jenv_res == JNI_EDETACHED) {
7229                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7230         } else {
7231                 DO_ASSERT(get_jenv_res == JNI_OK);
7232         }
7233         LDKWatchedOutput output_var = output;
7234         CHECK((((uint64_t)output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7235         CHECK((((uint64_t)&output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7236         uint64_t output_ref = (uint64_t)output_var.inner;
7237         if (output_var.is_owned) {
7238                 output_ref |= 1;
7239         }
7240         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7241         CHECK(obj != NULL);
7242         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->register_output_meth, output_ref);
7243         if ((*env)->ExceptionCheck(env)) {
7244                 (*env)->ExceptionDescribe(env);
7245                 (*env)->FatalError(env, "A call to register_output in LDKFilter from rust threw an exception.");
7246         }
7247         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
7248         CHECK_ACCESS(ret_ptr);
7249         LDKCOption_C2Tuple_usizeTransactionZZ ret_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(ret_ptr);
7250         ret_conv = COption_C2Tuple_usizeTransactionZZ_clone((LDKCOption_C2Tuple_usizeTransactionZZ*)(((uint64_t)ret) & ~1));
7251         if (get_jenv_res == JNI_EDETACHED) {
7252                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7253         }
7254         return ret_conv;
7255 }
7256 static void LDKFilter_JCalls_cloned(LDKFilter* new_obj) {
7257         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) new_obj->this_arg;
7258         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7259 }
7260 static inline LDKFilter LDKFilter_init (JNIEnv *env, jclass clz, jobject o) {
7261         jclass c = (*env)->GetObjectClass(env, o);
7262         CHECK(c != NULL);
7263         LDKFilter_JCalls *calls = MALLOC(sizeof(LDKFilter_JCalls), "LDKFilter_JCalls");
7264         atomic_init(&calls->refcnt, 1);
7265         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
7266         calls->o = (*env)->NewWeakGlobalRef(env, o);
7267         calls->register_tx_meth = (*env)->GetMethodID(env, c, "register_tx", "([B[B)V");
7268         CHECK(calls->register_tx_meth != NULL);
7269         calls->register_output_meth = (*env)->GetMethodID(env, c, "register_output", "(J)J");
7270         CHECK(calls->register_output_meth != NULL);
7271
7272         LDKFilter ret = {
7273                 .this_arg = (void*) calls,
7274                 .register_tx = register_tx_LDKFilter_jcall,
7275                 .register_output = register_output_LDKFilter_jcall,
7276                 .free = LDKFilter_JCalls_free,
7277         };
7278         return ret;
7279 }
7280 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKFilter_1new(JNIEnv *env, jclass clz, jobject o) {
7281         LDKFilter *res_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter");
7282         *res_ptr = LDKFilter_init(env, clz, o);
7283         return (uint64_t)res_ptr;
7284 }
7285 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) {
7286         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7287         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7288         LDKFilter* this_arg_conv = (LDKFilter*)this_arg_ptr;
7289         unsigned char txid_arr[32];
7290         CHECK((*env)->GetArrayLength(env, txid) == 32);
7291         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
7292         unsigned char (*txid_ref)[32] = &txid_arr;
7293         LDKu8slice script_pubkey_ref;
7294         script_pubkey_ref.datalen = (*env)->GetArrayLength(env, script_pubkey);
7295         script_pubkey_ref.data = (*env)->GetByteArrayElements (env, script_pubkey, NULL);
7296         (this_arg_conv->register_tx)(this_arg_conv->this_arg, txid_ref, script_pubkey_ref);
7297         (*env)->ReleaseByteArrayElements(env, script_pubkey, (int8_t*)script_pubkey_ref.data, 0);
7298 }
7299
7300 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Filter_1register_1output(JNIEnv *env, jclass clz, int64_t this_arg, int64_t output) {
7301         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7302         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7303         LDKFilter* this_arg_conv = (LDKFilter*)this_arg_ptr;
7304         LDKWatchedOutput output_conv;
7305         output_conv.inner = (void*)(output & (~1));
7306         output_conv.is_owned = (output & 1) || (output == 0);
7307         output_conv = WatchedOutput_clone(&output_conv);
7308         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
7309         *ret_copy = (this_arg_conv->register_output)(this_arg_conv->this_arg, output_conv);
7310         uint64_t ret_ref = (uint64_t)ret_copy;
7311         return ret_ref;
7312 }
7313
7314 static jclass LDKCOption_FilterZ_Some_class = NULL;
7315 static jmethodID LDKCOption_FilterZ_Some_meth = NULL;
7316 static jclass LDKCOption_FilterZ_None_class = NULL;
7317 static jmethodID LDKCOption_FilterZ_None_meth = NULL;
7318 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1FilterZ_init (JNIEnv *env, jclass clz) {
7319         LDKCOption_FilterZ_Some_class =
7320                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_FilterZ$Some;"));
7321         CHECK(LDKCOption_FilterZ_Some_class != NULL);
7322         LDKCOption_FilterZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_FilterZ_Some_class, "<init>", "(J)V");
7323         CHECK(LDKCOption_FilterZ_Some_meth != NULL);
7324         LDKCOption_FilterZ_None_class =
7325                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_FilterZ$None;"));
7326         CHECK(LDKCOption_FilterZ_None_class != NULL);
7327         LDKCOption_FilterZ_None_meth = (*env)->GetMethodID(env, LDKCOption_FilterZ_None_class, "<init>", "()V");
7328         CHECK(LDKCOption_FilterZ_None_meth != NULL);
7329 }
7330 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1FilterZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
7331         LDKCOption_FilterZ *obj = (LDKCOption_FilterZ*)(ptr & ~1);
7332         switch(obj->tag) {
7333                 case LDKCOption_FilterZ_Some: {
7334                         LDKFilter* some_ret =MALLOC(sizeof(LDKFilter), "LDKFilter");
7335                         *some_ret = obj->some;
7336                         // Warning: We likely need to clone here, but no clone is available, so we just do it for Java instances
7337                         if ((*some_ret).free == LDKFilter_JCalls_free) {
7338                                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
7339                                 LDKFilter_JCalls_cloned(&(*some_ret));
7340                         }
7341                         return (*env)->NewObject(env, LDKCOption_FilterZ_Some_class, LDKCOption_FilterZ_Some_meth, (uint64_t)some_ret);
7342                 }
7343                 case LDKCOption_FilterZ_None: {
7344                         return (*env)->NewObject(env, LDKCOption_FilterZ_None_class, LDKCOption_FilterZ_None_meth);
7345                 }
7346                 default: abort();
7347         }
7348 }
7349 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1LockedChannelMonitorNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
7350         return ((LDKCResult_LockedChannelMonitorNoneZ*)arg)->result_ok;
7351 }
7352 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1LockedChannelMonitorNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
7353         LDKCResult_LockedChannelMonitorNoneZ *val = (LDKCResult_LockedChannelMonitorNoneZ*)(arg & ~1);
7354         CHECK(val->result_ok);
7355         LDKLockedChannelMonitor res_var = (*val->contents.result);
7356         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7357         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7358         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
7359         return res_ref;
7360 }
7361 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1LockedChannelMonitorNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
7362         LDKCResult_LockedChannelMonitorNoneZ *val = (LDKCResult_LockedChannelMonitorNoneZ*)(arg & ~1);
7363         CHECK(!val->result_ok);
7364         return *val->contents.err;
7365 }
7366 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1OutPointZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
7367         LDKCVec_OutPointZ *ret = MALLOC(sizeof(LDKCVec_OutPointZ), "LDKCVec_OutPointZ");
7368         ret->datalen = (*env)->GetArrayLength(env, elems);
7369         if (ret->datalen == 0) {
7370                 ret->data = NULL;
7371         } else {
7372                 ret->data = MALLOC(sizeof(LDKOutPoint) * ret->datalen, "LDKCVec_OutPointZ Data");
7373                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
7374                 for (size_t i = 0; i < ret->datalen; i++) {
7375                         int64_t arr_elem = java_elems[i];
7376                         LDKOutPoint arr_elem_conv;
7377                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
7378                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
7379                         arr_elem_conv = OutPoint_clone(&arr_elem_conv);
7380                         ret->data[i] = arr_elem_conv;
7381                 }
7382                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
7383         }
7384         return (uint64_t)ret;
7385 }
7386 static inline LDKCVec_OutPointZ CVec_OutPointZ_clone(const LDKCVec_OutPointZ *orig) {
7387         LDKCVec_OutPointZ ret = { .data = MALLOC(sizeof(LDKOutPoint) * orig->datalen, "LDKCVec_OutPointZ clone bytes"), .datalen = orig->datalen };
7388         for (size_t i = 0; i < ret.datalen; i++) {
7389                 ret.data[i] = OutPoint_clone(&orig->data[i]);
7390         }
7391         return ret;
7392 }
7393 typedef struct LDKMessageSendEventsProvider_JCalls {
7394         atomic_size_t refcnt;
7395         JavaVM *vm;
7396         jweak o;
7397         jmethodID get_and_clear_pending_msg_events_meth;
7398 } LDKMessageSendEventsProvider_JCalls;
7399 static void LDKMessageSendEventsProvider_JCalls_free(void* this_arg) {
7400         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
7401         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7402                 JNIEnv *env;
7403                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7404                 if (get_jenv_res == JNI_EDETACHED) {
7405                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7406                 } else {
7407                         DO_ASSERT(get_jenv_res == JNI_OK);
7408                 }
7409                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
7410                 if (get_jenv_res == JNI_EDETACHED) {
7411                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7412                 }
7413                 FREE(j_calls);
7414         }
7415 }
7416 LDKCVec_MessageSendEventZ get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall(const void* this_arg) {
7417         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
7418         JNIEnv *env;
7419         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7420         if (get_jenv_res == JNI_EDETACHED) {
7421                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7422         } else {
7423                 DO_ASSERT(get_jenv_res == JNI_OK);
7424         }
7425         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7426         CHECK(obj != NULL);
7427         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_and_clear_pending_msg_events_meth);
7428         if ((*env)->ExceptionCheck(env)) {
7429                 (*env)->ExceptionDescribe(env);
7430                 (*env)->FatalError(env, "A call to get_and_clear_pending_msg_events in LDKMessageSendEventsProvider from rust threw an exception.");
7431         }
7432         LDKCVec_MessageSendEventZ ret_constr;
7433         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
7434         if (ret_constr.datalen > 0)
7435                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
7436         else
7437                 ret_constr.data = NULL;
7438         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
7439         for (size_t s = 0; s < ret_constr.datalen; s++) {
7440                 int64_t ret_conv_18 = ret_vals[s];
7441                 void* ret_conv_18_ptr = (void*)(((uint64_t)ret_conv_18) & ~1);
7442                 CHECK_ACCESS(ret_conv_18_ptr);
7443                 LDKMessageSendEvent ret_conv_18_conv = *(LDKMessageSendEvent*)(ret_conv_18_ptr);
7444                 ret_conv_18_conv = MessageSendEvent_clone((LDKMessageSendEvent*)(((uint64_t)ret_conv_18) & ~1));
7445                 ret_constr.data[s] = ret_conv_18_conv;
7446         }
7447         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
7448         if (get_jenv_res == JNI_EDETACHED) {
7449                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7450         }
7451         return ret_constr;
7452 }
7453 static void LDKMessageSendEventsProvider_JCalls_cloned(LDKMessageSendEventsProvider* new_obj) {
7454         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) new_obj->this_arg;
7455         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7456 }
7457 static inline LDKMessageSendEventsProvider LDKMessageSendEventsProvider_init (JNIEnv *env, jclass clz, jobject o) {
7458         jclass c = (*env)->GetObjectClass(env, o);
7459         CHECK(c != NULL);
7460         LDKMessageSendEventsProvider_JCalls *calls = MALLOC(sizeof(LDKMessageSendEventsProvider_JCalls), "LDKMessageSendEventsProvider_JCalls");
7461         atomic_init(&calls->refcnt, 1);
7462         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
7463         calls->o = (*env)->NewWeakGlobalRef(env, o);
7464         calls->get_and_clear_pending_msg_events_meth = (*env)->GetMethodID(env, c, "get_and_clear_pending_msg_events", "()[J");
7465         CHECK(calls->get_and_clear_pending_msg_events_meth != NULL);
7466
7467         LDKMessageSendEventsProvider ret = {
7468                 .this_arg = (void*) calls,
7469                 .get_and_clear_pending_msg_events = get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall,
7470                 .free = LDKMessageSendEventsProvider_JCalls_free,
7471         };
7472         return ret;
7473 }
7474 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEventsProvider_1new(JNIEnv *env, jclass clz, jobject o) {
7475         LDKMessageSendEventsProvider *res_ptr = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
7476         *res_ptr = LDKMessageSendEventsProvider_init(env, clz, o);
7477         return (uint64_t)res_ptr;
7478 }
7479 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_MessageSendEventsProvider_1get_1and_1clear_1pending_1msg_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
7480         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7481         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7482         LDKMessageSendEventsProvider* this_arg_conv = (LDKMessageSendEventsProvider*)this_arg_ptr;
7483         LDKCVec_MessageSendEventZ ret_var = (this_arg_conv->get_and_clear_pending_msg_events)(this_arg_conv->this_arg);
7484         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
7485         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
7486         for (size_t s = 0; s < ret_var.datalen; s++) {
7487                 LDKMessageSendEvent *ret_conv_18_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
7488                 *ret_conv_18_copy = ret_var.data[s];
7489                 uint64_t ret_conv_18_ref = (uint64_t)ret_conv_18_copy;
7490                 ret_arr_ptr[s] = ret_conv_18_ref;
7491         }
7492         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
7493         FREE(ret_var.data);
7494         return ret_arr;
7495 }
7496
7497 typedef struct LDKEventHandler_JCalls {
7498         atomic_size_t refcnt;
7499         JavaVM *vm;
7500         jweak o;
7501         jmethodID handle_event_meth;
7502 } LDKEventHandler_JCalls;
7503 static void LDKEventHandler_JCalls_free(void* this_arg) {
7504         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
7505         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7506                 JNIEnv *env;
7507                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7508                 if (get_jenv_res == JNI_EDETACHED) {
7509                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7510                 } else {
7511                         DO_ASSERT(get_jenv_res == JNI_OK);
7512                 }
7513                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
7514                 if (get_jenv_res == JNI_EDETACHED) {
7515                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7516                 }
7517                 FREE(j_calls);
7518         }
7519 }
7520 void handle_event_LDKEventHandler_jcall(const void* this_arg, const LDKEvent * event) {
7521         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
7522         JNIEnv *env;
7523         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7524         if (get_jenv_res == JNI_EDETACHED) {
7525                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7526         } else {
7527                 DO_ASSERT(get_jenv_res == JNI_OK);
7528         }
7529         LDKEvent *ret_event = MALLOC(sizeof(LDKEvent), "LDKEvent ret conversion");
7530         *ret_event = Event_clone(event);
7531         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7532         CHECK(obj != NULL);
7533         (*env)->CallVoidMethod(env, obj, j_calls->handle_event_meth, (uint64_t)ret_event);
7534         if ((*env)->ExceptionCheck(env)) {
7535                 (*env)->ExceptionDescribe(env);
7536                 (*env)->FatalError(env, "A call to handle_event in LDKEventHandler from rust threw an exception.");
7537         }
7538         if (get_jenv_res == JNI_EDETACHED) {
7539                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7540         }
7541 }
7542 static void LDKEventHandler_JCalls_cloned(LDKEventHandler* new_obj) {
7543         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) new_obj->this_arg;
7544         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7545 }
7546 static inline LDKEventHandler LDKEventHandler_init (JNIEnv *env, jclass clz, jobject o) {
7547         jclass c = (*env)->GetObjectClass(env, o);
7548         CHECK(c != NULL);
7549         LDKEventHandler_JCalls *calls = MALLOC(sizeof(LDKEventHandler_JCalls), "LDKEventHandler_JCalls");
7550         atomic_init(&calls->refcnt, 1);
7551         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
7552         calls->o = (*env)->NewWeakGlobalRef(env, o);
7553         calls->handle_event_meth = (*env)->GetMethodID(env, c, "handle_event", "(J)V");
7554         CHECK(calls->handle_event_meth != NULL);
7555
7556         LDKEventHandler ret = {
7557                 .this_arg = (void*) calls,
7558                 .handle_event = handle_event_LDKEventHandler_jcall,
7559                 .free = LDKEventHandler_JCalls_free,
7560         };
7561         return ret;
7562 }
7563 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKEventHandler_1new(JNIEnv *env, jclass clz, jobject o) {
7564         LDKEventHandler *res_ptr = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
7565         *res_ptr = LDKEventHandler_init(env, clz, o);
7566         return (uint64_t)res_ptr;
7567 }
7568 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventHandler_1handle_1event(JNIEnv *env, jclass clz, int64_t this_arg, int64_t event) {
7569         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7570         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7571         LDKEventHandler* this_arg_conv = (LDKEventHandler*)this_arg_ptr;
7572         LDKEvent* event_conv = (LDKEvent*)event;
7573         (this_arg_conv->handle_event)(this_arg_conv->this_arg, event_conv);
7574 }
7575
7576 typedef struct LDKEventsProvider_JCalls {
7577         atomic_size_t refcnt;
7578         JavaVM *vm;
7579         jweak o;
7580         jmethodID process_pending_events_meth;
7581 } LDKEventsProvider_JCalls;
7582 static void LDKEventsProvider_JCalls_free(void* this_arg) {
7583         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
7584         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7585                 JNIEnv *env;
7586                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7587                 if (get_jenv_res == JNI_EDETACHED) {
7588                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7589                 } else {
7590                         DO_ASSERT(get_jenv_res == JNI_OK);
7591                 }
7592                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
7593                 if (get_jenv_res == JNI_EDETACHED) {
7594                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7595                 }
7596                 FREE(j_calls);
7597         }
7598 }
7599 void process_pending_events_LDKEventsProvider_jcall(const void* this_arg, LDKEventHandler handler) {
7600         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
7601         JNIEnv *env;
7602         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7603         if (get_jenv_res == JNI_EDETACHED) {
7604                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7605         } else {
7606                 DO_ASSERT(get_jenv_res == JNI_OK);
7607         }
7608         LDKEventHandler* handler_ret =MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
7609         *handler_ret = handler;
7610         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7611         CHECK(obj != NULL);
7612         (*env)->CallVoidMethod(env, obj, j_calls->process_pending_events_meth, (uint64_t)handler_ret);
7613         if ((*env)->ExceptionCheck(env)) {
7614                 (*env)->ExceptionDescribe(env);
7615                 (*env)->FatalError(env, "A call to process_pending_events in LDKEventsProvider from rust threw an exception.");
7616         }
7617         if (get_jenv_res == JNI_EDETACHED) {
7618                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7619         }
7620 }
7621 static void LDKEventsProvider_JCalls_cloned(LDKEventsProvider* new_obj) {
7622         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) new_obj->this_arg;
7623         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7624 }
7625 static inline LDKEventsProvider LDKEventsProvider_init (JNIEnv *env, jclass clz, jobject o) {
7626         jclass c = (*env)->GetObjectClass(env, o);
7627         CHECK(c != NULL);
7628         LDKEventsProvider_JCalls *calls = MALLOC(sizeof(LDKEventsProvider_JCalls), "LDKEventsProvider_JCalls");
7629         atomic_init(&calls->refcnt, 1);
7630         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
7631         calls->o = (*env)->NewWeakGlobalRef(env, o);
7632         calls->process_pending_events_meth = (*env)->GetMethodID(env, c, "process_pending_events", "(J)V");
7633         CHECK(calls->process_pending_events_meth != NULL);
7634
7635         LDKEventsProvider ret = {
7636                 .this_arg = (void*) calls,
7637                 .process_pending_events = process_pending_events_LDKEventsProvider_jcall,
7638                 .free = LDKEventsProvider_JCalls_free,
7639         };
7640         return ret;
7641 }
7642 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKEventsProvider_1new(JNIEnv *env, jclass clz, jobject o) {
7643         LDKEventsProvider *res_ptr = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
7644         *res_ptr = LDKEventsProvider_init(env, clz, o);
7645         return (uint64_t)res_ptr;
7646 }
7647 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventsProvider_1process_1pending_1events(JNIEnv *env, jclass clz, int64_t this_arg, int64_t handler) {
7648         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7649         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7650         LDKEventsProvider* this_arg_conv = (LDKEventsProvider*)this_arg_ptr;
7651         void* handler_ptr = (void*)(((uint64_t)handler) & ~1);
7652         CHECK_ACCESS(handler_ptr);
7653         LDKEventHandler handler_conv = *(LDKEventHandler*)(handler_ptr);
7654         if (handler_conv.free == LDKEventHandler_JCalls_free) {
7655                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
7656                 LDKEventHandler_JCalls_cloned(&handler_conv);
7657         }
7658         (this_arg_conv->process_pending_events)(this_arg_conv->this_arg, handler_conv);
7659 }
7660
7661 typedef struct LDKListen_JCalls {
7662         atomic_size_t refcnt;
7663         JavaVM *vm;
7664         jweak o;
7665         jmethodID block_connected_meth;
7666         jmethodID block_disconnected_meth;
7667 } LDKListen_JCalls;
7668 static void LDKListen_JCalls_free(void* this_arg) {
7669         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
7670         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
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                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
7679                 if (get_jenv_res == JNI_EDETACHED) {
7680                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7681                 }
7682                 FREE(j_calls);
7683         }
7684 }
7685 void block_connected_LDKListen_jcall(const void* this_arg, LDKu8slice block, uint32_t height) {
7686         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
7687         JNIEnv *env;
7688         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7689         if (get_jenv_res == JNI_EDETACHED) {
7690                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7691         } else {
7692                 DO_ASSERT(get_jenv_res == JNI_OK);
7693         }
7694         LDKu8slice block_var = block;
7695         int8_tArray block_arr = (*env)->NewByteArray(env, block_var.datalen);
7696         (*env)->SetByteArrayRegion(env, block_arr, 0, block_var.datalen, block_var.data);
7697         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7698         CHECK(obj != NULL);
7699         (*env)->CallVoidMethod(env, obj, j_calls->block_connected_meth, block_arr, height);
7700         if ((*env)->ExceptionCheck(env)) {
7701                 (*env)->ExceptionDescribe(env);
7702                 (*env)->FatalError(env, "A call to block_connected in LDKListen from rust threw an exception.");
7703         }
7704         if (get_jenv_res == JNI_EDETACHED) {
7705                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7706         }
7707 }
7708 void block_disconnected_LDKListen_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
7709         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
7710         JNIEnv *env;
7711         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7712         if (get_jenv_res == JNI_EDETACHED) {
7713                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7714         } else {
7715                 DO_ASSERT(get_jenv_res == JNI_OK);
7716         }
7717         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
7718         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
7719         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7720         CHECK(obj != NULL);
7721         (*env)->CallVoidMethod(env, obj, j_calls->block_disconnected_meth, header_arr, height);
7722         if ((*env)->ExceptionCheck(env)) {
7723                 (*env)->ExceptionDescribe(env);
7724                 (*env)->FatalError(env, "A call to block_disconnected in LDKListen from rust threw an exception.");
7725         }
7726         if (get_jenv_res == JNI_EDETACHED) {
7727                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7728         }
7729 }
7730 static void LDKListen_JCalls_cloned(LDKListen* new_obj) {
7731         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) new_obj->this_arg;
7732         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7733 }
7734 static inline LDKListen LDKListen_init (JNIEnv *env, jclass clz, jobject o) {
7735         jclass c = (*env)->GetObjectClass(env, o);
7736         CHECK(c != NULL);
7737         LDKListen_JCalls *calls = MALLOC(sizeof(LDKListen_JCalls), "LDKListen_JCalls");
7738         atomic_init(&calls->refcnt, 1);
7739         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
7740         calls->o = (*env)->NewWeakGlobalRef(env, o);
7741         calls->block_connected_meth = (*env)->GetMethodID(env, c, "block_connected", "([BI)V");
7742         CHECK(calls->block_connected_meth != NULL);
7743         calls->block_disconnected_meth = (*env)->GetMethodID(env, c, "block_disconnected", "([BI)V");
7744         CHECK(calls->block_disconnected_meth != NULL);
7745
7746         LDKListen ret = {
7747                 .this_arg = (void*) calls,
7748                 .block_connected = block_connected_LDKListen_jcall,
7749                 .block_disconnected = block_disconnected_LDKListen_jcall,
7750                 .free = LDKListen_JCalls_free,
7751         };
7752         return ret;
7753 }
7754 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKListen_1new(JNIEnv *env, jclass clz, jobject o) {
7755         LDKListen *res_ptr = MALLOC(sizeof(LDKListen), "LDKListen");
7756         *res_ptr = LDKListen_init(env, clz, o);
7757         return (uint64_t)res_ptr;
7758 }
7759 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) {
7760         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7761         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7762         LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
7763         LDKu8slice block_ref;
7764         block_ref.datalen = (*env)->GetArrayLength(env, block);
7765         block_ref.data = (*env)->GetByteArrayElements (env, block, NULL);
7766         (this_arg_conv->block_connected)(this_arg_conv->this_arg, block_ref, height);
7767         (*env)->ReleaseByteArrayElements(env, block, (int8_t*)block_ref.data, 0);
7768 }
7769
7770 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) {
7771         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7772         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7773         LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
7774         unsigned char header_arr[80];
7775         CHECK((*env)->GetArrayLength(env, header) == 80);
7776         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
7777         unsigned char (*header_ref)[80] = &header_arr;
7778         (this_arg_conv->block_disconnected)(this_arg_conv->this_arg, header_ref, height);
7779 }
7780
7781 typedef struct LDKConfirm_JCalls {
7782         atomic_size_t refcnt;
7783         JavaVM *vm;
7784         jweak o;
7785         jmethodID transactions_confirmed_meth;
7786         jmethodID transaction_unconfirmed_meth;
7787         jmethodID best_block_updated_meth;
7788         jmethodID get_relevant_txids_meth;
7789 } LDKConfirm_JCalls;
7790 static void LDKConfirm_JCalls_free(void* this_arg) {
7791         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
7792         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7793                 JNIEnv *env;
7794                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7795                 if (get_jenv_res == JNI_EDETACHED) {
7796                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7797                 } else {
7798                         DO_ASSERT(get_jenv_res == JNI_OK);
7799                 }
7800                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
7801                 if (get_jenv_res == JNI_EDETACHED) {
7802                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7803                 }
7804                 FREE(j_calls);
7805         }
7806 }
7807 void transactions_confirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height) {
7808         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
7809         JNIEnv *env;
7810         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7811         if (get_jenv_res == JNI_EDETACHED) {
7812                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7813         } else {
7814                 DO_ASSERT(get_jenv_res == JNI_OK);
7815         }
7816         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
7817         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
7818         LDKCVec_C2Tuple_usizeTransactionZZ txdata_var = txdata;
7819         int64_tArray txdata_arr = (*env)->NewLongArray(env, txdata_var.datalen);
7820         int64_t *txdata_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, txdata_arr, NULL);
7821         for (size_t c = 0; c < txdata_var.datalen; c++) {
7822                 LDKC2Tuple_usizeTransactionZ* txdata_conv_28_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
7823                 *txdata_conv_28_conv = txdata_var.data[c];
7824                 txdata_arr_ptr[c] = ((uint64_t)txdata_conv_28_conv);
7825         }
7826         (*env)->ReleasePrimitiveArrayCritical(env, txdata_arr, txdata_arr_ptr, 0);
7827         FREE(txdata_var.data);
7828         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7829         CHECK(obj != NULL);
7830         (*env)->CallVoidMethod(env, obj, j_calls->transactions_confirmed_meth, header_arr, txdata_arr, height);
7831         if ((*env)->ExceptionCheck(env)) {
7832                 (*env)->ExceptionDescribe(env);
7833                 (*env)->FatalError(env, "A call to transactions_confirmed in LDKConfirm from rust threw an exception.");
7834         }
7835         if (get_jenv_res == JNI_EDETACHED) {
7836                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7837         }
7838 }
7839 void transaction_unconfirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* txid)[32]) {
7840         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
7841         JNIEnv *env;
7842         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7843         if (get_jenv_res == JNI_EDETACHED) {
7844                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7845         } else {
7846                 DO_ASSERT(get_jenv_res == JNI_OK);
7847         }
7848         int8_tArray txid_arr = (*env)->NewByteArray(env, 32);
7849         (*env)->SetByteArrayRegion(env, txid_arr, 0, 32, *txid);
7850         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7851         CHECK(obj != NULL);
7852         (*env)->CallVoidMethod(env, obj, j_calls->transaction_unconfirmed_meth, txid_arr);
7853         if ((*env)->ExceptionCheck(env)) {
7854                 (*env)->ExceptionDescribe(env);
7855                 (*env)->FatalError(env, "A call to transaction_unconfirmed in LDKConfirm from rust threw an exception.");
7856         }
7857         if (get_jenv_res == JNI_EDETACHED) {
7858                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7859         }
7860 }
7861 void best_block_updated_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
7862         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
7863         JNIEnv *env;
7864         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7865         if (get_jenv_res == JNI_EDETACHED) {
7866                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7867         } else {
7868                 DO_ASSERT(get_jenv_res == JNI_OK);
7869         }
7870         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
7871         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
7872         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7873         CHECK(obj != NULL);
7874         (*env)->CallVoidMethod(env, obj, j_calls->best_block_updated_meth, header_arr, height);
7875         if ((*env)->ExceptionCheck(env)) {
7876                 (*env)->ExceptionDescribe(env);
7877                 (*env)->FatalError(env, "A call to best_block_updated in LDKConfirm from rust threw an exception.");
7878         }
7879         if (get_jenv_res == JNI_EDETACHED) {
7880                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7881         }
7882 }
7883 LDKCVec_TxidZ get_relevant_txids_LDKConfirm_jcall(const void* this_arg) {
7884         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
7885         JNIEnv *env;
7886         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7887         if (get_jenv_res == JNI_EDETACHED) {
7888                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7889         } else {
7890                 DO_ASSERT(get_jenv_res == JNI_OK);
7891         }
7892         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7893         CHECK(obj != NULL);
7894         jobjectArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_relevant_txids_meth);
7895         if ((*env)->ExceptionCheck(env)) {
7896                 (*env)->ExceptionDescribe(env);
7897                 (*env)->FatalError(env, "A call to get_relevant_txids in LDKConfirm from rust threw an exception.");
7898         }
7899         LDKCVec_TxidZ ret_constr;
7900         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
7901         if (ret_constr.datalen > 0)
7902                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
7903         else
7904                 ret_constr.data = NULL;
7905         for (size_t i = 0; i < ret_constr.datalen; i++) {
7906                 int8_tArray ret_conv_8 = (*env)->GetObjectArrayElement(env, ret, i);
7907                 LDKThirtyTwoBytes ret_conv_8_ref;
7908                 CHECK((*env)->GetArrayLength(env, ret_conv_8) == 32);
7909                 (*env)->GetByteArrayRegion(env, ret_conv_8, 0, 32, ret_conv_8_ref.data);
7910                 ret_constr.data[i] = ret_conv_8_ref;
7911         }
7912         if (get_jenv_res == JNI_EDETACHED) {
7913                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7914         }
7915         return ret_constr;
7916 }
7917 static void LDKConfirm_JCalls_cloned(LDKConfirm* new_obj) {
7918         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) new_obj->this_arg;
7919         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7920 }
7921 static inline LDKConfirm LDKConfirm_init (JNIEnv *env, jclass clz, jobject o) {
7922         jclass c = (*env)->GetObjectClass(env, o);
7923         CHECK(c != NULL);
7924         LDKConfirm_JCalls *calls = MALLOC(sizeof(LDKConfirm_JCalls), "LDKConfirm_JCalls");
7925         atomic_init(&calls->refcnt, 1);
7926         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
7927         calls->o = (*env)->NewWeakGlobalRef(env, o);
7928         calls->transactions_confirmed_meth = (*env)->GetMethodID(env, c, "transactions_confirmed", "([B[JI)V");
7929         CHECK(calls->transactions_confirmed_meth != NULL);
7930         calls->transaction_unconfirmed_meth = (*env)->GetMethodID(env, c, "transaction_unconfirmed", "([B)V");
7931         CHECK(calls->transaction_unconfirmed_meth != NULL);
7932         calls->best_block_updated_meth = (*env)->GetMethodID(env, c, "best_block_updated", "([BI)V");
7933         CHECK(calls->best_block_updated_meth != NULL);
7934         calls->get_relevant_txids_meth = (*env)->GetMethodID(env, c, "get_relevant_txids", "()[[B");
7935         CHECK(calls->get_relevant_txids_meth != NULL);
7936
7937         LDKConfirm ret = {
7938                 .this_arg = (void*) calls,
7939                 .transactions_confirmed = transactions_confirmed_LDKConfirm_jcall,
7940                 .transaction_unconfirmed = transaction_unconfirmed_LDKConfirm_jcall,
7941                 .best_block_updated = best_block_updated_LDKConfirm_jcall,
7942                 .get_relevant_txids = get_relevant_txids_LDKConfirm_jcall,
7943                 .free = LDKConfirm_JCalls_free,
7944         };
7945         return ret;
7946 }
7947 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKConfirm_1new(JNIEnv *env, jclass clz, jobject o) {
7948         LDKConfirm *res_ptr = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
7949         *res_ptr = LDKConfirm_init(env, clz, o);
7950         return (uint64_t)res_ptr;
7951 }
7952 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) {
7953         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7954         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7955         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
7956         unsigned char header_arr[80];
7957         CHECK((*env)->GetArrayLength(env, header) == 80);
7958         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
7959         unsigned char (*header_ref)[80] = &header_arr;
7960         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
7961         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
7962         if (txdata_constr.datalen > 0)
7963                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
7964         else
7965                 txdata_constr.data = NULL;
7966         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
7967         for (size_t c = 0; c < txdata_constr.datalen; c++) {
7968                 int64_t txdata_conv_28 = txdata_vals[c];
7969                 void* txdata_conv_28_ptr = (void*)(((uint64_t)txdata_conv_28) & ~1);
7970                 CHECK_ACCESS(txdata_conv_28_ptr);
7971                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
7972                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_28) & ~1));
7973                 txdata_constr.data[c] = txdata_conv_28_conv;
7974         }
7975         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
7976         (this_arg_conv->transactions_confirmed)(this_arg_conv->this_arg, header_ref, txdata_constr, height);
7977 }
7978
7979 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Confirm_1transaction_1unconfirmed(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray txid) {
7980         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7981         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7982         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
7983         unsigned char txid_arr[32];
7984         CHECK((*env)->GetArrayLength(env, txid) == 32);
7985         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
7986         unsigned char (*txid_ref)[32] = &txid_arr;
7987         (this_arg_conv->transaction_unconfirmed)(this_arg_conv->this_arg, txid_ref);
7988 }
7989
7990 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) {
7991         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7992         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7993         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
7994         unsigned char header_arr[80];
7995         CHECK((*env)->GetArrayLength(env, header) == 80);
7996         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
7997         unsigned char (*header_ref)[80] = &header_arr;
7998         (this_arg_conv->best_block_updated)(this_arg_conv->this_arg, header_ref, height);
7999 }
8000
8001 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_Confirm_1get_1relevant_1txids(JNIEnv *env, jclass clz, int64_t this_arg) {
8002         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
8003         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8004         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
8005         LDKCVec_TxidZ ret_var = (this_arg_conv->get_relevant_txids)(this_arg_conv->this_arg);
8006         jobjectArray ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
8007         ;
8008         for (size_t i = 0; i < ret_var.datalen; i++) {
8009                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 32);
8010                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 32, ret_var.data[i].data);
8011                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
8012         }
8013         FREE(ret_var.data);
8014         return ret_arr;
8015 }
8016
8017 typedef struct LDKPersist_JCalls {
8018         atomic_size_t refcnt;
8019         JavaVM *vm;
8020         jweak o;
8021         jmethodID persist_new_channel_meth;
8022         jmethodID update_persisted_channel_meth;
8023 } LDKPersist_JCalls;
8024 static void LDKPersist_JCalls_free(void* this_arg) {
8025         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
8026         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8027                 JNIEnv *env;
8028                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8029                 if (get_jenv_res == JNI_EDETACHED) {
8030                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8031                 } else {
8032                         DO_ASSERT(get_jenv_res == JNI_OK);
8033                 }
8034                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
8035                 if (get_jenv_res == JNI_EDETACHED) {
8036                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8037                 }
8038                 FREE(j_calls);
8039         }
8040 }
8041 LDKCResult_NoneChannelMonitorUpdateErrZ persist_new_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint id, const LDKChannelMonitor * data) {
8042         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
8043         JNIEnv *env;
8044         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8045         if (get_jenv_res == JNI_EDETACHED) {
8046                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8047         } else {
8048                 DO_ASSERT(get_jenv_res == JNI_OK);
8049         }
8050         LDKOutPoint id_var = id;
8051         CHECK((((uint64_t)id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8052         CHECK((((uint64_t)&id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8053         uint64_t id_ref = (uint64_t)id_var.inner;
8054         if (id_var.is_owned) {
8055                 id_ref |= 1;
8056         }
8057         LDKChannelMonitor data_var = *data;
8058         data_var = ChannelMonitor_clone(data);
8059         CHECK((((uint64_t)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8060         CHECK((((uint64_t)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8061         uint64_t data_ref = (uint64_t)data_var.inner;
8062         if (data_var.is_owned) {
8063                 data_ref |= 1;
8064         }
8065         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8066         CHECK(obj != NULL);
8067         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->persist_new_channel_meth, id_ref, data_ref);
8068         if ((*env)->ExceptionCheck(env)) {
8069                 (*env)->ExceptionDescribe(env);
8070                 (*env)->FatalError(env, "A call to persist_new_channel in LDKPersist from rust threw an exception.");
8071         }
8072         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
8073         CHECK_ACCESS(ret_ptr);
8074         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
8075         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
8076         if (get_jenv_res == JNI_EDETACHED) {
8077                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8078         }
8079         return ret_conv;
8080 }
8081 LDKCResult_NoneChannelMonitorUpdateErrZ update_persisted_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint id, const LDKChannelMonitorUpdate * update, const LDKChannelMonitor * data) {
8082         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
8083         JNIEnv *env;
8084         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8085         if (get_jenv_res == JNI_EDETACHED) {
8086                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8087         } else {
8088                 DO_ASSERT(get_jenv_res == JNI_OK);
8089         }
8090         LDKOutPoint id_var = id;
8091         CHECK((((uint64_t)id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8092         CHECK((((uint64_t)&id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8093         uint64_t id_ref = (uint64_t)id_var.inner;
8094         if (id_var.is_owned) {
8095                 id_ref |= 1;
8096         }
8097         LDKChannelMonitorUpdate update_var = *update;
8098         update_var = ChannelMonitorUpdate_clone(update);
8099         CHECK((((uint64_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8100         CHECK((((uint64_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8101         uint64_t update_ref = (uint64_t)update_var.inner;
8102         if (update_var.is_owned) {
8103                 update_ref |= 1;
8104         }
8105         LDKChannelMonitor data_var = *data;
8106         data_var = ChannelMonitor_clone(data);
8107         CHECK((((uint64_t)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8108         CHECK((((uint64_t)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8109         uint64_t data_ref = (uint64_t)data_var.inner;
8110         if (data_var.is_owned) {
8111                 data_ref |= 1;
8112         }
8113         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8114         CHECK(obj != NULL);
8115         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->update_persisted_channel_meth, id_ref, update_ref, data_ref);
8116         if ((*env)->ExceptionCheck(env)) {
8117                 (*env)->ExceptionDescribe(env);
8118                 (*env)->FatalError(env, "A call to update_persisted_channel in LDKPersist from rust threw an exception.");
8119         }
8120         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
8121         CHECK_ACCESS(ret_ptr);
8122         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
8123         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
8124         if (get_jenv_res == JNI_EDETACHED) {
8125                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8126         }
8127         return ret_conv;
8128 }
8129 static void LDKPersist_JCalls_cloned(LDKPersist* new_obj) {
8130         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) new_obj->this_arg;
8131         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8132 }
8133 static inline LDKPersist LDKPersist_init (JNIEnv *env, jclass clz, jobject o) {
8134         jclass c = (*env)->GetObjectClass(env, o);
8135         CHECK(c != NULL);
8136         LDKPersist_JCalls *calls = MALLOC(sizeof(LDKPersist_JCalls), "LDKPersist_JCalls");
8137         atomic_init(&calls->refcnt, 1);
8138         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
8139         calls->o = (*env)->NewWeakGlobalRef(env, o);
8140         calls->persist_new_channel_meth = (*env)->GetMethodID(env, c, "persist_new_channel", "(JJ)J");
8141         CHECK(calls->persist_new_channel_meth != NULL);
8142         calls->update_persisted_channel_meth = (*env)->GetMethodID(env, c, "update_persisted_channel", "(JJJ)J");
8143         CHECK(calls->update_persisted_channel_meth != NULL);
8144
8145         LDKPersist ret = {
8146                 .this_arg = (void*) calls,
8147                 .persist_new_channel = persist_new_channel_LDKPersist_jcall,
8148                 .update_persisted_channel = update_persisted_channel_LDKPersist_jcall,
8149                 .free = LDKPersist_JCalls_free,
8150         };
8151         return ret;
8152 }
8153 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKPersist_1new(JNIEnv *env, jclass clz, jobject o) {
8154         LDKPersist *res_ptr = MALLOC(sizeof(LDKPersist), "LDKPersist");
8155         *res_ptr = LDKPersist_init(env, clz, o);
8156         return (uint64_t)res_ptr;
8157 }
8158 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) {
8159         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
8160         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8161         LDKPersist* this_arg_conv = (LDKPersist*)this_arg_ptr;
8162         LDKOutPoint id_conv;
8163         id_conv.inner = (void*)(id & (~1));
8164         id_conv.is_owned = (id & 1) || (id == 0);
8165         id_conv = OutPoint_clone(&id_conv);
8166         LDKChannelMonitor data_conv;
8167         data_conv.inner = (void*)(data & (~1));
8168         data_conv.is_owned = false;
8169         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
8170         *ret_conv = (this_arg_conv->persist_new_channel)(this_arg_conv->this_arg, id_conv, &data_conv);
8171         return (uint64_t)ret_conv;
8172 }
8173
8174 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) {
8175         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
8176         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8177         LDKPersist* this_arg_conv = (LDKPersist*)this_arg_ptr;
8178         LDKOutPoint id_conv;
8179         id_conv.inner = (void*)(id & (~1));
8180         id_conv.is_owned = (id & 1) || (id == 0);
8181         id_conv = OutPoint_clone(&id_conv);
8182         LDKChannelMonitorUpdate update_conv;
8183         update_conv.inner = (void*)(update & (~1));
8184         update_conv.is_owned = false;
8185         LDKChannelMonitor data_conv;
8186         data_conv.inner = (void*)(data & (~1));
8187         data_conv.is_owned = false;
8188         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
8189         *ret_conv = (this_arg_conv->update_persisted_channel)(this_arg_conv->this_arg, id_conv, &update_conv, &data_conv);
8190         return (uint64_t)ret_conv;
8191 }
8192
8193 typedef struct LDKChannelMessageHandler_JCalls {
8194         atomic_size_t refcnt;
8195         JavaVM *vm;
8196         jweak o;
8197         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
8198         jmethodID handle_open_channel_meth;
8199         jmethodID handle_accept_channel_meth;
8200         jmethodID handle_funding_created_meth;
8201         jmethodID handle_funding_signed_meth;
8202         jmethodID handle_funding_locked_meth;
8203         jmethodID handle_shutdown_meth;
8204         jmethodID handle_closing_signed_meth;
8205         jmethodID handle_update_add_htlc_meth;
8206         jmethodID handle_update_fulfill_htlc_meth;
8207         jmethodID handle_update_fail_htlc_meth;
8208         jmethodID handle_update_fail_malformed_htlc_meth;
8209         jmethodID handle_commitment_signed_meth;
8210         jmethodID handle_revoke_and_ack_meth;
8211         jmethodID handle_update_fee_meth;
8212         jmethodID handle_announcement_signatures_meth;
8213         jmethodID peer_disconnected_meth;
8214         jmethodID peer_connected_meth;
8215         jmethodID handle_channel_reestablish_meth;
8216         jmethodID handle_channel_update_meth;
8217         jmethodID handle_error_meth;
8218 } LDKChannelMessageHandler_JCalls;
8219 static void LDKChannelMessageHandler_JCalls_free(void* this_arg) {
8220         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8221         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8222                 JNIEnv *env;
8223                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8224                 if (get_jenv_res == JNI_EDETACHED) {
8225                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8226                 } else {
8227                         DO_ASSERT(get_jenv_res == JNI_OK);
8228                 }
8229                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
8230                 if (get_jenv_res == JNI_EDETACHED) {
8231                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8232                 }
8233                 FREE(j_calls);
8234         }
8235 }
8236 void handle_open_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKOpenChannel * msg) {
8237         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8238         JNIEnv *env;
8239         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8240         if (get_jenv_res == JNI_EDETACHED) {
8241                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8242         } else {
8243                 DO_ASSERT(get_jenv_res == JNI_OK);
8244         }
8245         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8246         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8247         LDKInitFeatures their_features_var = their_features;
8248         CHECK((((uint64_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8249         CHECK((((uint64_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8250         uint64_t their_features_ref = (uint64_t)their_features_var.inner;
8251         if (their_features_var.is_owned) {
8252                 their_features_ref |= 1;
8253         }
8254         LDKOpenChannel msg_var = *msg;
8255         msg_var = OpenChannel_clone(msg);
8256         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8257         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8258         uint64_t msg_ref = (uint64_t)msg_var.inner;
8259         if (msg_var.is_owned) {
8260                 msg_ref |= 1;
8261         }
8262         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8263         CHECK(obj != NULL);
8264         (*env)->CallVoidMethod(env, obj, j_calls->handle_open_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
8265         if ((*env)->ExceptionCheck(env)) {
8266                 (*env)->ExceptionDescribe(env);
8267                 (*env)->FatalError(env, "A call to handle_open_channel in LDKChannelMessageHandler from rust threw an exception.");
8268         }
8269         if (get_jenv_res == JNI_EDETACHED) {
8270                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8271         }
8272 }
8273 void handle_accept_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKAcceptChannel * msg) {
8274         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8275         JNIEnv *env;
8276         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8277         if (get_jenv_res == JNI_EDETACHED) {
8278                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8279         } else {
8280                 DO_ASSERT(get_jenv_res == JNI_OK);
8281         }
8282         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8283         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8284         LDKInitFeatures their_features_var = their_features;
8285         CHECK((((uint64_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8286         CHECK((((uint64_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8287         uint64_t their_features_ref = (uint64_t)their_features_var.inner;
8288         if (their_features_var.is_owned) {
8289                 their_features_ref |= 1;
8290         }
8291         LDKAcceptChannel msg_var = *msg;
8292         msg_var = AcceptChannel_clone(msg);
8293         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8294         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8295         uint64_t msg_ref = (uint64_t)msg_var.inner;
8296         if (msg_var.is_owned) {
8297                 msg_ref |= 1;
8298         }
8299         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8300         CHECK(obj != NULL);
8301         (*env)->CallVoidMethod(env, obj, j_calls->handle_accept_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
8302         if ((*env)->ExceptionCheck(env)) {
8303                 (*env)->ExceptionDescribe(env);
8304                 (*env)->FatalError(env, "A call to handle_accept_channel in LDKChannelMessageHandler from rust threw an exception.");
8305         }
8306         if (get_jenv_res == JNI_EDETACHED) {
8307                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8308         }
8309 }
8310 void handle_funding_created_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingCreated * msg) {
8311         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8312         JNIEnv *env;
8313         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8314         if (get_jenv_res == JNI_EDETACHED) {
8315                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8316         } else {
8317                 DO_ASSERT(get_jenv_res == JNI_OK);
8318         }
8319         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8320         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8321         LDKFundingCreated msg_var = *msg;
8322         msg_var = FundingCreated_clone(msg);
8323         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8324         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8325         uint64_t msg_ref = (uint64_t)msg_var.inner;
8326         if (msg_var.is_owned) {
8327                 msg_ref |= 1;
8328         }
8329         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8330         CHECK(obj != NULL);
8331         (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_created_meth, their_node_id_arr, msg_ref);
8332         if ((*env)->ExceptionCheck(env)) {
8333                 (*env)->ExceptionDescribe(env);
8334                 (*env)->FatalError(env, "A call to handle_funding_created in LDKChannelMessageHandler from rust threw an exception.");
8335         }
8336         if (get_jenv_res == JNI_EDETACHED) {
8337                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8338         }
8339 }
8340 void handle_funding_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingSigned * msg) {
8341         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8342         JNIEnv *env;
8343         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8344         if (get_jenv_res == JNI_EDETACHED) {
8345                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8346         } else {
8347                 DO_ASSERT(get_jenv_res == JNI_OK);
8348         }
8349         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8350         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8351         LDKFundingSigned msg_var = *msg;
8352         msg_var = FundingSigned_clone(msg);
8353         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8354         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8355         uint64_t msg_ref = (uint64_t)msg_var.inner;
8356         if (msg_var.is_owned) {
8357                 msg_ref |= 1;
8358         }
8359         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8360         CHECK(obj != NULL);
8361         (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_signed_meth, their_node_id_arr, msg_ref);
8362         if ((*env)->ExceptionCheck(env)) {
8363                 (*env)->ExceptionDescribe(env);
8364                 (*env)->FatalError(env, "A call to handle_funding_signed in LDKChannelMessageHandler from rust threw an exception.");
8365         }
8366         if (get_jenv_res == JNI_EDETACHED) {
8367                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8368         }
8369 }
8370 void handle_funding_locked_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingLocked * msg) {
8371         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8372         JNIEnv *env;
8373         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8374         if (get_jenv_res == JNI_EDETACHED) {
8375                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8376         } else {
8377                 DO_ASSERT(get_jenv_res == JNI_OK);
8378         }
8379         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8380         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8381         LDKFundingLocked msg_var = *msg;
8382         msg_var = FundingLocked_clone(msg);
8383         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8384         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8385         uint64_t msg_ref = (uint64_t)msg_var.inner;
8386         if (msg_var.is_owned) {
8387                 msg_ref |= 1;
8388         }
8389         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8390         CHECK(obj != NULL);
8391         (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_locked_meth, their_node_id_arr, msg_ref);
8392         if ((*env)->ExceptionCheck(env)) {
8393                 (*env)->ExceptionDescribe(env);
8394                 (*env)->FatalError(env, "A call to handle_funding_locked in LDKChannelMessageHandler from rust threw an exception.");
8395         }
8396         if (get_jenv_res == JNI_EDETACHED) {
8397                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8398         }
8399 }
8400 void handle_shutdown_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInitFeatures * their_features, const LDKShutdown * msg) {
8401         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8402         JNIEnv *env;
8403         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8404         if (get_jenv_res == JNI_EDETACHED) {
8405                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8406         } else {
8407                 DO_ASSERT(get_jenv_res == JNI_OK);
8408         }
8409         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8410         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8411         LDKInitFeatures their_features_var = *their_features;
8412         their_features_var = InitFeatures_clone(their_features);
8413         CHECK((((uint64_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8414         CHECK((((uint64_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8415         uint64_t their_features_ref = (uint64_t)their_features_var.inner;
8416         if (their_features_var.is_owned) {
8417                 their_features_ref |= 1;
8418         }
8419         LDKShutdown msg_var = *msg;
8420         msg_var = Shutdown_clone(msg);
8421         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8422         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8423         uint64_t msg_ref = (uint64_t)msg_var.inner;
8424         if (msg_var.is_owned) {
8425                 msg_ref |= 1;
8426         }
8427         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8428         CHECK(obj != NULL);
8429         (*env)->CallVoidMethod(env, obj, j_calls->handle_shutdown_meth, their_node_id_arr, their_features_ref, msg_ref);
8430         if ((*env)->ExceptionCheck(env)) {
8431                 (*env)->ExceptionDescribe(env);
8432                 (*env)->FatalError(env, "A call to handle_shutdown in LDKChannelMessageHandler from rust threw an exception.");
8433         }
8434         if (get_jenv_res == JNI_EDETACHED) {
8435                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8436         }
8437 }
8438 void handle_closing_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKClosingSigned * msg) {
8439         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8440         JNIEnv *env;
8441         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8442         if (get_jenv_res == JNI_EDETACHED) {
8443                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8444         } else {
8445                 DO_ASSERT(get_jenv_res == JNI_OK);
8446         }
8447         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8448         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8449         LDKClosingSigned msg_var = *msg;
8450         msg_var = ClosingSigned_clone(msg);
8451         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8452         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8453         uint64_t msg_ref = (uint64_t)msg_var.inner;
8454         if (msg_var.is_owned) {
8455                 msg_ref |= 1;
8456         }
8457         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8458         CHECK(obj != NULL);
8459         (*env)->CallVoidMethod(env, obj, j_calls->handle_closing_signed_meth, their_node_id_arr, msg_ref);
8460         if ((*env)->ExceptionCheck(env)) {
8461                 (*env)->ExceptionDescribe(env);
8462                 (*env)->FatalError(env, "A call to handle_closing_signed in LDKChannelMessageHandler from rust threw an exception.");
8463         }
8464         if (get_jenv_res == JNI_EDETACHED) {
8465                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8466         }
8467 }
8468 void handle_update_add_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateAddHTLC * msg) {
8469         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8470         JNIEnv *env;
8471         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8472         if (get_jenv_res == JNI_EDETACHED) {
8473                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8474         } else {
8475                 DO_ASSERT(get_jenv_res == JNI_OK);
8476         }
8477         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8478         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8479         LDKUpdateAddHTLC msg_var = *msg;
8480         msg_var = UpdateAddHTLC_clone(msg);
8481         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8482         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8483         uint64_t msg_ref = (uint64_t)msg_var.inner;
8484         if (msg_var.is_owned) {
8485                 msg_ref |= 1;
8486         }
8487         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8488         CHECK(obj != NULL);
8489         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_add_htlc_meth, their_node_id_arr, msg_ref);
8490         if ((*env)->ExceptionCheck(env)) {
8491                 (*env)->ExceptionDescribe(env);
8492                 (*env)->FatalError(env, "A call to handle_update_add_htlc in LDKChannelMessageHandler from rust threw an exception.");
8493         }
8494         if (get_jenv_res == JNI_EDETACHED) {
8495                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8496         }
8497 }
8498 void handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFulfillHTLC * msg) {
8499         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8500         JNIEnv *env;
8501         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8502         if (get_jenv_res == JNI_EDETACHED) {
8503                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8504         } else {
8505                 DO_ASSERT(get_jenv_res == JNI_OK);
8506         }
8507         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8508         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8509         LDKUpdateFulfillHTLC msg_var = *msg;
8510         msg_var = UpdateFulfillHTLC_clone(msg);
8511         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8512         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8513         uint64_t msg_ref = (uint64_t)msg_var.inner;
8514         if (msg_var.is_owned) {
8515                 msg_ref |= 1;
8516         }
8517         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8518         CHECK(obj != NULL);
8519         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fulfill_htlc_meth, their_node_id_arr, msg_ref);
8520         if ((*env)->ExceptionCheck(env)) {
8521                 (*env)->ExceptionDescribe(env);
8522                 (*env)->FatalError(env, "A call to handle_update_fulfill_htlc in LDKChannelMessageHandler from rust threw an exception.");
8523         }
8524         if (get_jenv_res == JNI_EDETACHED) {
8525                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8526         }
8527 }
8528 void handle_update_fail_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailHTLC * msg) {
8529         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8530         JNIEnv *env;
8531         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8532         if (get_jenv_res == JNI_EDETACHED) {
8533                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8534         } else {
8535                 DO_ASSERT(get_jenv_res == JNI_OK);
8536         }
8537         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8538         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8539         LDKUpdateFailHTLC msg_var = *msg;
8540         msg_var = UpdateFailHTLC_clone(msg);
8541         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8542         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8543         uint64_t msg_ref = (uint64_t)msg_var.inner;
8544         if (msg_var.is_owned) {
8545                 msg_ref |= 1;
8546         }
8547         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8548         CHECK(obj != NULL);
8549         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fail_htlc_meth, their_node_id_arr, msg_ref);
8550         if ((*env)->ExceptionCheck(env)) {
8551                 (*env)->ExceptionDescribe(env);
8552                 (*env)->FatalError(env, "A call to handle_update_fail_htlc in LDKChannelMessageHandler from rust threw an exception.");
8553         }
8554         if (get_jenv_res == JNI_EDETACHED) {
8555                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8556         }
8557 }
8558 void handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailMalformedHTLC * msg) {
8559         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8560         JNIEnv *env;
8561         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8562         if (get_jenv_res == JNI_EDETACHED) {
8563                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8564         } else {
8565                 DO_ASSERT(get_jenv_res == JNI_OK);
8566         }
8567         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8568         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8569         LDKUpdateFailMalformedHTLC msg_var = *msg;
8570         msg_var = UpdateFailMalformedHTLC_clone(msg);
8571         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8572         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8573         uint64_t msg_ref = (uint64_t)msg_var.inner;
8574         if (msg_var.is_owned) {
8575                 msg_ref |= 1;
8576         }
8577         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8578         CHECK(obj != NULL);
8579         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fail_malformed_htlc_meth, their_node_id_arr, msg_ref);
8580         if ((*env)->ExceptionCheck(env)) {
8581                 (*env)->ExceptionDescribe(env);
8582                 (*env)->FatalError(env, "A call to handle_update_fail_malformed_htlc in LDKChannelMessageHandler from rust threw an exception.");
8583         }
8584         if (get_jenv_res == JNI_EDETACHED) {
8585                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8586         }
8587 }
8588 void handle_commitment_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKCommitmentSigned * msg) {
8589         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8590         JNIEnv *env;
8591         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8592         if (get_jenv_res == JNI_EDETACHED) {
8593                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8594         } else {
8595                 DO_ASSERT(get_jenv_res == JNI_OK);
8596         }
8597         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8598         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8599         LDKCommitmentSigned msg_var = *msg;
8600         msg_var = CommitmentSigned_clone(msg);
8601         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8602         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8603         uint64_t msg_ref = (uint64_t)msg_var.inner;
8604         if (msg_var.is_owned) {
8605                 msg_ref |= 1;
8606         }
8607         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8608         CHECK(obj != NULL);
8609         (*env)->CallVoidMethod(env, obj, j_calls->handle_commitment_signed_meth, their_node_id_arr, msg_ref);
8610         if ((*env)->ExceptionCheck(env)) {
8611                 (*env)->ExceptionDescribe(env);
8612                 (*env)->FatalError(env, "A call to handle_commitment_signed in LDKChannelMessageHandler from rust threw an exception.");
8613         }
8614         if (get_jenv_res == JNI_EDETACHED) {
8615                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8616         }
8617 }
8618 void handle_revoke_and_ack_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKRevokeAndACK * msg) {
8619         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8620         JNIEnv *env;
8621         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8622         if (get_jenv_res == JNI_EDETACHED) {
8623                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8624         } else {
8625                 DO_ASSERT(get_jenv_res == JNI_OK);
8626         }
8627         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8628         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8629         LDKRevokeAndACK msg_var = *msg;
8630         msg_var = RevokeAndACK_clone(msg);
8631         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8632         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8633         uint64_t msg_ref = (uint64_t)msg_var.inner;
8634         if (msg_var.is_owned) {
8635                 msg_ref |= 1;
8636         }
8637         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8638         CHECK(obj != NULL);
8639         (*env)->CallVoidMethod(env, obj, j_calls->handle_revoke_and_ack_meth, their_node_id_arr, msg_ref);
8640         if ((*env)->ExceptionCheck(env)) {
8641                 (*env)->ExceptionDescribe(env);
8642                 (*env)->FatalError(env, "A call to handle_revoke_and_ack in LDKChannelMessageHandler from rust threw an exception.");
8643         }
8644         if (get_jenv_res == JNI_EDETACHED) {
8645                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8646         }
8647 }
8648 void handle_update_fee_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFee * msg) {
8649         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8650         JNIEnv *env;
8651         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8652         if (get_jenv_res == JNI_EDETACHED) {
8653                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8654         } else {
8655                 DO_ASSERT(get_jenv_res == JNI_OK);
8656         }
8657         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8658         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8659         LDKUpdateFee msg_var = *msg;
8660         msg_var = UpdateFee_clone(msg);
8661         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8662         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8663         uint64_t msg_ref = (uint64_t)msg_var.inner;
8664         if (msg_var.is_owned) {
8665                 msg_ref |= 1;
8666         }
8667         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8668         CHECK(obj != NULL);
8669         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fee_meth, their_node_id_arr, msg_ref);
8670         if ((*env)->ExceptionCheck(env)) {
8671                 (*env)->ExceptionDescribe(env);
8672                 (*env)->FatalError(env, "A call to handle_update_fee in LDKChannelMessageHandler from rust threw an exception.");
8673         }
8674         if (get_jenv_res == JNI_EDETACHED) {
8675                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8676         }
8677 }
8678 void handle_announcement_signatures_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKAnnouncementSignatures * msg) {
8679         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8680         JNIEnv *env;
8681         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8682         if (get_jenv_res == JNI_EDETACHED) {
8683                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8684         } else {
8685                 DO_ASSERT(get_jenv_res == JNI_OK);
8686         }
8687         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8688         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8689         LDKAnnouncementSignatures msg_var = *msg;
8690         msg_var = AnnouncementSignatures_clone(msg);
8691         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8692         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8693         uint64_t msg_ref = (uint64_t)msg_var.inner;
8694         if (msg_var.is_owned) {
8695                 msg_ref |= 1;
8696         }
8697         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8698         CHECK(obj != NULL);
8699         (*env)->CallVoidMethod(env, obj, j_calls->handle_announcement_signatures_meth, their_node_id_arr, msg_ref);
8700         if ((*env)->ExceptionCheck(env)) {
8701                 (*env)->ExceptionDescribe(env);
8702                 (*env)->FatalError(env, "A call to handle_announcement_signatures in LDKChannelMessageHandler from rust threw an exception.");
8703         }
8704         if (get_jenv_res == JNI_EDETACHED) {
8705                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8706         }
8707 }
8708 void peer_disconnected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, bool no_connection_possible) {
8709         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8710         JNIEnv *env;
8711         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8712         if (get_jenv_res == JNI_EDETACHED) {
8713                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8714         } else {
8715                 DO_ASSERT(get_jenv_res == JNI_OK);
8716         }
8717         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8718         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8719         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8720         CHECK(obj != NULL);
8721         (*env)->CallVoidMethod(env, obj, j_calls->peer_disconnected_meth, their_node_id_arr, no_connection_possible);
8722         if ((*env)->ExceptionCheck(env)) {
8723                 (*env)->ExceptionDescribe(env);
8724                 (*env)->FatalError(env, "A call to peer_disconnected in LDKChannelMessageHandler from rust threw an exception.");
8725         }
8726         if (get_jenv_res == JNI_EDETACHED) {
8727                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8728         }
8729 }
8730 void peer_connected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * msg) {
8731         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8732         JNIEnv *env;
8733         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8734         if (get_jenv_res == JNI_EDETACHED) {
8735                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8736         } else {
8737                 DO_ASSERT(get_jenv_res == JNI_OK);
8738         }
8739         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8740         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8741         LDKInit msg_var = *msg;
8742         msg_var = Init_clone(msg);
8743         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8744         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8745         uint64_t msg_ref = (uint64_t)msg_var.inner;
8746         if (msg_var.is_owned) {
8747                 msg_ref |= 1;
8748         }
8749         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8750         CHECK(obj != NULL);
8751         (*env)->CallVoidMethod(env, obj, j_calls->peer_connected_meth, their_node_id_arr, msg_ref);
8752         if ((*env)->ExceptionCheck(env)) {
8753                 (*env)->ExceptionDescribe(env);
8754                 (*env)->FatalError(env, "A call to peer_connected in LDKChannelMessageHandler from rust threw an exception.");
8755         }
8756         if (get_jenv_res == JNI_EDETACHED) {
8757                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8758         }
8759 }
8760 void handle_channel_reestablish_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelReestablish * msg) {
8761         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8762         JNIEnv *env;
8763         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8764         if (get_jenv_res == JNI_EDETACHED) {
8765                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8766         } else {
8767                 DO_ASSERT(get_jenv_res == JNI_OK);
8768         }
8769         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8770         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8771         LDKChannelReestablish msg_var = *msg;
8772         msg_var = ChannelReestablish_clone(msg);
8773         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8774         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8775         uint64_t msg_ref = (uint64_t)msg_var.inner;
8776         if (msg_var.is_owned) {
8777                 msg_ref |= 1;
8778         }
8779         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8780         CHECK(obj != NULL);
8781         (*env)->CallVoidMethod(env, obj, j_calls->handle_channel_reestablish_meth, their_node_id_arr, msg_ref);
8782         if ((*env)->ExceptionCheck(env)) {
8783                 (*env)->ExceptionDescribe(env);
8784                 (*env)->FatalError(env, "A call to handle_channel_reestablish in LDKChannelMessageHandler from rust threw an exception.");
8785         }
8786         if (get_jenv_res == JNI_EDETACHED) {
8787                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8788         }
8789 }
8790 void handle_channel_update_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelUpdate * msg) {
8791         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8792         JNIEnv *env;
8793         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8794         if (get_jenv_res == JNI_EDETACHED) {
8795                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8796         } else {
8797                 DO_ASSERT(get_jenv_res == JNI_OK);
8798         }
8799         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8800         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8801         LDKChannelUpdate msg_var = *msg;
8802         msg_var = ChannelUpdate_clone(msg);
8803         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8804         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8805         uint64_t msg_ref = (uint64_t)msg_var.inner;
8806         if (msg_var.is_owned) {
8807                 msg_ref |= 1;
8808         }
8809         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8810         CHECK(obj != NULL);
8811         (*env)->CallVoidMethod(env, obj, j_calls->handle_channel_update_meth, their_node_id_arr, msg_ref);
8812         if ((*env)->ExceptionCheck(env)) {
8813                 (*env)->ExceptionDescribe(env);
8814                 (*env)->FatalError(env, "A call to handle_channel_update in LDKChannelMessageHandler from rust threw an exception.");
8815         }
8816         if (get_jenv_res == JNI_EDETACHED) {
8817                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8818         }
8819 }
8820 void handle_error_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKErrorMessage * msg) {
8821         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8822         JNIEnv *env;
8823         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8824         if (get_jenv_res == JNI_EDETACHED) {
8825                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8826         } else {
8827                 DO_ASSERT(get_jenv_res == JNI_OK);
8828         }
8829         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8830         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8831         LDKErrorMessage msg_var = *msg;
8832         msg_var = ErrorMessage_clone(msg);
8833         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8834         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8835         uint64_t msg_ref = (uint64_t)msg_var.inner;
8836         if (msg_var.is_owned) {
8837                 msg_ref |= 1;
8838         }
8839         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8840         CHECK(obj != NULL);
8841         (*env)->CallVoidMethod(env, obj, j_calls->handle_error_meth, their_node_id_arr, msg_ref);
8842         if ((*env)->ExceptionCheck(env)) {
8843                 (*env)->ExceptionDescribe(env);
8844                 (*env)->FatalError(env, "A call to handle_error in LDKChannelMessageHandler from rust threw an exception.");
8845         }
8846         if (get_jenv_res == JNI_EDETACHED) {
8847                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8848         }
8849 }
8850 static void LDKChannelMessageHandler_JCalls_cloned(LDKChannelMessageHandler* new_obj) {
8851         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) new_obj->this_arg;
8852         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8853         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
8854 }
8855 static inline LDKChannelMessageHandler LDKChannelMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
8856         jclass c = (*env)->GetObjectClass(env, o);
8857         CHECK(c != NULL);
8858         LDKChannelMessageHandler_JCalls *calls = MALLOC(sizeof(LDKChannelMessageHandler_JCalls), "LDKChannelMessageHandler_JCalls");
8859         atomic_init(&calls->refcnt, 1);
8860         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
8861         calls->o = (*env)->NewWeakGlobalRef(env, o);
8862         calls->handle_open_channel_meth = (*env)->GetMethodID(env, c, "handle_open_channel", "([BJJ)V");
8863         CHECK(calls->handle_open_channel_meth != NULL);
8864         calls->handle_accept_channel_meth = (*env)->GetMethodID(env, c, "handle_accept_channel", "([BJJ)V");
8865         CHECK(calls->handle_accept_channel_meth != NULL);
8866         calls->handle_funding_created_meth = (*env)->GetMethodID(env, c, "handle_funding_created", "([BJ)V");
8867         CHECK(calls->handle_funding_created_meth != NULL);
8868         calls->handle_funding_signed_meth = (*env)->GetMethodID(env, c, "handle_funding_signed", "([BJ)V");
8869         CHECK(calls->handle_funding_signed_meth != NULL);
8870         calls->handle_funding_locked_meth = (*env)->GetMethodID(env, c, "handle_funding_locked", "([BJ)V");
8871         CHECK(calls->handle_funding_locked_meth != NULL);
8872         calls->handle_shutdown_meth = (*env)->GetMethodID(env, c, "handle_shutdown", "([BJJ)V");
8873         CHECK(calls->handle_shutdown_meth != NULL);
8874         calls->handle_closing_signed_meth = (*env)->GetMethodID(env, c, "handle_closing_signed", "([BJ)V");
8875         CHECK(calls->handle_closing_signed_meth != NULL);
8876         calls->handle_update_add_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_add_htlc", "([BJ)V");
8877         CHECK(calls->handle_update_add_htlc_meth != NULL);
8878         calls->handle_update_fulfill_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fulfill_htlc", "([BJ)V");
8879         CHECK(calls->handle_update_fulfill_htlc_meth != NULL);
8880         calls->handle_update_fail_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fail_htlc", "([BJ)V");
8881         CHECK(calls->handle_update_fail_htlc_meth != NULL);
8882         calls->handle_update_fail_malformed_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fail_malformed_htlc", "([BJ)V");
8883         CHECK(calls->handle_update_fail_malformed_htlc_meth != NULL);
8884         calls->handle_commitment_signed_meth = (*env)->GetMethodID(env, c, "handle_commitment_signed", "([BJ)V");
8885         CHECK(calls->handle_commitment_signed_meth != NULL);
8886         calls->handle_revoke_and_ack_meth = (*env)->GetMethodID(env, c, "handle_revoke_and_ack", "([BJ)V");
8887         CHECK(calls->handle_revoke_and_ack_meth != NULL);
8888         calls->handle_update_fee_meth = (*env)->GetMethodID(env, c, "handle_update_fee", "([BJ)V");
8889         CHECK(calls->handle_update_fee_meth != NULL);
8890         calls->handle_announcement_signatures_meth = (*env)->GetMethodID(env, c, "handle_announcement_signatures", "([BJ)V");
8891         CHECK(calls->handle_announcement_signatures_meth != NULL);
8892         calls->peer_disconnected_meth = (*env)->GetMethodID(env, c, "peer_disconnected", "([BZ)V");
8893         CHECK(calls->peer_disconnected_meth != NULL);
8894         calls->peer_connected_meth = (*env)->GetMethodID(env, c, "peer_connected", "([BJ)V");
8895         CHECK(calls->peer_connected_meth != NULL);
8896         calls->handle_channel_reestablish_meth = (*env)->GetMethodID(env, c, "handle_channel_reestablish", "([BJ)V");
8897         CHECK(calls->handle_channel_reestablish_meth != NULL);
8898         calls->handle_channel_update_meth = (*env)->GetMethodID(env, c, "handle_channel_update", "([BJ)V");
8899         CHECK(calls->handle_channel_update_meth != NULL);
8900         calls->handle_error_meth = (*env)->GetMethodID(env, c, "handle_error", "([BJ)V");
8901         CHECK(calls->handle_error_meth != NULL);
8902
8903         LDKChannelMessageHandler ret = {
8904                 .this_arg = (void*) calls,
8905                 .handle_open_channel = handle_open_channel_LDKChannelMessageHandler_jcall,
8906                 .handle_accept_channel = handle_accept_channel_LDKChannelMessageHandler_jcall,
8907                 .handle_funding_created = handle_funding_created_LDKChannelMessageHandler_jcall,
8908                 .handle_funding_signed = handle_funding_signed_LDKChannelMessageHandler_jcall,
8909                 .handle_funding_locked = handle_funding_locked_LDKChannelMessageHandler_jcall,
8910                 .handle_shutdown = handle_shutdown_LDKChannelMessageHandler_jcall,
8911                 .handle_closing_signed = handle_closing_signed_LDKChannelMessageHandler_jcall,
8912                 .handle_update_add_htlc = handle_update_add_htlc_LDKChannelMessageHandler_jcall,
8913                 .handle_update_fulfill_htlc = handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall,
8914                 .handle_update_fail_htlc = handle_update_fail_htlc_LDKChannelMessageHandler_jcall,
8915                 .handle_update_fail_malformed_htlc = handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall,
8916                 .handle_commitment_signed = handle_commitment_signed_LDKChannelMessageHandler_jcall,
8917                 .handle_revoke_and_ack = handle_revoke_and_ack_LDKChannelMessageHandler_jcall,
8918                 .handle_update_fee = handle_update_fee_LDKChannelMessageHandler_jcall,
8919                 .handle_announcement_signatures = handle_announcement_signatures_LDKChannelMessageHandler_jcall,
8920                 .peer_disconnected = peer_disconnected_LDKChannelMessageHandler_jcall,
8921                 .peer_connected = peer_connected_LDKChannelMessageHandler_jcall,
8922                 .handle_channel_reestablish = handle_channel_reestablish_LDKChannelMessageHandler_jcall,
8923                 .handle_channel_update = handle_channel_update_LDKChannelMessageHandler_jcall,
8924                 .handle_error = handle_error_LDKChannelMessageHandler_jcall,
8925                 .free = LDKChannelMessageHandler_JCalls_free,
8926                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(env, clz, MessageSendEventsProvider),
8927         };
8928         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
8929         return ret;
8930 }
8931 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
8932         LDKChannelMessageHandler *res_ptr = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
8933         *res_ptr = LDKChannelMessageHandler_init(env, clz, o, MessageSendEventsProvider);
8934         return (uint64_t)res_ptr;
8935 }
8936 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1get_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t arg) {
8937         LDKChannelMessageHandler *inp = (LDKChannelMessageHandler *)(arg & ~1);
8938         uint64_t res_ptr = (uint64_t)&inp->MessageSendEventsProvider;
8939         DO_ASSERT((res_ptr & 1) == 0);
8940         return (int64_t)(res_ptr | 1);
8941 }
8942 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) {
8943         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
8944         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8945         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
8946         LDKPublicKey their_node_id_ref;
8947         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8948         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8949         LDKInitFeatures their_features_conv;
8950         their_features_conv.inner = (void*)(their_features & (~1));
8951         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
8952         their_features_conv = InitFeatures_clone(&their_features_conv);
8953         LDKOpenChannel msg_conv;
8954         msg_conv.inner = (void*)(msg & (~1));
8955         msg_conv.is_owned = false;
8956         (this_arg_conv->handle_open_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
8957 }
8958
8959 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) {
8960         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
8961         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8962         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
8963         LDKPublicKey their_node_id_ref;
8964         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8965         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8966         LDKInitFeatures their_features_conv;
8967         their_features_conv.inner = (void*)(their_features & (~1));
8968         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
8969         their_features_conv = InitFeatures_clone(&their_features_conv);
8970         LDKAcceptChannel msg_conv;
8971         msg_conv.inner = (void*)(msg & (~1));
8972         msg_conv.is_owned = false;
8973         (this_arg_conv->handle_accept_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
8974 }
8975
8976 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) {
8977         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
8978         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8979         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
8980         LDKPublicKey their_node_id_ref;
8981         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8982         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8983         LDKFundingCreated msg_conv;
8984         msg_conv.inner = (void*)(msg & (~1));
8985         msg_conv.is_owned = false;
8986         (this_arg_conv->handle_funding_created)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8987 }
8988
8989 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) {
8990         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
8991         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8992         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
8993         LDKPublicKey their_node_id_ref;
8994         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8995         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8996         LDKFundingSigned msg_conv;
8997         msg_conv.inner = (void*)(msg & (~1));
8998         msg_conv.is_owned = false;
8999         (this_arg_conv->handle_funding_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9000 }
9001
9002 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) {
9003         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
9004         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9005         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9006         LDKPublicKey their_node_id_ref;
9007         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9008         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9009         LDKFundingLocked msg_conv;
9010         msg_conv.inner = (void*)(msg & (~1));
9011         msg_conv.is_owned = false;
9012         (this_arg_conv->handle_funding_locked)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9013 }
9014
9015 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) {
9016         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
9017         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9018         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9019         LDKPublicKey their_node_id_ref;
9020         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9021         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9022         LDKInitFeatures their_features_conv;
9023         their_features_conv.inner = (void*)(their_features & (~1));
9024         their_features_conv.is_owned = false;
9025         LDKShutdown msg_conv;
9026         msg_conv.inner = (void*)(msg & (~1));
9027         msg_conv.is_owned = false;
9028         (this_arg_conv->handle_shutdown)(this_arg_conv->this_arg, their_node_id_ref, &their_features_conv, &msg_conv);
9029 }
9030
9031 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) {
9032         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
9033         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9034         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9035         LDKPublicKey their_node_id_ref;
9036         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9037         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9038         LDKClosingSigned msg_conv;
9039         msg_conv.inner = (void*)(msg & (~1));
9040         msg_conv.is_owned = false;
9041         (this_arg_conv->handle_closing_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9042 }
9043
9044 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) {
9045         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
9046         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9047         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9048         LDKPublicKey their_node_id_ref;
9049         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9050         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9051         LDKUpdateAddHTLC msg_conv;
9052         msg_conv.inner = (void*)(msg & (~1));
9053         msg_conv.is_owned = false;
9054         (this_arg_conv->handle_update_add_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9055 }
9056
9057 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) {
9058         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
9059         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9060         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9061         LDKPublicKey their_node_id_ref;
9062         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9063         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9064         LDKUpdateFulfillHTLC msg_conv;
9065         msg_conv.inner = (void*)(msg & (~1));
9066         msg_conv.is_owned = false;
9067         (this_arg_conv->handle_update_fulfill_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9068 }
9069
9070 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) {
9071         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
9072         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9073         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9074         LDKPublicKey their_node_id_ref;
9075         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9076         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9077         LDKUpdateFailHTLC msg_conv;
9078         msg_conv.inner = (void*)(msg & (~1));
9079         msg_conv.is_owned = false;
9080         (this_arg_conv->handle_update_fail_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9081 }
9082
9083 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) {
9084         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
9085         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9086         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
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         LDKUpdateFailMalformedHTLC msg_conv;
9091         msg_conv.inner = (void*)(msg & (~1));
9092         msg_conv.is_owned = false;
9093         (this_arg_conv->handle_update_fail_malformed_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_1commitment_1signed(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
9097         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
9098         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9099         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9100         LDKPublicKey their_node_id_ref;
9101         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9102         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9103         LDKCommitmentSigned msg_conv;
9104         msg_conv.inner = (void*)(msg & (~1));
9105         msg_conv.is_owned = false;
9106         (this_arg_conv->handle_commitment_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9107 }
9108
9109 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) {
9110         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
9111         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9112         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9113         LDKPublicKey their_node_id_ref;
9114         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9115         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9116         LDKRevokeAndACK msg_conv;
9117         msg_conv.inner = (void*)(msg & (~1));
9118         msg_conv.is_owned = false;
9119         (this_arg_conv->handle_revoke_and_ack)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9120 }
9121
9122 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) {
9123         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
9124         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9125         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9126         LDKPublicKey their_node_id_ref;
9127         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9128         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9129         LDKUpdateFee msg_conv;
9130         msg_conv.inner = (void*)(msg & (~1));
9131         msg_conv.is_owned = false;
9132         (this_arg_conv->handle_update_fee)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9133 }
9134
9135 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) {
9136         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
9137         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9138         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9139         LDKPublicKey their_node_id_ref;
9140         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9141         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9142         LDKAnnouncementSignatures msg_conv;
9143         msg_conv.inner = (void*)(msg & (~1));
9144         msg_conv.is_owned = false;
9145         (this_arg_conv->handle_announcement_signatures)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9146 }
9147
9148 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) {
9149         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
9150         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9151         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9152         LDKPublicKey their_node_id_ref;
9153         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9154         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9155         (this_arg_conv->peer_disconnected)(this_arg_conv->this_arg, their_node_id_ref, no_connection_possible);
9156 }
9157
9158 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) {
9159         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
9160         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9161         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9162         LDKPublicKey their_node_id_ref;
9163         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9164         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9165         LDKInit msg_conv;
9166         msg_conv.inner = (void*)(msg & (~1));
9167         msg_conv.is_owned = false;
9168         (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9169 }
9170
9171 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) {
9172         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
9173         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9174         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9175         LDKPublicKey their_node_id_ref;
9176         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9177         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9178         LDKChannelReestablish msg_conv;
9179         msg_conv.inner = (void*)(msg & (~1));
9180         msg_conv.is_owned = false;
9181         (this_arg_conv->handle_channel_reestablish)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9182 }
9183
9184 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) {
9185         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
9186         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9187         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9188         LDKPublicKey their_node_id_ref;
9189         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9190         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9191         LDKChannelUpdate msg_conv;
9192         msg_conv.inner = (void*)(msg & (~1));
9193         msg_conv.is_owned = false;
9194         (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9195 }
9196
9197 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) {
9198         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
9199         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9200         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9201         LDKPublicKey their_node_id_ref;
9202         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9203         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9204         LDKErrorMessage msg_conv;
9205         msg_conv.inner = (void*)(msg & (~1));
9206         msg_conv.is_owned = false;
9207         (this_arg_conv->handle_error)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9208 }
9209
9210 typedef struct LDKRoutingMessageHandler_JCalls {
9211         atomic_size_t refcnt;
9212         JavaVM *vm;
9213         jweak o;
9214         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
9215         jmethodID handle_node_announcement_meth;
9216         jmethodID handle_channel_announcement_meth;
9217         jmethodID handle_channel_update_meth;
9218         jmethodID get_next_channel_announcements_meth;
9219         jmethodID get_next_node_announcements_meth;
9220         jmethodID sync_routing_table_meth;
9221         jmethodID handle_reply_channel_range_meth;
9222         jmethodID handle_reply_short_channel_ids_end_meth;
9223         jmethodID handle_query_channel_range_meth;
9224         jmethodID handle_query_short_channel_ids_meth;
9225 } LDKRoutingMessageHandler_JCalls;
9226 static void LDKRoutingMessageHandler_JCalls_free(void* this_arg) {
9227         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9228         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
9229                 JNIEnv *env;
9230                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9231                 if (get_jenv_res == JNI_EDETACHED) {
9232                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9233                 } else {
9234                         DO_ASSERT(get_jenv_res == JNI_OK);
9235                 }
9236                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
9237                 if (get_jenv_res == JNI_EDETACHED) {
9238                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9239                 }
9240                 FREE(j_calls);
9241         }
9242 }
9243 LDKCResult_boolLightningErrorZ handle_node_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKNodeAnnouncement * msg) {
9244         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9245         JNIEnv *env;
9246         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9247         if (get_jenv_res == JNI_EDETACHED) {
9248                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9249         } else {
9250                 DO_ASSERT(get_jenv_res == JNI_OK);
9251         }
9252         LDKNodeAnnouncement msg_var = *msg;
9253         msg_var = NodeAnnouncement_clone(msg);
9254         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9255         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9256         uint64_t msg_ref = (uint64_t)msg_var.inner;
9257         if (msg_var.is_owned) {
9258                 msg_ref |= 1;
9259         }
9260         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9261         CHECK(obj != NULL);
9262         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_node_announcement_meth, msg_ref);
9263         if ((*env)->ExceptionCheck(env)) {
9264                 (*env)->ExceptionDescribe(env);
9265                 (*env)->FatalError(env, "A call to handle_node_announcement in LDKRoutingMessageHandler from rust threw an exception.");
9266         }
9267         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
9268         CHECK_ACCESS(ret_ptr);
9269         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
9270         ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1));
9271         if (get_jenv_res == JNI_EDETACHED) {
9272                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9273         }
9274         return ret_conv;
9275 }
9276 LDKCResult_boolLightningErrorZ handle_channel_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelAnnouncement * msg) {
9277         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9278         JNIEnv *env;
9279         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9280         if (get_jenv_res == JNI_EDETACHED) {
9281                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9282         } else {
9283                 DO_ASSERT(get_jenv_res == JNI_OK);
9284         }
9285         LDKChannelAnnouncement msg_var = *msg;
9286         msg_var = ChannelAnnouncement_clone(msg);
9287         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9288         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9289         uint64_t msg_ref = (uint64_t)msg_var.inner;
9290         if (msg_var.is_owned) {
9291                 msg_ref |= 1;
9292         }
9293         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9294         CHECK(obj != NULL);
9295         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_channel_announcement_meth, msg_ref);
9296         if ((*env)->ExceptionCheck(env)) {
9297                 (*env)->ExceptionDescribe(env);
9298                 (*env)->FatalError(env, "A call to handle_channel_announcement in LDKRoutingMessageHandler from rust threw an exception.");
9299         }
9300         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
9301         CHECK_ACCESS(ret_ptr);
9302         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
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         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
9334         CHECK_ACCESS(ret_ptr);
9335         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
9336         ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1));
9337         if (get_jenv_res == JNI_EDETACHED) {
9338                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9339         }
9340         return ret_conv;
9341 }
9342 LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ get_next_channel_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, uint64_t starting_point, uint8_t batch_amount) {
9343         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9344         JNIEnv *env;
9345         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9346         if (get_jenv_res == JNI_EDETACHED) {
9347                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9348         } else {
9349                 DO_ASSERT(get_jenv_res == JNI_OK);
9350         }
9351         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9352         CHECK(obj != NULL);
9353         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_next_channel_announcements_meth, starting_point, batch_amount);
9354         if ((*env)->ExceptionCheck(env)) {
9355                 (*env)->ExceptionDescribe(env);
9356                 (*env)->FatalError(env, "A call to get_next_channel_announcements in LDKRoutingMessageHandler from rust threw an exception.");
9357         }
9358         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_constr;
9359         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
9360         if (ret_constr.datalen > 0)
9361                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
9362         else
9363                 ret_constr.data = NULL;
9364         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
9365         for (size_t h = 0; h < ret_constr.datalen; h++) {
9366                 int64_t ret_conv_59 = ret_vals[h];
9367                 void* ret_conv_59_ptr = (void*)(((uint64_t)ret_conv_59) & ~1);
9368                 CHECK_ACCESS(ret_conv_59_ptr);
9369                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ ret_conv_59_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ret_conv_59_ptr);
9370                 ret_conv_59_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone((LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)ret_conv_59) & ~1));
9371                 ret_constr.data[h] = ret_conv_59_conv;
9372         }
9373         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
9374         if (get_jenv_res == JNI_EDETACHED) {
9375                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9376         }
9377         return ret_constr;
9378 }
9379 LDKCVec_NodeAnnouncementZ get_next_node_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey starting_point, uint8_t batch_amount) {
9380         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9381         JNIEnv *env;
9382         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9383         if (get_jenv_res == JNI_EDETACHED) {
9384                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9385         } else {
9386                 DO_ASSERT(get_jenv_res == JNI_OK);
9387         }
9388         int8_tArray starting_point_arr = (*env)->NewByteArray(env, 33);
9389         (*env)->SetByteArrayRegion(env, starting_point_arr, 0, 33, starting_point.compressed_form);
9390         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9391         CHECK(obj != NULL);
9392         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_next_node_announcements_meth, starting_point_arr, batch_amount);
9393         if ((*env)->ExceptionCheck(env)) {
9394                 (*env)->ExceptionDescribe(env);
9395                 (*env)->FatalError(env, "A call to get_next_node_announcements in LDKRoutingMessageHandler from rust threw an exception.");
9396         }
9397         LDKCVec_NodeAnnouncementZ ret_constr;
9398         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
9399         if (ret_constr.datalen > 0)
9400                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
9401         else
9402                 ret_constr.data = NULL;
9403         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
9404         for (size_t s = 0; s < ret_constr.datalen; s++) {
9405                 int64_t ret_conv_18 = ret_vals[s];
9406                 LDKNodeAnnouncement ret_conv_18_conv;
9407                 ret_conv_18_conv.inner = (void*)(ret_conv_18 & (~1));
9408                 ret_conv_18_conv.is_owned = (ret_conv_18 & 1) || (ret_conv_18 == 0);
9409                 ret_conv_18_conv = NodeAnnouncement_clone(&ret_conv_18_conv);
9410                 ret_constr.data[s] = ret_conv_18_conv;
9411         }
9412         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
9413         if (get_jenv_res == JNI_EDETACHED) {
9414                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9415         }
9416         return ret_constr;
9417 }
9418 void sync_routing_table_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * init) {
9419         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9420         JNIEnv *env;
9421         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9422         if (get_jenv_res == JNI_EDETACHED) {
9423                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9424         } else {
9425                 DO_ASSERT(get_jenv_res == JNI_OK);
9426         }
9427         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
9428         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
9429         LDKInit init_var = *init;
9430         init_var = Init_clone(init);
9431         CHECK((((uint64_t)init_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9432         CHECK((((uint64_t)&init_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9433         uint64_t init_ref = (uint64_t)init_var.inner;
9434         if (init_var.is_owned) {
9435                 init_ref |= 1;
9436         }
9437         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9438         CHECK(obj != NULL);
9439         (*env)->CallVoidMethod(env, obj, j_calls->sync_routing_table_meth, their_node_id_arr, init_ref);
9440         if ((*env)->ExceptionCheck(env)) {
9441                 (*env)->ExceptionDescribe(env);
9442                 (*env)->FatalError(env, "A call to sync_routing_table in LDKRoutingMessageHandler from rust threw an exception.");
9443         }
9444         if (get_jenv_res == JNI_EDETACHED) {
9445                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9446         }
9447 }
9448 LDKCResult_NoneLightningErrorZ handle_reply_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyChannelRange msg) {
9449         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9450         JNIEnv *env;
9451         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9452         if (get_jenv_res == JNI_EDETACHED) {
9453                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9454         } else {
9455                 DO_ASSERT(get_jenv_res == JNI_OK);
9456         }
9457         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
9458         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
9459         LDKReplyChannelRange msg_var = msg;
9460         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9461         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9462         uint64_t msg_ref = (uint64_t)msg_var.inner;
9463         if (msg_var.is_owned) {
9464                 msg_ref |= 1;
9465         }
9466         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9467         CHECK(obj != NULL);
9468         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_reply_channel_range_meth, their_node_id_arr, msg_ref);
9469         if ((*env)->ExceptionCheck(env)) {
9470                 (*env)->ExceptionDescribe(env);
9471                 (*env)->FatalError(env, "A call to handle_reply_channel_range in LDKRoutingMessageHandler from rust threw an exception.");
9472         }
9473         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
9474         CHECK_ACCESS(ret_ptr);
9475         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
9476         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
9477         if (get_jenv_res == JNI_EDETACHED) {
9478                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9479         }
9480         return ret_conv;
9481 }
9482 LDKCResult_NoneLightningErrorZ handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyShortChannelIdsEnd msg) {
9483         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9484         JNIEnv *env;
9485         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9486         if (get_jenv_res == JNI_EDETACHED) {
9487                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9488         } else {
9489                 DO_ASSERT(get_jenv_res == JNI_OK);
9490         }
9491         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
9492         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
9493         LDKReplyShortChannelIdsEnd msg_var = msg;
9494         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9495         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9496         uint64_t msg_ref = (uint64_t)msg_var.inner;
9497         if (msg_var.is_owned) {
9498                 msg_ref |= 1;
9499         }
9500         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9501         CHECK(obj != NULL);
9502         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_reply_short_channel_ids_end_meth, their_node_id_arr, msg_ref);
9503         if ((*env)->ExceptionCheck(env)) {
9504                 (*env)->ExceptionDescribe(env);
9505                 (*env)->FatalError(env, "A call to handle_reply_short_channel_ids_end in LDKRoutingMessageHandler from rust threw an exception.");
9506         }
9507         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
9508         CHECK_ACCESS(ret_ptr);
9509         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
9510         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
9511         if (get_jenv_res == JNI_EDETACHED) {
9512                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9513         }
9514         return ret_conv;
9515 }
9516 LDKCResult_NoneLightningErrorZ handle_query_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryChannelRange msg) {
9517         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9518         JNIEnv *env;
9519         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9520         if (get_jenv_res == JNI_EDETACHED) {
9521                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9522         } else {
9523                 DO_ASSERT(get_jenv_res == JNI_OK);
9524         }
9525         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
9526         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
9527         LDKQueryChannelRange msg_var = msg;
9528         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9529         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9530         uint64_t msg_ref = (uint64_t)msg_var.inner;
9531         if (msg_var.is_owned) {
9532                 msg_ref |= 1;
9533         }
9534         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9535         CHECK(obj != NULL);
9536         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_query_channel_range_meth, their_node_id_arr, msg_ref);
9537         if ((*env)->ExceptionCheck(env)) {
9538                 (*env)->ExceptionDescribe(env);
9539                 (*env)->FatalError(env, "A call to handle_query_channel_range in LDKRoutingMessageHandler from rust threw an exception.");
9540         }
9541         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
9542         CHECK_ACCESS(ret_ptr);
9543         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
9544         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
9545         if (get_jenv_res == JNI_EDETACHED) {
9546                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9547         }
9548         return ret_conv;
9549 }
9550 LDKCResult_NoneLightningErrorZ handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryShortChannelIds msg) {
9551         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9552         JNIEnv *env;
9553         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9554         if (get_jenv_res == JNI_EDETACHED) {
9555                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9556         } else {
9557                 DO_ASSERT(get_jenv_res == JNI_OK);
9558         }
9559         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
9560         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
9561         LDKQueryShortChannelIds msg_var = msg;
9562         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9563         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9564         uint64_t msg_ref = (uint64_t)msg_var.inner;
9565         if (msg_var.is_owned) {
9566                 msg_ref |= 1;
9567         }
9568         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9569         CHECK(obj != NULL);
9570         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_query_short_channel_ids_meth, their_node_id_arr, msg_ref);
9571         if ((*env)->ExceptionCheck(env)) {
9572                 (*env)->ExceptionDescribe(env);
9573                 (*env)->FatalError(env, "A call to handle_query_short_channel_ids in LDKRoutingMessageHandler from rust threw an exception.");
9574         }
9575         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
9576         CHECK_ACCESS(ret_ptr);
9577         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
9578         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
9579         if (get_jenv_res == JNI_EDETACHED) {
9580                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9581         }
9582         return ret_conv;
9583 }
9584 static void LDKRoutingMessageHandler_JCalls_cloned(LDKRoutingMessageHandler* new_obj) {
9585         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) new_obj->this_arg;
9586         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
9587         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
9588 }
9589 static inline LDKRoutingMessageHandler LDKRoutingMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
9590         jclass c = (*env)->GetObjectClass(env, o);
9591         CHECK(c != NULL);
9592         LDKRoutingMessageHandler_JCalls *calls = MALLOC(sizeof(LDKRoutingMessageHandler_JCalls), "LDKRoutingMessageHandler_JCalls");
9593         atomic_init(&calls->refcnt, 1);
9594         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
9595         calls->o = (*env)->NewWeakGlobalRef(env, o);
9596         calls->handle_node_announcement_meth = (*env)->GetMethodID(env, c, "handle_node_announcement", "(J)J");
9597         CHECK(calls->handle_node_announcement_meth != NULL);
9598         calls->handle_channel_announcement_meth = (*env)->GetMethodID(env, c, "handle_channel_announcement", "(J)J");
9599         CHECK(calls->handle_channel_announcement_meth != NULL);
9600         calls->handle_channel_update_meth = (*env)->GetMethodID(env, c, "handle_channel_update", "(J)J");
9601         CHECK(calls->handle_channel_update_meth != NULL);
9602         calls->get_next_channel_announcements_meth = (*env)->GetMethodID(env, c, "get_next_channel_announcements", "(JB)[J");
9603         CHECK(calls->get_next_channel_announcements_meth != NULL);
9604         calls->get_next_node_announcements_meth = (*env)->GetMethodID(env, c, "get_next_node_announcements", "([BB)[J");
9605         CHECK(calls->get_next_node_announcements_meth != NULL);
9606         calls->sync_routing_table_meth = (*env)->GetMethodID(env, c, "sync_routing_table", "([BJ)V");
9607         CHECK(calls->sync_routing_table_meth != NULL);
9608         calls->handle_reply_channel_range_meth = (*env)->GetMethodID(env, c, "handle_reply_channel_range", "([BJ)J");
9609         CHECK(calls->handle_reply_channel_range_meth != NULL);
9610         calls->handle_reply_short_channel_ids_end_meth = (*env)->GetMethodID(env, c, "handle_reply_short_channel_ids_end", "([BJ)J");
9611         CHECK(calls->handle_reply_short_channel_ids_end_meth != NULL);
9612         calls->handle_query_channel_range_meth = (*env)->GetMethodID(env, c, "handle_query_channel_range", "([BJ)J");
9613         CHECK(calls->handle_query_channel_range_meth != NULL);
9614         calls->handle_query_short_channel_ids_meth = (*env)->GetMethodID(env, c, "handle_query_short_channel_ids", "([BJ)J");
9615         CHECK(calls->handle_query_short_channel_ids_meth != NULL);
9616
9617         LDKRoutingMessageHandler ret = {
9618                 .this_arg = (void*) calls,
9619                 .handle_node_announcement = handle_node_announcement_LDKRoutingMessageHandler_jcall,
9620                 .handle_channel_announcement = handle_channel_announcement_LDKRoutingMessageHandler_jcall,
9621                 .handle_channel_update = handle_channel_update_LDKRoutingMessageHandler_jcall,
9622                 .get_next_channel_announcements = get_next_channel_announcements_LDKRoutingMessageHandler_jcall,
9623                 .get_next_node_announcements = get_next_node_announcements_LDKRoutingMessageHandler_jcall,
9624                 .sync_routing_table = sync_routing_table_LDKRoutingMessageHandler_jcall,
9625                 .handle_reply_channel_range = handle_reply_channel_range_LDKRoutingMessageHandler_jcall,
9626                 .handle_reply_short_channel_ids_end = handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall,
9627                 .handle_query_channel_range = handle_query_channel_range_LDKRoutingMessageHandler_jcall,
9628                 .handle_query_short_channel_ids = handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall,
9629                 .free = LDKRoutingMessageHandler_JCalls_free,
9630                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(env, clz, MessageSendEventsProvider),
9631         };
9632         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
9633         return ret;
9634 }
9635 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
9636         LDKRoutingMessageHandler *res_ptr = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
9637         *res_ptr = LDKRoutingMessageHandler_init(env, clz, o, MessageSendEventsProvider);
9638         return (uint64_t)res_ptr;
9639 }
9640 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1get_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t arg) {
9641         LDKRoutingMessageHandler *inp = (LDKRoutingMessageHandler *)(arg & ~1);
9642         uint64_t res_ptr = (uint64_t)&inp->MessageSendEventsProvider;
9643         DO_ASSERT((res_ptr & 1) == 0);
9644         return (int64_t)(res_ptr | 1);
9645 }
9646 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1node_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
9647         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
9648         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9649         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
9650         LDKNodeAnnouncement msg_conv;
9651         msg_conv.inner = (void*)(msg & (~1));
9652         msg_conv.is_owned = false;
9653         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
9654         *ret_conv = (this_arg_conv->handle_node_announcement)(this_arg_conv->this_arg, &msg_conv);
9655         return (uint64_t)ret_conv;
9656 }
9657
9658 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1channel_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
9659         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
9660         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9661         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
9662         LDKChannelAnnouncement msg_conv;
9663         msg_conv.inner = (void*)(msg & (~1));
9664         msg_conv.is_owned = false;
9665         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
9666         *ret_conv = (this_arg_conv->handle_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
9667         return (uint64_t)ret_conv;
9668 }
9669
9670 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1channel_1update(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
9671         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
9672         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9673         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
9674         LDKChannelUpdate msg_conv;
9675         msg_conv.inner = (void*)(msg & (~1));
9676         msg_conv.is_owned = false;
9677         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
9678         *ret_conv = (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, &msg_conv);
9679         return (uint64_t)ret_conv;
9680 }
9681
9682 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) {
9683         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
9684         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9685         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
9686         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_var = (this_arg_conv->get_next_channel_announcements)(this_arg_conv->this_arg, starting_point, batch_amount);
9687         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
9688         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
9689         for (size_t h = 0; h < ret_var.datalen; h++) {
9690                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv_59_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
9691                 *ret_conv_59_conv = ret_var.data[h];
9692                 ret_arr_ptr[h] = ((uint64_t)ret_conv_59_conv);
9693         }
9694         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
9695         FREE(ret_var.data);
9696         return ret_arr;
9697 }
9698
9699 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) {
9700         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
9701         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9702         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
9703         LDKPublicKey starting_point_ref;
9704         CHECK((*env)->GetArrayLength(env, starting_point) == 33);
9705         (*env)->GetByteArrayRegion(env, starting_point, 0, 33, starting_point_ref.compressed_form);
9706         LDKCVec_NodeAnnouncementZ ret_var = (this_arg_conv->get_next_node_announcements)(this_arg_conv->this_arg, starting_point_ref, batch_amount);
9707         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
9708         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
9709         for (size_t s = 0; s < ret_var.datalen; s++) {
9710                 LDKNodeAnnouncement ret_conv_18_var = ret_var.data[s];
9711                 CHECK((((uint64_t)ret_conv_18_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9712                 CHECK((((uint64_t)&ret_conv_18_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9713                 uint64_t ret_conv_18_ref = (uint64_t)ret_conv_18_var.inner;
9714                 if (ret_conv_18_var.is_owned) {
9715                         ret_conv_18_ref |= 1;
9716                 }
9717                 ret_arr_ptr[s] = ret_conv_18_ref;
9718         }
9719         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
9720         FREE(ret_var.data);
9721         return ret_arr;
9722 }
9723
9724 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) {
9725         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
9726         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9727         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
9728         LDKPublicKey their_node_id_ref;
9729         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9730         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9731         LDKInit init_conv;
9732         init_conv.inner = (void*)(init & (~1));
9733         init_conv.is_owned = false;
9734         (this_arg_conv->sync_routing_table)(this_arg_conv->this_arg, their_node_id_ref, &init_conv);
9735 }
9736
9737 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) {
9738         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
9739         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9740         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
9741         LDKPublicKey their_node_id_ref;
9742         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9743         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9744         LDKReplyChannelRange msg_conv;
9745         msg_conv.inner = (void*)(msg & (~1));
9746         msg_conv.is_owned = (msg & 1) || (msg == 0);
9747         msg_conv = ReplyChannelRange_clone(&msg_conv);
9748         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
9749         *ret_conv = (this_arg_conv->handle_reply_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
9750         return (uint64_t)ret_conv;
9751 }
9752
9753 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) {
9754         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
9755         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9756         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
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         LDKReplyShortChannelIdsEnd msg_conv;
9761         msg_conv.inner = (void*)(msg & (~1));
9762         msg_conv.is_owned = (msg & 1) || (msg == 0);
9763         msg_conv = ReplyShortChannelIdsEnd_clone(&msg_conv);
9764         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
9765         *ret_conv = (this_arg_conv->handle_reply_short_channel_ids_end)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
9766         return (uint64_t)ret_conv;
9767 }
9768
9769 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) {
9770         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
9771         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9772         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
9773         LDKPublicKey their_node_id_ref;
9774         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9775         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9776         LDKQueryChannelRange msg_conv;
9777         msg_conv.inner = (void*)(msg & (~1));
9778         msg_conv.is_owned = (msg & 1) || (msg == 0);
9779         msg_conv = QueryChannelRange_clone(&msg_conv);
9780         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
9781         *ret_conv = (this_arg_conv->handle_query_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
9782         return (uint64_t)ret_conv;
9783 }
9784
9785 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) {
9786         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
9787         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9788         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
9789         LDKPublicKey their_node_id_ref;
9790         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9791         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9792         LDKQueryShortChannelIds msg_conv;
9793         msg_conv.inner = (void*)(msg & (~1));
9794         msg_conv.is_owned = (msg & 1) || (msg == 0);
9795         msg_conv = QueryShortChannelIds_clone(&msg_conv);
9796         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
9797         *ret_conv = (this_arg_conv->handle_query_short_channel_ids)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
9798         return (uint64_t)ret_conv;
9799 }
9800
9801 typedef struct LDKCustomMessageReader_JCalls {
9802         atomic_size_t refcnt;
9803         JavaVM *vm;
9804         jweak o;
9805         jmethodID read_meth;
9806 } LDKCustomMessageReader_JCalls;
9807 static void LDKCustomMessageReader_JCalls_free(void* this_arg) {
9808         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) this_arg;
9809         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
9810                 JNIEnv *env;
9811                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9812                 if (get_jenv_res == JNI_EDETACHED) {
9813                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9814                 } else {
9815                         DO_ASSERT(get_jenv_res == JNI_OK);
9816                 }
9817                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
9818                 if (get_jenv_res == JNI_EDETACHED) {
9819                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9820                 }
9821                 FREE(j_calls);
9822         }
9823 }
9824 LDKCResult_COption_TypeZDecodeErrorZ read_LDKCustomMessageReader_jcall(const void* this_arg, uint16_t message_type, LDKu8slice buffer) {
9825         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) this_arg;
9826         JNIEnv *env;
9827         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9828         if (get_jenv_res == JNI_EDETACHED) {
9829                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9830         } else {
9831                 DO_ASSERT(get_jenv_res == JNI_OK);
9832         }
9833         LDKu8slice buffer_var = buffer;
9834         int8_tArray buffer_arr = (*env)->NewByteArray(env, buffer_var.datalen);
9835         (*env)->SetByteArrayRegion(env, buffer_arr, 0, buffer_var.datalen, buffer_var.data);
9836         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9837         CHECK(obj != NULL);
9838         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->read_meth, message_type, buffer_arr);
9839         if ((*env)->ExceptionCheck(env)) {
9840                 (*env)->ExceptionDescribe(env);
9841                 (*env)->FatalError(env, "A call to read in LDKCustomMessageReader from rust threw an exception.");
9842         }
9843         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
9844         CHECK_ACCESS(ret_ptr);
9845         LDKCResult_COption_TypeZDecodeErrorZ ret_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(ret_ptr);
9846         ret_conv = CResult_COption_TypeZDecodeErrorZ_clone((LDKCResult_COption_TypeZDecodeErrorZ*)(((uint64_t)ret) & ~1));
9847         if (get_jenv_res == JNI_EDETACHED) {
9848                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9849         }
9850         return ret_conv;
9851 }
9852 static void LDKCustomMessageReader_JCalls_cloned(LDKCustomMessageReader* new_obj) {
9853         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) new_obj->this_arg;
9854         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
9855 }
9856 static inline LDKCustomMessageReader LDKCustomMessageReader_init (JNIEnv *env, jclass clz, jobject o) {
9857         jclass c = (*env)->GetObjectClass(env, o);
9858         CHECK(c != NULL);
9859         LDKCustomMessageReader_JCalls *calls = MALLOC(sizeof(LDKCustomMessageReader_JCalls), "LDKCustomMessageReader_JCalls");
9860         atomic_init(&calls->refcnt, 1);
9861         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
9862         calls->o = (*env)->NewWeakGlobalRef(env, o);
9863         calls->read_meth = (*env)->GetMethodID(env, c, "read", "(S[B)J");
9864         CHECK(calls->read_meth != NULL);
9865
9866         LDKCustomMessageReader ret = {
9867                 .this_arg = (void*) calls,
9868                 .read = read_LDKCustomMessageReader_jcall,
9869                 .free = LDKCustomMessageReader_JCalls_free,
9870         };
9871         return ret;
9872 }
9873 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCustomMessageReader_1new(JNIEnv *env, jclass clz, jobject o) {
9874         LDKCustomMessageReader *res_ptr = MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader");
9875         *res_ptr = LDKCustomMessageReader_init(env, clz, o);
9876         return (uint64_t)res_ptr;
9877 }
9878 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) {
9879         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
9880         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9881         LDKCustomMessageReader* this_arg_conv = (LDKCustomMessageReader*)this_arg_ptr;
9882         LDKu8slice buffer_ref;
9883         buffer_ref.datalen = (*env)->GetArrayLength(env, buffer);
9884         buffer_ref.data = (*env)->GetByteArrayElements (env, buffer, NULL);
9885         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
9886         *ret_conv = (this_arg_conv->read)(this_arg_conv->this_arg, message_type, buffer_ref);
9887         (*env)->ReleaseByteArrayElements(env, buffer, (int8_t*)buffer_ref.data, 0);
9888         return (uint64_t)ret_conv;
9889 }
9890
9891 typedef struct LDKCustomMessageHandler_JCalls {
9892         atomic_size_t refcnt;
9893         JavaVM *vm;
9894         jweak o;
9895         LDKCustomMessageReader_JCalls* CustomMessageReader;
9896         jmethodID handle_custom_message_meth;
9897         jmethodID get_and_clear_pending_msg_meth;
9898 } LDKCustomMessageHandler_JCalls;
9899 static void LDKCustomMessageHandler_JCalls_free(void* this_arg) {
9900         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
9901         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
9902                 JNIEnv *env;
9903                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9904                 if (get_jenv_res == JNI_EDETACHED) {
9905                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9906                 } else {
9907                         DO_ASSERT(get_jenv_res == JNI_OK);
9908                 }
9909                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
9910                 if (get_jenv_res == JNI_EDETACHED) {
9911                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9912                 }
9913                 FREE(j_calls);
9914         }
9915 }
9916 LDKCResult_NoneLightningErrorZ handle_custom_message_LDKCustomMessageHandler_jcall(const void* this_arg, LDKType msg, LDKPublicKey sender_node_id) {
9917         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
9918         JNIEnv *env;
9919         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9920         if (get_jenv_res == JNI_EDETACHED) {
9921                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9922         } else {
9923                 DO_ASSERT(get_jenv_res == JNI_OK);
9924         }
9925         LDKType* msg_ret =MALLOC(sizeof(LDKType), "LDKType");
9926         *msg_ret = msg;
9927         int8_tArray sender_node_id_arr = (*env)->NewByteArray(env, 33);
9928         (*env)->SetByteArrayRegion(env, sender_node_id_arr, 0, 33, sender_node_id.compressed_form);
9929         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9930         CHECK(obj != NULL);
9931         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_custom_message_meth, (uint64_t)msg_ret, sender_node_id_arr);
9932         if ((*env)->ExceptionCheck(env)) {
9933                 (*env)->ExceptionDescribe(env);
9934                 (*env)->FatalError(env, "A call to handle_custom_message in LDKCustomMessageHandler from rust threw an exception.");
9935         }
9936         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
9937         CHECK_ACCESS(ret_ptr);
9938         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
9939         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
9940         if (get_jenv_res == JNI_EDETACHED) {
9941                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9942         }
9943         return ret_conv;
9944 }
9945 LDKCVec_C2Tuple_PublicKeyTypeZZ get_and_clear_pending_msg_LDKCustomMessageHandler_jcall(const void* this_arg) {
9946         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
9947         JNIEnv *env;
9948         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9949         if (get_jenv_res == JNI_EDETACHED) {
9950                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9951         } else {
9952                 DO_ASSERT(get_jenv_res == JNI_OK);
9953         }
9954         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9955         CHECK(obj != NULL);
9956         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_and_clear_pending_msg_meth);
9957         if ((*env)->ExceptionCheck(env)) {
9958                 (*env)->ExceptionDescribe(env);
9959                 (*env)->FatalError(env, "A call to get_and_clear_pending_msg in LDKCustomMessageHandler from rust threw an exception.");
9960         }
9961         LDKCVec_C2Tuple_PublicKeyTypeZZ ret_constr;
9962         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
9963         if (ret_constr.datalen > 0)
9964                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ Elements");
9965         else
9966                 ret_constr.data = NULL;
9967         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
9968         for (size_t z = 0; z < ret_constr.datalen; z++) {
9969                 int64_t ret_conv_25 = ret_vals[z];
9970                 void* ret_conv_25_ptr = (void*)(((uint64_t)ret_conv_25) & ~1);
9971                 CHECK_ACCESS(ret_conv_25_ptr);
9972                 LDKC2Tuple_PublicKeyTypeZ ret_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(ret_conv_25_ptr);
9973                 ret_conv_25_conv = C2Tuple_PublicKeyTypeZ_clone((LDKC2Tuple_PublicKeyTypeZ*)(((uint64_t)ret_conv_25) & ~1));
9974                 ret_constr.data[z] = ret_conv_25_conv;
9975         }
9976         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
9977         if (get_jenv_res == JNI_EDETACHED) {
9978                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9979         }
9980         return ret_constr;
9981 }
9982 static void LDKCustomMessageHandler_JCalls_cloned(LDKCustomMessageHandler* new_obj) {
9983         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) new_obj->this_arg;
9984         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
9985         atomic_fetch_add_explicit(&j_calls->CustomMessageReader->refcnt, 1, memory_order_release);
9986 }
9987 static inline LDKCustomMessageHandler LDKCustomMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject CustomMessageReader) {
9988         jclass c = (*env)->GetObjectClass(env, o);
9989         CHECK(c != NULL);
9990         LDKCustomMessageHandler_JCalls *calls = MALLOC(sizeof(LDKCustomMessageHandler_JCalls), "LDKCustomMessageHandler_JCalls");
9991         atomic_init(&calls->refcnt, 1);
9992         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
9993         calls->o = (*env)->NewWeakGlobalRef(env, o);
9994         calls->handle_custom_message_meth = (*env)->GetMethodID(env, c, "handle_custom_message", "(J[B)J");
9995         CHECK(calls->handle_custom_message_meth != NULL);
9996         calls->get_and_clear_pending_msg_meth = (*env)->GetMethodID(env, c, "get_and_clear_pending_msg", "()[J");
9997         CHECK(calls->get_and_clear_pending_msg_meth != NULL);
9998
9999         LDKCustomMessageHandler ret = {
10000                 .this_arg = (void*) calls,
10001                 .handle_custom_message = handle_custom_message_LDKCustomMessageHandler_jcall,
10002                 .get_and_clear_pending_msg = get_and_clear_pending_msg_LDKCustomMessageHandler_jcall,
10003                 .free = LDKCustomMessageHandler_JCalls_free,
10004                 .CustomMessageReader = LDKCustomMessageReader_init(env, clz, CustomMessageReader),
10005         };
10006         calls->CustomMessageReader = ret.CustomMessageReader.this_arg;
10007         return ret;
10008 }
10009 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCustomMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject CustomMessageReader) {
10010         LDKCustomMessageHandler *res_ptr = MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler");
10011         *res_ptr = LDKCustomMessageHandler_init(env, clz, o, CustomMessageReader);
10012         return (uint64_t)res_ptr;
10013 }
10014 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCustomMessageHandler_1get_1CustomMessageReader(JNIEnv *env, jclass clz, int64_t arg) {
10015         LDKCustomMessageHandler *inp = (LDKCustomMessageHandler *)(arg & ~1);
10016         uint64_t res_ptr = (uint64_t)&inp->CustomMessageReader;
10017         DO_ASSERT((res_ptr & 1) == 0);
10018         return (int64_t)(res_ptr | 1);
10019 }
10020 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) {
10021         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
10022         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10023         LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)this_arg_ptr;
10024         void* msg_ptr = (void*)(((uint64_t)msg) & ~1);
10025         CHECK_ACCESS(msg_ptr);
10026         LDKType msg_conv = *(LDKType*)(msg_ptr);
10027         if (msg_conv.free == LDKType_JCalls_free) {
10028                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
10029                 LDKType_JCalls_cloned(&msg_conv);
10030         }
10031         LDKPublicKey sender_node_id_ref;
10032         CHECK((*env)->GetArrayLength(env, sender_node_id) == 33);
10033         (*env)->GetByteArrayRegion(env, sender_node_id, 0, 33, sender_node_id_ref.compressed_form);
10034         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
10035         *ret_conv = (this_arg_conv->handle_custom_message)(this_arg_conv->this_arg, msg_conv, sender_node_id_ref);
10036         return (uint64_t)ret_conv;
10037 }
10038
10039 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CustomMessageHandler_1get_1and_1clear_1pending_1msg(JNIEnv *env, jclass clz, int64_t this_arg) {
10040         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
10041         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10042         LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)this_arg_ptr;
10043         LDKCVec_C2Tuple_PublicKeyTypeZZ ret_var = (this_arg_conv->get_and_clear_pending_msg)(this_arg_conv->this_arg);
10044         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
10045         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
10046         for (size_t z = 0; z < ret_var.datalen; z++) {
10047                 LDKC2Tuple_PublicKeyTypeZ* ret_conv_25_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
10048                 *ret_conv_25_conv = ret_var.data[z];
10049                 ret_arr_ptr[z] = ((uint64_t)ret_conv_25_conv);
10050         }
10051         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
10052         FREE(ret_var.data);
10053         return ret_arr;
10054 }
10055
10056 typedef struct LDKSocketDescriptor_JCalls {
10057         atomic_size_t refcnt;
10058         JavaVM *vm;
10059         jweak o;
10060         jmethodID send_data_meth;
10061         jmethodID disconnect_socket_meth;
10062         jmethodID eq_meth;
10063         jmethodID hash_meth;
10064 } LDKSocketDescriptor_JCalls;
10065 static void LDKSocketDescriptor_JCalls_free(void* this_arg) {
10066         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
10067         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10068                 JNIEnv *env;
10069                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10070                 if (get_jenv_res == JNI_EDETACHED) {
10071                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10072                 } else {
10073                         DO_ASSERT(get_jenv_res == JNI_OK);
10074                 }
10075                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
10076                 if (get_jenv_res == JNI_EDETACHED) {
10077                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10078                 }
10079                 FREE(j_calls);
10080         }
10081 }
10082 uintptr_t send_data_LDKSocketDescriptor_jcall(void* this_arg, LDKu8slice data, bool resume_read) {
10083         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
10084         JNIEnv *env;
10085         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10086         if (get_jenv_res == JNI_EDETACHED) {
10087                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10088         } else {
10089                 DO_ASSERT(get_jenv_res == JNI_OK);
10090         }
10091         LDKu8slice data_var = data;
10092         int8_tArray data_arr = (*env)->NewByteArray(env, data_var.datalen);
10093         (*env)->SetByteArrayRegion(env, data_arr, 0, data_var.datalen, data_var.data);
10094         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10095         CHECK(obj != NULL);
10096         int64_t ret = (*env)->CallLongMethod(env, obj, j_calls->send_data_meth, data_arr, resume_read);
10097         if ((*env)->ExceptionCheck(env)) {
10098                 (*env)->ExceptionDescribe(env);
10099                 (*env)->FatalError(env, "A call to send_data in LDKSocketDescriptor from rust threw an exception.");
10100         }
10101         if (get_jenv_res == JNI_EDETACHED) {
10102                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10103         }
10104         return ret;
10105 }
10106 void disconnect_socket_LDKSocketDescriptor_jcall(void* this_arg) {
10107         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
10108         JNIEnv *env;
10109         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10110         if (get_jenv_res == JNI_EDETACHED) {
10111                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10112         } else {
10113                 DO_ASSERT(get_jenv_res == JNI_OK);
10114         }
10115         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10116         CHECK(obj != NULL);
10117         (*env)->CallVoidMethod(env, obj, j_calls->disconnect_socket_meth);
10118         if ((*env)->ExceptionCheck(env)) {
10119                 (*env)->ExceptionDescribe(env);
10120                 (*env)->FatalError(env, "A call to disconnect_socket in LDKSocketDescriptor from rust threw an exception.");
10121         }
10122         if (get_jenv_res == JNI_EDETACHED) {
10123                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10124         }
10125 }
10126 bool eq_LDKSocketDescriptor_jcall(const void* this_arg, const LDKSocketDescriptor * other_arg) {
10127         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
10128         JNIEnv *env;
10129         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10130         if (get_jenv_res == JNI_EDETACHED) {
10131                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10132         } else {
10133                 DO_ASSERT(get_jenv_res == JNI_OK);
10134         }
10135         LDKSocketDescriptor *other_arg_clone = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
10136         *other_arg_clone = SocketDescriptor_clone(other_arg);
10137         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10138         CHECK(obj != NULL);
10139         jboolean ret = (*env)->CallBooleanMethod(env, obj, j_calls->eq_meth, (uint64_t)other_arg_clone);
10140         if ((*env)->ExceptionCheck(env)) {
10141                 (*env)->ExceptionDescribe(env);
10142                 (*env)->FatalError(env, "A call to eq in LDKSocketDescriptor from rust threw an exception.");
10143         }
10144         if (get_jenv_res == JNI_EDETACHED) {
10145                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10146         }
10147         return ret;
10148 }
10149 uint64_t hash_LDKSocketDescriptor_jcall(const void* this_arg) {
10150         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
10151         JNIEnv *env;
10152         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10153         if (get_jenv_res == JNI_EDETACHED) {
10154                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10155         } else {
10156                 DO_ASSERT(get_jenv_res == JNI_OK);
10157         }
10158         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10159         CHECK(obj != NULL);
10160         int64_t ret = (*env)->CallLongMethod(env, obj, j_calls->hash_meth);
10161         if ((*env)->ExceptionCheck(env)) {
10162                 (*env)->ExceptionDescribe(env);
10163                 (*env)->FatalError(env, "A call to hash in LDKSocketDescriptor from rust threw an exception.");
10164         }
10165         if (get_jenv_res == JNI_EDETACHED) {
10166                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10167         }
10168         return ret;
10169 }
10170 static void LDKSocketDescriptor_JCalls_cloned(LDKSocketDescriptor* new_obj) {
10171         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) new_obj->this_arg;
10172         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10173 }
10174 static inline LDKSocketDescriptor LDKSocketDescriptor_init (JNIEnv *env, jclass clz, jobject o) {
10175         jclass c = (*env)->GetObjectClass(env, o);
10176         CHECK(c != NULL);
10177         LDKSocketDescriptor_JCalls *calls = MALLOC(sizeof(LDKSocketDescriptor_JCalls), "LDKSocketDescriptor_JCalls");
10178         atomic_init(&calls->refcnt, 1);
10179         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
10180         calls->o = (*env)->NewWeakGlobalRef(env, o);
10181         calls->send_data_meth = (*env)->GetMethodID(env, c, "send_data", "([BZ)J");
10182         CHECK(calls->send_data_meth != NULL);
10183         calls->disconnect_socket_meth = (*env)->GetMethodID(env, c, "disconnect_socket", "()V");
10184         CHECK(calls->disconnect_socket_meth != NULL);
10185         calls->eq_meth = (*env)->GetMethodID(env, c, "eq", "(J)Z");
10186         CHECK(calls->eq_meth != NULL);
10187         calls->hash_meth = (*env)->GetMethodID(env, c, "hash", "()J");
10188         CHECK(calls->hash_meth != NULL);
10189
10190         LDKSocketDescriptor ret = {
10191                 .this_arg = (void*) calls,
10192                 .send_data = send_data_LDKSocketDescriptor_jcall,
10193                 .disconnect_socket = disconnect_socket_LDKSocketDescriptor_jcall,
10194                 .eq = eq_LDKSocketDescriptor_jcall,
10195                 .hash = hash_LDKSocketDescriptor_jcall,
10196                 .cloned = LDKSocketDescriptor_JCalls_cloned,
10197                 .free = LDKSocketDescriptor_JCalls_free,
10198         };
10199         return ret;
10200 }
10201 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSocketDescriptor_1new(JNIEnv *env, jclass clz, jobject o) {
10202         LDKSocketDescriptor *res_ptr = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
10203         *res_ptr = LDKSocketDescriptor_init(env, clz, o);
10204         return (uint64_t)res_ptr;
10205 }
10206 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) {
10207         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
10208         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10209         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
10210         LDKu8slice data_ref;
10211         data_ref.datalen = (*env)->GetArrayLength(env, data);
10212         data_ref.data = (*env)->GetByteArrayElements (env, data, NULL);
10213         int64_t ret_val = (this_arg_conv->send_data)(this_arg_conv->this_arg, data_ref, resume_read);
10214         (*env)->ReleaseByteArrayElements(env, data, (int8_t*)data_ref.data, 0);
10215         return ret_val;
10216 }
10217
10218 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1disconnect_1socket(JNIEnv *env, jclass clz, int64_t this_arg) {
10219         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
10220         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10221         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
10222         (this_arg_conv->disconnect_socket)(this_arg_conv->this_arg);
10223 }
10224
10225 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
10226         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
10227         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10228         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
10229         int64_t ret_val = (this_arg_conv->hash)(this_arg_conv->this_arg);
10230         return ret_val;
10231 }
10232
10233 typedef struct LDKScore_JCalls {
10234         atomic_size_t refcnt;
10235         JavaVM *vm;
10236         jweak o;
10237         jmethodID channel_penalty_msat_meth;
10238 } LDKScore_JCalls;
10239 static void LDKScore_JCalls_free(void* this_arg) {
10240         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
10241         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10242                 JNIEnv *env;
10243                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10244                 if (get_jenv_res == JNI_EDETACHED) {
10245                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10246                 } else {
10247                         DO_ASSERT(get_jenv_res == JNI_OK);
10248                 }
10249                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
10250                 if (get_jenv_res == JNI_EDETACHED) {
10251                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10252                 }
10253                 FREE(j_calls);
10254         }
10255 }
10256 uint64_t channel_penalty_msat_LDKScore_jcall(const void* this_arg, uint64_t short_channel_id) {
10257         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
10258         JNIEnv *env;
10259         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10260         if (get_jenv_res == JNI_EDETACHED) {
10261                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10262         } else {
10263                 DO_ASSERT(get_jenv_res == JNI_OK);
10264         }
10265         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10266         CHECK(obj != NULL);
10267         int64_t ret = (*env)->CallLongMethod(env, obj, j_calls->channel_penalty_msat_meth, short_channel_id);
10268         if ((*env)->ExceptionCheck(env)) {
10269                 (*env)->ExceptionDescribe(env);
10270                 (*env)->FatalError(env, "A call to channel_penalty_msat in LDKScore from rust threw an exception.");
10271         }
10272         if (get_jenv_res == JNI_EDETACHED) {
10273                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10274         }
10275         return ret;
10276 }
10277 static void LDKScore_JCalls_cloned(LDKScore* new_obj) {
10278         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) new_obj->this_arg;
10279         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10280 }
10281 static inline LDKScore LDKScore_init (JNIEnv *env, jclass clz, jobject o) {
10282         jclass c = (*env)->GetObjectClass(env, o);
10283         CHECK(c != NULL);
10284         LDKScore_JCalls *calls = MALLOC(sizeof(LDKScore_JCalls), "LDKScore_JCalls");
10285         atomic_init(&calls->refcnt, 1);
10286         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
10287         calls->o = (*env)->NewWeakGlobalRef(env, o);
10288         calls->channel_penalty_msat_meth = (*env)->GetMethodID(env, c, "channel_penalty_msat", "(J)J");
10289         CHECK(calls->channel_penalty_msat_meth != NULL);
10290
10291         LDKScore ret = {
10292                 .this_arg = (void*) calls,
10293                 .channel_penalty_msat = channel_penalty_msat_LDKScore_jcall,
10294                 .free = LDKScore_JCalls_free,
10295         };
10296         return ret;
10297 }
10298 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKScore_1new(JNIEnv *env, jclass clz, jobject o) {
10299         LDKScore *res_ptr = MALLOC(sizeof(LDKScore), "LDKScore");
10300         *res_ptr = LDKScore_init(env, clz, o);
10301         return (uint64_t)res_ptr;
10302 }
10303 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) {
10304         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
10305         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10306         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
10307         int64_t ret_val = (this_arg_conv->channel_penalty_msat)(this_arg_conv->this_arg, short_channel_id);
10308         return ret_val;
10309 }
10310
10311 typedef struct LDKChannelManagerPersister_JCalls {
10312         atomic_size_t refcnt;
10313         JavaVM *vm;
10314         jweak o;
10315         jmethodID persist_manager_meth;
10316 } LDKChannelManagerPersister_JCalls;
10317 static void LDKChannelManagerPersister_JCalls_free(void* this_arg) {
10318         LDKChannelManagerPersister_JCalls *j_calls = (LDKChannelManagerPersister_JCalls*) this_arg;
10319         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10320                 JNIEnv *env;
10321                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10322                 if (get_jenv_res == JNI_EDETACHED) {
10323                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10324                 } else {
10325                         DO_ASSERT(get_jenv_res == JNI_OK);
10326                 }
10327                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
10328                 if (get_jenv_res == JNI_EDETACHED) {
10329                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10330                 }
10331                 FREE(j_calls);
10332         }
10333 }
10334 LDKCResult_NoneErrorZ persist_manager_LDKChannelManagerPersister_jcall(const void* this_arg, const LDKChannelManager * channel_manager) {
10335         LDKChannelManagerPersister_JCalls *j_calls = (LDKChannelManagerPersister_JCalls*) this_arg;
10336         JNIEnv *env;
10337         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10338         if (get_jenv_res == JNI_EDETACHED) {
10339                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10340         } else {
10341                 DO_ASSERT(get_jenv_res == JNI_OK);
10342         }
10343         LDKChannelManager channel_manager_var = *channel_manager;
10344         // Warning: we may need a move here but no clone is available for LDKChannelManager
10345         CHECK((((uint64_t)channel_manager_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10346         CHECK((((uint64_t)&channel_manager_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10347         uint64_t channel_manager_ref = (uint64_t)channel_manager_var.inner;
10348         if (channel_manager_var.is_owned) {
10349                 channel_manager_ref |= 1;
10350         }
10351         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10352         CHECK(obj != NULL);
10353         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->persist_manager_meth, channel_manager_ref);
10354         if ((*env)->ExceptionCheck(env)) {
10355                 (*env)->ExceptionDescribe(env);
10356                 (*env)->FatalError(env, "A call to persist_manager in LDKChannelManagerPersister from rust threw an exception.");
10357         }
10358         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
10359         CHECK_ACCESS(ret_ptr);
10360         LDKCResult_NoneErrorZ ret_conv = *(LDKCResult_NoneErrorZ*)(ret_ptr);
10361         ret_conv = CResult_NoneErrorZ_clone((LDKCResult_NoneErrorZ*)(((uint64_t)ret) & ~1));
10362         if (get_jenv_res == JNI_EDETACHED) {
10363                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10364         }
10365         return ret_conv;
10366 }
10367 static void LDKChannelManagerPersister_JCalls_cloned(LDKChannelManagerPersister* new_obj) {
10368         LDKChannelManagerPersister_JCalls *j_calls = (LDKChannelManagerPersister_JCalls*) new_obj->this_arg;
10369         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10370 }
10371 static inline LDKChannelManagerPersister LDKChannelManagerPersister_init (JNIEnv *env, jclass clz, jobject o) {
10372         jclass c = (*env)->GetObjectClass(env, o);
10373         CHECK(c != NULL);
10374         LDKChannelManagerPersister_JCalls *calls = MALLOC(sizeof(LDKChannelManagerPersister_JCalls), "LDKChannelManagerPersister_JCalls");
10375         atomic_init(&calls->refcnt, 1);
10376         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
10377         calls->o = (*env)->NewWeakGlobalRef(env, o);
10378         calls->persist_manager_meth = (*env)->GetMethodID(env, c, "persist_manager", "(J)J");
10379         CHECK(calls->persist_manager_meth != NULL);
10380
10381         LDKChannelManagerPersister ret = {
10382                 .this_arg = (void*) calls,
10383                 .persist_manager = persist_manager_LDKChannelManagerPersister_jcall,
10384                 .free = LDKChannelManagerPersister_JCalls_free,
10385         };
10386         return ret;
10387 }
10388 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKChannelManagerPersister_1new(JNIEnv *env, jclass clz, jobject o) {
10389         LDKChannelManagerPersister *res_ptr = MALLOC(sizeof(LDKChannelManagerPersister), "LDKChannelManagerPersister");
10390         *res_ptr = LDKChannelManagerPersister_init(env, clz, o);
10391         return (uint64_t)res_ptr;
10392 }
10393 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerPersister_1persist_1manager(JNIEnv *env, jclass clz, int64_t this_arg, int64_t channel_manager) {
10394         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
10395         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10396         LDKChannelManagerPersister* this_arg_conv = (LDKChannelManagerPersister*)this_arg_ptr;
10397         LDKChannelManager channel_manager_conv;
10398         channel_manager_conv.inner = (void*)(channel_manager & (~1));
10399         channel_manager_conv.is_owned = false;
10400         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
10401         *ret_conv = (this_arg_conv->persist_manager)(this_arg_conv->this_arg, &channel_manager_conv);
10402         return (uint64_t)ret_conv;
10403 }
10404
10405 static jclass LDKFallback_SegWitProgram_class = NULL;
10406 static jmethodID LDKFallback_SegWitProgram_meth = NULL;
10407 static jclass LDKFallback_PubKeyHash_class = NULL;
10408 static jmethodID LDKFallback_PubKeyHash_meth = NULL;
10409 static jclass LDKFallback_ScriptHash_class = NULL;
10410 static jmethodID LDKFallback_ScriptHash_meth = NULL;
10411 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKFallback_init (JNIEnv *env, jclass clz) {
10412         LDKFallback_SegWitProgram_class =
10413                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKFallback$SegWitProgram;"));
10414         CHECK(LDKFallback_SegWitProgram_class != NULL);
10415         LDKFallback_SegWitProgram_meth = (*env)->GetMethodID(env, LDKFallback_SegWitProgram_class, "<init>", "(B[B)V");
10416         CHECK(LDKFallback_SegWitProgram_meth != NULL);
10417         LDKFallback_PubKeyHash_class =
10418                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKFallback$PubKeyHash;"));
10419         CHECK(LDKFallback_PubKeyHash_class != NULL);
10420         LDKFallback_PubKeyHash_meth = (*env)->GetMethodID(env, LDKFallback_PubKeyHash_class, "<init>", "([B)V");
10421         CHECK(LDKFallback_PubKeyHash_meth != NULL);
10422         LDKFallback_ScriptHash_class =
10423                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKFallback$ScriptHash;"));
10424         CHECK(LDKFallback_ScriptHash_class != NULL);
10425         LDKFallback_ScriptHash_meth = (*env)->GetMethodID(env, LDKFallback_ScriptHash_class, "<init>", "([B)V");
10426         CHECK(LDKFallback_ScriptHash_meth != NULL);
10427 }
10428 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKFallback_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
10429         LDKFallback *obj = (LDKFallback*)(ptr & ~1);
10430         switch(obj->tag) {
10431                 case LDKFallback_SegWitProgram: {
10432                         uint8_t version_val = obj->seg_wit_program.version._0;
10433                         LDKCVec_u8Z program_var = obj->seg_wit_program.program;
10434                         int8_tArray program_arr = (*env)->NewByteArray(env, program_var.datalen);
10435                         (*env)->SetByteArrayRegion(env, program_arr, 0, program_var.datalen, program_var.data);
10436                         return (*env)->NewObject(env, LDKFallback_SegWitProgram_class, LDKFallback_SegWitProgram_meth, version_val, program_arr);
10437                 }
10438                 case LDKFallback_PubKeyHash: {
10439                         int8_tArray pub_key_hash_arr = (*env)->NewByteArray(env, 20);
10440                         (*env)->SetByteArrayRegion(env, pub_key_hash_arr, 0, 20, obj->pub_key_hash.data);
10441                         return (*env)->NewObject(env, LDKFallback_PubKeyHash_class, LDKFallback_PubKeyHash_meth, pub_key_hash_arr);
10442                 }
10443                 case LDKFallback_ScriptHash: {
10444                         int8_tArray script_hash_arr = (*env)->NewByteArray(env, 20);
10445                         (*env)->SetByteArrayRegion(env, script_hash_arr, 0, 20, obj->script_hash.data);
10446                         return (*env)->NewObject(env, LDKFallback_ScriptHash_class, LDKFallback_ScriptHash_meth, script_hash_arr);
10447                 }
10448                 default: abort();
10449         }
10450 }
10451 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings__1ldk_1get_1compiled_1version(JNIEnv *env, jclass clz) {
10452         LDKStr ret_str = _ldk_get_compiled_version();
10453         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
10454         Str_free(ret_str);
10455         return ret_conv;
10456 }
10457
10458 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings__1ldk_1c_1bindings_1get_1compiled_1version(JNIEnv *env, jclass clz) {
10459         LDKStr ret_str = _ldk_c_bindings_get_compiled_version();
10460         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
10461         Str_free(ret_str);
10462         return ret_conv;
10463 }
10464
10465 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Transaction_1free(JNIEnv *env, jclass clz, int8_tArray _res) {
10466         LDKTransaction _res_ref;
10467         _res_ref.datalen = (*env)->GetArrayLength(env, _res);
10468         _res_ref.data = MALLOC(_res_ref.datalen, "LDKTransaction Bytes");
10469         (*env)->GetByteArrayRegion(env, _res, 0, _res_ref.datalen, _res_ref.data);
10470         _res_ref.data_is_owned = true;
10471         Transaction_free(_res_ref);
10472 }
10473
10474 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxOut_1new(JNIEnv *env, jclass clz, int8_tArray script_pubkey, int64_t value) {
10475         LDKCVec_u8Z script_pubkey_ref;
10476         script_pubkey_ref.datalen = (*env)->GetArrayLength(env, script_pubkey);
10477         script_pubkey_ref.data = MALLOC(script_pubkey_ref.datalen, "LDKCVec_u8Z Bytes");
10478         (*env)->GetByteArrayRegion(env, script_pubkey, 0, script_pubkey_ref.datalen, script_pubkey_ref.data);
10479         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
10480         *ret_ref = TxOut_new(script_pubkey_ref, value);
10481         return (uint64_t)ret_ref;
10482 }
10483
10484 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxOut_1free(JNIEnv *env, jclass clz, int64_t _res) {
10485         if ((_res & 1) != 0) return;
10486         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
10487         CHECK_ACCESS(_res_ptr);
10488         LDKTxOut _res_conv = *(LDKTxOut*)(_res_ptr);
10489         FREE((void*)_res);
10490         TxOut_free(_res_conv);
10491 }
10492
10493 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxOut_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10494         LDKTxOut* orig_conv = (LDKTxOut*)(orig & ~1);
10495         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
10496         *ret_ref = TxOut_clone(orig_conv);
10497         return (uint64_t)ret_ref;
10498 }
10499
10500 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Str_1free(JNIEnv *env, jclass clz, jstring _res) {
10501         LDKStr dummy = { .chars = NULL, .len = 0, .chars_is_owned = false };
10502         Str_free(dummy);
10503 }
10504
10505 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
10506         LDKSecretKey o_ref;
10507         CHECK((*env)->GetArrayLength(env, o) == 32);
10508         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.bytes);
10509         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
10510         *ret_conv = CResult_SecretKeyErrorZ_ok(o_ref);
10511         return (uint64_t)ret_conv;
10512 }
10513
10514 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
10515         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
10516         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
10517         *ret_conv = CResult_SecretKeyErrorZ_err(e_conv);
10518         return (uint64_t)ret_conv;
10519 }
10520
10521 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10522         if ((_res & 1) != 0) return;
10523         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
10524         CHECK_ACCESS(_res_ptr);
10525         LDKCResult_SecretKeyErrorZ _res_conv = *(LDKCResult_SecretKeyErrorZ*)(_res_ptr);
10526         FREE((void*)_res);
10527         CResult_SecretKeyErrorZ_free(_res_conv);
10528 }
10529
10530 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
10531         LDKPublicKey o_ref;
10532         CHECK((*env)->GetArrayLength(env, o) == 33);
10533         (*env)->GetByteArrayRegion(env, o, 0, 33, o_ref.compressed_form);
10534         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
10535         *ret_conv = CResult_PublicKeyErrorZ_ok(o_ref);
10536         return (uint64_t)ret_conv;
10537 }
10538
10539 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
10540         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
10541         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
10542         *ret_conv = CResult_PublicKeyErrorZ_err(e_conv);
10543         return (uint64_t)ret_conv;
10544 }
10545
10546 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10547         if ((_res & 1) != 0) return;
10548         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
10549         CHECK_ACCESS(_res_ptr);
10550         LDKCResult_PublicKeyErrorZ _res_conv = *(LDKCResult_PublicKeyErrorZ*)(_res_ptr);
10551         FREE((void*)_res);
10552         CResult_PublicKeyErrorZ_free(_res_conv);
10553 }
10554
10555 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10556         LDKCResult_PublicKeyErrorZ* orig_conv = (LDKCResult_PublicKeyErrorZ*)(orig & ~1);
10557         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
10558         *ret_conv = CResult_PublicKeyErrorZ_clone(orig_conv);
10559         return (uint64_t)ret_conv;
10560 }
10561
10562 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10563         LDKTxCreationKeys o_conv;
10564         o_conv.inner = (void*)(o & (~1));
10565         o_conv.is_owned = (o & 1) || (o == 0);
10566         o_conv = TxCreationKeys_clone(&o_conv);
10567         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
10568         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_ok(o_conv);
10569         return (uint64_t)ret_conv;
10570 }
10571
10572 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10573         LDKDecodeError e_conv;
10574         e_conv.inner = (void*)(e & (~1));
10575         e_conv.is_owned = (e & 1) || (e == 0);
10576         e_conv = DecodeError_clone(&e_conv);
10577         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
10578         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_err(e_conv);
10579         return (uint64_t)ret_conv;
10580 }
10581
10582 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10583         if ((_res & 1) != 0) return;
10584         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
10585         CHECK_ACCESS(_res_ptr);
10586         LDKCResult_TxCreationKeysDecodeErrorZ _res_conv = *(LDKCResult_TxCreationKeysDecodeErrorZ*)(_res_ptr);
10587         FREE((void*)_res);
10588         CResult_TxCreationKeysDecodeErrorZ_free(_res_conv);
10589 }
10590
10591 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10592         LDKCResult_TxCreationKeysDecodeErrorZ* orig_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(orig & ~1);
10593         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
10594         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(orig_conv);
10595         return (uint64_t)ret_conv;
10596 }
10597
10598 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10599         LDKChannelPublicKeys o_conv;
10600         o_conv.inner = (void*)(o & (~1));
10601         o_conv.is_owned = (o & 1) || (o == 0);
10602         o_conv = ChannelPublicKeys_clone(&o_conv);
10603         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
10604         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_ok(o_conv);
10605         return (uint64_t)ret_conv;
10606 }
10607
10608 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10609         LDKDecodeError e_conv;
10610         e_conv.inner = (void*)(e & (~1));
10611         e_conv.is_owned = (e & 1) || (e == 0);
10612         e_conv = DecodeError_clone(&e_conv);
10613         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
10614         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_err(e_conv);
10615         return (uint64_t)ret_conv;
10616 }
10617
10618 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10619         if ((_res & 1) != 0) return;
10620         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
10621         CHECK_ACCESS(_res_ptr);
10622         LDKCResult_ChannelPublicKeysDecodeErrorZ _res_conv = *(LDKCResult_ChannelPublicKeysDecodeErrorZ*)(_res_ptr);
10623         FREE((void*)_res);
10624         CResult_ChannelPublicKeysDecodeErrorZ_free(_res_conv);
10625 }
10626
10627 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10628         LDKCResult_ChannelPublicKeysDecodeErrorZ* orig_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(orig & ~1);
10629         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
10630         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(orig_conv);
10631         return (uint64_t)ret_conv;
10632 }
10633
10634 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10635         LDKTxCreationKeys o_conv;
10636         o_conv.inner = (void*)(o & (~1));
10637         o_conv.is_owned = (o & 1) || (o == 0);
10638         o_conv = TxCreationKeys_clone(&o_conv);
10639         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
10640         *ret_conv = CResult_TxCreationKeysErrorZ_ok(o_conv);
10641         return (uint64_t)ret_conv;
10642 }
10643
10644 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
10645         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
10646         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
10647         *ret_conv = CResult_TxCreationKeysErrorZ_err(e_conv);
10648         return (uint64_t)ret_conv;
10649 }
10650
10651 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10652         if ((_res & 1) != 0) return;
10653         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
10654         CHECK_ACCESS(_res_ptr);
10655         LDKCResult_TxCreationKeysErrorZ _res_conv = *(LDKCResult_TxCreationKeysErrorZ*)(_res_ptr);
10656         FREE((void*)_res);
10657         CResult_TxCreationKeysErrorZ_free(_res_conv);
10658 }
10659
10660 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10661         LDKCResult_TxCreationKeysErrorZ* orig_conv = (LDKCResult_TxCreationKeysErrorZ*)(orig & ~1);
10662         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
10663         *ret_conv = CResult_TxCreationKeysErrorZ_clone(orig_conv);
10664         return (uint64_t)ret_conv;
10665 }
10666
10667 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1some(JNIEnv *env, jclass clz, int32_t o) {
10668         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
10669         *ret_copy = COption_u32Z_some(o);
10670         uint64_t ret_ref = (uint64_t)ret_copy;
10671         return ret_ref;
10672 }
10673
10674 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1none(JNIEnv *env, jclass clz) {
10675         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
10676         *ret_copy = COption_u32Z_none();
10677         uint64_t ret_ref = (uint64_t)ret_copy;
10678         return ret_ref;
10679 }
10680
10681 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
10682         if ((_res & 1) != 0) return;
10683         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
10684         CHECK_ACCESS(_res_ptr);
10685         LDKCOption_u32Z _res_conv = *(LDKCOption_u32Z*)(_res_ptr);
10686         FREE((void*)_res);
10687         COption_u32Z_free(_res_conv);
10688 }
10689
10690 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10691         LDKCOption_u32Z* orig_conv = (LDKCOption_u32Z*)orig;
10692         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
10693         *ret_copy = COption_u32Z_clone(orig_conv);
10694         uint64_t ret_ref = (uint64_t)ret_copy;
10695         return ret_ref;
10696 }
10697
10698 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10699         LDKHTLCOutputInCommitment o_conv;
10700         o_conv.inner = (void*)(o & (~1));
10701         o_conv.is_owned = (o & 1) || (o == 0);
10702         o_conv = HTLCOutputInCommitment_clone(&o_conv);
10703         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
10704         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(o_conv);
10705         return (uint64_t)ret_conv;
10706 }
10707
10708 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10709         LDKDecodeError e_conv;
10710         e_conv.inner = (void*)(e & (~1));
10711         e_conv.is_owned = (e & 1) || (e == 0);
10712         e_conv = DecodeError_clone(&e_conv);
10713         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
10714         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_err(e_conv);
10715         return (uint64_t)ret_conv;
10716 }
10717
10718 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10719         if ((_res & 1) != 0) return;
10720         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
10721         CHECK_ACCESS(_res_ptr);
10722         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ _res_conv = *(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(_res_ptr);
10723         FREE((void*)_res);
10724         CResult_HTLCOutputInCommitmentDecodeErrorZ_free(_res_conv);
10725 }
10726
10727 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10728         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* orig_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(orig & ~1);
10729         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
10730         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(orig_conv);
10731         return (uint64_t)ret_conv;
10732 }
10733
10734 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10735         LDKCounterpartyChannelTransactionParameters o_conv;
10736         o_conv.inner = (void*)(o & (~1));
10737         o_conv.is_owned = (o & 1) || (o == 0);
10738         o_conv = CounterpartyChannelTransactionParameters_clone(&o_conv);
10739         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
10740         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(o_conv);
10741         return (uint64_t)ret_conv;
10742 }
10743
10744 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10745         LDKDecodeError e_conv;
10746         e_conv.inner = (void*)(e & (~1));
10747         e_conv.is_owned = (e & 1) || (e == 0);
10748         e_conv = DecodeError_clone(&e_conv);
10749         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
10750         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(e_conv);
10751         return (uint64_t)ret_conv;
10752 }
10753
10754 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10755         if ((_res & 1) != 0) return;
10756         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
10757         CHECK_ACCESS(_res_ptr);
10758         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(_res_ptr);
10759         FREE((void*)_res);
10760         CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(_res_conv);
10761 }
10762
10763 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10764         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
10765         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
10766         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
10767         return (uint64_t)ret_conv;
10768 }
10769
10770 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10771         LDKChannelTransactionParameters o_conv;
10772         o_conv.inner = (void*)(o & (~1));
10773         o_conv.is_owned = (o & 1) || (o == 0);
10774         o_conv = ChannelTransactionParameters_clone(&o_conv);
10775         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
10776         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_ok(o_conv);
10777         return (uint64_t)ret_conv;
10778 }
10779
10780 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10781         LDKDecodeError e_conv;
10782         e_conv.inner = (void*)(e & (~1));
10783         e_conv.is_owned = (e & 1) || (e == 0);
10784         e_conv = DecodeError_clone(&e_conv);
10785         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
10786         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_err(e_conv);
10787         return (uint64_t)ret_conv;
10788 }
10789
10790 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10791         if ((_res & 1) != 0) return;
10792         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
10793         CHECK_ACCESS(_res_ptr);
10794         LDKCResult_ChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(_res_ptr);
10795         FREE((void*)_res);
10796         CResult_ChannelTransactionParametersDecodeErrorZ_free(_res_conv);
10797 }
10798
10799 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10800         LDKCResult_ChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
10801         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
10802         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
10803         return (uint64_t)ret_conv;
10804 }
10805
10806 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1SignatureZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
10807         LDKCVec_SignatureZ _res_constr;
10808         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
10809         if (_res_constr.datalen > 0)
10810                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
10811         else
10812                 _res_constr.data = NULL;
10813         for (size_t i = 0; i < _res_constr.datalen; i++) {
10814                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
10815                 LDKSignature _res_conv_8_ref;
10816                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 64);
10817                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 64, _res_conv_8_ref.compact_form);
10818                 _res_constr.data[i] = _res_conv_8_ref;
10819         }
10820         CVec_SignatureZ_free(_res_constr);
10821 }
10822
10823 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10824         LDKHolderCommitmentTransaction o_conv;
10825         o_conv.inner = (void*)(o & (~1));
10826         o_conv.is_owned = (o & 1) || (o == 0);
10827         o_conv = HolderCommitmentTransaction_clone(&o_conv);
10828         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
10829         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_ok(o_conv);
10830         return (uint64_t)ret_conv;
10831 }
10832
10833 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10834         LDKDecodeError e_conv;
10835         e_conv.inner = (void*)(e & (~1));
10836         e_conv.is_owned = (e & 1) || (e == 0);
10837         e_conv = DecodeError_clone(&e_conv);
10838         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
10839         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_err(e_conv);
10840         return (uint64_t)ret_conv;
10841 }
10842
10843 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10844         if ((_res & 1) != 0) return;
10845         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
10846         CHECK_ACCESS(_res_ptr);
10847         LDKCResult_HolderCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(_res_ptr);
10848         FREE((void*)_res);
10849         CResult_HolderCommitmentTransactionDecodeErrorZ_free(_res_conv);
10850 }
10851
10852 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10853         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(orig & ~1);
10854         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
10855         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(orig_conv);
10856         return (uint64_t)ret_conv;
10857 }
10858
10859 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10860         LDKBuiltCommitmentTransaction o_conv;
10861         o_conv.inner = (void*)(o & (~1));
10862         o_conv.is_owned = (o & 1) || (o == 0);
10863         o_conv = BuiltCommitmentTransaction_clone(&o_conv);
10864         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
10865         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(o_conv);
10866         return (uint64_t)ret_conv;
10867 }
10868
10869 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10870         LDKDecodeError e_conv;
10871         e_conv.inner = (void*)(e & (~1));
10872         e_conv.is_owned = (e & 1) || (e == 0);
10873         e_conv = DecodeError_clone(&e_conv);
10874         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
10875         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_err(e_conv);
10876         return (uint64_t)ret_conv;
10877 }
10878
10879 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10880         if ((_res & 1) != 0) return;
10881         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
10882         CHECK_ACCESS(_res_ptr);
10883         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(_res_ptr);
10884         FREE((void*)_res);
10885         CResult_BuiltCommitmentTransactionDecodeErrorZ_free(_res_conv);
10886 }
10887
10888 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10889         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(orig & ~1);
10890         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
10891         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(orig_conv);
10892         return (uint64_t)ret_conv;
10893 }
10894
10895 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10896         LDKTrustedClosingTransaction o_conv;
10897         o_conv.inner = (void*)(o & (~1));
10898         o_conv.is_owned = (o & 1) || (o == 0);
10899         // Warning: we need a move here but no clone is available for LDKTrustedClosingTransaction
10900         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
10901         *ret_conv = CResult_TrustedClosingTransactionNoneZ_ok(o_conv);
10902         return (uint64_t)ret_conv;
10903 }
10904
10905 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1err(JNIEnv *env, jclass clz) {
10906         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
10907         *ret_conv = CResult_TrustedClosingTransactionNoneZ_err();
10908         return (uint64_t)ret_conv;
10909 }
10910
10911 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10912         if ((_res & 1) != 0) return;
10913         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
10914         CHECK_ACCESS(_res_ptr);
10915         LDKCResult_TrustedClosingTransactionNoneZ _res_conv = *(LDKCResult_TrustedClosingTransactionNoneZ*)(_res_ptr);
10916         FREE((void*)_res);
10917         CResult_TrustedClosingTransactionNoneZ_free(_res_conv);
10918 }
10919
10920 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10921         LDKCommitmentTransaction o_conv;
10922         o_conv.inner = (void*)(o & (~1));
10923         o_conv.is_owned = (o & 1) || (o == 0);
10924         o_conv = CommitmentTransaction_clone(&o_conv);
10925         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
10926         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_ok(o_conv);
10927         return (uint64_t)ret_conv;
10928 }
10929
10930 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10931         LDKDecodeError e_conv;
10932         e_conv.inner = (void*)(e & (~1));
10933         e_conv.is_owned = (e & 1) || (e == 0);
10934         e_conv = DecodeError_clone(&e_conv);
10935         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
10936         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_err(e_conv);
10937         return (uint64_t)ret_conv;
10938 }
10939
10940 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10941         if ((_res & 1) != 0) return;
10942         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
10943         CHECK_ACCESS(_res_ptr);
10944         LDKCResult_CommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_CommitmentTransactionDecodeErrorZ*)(_res_ptr);
10945         FREE((void*)_res);
10946         CResult_CommitmentTransactionDecodeErrorZ_free(_res_conv);
10947 }
10948
10949 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10950         LDKCResult_CommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(orig & ~1);
10951         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
10952         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(orig_conv);
10953         return (uint64_t)ret_conv;
10954 }
10955
10956 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10957         LDKTrustedCommitmentTransaction o_conv;
10958         o_conv.inner = (void*)(o & (~1));
10959         o_conv.is_owned = (o & 1) || (o == 0);
10960         // Warning: we need a move here but no clone is available for LDKTrustedCommitmentTransaction
10961         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
10962         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_ok(o_conv);
10963         return (uint64_t)ret_conv;
10964 }
10965
10966 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1err(JNIEnv *env, jclass clz) {
10967         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
10968         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_err();
10969         return (uint64_t)ret_conv;
10970 }
10971
10972 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10973         if ((_res & 1) != 0) return;
10974         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
10975         CHECK_ACCESS(_res_ptr);
10976         LDKCResult_TrustedCommitmentTransactionNoneZ _res_conv = *(LDKCResult_TrustedCommitmentTransactionNoneZ*)(_res_ptr);
10977         FREE((void*)_res);
10978         CResult_TrustedCommitmentTransactionNoneZ_free(_res_conv);
10979 }
10980
10981 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1ok(JNIEnv *env, jclass clz, jobjectArray o) {
10982         LDKCVec_SignatureZ o_constr;
10983         o_constr.datalen = (*env)->GetArrayLength(env, o);
10984         if (o_constr.datalen > 0)
10985                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
10986         else
10987                 o_constr.data = NULL;
10988         for (size_t i = 0; i < o_constr.datalen; i++) {
10989                 int8_tArray o_conv_8 = (*env)->GetObjectArrayElement(env, o, i);
10990                 LDKSignature o_conv_8_ref;
10991                 CHECK((*env)->GetArrayLength(env, o_conv_8) == 64);
10992                 (*env)->GetByteArrayRegion(env, o_conv_8, 0, 64, o_conv_8_ref.compact_form);
10993                 o_constr.data[i] = o_conv_8_ref;
10994         }
10995         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
10996         *ret_conv = CResult_CVec_SignatureZNoneZ_ok(o_constr);
10997         return (uint64_t)ret_conv;
10998 }
10999
11000 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1err(JNIEnv *env, jclass clz) {
11001         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
11002         *ret_conv = CResult_CVec_SignatureZNoneZ_err();
11003         return (uint64_t)ret_conv;
11004 }
11005
11006 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11007         if ((_res & 1) != 0) return;
11008         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11009         CHECK_ACCESS(_res_ptr);
11010         LDKCResult_CVec_SignatureZNoneZ _res_conv = *(LDKCResult_CVec_SignatureZNoneZ*)(_res_ptr);
11011         FREE((void*)_res);
11012         CResult_CVec_SignatureZNoneZ_free(_res_conv);
11013 }
11014
11015 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11016         LDKCResult_CVec_SignatureZNoneZ* orig_conv = (LDKCResult_CVec_SignatureZNoneZ*)(orig & ~1);
11017         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
11018         *ret_conv = CResult_CVec_SignatureZNoneZ_clone(orig_conv);
11019         return (uint64_t)ret_conv;
11020 }
11021
11022 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11023         LDKShutdownScript o_conv;
11024         o_conv.inner = (void*)(o & (~1));
11025         o_conv.is_owned = (o & 1) || (o == 0);
11026         o_conv = ShutdownScript_clone(&o_conv);
11027         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
11028         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_ok(o_conv);
11029         return (uint64_t)ret_conv;
11030 }
11031
11032 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11033         LDKDecodeError e_conv;
11034         e_conv.inner = (void*)(e & (~1));
11035         e_conv.is_owned = (e & 1) || (e == 0);
11036         e_conv = DecodeError_clone(&e_conv);
11037         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
11038         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_err(e_conv);
11039         return (uint64_t)ret_conv;
11040 }
11041
11042 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11043         if ((_res & 1) != 0) return;
11044         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11045         CHECK_ACCESS(_res_ptr);
11046         LDKCResult_ShutdownScriptDecodeErrorZ _res_conv = *(LDKCResult_ShutdownScriptDecodeErrorZ*)(_res_ptr);
11047         FREE((void*)_res);
11048         CResult_ShutdownScriptDecodeErrorZ_free(_res_conv);
11049 }
11050
11051 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11052         LDKCResult_ShutdownScriptDecodeErrorZ* orig_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(orig & ~1);
11053         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
11054         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone(orig_conv);
11055         return (uint64_t)ret_conv;
11056 }
11057
11058 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11059         LDKShutdownScript o_conv;
11060         o_conv.inner = (void*)(o & (~1));
11061         o_conv.is_owned = (o & 1) || (o == 0);
11062         o_conv = ShutdownScript_clone(&o_conv);
11063         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
11064         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_ok(o_conv);
11065         return (uint64_t)ret_conv;
11066 }
11067
11068 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11069         LDKInvalidShutdownScript e_conv;
11070         e_conv.inner = (void*)(e & (~1));
11071         e_conv.is_owned = (e & 1) || (e == 0);
11072         e_conv = InvalidShutdownScript_clone(&e_conv);
11073         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
11074         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_err(e_conv);
11075         return (uint64_t)ret_conv;
11076 }
11077
11078 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11079         if ((_res & 1) != 0) return;
11080         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11081         CHECK_ACCESS(_res_ptr);
11082         LDKCResult_ShutdownScriptInvalidShutdownScriptZ _res_conv = *(LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(_res_ptr);
11083         FREE((void*)_res);
11084         CResult_ShutdownScriptInvalidShutdownScriptZ_free(_res_conv);
11085 }
11086
11087 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11088         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* orig_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(orig & ~1);
11089         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
11090         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone(orig_conv);
11091         return (uint64_t)ret_conv;
11092 }
11093
11094 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1ok(JNIEnv *env, jclass clz) {
11095         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
11096         *ret_conv = CResult_NoneErrorZ_ok();
11097         return (uint64_t)ret_conv;
11098 }
11099
11100 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
11101         LDKIOError e_conv = LDKIOError_from_java(env, e);
11102         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
11103         *ret_conv = CResult_NoneErrorZ_err(e_conv);
11104         return (uint64_t)ret_conv;
11105 }
11106
11107 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11108         if ((_res & 1) != 0) return;
11109         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11110         CHECK_ACCESS(_res_ptr);
11111         LDKCResult_NoneErrorZ _res_conv = *(LDKCResult_NoneErrorZ*)(_res_ptr);
11112         FREE((void*)_res);
11113         CResult_NoneErrorZ_free(_res_conv);
11114 }
11115
11116 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11117         LDKCResult_NoneErrorZ* orig_conv = (LDKCResult_NoneErrorZ*)(orig & ~1);
11118         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
11119         *ret_conv = CResult_NoneErrorZ_clone(orig_conv);
11120         return (uint64_t)ret_conv;
11121 }
11122
11123 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11124         LDKRouteHop o_conv;
11125         o_conv.inner = (void*)(o & (~1));
11126         o_conv.is_owned = (o & 1) || (o == 0);
11127         o_conv = RouteHop_clone(&o_conv);
11128         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
11129         *ret_conv = CResult_RouteHopDecodeErrorZ_ok(o_conv);
11130         return (uint64_t)ret_conv;
11131 }
11132
11133 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11134         LDKDecodeError e_conv;
11135         e_conv.inner = (void*)(e & (~1));
11136         e_conv.is_owned = (e & 1) || (e == 0);
11137         e_conv = DecodeError_clone(&e_conv);
11138         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
11139         *ret_conv = CResult_RouteHopDecodeErrorZ_err(e_conv);
11140         return (uint64_t)ret_conv;
11141 }
11142
11143 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11144         if ((_res & 1) != 0) return;
11145         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11146         CHECK_ACCESS(_res_ptr);
11147         LDKCResult_RouteHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHopDecodeErrorZ*)(_res_ptr);
11148         FREE((void*)_res);
11149         CResult_RouteHopDecodeErrorZ_free(_res_conv);
11150 }
11151
11152 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11153         LDKCResult_RouteHopDecodeErrorZ* orig_conv = (LDKCResult_RouteHopDecodeErrorZ*)(orig & ~1);
11154         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
11155         *ret_conv = CResult_RouteHopDecodeErrorZ_clone(orig_conv);
11156         return (uint64_t)ret_conv;
11157 }
11158
11159 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHopZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
11160         LDKCVec_RouteHopZ _res_constr;
11161         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11162         if (_res_constr.datalen > 0)
11163                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
11164         else
11165                 _res_constr.data = NULL;
11166         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
11167         for (size_t k = 0; k < _res_constr.datalen; k++) {
11168                 int64_t _res_conv_10 = _res_vals[k];
11169                 LDKRouteHop _res_conv_10_conv;
11170                 _res_conv_10_conv.inner = (void*)(_res_conv_10 & (~1));
11171                 _res_conv_10_conv.is_owned = (_res_conv_10 & 1) || (_res_conv_10 == 0);
11172                 _res_constr.data[k] = _res_conv_10_conv;
11173         }
11174         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
11175         CVec_RouteHopZ_free(_res_constr);
11176 }
11177
11178 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CVec_1RouteHopZZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
11179         LDKCVec_CVec_RouteHopZZ _res_constr;
11180         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11181         if (_res_constr.datalen > 0)
11182                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
11183         else
11184                 _res_constr.data = NULL;
11185         for (size_t m = 0; m < _res_constr.datalen; m++) {
11186                 int64_tArray _res_conv_12 = (*env)->GetObjectArrayElement(env, _res, m);
11187                 LDKCVec_RouteHopZ _res_conv_12_constr;
11188                 _res_conv_12_constr.datalen = (*env)->GetArrayLength(env, _res_conv_12);
11189                 if (_res_conv_12_constr.datalen > 0)
11190                         _res_conv_12_constr.data = MALLOC(_res_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
11191                 else
11192                         _res_conv_12_constr.data = NULL;
11193                 int64_t* _res_conv_12_vals = (*env)->GetLongArrayElements (env, _res_conv_12, NULL);
11194                 for (size_t k = 0; k < _res_conv_12_constr.datalen; k++) {
11195                         int64_t _res_conv_12_conv_10 = _res_conv_12_vals[k];
11196                         LDKRouteHop _res_conv_12_conv_10_conv;
11197                         _res_conv_12_conv_10_conv.inner = (void*)(_res_conv_12_conv_10 & (~1));
11198                         _res_conv_12_conv_10_conv.is_owned = (_res_conv_12_conv_10 & 1) || (_res_conv_12_conv_10 == 0);
11199                         _res_conv_12_constr.data[k] = _res_conv_12_conv_10_conv;
11200                 }
11201                 (*env)->ReleaseLongArrayElements(env, _res_conv_12, _res_conv_12_vals, 0);
11202                 _res_constr.data[m] = _res_conv_12_constr;
11203         }
11204         CVec_CVec_RouteHopZZ_free(_res_constr);
11205 }
11206
11207 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11208         LDKRoute o_conv;
11209         o_conv.inner = (void*)(o & (~1));
11210         o_conv.is_owned = (o & 1) || (o == 0);
11211         o_conv = Route_clone(&o_conv);
11212         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
11213         *ret_conv = CResult_RouteDecodeErrorZ_ok(o_conv);
11214         return (uint64_t)ret_conv;
11215 }
11216
11217 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11218         LDKDecodeError e_conv;
11219         e_conv.inner = (void*)(e & (~1));
11220         e_conv.is_owned = (e & 1) || (e == 0);
11221         e_conv = DecodeError_clone(&e_conv);
11222         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
11223         *ret_conv = CResult_RouteDecodeErrorZ_err(e_conv);
11224         return (uint64_t)ret_conv;
11225 }
11226
11227 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11228         if ((_res & 1) != 0) return;
11229         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11230         CHECK_ACCESS(_res_ptr);
11231         LDKCResult_RouteDecodeErrorZ _res_conv = *(LDKCResult_RouteDecodeErrorZ*)(_res_ptr);
11232         FREE((void*)_res);
11233         CResult_RouteDecodeErrorZ_free(_res_conv);
11234 }
11235
11236 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11237         LDKCResult_RouteDecodeErrorZ* orig_conv = (LDKCResult_RouteDecodeErrorZ*)(orig & ~1);
11238         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
11239         *ret_conv = CResult_RouteDecodeErrorZ_clone(orig_conv);
11240         return (uint64_t)ret_conv;
11241 }
11242
11243 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1some(JNIEnv *env, jclass clz, int64_t o) {
11244         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
11245         *ret_copy = COption_u64Z_some(o);
11246         uint64_t ret_ref = (uint64_t)ret_copy;
11247         return ret_ref;
11248 }
11249
11250 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1none(JNIEnv *env, jclass clz) {
11251         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
11252         *ret_copy = COption_u64Z_none();
11253         uint64_t ret_ref = (uint64_t)ret_copy;
11254         return ret_ref;
11255 }
11256
11257 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
11258         if ((_res & 1) != 0) return;
11259         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11260         CHECK_ACCESS(_res_ptr);
11261         LDKCOption_u64Z _res_conv = *(LDKCOption_u64Z*)(_res_ptr);
11262         FREE((void*)_res);
11263         COption_u64Z_free(_res_conv);
11264 }
11265
11266 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11267         LDKCOption_u64Z* orig_conv = (LDKCOption_u64Z*)orig;
11268         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
11269         *ret_copy = COption_u64Z_clone(orig_conv);
11270         uint64_t ret_ref = (uint64_t)ret_copy;
11271         return ret_ref;
11272 }
11273
11274 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ChannelDetailsZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
11275         LDKCVec_ChannelDetailsZ _res_constr;
11276         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11277         if (_res_constr.datalen > 0)
11278                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
11279         else
11280                 _res_constr.data = NULL;
11281         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
11282         for (size_t q = 0; q < _res_constr.datalen; q++) {
11283                 int64_t _res_conv_16 = _res_vals[q];
11284                 LDKChannelDetails _res_conv_16_conv;
11285                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
11286                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
11287                 _res_constr.data[q] = _res_conv_16_conv;
11288         }
11289         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
11290         CVec_ChannelDetailsZ_free(_res_constr);
11291 }
11292
11293 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHintZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
11294         LDKCVec_RouteHintZ _res_constr;
11295         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11296         if (_res_constr.datalen > 0)
11297                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
11298         else
11299                 _res_constr.data = NULL;
11300         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
11301         for (size_t l = 0; l < _res_constr.datalen; l++) {
11302                 int64_t _res_conv_11 = _res_vals[l];
11303                 LDKRouteHint _res_conv_11_conv;
11304                 _res_conv_11_conv.inner = (void*)(_res_conv_11 & (~1));
11305                 _res_conv_11_conv.is_owned = (_res_conv_11 & 1) || (_res_conv_11 == 0);
11306                 _res_constr.data[l] = _res_conv_11_conv;
11307         }
11308         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
11309         CVec_RouteHintZ_free(_res_constr);
11310 }
11311
11312 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11313         LDKRoute o_conv;
11314         o_conv.inner = (void*)(o & (~1));
11315         o_conv.is_owned = (o & 1) || (o == 0);
11316         o_conv = Route_clone(&o_conv);
11317         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
11318         *ret_conv = CResult_RouteLightningErrorZ_ok(o_conv);
11319         return (uint64_t)ret_conv;
11320 }
11321
11322 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11323         LDKLightningError e_conv;
11324         e_conv.inner = (void*)(e & (~1));
11325         e_conv.is_owned = (e & 1) || (e == 0);
11326         e_conv = LightningError_clone(&e_conv);
11327         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
11328         *ret_conv = CResult_RouteLightningErrorZ_err(e_conv);
11329         return (uint64_t)ret_conv;
11330 }
11331
11332 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11333         if ((_res & 1) != 0) return;
11334         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11335         CHECK_ACCESS(_res_ptr);
11336         LDKCResult_RouteLightningErrorZ _res_conv = *(LDKCResult_RouteLightningErrorZ*)(_res_ptr);
11337         FREE((void*)_res);
11338         CResult_RouteLightningErrorZ_free(_res_conv);
11339 }
11340
11341 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11342         LDKCResult_RouteLightningErrorZ* orig_conv = (LDKCResult_RouteLightningErrorZ*)(orig & ~1);
11343         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
11344         *ret_conv = CResult_RouteLightningErrorZ_clone(orig_conv);
11345         return (uint64_t)ret_conv;
11346 }
11347
11348 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11349         void* o_ptr = (void*)(((uint64_t)o) & ~1);
11350         CHECK_ACCESS(o_ptr);
11351         LDKTxOut o_conv = *(LDKTxOut*)(o_ptr);
11352         o_conv = TxOut_clone((LDKTxOut*)(((uint64_t)o) & ~1));
11353         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
11354         *ret_conv = CResult_TxOutAccessErrorZ_ok(o_conv);
11355         return (uint64_t)ret_conv;
11356 }
11357
11358 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
11359         LDKAccessError e_conv = LDKAccessError_from_java(env, e);
11360         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
11361         *ret_conv = CResult_TxOutAccessErrorZ_err(e_conv);
11362         return (uint64_t)ret_conv;
11363 }
11364
11365 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11366         if ((_res & 1) != 0) return;
11367         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11368         CHECK_ACCESS(_res_ptr);
11369         LDKCResult_TxOutAccessErrorZ _res_conv = *(LDKCResult_TxOutAccessErrorZ*)(_res_ptr);
11370         FREE((void*)_res);
11371         CResult_TxOutAccessErrorZ_free(_res_conv);
11372 }
11373
11374 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11375         LDKCResult_TxOutAccessErrorZ* orig_conv = (LDKCResult_TxOutAccessErrorZ*)(orig & ~1);
11376         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
11377         *ret_conv = CResult_TxOutAccessErrorZ_clone(orig_conv);
11378         return (uint64_t)ret_conv;
11379 }
11380
11381 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11382         LDKC2Tuple_usizeTransactionZ* orig_conv = (LDKC2Tuple_usizeTransactionZ*)(orig & ~1);
11383         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
11384         *ret_conv = C2Tuple_usizeTransactionZ_clone(orig_conv);
11385         return ((uint64_t)ret_conv);
11386 }
11387
11388 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
11389         LDKTransaction b_ref;
11390         b_ref.datalen = (*env)->GetArrayLength(env, b);
11391         b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
11392         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
11393         b_ref.data_is_owned = true;
11394         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
11395         *ret_conv = C2Tuple_usizeTransactionZ_new(a, b_ref);
11396         return ((uint64_t)ret_conv);
11397 }
11398
11399 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11400         if ((_res & 1) != 0) return;
11401         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11402         CHECK_ACCESS(_res_ptr);
11403         LDKC2Tuple_usizeTransactionZ _res_conv = *(LDKC2Tuple_usizeTransactionZ*)(_res_ptr);
11404         FREE((void*)_res);
11405         C2Tuple_usizeTransactionZ_free(_res_conv);
11406 }
11407
11408 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1usizeTransactionZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
11409         LDKCVec_C2Tuple_usizeTransactionZZ _res_constr;
11410         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11411         if (_res_constr.datalen > 0)
11412                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
11413         else
11414                 _res_constr.data = NULL;
11415         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
11416         for (size_t c = 0; c < _res_constr.datalen; c++) {
11417                 int64_t _res_conv_28 = _res_vals[c];
11418                 void* _res_conv_28_ptr = (void*)(((uint64_t)_res_conv_28) & ~1);
11419                 CHECK_ACCESS(_res_conv_28_ptr);
11420                 LDKC2Tuple_usizeTransactionZ _res_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(_res_conv_28_ptr);
11421                 FREE((void*)_res_conv_28);
11422                 _res_constr.data[c] = _res_conv_28_conv;
11423         }
11424         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
11425         CVec_C2Tuple_usizeTransactionZZ_free(_res_constr);
11426 }
11427
11428 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TxidZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
11429         LDKCVec_TxidZ _res_constr;
11430         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11431         if (_res_constr.datalen > 0)
11432                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
11433         else
11434                 _res_constr.data = NULL;
11435         for (size_t i = 0; i < _res_constr.datalen; i++) {
11436                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
11437                 LDKThirtyTwoBytes _res_conv_8_ref;
11438                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 32);
11439                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 32, _res_conv_8_ref.data);
11440                 _res_constr.data[i] = _res_conv_8_ref;
11441         }
11442         CVec_TxidZ_free(_res_constr);
11443 }
11444
11445 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1ok(JNIEnv *env, jclass clz) {
11446         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
11447         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_ok();
11448         return (uint64_t)ret_conv;
11449 }
11450
11451 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1err(JNIEnv *env, jclass clz, jclass e) {
11452         LDKChannelMonitorUpdateErr e_conv = LDKChannelMonitorUpdateErr_from_java(env, e);
11453         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
11454         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_err(e_conv);
11455         return (uint64_t)ret_conv;
11456 }
11457
11458 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11459         if ((_res & 1) != 0) return;
11460         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11461         CHECK_ACCESS(_res_ptr);
11462         LDKCResult_NoneChannelMonitorUpdateErrZ _res_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(_res_ptr);
11463         FREE((void*)_res);
11464         CResult_NoneChannelMonitorUpdateErrZ_free(_res_conv);
11465 }
11466
11467 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11468         LDKCResult_NoneChannelMonitorUpdateErrZ* orig_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(orig & ~1);
11469         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
11470         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone(orig_conv);
11471         return (uint64_t)ret_conv;
11472 }
11473
11474 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1MonitorEventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
11475         LDKCVec_MonitorEventZ _res_constr;
11476         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11477         if (_res_constr.datalen > 0)
11478                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
11479         else
11480                 _res_constr.data = NULL;
11481         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
11482         for (size_t o = 0; o < _res_constr.datalen; o++) {
11483                 int64_t _res_conv_14 = _res_vals[o];
11484                 void* _res_conv_14_ptr = (void*)(((uint64_t)_res_conv_14) & ~1);
11485                 CHECK_ACCESS(_res_conv_14_ptr);
11486                 LDKMonitorEvent _res_conv_14_conv = *(LDKMonitorEvent*)(_res_conv_14_ptr);
11487                 FREE((void*)_res_conv_14);
11488                 _res_constr.data[o] = _res_conv_14_conv;
11489         }
11490         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
11491         CVec_MonitorEventZ_free(_res_constr);
11492 }
11493
11494 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1some(JNIEnv *env, jclass clz, int64_t o) {
11495         void* o_ptr = (void*)(((uint64_t)o) & ~1);
11496         CHECK_ACCESS(o_ptr);
11497         LDKC2Tuple_usizeTransactionZ o_conv = *(LDKC2Tuple_usizeTransactionZ*)(o_ptr);
11498         o_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)o) & ~1));
11499         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
11500         *ret_copy = COption_C2Tuple_usizeTransactionZZ_some(o_conv);
11501         uint64_t ret_ref = (uint64_t)ret_copy;
11502         return ret_ref;
11503 }
11504
11505 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1none(JNIEnv *env, jclass clz) {
11506         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
11507         *ret_copy = COption_C2Tuple_usizeTransactionZZ_none();
11508         uint64_t ret_ref = (uint64_t)ret_copy;
11509         return ret_ref;
11510 }
11511
11512 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11513         if ((_res & 1) != 0) return;
11514         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11515         CHECK_ACCESS(_res_ptr);
11516         LDKCOption_C2Tuple_usizeTransactionZZ _res_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(_res_ptr);
11517         FREE((void*)_res);
11518         COption_C2Tuple_usizeTransactionZZ_free(_res_conv);
11519 }
11520
11521 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11522         LDKCOption_C2Tuple_usizeTransactionZZ* orig_conv = (LDKCOption_C2Tuple_usizeTransactionZZ*)orig;
11523         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
11524         *ret_copy = COption_C2Tuple_usizeTransactionZZ_clone(orig_conv);
11525         uint64_t ret_ref = (uint64_t)ret_copy;
11526         return ret_ref;
11527 }
11528
11529 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1some(JNIEnv *env, jclass clz, int64_t o) {
11530         void* o_ptr = (void*)(((uint64_t)o) & ~1);
11531         CHECK_ACCESS(o_ptr);
11532         LDKNetworkUpdate o_conv = *(LDKNetworkUpdate*)(o_ptr);
11533         o_conv = NetworkUpdate_clone((LDKNetworkUpdate*)(((uint64_t)o) & ~1));
11534         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
11535         *ret_copy = COption_NetworkUpdateZ_some(o_conv);
11536         uint64_t ret_ref = (uint64_t)ret_copy;
11537         return ret_ref;
11538 }
11539
11540 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1none(JNIEnv *env, jclass clz) {
11541         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
11542         *ret_copy = COption_NetworkUpdateZ_none();
11543         uint64_t ret_ref = (uint64_t)ret_copy;
11544         return ret_ref;
11545 }
11546
11547 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11548         if ((_res & 1) != 0) return;
11549         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11550         CHECK_ACCESS(_res_ptr);
11551         LDKCOption_NetworkUpdateZ _res_conv = *(LDKCOption_NetworkUpdateZ*)(_res_ptr);
11552         FREE((void*)_res);
11553         COption_NetworkUpdateZ_free(_res_conv);
11554 }
11555
11556 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11557         LDKCOption_NetworkUpdateZ* orig_conv = (LDKCOption_NetworkUpdateZ*)orig;
11558         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
11559         *ret_copy = COption_NetworkUpdateZ_clone(orig_conv);
11560         uint64_t ret_ref = (uint64_t)ret_copy;
11561         return ret_ref;
11562 }
11563
11564 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1SpendableOutputDescriptorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
11565         LDKCVec_SpendableOutputDescriptorZ _res_constr;
11566         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11567         if (_res_constr.datalen > 0)
11568                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
11569         else
11570                 _res_constr.data = NULL;
11571         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
11572         for (size_t b = 0; b < _res_constr.datalen; b++) {
11573                 int64_t _res_conv_27 = _res_vals[b];
11574                 void* _res_conv_27_ptr = (void*)(((uint64_t)_res_conv_27) & ~1);
11575                 CHECK_ACCESS(_res_conv_27_ptr);
11576                 LDKSpendableOutputDescriptor _res_conv_27_conv = *(LDKSpendableOutputDescriptor*)(_res_conv_27_ptr);
11577                 FREE((void*)_res_conv_27);
11578                 _res_constr.data[b] = _res_conv_27_conv;
11579         }
11580         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
11581         CVec_SpendableOutputDescriptorZ_free(_res_constr);
11582 }
11583
11584 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1MessageSendEventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
11585         LDKCVec_MessageSendEventZ _res_constr;
11586         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11587         if (_res_constr.datalen > 0)
11588                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
11589         else
11590                 _res_constr.data = NULL;
11591         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
11592         for (size_t s = 0; s < _res_constr.datalen; s++) {
11593                 int64_t _res_conv_18 = _res_vals[s];
11594                 void* _res_conv_18_ptr = (void*)(((uint64_t)_res_conv_18) & ~1);
11595                 CHECK_ACCESS(_res_conv_18_ptr);
11596                 LDKMessageSendEvent _res_conv_18_conv = *(LDKMessageSendEvent*)(_res_conv_18_ptr);
11597                 FREE((void*)_res_conv_18);
11598                 _res_constr.data[s] = _res_conv_18_conv;
11599         }
11600         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
11601         CVec_MessageSendEventZ_free(_res_constr);
11602 }
11603
11604 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11605         LDKInitFeatures o_conv;
11606         o_conv.inner = (void*)(o & (~1));
11607         o_conv.is_owned = (o & 1) || (o == 0);
11608         o_conv = InitFeatures_clone(&o_conv);
11609         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
11610         *ret_conv = CResult_InitFeaturesDecodeErrorZ_ok(o_conv);
11611         return (uint64_t)ret_conv;
11612 }
11613
11614 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11615         LDKDecodeError e_conv;
11616         e_conv.inner = (void*)(e & (~1));
11617         e_conv.is_owned = (e & 1) || (e == 0);
11618         e_conv = DecodeError_clone(&e_conv);
11619         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
11620         *ret_conv = CResult_InitFeaturesDecodeErrorZ_err(e_conv);
11621         return (uint64_t)ret_conv;
11622 }
11623
11624 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11625         if ((_res & 1) != 0) return;
11626         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11627         CHECK_ACCESS(_res_ptr);
11628         LDKCResult_InitFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InitFeaturesDecodeErrorZ*)(_res_ptr);
11629         FREE((void*)_res);
11630         CResult_InitFeaturesDecodeErrorZ_free(_res_conv);
11631 }
11632
11633 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11634         LDKNodeFeatures o_conv;
11635         o_conv.inner = (void*)(o & (~1));
11636         o_conv.is_owned = (o & 1) || (o == 0);
11637         o_conv = NodeFeatures_clone(&o_conv);
11638         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
11639         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_ok(o_conv);
11640         return (uint64_t)ret_conv;
11641 }
11642
11643 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11644         LDKDecodeError e_conv;
11645         e_conv.inner = (void*)(e & (~1));
11646         e_conv.is_owned = (e & 1) || (e == 0);
11647         e_conv = DecodeError_clone(&e_conv);
11648         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
11649         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_err(e_conv);
11650         return (uint64_t)ret_conv;
11651 }
11652
11653 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11654         if ((_res & 1) != 0) return;
11655         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11656         CHECK_ACCESS(_res_ptr);
11657         LDKCResult_NodeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_NodeFeaturesDecodeErrorZ*)(_res_ptr);
11658         FREE((void*)_res);
11659         CResult_NodeFeaturesDecodeErrorZ_free(_res_conv);
11660 }
11661
11662 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11663         LDKChannelFeatures o_conv;
11664         o_conv.inner = (void*)(o & (~1));
11665         o_conv.is_owned = (o & 1) || (o == 0);
11666         o_conv = ChannelFeatures_clone(&o_conv);
11667         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
11668         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_ok(o_conv);
11669         return (uint64_t)ret_conv;
11670 }
11671
11672 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11673         LDKDecodeError e_conv;
11674         e_conv.inner = (void*)(e & (~1));
11675         e_conv.is_owned = (e & 1) || (e == 0);
11676         e_conv = DecodeError_clone(&e_conv);
11677         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
11678         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_err(e_conv);
11679         return (uint64_t)ret_conv;
11680 }
11681
11682 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11683         if ((_res & 1) != 0) return;
11684         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11685         CHECK_ACCESS(_res_ptr);
11686         LDKCResult_ChannelFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelFeaturesDecodeErrorZ*)(_res_ptr);
11687         FREE((void*)_res);
11688         CResult_ChannelFeaturesDecodeErrorZ_free(_res_conv);
11689 }
11690
11691 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11692         LDKInvoiceFeatures o_conv;
11693         o_conv.inner = (void*)(o & (~1));
11694         o_conv.is_owned = (o & 1) || (o == 0);
11695         o_conv = InvoiceFeatures_clone(&o_conv);
11696         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
11697         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_ok(o_conv);
11698         return (uint64_t)ret_conv;
11699 }
11700
11701 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11702         LDKDecodeError e_conv;
11703         e_conv.inner = (void*)(e & (~1));
11704         e_conv.is_owned = (e & 1) || (e == 0);
11705         e_conv = DecodeError_clone(&e_conv);
11706         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
11707         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_err(e_conv);
11708         return (uint64_t)ret_conv;
11709 }
11710
11711 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11712         if ((_res & 1) != 0) return;
11713         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11714         CHECK_ACCESS(_res_ptr);
11715         LDKCResult_InvoiceFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InvoiceFeaturesDecodeErrorZ*)(_res_ptr);
11716         FREE((void*)_res);
11717         CResult_InvoiceFeaturesDecodeErrorZ_free(_res_conv);
11718 }
11719
11720 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11721         LDKDelayedPaymentOutputDescriptor o_conv;
11722         o_conv.inner = (void*)(o & (~1));
11723         o_conv.is_owned = (o & 1) || (o == 0);
11724         o_conv = DelayedPaymentOutputDescriptor_clone(&o_conv);
11725         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
11726         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
11727         return (uint64_t)ret_conv;
11728 }
11729
11730 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11731         LDKDecodeError e_conv;
11732         e_conv.inner = (void*)(e & (~1));
11733         e_conv.is_owned = (e & 1) || (e == 0);
11734         e_conv = DecodeError_clone(&e_conv);
11735         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
11736         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
11737         return (uint64_t)ret_conv;
11738 }
11739
11740 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11741         if ((_res & 1) != 0) return;
11742         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11743         CHECK_ACCESS(_res_ptr);
11744         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(_res_ptr);
11745         FREE((void*)_res);
11746         CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
11747 }
11748
11749 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11750         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(orig & ~1);
11751         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
11752         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
11753         return (uint64_t)ret_conv;
11754 }
11755
11756 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11757         LDKStaticPaymentOutputDescriptor o_conv;
11758         o_conv.inner = (void*)(o & (~1));
11759         o_conv.is_owned = (o & 1) || (o == 0);
11760         o_conv = StaticPaymentOutputDescriptor_clone(&o_conv);
11761         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
11762         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
11763         return (uint64_t)ret_conv;
11764 }
11765
11766 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11767         LDKDecodeError e_conv;
11768         e_conv.inner = (void*)(e & (~1));
11769         e_conv.is_owned = (e & 1) || (e == 0);
11770         e_conv = DecodeError_clone(&e_conv);
11771         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
11772         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
11773         return (uint64_t)ret_conv;
11774 }
11775
11776 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11777         if ((_res & 1) != 0) return;
11778         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11779         CHECK_ACCESS(_res_ptr);
11780         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(_res_ptr);
11781         FREE((void*)_res);
11782         CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
11783 }
11784
11785 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11786         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(orig & ~1);
11787         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
11788         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
11789         return (uint64_t)ret_conv;
11790 }
11791
11792 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11793         void* o_ptr = (void*)(((uint64_t)o) & ~1);
11794         CHECK_ACCESS(o_ptr);
11795         LDKSpendableOutputDescriptor o_conv = *(LDKSpendableOutputDescriptor*)(o_ptr);
11796         o_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uint64_t)o) & ~1));
11797         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
11798         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_ok(o_conv);
11799         return (uint64_t)ret_conv;
11800 }
11801
11802 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11803         LDKDecodeError e_conv;
11804         e_conv.inner = (void*)(e & (~1));
11805         e_conv.is_owned = (e & 1) || (e == 0);
11806         e_conv = DecodeError_clone(&e_conv);
11807         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
11808         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_err(e_conv);
11809         return (uint64_t)ret_conv;
11810 }
11811
11812 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11813         if ((_res & 1) != 0) return;
11814         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11815         CHECK_ACCESS(_res_ptr);
11816         LDKCResult_SpendableOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(_res_ptr);
11817         FREE((void*)_res);
11818         CResult_SpendableOutputDescriptorDecodeErrorZ_free(_res_conv);
11819 }
11820
11821 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11822         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(orig & ~1);
11823         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
11824         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(orig_conv);
11825         return (uint64_t)ret_conv;
11826 }
11827
11828 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1ok(JNIEnv *env, jclass clz) {
11829         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
11830         *ret_conv = CResult_NoneNoneZ_ok();
11831         return (uint64_t)ret_conv;
11832 }
11833
11834 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1err(JNIEnv *env, jclass clz) {
11835         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
11836         *ret_conv = CResult_NoneNoneZ_err();
11837         return (uint64_t)ret_conv;
11838 }
11839
11840 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11841         if ((_res & 1) != 0) return;
11842         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11843         CHECK_ACCESS(_res_ptr);
11844         LDKCResult_NoneNoneZ _res_conv = *(LDKCResult_NoneNoneZ*)(_res_ptr);
11845         FREE((void*)_res);
11846         CResult_NoneNoneZ_free(_res_conv);
11847 }
11848
11849 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11850         LDKCResult_NoneNoneZ* orig_conv = (LDKCResult_NoneNoneZ*)(orig & ~1);
11851         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
11852         *ret_conv = CResult_NoneNoneZ_clone(orig_conv);
11853         return (uint64_t)ret_conv;
11854 }
11855
11856 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11857         LDKC2Tuple_SignatureCVec_SignatureZZ* orig_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(orig & ~1);
11858         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
11859         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_clone(orig_conv);
11860         return ((uint64_t)ret_conv);
11861 }
11862
11863 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, jobjectArray b) {
11864         LDKSignature a_ref;
11865         CHECK((*env)->GetArrayLength(env, a) == 64);
11866         (*env)->GetByteArrayRegion(env, a, 0, 64, a_ref.compact_form);
11867         LDKCVec_SignatureZ b_constr;
11868         b_constr.datalen = (*env)->GetArrayLength(env, b);
11869         if (b_constr.datalen > 0)
11870                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
11871         else
11872                 b_constr.data = NULL;
11873         for (size_t i = 0; i < b_constr.datalen; i++) {
11874                 int8_tArray b_conv_8 = (*env)->GetObjectArrayElement(env, b, i);
11875                 LDKSignature b_conv_8_ref;
11876                 CHECK((*env)->GetArrayLength(env, b_conv_8) == 64);
11877                 (*env)->GetByteArrayRegion(env, b_conv_8, 0, 64, b_conv_8_ref.compact_form);
11878                 b_constr.data[i] = b_conv_8_ref;
11879         }
11880         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
11881         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_new(a_ref, b_constr);
11882         return ((uint64_t)ret_conv);
11883 }
11884
11885 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11886         if ((_res & 1) != 0) return;
11887         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11888         CHECK_ACCESS(_res_ptr);
11889         LDKC2Tuple_SignatureCVec_SignatureZZ _res_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(_res_ptr);
11890         FREE((void*)_res);
11891         C2Tuple_SignatureCVec_SignatureZZ_free(_res_conv);
11892 }
11893
11894 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11895         void* o_ptr = (void*)(((uint64_t)o) & ~1);
11896         CHECK_ACCESS(o_ptr);
11897         LDKC2Tuple_SignatureCVec_SignatureZZ o_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(o_ptr);
11898         o_conv = C2Tuple_SignatureCVec_SignatureZZ_clone((LDKC2Tuple_SignatureCVec_SignatureZZ*)(((uint64_t)o) & ~1));
11899         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
11900         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(o_conv);
11901         return (uint64_t)ret_conv;
11902 }
11903
11904 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1err(JNIEnv *env, jclass clz) {
11905         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
11906         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err();
11907         return (uint64_t)ret_conv;
11908 }
11909
11910 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11911         if ((_res & 1) != 0) return;
11912         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11913         CHECK_ACCESS(_res_ptr);
11914         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ _res_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(_res_ptr);
11915         FREE((void*)_res);
11916         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(_res_conv);
11917 }
11918
11919 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11920         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* orig_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(orig & ~1);
11921         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
11922         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(orig_conv);
11923         return (uint64_t)ret_conv;
11924 }
11925
11926 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
11927         LDKSignature o_ref;
11928         CHECK((*env)->GetArrayLength(env, o) == 64);
11929         (*env)->GetByteArrayRegion(env, o, 0, 64, o_ref.compact_form);
11930         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
11931         *ret_conv = CResult_SignatureNoneZ_ok(o_ref);
11932         return (uint64_t)ret_conv;
11933 }
11934
11935 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1err(JNIEnv *env, jclass clz) {
11936         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
11937         *ret_conv = CResult_SignatureNoneZ_err();
11938         return (uint64_t)ret_conv;
11939 }
11940
11941 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11942         if ((_res & 1) != 0) return;
11943         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11944         CHECK_ACCESS(_res_ptr);
11945         LDKCResult_SignatureNoneZ _res_conv = *(LDKCResult_SignatureNoneZ*)(_res_ptr);
11946         FREE((void*)_res);
11947         CResult_SignatureNoneZ_free(_res_conv);
11948 }
11949
11950 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11951         LDKCResult_SignatureNoneZ* orig_conv = (LDKCResult_SignatureNoneZ*)(orig & ~1);
11952         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
11953         *ret_conv = CResult_SignatureNoneZ_clone(orig_conv);
11954         return (uint64_t)ret_conv;
11955 }
11956
11957 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11958         void* o_ptr = (void*)(((uint64_t)o) & ~1);
11959         CHECK_ACCESS(o_ptr);
11960         LDKSign o_conv = *(LDKSign*)(o_ptr);
11961         if (o_conv.free == LDKSign_JCalls_free) {
11962                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
11963                 LDKSign_JCalls_cloned(&o_conv);
11964         }
11965         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
11966         *ret_conv = CResult_SignDecodeErrorZ_ok(o_conv);
11967         return (uint64_t)ret_conv;
11968 }
11969
11970 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11971         LDKDecodeError e_conv;
11972         e_conv.inner = (void*)(e & (~1));
11973         e_conv.is_owned = (e & 1) || (e == 0);
11974         e_conv = DecodeError_clone(&e_conv);
11975         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
11976         *ret_conv = CResult_SignDecodeErrorZ_err(e_conv);
11977         return (uint64_t)ret_conv;
11978 }
11979
11980 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11981         if ((_res & 1) != 0) return;
11982         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11983         CHECK_ACCESS(_res_ptr);
11984         LDKCResult_SignDecodeErrorZ _res_conv = *(LDKCResult_SignDecodeErrorZ*)(_res_ptr);
11985         FREE((void*)_res);
11986         CResult_SignDecodeErrorZ_free(_res_conv);
11987 }
11988
11989 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11990         LDKCResult_SignDecodeErrorZ* orig_conv = (LDKCResult_SignDecodeErrorZ*)(orig & ~1);
11991         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
11992         *ret_conv = CResult_SignDecodeErrorZ_clone(orig_conv);
11993         return (uint64_t)ret_conv;
11994 }
11995
11996 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u8Z_1free(JNIEnv *env, jclass clz, int8_tArray _res) {
11997         LDKCVec_u8Z _res_ref;
11998         _res_ref.datalen = (*env)->GetArrayLength(env, _res);
11999         _res_ref.data = MALLOC(_res_ref.datalen, "LDKCVec_u8Z Bytes");
12000         (*env)->GetByteArrayRegion(env, _res, 0, _res_ref.datalen, _res_ref.data);
12001         CVec_u8Z_free(_res_ref);
12002 }
12003
12004 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray arg) {
12005         LDKRecoverableSignature arg_ref;
12006         CHECK((*env)->GetArrayLength(env, arg) == 68);
12007         (*env)->GetByteArrayRegion(env, arg, 0, 68, arg_ref.serialized_form);
12008         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
12009         *ret_conv = CResult_RecoverableSignatureNoneZ_ok(arg_ref);
12010         return (uint64_t)ret_conv;
12011 }
12012
12013 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1err(JNIEnv *env, jclass clz) {
12014         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
12015         *ret_conv = CResult_RecoverableSignatureNoneZ_err();
12016         return (uint64_t)ret_conv;
12017 }
12018
12019 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12020         if ((_res & 1) != 0) return;
12021         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12022         CHECK_ACCESS(_res_ptr);
12023         LDKCResult_RecoverableSignatureNoneZ _res_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(_res_ptr);
12024         FREE((void*)_res);
12025         CResult_RecoverableSignatureNoneZ_free(_res_conv);
12026 }
12027
12028 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12029         LDKCResult_RecoverableSignatureNoneZ* orig_conv = (LDKCResult_RecoverableSignatureNoneZ*)(orig & ~1);
12030         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
12031         *ret_conv = CResult_RecoverableSignatureNoneZ_clone(orig_conv);
12032         return (uint64_t)ret_conv;
12033 }
12034
12035 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CVec_1u8ZZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
12036         LDKCVec_CVec_u8ZZ _res_constr;
12037         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
12038         if (_res_constr.datalen > 0)
12039                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
12040         else
12041                 _res_constr.data = NULL;
12042         for (size_t i = 0; i < _res_constr.datalen; i++) {
12043                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
12044                 LDKCVec_u8Z _res_conv_8_ref;
12045                 _res_conv_8_ref.datalen = (*env)->GetArrayLength(env, _res_conv_8);
12046                 _res_conv_8_ref.data = MALLOC(_res_conv_8_ref.datalen, "LDKCVec_u8Z Bytes");
12047                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, _res_conv_8_ref.datalen, _res_conv_8_ref.data);
12048                 _res_constr.data[i] = _res_conv_8_ref;
12049         }
12050         CVec_CVec_u8ZZ_free(_res_constr);
12051 }
12052
12053 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1ok(JNIEnv *env, jclass clz, jobjectArray o) {
12054         LDKCVec_CVec_u8ZZ o_constr;
12055         o_constr.datalen = (*env)->GetArrayLength(env, o);
12056         if (o_constr.datalen > 0)
12057                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
12058         else
12059                 o_constr.data = NULL;
12060         for (size_t i = 0; i < o_constr.datalen; i++) {
12061                 int8_tArray o_conv_8 = (*env)->GetObjectArrayElement(env, o, i);
12062                 LDKCVec_u8Z o_conv_8_ref;
12063                 o_conv_8_ref.datalen = (*env)->GetArrayLength(env, o_conv_8);
12064                 o_conv_8_ref.data = MALLOC(o_conv_8_ref.datalen, "LDKCVec_u8Z Bytes");
12065                 (*env)->GetByteArrayRegion(env, o_conv_8, 0, o_conv_8_ref.datalen, o_conv_8_ref.data);
12066                 o_constr.data[i] = o_conv_8_ref;
12067         }
12068         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
12069         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_ok(o_constr);
12070         return (uint64_t)ret_conv;
12071 }
12072
12073 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1err(JNIEnv *env, jclass clz) {
12074         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
12075         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_err();
12076         return (uint64_t)ret_conv;
12077 }
12078
12079 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12080         if ((_res & 1) != 0) return;
12081         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12082         CHECK_ACCESS(_res_ptr);
12083         LDKCResult_CVec_CVec_u8ZZNoneZ _res_conv = *(LDKCResult_CVec_CVec_u8ZZNoneZ*)(_res_ptr);
12084         FREE((void*)_res);
12085         CResult_CVec_CVec_u8ZZNoneZ_free(_res_conv);
12086 }
12087
12088 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12089         LDKCResult_CVec_CVec_u8ZZNoneZ* orig_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(orig & ~1);
12090         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
12091         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(orig_conv);
12092         return (uint64_t)ret_conv;
12093 }
12094
12095 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12096         LDKInMemorySigner o_conv;
12097         o_conv.inner = (void*)(o & (~1));
12098         o_conv.is_owned = (o & 1) || (o == 0);
12099         o_conv = InMemorySigner_clone(&o_conv);
12100         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
12101         *ret_conv = CResult_InMemorySignerDecodeErrorZ_ok(o_conv);
12102         return (uint64_t)ret_conv;
12103 }
12104
12105 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_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_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
12111         *ret_conv = CResult_InMemorySignerDecodeErrorZ_err(e_conv);
12112         return (uint64_t)ret_conv;
12113 }
12114
12115 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12116         if ((_res & 1) != 0) return;
12117         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12118         CHECK_ACCESS(_res_ptr);
12119         LDKCResult_InMemorySignerDecodeErrorZ _res_conv = *(LDKCResult_InMemorySignerDecodeErrorZ*)(_res_ptr);
12120         FREE((void*)_res);
12121         CResult_InMemorySignerDecodeErrorZ_free(_res_conv);
12122 }
12123
12124 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12125         LDKCResult_InMemorySignerDecodeErrorZ* orig_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(orig & ~1);
12126         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
12127         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(orig_conv);
12128         return (uint64_t)ret_conv;
12129 }
12130
12131 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TxOutZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
12132         LDKCVec_TxOutZ _res_constr;
12133         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
12134         if (_res_constr.datalen > 0)
12135                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
12136         else
12137                 _res_constr.data = NULL;
12138         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
12139         for (size_t h = 0; h < _res_constr.datalen; h++) {
12140                 int64_t _res_conv_7 = _res_vals[h];
12141                 void* _res_conv_7_ptr = (void*)(((uint64_t)_res_conv_7) & ~1);
12142                 CHECK_ACCESS(_res_conv_7_ptr);
12143                 LDKTxOut _res_conv_7_conv = *(LDKTxOut*)(_res_conv_7_ptr);
12144                 FREE((void*)_res_conv_7);
12145                 _res_constr.data[h] = _res_conv_7_conv;
12146         }
12147         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
12148         CVec_TxOutZ_free(_res_constr);
12149 }
12150
12151 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
12152         LDKTransaction o_ref;
12153         o_ref.datalen = (*env)->GetArrayLength(env, o);
12154         o_ref.data = MALLOC(o_ref.datalen, "LDKTransaction Bytes");
12155         (*env)->GetByteArrayRegion(env, o, 0, o_ref.datalen, o_ref.data);
12156         o_ref.data_is_owned = true;
12157         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
12158         *ret_conv = CResult_TransactionNoneZ_ok(o_ref);
12159         return (uint64_t)ret_conv;
12160 }
12161
12162 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1err(JNIEnv *env, jclass clz) {
12163         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
12164         *ret_conv = CResult_TransactionNoneZ_err();
12165         return (uint64_t)ret_conv;
12166 }
12167
12168 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12169         if ((_res & 1) != 0) return;
12170         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12171         CHECK_ACCESS(_res_ptr);
12172         LDKCResult_TransactionNoneZ _res_conv = *(LDKCResult_TransactionNoneZ*)(_res_ptr);
12173         FREE((void*)_res);
12174         CResult_TransactionNoneZ_free(_res_conv);
12175 }
12176
12177 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12178         LDKCResult_TransactionNoneZ* orig_conv = (LDKCResult_TransactionNoneZ*)(orig & ~1);
12179         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
12180         *ret_conv = CResult_TransactionNoneZ_clone(orig_conv);
12181         return (uint64_t)ret_conv;
12182 }
12183
12184 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12185         LDKC2Tuple_BlockHashChannelMonitorZ* orig_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(orig & ~1);
12186         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
12187         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone(orig_conv);
12188         return ((uint64_t)ret_conv);
12189 }
12190
12191 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
12192         LDKThirtyTwoBytes a_ref;
12193         CHECK((*env)->GetArrayLength(env, a) == 32);
12194         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
12195         LDKChannelMonitor b_conv;
12196         b_conv.inner = (void*)(b & (~1));
12197         b_conv.is_owned = (b & 1) || (b == 0);
12198         b_conv = ChannelMonitor_clone(&b_conv);
12199         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
12200         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_new(a_ref, b_conv);
12201         return ((uint64_t)ret_conv);
12202 }
12203
12204 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12205         if ((_res & 1) != 0) return;
12206         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12207         CHECK_ACCESS(_res_ptr);
12208         LDKC2Tuple_BlockHashChannelMonitorZ _res_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(_res_ptr);
12209         FREE((void*)_res);
12210         C2Tuple_BlockHashChannelMonitorZ_free(_res_conv);
12211 }
12212
12213 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1BlockHashChannelMonitorZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
12214         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ _res_constr;
12215         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
12216         if (_res_constr.datalen > 0)
12217                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Elements");
12218         else
12219                 _res_constr.data = NULL;
12220         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
12221         for (size_t j = 0; j < _res_constr.datalen; j++) {
12222                 int64_t _res_conv_35 = _res_vals[j];
12223                 void* _res_conv_35_ptr = (void*)(((uint64_t)_res_conv_35) & ~1);
12224                 CHECK_ACCESS(_res_conv_35_ptr);
12225                 LDKC2Tuple_BlockHashChannelMonitorZ _res_conv_35_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(_res_conv_35_ptr);
12226                 FREE((void*)_res_conv_35);
12227                 _res_constr.data[j] = _res_conv_35_conv;
12228         }
12229         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
12230         CVec_C2Tuple_BlockHashChannelMonitorZZ_free(_res_constr);
12231 }
12232
12233 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1ok(JNIEnv *env, jclass clz, int64_tArray o) {
12234         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ o_constr;
12235         o_constr.datalen = (*env)->GetArrayLength(env, o);
12236         if (o_constr.datalen > 0)
12237                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Elements");
12238         else
12239                 o_constr.data = NULL;
12240         int64_t* o_vals = (*env)->GetLongArrayElements (env, o, NULL);
12241         for (size_t j = 0; j < o_constr.datalen; j++) {
12242                 int64_t o_conv_35 = o_vals[j];
12243                 void* o_conv_35_ptr = (void*)(((uint64_t)o_conv_35) & ~1);
12244                 CHECK_ACCESS(o_conv_35_ptr);
12245                 LDKC2Tuple_BlockHashChannelMonitorZ o_conv_35_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(o_conv_35_ptr);
12246                 o_conv_35_conv = C2Tuple_BlockHashChannelMonitorZ_clone((LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)o_conv_35) & ~1));
12247                 o_constr.data[j] = o_conv_35_conv;
12248         }
12249         (*env)->ReleaseLongArrayElements(env, o, o_vals, 0);
12250         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
12251         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_ok(o_constr);
12252         return (uint64_t)ret_conv;
12253 }
12254
12255 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
12256         LDKIOError e_conv = LDKIOError_from_java(env, e);
12257         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
12258         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_err(e_conv);
12259         return (uint64_t)ret_conv;
12260 }
12261
12262 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12263         if ((_res & 1) != 0) return;
12264         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12265         CHECK_ACCESS(_res_ptr);
12266         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ _res_conv = *(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(_res_ptr);
12267         FREE((void*)_res);
12268         CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_free(_res_conv);
12269 }
12270
12271 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12272         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* orig_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(orig & ~1);
12273         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
12274         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone(orig_conv);
12275         return (uint64_t)ret_conv;
12276 }
12277
12278 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12279         LDKPaymentId o_conv;
12280         o_conv.inner = (void*)(o & (~1));
12281         o_conv.is_owned = (o & 1) || (o == 0);
12282         o_conv = PaymentId_clone(&o_conv);
12283         LDKCResult_PaymentIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdDecodeErrorZ), "LDKCResult_PaymentIdDecodeErrorZ");
12284         *ret_conv = CResult_PaymentIdDecodeErrorZ_ok(o_conv);
12285         return (uint64_t)ret_conv;
12286 }
12287
12288 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12289         LDKDecodeError e_conv;
12290         e_conv.inner = (void*)(e & (~1));
12291         e_conv.is_owned = (e & 1) || (e == 0);
12292         e_conv = DecodeError_clone(&e_conv);
12293         LDKCResult_PaymentIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdDecodeErrorZ), "LDKCResult_PaymentIdDecodeErrorZ");
12294         *ret_conv = CResult_PaymentIdDecodeErrorZ_err(e_conv);
12295         return (uint64_t)ret_conv;
12296 }
12297
12298 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12299         if ((_res & 1) != 0) return;
12300         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12301         CHECK_ACCESS(_res_ptr);
12302         LDKCResult_PaymentIdDecodeErrorZ _res_conv = *(LDKCResult_PaymentIdDecodeErrorZ*)(_res_ptr);
12303         FREE((void*)_res);
12304         CResult_PaymentIdDecodeErrorZ_free(_res_conv);
12305 }
12306
12307 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12308         LDKCResult_PaymentIdDecodeErrorZ* orig_conv = (LDKCResult_PaymentIdDecodeErrorZ*)(orig & ~1);
12309         LDKCResult_PaymentIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdDecodeErrorZ), "LDKCResult_PaymentIdDecodeErrorZ");
12310         *ret_conv = CResult_PaymentIdDecodeErrorZ_clone(orig_conv);
12311         return (uint64_t)ret_conv;
12312 }
12313
12314 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1some(JNIEnv *env, jclass clz, int16_t o) {
12315         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
12316         *ret_copy = COption_u16Z_some(o);
12317         uint64_t ret_ref = (uint64_t)ret_copy;
12318         return ret_ref;
12319 }
12320
12321 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1none(JNIEnv *env, jclass clz) {
12322         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
12323         *ret_copy = COption_u16Z_none();
12324         uint64_t ret_ref = (uint64_t)ret_copy;
12325         return ret_ref;
12326 }
12327
12328 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
12329         if ((_res & 1) != 0) return;
12330         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12331         CHECK_ACCESS(_res_ptr);
12332         LDKCOption_u16Z _res_conv = *(LDKCOption_u16Z*)(_res_ptr);
12333         FREE((void*)_res);
12334         COption_u16Z_free(_res_conv);
12335 }
12336
12337 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12338         LDKCOption_u16Z* orig_conv = (LDKCOption_u16Z*)orig;
12339         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
12340         *ret_copy = COption_u16Z_clone(orig_conv);
12341         uint64_t ret_ref = (uint64_t)ret_copy;
12342         return ret_ref;
12343 }
12344
12345 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1ok(JNIEnv *env, jclass clz) {
12346         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
12347         *ret_conv = CResult_NoneAPIErrorZ_ok();
12348         return (uint64_t)ret_conv;
12349 }
12350
12351 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12352         void* e_ptr = (void*)(((uint64_t)e) & ~1);
12353         CHECK_ACCESS(e_ptr);
12354         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
12355         e_conv = APIError_clone((LDKAPIError*)(((uint64_t)e) & ~1));
12356         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
12357         *ret_conv = CResult_NoneAPIErrorZ_err(e_conv);
12358         return (uint64_t)ret_conv;
12359 }
12360
12361 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12362         if ((_res & 1) != 0) return;
12363         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12364         CHECK_ACCESS(_res_ptr);
12365         LDKCResult_NoneAPIErrorZ _res_conv = *(LDKCResult_NoneAPIErrorZ*)(_res_ptr);
12366         FREE((void*)_res);
12367         CResult_NoneAPIErrorZ_free(_res_conv);
12368 }
12369
12370 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12371         LDKCResult_NoneAPIErrorZ* orig_conv = (LDKCResult_NoneAPIErrorZ*)(orig & ~1);
12372         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
12373         *ret_conv = CResult_NoneAPIErrorZ_clone(orig_conv);
12374         return (uint64_t)ret_conv;
12375 }
12376
12377 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CResult_1NoneAPIErrorZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
12378         LDKCVec_CResult_NoneAPIErrorZZ _res_constr;
12379         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
12380         if (_res_constr.datalen > 0)
12381                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
12382         else
12383                 _res_constr.data = NULL;
12384         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
12385         for (size_t w = 0; w < _res_constr.datalen; w++) {
12386                 int64_t _res_conv_22 = _res_vals[w];
12387                 void* _res_conv_22_ptr = (void*)(((uint64_t)_res_conv_22) & ~1);
12388                 CHECK_ACCESS(_res_conv_22_ptr);
12389                 LDKCResult_NoneAPIErrorZ _res_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(_res_conv_22_ptr);
12390                 FREE((void*)_res_conv_22);
12391                 _res_constr.data[w] = _res_conv_22_conv;
12392         }
12393         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
12394         CVec_CResult_NoneAPIErrorZZ_free(_res_constr);
12395 }
12396
12397 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1APIErrorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
12398         LDKCVec_APIErrorZ _res_constr;
12399         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
12400         if (_res_constr.datalen > 0)
12401                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
12402         else
12403                 _res_constr.data = NULL;
12404         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
12405         for (size_t k = 0; k < _res_constr.datalen; k++) {
12406                 int64_t _res_conv_10 = _res_vals[k];
12407                 void* _res_conv_10_ptr = (void*)(((uint64_t)_res_conv_10) & ~1);
12408                 CHECK_ACCESS(_res_conv_10_ptr);
12409                 LDKAPIError _res_conv_10_conv = *(LDKAPIError*)(_res_conv_10_ptr);
12410                 FREE((void*)_res_conv_10);
12411                 _res_constr.data[k] = _res_conv_10_conv;
12412         }
12413         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
12414         CVec_APIErrorZ_free(_res_constr);
12415 }
12416
12417 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
12418         LDKThirtyTwoBytes o_ref;
12419         CHECK((*env)->GetArrayLength(env, o) == 32);
12420         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
12421         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
12422         *ret_conv = CResult__u832APIErrorZ_ok(o_ref);
12423         return (uint64_t)ret_conv;
12424 }
12425
12426 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12427         void* e_ptr = (void*)(((uint64_t)e) & ~1);
12428         CHECK_ACCESS(e_ptr);
12429         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
12430         e_conv = APIError_clone((LDKAPIError*)(((uint64_t)e) & ~1));
12431         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
12432         *ret_conv = CResult__u832APIErrorZ_err(e_conv);
12433         return (uint64_t)ret_conv;
12434 }
12435
12436 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12437         if ((_res & 1) != 0) return;
12438         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12439         CHECK_ACCESS(_res_ptr);
12440         LDKCResult__u832APIErrorZ _res_conv = *(LDKCResult__u832APIErrorZ*)(_res_ptr);
12441         FREE((void*)_res);
12442         CResult__u832APIErrorZ_free(_res_conv);
12443 }
12444
12445 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12446         LDKCResult__u832APIErrorZ* orig_conv = (LDKCResult__u832APIErrorZ*)(orig & ~1);
12447         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
12448         *ret_conv = CResult__u832APIErrorZ_clone(orig_conv);
12449         return (uint64_t)ret_conv;
12450 }
12451
12452 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12453         LDKPaymentId o_conv;
12454         o_conv.inner = (void*)(o & (~1));
12455         o_conv.is_owned = (o & 1) || (o == 0);
12456         o_conv = PaymentId_clone(&o_conv);
12457         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
12458         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_ok(o_conv);
12459         return (uint64_t)ret_conv;
12460 }
12461
12462 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12463         void* e_ptr = (void*)(((uint64_t)e) & ~1);
12464         CHECK_ACCESS(e_ptr);
12465         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
12466         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uint64_t)e) & ~1));
12467         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
12468         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_err(e_conv);
12469         return (uint64_t)ret_conv;
12470 }
12471
12472 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12473         if ((_res & 1) != 0) return;
12474         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12475         CHECK_ACCESS(_res_ptr);
12476         LDKCResult_PaymentIdPaymentSendFailureZ _res_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(_res_ptr);
12477         FREE((void*)_res);
12478         CResult_PaymentIdPaymentSendFailureZ_free(_res_conv);
12479 }
12480
12481 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12482         LDKCResult_PaymentIdPaymentSendFailureZ* orig_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(orig & ~1);
12483         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
12484         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_clone(orig_conv);
12485         return (uint64_t)ret_conv;
12486 }
12487
12488 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1ok(JNIEnv *env, jclass clz) {
12489         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
12490         *ret_conv = CResult_NonePaymentSendFailureZ_ok();
12491         return (uint64_t)ret_conv;
12492 }
12493
12494 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12495         void* e_ptr = (void*)(((uint64_t)e) & ~1);
12496         CHECK_ACCESS(e_ptr);
12497         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
12498         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uint64_t)e) & ~1));
12499         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
12500         *ret_conv = CResult_NonePaymentSendFailureZ_err(e_conv);
12501         return (uint64_t)ret_conv;
12502 }
12503
12504 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12505         if ((_res & 1) != 0) return;
12506         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12507         CHECK_ACCESS(_res_ptr);
12508         LDKCResult_NonePaymentSendFailureZ _res_conv = *(LDKCResult_NonePaymentSendFailureZ*)(_res_ptr);
12509         FREE((void*)_res);
12510         CResult_NonePaymentSendFailureZ_free(_res_conv);
12511 }
12512
12513 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12514         LDKCResult_NonePaymentSendFailureZ* orig_conv = (LDKCResult_NonePaymentSendFailureZ*)(orig & ~1);
12515         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
12516         *ret_conv = CResult_NonePaymentSendFailureZ_clone(orig_conv);
12517         return (uint64_t)ret_conv;
12518 }
12519
12520 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12521         LDKC2Tuple_PaymentHashPaymentIdZ* orig_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(orig & ~1);
12522         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
12523         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone(orig_conv);
12524         return ((uint64_t)ret_conv);
12525 }
12526
12527 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
12528         LDKThirtyTwoBytes a_ref;
12529         CHECK((*env)->GetArrayLength(env, a) == 32);
12530         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
12531         LDKPaymentId b_conv;
12532         b_conv.inner = (void*)(b & (~1));
12533         b_conv.is_owned = (b & 1) || (b == 0);
12534         b_conv = PaymentId_clone(&b_conv);
12535         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
12536         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_new(a_ref, b_conv);
12537         return ((uint64_t)ret_conv);
12538 }
12539
12540 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12541         if ((_res & 1) != 0) return;
12542         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12543         CHECK_ACCESS(_res_ptr);
12544         LDKC2Tuple_PaymentHashPaymentIdZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentIdZ*)(_res_ptr);
12545         FREE((void*)_res);
12546         C2Tuple_PaymentHashPaymentIdZ_free(_res_conv);
12547 }
12548
12549 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12550         void* o_ptr = (void*)(((uint64_t)o) & ~1);
12551         CHECK_ACCESS(o_ptr);
12552         LDKC2Tuple_PaymentHashPaymentIdZ o_conv = *(LDKC2Tuple_PaymentHashPaymentIdZ*)(o_ptr);
12553         o_conv = C2Tuple_PaymentHashPaymentIdZ_clone((LDKC2Tuple_PaymentHashPaymentIdZ*)(((uint64_t)o) & ~1));
12554         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
12555         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_ok(o_conv);
12556         return (uint64_t)ret_conv;
12557 }
12558
12559 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12560         void* e_ptr = (void*)(((uint64_t)e) & ~1);
12561         CHECK_ACCESS(e_ptr);
12562         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
12563         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uint64_t)e) & ~1));
12564         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
12565         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_err(e_conv);
12566         return (uint64_t)ret_conv;
12567 }
12568
12569 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12570         if ((_res & 1) != 0) return;
12571         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12572         CHECK_ACCESS(_res_ptr);
12573         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(_res_ptr);
12574         FREE((void*)_res);
12575         CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_free(_res_conv);
12576 }
12577
12578 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12579         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(orig & ~1);
12580         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
12581         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(orig_conv);
12582         return (uint64_t)ret_conv;
12583 }
12584
12585 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1NetAddressZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
12586         LDKCVec_NetAddressZ _res_constr;
12587         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
12588         if (_res_constr.datalen > 0)
12589                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
12590         else
12591                 _res_constr.data = NULL;
12592         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
12593         for (size_t m = 0; m < _res_constr.datalen; m++) {
12594                 int64_t _res_conv_12 = _res_vals[m];
12595                 void* _res_conv_12_ptr = (void*)(((uint64_t)_res_conv_12) & ~1);
12596                 CHECK_ACCESS(_res_conv_12_ptr);
12597                 LDKNetAddress _res_conv_12_conv = *(LDKNetAddress*)(_res_conv_12_ptr);
12598                 FREE((void*)_res_conv_12);
12599                 _res_constr.data[m] = _res_conv_12_conv;
12600         }
12601         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
12602         CVec_NetAddressZ_free(_res_constr);
12603 }
12604
12605 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12606         LDKC2Tuple_PaymentHashPaymentSecretZ* orig_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(orig & ~1);
12607         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
12608         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone(orig_conv);
12609         return ((uint64_t)ret_conv);
12610 }
12611
12612 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int8_tArray b) {
12613         LDKThirtyTwoBytes a_ref;
12614         CHECK((*env)->GetArrayLength(env, a) == 32);
12615         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
12616         LDKThirtyTwoBytes b_ref;
12617         CHECK((*env)->GetArrayLength(env, b) == 32);
12618         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
12619         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
12620         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_new(a_ref, b_ref);
12621         return ((uint64_t)ret_conv);
12622 }
12623
12624 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12625         if ((_res & 1) != 0) return;
12626         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12627         CHECK_ACCESS(_res_ptr);
12628         LDKC2Tuple_PaymentHashPaymentSecretZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(_res_ptr);
12629         FREE((void*)_res);
12630         C2Tuple_PaymentHashPaymentSecretZ_free(_res_conv);
12631 }
12632
12633 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
12634         LDKThirtyTwoBytes o_ref;
12635         CHECK((*env)->GetArrayLength(env, o) == 32);
12636         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
12637         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
12638         *ret_conv = CResult_PaymentSecretAPIErrorZ_ok(o_ref);
12639         return (uint64_t)ret_conv;
12640 }
12641
12642 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12643         void* e_ptr = (void*)(((uint64_t)e) & ~1);
12644         CHECK_ACCESS(e_ptr);
12645         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
12646         e_conv = APIError_clone((LDKAPIError*)(((uint64_t)e) & ~1));
12647         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
12648         *ret_conv = CResult_PaymentSecretAPIErrorZ_err(e_conv);
12649         return (uint64_t)ret_conv;
12650 }
12651
12652 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12653         if ((_res & 1) != 0) return;
12654         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12655         CHECK_ACCESS(_res_ptr);
12656         LDKCResult_PaymentSecretAPIErrorZ _res_conv = *(LDKCResult_PaymentSecretAPIErrorZ*)(_res_ptr);
12657         FREE((void*)_res);
12658         CResult_PaymentSecretAPIErrorZ_free(_res_conv);
12659 }
12660
12661 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12662         LDKCResult_PaymentSecretAPIErrorZ* orig_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(orig & ~1);
12663         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
12664         *ret_conv = CResult_PaymentSecretAPIErrorZ_clone(orig_conv);
12665         return (uint64_t)ret_conv;
12666 }
12667
12668 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ChannelMonitorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
12669         LDKCVec_ChannelMonitorZ _res_constr;
12670         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
12671         if (_res_constr.datalen > 0)
12672                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
12673         else
12674                 _res_constr.data = NULL;
12675         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
12676         for (size_t q = 0; q < _res_constr.datalen; q++) {
12677                 int64_t _res_conv_16 = _res_vals[q];
12678                 LDKChannelMonitor _res_conv_16_conv;
12679                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
12680                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
12681                 _res_constr.data[q] = _res_conv_16_conv;
12682         }
12683         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
12684         CVec_ChannelMonitorZ_free(_res_constr);
12685 }
12686
12687 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
12688         LDKThirtyTwoBytes a_ref;
12689         CHECK((*env)->GetArrayLength(env, a) == 32);
12690         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
12691         LDKChannelManager b_conv;
12692         b_conv.inner = (void*)(b & (~1));
12693         b_conv.is_owned = (b & 1) || (b == 0);
12694         // Warning: we need a move here but no clone is available for LDKChannelManager
12695         LDKC2Tuple_BlockHashChannelManagerZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
12696         *ret_conv = C2Tuple_BlockHashChannelManagerZ_new(a_ref, b_conv);
12697         return ((uint64_t)ret_conv);
12698 }
12699
12700 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12701         if ((_res & 1) != 0) return;
12702         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12703         CHECK_ACCESS(_res_ptr);
12704         LDKC2Tuple_BlockHashChannelManagerZ _res_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(_res_ptr);
12705         FREE((void*)_res);
12706         C2Tuple_BlockHashChannelManagerZ_free(_res_conv);
12707 }
12708
12709 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12710         void* o_ptr = (void*)(((uint64_t)o) & ~1);
12711         CHECK_ACCESS(o_ptr);
12712         LDKC2Tuple_BlockHashChannelManagerZ o_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(o_ptr);
12713         // Warning: we may need a move here but no clone is available for LDKC2Tuple_BlockHashChannelManagerZ
12714         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
12715         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(o_conv);
12716         return (uint64_t)ret_conv;
12717 }
12718
12719 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12720         LDKDecodeError e_conv;
12721         e_conv.inner = (void*)(e & (~1));
12722         e_conv.is_owned = (e & 1) || (e == 0);
12723         e_conv = DecodeError_clone(&e_conv);
12724         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
12725         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(e_conv);
12726         return (uint64_t)ret_conv;
12727 }
12728
12729 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12730         if ((_res & 1) != 0) return;
12731         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12732         CHECK_ACCESS(_res_ptr);
12733         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(_res_ptr);
12734         FREE((void*)_res);
12735         CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(_res_conv);
12736 }
12737
12738 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12739         LDKChannelConfig o_conv;
12740         o_conv.inner = (void*)(o & (~1));
12741         o_conv.is_owned = (o & 1) || (o == 0);
12742         o_conv = ChannelConfig_clone(&o_conv);
12743         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
12744         *ret_conv = CResult_ChannelConfigDecodeErrorZ_ok(o_conv);
12745         return (uint64_t)ret_conv;
12746 }
12747
12748 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12749         LDKDecodeError e_conv;
12750         e_conv.inner = (void*)(e & (~1));
12751         e_conv.is_owned = (e & 1) || (e == 0);
12752         e_conv = DecodeError_clone(&e_conv);
12753         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
12754         *ret_conv = CResult_ChannelConfigDecodeErrorZ_err(e_conv);
12755         return (uint64_t)ret_conv;
12756 }
12757
12758 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12759         if ((_res & 1) != 0) return;
12760         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12761         CHECK_ACCESS(_res_ptr);
12762         LDKCResult_ChannelConfigDecodeErrorZ _res_conv = *(LDKCResult_ChannelConfigDecodeErrorZ*)(_res_ptr);
12763         FREE((void*)_res);
12764         CResult_ChannelConfigDecodeErrorZ_free(_res_conv);
12765 }
12766
12767 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12768         LDKCResult_ChannelConfigDecodeErrorZ* orig_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(orig & ~1);
12769         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
12770         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(orig_conv);
12771         return (uint64_t)ret_conv;
12772 }
12773
12774 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12775         LDKOutPoint o_conv;
12776         o_conv.inner = (void*)(o & (~1));
12777         o_conv.is_owned = (o & 1) || (o == 0);
12778         o_conv = OutPoint_clone(&o_conv);
12779         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
12780         *ret_conv = CResult_OutPointDecodeErrorZ_ok(o_conv);
12781         return (uint64_t)ret_conv;
12782 }
12783
12784 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12785         LDKDecodeError e_conv;
12786         e_conv.inner = (void*)(e & (~1));
12787         e_conv.is_owned = (e & 1) || (e == 0);
12788         e_conv = DecodeError_clone(&e_conv);
12789         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
12790         *ret_conv = CResult_OutPointDecodeErrorZ_err(e_conv);
12791         return (uint64_t)ret_conv;
12792 }
12793
12794 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12795         if ((_res & 1) != 0) return;
12796         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12797         CHECK_ACCESS(_res_ptr);
12798         LDKCResult_OutPointDecodeErrorZ _res_conv = *(LDKCResult_OutPointDecodeErrorZ*)(_res_ptr);
12799         FREE((void*)_res);
12800         CResult_OutPointDecodeErrorZ_free(_res_conv);
12801 }
12802
12803 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12804         LDKCResult_OutPointDecodeErrorZ* orig_conv = (LDKCResult_OutPointDecodeErrorZ*)(orig & ~1);
12805         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
12806         *ret_conv = CResult_OutPointDecodeErrorZ_clone(orig_conv);
12807         return (uint64_t)ret_conv;
12808 }
12809
12810 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1some(JNIEnv *env, jclass clz, int64_t o) {
12811         void* o_ptr = (void*)(((uint64_t)o) & ~1);
12812         CHECK_ACCESS(o_ptr);
12813         LDKType o_conv = *(LDKType*)(o_ptr);
12814         if (o_conv.free == LDKType_JCalls_free) {
12815                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
12816                 LDKType_JCalls_cloned(&o_conv);
12817         }
12818         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
12819         *ret_copy = COption_TypeZ_some(o_conv);
12820         uint64_t ret_ref = (uint64_t)ret_copy;
12821         return ret_ref;
12822 }
12823
12824 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1none(JNIEnv *env, jclass clz) {
12825         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
12826         *ret_copy = COption_TypeZ_none();
12827         uint64_t ret_ref = (uint64_t)ret_copy;
12828         return ret_ref;
12829 }
12830
12831 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12832         if ((_res & 1) != 0) return;
12833         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12834         CHECK_ACCESS(_res_ptr);
12835         LDKCOption_TypeZ _res_conv = *(LDKCOption_TypeZ*)(_res_ptr);
12836         FREE((void*)_res);
12837         COption_TypeZ_free(_res_conv);
12838 }
12839
12840 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12841         LDKCOption_TypeZ* orig_conv = (LDKCOption_TypeZ*)orig;
12842         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
12843         *ret_copy = COption_TypeZ_clone(orig_conv);
12844         uint64_t ret_ref = (uint64_t)ret_copy;
12845         return ret_ref;
12846 }
12847
12848 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12849         void* o_ptr = (void*)(((uint64_t)o) & ~1);
12850         CHECK_ACCESS(o_ptr);
12851         LDKCOption_TypeZ o_conv = *(LDKCOption_TypeZ*)(o_ptr);
12852         o_conv = COption_TypeZ_clone((LDKCOption_TypeZ*)(((uint64_t)o) & ~1));
12853         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
12854         *ret_conv = CResult_COption_TypeZDecodeErrorZ_ok(o_conv);
12855         return (uint64_t)ret_conv;
12856 }
12857
12858 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12859         LDKDecodeError e_conv;
12860         e_conv.inner = (void*)(e & (~1));
12861         e_conv.is_owned = (e & 1) || (e == 0);
12862         e_conv = DecodeError_clone(&e_conv);
12863         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
12864         *ret_conv = CResult_COption_TypeZDecodeErrorZ_err(e_conv);
12865         return (uint64_t)ret_conv;
12866 }
12867
12868 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12869         if ((_res & 1) != 0) return;
12870         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12871         CHECK_ACCESS(_res_ptr);
12872         LDKCResult_COption_TypeZDecodeErrorZ _res_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(_res_ptr);
12873         FREE((void*)_res);
12874         CResult_COption_TypeZDecodeErrorZ_free(_res_conv);
12875 }
12876
12877 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12878         LDKCResult_COption_TypeZDecodeErrorZ* orig_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(orig & ~1);
12879         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
12880         *ret_conv = CResult_COption_TypeZDecodeErrorZ_clone(orig_conv);
12881         return (uint64_t)ret_conv;
12882 }
12883
12884 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixNoneZ_1ok(JNIEnv *env, jclass clz, jclass o) {
12885         LDKSiPrefix o_conv = LDKSiPrefix_from_java(env, o);
12886         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
12887         *ret_conv = CResult_SiPrefixNoneZ_ok(o_conv);
12888         return (uint64_t)ret_conv;
12889 }
12890
12891 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixNoneZ_1err(JNIEnv *env, jclass clz) {
12892         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
12893         *ret_conv = CResult_SiPrefixNoneZ_err();
12894         return (uint64_t)ret_conv;
12895 }
12896
12897 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12898         if ((_res & 1) != 0) return;
12899         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12900         CHECK_ACCESS(_res_ptr);
12901         LDKCResult_SiPrefixNoneZ _res_conv = *(LDKCResult_SiPrefixNoneZ*)(_res_ptr);
12902         FREE((void*)_res);
12903         CResult_SiPrefixNoneZ_free(_res_conv);
12904 }
12905
12906 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12907         LDKCResult_SiPrefixNoneZ* orig_conv = (LDKCResult_SiPrefixNoneZ*)(orig & ~1);
12908         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
12909         *ret_conv = CResult_SiPrefixNoneZ_clone(orig_conv);
12910         return (uint64_t)ret_conv;
12911 }
12912
12913 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12914         LDKInvoice o_conv;
12915         o_conv.inner = (void*)(o & (~1));
12916         o_conv.is_owned = (o & 1) || (o == 0);
12917         o_conv = Invoice_clone(&o_conv);
12918         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
12919         *ret_conv = CResult_InvoiceNoneZ_ok(o_conv);
12920         return (uint64_t)ret_conv;
12921 }
12922
12923 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceNoneZ_1err(JNIEnv *env, jclass clz) {
12924         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
12925         *ret_conv = CResult_InvoiceNoneZ_err();
12926         return (uint64_t)ret_conv;
12927 }
12928
12929 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12930         if ((_res & 1) != 0) return;
12931         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12932         CHECK_ACCESS(_res_ptr);
12933         LDKCResult_InvoiceNoneZ _res_conv = *(LDKCResult_InvoiceNoneZ*)(_res_ptr);
12934         FREE((void*)_res);
12935         CResult_InvoiceNoneZ_free(_res_conv);
12936 }
12937
12938 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12939         LDKCResult_InvoiceNoneZ* orig_conv = (LDKCResult_InvoiceNoneZ*)(orig & ~1);
12940         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
12941         *ret_conv = CResult_InvoiceNoneZ_clone(orig_conv);
12942         return (uint64_t)ret_conv;
12943 }
12944
12945 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12946         LDKSignedRawInvoice o_conv;
12947         o_conv.inner = (void*)(o & (~1));
12948         o_conv.is_owned = (o & 1) || (o == 0);
12949         o_conv = SignedRawInvoice_clone(&o_conv);
12950         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
12951         *ret_conv = CResult_SignedRawInvoiceNoneZ_ok(o_conv);
12952         return (uint64_t)ret_conv;
12953 }
12954
12955 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceNoneZ_1err(JNIEnv *env, jclass clz) {
12956         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
12957         *ret_conv = CResult_SignedRawInvoiceNoneZ_err();
12958         return (uint64_t)ret_conv;
12959 }
12960
12961 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12962         if ((_res & 1) != 0) return;
12963         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12964         CHECK_ACCESS(_res_ptr);
12965         LDKCResult_SignedRawInvoiceNoneZ _res_conv = *(LDKCResult_SignedRawInvoiceNoneZ*)(_res_ptr);
12966         FREE((void*)_res);
12967         CResult_SignedRawInvoiceNoneZ_free(_res_conv);
12968 }
12969
12970 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12971         LDKCResult_SignedRawInvoiceNoneZ* orig_conv = (LDKCResult_SignedRawInvoiceNoneZ*)(orig & ~1);
12972         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
12973         *ret_conv = CResult_SignedRawInvoiceNoneZ_clone(orig_conv);
12974         return (uint64_t)ret_conv;
12975 }
12976
12977 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12978         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* orig_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(orig & ~1);
12979         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
12980         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(orig_conv);
12981         return ((uint64_t)ret_conv);
12982 }
12983
12984 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) {
12985         LDKRawInvoice a_conv;
12986         a_conv.inner = (void*)(a & (~1));
12987         a_conv.is_owned = (a & 1) || (a == 0);
12988         a_conv = RawInvoice_clone(&a_conv);
12989         LDKThirtyTwoBytes b_ref;
12990         CHECK((*env)->GetArrayLength(env, b) == 32);
12991         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
12992         LDKInvoiceSignature c_conv;
12993         c_conv.inner = (void*)(c & (~1));
12994         c_conv.is_owned = (c & 1) || (c == 0);
12995         c_conv = InvoiceSignature_clone(&c_conv);
12996         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
12997         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_new(a_conv, b_ref, c_conv);
12998         return ((uint64_t)ret_conv);
12999 }
13000
13001 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13002         if ((_res & 1) != 0) return;
13003         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13004         CHECK_ACCESS(_res_ptr);
13005         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ _res_conv = *(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(_res_ptr);
13006         FREE((void*)_res);
13007         C3Tuple_RawInvoice_u832InvoiceSignatureZ_free(_res_conv);
13008 }
13009
13010 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13011         LDKPayeePubKey o_conv;
13012         o_conv.inner = (void*)(o & (~1));
13013         o_conv.is_owned = (o & 1) || (o == 0);
13014         o_conv = PayeePubKey_clone(&o_conv);
13015         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
13016         *ret_conv = CResult_PayeePubKeyErrorZ_ok(o_conv);
13017         return (uint64_t)ret_conv;
13018 }
13019
13020 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
13021         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
13022         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
13023         *ret_conv = CResult_PayeePubKeyErrorZ_err(e_conv);
13024         return (uint64_t)ret_conv;
13025 }
13026
13027 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13028         if ((_res & 1) != 0) return;
13029         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13030         CHECK_ACCESS(_res_ptr);
13031         LDKCResult_PayeePubKeyErrorZ _res_conv = *(LDKCResult_PayeePubKeyErrorZ*)(_res_ptr);
13032         FREE((void*)_res);
13033         CResult_PayeePubKeyErrorZ_free(_res_conv);
13034 }
13035
13036 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13037         LDKCResult_PayeePubKeyErrorZ* orig_conv = (LDKCResult_PayeePubKeyErrorZ*)(orig & ~1);
13038         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
13039         *ret_conv = CResult_PayeePubKeyErrorZ_clone(orig_conv);
13040         return (uint64_t)ret_conv;
13041 }
13042
13043 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PrivateRouteZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
13044         LDKCVec_PrivateRouteZ _res_constr;
13045         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
13046         if (_res_constr.datalen > 0)
13047                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPrivateRoute), "LDKCVec_PrivateRouteZ Elements");
13048         else
13049                 _res_constr.data = NULL;
13050         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
13051         for (size_t o = 0; o < _res_constr.datalen; o++) {
13052                 int64_t _res_conv_14 = _res_vals[o];
13053                 LDKPrivateRoute _res_conv_14_conv;
13054                 _res_conv_14_conv.inner = (void*)(_res_conv_14 & (~1));
13055                 _res_conv_14_conv.is_owned = (_res_conv_14 & 1) || (_res_conv_14 == 0);
13056                 _res_constr.data[o] = _res_conv_14_conv;
13057         }
13058         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
13059         CVec_PrivateRouteZ_free(_res_constr);
13060 }
13061
13062 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13063         LDKPositiveTimestamp o_conv;
13064         o_conv.inner = (void*)(o & (~1));
13065         o_conv.is_owned = (o & 1) || (o == 0);
13066         o_conv = PositiveTimestamp_clone(&o_conv);
13067         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
13068         *ret_conv = CResult_PositiveTimestampCreationErrorZ_ok(o_conv);
13069         return (uint64_t)ret_conv;
13070 }
13071
13072 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
13073         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
13074         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
13075         *ret_conv = CResult_PositiveTimestampCreationErrorZ_err(e_conv);
13076         return (uint64_t)ret_conv;
13077 }
13078
13079 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13080         if ((_res & 1) != 0) return;
13081         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13082         CHECK_ACCESS(_res_ptr);
13083         LDKCResult_PositiveTimestampCreationErrorZ _res_conv = *(LDKCResult_PositiveTimestampCreationErrorZ*)(_res_ptr);
13084         FREE((void*)_res);
13085         CResult_PositiveTimestampCreationErrorZ_free(_res_conv);
13086 }
13087
13088 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13089         LDKCResult_PositiveTimestampCreationErrorZ* orig_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(orig & ~1);
13090         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
13091         *ret_conv = CResult_PositiveTimestampCreationErrorZ_clone(orig_conv);
13092         return (uint64_t)ret_conv;
13093 }
13094
13095 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1ok(JNIEnv *env, jclass clz) {
13096         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
13097         *ret_conv = CResult_NoneSemanticErrorZ_ok();
13098         return (uint64_t)ret_conv;
13099 }
13100
13101 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
13102         LDKSemanticError e_conv = LDKSemanticError_from_java(env, e);
13103         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
13104         *ret_conv = CResult_NoneSemanticErrorZ_err(e_conv);
13105         return (uint64_t)ret_conv;
13106 }
13107
13108 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13109         if ((_res & 1) != 0) return;
13110         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13111         CHECK_ACCESS(_res_ptr);
13112         LDKCResult_NoneSemanticErrorZ _res_conv = *(LDKCResult_NoneSemanticErrorZ*)(_res_ptr);
13113         FREE((void*)_res);
13114         CResult_NoneSemanticErrorZ_free(_res_conv);
13115 }
13116
13117 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13118         LDKCResult_NoneSemanticErrorZ* orig_conv = (LDKCResult_NoneSemanticErrorZ*)(orig & ~1);
13119         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
13120         *ret_conv = CResult_NoneSemanticErrorZ_clone(orig_conv);
13121         return (uint64_t)ret_conv;
13122 }
13123
13124 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13125         LDKInvoice o_conv;
13126         o_conv.inner = (void*)(o & (~1));
13127         o_conv.is_owned = (o & 1) || (o == 0);
13128         o_conv = Invoice_clone(&o_conv);
13129         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
13130         *ret_conv = CResult_InvoiceSemanticErrorZ_ok(o_conv);
13131         return (uint64_t)ret_conv;
13132 }
13133
13134 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
13135         LDKSemanticError e_conv = LDKSemanticError_from_java(env, e);
13136         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
13137         *ret_conv = CResult_InvoiceSemanticErrorZ_err(e_conv);
13138         return (uint64_t)ret_conv;
13139 }
13140
13141 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13142         if ((_res & 1) != 0) return;
13143         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13144         CHECK_ACCESS(_res_ptr);
13145         LDKCResult_InvoiceSemanticErrorZ _res_conv = *(LDKCResult_InvoiceSemanticErrorZ*)(_res_ptr);
13146         FREE((void*)_res);
13147         CResult_InvoiceSemanticErrorZ_free(_res_conv);
13148 }
13149
13150 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13151         LDKCResult_InvoiceSemanticErrorZ* orig_conv = (LDKCResult_InvoiceSemanticErrorZ*)(orig & ~1);
13152         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
13153         *ret_conv = CResult_InvoiceSemanticErrorZ_clone(orig_conv);
13154         return (uint64_t)ret_conv;
13155 }
13156
13157 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13158         LDKDescription o_conv;
13159         o_conv.inner = (void*)(o & (~1));
13160         o_conv.is_owned = (o & 1) || (o == 0);
13161         o_conv = Description_clone(&o_conv);
13162         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
13163         *ret_conv = CResult_DescriptionCreationErrorZ_ok(o_conv);
13164         return (uint64_t)ret_conv;
13165 }
13166
13167 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
13168         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
13169         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
13170         *ret_conv = CResult_DescriptionCreationErrorZ_err(e_conv);
13171         return (uint64_t)ret_conv;
13172 }
13173
13174 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13175         if ((_res & 1) != 0) return;
13176         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13177         CHECK_ACCESS(_res_ptr);
13178         LDKCResult_DescriptionCreationErrorZ _res_conv = *(LDKCResult_DescriptionCreationErrorZ*)(_res_ptr);
13179         FREE((void*)_res);
13180         CResult_DescriptionCreationErrorZ_free(_res_conv);
13181 }
13182
13183 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13184         LDKCResult_DescriptionCreationErrorZ* orig_conv = (LDKCResult_DescriptionCreationErrorZ*)(orig & ~1);
13185         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
13186         *ret_conv = CResult_DescriptionCreationErrorZ_clone(orig_conv);
13187         return (uint64_t)ret_conv;
13188 }
13189
13190 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ExpiryTimeCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13191         LDKExpiryTime o_conv;
13192         o_conv.inner = (void*)(o & (~1));
13193         o_conv.is_owned = (o & 1) || (o == 0);
13194         o_conv = ExpiryTime_clone(&o_conv);
13195         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
13196         *ret_conv = CResult_ExpiryTimeCreationErrorZ_ok(o_conv);
13197         return (uint64_t)ret_conv;
13198 }
13199
13200 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ExpiryTimeCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
13201         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
13202         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
13203         *ret_conv = CResult_ExpiryTimeCreationErrorZ_err(e_conv);
13204         return (uint64_t)ret_conv;
13205 }
13206
13207 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ExpiryTimeCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13208         if ((_res & 1) != 0) return;
13209         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13210         CHECK_ACCESS(_res_ptr);
13211         LDKCResult_ExpiryTimeCreationErrorZ _res_conv = *(LDKCResult_ExpiryTimeCreationErrorZ*)(_res_ptr);
13212         FREE((void*)_res);
13213         CResult_ExpiryTimeCreationErrorZ_free(_res_conv);
13214 }
13215
13216 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ExpiryTimeCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13217         LDKCResult_ExpiryTimeCreationErrorZ* orig_conv = (LDKCResult_ExpiryTimeCreationErrorZ*)(orig & ~1);
13218         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
13219         *ret_conv = CResult_ExpiryTimeCreationErrorZ_clone(orig_conv);
13220         return (uint64_t)ret_conv;
13221 }
13222
13223 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13224         LDKPrivateRoute o_conv;
13225         o_conv.inner = (void*)(o & (~1));
13226         o_conv.is_owned = (o & 1) || (o == 0);
13227         o_conv = PrivateRoute_clone(&o_conv);
13228         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
13229         *ret_conv = CResult_PrivateRouteCreationErrorZ_ok(o_conv);
13230         return (uint64_t)ret_conv;
13231 }
13232
13233 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
13234         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
13235         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
13236         *ret_conv = CResult_PrivateRouteCreationErrorZ_err(e_conv);
13237         return (uint64_t)ret_conv;
13238 }
13239
13240 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13241         if ((_res & 1) != 0) return;
13242         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13243         CHECK_ACCESS(_res_ptr);
13244         LDKCResult_PrivateRouteCreationErrorZ _res_conv = *(LDKCResult_PrivateRouteCreationErrorZ*)(_res_ptr);
13245         FREE((void*)_res);
13246         CResult_PrivateRouteCreationErrorZ_free(_res_conv);
13247 }
13248
13249 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13250         LDKCResult_PrivateRouteCreationErrorZ* orig_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(orig & ~1);
13251         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
13252         *ret_conv = CResult_PrivateRouteCreationErrorZ_clone(orig_conv);
13253         return (uint64_t)ret_conv;
13254 }
13255
13256 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1ok(JNIEnv *env, jclass clz, jstring o) {
13257         LDKStr o_conv = java_to_owned_str(env, o);
13258         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
13259         *ret_conv = CResult_StringErrorZ_ok(o_conv);
13260         return (uint64_t)ret_conv;
13261 }
13262
13263 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
13264         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
13265         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
13266         *ret_conv = CResult_StringErrorZ_err(e_conv);
13267         return (uint64_t)ret_conv;
13268 }
13269
13270 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13271         if ((_res & 1) != 0) return;
13272         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13273         CHECK_ACCESS(_res_ptr);
13274         LDKCResult_StringErrorZ _res_conv = *(LDKCResult_StringErrorZ*)(_res_ptr);
13275         FREE((void*)_res);
13276         CResult_StringErrorZ_free(_res_conv);
13277 }
13278
13279 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13280         LDKChannelMonitorUpdate o_conv;
13281         o_conv.inner = (void*)(o & (~1));
13282         o_conv.is_owned = (o & 1) || (o == 0);
13283         o_conv = ChannelMonitorUpdate_clone(&o_conv);
13284         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
13285         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_ok(o_conv);
13286         return (uint64_t)ret_conv;
13287 }
13288
13289 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13290         LDKDecodeError e_conv;
13291         e_conv.inner = (void*)(e & (~1));
13292         e_conv.is_owned = (e & 1) || (e == 0);
13293         e_conv = DecodeError_clone(&e_conv);
13294         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
13295         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_err(e_conv);
13296         return (uint64_t)ret_conv;
13297 }
13298
13299 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13300         if ((_res & 1) != 0) return;
13301         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13302         CHECK_ACCESS(_res_ptr);
13303         LDKCResult_ChannelMonitorUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(_res_ptr);
13304         FREE((void*)_res);
13305         CResult_ChannelMonitorUpdateDecodeErrorZ_free(_res_conv);
13306 }
13307
13308 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13309         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(orig & ~1);
13310         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
13311         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(orig_conv);
13312         return (uint64_t)ret_conv;
13313 }
13314
13315 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13316         LDKHTLCUpdate o_conv;
13317         o_conv.inner = (void*)(o & (~1));
13318         o_conv.is_owned = (o & 1) || (o == 0);
13319         o_conv = HTLCUpdate_clone(&o_conv);
13320         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
13321         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_ok(o_conv);
13322         return (uint64_t)ret_conv;
13323 }
13324
13325 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13326         LDKDecodeError e_conv;
13327         e_conv.inner = (void*)(e & (~1));
13328         e_conv.is_owned = (e & 1) || (e == 0);
13329         e_conv = DecodeError_clone(&e_conv);
13330         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
13331         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_err(e_conv);
13332         return (uint64_t)ret_conv;
13333 }
13334
13335 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13336         if ((_res & 1) != 0) return;
13337         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13338         CHECK_ACCESS(_res_ptr);
13339         LDKCResult_HTLCUpdateDecodeErrorZ _res_conv = *(LDKCResult_HTLCUpdateDecodeErrorZ*)(_res_ptr);
13340         FREE((void*)_res);
13341         CResult_HTLCUpdateDecodeErrorZ_free(_res_conv);
13342 }
13343
13344 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13345         LDKCResult_HTLCUpdateDecodeErrorZ* orig_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(orig & ~1);
13346         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
13347         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(orig_conv);
13348         return (uint64_t)ret_conv;
13349 }
13350
13351 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneMonitorUpdateErrorZ_1ok(JNIEnv *env, jclass clz) {
13352         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
13353         *ret_conv = CResult_NoneMonitorUpdateErrorZ_ok();
13354         return (uint64_t)ret_conv;
13355 }
13356
13357 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneMonitorUpdateErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13358         LDKMonitorUpdateError e_conv;
13359         e_conv.inner = (void*)(e & (~1));
13360         e_conv.is_owned = (e & 1) || (e == 0);
13361         e_conv = MonitorUpdateError_clone(&e_conv);
13362         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
13363         *ret_conv = CResult_NoneMonitorUpdateErrorZ_err(e_conv);
13364         return (uint64_t)ret_conv;
13365 }
13366
13367 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneMonitorUpdateErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13368         if ((_res & 1) != 0) return;
13369         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13370         CHECK_ACCESS(_res_ptr);
13371         LDKCResult_NoneMonitorUpdateErrorZ _res_conv = *(LDKCResult_NoneMonitorUpdateErrorZ*)(_res_ptr);
13372         FREE((void*)_res);
13373         CResult_NoneMonitorUpdateErrorZ_free(_res_conv);
13374 }
13375
13376 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneMonitorUpdateErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13377         LDKCResult_NoneMonitorUpdateErrorZ* orig_conv = (LDKCResult_NoneMonitorUpdateErrorZ*)(orig & ~1);
13378         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
13379         *ret_conv = CResult_NoneMonitorUpdateErrorZ_clone(orig_conv);
13380         return (uint64_t)ret_conv;
13381 }
13382
13383 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13384         LDKC2Tuple_OutPointScriptZ* orig_conv = (LDKC2Tuple_OutPointScriptZ*)(orig & ~1);
13385         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
13386         *ret_conv = C2Tuple_OutPointScriptZ_clone(orig_conv);
13387         return ((uint64_t)ret_conv);
13388 }
13389
13390 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
13391         LDKOutPoint a_conv;
13392         a_conv.inner = (void*)(a & (~1));
13393         a_conv.is_owned = (a & 1) || (a == 0);
13394         a_conv = OutPoint_clone(&a_conv);
13395         LDKCVec_u8Z b_ref;
13396         b_ref.datalen = (*env)->GetArrayLength(env, b);
13397         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
13398         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
13399         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
13400         *ret_conv = C2Tuple_OutPointScriptZ_new(a_conv, b_ref);
13401         return ((uint64_t)ret_conv);
13402 }
13403
13404 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13405         if ((_res & 1) != 0) return;
13406         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13407         CHECK_ACCESS(_res_ptr);
13408         LDKC2Tuple_OutPointScriptZ _res_conv = *(LDKC2Tuple_OutPointScriptZ*)(_res_ptr);
13409         FREE((void*)_res);
13410         C2Tuple_OutPointScriptZ_free(_res_conv);
13411 }
13412
13413 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13414         LDKC2Tuple_u32ScriptZ* orig_conv = (LDKC2Tuple_u32ScriptZ*)(orig & ~1);
13415         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
13416         *ret_conv = C2Tuple_u32ScriptZ_clone(orig_conv);
13417         return ((uint64_t)ret_conv);
13418 }
13419
13420 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1new(JNIEnv *env, jclass clz, int32_t a, int8_tArray b) {
13421         LDKCVec_u8Z b_ref;
13422         b_ref.datalen = (*env)->GetArrayLength(env, b);
13423         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
13424         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
13425         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
13426         *ret_conv = C2Tuple_u32ScriptZ_new(a, b_ref);
13427         return ((uint64_t)ret_conv);
13428 }
13429
13430 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13431         if ((_res & 1) != 0) return;
13432         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13433         CHECK_ACCESS(_res_ptr);
13434         LDKC2Tuple_u32ScriptZ _res_conv = *(LDKC2Tuple_u32ScriptZ*)(_res_ptr);
13435         FREE((void*)_res);
13436         C2Tuple_u32ScriptZ_free(_res_conv);
13437 }
13438
13439 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1u32ScriptZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
13440         LDKCVec_C2Tuple_u32ScriptZZ _res_constr;
13441         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
13442         if (_res_constr.datalen > 0)
13443                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
13444         else
13445                 _res_constr.data = NULL;
13446         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
13447         for (size_t v = 0; v < _res_constr.datalen; v++) {
13448                 int64_t _res_conv_21 = _res_vals[v];
13449                 void* _res_conv_21_ptr = (void*)(((uint64_t)_res_conv_21) & ~1);
13450                 CHECK_ACCESS(_res_conv_21_ptr);
13451                 LDKC2Tuple_u32ScriptZ _res_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(_res_conv_21_ptr);
13452                 FREE((void*)_res_conv_21);
13453                 _res_constr.data[v] = _res_conv_21_conv;
13454         }
13455         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
13456         CVec_C2Tuple_u32ScriptZZ_free(_res_constr);
13457 }
13458
13459 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13460         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(orig & ~1);
13461         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
13462         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(orig_conv);
13463         return ((uint64_t)ret_conv);
13464 }
13465
13466 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
13467         LDKThirtyTwoBytes a_ref;
13468         CHECK((*env)->GetArrayLength(env, a) == 32);
13469         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
13470         LDKCVec_C2Tuple_u32ScriptZZ b_constr;
13471         b_constr.datalen = (*env)->GetArrayLength(env, b);
13472         if (b_constr.datalen > 0)
13473                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
13474         else
13475                 b_constr.data = NULL;
13476         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
13477         for (size_t v = 0; v < b_constr.datalen; v++) {
13478                 int64_t b_conv_21 = b_vals[v];
13479                 void* b_conv_21_ptr = (void*)(((uint64_t)b_conv_21) & ~1);
13480                 CHECK_ACCESS(b_conv_21_ptr);
13481                 LDKC2Tuple_u32ScriptZ b_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(b_conv_21_ptr);
13482                 b_conv_21_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_21) & ~1));
13483                 b_constr.data[v] = b_conv_21_conv;
13484         }
13485         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
13486         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
13487         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(a_ref, b_constr);
13488         return ((uint64_t)ret_conv);
13489 }
13490
13491 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13492         if ((_res & 1) != 0) return;
13493         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13494         CHECK_ACCESS(_res_ptr);
13495         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(_res_ptr);
13496         FREE((void*)_res);
13497         C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(_res_conv);
13498 }
13499
13500 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
13501         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ _res_constr;
13502         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
13503         if (_res_constr.datalen > 0)
13504                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ Elements");
13505         else
13506                 _res_constr.data = NULL;
13507         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
13508         for (size_t o = 0; o < _res_constr.datalen; o++) {
13509                 int64_t _res_conv_40 = _res_vals[o];
13510                 void* _res_conv_40_ptr = (void*)(((uint64_t)_res_conv_40) & ~1);
13511                 CHECK_ACCESS(_res_conv_40_ptr);
13512                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv_40_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(_res_conv_40_ptr);
13513                 FREE((void*)_res_conv_40);
13514                 _res_constr.data[o] = _res_conv_40_conv;
13515         }
13516         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
13517         CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(_res_constr);
13518 }
13519
13520 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1EventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
13521         LDKCVec_EventZ _res_constr;
13522         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
13523         if (_res_constr.datalen > 0)
13524                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKEvent), "LDKCVec_EventZ Elements");
13525         else
13526                 _res_constr.data = NULL;
13527         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
13528         for (size_t h = 0; h < _res_constr.datalen; h++) {
13529                 int64_t _res_conv_7 = _res_vals[h];
13530                 void* _res_conv_7_ptr = (void*)(((uint64_t)_res_conv_7) & ~1);
13531                 CHECK_ACCESS(_res_conv_7_ptr);
13532                 LDKEvent _res_conv_7_conv = *(LDKEvent*)(_res_conv_7_ptr);
13533                 FREE((void*)_res_conv_7);
13534                 _res_constr.data[h] = _res_conv_7_conv;
13535         }
13536         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
13537         CVec_EventZ_free(_res_constr);
13538 }
13539
13540 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TransactionZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
13541         LDKCVec_TransactionZ _res_constr;
13542         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
13543         if (_res_constr.datalen > 0)
13544                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTransaction), "LDKCVec_TransactionZ Elements");
13545         else
13546                 _res_constr.data = NULL;
13547         for (size_t i = 0; i < _res_constr.datalen; i++) {
13548                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
13549                 LDKTransaction _res_conv_8_ref;
13550                 _res_conv_8_ref.datalen = (*env)->GetArrayLength(env, _res_conv_8);
13551                 _res_conv_8_ref.data = MALLOC(_res_conv_8_ref.datalen, "LDKTransaction Bytes");
13552                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, _res_conv_8_ref.datalen, _res_conv_8_ref.data);
13553                 _res_conv_8_ref.data_is_owned = true;
13554                 _res_constr.data[i] = _res_conv_8_ref;
13555         }
13556         CVec_TransactionZ_free(_res_constr);
13557 }
13558
13559 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13560         LDKC2Tuple_u32TxOutZ* orig_conv = (LDKC2Tuple_u32TxOutZ*)(orig & ~1);
13561         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
13562         *ret_conv = C2Tuple_u32TxOutZ_clone(orig_conv);
13563         return ((uint64_t)ret_conv);
13564 }
13565
13566 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1new(JNIEnv *env, jclass clz, int32_t a, int64_t b) {
13567         void* b_ptr = (void*)(((uint64_t)b) & ~1);
13568         CHECK_ACCESS(b_ptr);
13569         LDKTxOut b_conv = *(LDKTxOut*)(b_ptr);
13570         b_conv = TxOut_clone((LDKTxOut*)(((uint64_t)b) & ~1));
13571         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
13572         *ret_conv = C2Tuple_u32TxOutZ_new(a, b_conv);
13573         return ((uint64_t)ret_conv);
13574 }
13575
13576 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13577         if ((_res & 1) != 0) return;
13578         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13579         CHECK_ACCESS(_res_ptr);
13580         LDKC2Tuple_u32TxOutZ _res_conv = *(LDKC2Tuple_u32TxOutZ*)(_res_ptr);
13581         FREE((void*)_res);
13582         C2Tuple_u32TxOutZ_free(_res_conv);
13583 }
13584
13585 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1u32TxOutZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
13586         LDKCVec_C2Tuple_u32TxOutZZ _res_constr;
13587         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
13588         if (_res_constr.datalen > 0)
13589                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
13590         else
13591                 _res_constr.data = NULL;
13592         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
13593         for (size_t u = 0; u < _res_constr.datalen; u++) {
13594                 int64_t _res_conv_20 = _res_vals[u];
13595                 void* _res_conv_20_ptr = (void*)(((uint64_t)_res_conv_20) & ~1);
13596                 CHECK_ACCESS(_res_conv_20_ptr);
13597                 LDKC2Tuple_u32TxOutZ _res_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(_res_conv_20_ptr);
13598                 FREE((void*)_res_conv_20);
13599                 _res_constr.data[u] = _res_conv_20_conv;
13600         }
13601         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
13602         CVec_C2Tuple_u32TxOutZZ_free(_res_constr);
13603 }
13604
13605 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13606         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(orig & ~1);
13607         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
13608         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(orig_conv);
13609         return ((uint64_t)ret_conv);
13610 }
13611
13612 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
13613         LDKThirtyTwoBytes a_ref;
13614         CHECK((*env)->GetArrayLength(env, a) == 32);
13615         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
13616         LDKCVec_C2Tuple_u32TxOutZZ b_constr;
13617         b_constr.datalen = (*env)->GetArrayLength(env, b);
13618         if (b_constr.datalen > 0)
13619                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
13620         else
13621                 b_constr.data = NULL;
13622         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
13623         for (size_t u = 0; u < b_constr.datalen; u++) {
13624                 int64_t b_conv_20 = b_vals[u];
13625                 void* b_conv_20_ptr = (void*)(((uint64_t)b_conv_20) & ~1);
13626                 CHECK_ACCESS(b_conv_20_ptr);
13627                 LDKC2Tuple_u32TxOutZ b_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(b_conv_20_ptr);
13628                 b_conv_20_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_20) & ~1));
13629                 b_constr.data[u] = b_conv_20_conv;
13630         }
13631         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
13632         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
13633         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(a_ref, b_constr);
13634         return ((uint64_t)ret_conv);
13635 }
13636
13637 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13638         if ((_res & 1) != 0) return;
13639         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13640         CHECK_ACCESS(_res_ptr);
13641         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(_res_ptr);
13642         FREE((void*)_res);
13643         C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(_res_conv);
13644 }
13645
13646 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
13647         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ _res_constr;
13648         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
13649         if (_res_constr.datalen > 0)
13650                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Elements");
13651         else
13652                 _res_constr.data = NULL;
13653         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
13654         for (size_t n = 0; n < _res_constr.datalen; n++) {
13655                 int64_t _res_conv_39 = _res_vals[n];
13656                 void* _res_conv_39_ptr = (void*)(((uint64_t)_res_conv_39) & ~1);
13657                 CHECK_ACCESS(_res_conv_39_ptr);
13658                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv_39_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(_res_conv_39_ptr);
13659                 FREE((void*)_res_conv_39);
13660                 _res_constr.data[n] = _res_conv_39_conv;
13661         }
13662         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
13663         CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(_res_constr);
13664 }
13665
13666 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1BalanceZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
13667         LDKCVec_BalanceZ _res_constr;
13668         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
13669         if (_res_constr.datalen > 0)
13670                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKBalance), "LDKCVec_BalanceZ Elements");
13671         else
13672                 _res_constr.data = NULL;
13673         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
13674         for (size_t j = 0; j < _res_constr.datalen; j++) {
13675                 int64_t _res_conv_9 = _res_vals[j];
13676                 void* _res_conv_9_ptr = (void*)(((uint64_t)_res_conv_9) & ~1);
13677                 CHECK_ACCESS(_res_conv_9_ptr);
13678                 LDKBalance _res_conv_9_conv = *(LDKBalance*)(_res_conv_9_ptr);
13679                 FREE((void*)_res_conv_9);
13680                 _res_constr.data[j] = _res_conv_9_conv;
13681         }
13682         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
13683         CVec_BalanceZ_free(_res_constr);
13684 }
13685
13686 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13687         void* o_ptr = (void*)(((uint64_t)o) & ~1);
13688         CHECK_ACCESS(o_ptr);
13689         LDKC2Tuple_BlockHashChannelMonitorZ o_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(o_ptr);
13690         o_conv = C2Tuple_BlockHashChannelMonitorZ_clone((LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)o) & ~1));
13691         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
13692         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(o_conv);
13693         return (uint64_t)ret_conv;
13694 }
13695
13696 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13697         LDKDecodeError e_conv;
13698         e_conv.inner = (void*)(e & (~1));
13699         e_conv.is_owned = (e & 1) || (e == 0);
13700         e_conv = DecodeError_clone(&e_conv);
13701         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
13702         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(e_conv);
13703         return (uint64_t)ret_conv;
13704 }
13705
13706 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13707         if ((_res & 1) != 0) return;
13708         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13709         CHECK_ACCESS(_res_ptr);
13710         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(_res_ptr);
13711         FREE((void*)_res);
13712         CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(_res_conv);
13713 }
13714
13715 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13716         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* orig_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(orig & ~1);
13717         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
13718         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone(orig_conv);
13719         return (uint64_t)ret_conv;
13720 }
13721
13722 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1ok(JNIEnv *env, jclass clz) {
13723         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
13724         *ret_conv = CResult_NoneLightningErrorZ_ok();
13725         return (uint64_t)ret_conv;
13726 }
13727
13728 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13729         LDKLightningError e_conv;
13730         e_conv.inner = (void*)(e & (~1));
13731         e_conv.is_owned = (e & 1) || (e == 0);
13732         e_conv = LightningError_clone(&e_conv);
13733         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
13734         *ret_conv = CResult_NoneLightningErrorZ_err(e_conv);
13735         return (uint64_t)ret_conv;
13736 }
13737
13738 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13739         if ((_res & 1) != 0) return;
13740         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13741         CHECK_ACCESS(_res_ptr);
13742         LDKCResult_NoneLightningErrorZ _res_conv = *(LDKCResult_NoneLightningErrorZ*)(_res_ptr);
13743         FREE((void*)_res);
13744         CResult_NoneLightningErrorZ_free(_res_conv);
13745 }
13746
13747 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13748         LDKCResult_NoneLightningErrorZ* orig_conv = (LDKCResult_NoneLightningErrorZ*)(orig & ~1);
13749         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
13750         *ret_conv = CResult_NoneLightningErrorZ_clone(orig_conv);
13751         return (uint64_t)ret_conv;
13752 }
13753
13754 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13755         LDKC2Tuple_PublicKeyTypeZ* orig_conv = (LDKC2Tuple_PublicKeyTypeZ*)(orig & ~1);
13756         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
13757         *ret_conv = C2Tuple_PublicKeyTypeZ_clone(orig_conv);
13758         return ((uint64_t)ret_conv);
13759 }
13760
13761 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
13762         LDKPublicKey a_ref;
13763         CHECK((*env)->GetArrayLength(env, a) == 33);
13764         (*env)->GetByteArrayRegion(env, a, 0, 33, a_ref.compressed_form);
13765         void* b_ptr = (void*)(((uint64_t)b) & ~1);
13766         CHECK_ACCESS(b_ptr);
13767         LDKType b_conv = *(LDKType*)(b_ptr);
13768         if (b_conv.free == LDKType_JCalls_free) {
13769                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
13770                 LDKType_JCalls_cloned(&b_conv);
13771         }
13772         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
13773         *ret_conv = C2Tuple_PublicKeyTypeZ_new(a_ref, b_conv);
13774         return ((uint64_t)ret_conv);
13775 }
13776
13777 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13778         if ((_res & 1) != 0) return;
13779         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13780         CHECK_ACCESS(_res_ptr);
13781         LDKC2Tuple_PublicKeyTypeZ _res_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(_res_ptr);
13782         FREE((void*)_res);
13783         C2Tuple_PublicKeyTypeZ_free(_res_conv);
13784 }
13785
13786 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1PublicKeyTypeZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
13787         LDKCVec_C2Tuple_PublicKeyTypeZZ _res_constr;
13788         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
13789         if (_res_constr.datalen > 0)
13790                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ Elements");
13791         else
13792                 _res_constr.data = NULL;
13793         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
13794         for (size_t z = 0; z < _res_constr.datalen; z++) {
13795                 int64_t _res_conv_25 = _res_vals[z];
13796                 void* _res_conv_25_ptr = (void*)(((uint64_t)_res_conv_25) & ~1);
13797                 CHECK_ACCESS(_res_conv_25_ptr);
13798                 LDKC2Tuple_PublicKeyTypeZ _res_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(_res_conv_25_ptr);
13799                 FREE((void*)_res_conv_25);
13800                 _res_constr.data[z] = _res_conv_25_conv;
13801         }
13802         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
13803         CVec_C2Tuple_PublicKeyTypeZZ_free(_res_constr);
13804 }
13805
13806 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1ok(JNIEnv *env, jclass clz, jboolean o) {
13807         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
13808         *ret_conv = CResult_boolLightningErrorZ_ok(o);
13809         return (uint64_t)ret_conv;
13810 }
13811
13812 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13813         LDKLightningError e_conv;
13814         e_conv.inner = (void*)(e & (~1));
13815         e_conv.is_owned = (e & 1) || (e == 0);
13816         e_conv = LightningError_clone(&e_conv);
13817         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
13818         *ret_conv = CResult_boolLightningErrorZ_err(e_conv);
13819         return (uint64_t)ret_conv;
13820 }
13821
13822 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13823         if ((_res & 1) != 0) return;
13824         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13825         CHECK_ACCESS(_res_ptr);
13826         LDKCResult_boolLightningErrorZ _res_conv = *(LDKCResult_boolLightningErrorZ*)(_res_ptr);
13827         FREE((void*)_res);
13828         CResult_boolLightningErrorZ_free(_res_conv);
13829 }
13830
13831 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13832         LDKCResult_boolLightningErrorZ* orig_conv = (LDKCResult_boolLightningErrorZ*)(orig & ~1);
13833         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
13834         *ret_conv = CResult_boolLightningErrorZ_clone(orig_conv);
13835         return (uint64_t)ret_conv;
13836 }
13837
13838 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13839         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* orig_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(orig & ~1);
13840         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
13841         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(orig_conv);
13842         return ((uint64_t)ret_conv);
13843 }
13844
13845 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) {
13846         LDKChannelAnnouncement a_conv;
13847         a_conv.inner = (void*)(a & (~1));
13848         a_conv.is_owned = (a & 1) || (a == 0);
13849         a_conv = ChannelAnnouncement_clone(&a_conv);
13850         LDKChannelUpdate b_conv;
13851         b_conv.inner = (void*)(b & (~1));
13852         b_conv.is_owned = (b & 1) || (b == 0);
13853         b_conv = ChannelUpdate_clone(&b_conv);
13854         LDKChannelUpdate c_conv;
13855         c_conv.inner = (void*)(c & (~1));
13856         c_conv.is_owned = (c & 1) || (c == 0);
13857         c_conv = ChannelUpdate_clone(&c_conv);
13858         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
13859         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(a_conv, b_conv, c_conv);
13860         return ((uint64_t)ret_conv);
13861 }
13862
13863 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13864         if ((_res & 1) != 0) return;
13865         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13866         CHECK_ACCESS(_res_ptr);
13867         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(_res_ptr);
13868         FREE((void*)_res);
13869         C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(_res_conv);
13870 }
13871
13872 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
13873         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ _res_constr;
13874         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
13875         if (_res_constr.datalen > 0)
13876                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
13877         else
13878                 _res_constr.data = NULL;
13879         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
13880         for (size_t h = 0; h < _res_constr.datalen; h++) {
13881                 int64_t _res_conv_59 = _res_vals[h];
13882                 void* _res_conv_59_ptr = (void*)(((uint64_t)_res_conv_59) & ~1);
13883                 CHECK_ACCESS(_res_conv_59_ptr);
13884                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv_59_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(_res_conv_59_ptr);
13885                 FREE((void*)_res_conv_59);
13886                 _res_constr.data[h] = _res_conv_59_conv;
13887         }
13888         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
13889         CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(_res_constr);
13890 }
13891
13892 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1NodeAnnouncementZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
13893         LDKCVec_NodeAnnouncementZ _res_constr;
13894         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
13895         if (_res_constr.datalen > 0)
13896                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
13897         else
13898                 _res_constr.data = NULL;
13899         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
13900         for (size_t s = 0; s < _res_constr.datalen; s++) {
13901                 int64_t _res_conv_18 = _res_vals[s];
13902                 LDKNodeAnnouncement _res_conv_18_conv;
13903                 _res_conv_18_conv.inner = (void*)(_res_conv_18 & (~1));
13904                 _res_conv_18_conv.is_owned = (_res_conv_18 & 1) || (_res_conv_18 == 0);
13905                 _res_constr.data[s] = _res_conv_18_conv;
13906         }
13907         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
13908         CVec_NodeAnnouncementZ_free(_res_constr);
13909 }
13910
13911 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PublicKeyZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
13912         LDKCVec_PublicKeyZ _res_constr;
13913         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
13914         if (_res_constr.datalen > 0)
13915                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
13916         else
13917                 _res_constr.data = NULL;
13918         for (size_t i = 0; i < _res_constr.datalen; i++) {
13919                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
13920                 LDKPublicKey _res_conv_8_ref;
13921                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 33);
13922                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 33, _res_conv_8_ref.compressed_form);
13923                 _res_constr.data[i] = _res_conv_8_ref;
13924         }
13925         CVec_PublicKeyZ_free(_res_constr);
13926 }
13927
13928 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
13929         LDKCVec_u8Z o_ref;
13930         o_ref.datalen = (*env)->GetArrayLength(env, o);
13931         o_ref.data = MALLOC(o_ref.datalen, "LDKCVec_u8Z Bytes");
13932         (*env)->GetByteArrayRegion(env, o, 0, o_ref.datalen, o_ref.data);
13933         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
13934         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_ok(o_ref);
13935         return (uint64_t)ret_conv;
13936 }
13937
13938 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13939         LDKPeerHandleError e_conv;
13940         e_conv.inner = (void*)(e & (~1));
13941         e_conv.is_owned = (e & 1) || (e == 0);
13942         e_conv = PeerHandleError_clone(&e_conv);
13943         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
13944         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_err(e_conv);
13945         return (uint64_t)ret_conv;
13946 }
13947
13948 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13949         if ((_res & 1) != 0) return;
13950         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13951         CHECK_ACCESS(_res_ptr);
13952         LDKCResult_CVec_u8ZPeerHandleErrorZ _res_conv = *(LDKCResult_CVec_u8ZPeerHandleErrorZ*)(_res_ptr);
13953         FREE((void*)_res);
13954         CResult_CVec_u8ZPeerHandleErrorZ_free(_res_conv);
13955 }
13956
13957 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13958         LDKCResult_CVec_u8ZPeerHandleErrorZ* orig_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(orig & ~1);
13959         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
13960         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(orig_conv);
13961         return (uint64_t)ret_conv;
13962 }
13963
13964 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1ok(JNIEnv *env, jclass clz) {
13965         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
13966         *ret_conv = CResult_NonePeerHandleErrorZ_ok();
13967         return (uint64_t)ret_conv;
13968 }
13969
13970 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13971         LDKPeerHandleError e_conv;
13972         e_conv.inner = (void*)(e & (~1));
13973         e_conv.is_owned = (e & 1) || (e == 0);
13974         e_conv = PeerHandleError_clone(&e_conv);
13975         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
13976         *ret_conv = CResult_NonePeerHandleErrorZ_err(e_conv);
13977         return (uint64_t)ret_conv;
13978 }
13979
13980 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13981         if ((_res & 1) != 0) return;
13982         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13983         CHECK_ACCESS(_res_ptr);
13984         LDKCResult_NonePeerHandleErrorZ _res_conv = *(LDKCResult_NonePeerHandleErrorZ*)(_res_ptr);
13985         FREE((void*)_res);
13986         CResult_NonePeerHandleErrorZ_free(_res_conv);
13987 }
13988
13989 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13990         LDKCResult_NonePeerHandleErrorZ* orig_conv = (LDKCResult_NonePeerHandleErrorZ*)(orig & ~1);
13991         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
13992         *ret_conv = CResult_NonePeerHandleErrorZ_clone(orig_conv);
13993         return (uint64_t)ret_conv;
13994 }
13995
13996 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1ok(JNIEnv *env, jclass clz, jboolean o) {
13997         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
13998         *ret_conv = CResult_boolPeerHandleErrorZ_ok(o);
13999         return (uint64_t)ret_conv;
14000 }
14001
14002 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14003         LDKPeerHandleError e_conv;
14004         e_conv.inner = (void*)(e & (~1));
14005         e_conv.is_owned = (e & 1) || (e == 0);
14006         e_conv = PeerHandleError_clone(&e_conv);
14007         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
14008         *ret_conv = CResult_boolPeerHandleErrorZ_err(e_conv);
14009         return (uint64_t)ret_conv;
14010 }
14011
14012 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14013         if ((_res & 1) != 0) return;
14014         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14015         CHECK_ACCESS(_res_ptr);
14016         LDKCResult_boolPeerHandleErrorZ _res_conv = *(LDKCResult_boolPeerHandleErrorZ*)(_res_ptr);
14017         FREE((void*)_res);
14018         CResult_boolPeerHandleErrorZ_free(_res_conv);
14019 }
14020
14021 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14022         LDKCResult_boolPeerHandleErrorZ* orig_conv = (LDKCResult_boolPeerHandleErrorZ*)(orig & ~1);
14023         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
14024         *ret_conv = CResult_boolPeerHandleErrorZ_clone(orig_conv);
14025         return (uint64_t)ret_conv;
14026 }
14027
14028 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14029         LDKNodeId o_conv;
14030         o_conv.inner = (void*)(o & (~1));
14031         o_conv.is_owned = (o & 1) || (o == 0);
14032         o_conv = NodeId_clone(&o_conv);
14033         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
14034         *ret_conv = CResult_NodeIdDecodeErrorZ_ok(o_conv);
14035         return (uint64_t)ret_conv;
14036 }
14037
14038 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14039         LDKDecodeError e_conv;
14040         e_conv.inner = (void*)(e & (~1));
14041         e_conv.is_owned = (e & 1) || (e == 0);
14042         e_conv = DecodeError_clone(&e_conv);
14043         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
14044         *ret_conv = CResult_NodeIdDecodeErrorZ_err(e_conv);
14045         return (uint64_t)ret_conv;
14046 }
14047
14048 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14049         if ((_res & 1) != 0) return;
14050         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14051         CHECK_ACCESS(_res_ptr);
14052         LDKCResult_NodeIdDecodeErrorZ _res_conv = *(LDKCResult_NodeIdDecodeErrorZ*)(_res_ptr);
14053         FREE((void*)_res);
14054         CResult_NodeIdDecodeErrorZ_free(_res_conv);
14055 }
14056
14057 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14058         LDKCResult_NodeIdDecodeErrorZ* orig_conv = (LDKCResult_NodeIdDecodeErrorZ*)(orig & ~1);
14059         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
14060         *ret_conv = CResult_NodeIdDecodeErrorZ_clone(orig_conv);
14061         return (uint64_t)ret_conv;
14062 }
14063
14064 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1AccessZ_1some(JNIEnv *env, jclass clz, int64_t o) {
14065         void* o_ptr = (void*)(((uint64_t)o) & ~1);
14066         CHECK_ACCESS(o_ptr);
14067         LDKAccess o_conv = *(LDKAccess*)(o_ptr);
14068         if (o_conv.free == LDKAccess_JCalls_free) {
14069                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14070                 LDKAccess_JCalls_cloned(&o_conv);
14071         }
14072         LDKCOption_AccessZ *ret_copy = MALLOC(sizeof(LDKCOption_AccessZ), "LDKCOption_AccessZ");
14073         *ret_copy = COption_AccessZ_some(o_conv);
14074         uint64_t ret_ref = (uint64_t)ret_copy;
14075         return ret_ref;
14076 }
14077
14078 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1AccessZ_1none(JNIEnv *env, jclass clz) {
14079         LDKCOption_AccessZ *ret_copy = MALLOC(sizeof(LDKCOption_AccessZ), "LDKCOption_AccessZ");
14080         *ret_copy = COption_AccessZ_none();
14081         uint64_t ret_ref = (uint64_t)ret_copy;
14082         return ret_ref;
14083 }
14084
14085 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1AccessZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14086         if ((_res & 1) != 0) return;
14087         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14088         CHECK_ACCESS(_res_ptr);
14089         LDKCOption_AccessZ _res_conv = *(LDKCOption_AccessZ*)(_res_ptr);
14090         FREE((void*)_res);
14091         COption_AccessZ_free(_res_conv);
14092 }
14093
14094 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DirectionalChannelInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14095         LDKDirectionalChannelInfo o_conv;
14096         o_conv.inner = (void*)(o & (~1));
14097         o_conv.is_owned = (o & 1) || (o == 0);
14098         o_conv = DirectionalChannelInfo_clone(&o_conv);
14099         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
14100         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_ok(o_conv);
14101         return (uint64_t)ret_conv;
14102 }
14103
14104 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DirectionalChannelInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14105         LDKDecodeError e_conv;
14106         e_conv.inner = (void*)(e & (~1));
14107         e_conv.is_owned = (e & 1) || (e == 0);
14108         e_conv = DecodeError_clone(&e_conv);
14109         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
14110         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_err(e_conv);
14111         return (uint64_t)ret_conv;
14112 }
14113
14114 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1DirectionalChannelInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14115         if ((_res & 1) != 0) return;
14116         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14117         CHECK_ACCESS(_res_ptr);
14118         LDKCResult_DirectionalChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(_res_ptr);
14119         FREE((void*)_res);
14120         CResult_DirectionalChannelInfoDecodeErrorZ_free(_res_conv);
14121 }
14122
14123 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DirectionalChannelInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14124         LDKCResult_DirectionalChannelInfoDecodeErrorZ* orig_conv = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(orig & ~1);
14125         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
14126         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_clone(orig_conv);
14127         return (uint64_t)ret_conv;
14128 }
14129
14130 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14131         LDKChannelInfo o_conv;
14132         o_conv.inner = (void*)(o & (~1));
14133         o_conv.is_owned = (o & 1) || (o == 0);
14134         o_conv = ChannelInfo_clone(&o_conv);
14135         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
14136         *ret_conv = CResult_ChannelInfoDecodeErrorZ_ok(o_conv);
14137         return (uint64_t)ret_conv;
14138 }
14139
14140 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14141         LDKDecodeError e_conv;
14142         e_conv.inner = (void*)(e & (~1));
14143         e_conv.is_owned = (e & 1) || (e == 0);
14144         e_conv = DecodeError_clone(&e_conv);
14145         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
14146         *ret_conv = CResult_ChannelInfoDecodeErrorZ_err(e_conv);
14147         return (uint64_t)ret_conv;
14148 }
14149
14150 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14151         if ((_res & 1) != 0) return;
14152         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14153         CHECK_ACCESS(_res_ptr);
14154         LDKCResult_ChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelInfoDecodeErrorZ*)(_res_ptr);
14155         FREE((void*)_res);
14156         CResult_ChannelInfoDecodeErrorZ_free(_res_conv);
14157 }
14158
14159 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14160         LDKCResult_ChannelInfoDecodeErrorZ* orig_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(orig & ~1);
14161         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
14162         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(orig_conv);
14163         return (uint64_t)ret_conv;
14164 }
14165
14166 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14167         LDKRoutingFees o_conv;
14168         o_conv.inner = (void*)(o & (~1));
14169         o_conv.is_owned = (o & 1) || (o == 0);
14170         o_conv = RoutingFees_clone(&o_conv);
14171         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
14172         *ret_conv = CResult_RoutingFeesDecodeErrorZ_ok(o_conv);
14173         return (uint64_t)ret_conv;
14174 }
14175
14176 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14177         LDKDecodeError e_conv;
14178         e_conv.inner = (void*)(e & (~1));
14179         e_conv.is_owned = (e & 1) || (e == 0);
14180         e_conv = DecodeError_clone(&e_conv);
14181         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
14182         *ret_conv = CResult_RoutingFeesDecodeErrorZ_err(e_conv);
14183         return (uint64_t)ret_conv;
14184 }
14185
14186 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14187         if ((_res & 1) != 0) return;
14188         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14189         CHECK_ACCESS(_res_ptr);
14190         LDKCResult_RoutingFeesDecodeErrorZ _res_conv = *(LDKCResult_RoutingFeesDecodeErrorZ*)(_res_ptr);
14191         FREE((void*)_res);
14192         CResult_RoutingFeesDecodeErrorZ_free(_res_conv);
14193 }
14194
14195 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14196         LDKCResult_RoutingFeesDecodeErrorZ* orig_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(orig & ~1);
14197         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
14198         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(orig_conv);
14199         return (uint64_t)ret_conv;
14200 }
14201
14202 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14203         LDKNodeAnnouncementInfo o_conv;
14204         o_conv.inner = (void*)(o & (~1));
14205         o_conv.is_owned = (o & 1) || (o == 0);
14206         o_conv = NodeAnnouncementInfo_clone(&o_conv);
14207         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
14208         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_ok(o_conv);
14209         return (uint64_t)ret_conv;
14210 }
14211
14212 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14213         LDKDecodeError e_conv;
14214         e_conv.inner = (void*)(e & (~1));
14215         e_conv.is_owned = (e & 1) || (e == 0);
14216         e_conv = DecodeError_clone(&e_conv);
14217         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
14218         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_err(e_conv);
14219         return (uint64_t)ret_conv;
14220 }
14221
14222 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14223         if ((_res & 1) != 0) return;
14224         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14225         CHECK_ACCESS(_res_ptr);
14226         LDKCResult_NodeAnnouncementInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(_res_ptr);
14227         FREE((void*)_res);
14228         CResult_NodeAnnouncementInfoDecodeErrorZ_free(_res_conv);
14229 }
14230
14231 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14232         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(orig & ~1);
14233         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
14234         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(orig_conv);
14235         return (uint64_t)ret_conv;
14236 }
14237
14238 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u64Z_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
14239         LDKCVec_u64Z _res_constr;
14240         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
14241         if (_res_constr.datalen > 0)
14242                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
14243         else
14244                 _res_constr.data = NULL;
14245         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
14246         for (size_t g = 0; g < _res_constr.datalen; g++) {
14247                 int64_t _res_conv_6 = _res_vals[g];
14248                 _res_constr.data[g] = _res_conv_6;
14249         }
14250         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
14251         CVec_u64Z_free(_res_constr);
14252 }
14253
14254 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14255         LDKNodeInfo o_conv;
14256         o_conv.inner = (void*)(o & (~1));
14257         o_conv.is_owned = (o & 1) || (o == 0);
14258         o_conv = NodeInfo_clone(&o_conv);
14259         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
14260         *ret_conv = CResult_NodeInfoDecodeErrorZ_ok(o_conv);
14261         return (uint64_t)ret_conv;
14262 }
14263
14264 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14265         LDKDecodeError e_conv;
14266         e_conv.inner = (void*)(e & (~1));
14267         e_conv.is_owned = (e & 1) || (e == 0);
14268         e_conv = DecodeError_clone(&e_conv);
14269         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
14270         *ret_conv = CResult_NodeInfoDecodeErrorZ_err(e_conv);
14271         return (uint64_t)ret_conv;
14272 }
14273
14274 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14275         if ((_res & 1) != 0) return;
14276         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14277         CHECK_ACCESS(_res_ptr);
14278         LDKCResult_NodeInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeInfoDecodeErrorZ*)(_res_ptr);
14279         FREE((void*)_res);
14280         CResult_NodeInfoDecodeErrorZ_free(_res_conv);
14281 }
14282
14283 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14284         LDKCResult_NodeInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(orig & ~1);
14285         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
14286         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(orig_conv);
14287         return (uint64_t)ret_conv;
14288 }
14289
14290 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14291         LDKNetworkGraph o_conv;
14292         o_conv.inner = (void*)(o & (~1));
14293         o_conv.is_owned = (o & 1) || (o == 0);
14294         o_conv = NetworkGraph_clone(&o_conv);
14295         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
14296         *ret_conv = CResult_NetworkGraphDecodeErrorZ_ok(o_conv);
14297         return (uint64_t)ret_conv;
14298 }
14299
14300 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14301         LDKDecodeError e_conv;
14302         e_conv.inner = (void*)(e & (~1));
14303         e_conv.is_owned = (e & 1) || (e == 0);
14304         e_conv = DecodeError_clone(&e_conv);
14305         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
14306         *ret_conv = CResult_NetworkGraphDecodeErrorZ_err(e_conv);
14307         return (uint64_t)ret_conv;
14308 }
14309
14310 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14311         if ((_res & 1) != 0) return;
14312         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14313         CHECK_ACCESS(_res_ptr);
14314         LDKCResult_NetworkGraphDecodeErrorZ _res_conv = *(LDKCResult_NetworkGraphDecodeErrorZ*)(_res_ptr);
14315         FREE((void*)_res);
14316         CResult_NetworkGraphDecodeErrorZ_free(_res_conv);
14317 }
14318
14319 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14320         LDKCResult_NetworkGraphDecodeErrorZ* orig_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(orig & ~1);
14321         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
14322         *ret_conv = CResult_NetworkGraphDecodeErrorZ_clone(orig_conv);
14323         return (uint64_t)ret_conv;
14324 }
14325
14326 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1some(JNIEnv *env, jclass clz, int64_tArray o) {
14327         LDKCVec_NetAddressZ o_constr;
14328         o_constr.datalen = (*env)->GetArrayLength(env, o);
14329         if (o_constr.datalen > 0)
14330                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
14331         else
14332                 o_constr.data = NULL;
14333         int64_t* o_vals = (*env)->GetLongArrayElements (env, o, NULL);
14334         for (size_t m = 0; m < o_constr.datalen; m++) {
14335                 int64_t o_conv_12 = o_vals[m];
14336                 void* o_conv_12_ptr = (void*)(((uint64_t)o_conv_12) & ~1);
14337                 CHECK_ACCESS(o_conv_12_ptr);
14338                 LDKNetAddress o_conv_12_conv = *(LDKNetAddress*)(o_conv_12_ptr);
14339                 o_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)o_conv_12) & ~1));
14340                 o_constr.data[m] = o_conv_12_conv;
14341         }
14342         (*env)->ReleaseLongArrayElements(env, o, o_vals, 0);
14343         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
14344         *ret_copy = COption_CVec_NetAddressZZ_some(o_constr);
14345         uint64_t ret_ref = (uint64_t)ret_copy;
14346         return ret_ref;
14347 }
14348
14349 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1none(JNIEnv *env, jclass clz) {
14350         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
14351         *ret_copy = COption_CVec_NetAddressZZ_none();
14352         uint64_t ret_ref = (uint64_t)ret_copy;
14353         return ret_ref;
14354 }
14355
14356 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14357         if ((_res & 1) != 0) return;
14358         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14359         CHECK_ACCESS(_res_ptr);
14360         LDKCOption_CVec_NetAddressZZ _res_conv = *(LDKCOption_CVec_NetAddressZZ*)(_res_ptr);
14361         FREE((void*)_res);
14362         COption_CVec_NetAddressZZ_free(_res_conv);
14363 }
14364
14365 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14366         LDKCOption_CVec_NetAddressZZ* orig_conv = (LDKCOption_CVec_NetAddressZZ*)orig;
14367         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
14368         *ret_copy = COption_CVec_NetAddressZZ_clone(orig_conv);
14369         uint64_t ret_ref = (uint64_t)ret_copy;
14370         return ret_ref;
14371 }
14372
14373 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressu8Z_1ok(JNIEnv *env, jclass clz, int64_t o) {
14374         void* o_ptr = (void*)(((uint64_t)o) & ~1);
14375         CHECK_ACCESS(o_ptr);
14376         LDKNetAddress o_conv = *(LDKNetAddress*)(o_ptr);
14377         o_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)o) & ~1));
14378         LDKCResult_NetAddressu8Z* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
14379         *ret_conv = CResult_NetAddressu8Z_ok(o_conv);
14380         return (uint64_t)ret_conv;
14381 }
14382
14383 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressu8Z_1err(JNIEnv *env, jclass clz, int8_t e) {
14384         LDKCResult_NetAddressu8Z* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
14385         *ret_conv = CResult_NetAddressu8Z_err(e);
14386         return (uint64_t)ret_conv;
14387 }
14388
14389 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressu8Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
14390         if ((_res & 1) != 0) return;
14391         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14392         CHECK_ACCESS(_res_ptr);
14393         LDKCResult_NetAddressu8Z _res_conv = *(LDKCResult_NetAddressu8Z*)(_res_ptr);
14394         FREE((void*)_res);
14395         CResult_NetAddressu8Z_free(_res_conv);
14396 }
14397
14398 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressu8Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14399         LDKCResult_NetAddressu8Z* orig_conv = (LDKCResult_NetAddressu8Z*)(orig & ~1);
14400         LDKCResult_NetAddressu8Z* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
14401         *ret_conv = CResult_NetAddressu8Z_clone(orig_conv);
14402         return (uint64_t)ret_conv;
14403 }
14404
14405 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CResult_1NetAddressu8ZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14406         void* o_ptr = (void*)(((uint64_t)o) & ~1);
14407         CHECK_ACCESS(o_ptr);
14408         LDKCResult_NetAddressu8Z o_conv = *(LDKCResult_NetAddressu8Z*)(o_ptr);
14409         o_conv = CResult_NetAddressu8Z_clone((LDKCResult_NetAddressu8Z*)(((uint64_t)o) & ~1));
14410         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
14411         *ret_conv = CResult_CResult_NetAddressu8ZDecodeErrorZ_ok(o_conv);
14412         return (uint64_t)ret_conv;
14413 }
14414
14415 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CResult_1NetAddressu8ZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14416         LDKDecodeError e_conv;
14417         e_conv.inner = (void*)(e & (~1));
14418         e_conv.is_owned = (e & 1) || (e == 0);
14419         e_conv = DecodeError_clone(&e_conv);
14420         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
14421         *ret_conv = CResult_CResult_NetAddressu8ZDecodeErrorZ_err(e_conv);
14422         return (uint64_t)ret_conv;
14423 }
14424
14425 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CResult_1NetAddressu8ZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14426         if ((_res & 1) != 0) return;
14427         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14428         CHECK_ACCESS(_res_ptr);
14429         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ _res_conv = *(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(_res_ptr);
14430         FREE((void*)_res);
14431         CResult_CResult_NetAddressu8ZDecodeErrorZ_free(_res_conv);
14432 }
14433
14434 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CResult_1NetAddressu8ZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14435         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* orig_conv = (LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(orig & ~1);
14436         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
14437         *ret_conv = CResult_CResult_NetAddressu8ZDecodeErrorZ_clone(orig_conv);
14438         return (uint64_t)ret_conv;
14439 }
14440
14441 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14442         void* o_ptr = (void*)(((uint64_t)o) & ~1);
14443         CHECK_ACCESS(o_ptr);
14444         LDKNetAddress o_conv = *(LDKNetAddress*)(o_ptr);
14445         o_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)o) & ~1));
14446         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
14447         *ret_conv = CResult_NetAddressDecodeErrorZ_ok(o_conv);
14448         return (uint64_t)ret_conv;
14449 }
14450
14451 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14452         LDKDecodeError e_conv;
14453         e_conv.inner = (void*)(e & (~1));
14454         e_conv.is_owned = (e & 1) || (e == 0);
14455         e_conv = DecodeError_clone(&e_conv);
14456         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
14457         *ret_conv = CResult_NetAddressDecodeErrorZ_err(e_conv);
14458         return (uint64_t)ret_conv;
14459 }
14460
14461 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14462         if ((_res & 1) != 0) return;
14463         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14464         CHECK_ACCESS(_res_ptr);
14465         LDKCResult_NetAddressDecodeErrorZ _res_conv = *(LDKCResult_NetAddressDecodeErrorZ*)(_res_ptr);
14466         FREE((void*)_res);
14467         CResult_NetAddressDecodeErrorZ_free(_res_conv);
14468 }
14469
14470 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14471         LDKCResult_NetAddressDecodeErrorZ* orig_conv = (LDKCResult_NetAddressDecodeErrorZ*)(orig & ~1);
14472         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
14473         *ret_conv = CResult_NetAddressDecodeErrorZ_clone(orig_conv);
14474         return (uint64_t)ret_conv;
14475 }
14476
14477 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateAddHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
14478         LDKCVec_UpdateAddHTLCZ _res_constr;
14479         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
14480         if (_res_constr.datalen > 0)
14481                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
14482         else
14483                 _res_constr.data = NULL;
14484         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
14485         for (size_t p = 0; p < _res_constr.datalen; p++) {
14486                 int64_t _res_conv_15 = _res_vals[p];
14487                 LDKUpdateAddHTLC _res_conv_15_conv;
14488                 _res_conv_15_conv.inner = (void*)(_res_conv_15 & (~1));
14489                 _res_conv_15_conv.is_owned = (_res_conv_15 & 1) || (_res_conv_15 == 0);
14490                 _res_constr.data[p] = _res_conv_15_conv;
14491         }
14492         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
14493         CVec_UpdateAddHTLCZ_free(_res_constr);
14494 }
14495
14496 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFulfillHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
14497         LDKCVec_UpdateFulfillHTLCZ _res_constr;
14498         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
14499         if (_res_constr.datalen > 0)
14500                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
14501         else
14502                 _res_constr.data = NULL;
14503         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
14504         for (size_t t = 0; t < _res_constr.datalen; t++) {
14505                 int64_t _res_conv_19 = _res_vals[t];
14506                 LDKUpdateFulfillHTLC _res_conv_19_conv;
14507                 _res_conv_19_conv.inner = (void*)(_res_conv_19 & (~1));
14508                 _res_conv_19_conv.is_owned = (_res_conv_19 & 1) || (_res_conv_19 == 0);
14509                 _res_constr.data[t] = _res_conv_19_conv;
14510         }
14511         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
14512         CVec_UpdateFulfillHTLCZ_free(_res_constr);
14513 }
14514
14515 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFailHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
14516         LDKCVec_UpdateFailHTLCZ _res_constr;
14517         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
14518         if (_res_constr.datalen > 0)
14519                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
14520         else
14521                 _res_constr.data = NULL;
14522         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
14523         for (size_t q = 0; q < _res_constr.datalen; q++) {
14524                 int64_t _res_conv_16 = _res_vals[q];
14525                 LDKUpdateFailHTLC _res_conv_16_conv;
14526                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
14527                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
14528                 _res_constr.data[q] = _res_conv_16_conv;
14529         }
14530         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
14531         CVec_UpdateFailHTLCZ_free(_res_constr);
14532 }
14533
14534 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFailMalformedHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
14535         LDKCVec_UpdateFailMalformedHTLCZ _res_constr;
14536         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
14537         if (_res_constr.datalen > 0)
14538                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
14539         else
14540                 _res_constr.data = NULL;
14541         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
14542         for (size_t z = 0; z < _res_constr.datalen; z++) {
14543                 int64_t _res_conv_25 = _res_vals[z];
14544                 LDKUpdateFailMalformedHTLC _res_conv_25_conv;
14545                 _res_conv_25_conv.inner = (void*)(_res_conv_25 & (~1));
14546                 _res_conv_25_conv.is_owned = (_res_conv_25 & 1) || (_res_conv_25 == 0);
14547                 _res_constr.data[z] = _res_conv_25_conv;
14548         }
14549         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
14550         CVec_UpdateFailMalformedHTLCZ_free(_res_constr);
14551 }
14552
14553 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14554         LDKAcceptChannel o_conv;
14555         o_conv.inner = (void*)(o & (~1));
14556         o_conv.is_owned = (o & 1) || (o == 0);
14557         o_conv = AcceptChannel_clone(&o_conv);
14558         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
14559         *ret_conv = CResult_AcceptChannelDecodeErrorZ_ok(o_conv);
14560         return (uint64_t)ret_conv;
14561 }
14562
14563 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14564         LDKDecodeError e_conv;
14565         e_conv.inner = (void*)(e & (~1));
14566         e_conv.is_owned = (e & 1) || (e == 0);
14567         e_conv = DecodeError_clone(&e_conv);
14568         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
14569         *ret_conv = CResult_AcceptChannelDecodeErrorZ_err(e_conv);
14570         return (uint64_t)ret_conv;
14571 }
14572
14573 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14574         if ((_res & 1) != 0) return;
14575         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14576         CHECK_ACCESS(_res_ptr);
14577         LDKCResult_AcceptChannelDecodeErrorZ _res_conv = *(LDKCResult_AcceptChannelDecodeErrorZ*)(_res_ptr);
14578         FREE((void*)_res);
14579         CResult_AcceptChannelDecodeErrorZ_free(_res_conv);
14580 }
14581
14582 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14583         LDKCResult_AcceptChannelDecodeErrorZ* orig_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(orig & ~1);
14584         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
14585         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(orig_conv);
14586         return (uint64_t)ret_conv;
14587 }
14588
14589 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14590         LDKAnnouncementSignatures o_conv;
14591         o_conv.inner = (void*)(o & (~1));
14592         o_conv.is_owned = (o & 1) || (o == 0);
14593         o_conv = AnnouncementSignatures_clone(&o_conv);
14594         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
14595         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_ok(o_conv);
14596         return (uint64_t)ret_conv;
14597 }
14598
14599 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14600         LDKDecodeError e_conv;
14601         e_conv.inner = (void*)(e & (~1));
14602         e_conv.is_owned = (e & 1) || (e == 0);
14603         e_conv = DecodeError_clone(&e_conv);
14604         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
14605         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_err(e_conv);
14606         return (uint64_t)ret_conv;
14607 }
14608
14609 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14610         if ((_res & 1) != 0) return;
14611         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14612         CHECK_ACCESS(_res_ptr);
14613         LDKCResult_AnnouncementSignaturesDecodeErrorZ _res_conv = *(LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(_res_ptr);
14614         FREE((void*)_res);
14615         CResult_AnnouncementSignaturesDecodeErrorZ_free(_res_conv);
14616 }
14617
14618 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14619         LDKCResult_AnnouncementSignaturesDecodeErrorZ* orig_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(orig & ~1);
14620         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
14621         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(orig_conv);
14622         return (uint64_t)ret_conv;
14623 }
14624
14625 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14626         LDKChannelReestablish o_conv;
14627         o_conv.inner = (void*)(o & (~1));
14628         o_conv.is_owned = (o & 1) || (o == 0);
14629         o_conv = ChannelReestablish_clone(&o_conv);
14630         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
14631         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_ok(o_conv);
14632         return (uint64_t)ret_conv;
14633 }
14634
14635 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14636         LDKDecodeError e_conv;
14637         e_conv.inner = (void*)(e & (~1));
14638         e_conv.is_owned = (e & 1) || (e == 0);
14639         e_conv = DecodeError_clone(&e_conv);
14640         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
14641         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_err(e_conv);
14642         return (uint64_t)ret_conv;
14643 }
14644
14645 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14646         if ((_res & 1) != 0) return;
14647         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14648         CHECK_ACCESS(_res_ptr);
14649         LDKCResult_ChannelReestablishDecodeErrorZ _res_conv = *(LDKCResult_ChannelReestablishDecodeErrorZ*)(_res_ptr);
14650         FREE((void*)_res);
14651         CResult_ChannelReestablishDecodeErrorZ_free(_res_conv);
14652 }
14653
14654 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14655         LDKCResult_ChannelReestablishDecodeErrorZ* orig_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(orig & ~1);
14656         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
14657         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(orig_conv);
14658         return (uint64_t)ret_conv;
14659 }
14660
14661 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14662         LDKClosingSigned o_conv;
14663         o_conv.inner = (void*)(o & (~1));
14664         o_conv.is_owned = (o & 1) || (o == 0);
14665         o_conv = ClosingSigned_clone(&o_conv);
14666         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
14667         *ret_conv = CResult_ClosingSignedDecodeErrorZ_ok(o_conv);
14668         return (uint64_t)ret_conv;
14669 }
14670
14671 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14672         LDKDecodeError e_conv;
14673         e_conv.inner = (void*)(e & (~1));
14674         e_conv.is_owned = (e & 1) || (e == 0);
14675         e_conv = DecodeError_clone(&e_conv);
14676         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
14677         *ret_conv = CResult_ClosingSignedDecodeErrorZ_err(e_conv);
14678         return (uint64_t)ret_conv;
14679 }
14680
14681 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14682         if ((_res & 1) != 0) return;
14683         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14684         CHECK_ACCESS(_res_ptr);
14685         LDKCResult_ClosingSignedDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedDecodeErrorZ*)(_res_ptr);
14686         FREE((void*)_res);
14687         CResult_ClosingSignedDecodeErrorZ_free(_res_conv);
14688 }
14689
14690 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14691         LDKCResult_ClosingSignedDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(orig & ~1);
14692         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
14693         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(orig_conv);
14694         return (uint64_t)ret_conv;
14695 }
14696
14697 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14698         LDKClosingSignedFeeRange o_conv;
14699         o_conv.inner = (void*)(o & (~1));
14700         o_conv.is_owned = (o & 1) || (o == 0);
14701         o_conv = ClosingSignedFeeRange_clone(&o_conv);
14702         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
14703         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_ok(o_conv);
14704         return (uint64_t)ret_conv;
14705 }
14706
14707 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14708         LDKDecodeError e_conv;
14709         e_conv.inner = (void*)(e & (~1));
14710         e_conv.is_owned = (e & 1) || (e == 0);
14711         e_conv = DecodeError_clone(&e_conv);
14712         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
14713         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_err(e_conv);
14714         return (uint64_t)ret_conv;
14715 }
14716
14717 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14718         if ((_res & 1) != 0) return;
14719         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14720         CHECK_ACCESS(_res_ptr);
14721         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(_res_ptr);
14722         FREE((void*)_res);
14723         CResult_ClosingSignedFeeRangeDecodeErrorZ_free(_res_conv);
14724 }
14725
14726 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14727         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(orig & ~1);
14728         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
14729         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(orig_conv);
14730         return (uint64_t)ret_conv;
14731 }
14732
14733 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14734         LDKCommitmentSigned o_conv;
14735         o_conv.inner = (void*)(o & (~1));
14736         o_conv.is_owned = (o & 1) || (o == 0);
14737         o_conv = CommitmentSigned_clone(&o_conv);
14738         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
14739         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_ok(o_conv);
14740         return (uint64_t)ret_conv;
14741 }
14742
14743 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14744         LDKDecodeError e_conv;
14745         e_conv.inner = (void*)(e & (~1));
14746         e_conv.is_owned = (e & 1) || (e == 0);
14747         e_conv = DecodeError_clone(&e_conv);
14748         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
14749         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_err(e_conv);
14750         return (uint64_t)ret_conv;
14751 }
14752
14753 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14754         if ((_res & 1) != 0) return;
14755         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14756         CHECK_ACCESS(_res_ptr);
14757         LDKCResult_CommitmentSignedDecodeErrorZ _res_conv = *(LDKCResult_CommitmentSignedDecodeErrorZ*)(_res_ptr);
14758         FREE((void*)_res);
14759         CResult_CommitmentSignedDecodeErrorZ_free(_res_conv);
14760 }
14761
14762 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14763         LDKCResult_CommitmentSignedDecodeErrorZ* orig_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(orig & ~1);
14764         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
14765         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(orig_conv);
14766         return (uint64_t)ret_conv;
14767 }
14768
14769 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14770         LDKFundingCreated o_conv;
14771         o_conv.inner = (void*)(o & (~1));
14772         o_conv.is_owned = (o & 1) || (o == 0);
14773         o_conv = FundingCreated_clone(&o_conv);
14774         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
14775         *ret_conv = CResult_FundingCreatedDecodeErrorZ_ok(o_conv);
14776         return (uint64_t)ret_conv;
14777 }
14778
14779 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14780         LDKDecodeError e_conv;
14781         e_conv.inner = (void*)(e & (~1));
14782         e_conv.is_owned = (e & 1) || (e == 0);
14783         e_conv = DecodeError_clone(&e_conv);
14784         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
14785         *ret_conv = CResult_FundingCreatedDecodeErrorZ_err(e_conv);
14786         return (uint64_t)ret_conv;
14787 }
14788
14789 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14790         if ((_res & 1) != 0) return;
14791         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14792         CHECK_ACCESS(_res_ptr);
14793         LDKCResult_FundingCreatedDecodeErrorZ _res_conv = *(LDKCResult_FundingCreatedDecodeErrorZ*)(_res_ptr);
14794         FREE((void*)_res);
14795         CResult_FundingCreatedDecodeErrorZ_free(_res_conv);
14796 }
14797
14798 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14799         LDKCResult_FundingCreatedDecodeErrorZ* orig_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(orig & ~1);
14800         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
14801         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(orig_conv);
14802         return (uint64_t)ret_conv;
14803 }
14804
14805 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14806         LDKFundingSigned o_conv;
14807         o_conv.inner = (void*)(o & (~1));
14808         o_conv.is_owned = (o & 1) || (o == 0);
14809         o_conv = FundingSigned_clone(&o_conv);
14810         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
14811         *ret_conv = CResult_FundingSignedDecodeErrorZ_ok(o_conv);
14812         return (uint64_t)ret_conv;
14813 }
14814
14815 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14816         LDKDecodeError e_conv;
14817         e_conv.inner = (void*)(e & (~1));
14818         e_conv.is_owned = (e & 1) || (e == 0);
14819         e_conv = DecodeError_clone(&e_conv);
14820         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
14821         *ret_conv = CResult_FundingSignedDecodeErrorZ_err(e_conv);
14822         return (uint64_t)ret_conv;
14823 }
14824
14825 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14826         if ((_res & 1) != 0) return;
14827         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14828         CHECK_ACCESS(_res_ptr);
14829         LDKCResult_FundingSignedDecodeErrorZ _res_conv = *(LDKCResult_FundingSignedDecodeErrorZ*)(_res_ptr);
14830         FREE((void*)_res);
14831         CResult_FundingSignedDecodeErrorZ_free(_res_conv);
14832 }
14833
14834 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14835         LDKCResult_FundingSignedDecodeErrorZ* orig_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(orig & ~1);
14836         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
14837         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(orig_conv);
14838         return (uint64_t)ret_conv;
14839 }
14840
14841 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14842         LDKFundingLocked o_conv;
14843         o_conv.inner = (void*)(o & (~1));
14844         o_conv.is_owned = (o & 1) || (o == 0);
14845         o_conv = FundingLocked_clone(&o_conv);
14846         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
14847         *ret_conv = CResult_FundingLockedDecodeErrorZ_ok(o_conv);
14848         return (uint64_t)ret_conv;
14849 }
14850
14851 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14852         LDKDecodeError e_conv;
14853         e_conv.inner = (void*)(e & (~1));
14854         e_conv.is_owned = (e & 1) || (e == 0);
14855         e_conv = DecodeError_clone(&e_conv);
14856         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
14857         *ret_conv = CResult_FundingLockedDecodeErrorZ_err(e_conv);
14858         return (uint64_t)ret_conv;
14859 }
14860
14861 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14862         if ((_res & 1) != 0) return;
14863         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14864         CHECK_ACCESS(_res_ptr);
14865         LDKCResult_FundingLockedDecodeErrorZ _res_conv = *(LDKCResult_FundingLockedDecodeErrorZ*)(_res_ptr);
14866         FREE((void*)_res);
14867         CResult_FundingLockedDecodeErrorZ_free(_res_conv);
14868 }
14869
14870 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14871         LDKCResult_FundingLockedDecodeErrorZ* orig_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(orig & ~1);
14872         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
14873         *ret_conv = CResult_FundingLockedDecodeErrorZ_clone(orig_conv);
14874         return (uint64_t)ret_conv;
14875 }
14876
14877 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14878         LDKInit o_conv;
14879         o_conv.inner = (void*)(o & (~1));
14880         o_conv.is_owned = (o & 1) || (o == 0);
14881         o_conv = Init_clone(&o_conv);
14882         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
14883         *ret_conv = CResult_InitDecodeErrorZ_ok(o_conv);
14884         return (uint64_t)ret_conv;
14885 }
14886
14887 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14888         LDKDecodeError e_conv;
14889         e_conv.inner = (void*)(e & (~1));
14890         e_conv.is_owned = (e & 1) || (e == 0);
14891         e_conv = DecodeError_clone(&e_conv);
14892         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
14893         *ret_conv = CResult_InitDecodeErrorZ_err(e_conv);
14894         return (uint64_t)ret_conv;
14895 }
14896
14897 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14898         if ((_res & 1) != 0) return;
14899         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14900         CHECK_ACCESS(_res_ptr);
14901         LDKCResult_InitDecodeErrorZ _res_conv = *(LDKCResult_InitDecodeErrorZ*)(_res_ptr);
14902         FREE((void*)_res);
14903         CResult_InitDecodeErrorZ_free(_res_conv);
14904 }
14905
14906 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14907         LDKCResult_InitDecodeErrorZ* orig_conv = (LDKCResult_InitDecodeErrorZ*)(orig & ~1);
14908         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
14909         *ret_conv = CResult_InitDecodeErrorZ_clone(orig_conv);
14910         return (uint64_t)ret_conv;
14911 }
14912
14913 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14914         LDKOpenChannel o_conv;
14915         o_conv.inner = (void*)(o & (~1));
14916         o_conv.is_owned = (o & 1) || (o == 0);
14917         o_conv = OpenChannel_clone(&o_conv);
14918         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
14919         *ret_conv = CResult_OpenChannelDecodeErrorZ_ok(o_conv);
14920         return (uint64_t)ret_conv;
14921 }
14922
14923 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14924         LDKDecodeError e_conv;
14925         e_conv.inner = (void*)(e & (~1));
14926         e_conv.is_owned = (e & 1) || (e == 0);
14927         e_conv = DecodeError_clone(&e_conv);
14928         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
14929         *ret_conv = CResult_OpenChannelDecodeErrorZ_err(e_conv);
14930         return (uint64_t)ret_conv;
14931 }
14932
14933 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14934         if ((_res & 1) != 0) return;
14935         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14936         CHECK_ACCESS(_res_ptr);
14937         LDKCResult_OpenChannelDecodeErrorZ _res_conv = *(LDKCResult_OpenChannelDecodeErrorZ*)(_res_ptr);
14938         FREE((void*)_res);
14939         CResult_OpenChannelDecodeErrorZ_free(_res_conv);
14940 }
14941
14942 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14943         LDKCResult_OpenChannelDecodeErrorZ* orig_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(orig & ~1);
14944         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
14945         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(orig_conv);
14946         return (uint64_t)ret_conv;
14947 }
14948
14949 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14950         LDKRevokeAndACK o_conv;
14951         o_conv.inner = (void*)(o & (~1));
14952         o_conv.is_owned = (o & 1) || (o == 0);
14953         o_conv = RevokeAndACK_clone(&o_conv);
14954         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
14955         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_ok(o_conv);
14956         return (uint64_t)ret_conv;
14957 }
14958
14959 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14960         LDKDecodeError e_conv;
14961         e_conv.inner = (void*)(e & (~1));
14962         e_conv.is_owned = (e & 1) || (e == 0);
14963         e_conv = DecodeError_clone(&e_conv);
14964         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
14965         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_err(e_conv);
14966         return (uint64_t)ret_conv;
14967 }
14968
14969 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14970         if ((_res & 1) != 0) return;
14971         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14972         CHECK_ACCESS(_res_ptr);
14973         LDKCResult_RevokeAndACKDecodeErrorZ _res_conv = *(LDKCResult_RevokeAndACKDecodeErrorZ*)(_res_ptr);
14974         FREE((void*)_res);
14975         CResult_RevokeAndACKDecodeErrorZ_free(_res_conv);
14976 }
14977
14978 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14979         LDKCResult_RevokeAndACKDecodeErrorZ* orig_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(orig & ~1);
14980         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
14981         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(orig_conv);
14982         return (uint64_t)ret_conv;
14983 }
14984
14985 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14986         LDKShutdown o_conv;
14987         o_conv.inner = (void*)(o & (~1));
14988         o_conv.is_owned = (o & 1) || (o == 0);
14989         o_conv = Shutdown_clone(&o_conv);
14990         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
14991         *ret_conv = CResult_ShutdownDecodeErrorZ_ok(o_conv);
14992         return (uint64_t)ret_conv;
14993 }
14994
14995 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14996         LDKDecodeError e_conv;
14997         e_conv.inner = (void*)(e & (~1));
14998         e_conv.is_owned = (e & 1) || (e == 0);
14999         e_conv = DecodeError_clone(&e_conv);
15000         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
15001         *ret_conv = CResult_ShutdownDecodeErrorZ_err(e_conv);
15002         return (uint64_t)ret_conv;
15003 }
15004
15005 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15006         if ((_res & 1) != 0) return;
15007         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15008         CHECK_ACCESS(_res_ptr);
15009         LDKCResult_ShutdownDecodeErrorZ _res_conv = *(LDKCResult_ShutdownDecodeErrorZ*)(_res_ptr);
15010         FREE((void*)_res);
15011         CResult_ShutdownDecodeErrorZ_free(_res_conv);
15012 }
15013
15014 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15015         LDKCResult_ShutdownDecodeErrorZ* orig_conv = (LDKCResult_ShutdownDecodeErrorZ*)(orig & ~1);
15016         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
15017         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(orig_conv);
15018         return (uint64_t)ret_conv;
15019 }
15020
15021 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15022         LDKUpdateFailHTLC o_conv;
15023         o_conv.inner = (void*)(o & (~1));
15024         o_conv.is_owned = (o & 1) || (o == 0);
15025         o_conv = UpdateFailHTLC_clone(&o_conv);
15026         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
15027         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_ok(o_conv);
15028         return (uint64_t)ret_conv;
15029 }
15030
15031 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15032         LDKDecodeError e_conv;
15033         e_conv.inner = (void*)(e & (~1));
15034         e_conv.is_owned = (e & 1) || (e == 0);
15035         e_conv = DecodeError_clone(&e_conv);
15036         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
15037         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_err(e_conv);
15038         return (uint64_t)ret_conv;
15039 }
15040
15041 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15042         if ((_res & 1) != 0) return;
15043         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15044         CHECK_ACCESS(_res_ptr);
15045         LDKCResult_UpdateFailHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailHTLCDecodeErrorZ*)(_res_ptr);
15046         FREE((void*)_res);
15047         CResult_UpdateFailHTLCDecodeErrorZ_free(_res_conv);
15048 }
15049
15050 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15051         LDKCResult_UpdateFailHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(orig & ~1);
15052         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
15053         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(orig_conv);
15054         return (uint64_t)ret_conv;
15055 }
15056
15057 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15058         LDKUpdateFailMalformedHTLC o_conv;
15059         o_conv.inner = (void*)(o & (~1));
15060         o_conv.is_owned = (o & 1) || (o == 0);
15061         o_conv = UpdateFailMalformedHTLC_clone(&o_conv);
15062         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
15063         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(o_conv);
15064         return (uint64_t)ret_conv;
15065 }
15066
15067 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15068         LDKDecodeError e_conv;
15069         e_conv.inner = (void*)(e & (~1));
15070         e_conv.is_owned = (e & 1) || (e == 0);
15071         e_conv = DecodeError_clone(&e_conv);
15072         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
15073         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(e_conv);
15074         return (uint64_t)ret_conv;
15075 }
15076
15077 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15078         if ((_res & 1) != 0) return;
15079         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15080         CHECK_ACCESS(_res_ptr);
15081         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(_res_ptr);
15082         FREE((void*)_res);
15083         CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(_res_conv);
15084 }
15085
15086 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15087         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(orig & ~1);
15088         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
15089         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(orig_conv);
15090         return (uint64_t)ret_conv;
15091 }
15092
15093 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15094         LDKUpdateFee o_conv;
15095         o_conv.inner = (void*)(o & (~1));
15096         o_conv.is_owned = (o & 1) || (o == 0);
15097         o_conv = UpdateFee_clone(&o_conv);
15098         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
15099         *ret_conv = CResult_UpdateFeeDecodeErrorZ_ok(o_conv);
15100         return (uint64_t)ret_conv;
15101 }
15102
15103 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15104         LDKDecodeError e_conv;
15105         e_conv.inner = (void*)(e & (~1));
15106         e_conv.is_owned = (e & 1) || (e == 0);
15107         e_conv = DecodeError_clone(&e_conv);
15108         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
15109         *ret_conv = CResult_UpdateFeeDecodeErrorZ_err(e_conv);
15110         return (uint64_t)ret_conv;
15111 }
15112
15113 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15114         if ((_res & 1) != 0) return;
15115         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15116         CHECK_ACCESS(_res_ptr);
15117         LDKCResult_UpdateFeeDecodeErrorZ _res_conv = *(LDKCResult_UpdateFeeDecodeErrorZ*)(_res_ptr);
15118         FREE((void*)_res);
15119         CResult_UpdateFeeDecodeErrorZ_free(_res_conv);
15120 }
15121
15122 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15123         LDKCResult_UpdateFeeDecodeErrorZ* orig_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(orig & ~1);
15124         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
15125         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(orig_conv);
15126         return (uint64_t)ret_conv;
15127 }
15128
15129 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15130         LDKUpdateFulfillHTLC o_conv;
15131         o_conv.inner = (void*)(o & (~1));
15132         o_conv.is_owned = (o & 1) || (o == 0);
15133         o_conv = UpdateFulfillHTLC_clone(&o_conv);
15134         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
15135         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_ok(o_conv);
15136         return (uint64_t)ret_conv;
15137 }
15138
15139 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15140         LDKDecodeError e_conv;
15141         e_conv.inner = (void*)(e & (~1));
15142         e_conv.is_owned = (e & 1) || (e == 0);
15143         e_conv = DecodeError_clone(&e_conv);
15144         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
15145         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_err(e_conv);
15146         return (uint64_t)ret_conv;
15147 }
15148
15149 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15150         if ((_res & 1) != 0) return;
15151         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15152         CHECK_ACCESS(_res_ptr);
15153         LDKCResult_UpdateFulfillHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(_res_ptr);
15154         FREE((void*)_res);
15155         CResult_UpdateFulfillHTLCDecodeErrorZ_free(_res_conv);
15156 }
15157
15158 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15159         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(orig & ~1);
15160         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
15161         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(orig_conv);
15162         return (uint64_t)ret_conv;
15163 }
15164
15165 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15166         LDKUpdateAddHTLC o_conv;
15167         o_conv.inner = (void*)(o & (~1));
15168         o_conv.is_owned = (o & 1) || (o == 0);
15169         o_conv = UpdateAddHTLC_clone(&o_conv);
15170         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
15171         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_ok(o_conv);
15172         return (uint64_t)ret_conv;
15173 }
15174
15175 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15176         LDKDecodeError e_conv;
15177         e_conv.inner = (void*)(e & (~1));
15178         e_conv.is_owned = (e & 1) || (e == 0);
15179         e_conv = DecodeError_clone(&e_conv);
15180         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
15181         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_err(e_conv);
15182         return (uint64_t)ret_conv;
15183 }
15184
15185 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15186         if ((_res & 1) != 0) return;
15187         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15188         CHECK_ACCESS(_res_ptr);
15189         LDKCResult_UpdateAddHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateAddHTLCDecodeErrorZ*)(_res_ptr);
15190         FREE((void*)_res);
15191         CResult_UpdateAddHTLCDecodeErrorZ_free(_res_conv);
15192 }
15193
15194 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15195         LDKCResult_UpdateAddHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(orig & ~1);
15196         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
15197         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(orig_conv);
15198         return (uint64_t)ret_conv;
15199 }
15200
15201 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15202         LDKPing o_conv;
15203         o_conv.inner = (void*)(o & (~1));
15204         o_conv.is_owned = (o & 1) || (o == 0);
15205         o_conv = Ping_clone(&o_conv);
15206         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
15207         *ret_conv = CResult_PingDecodeErrorZ_ok(o_conv);
15208         return (uint64_t)ret_conv;
15209 }
15210
15211 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15212         LDKDecodeError e_conv;
15213         e_conv.inner = (void*)(e & (~1));
15214         e_conv.is_owned = (e & 1) || (e == 0);
15215         e_conv = DecodeError_clone(&e_conv);
15216         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
15217         *ret_conv = CResult_PingDecodeErrorZ_err(e_conv);
15218         return (uint64_t)ret_conv;
15219 }
15220
15221 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15222         if ((_res & 1) != 0) return;
15223         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15224         CHECK_ACCESS(_res_ptr);
15225         LDKCResult_PingDecodeErrorZ _res_conv = *(LDKCResult_PingDecodeErrorZ*)(_res_ptr);
15226         FREE((void*)_res);
15227         CResult_PingDecodeErrorZ_free(_res_conv);
15228 }
15229
15230 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15231         LDKCResult_PingDecodeErrorZ* orig_conv = (LDKCResult_PingDecodeErrorZ*)(orig & ~1);
15232         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
15233         *ret_conv = CResult_PingDecodeErrorZ_clone(orig_conv);
15234         return (uint64_t)ret_conv;
15235 }
15236
15237 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15238         LDKPong o_conv;
15239         o_conv.inner = (void*)(o & (~1));
15240         o_conv.is_owned = (o & 1) || (o == 0);
15241         o_conv = Pong_clone(&o_conv);
15242         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
15243         *ret_conv = CResult_PongDecodeErrorZ_ok(o_conv);
15244         return (uint64_t)ret_conv;
15245 }
15246
15247 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15248         LDKDecodeError e_conv;
15249         e_conv.inner = (void*)(e & (~1));
15250         e_conv.is_owned = (e & 1) || (e == 0);
15251         e_conv = DecodeError_clone(&e_conv);
15252         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
15253         *ret_conv = CResult_PongDecodeErrorZ_err(e_conv);
15254         return (uint64_t)ret_conv;
15255 }
15256
15257 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15258         if ((_res & 1) != 0) return;
15259         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15260         CHECK_ACCESS(_res_ptr);
15261         LDKCResult_PongDecodeErrorZ _res_conv = *(LDKCResult_PongDecodeErrorZ*)(_res_ptr);
15262         FREE((void*)_res);
15263         CResult_PongDecodeErrorZ_free(_res_conv);
15264 }
15265
15266 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15267         LDKCResult_PongDecodeErrorZ* orig_conv = (LDKCResult_PongDecodeErrorZ*)(orig & ~1);
15268         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
15269         *ret_conv = CResult_PongDecodeErrorZ_clone(orig_conv);
15270         return (uint64_t)ret_conv;
15271 }
15272
15273 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15274         LDKUnsignedChannelAnnouncement o_conv;
15275         o_conv.inner = (void*)(o & (~1));
15276         o_conv.is_owned = (o & 1) || (o == 0);
15277         o_conv = UnsignedChannelAnnouncement_clone(&o_conv);
15278         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
15279         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(o_conv);
15280         return (uint64_t)ret_conv;
15281 }
15282
15283 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15284         LDKDecodeError e_conv;
15285         e_conv.inner = (void*)(e & (~1));
15286         e_conv.is_owned = (e & 1) || (e == 0);
15287         e_conv = DecodeError_clone(&e_conv);
15288         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
15289         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(e_conv);
15290         return (uint64_t)ret_conv;
15291 }
15292
15293 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15294         if ((_res & 1) != 0) return;
15295         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15296         CHECK_ACCESS(_res_ptr);
15297         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(_res_ptr);
15298         FREE((void*)_res);
15299         CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(_res_conv);
15300 }
15301
15302 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15303         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(orig & ~1);
15304         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
15305         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(orig_conv);
15306         return (uint64_t)ret_conv;
15307 }
15308
15309 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15310         LDKChannelAnnouncement o_conv;
15311         o_conv.inner = (void*)(o & (~1));
15312         o_conv.is_owned = (o & 1) || (o == 0);
15313         o_conv = ChannelAnnouncement_clone(&o_conv);
15314         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
15315         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_ok(o_conv);
15316         return (uint64_t)ret_conv;
15317 }
15318
15319 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15320         LDKDecodeError e_conv;
15321         e_conv.inner = (void*)(e & (~1));
15322         e_conv.is_owned = (e & 1) || (e == 0);
15323         e_conv = DecodeError_clone(&e_conv);
15324         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
15325         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_err(e_conv);
15326         return (uint64_t)ret_conv;
15327 }
15328
15329 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15330         if ((_res & 1) != 0) return;
15331         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15332         CHECK_ACCESS(_res_ptr);
15333         LDKCResult_ChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_ChannelAnnouncementDecodeErrorZ*)(_res_ptr);
15334         FREE((void*)_res);
15335         CResult_ChannelAnnouncementDecodeErrorZ_free(_res_conv);
15336 }
15337
15338 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15339         LDKCResult_ChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(orig & ~1);
15340         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
15341         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(orig_conv);
15342         return (uint64_t)ret_conv;
15343 }
15344
15345 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15346         LDKUnsignedChannelUpdate o_conv;
15347         o_conv.inner = (void*)(o & (~1));
15348         o_conv.is_owned = (o & 1) || (o == 0);
15349         o_conv = UnsignedChannelUpdate_clone(&o_conv);
15350         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
15351         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_ok(o_conv);
15352         return (uint64_t)ret_conv;
15353 }
15354
15355 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15356         LDKDecodeError e_conv;
15357         e_conv.inner = (void*)(e & (~1));
15358         e_conv.is_owned = (e & 1) || (e == 0);
15359         e_conv = DecodeError_clone(&e_conv);
15360         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
15361         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_err(e_conv);
15362         return (uint64_t)ret_conv;
15363 }
15364
15365 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15366         if ((_res & 1) != 0) return;
15367         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15368         CHECK_ACCESS(_res_ptr);
15369         LDKCResult_UnsignedChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(_res_ptr);
15370         FREE((void*)_res);
15371         CResult_UnsignedChannelUpdateDecodeErrorZ_free(_res_conv);
15372 }
15373
15374 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15375         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(orig & ~1);
15376         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
15377         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(orig_conv);
15378         return (uint64_t)ret_conv;
15379 }
15380
15381 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15382         LDKChannelUpdate o_conv;
15383         o_conv.inner = (void*)(o & (~1));
15384         o_conv.is_owned = (o & 1) || (o == 0);
15385         o_conv = ChannelUpdate_clone(&o_conv);
15386         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
15387         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_ok(o_conv);
15388         return (uint64_t)ret_conv;
15389 }
15390
15391 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15392         LDKDecodeError e_conv;
15393         e_conv.inner = (void*)(e & (~1));
15394         e_conv.is_owned = (e & 1) || (e == 0);
15395         e_conv = DecodeError_clone(&e_conv);
15396         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
15397         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_err(e_conv);
15398         return (uint64_t)ret_conv;
15399 }
15400
15401 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15402         if ((_res & 1) != 0) return;
15403         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15404         CHECK_ACCESS(_res_ptr);
15405         LDKCResult_ChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateDecodeErrorZ*)(_res_ptr);
15406         FREE((void*)_res);
15407         CResult_ChannelUpdateDecodeErrorZ_free(_res_conv);
15408 }
15409
15410 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15411         LDKCResult_ChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(orig & ~1);
15412         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
15413         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(orig_conv);
15414         return (uint64_t)ret_conv;
15415 }
15416
15417 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15418         LDKErrorMessage o_conv;
15419         o_conv.inner = (void*)(o & (~1));
15420         o_conv.is_owned = (o & 1) || (o == 0);
15421         o_conv = ErrorMessage_clone(&o_conv);
15422         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
15423         *ret_conv = CResult_ErrorMessageDecodeErrorZ_ok(o_conv);
15424         return (uint64_t)ret_conv;
15425 }
15426
15427 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15428         LDKDecodeError e_conv;
15429         e_conv.inner = (void*)(e & (~1));
15430         e_conv.is_owned = (e & 1) || (e == 0);
15431         e_conv = DecodeError_clone(&e_conv);
15432         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
15433         *ret_conv = CResult_ErrorMessageDecodeErrorZ_err(e_conv);
15434         return (uint64_t)ret_conv;
15435 }
15436
15437 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15438         if ((_res & 1) != 0) return;
15439         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15440         CHECK_ACCESS(_res_ptr);
15441         LDKCResult_ErrorMessageDecodeErrorZ _res_conv = *(LDKCResult_ErrorMessageDecodeErrorZ*)(_res_ptr);
15442         FREE((void*)_res);
15443         CResult_ErrorMessageDecodeErrorZ_free(_res_conv);
15444 }
15445
15446 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15447         LDKCResult_ErrorMessageDecodeErrorZ* orig_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(orig & ~1);
15448         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
15449         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(orig_conv);
15450         return (uint64_t)ret_conv;
15451 }
15452
15453 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15454         LDKUnsignedNodeAnnouncement o_conv;
15455         o_conv.inner = (void*)(o & (~1));
15456         o_conv.is_owned = (o & 1) || (o == 0);
15457         o_conv = UnsignedNodeAnnouncement_clone(&o_conv);
15458         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
15459         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(o_conv);
15460         return (uint64_t)ret_conv;
15461 }
15462
15463 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15464         LDKDecodeError e_conv;
15465         e_conv.inner = (void*)(e & (~1));
15466         e_conv.is_owned = (e & 1) || (e == 0);
15467         e_conv = DecodeError_clone(&e_conv);
15468         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
15469         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(e_conv);
15470         return (uint64_t)ret_conv;
15471 }
15472
15473 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15474         if ((_res & 1) != 0) return;
15475         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15476         CHECK_ACCESS(_res_ptr);
15477         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(_res_ptr);
15478         FREE((void*)_res);
15479         CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(_res_conv);
15480 }
15481
15482 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15483         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(orig & ~1);
15484         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
15485         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(orig_conv);
15486         return (uint64_t)ret_conv;
15487 }
15488
15489 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15490         LDKNodeAnnouncement o_conv;
15491         o_conv.inner = (void*)(o & (~1));
15492         o_conv.is_owned = (o & 1) || (o == 0);
15493         o_conv = NodeAnnouncement_clone(&o_conv);
15494         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
15495         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_ok(o_conv);
15496         return (uint64_t)ret_conv;
15497 }
15498
15499 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15500         LDKDecodeError e_conv;
15501         e_conv.inner = (void*)(e & (~1));
15502         e_conv.is_owned = (e & 1) || (e == 0);
15503         e_conv = DecodeError_clone(&e_conv);
15504         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
15505         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_err(e_conv);
15506         return (uint64_t)ret_conv;
15507 }
15508
15509 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15510         if ((_res & 1) != 0) return;
15511         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15512         CHECK_ACCESS(_res_ptr);
15513         LDKCResult_NodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementDecodeErrorZ*)(_res_ptr);
15514         FREE((void*)_res);
15515         CResult_NodeAnnouncementDecodeErrorZ_free(_res_conv);
15516 }
15517
15518 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15519         LDKCResult_NodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(orig & ~1);
15520         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
15521         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(orig_conv);
15522         return (uint64_t)ret_conv;
15523 }
15524
15525 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15526         LDKQueryShortChannelIds o_conv;
15527         o_conv.inner = (void*)(o & (~1));
15528         o_conv.is_owned = (o & 1) || (o == 0);
15529         o_conv = QueryShortChannelIds_clone(&o_conv);
15530         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
15531         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_ok(o_conv);
15532         return (uint64_t)ret_conv;
15533 }
15534
15535 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15536         LDKDecodeError e_conv;
15537         e_conv.inner = (void*)(e & (~1));
15538         e_conv.is_owned = (e & 1) || (e == 0);
15539         e_conv = DecodeError_clone(&e_conv);
15540         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
15541         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_err(e_conv);
15542         return (uint64_t)ret_conv;
15543 }
15544
15545 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15546         if ((_res & 1) != 0) return;
15547         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15548         CHECK_ACCESS(_res_ptr);
15549         LDKCResult_QueryShortChannelIdsDecodeErrorZ _res_conv = *(LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(_res_ptr);
15550         FREE((void*)_res);
15551         CResult_QueryShortChannelIdsDecodeErrorZ_free(_res_conv);
15552 }
15553
15554 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15555         LDKCResult_QueryShortChannelIdsDecodeErrorZ* orig_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(orig & ~1);
15556         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
15557         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(orig_conv);
15558         return (uint64_t)ret_conv;
15559 }
15560
15561 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15562         LDKReplyShortChannelIdsEnd o_conv;
15563         o_conv.inner = (void*)(o & (~1));
15564         o_conv.is_owned = (o & 1) || (o == 0);
15565         o_conv = ReplyShortChannelIdsEnd_clone(&o_conv);
15566         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
15567         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(o_conv);
15568         return (uint64_t)ret_conv;
15569 }
15570
15571 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15572         LDKDecodeError e_conv;
15573         e_conv.inner = (void*)(e & (~1));
15574         e_conv.is_owned = (e & 1) || (e == 0);
15575         e_conv = DecodeError_clone(&e_conv);
15576         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
15577         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(e_conv);
15578         return (uint64_t)ret_conv;
15579 }
15580
15581 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15582         if ((_res & 1) != 0) return;
15583         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15584         CHECK_ACCESS(_res_ptr);
15585         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ _res_conv = *(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(_res_ptr);
15586         FREE((void*)_res);
15587         CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(_res_conv);
15588 }
15589
15590 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15591         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* orig_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(orig & ~1);
15592         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
15593         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(orig_conv);
15594         return (uint64_t)ret_conv;
15595 }
15596
15597 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15598         LDKQueryChannelRange o_conv;
15599         o_conv.inner = (void*)(o & (~1));
15600         o_conv.is_owned = (o & 1) || (o == 0);
15601         o_conv = QueryChannelRange_clone(&o_conv);
15602         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
15603         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_ok(o_conv);
15604         return (uint64_t)ret_conv;
15605 }
15606
15607 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15608         LDKDecodeError e_conv;
15609         e_conv.inner = (void*)(e & (~1));
15610         e_conv.is_owned = (e & 1) || (e == 0);
15611         e_conv = DecodeError_clone(&e_conv);
15612         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
15613         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_err(e_conv);
15614         return (uint64_t)ret_conv;
15615 }
15616
15617 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15618         if ((_res & 1) != 0) return;
15619         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15620         CHECK_ACCESS(_res_ptr);
15621         LDKCResult_QueryChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_QueryChannelRangeDecodeErrorZ*)(_res_ptr);
15622         FREE((void*)_res);
15623         CResult_QueryChannelRangeDecodeErrorZ_free(_res_conv);
15624 }
15625
15626 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15627         LDKCResult_QueryChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(orig & ~1);
15628         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
15629         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(orig_conv);
15630         return (uint64_t)ret_conv;
15631 }
15632
15633 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15634         LDKReplyChannelRange o_conv;
15635         o_conv.inner = (void*)(o & (~1));
15636         o_conv.is_owned = (o & 1) || (o == 0);
15637         o_conv = ReplyChannelRange_clone(&o_conv);
15638         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
15639         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_ok(o_conv);
15640         return (uint64_t)ret_conv;
15641 }
15642
15643 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15644         LDKDecodeError e_conv;
15645         e_conv.inner = (void*)(e & (~1));
15646         e_conv.is_owned = (e & 1) || (e == 0);
15647         e_conv = DecodeError_clone(&e_conv);
15648         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
15649         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_err(e_conv);
15650         return (uint64_t)ret_conv;
15651 }
15652
15653 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15654         if ((_res & 1) != 0) return;
15655         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15656         CHECK_ACCESS(_res_ptr);
15657         LDKCResult_ReplyChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_ReplyChannelRangeDecodeErrorZ*)(_res_ptr);
15658         FREE((void*)_res);
15659         CResult_ReplyChannelRangeDecodeErrorZ_free(_res_conv);
15660 }
15661
15662 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15663         LDKCResult_ReplyChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(orig & ~1);
15664         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
15665         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(orig_conv);
15666         return (uint64_t)ret_conv;
15667 }
15668
15669 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15670         LDKGossipTimestampFilter o_conv;
15671         o_conv.inner = (void*)(o & (~1));
15672         o_conv.is_owned = (o & 1) || (o == 0);
15673         o_conv = GossipTimestampFilter_clone(&o_conv);
15674         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
15675         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_ok(o_conv);
15676         return (uint64_t)ret_conv;
15677 }
15678
15679 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15680         LDKDecodeError e_conv;
15681         e_conv.inner = (void*)(e & (~1));
15682         e_conv.is_owned = (e & 1) || (e == 0);
15683         e_conv = DecodeError_clone(&e_conv);
15684         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
15685         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_err(e_conv);
15686         return (uint64_t)ret_conv;
15687 }
15688
15689 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15690         if ((_res & 1) != 0) return;
15691         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15692         CHECK_ACCESS(_res_ptr);
15693         LDKCResult_GossipTimestampFilterDecodeErrorZ _res_conv = *(LDKCResult_GossipTimestampFilterDecodeErrorZ*)(_res_ptr);
15694         FREE((void*)_res);
15695         CResult_GossipTimestampFilterDecodeErrorZ_free(_res_conv);
15696 }
15697
15698 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15699         LDKCResult_GossipTimestampFilterDecodeErrorZ* orig_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(orig & ~1);
15700         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
15701         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(orig_conv);
15702         return (uint64_t)ret_conv;
15703 }
15704
15705 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15706         LDKInvoice o_conv;
15707         o_conv.inner = (void*)(o & (~1));
15708         o_conv.is_owned = (o & 1) || (o == 0);
15709         o_conv = Invoice_clone(&o_conv);
15710         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
15711         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_ok(o_conv);
15712         return (uint64_t)ret_conv;
15713 }
15714
15715 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15716         void* e_ptr = (void*)(((uint64_t)e) & ~1);
15717         CHECK_ACCESS(e_ptr);
15718         LDKSignOrCreationError e_conv = *(LDKSignOrCreationError*)(e_ptr);
15719         e_conv = SignOrCreationError_clone((LDKSignOrCreationError*)(((uint64_t)e) & ~1));
15720         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
15721         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_err(e_conv);
15722         return (uint64_t)ret_conv;
15723 }
15724
15725 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15726         if ((_res & 1) != 0) return;
15727         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15728         CHECK_ACCESS(_res_ptr);
15729         LDKCResult_InvoiceSignOrCreationErrorZ _res_conv = *(LDKCResult_InvoiceSignOrCreationErrorZ*)(_res_ptr);
15730         FREE((void*)_res);
15731         CResult_InvoiceSignOrCreationErrorZ_free(_res_conv);
15732 }
15733
15734 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15735         LDKCResult_InvoiceSignOrCreationErrorZ* orig_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(orig & ~1);
15736         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
15737         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone(orig_conv);
15738         return (uint64_t)ret_conv;
15739 }
15740
15741 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1FilterZ_1some(JNIEnv *env, jclass clz, int64_t o) {
15742         void* o_ptr = (void*)(((uint64_t)o) & ~1);
15743         CHECK_ACCESS(o_ptr);
15744         LDKFilter o_conv = *(LDKFilter*)(o_ptr);
15745         if (o_conv.free == LDKFilter_JCalls_free) {
15746                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
15747                 LDKFilter_JCalls_cloned(&o_conv);
15748         }
15749         LDKCOption_FilterZ *ret_copy = MALLOC(sizeof(LDKCOption_FilterZ), "LDKCOption_FilterZ");
15750         *ret_copy = COption_FilterZ_some(o_conv);
15751         uint64_t ret_ref = (uint64_t)ret_copy;
15752         return ret_ref;
15753 }
15754
15755 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1FilterZ_1none(JNIEnv *env, jclass clz) {
15756         LDKCOption_FilterZ *ret_copy = MALLOC(sizeof(LDKCOption_FilterZ), "LDKCOption_FilterZ");
15757         *ret_copy = COption_FilterZ_none();
15758         uint64_t ret_ref = (uint64_t)ret_copy;
15759         return ret_ref;
15760 }
15761
15762 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1FilterZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15763         if ((_res & 1) != 0) return;
15764         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15765         CHECK_ACCESS(_res_ptr);
15766         LDKCOption_FilterZ _res_conv = *(LDKCOption_FilterZ*)(_res_ptr);
15767         FREE((void*)_res);
15768         COption_FilterZ_free(_res_conv);
15769 }
15770
15771 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15772         LDKLockedChannelMonitor o_conv;
15773         o_conv.inner = (void*)(o & (~1));
15774         o_conv.is_owned = (o & 1) || (o == 0);
15775         // Warning: we need a move here but no clone is available for LDKLockedChannelMonitor
15776         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
15777         *ret_conv = CResult_LockedChannelMonitorNoneZ_ok(o_conv);
15778         return (uint64_t)ret_conv;
15779 }
15780
15781 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1err(JNIEnv *env, jclass clz) {
15782         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
15783         *ret_conv = CResult_LockedChannelMonitorNoneZ_err();
15784         return (uint64_t)ret_conv;
15785 }
15786
15787 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15788         if ((_res & 1) != 0) return;
15789         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15790         CHECK_ACCESS(_res_ptr);
15791         LDKCResult_LockedChannelMonitorNoneZ _res_conv = *(LDKCResult_LockedChannelMonitorNoneZ*)(_res_ptr);
15792         FREE((void*)_res);
15793         CResult_LockedChannelMonitorNoneZ_free(_res_conv);
15794 }
15795
15796 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1OutPointZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
15797         LDKCVec_OutPointZ _res_constr;
15798         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
15799         if (_res_constr.datalen > 0)
15800                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKOutPoint), "LDKCVec_OutPointZ Elements");
15801         else
15802                 _res_constr.data = NULL;
15803         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
15804         for (size_t k = 0; k < _res_constr.datalen; k++) {
15805                 int64_t _res_conv_10 = _res_vals[k];
15806                 LDKOutPoint _res_conv_10_conv;
15807                 _res_conv_10_conv.inner = (void*)(_res_conv_10 & (~1));
15808                 _res_conv_10_conv.is_owned = (_res_conv_10 & 1) || (_res_conv_10 == 0);
15809                 _res_constr.data[k] = _res_conv_10_conv;
15810         }
15811         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
15812         CVec_OutPointZ_free(_res_constr);
15813 }
15814
15815 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
15816         if ((this_ptr & 1) != 0) return;
15817         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
15818         CHECK_ACCESS(this_ptr_ptr);
15819         LDKPaymentPurpose this_ptr_conv = *(LDKPaymentPurpose*)(this_ptr_ptr);
15820         FREE((void*)this_ptr);
15821         PaymentPurpose_free(this_ptr_conv);
15822 }
15823
15824 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15825         LDKPaymentPurpose* orig_conv = (LDKPaymentPurpose*)orig;
15826         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
15827         *ret_copy = PaymentPurpose_clone(orig_conv);
15828         uint64_t ret_ref = (uint64_t)ret_copy;
15829         return ret_ref;
15830 }
15831
15832 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) {
15833         LDKThirtyTwoBytes payment_preimage_ref;
15834         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
15835         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
15836         LDKThirtyTwoBytes payment_secret_ref;
15837         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
15838         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
15839         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
15840         *ret_copy = PaymentPurpose_invoice_payment(payment_preimage_ref, payment_secret_ref, user_payment_id);
15841         uint64_t ret_ref = (uint64_t)ret_copy;
15842         return ret_ref;
15843 }
15844
15845 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1spontaneous_1payment(JNIEnv *env, jclass clz, int8_tArray a) {
15846         LDKThirtyTwoBytes a_ref;
15847         CHECK((*env)->GetArrayLength(env, a) == 32);
15848         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
15849         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
15850         *ret_copy = PaymentPurpose_spontaneous_payment(a_ref);
15851         uint64_t ret_ref = (uint64_t)ret_copy;
15852         return ret_ref;
15853 }
15854
15855 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosureReason_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
15856         if ((this_ptr & 1) != 0) return;
15857         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
15858         CHECK_ACCESS(this_ptr_ptr);
15859         LDKClosureReason this_ptr_conv = *(LDKClosureReason*)(this_ptr_ptr);
15860         FREE((void*)this_ptr);
15861         ClosureReason_free(this_ptr_conv);
15862 }
15863
15864 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15865         LDKClosureReason* orig_conv = (LDKClosureReason*)orig;
15866         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
15867         *ret_copy = ClosureReason_clone(orig_conv);
15868         uint64_t ret_ref = (uint64_t)ret_copy;
15869         return ret_ref;
15870 }
15871
15872 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1counterparty_1force_1closed(JNIEnv *env, jclass clz, jstring peer_msg) {
15873         LDKStr peer_msg_conv = java_to_owned_str(env, peer_msg);
15874         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
15875         *ret_copy = ClosureReason_counterparty_force_closed(peer_msg_conv);
15876         uint64_t ret_ref = (uint64_t)ret_copy;
15877         return ret_ref;
15878 }
15879
15880 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1holder_1force_1closed(JNIEnv *env, jclass clz) {
15881         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
15882         *ret_copy = ClosureReason_holder_force_closed();
15883         uint64_t ret_ref = (uint64_t)ret_copy;
15884         return ret_ref;
15885 }
15886
15887 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1cooperative_1closure(JNIEnv *env, jclass clz) {
15888         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
15889         *ret_copy = ClosureReason_cooperative_closure();
15890         uint64_t ret_ref = (uint64_t)ret_copy;
15891         return ret_ref;
15892 }
15893
15894 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1commitment_1tx_1confirmed(JNIEnv *env, jclass clz) {
15895         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
15896         *ret_copy = ClosureReason_commitment_tx_confirmed();
15897         uint64_t ret_ref = (uint64_t)ret_copy;
15898         return ret_ref;
15899 }
15900
15901 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1processing_1error(JNIEnv *env, jclass clz, jstring err) {
15902         LDKStr err_conv = java_to_owned_str(env, err);
15903         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
15904         *ret_copy = ClosureReason_processing_error(err_conv);
15905         uint64_t ret_ref = (uint64_t)ret_copy;
15906         return ret_ref;
15907 }
15908
15909 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1disconnected_1peer(JNIEnv *env, jclass clz) {
15910         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
15911         *ret_copy = ClosureReason_disconnected_peer();
15912         uint64_t ret_ref = (uint64_t)ret_copy;
15913         return ret_ref;
15914 }
15915
15916 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1outdated_1channel_1manager(JNIEnv *env, jclass clz) {
15917         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
15918         *ret_copy = ClosureReason_outdated_channel_manager();
15919         uint64_t ret_ref = (uint64_t)ret_copy;
15920         return ret_ref;
15921 }
15922
15923 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosureReason_1write(JNIEnv *env, jclass clz, int64_t obj) {
15924         LDKClosureReason* obj_conv = (LDKClosureReason*)obj;
15925         LDKCVec_u8Z ret_var = ClosureReason_write(obj_conv);
15926         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
15927         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
15928         CVec_u8Z_free(ret_var);
15929         return ret_arr;
15930 }
15931
15932 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Event_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
15933         if ((this_ptr & 1) != 0) return;
15934         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
15935         CHECK_ACCESS(this_ptr_ptr);
15936         LDKEvent this_ptr_conv = *(LDKEvent*)(this_ptr_ptr);
15937         FREE((void*)this_ptr);
15938         Event_free(this_ptr_conv);
15939 }
15940
15941 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15942         LDKEvent* orig_conv = (LDKEvent*)orig;
15943         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
15944         *ret_copy = Event_clone(orig_conv);
15945         uint64_t ret_ref = (uint64_t)ret_copy;
15946         return ret_ref;
15947 }
15948
15949 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) {
15950         LDKThirtyTwoBytes temporary_channel_id_ref;
15951         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
15952         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_ref.data);
15953         LDKCVec_u8Z output_script_ref;
15954         output_script_ref.datalen = (*env)->GetArrayLength(env, output_script);
15955         output_script_ref.data = MALLOC(output_script_ref.datalen, "LDKCVec_u8Z Bytes");
15956         (*env)->GetByteArrayRegion(env, output_script, 0, output_script_ref.datalen, output_script_ref.data);
15957         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
15958         *ret_copy = Event_funding_generation_ready(temporary_channel_id_ref, channel_value_satoshis, output_script_ref, user_channel_id);
15959         uint64_t ret_ref = (uint64_t)ret_copy;
15960         return ret_ref;
15961 }
15962
15963 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) {
15964         LDKThirtyTwoBytes payment_hash_ref;
15965         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
15966         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
15967         void* purpose_ptr = (void*)(((uint64_t)purpose) & ~1);
15968         CHECK_ACCESS(purpose_ptr);
15969         LDKPaymentPurpose purpose_conv = *(LDKPaymentPurpose*)(purpose_ptr);
15970         purpose_conv = PaymentPurpose_clone((LDKPaymentPurpose*)(((uint64_t)purpose) & ~1));
15971         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
15972         *ret_copy = Event_payment_received(payment_hash_ref, amt, purpose_conv);
15973         uint64_t ret_ref = (uint64_t)ret_copy;
15974         return ret_ref;
15975 }
15976
15977 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1payment_1sent(JNIEnv *env, jclass clz, int8_tArray payment_preimage, int8_tArray payment_hash) {
15978         LDKThirtyTwoBytes payment_preimage_ref;
15979         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
15980         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
15981         LDKThirtyTwoBytes payment_hash_ref;
15982         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
15983         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
15984         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
15985         *ret_copy = Event_payment_sent(payment_preimage_ref, payment_hash_ref);
15986         uint64_t ret_ref = (uint64_t)ret_copy;
15987         return ret_ref;
15988 }
15989
15990 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) {
15991         LDKThirtyTwoBytes payment_hash_ref;
15992         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
15993         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
15994         void* network_update_ptr = (void*)(((uint64_t)network_update) & ~1);
15995         CHECK_ACCESS(network_update_ptr);
15996         LDKCOption_NetworkUpdateZ network_update_conv = *(LDKCOption_NetworkUpdateZ*)(network_update_ptr);
15997         network_update_conv = COption_NetworkUpdateZ_clone((LDKCOption_NetworkUpdateZ*)(((uint64_t)network_update) & ~1));
15998         LDKCVec_RouteHopZ path_constr;
15999         path_constr.datalen = (*env)->GetArrayLength(env, path);
16000         if (path_constr.datalen > 0)
16001                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
16002         else
16003                 path_constr.data = NULL;
16004         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
16005         for (size_t k = 0; k < path_constr.datalen; k++) {
16006                 int64_t path_conv_10 = path_vals[k];
16007                 LDKRouteHop path_conv_10_conv;
16008                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
16009                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
16010                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
16011                 path_constr.data[k] = path_conv_10_conv;
16012         }
16013         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
16014         void* short_channel_id_ptr = (void*)(((uint64_t)short_channel_id) & ~1);
16015         CHECK_ACCESS(short_channel_id_ptr);
16016         LDKCOption_u64Z short_channel_id_conv = *(LDKCOption_u64Z*)(short_channel_id_ptr);
16017         short_channel_id_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)short_channel_id) & ~1));
16018         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
16019         *ret_copy = Event_payment_path_failed(payment_hash_ref, rejected_by_dest, network_update_conv, all_paths_failed, path_constr, short_channel_id_conv);
16020         uint64_t ret_ref = (uint64_t)ret_copy;
16021         return ret_ref;
16022 }
16023
16024 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1pending_1htlcs_1forwardable(JNIEnv *env, jclass clz, int64_t time_forwardable) {
16025         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
16026         *ret_copy = Event_pending_htlcs_forwardable(time_forwardable);
16027         uint64_t ret_ref = (uint64_t)ret_copy;
16028         return ret_ref;
16029 }
16030
16031 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1spendable_1outputs(JNIEnv *env, jclass clz, int64_tArray outputs) {
16032         LDKCVec_SpendableOutputDescriptorZ outputs_constr;
16033         outputs_constr.datalen = (*env)->GetArrayLength(env, outputs);
16034         if (outputs_constr.datalen > 0)
16035                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
16036         else
16037                 outputs_constr.data = NULL;
16038         int64_t* outputs_vals = (*env)->GetLongArrayElements (env, outputs, NULL);
16039         for (size_t b = 0; b < outputs_constr.datalen; b++) {
16040                 int64_t outputs_conv_27 = outputs_vals[b];
16041                 void* outputs_conv_27_ptr = (void*)(((uint64_t)outputs_conv_27) & ~1);
16042                 CHECK_ACCESS(outputs_conv_27_ptr);
16043                 LDKSpendableOutputDescriptor outputs_conv_27_conv = *(LDKSpendableOutputDescriptor*)(outputs_conv_27_ptr);
16044                 outputs_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uint64_t)outputs_conv_27) & ~1));
16045                 outputs_constr.data[b] = outputs_conv_27_conv;
16046         }
16047         (*env)->ReleaseLongArrayElements(env, outputs, outputs_vals, 0);
16048         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
16049         *ret_copy = Event_spendable_outputs(outputs_constr);
16050         uint64_t ret_ref = (uint64_t)ret_copy;
16051         return ret_ref;
16052 }
16053
16054 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) {
16055         void* fee_earned_msat_ptr = (void*)(((uint64_t)fee_earned_msat) & ~1);
16056         CHECK_ACCESS(fee_earned_msat_ptr);
16057         LDKCOption_u64Z fee_earned_msat_conv = *(LDKCOption_u64Z*)(fee_earned_msat_ptr);
16058         fee_earned_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)fee_earned_msat) & ~1));
16059         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
16060         *ret_copy = Event_payment_forwarded(fee_earned_msat_conv, claim_from_onchain_tx);
16061         uint64_t ret_ref = (uint64_t)ret_copy;
16062         return ret_ref;
16063 }
16064
16065 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) {
16066         LDKThirtyTwoBytes channel_id_ref;
16067         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
16068         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_ref.data);
16069         void* reason_ptr = (void*)(((uint64_t)reason) & ~1);
16070         CHECK_ACCESS(reason_ptr);
16071         LDKClosureReason reason_conv = *(LDKClosureReason*)(reason_ptr);
16072         reason_conv = ClosureReason_clone((LDKClosureReason*)(((uint64_t)reason) & ~1));
16073         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
16074         *ret_copy = Event_channel_closed(channel_id_ref, user_channel_id, reason_conv);
16075         uint64_t ret_ref = (uint64_t)ret_copy;
16076         return ret_ref;
16077 }
16078
16079 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1discard_1funding(JNIEnv *env, jclass clz, int8_tArray channel_id, int8_tArray transaction) {
16080         LDKThirtyTwoBytes channel_id_ref;
16081         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
16082         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_ref.data);
16083         LDKTransaction transaction_ref;
16084         transaction_ref.datalen = (*env)->GetArrayLength(env, transaction);
16085         transaction_ref.data = MALLOC(transaction_ref.datalen, "LDKTransaction Bytes");
16086         (*env)->GetByteArrayRegion(env, transaction, 0, transaction_ref.datalen, transaction_ref.data);
16087         transaction_ref.data_is_owned = true;
16088         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
16089         *ret_copy = Event_discard_funding(channel_id_ref, transaction_ref);
16090         uint64_t ret_ref = (uint64_t)ret_copy;
16091         return ret_ref;
16092 }
16093
16094 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Event_1write(JNIEnv *env, jclass clz, int64_t obj) {
16095         LDKEvent* obj_conv = (LDKEvent*)obj;
16096         LDKCVec_u8Z ret_var = Event_write(obj_conv);
16097         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
16098         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
16099         CVec_u8Z_free(ret_var);
16100         return ret_arr;
16101 }
16102
16103 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
16104         if ((this_ptr & 1) != 0) return;
16105         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
16106         CHECK_ACCESS(this_ptr_ptr);
16107         LDKMessageSendEvent this_ptr_conv = *(LDKMessageSendEvent*)(this_ptr_ptr);
16108         FREE((void*)this_ptr);
16109         MessageSendEvent_free(this_ptr_conv);
16110 }
16111
16112 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16113         LDKMessageSendEvent* orig_conv = (LDKMessageSendEvent*)orig;
16114         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
16115         *ret_copy = MessageSendEvent_clone(orig_conv);
16116         uint64_t ret_ref = (uint64_t)ret_copy;
16117         return ret_ref;
16118 }
16119
16120 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1accept_1channel(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
16121         LDKPublicKey node_id_ref;
16122         CHECK((*env)->GetArrayLength(env, node_id) == 33);
16123         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
16124         LDKAcceptChannel msg_conv;
16125         msg_conv.inner = (void*)(msg & (~1));
16126         msg_conv.is_owned = (msg & 1) || (msg == 0);
16127         msg_conv = AcceptChannel_clone(&msg_conv);
16128         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
16129         *ret_copy = MessageSendEvent_send_accept_channel(node_id_ref, msg_conv);
16130         uint64_t ret_ref = (uint64_t)ret_copy;
16131         return ret_ref;
16132 }
16133
16134 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1open_1channel(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
16135         LDKPublicKey node_id_ref;
16136         CHECK((*env)->GetArrayLength(env, node_id) == 33);
16137         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
16138         LDKOpenChannel msg_conv;
16139         msg_conv.inner = (void*)(msg & (~1));
16140         msg_conv.is_owned = (msg & 1) || (msg == 0);
16141         msg_conv = OpenChannel_clone(&msg_conv);
16142         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
16143         *ret_copy = MessageSendEvent_send_open_channel(node_id_ref, msg_conv);
16144         uint64_t ret_ref = (uint64_t)ret_copy;
16145         return ret_ref;
16146 }
16147
16148 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1funding_1created(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
16149         LDKPublicKey node_id_ref;
16150         CHECK((*env)->GetArrayLength(env, node_id) == 33);
16151         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
16152         LDKFundingCreated msg_conv;
16153         msg_conv.inner = (void*)(msg & (~1));
16154         msg_conv.is_owned = (msg & 1) || (msg == 0);
16155         msg_conv = FundingCreated_clone(&msg_conv);
16156         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
16157         *ret_copy = MessageSendEvent_send_funding_created(node_id_ref, msg_conv);
16158         uint64_t ret_ref = (uint64_t)ret_copy;
16159         return ret_ref;
16160 }
16161
16162 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1funding_1signed(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
16163         LDKPublicKey node_id_ref;
16164         CHECK((*env)->GetArrayLength(env, node_id) == 33);
16165         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
16166         LDKFundingSigned msg_conv;
16167         msg_conv.inner = (void*)(msg & (~1));
16168         msg_conv.is_owned = (msg & 1) || (msg == 0);
16169         msg_conv = FundingSigned_clone(&msg_conv);
16170         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
16171         *ret_copy = MessageSendEvent_send_funding_signed(node_id_ref, msg_conv);
16172         uint64_t ret_ref = (uint64_t)ret_copy;
16173         return ret_ref;
16174 }
16175
16176 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1funding_1locked(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
16177         LDKPublicKey node_id_ref;
16178         CHECK((*env)->GetArrayLength(env, node_id) == 33);
16179         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
16180         LDKFundingLocked msg_conv;
16181         msg_conv.inner = (void*)(msg & (~1));
16182         msg_conv.is_owned = (msg & 1) || (msg == 0);
16183         msg_conv = FundingLocked_clone(&msg_conv);
16184         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
16185         *ret_copy = MessageSendEvent_send_funding_locked(node_id_ref, msg_conv);
16186         uint64_t ret_ref = (uint64_t)ret_copy;
16187         return ret_ref;
16188 }
16189
16190 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1announcement_1signatures(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
16191         LDKPublicKey node_id_ref;
16192         CHECK((*env)->GetArrayLength(env, node_id) == 33);
16193         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
16194         LDKAnnouncementSignatures msg_conv;
16195         msg_conv.inner = (void*)(msg & (~1));
16196         msg_conv.is_owned = (msg & 1) || (msg == 0);
16197         msg_conv = AnnouncementSignatures_clone(&msg_conv);
16198         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
16199         *ret_copy = MessageSendEvent_send_announcement_signatures(node_id_ref, msg_conv);
16200         uint64_t ret_ref = (uint64_t)ret_copy;
16201         return ret_ref;
16202 }
16203
16204 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1update_1htlcs(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t updates) {
16205         LDKPublicKey node_id_ref;
16206         CHECK((*env)->GetArrayLength(env, node_id) == 33);
16207         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
16208         LDKCommitmentUpdate updates_conv;
16209         updates_conv.inner = (void*)(updates & (~1));
16210         updates_conv.is_owned = (updates & 1) || (updates == 0);
16211         updates_conv = CommitmentUpdate_clone(&updates_conv);
16212         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
16213         *ret_copy = MessageSendEvent_update_htlcs(node_id_ref, updates_conv);
16214         uint64_t ret_ref = (uint64_t)ret_copy;
16215         return ret_ref;
16216 }
16217
16218 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) {
16219         LDKPublicKey node_id_ref;
16220         CHECK((*env)->GetArrayLength(env, node_id) == 33);
16221         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
16222         LDKRevokeAndACK msg_conv;
16223         msg_conv.inner = (void*)(msg & (~1));
16224         msg_conv.is_owned = (msg & 1) || (msg == 0);
16225         msg_conv = RevokeAndACK_clone(&msg_conv);
16226         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
16227         *ret_copy = MessageSendEvent_send_revoke_and_ack(node_id_ref, msg_conv);
16228         uint64_t ret_ref = (uint64_t)ret_copy;
16229         return ret_ref;
16230 }
16231
16232 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1closing_1signed(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
16233         LDKPublicKey node_id_ref;
16234         CHECK((*env)->GetArrayLength(env, node_id) == 33);
16235         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
16236         LDKClosingSigned msg_conv;
16237         msg_conv.inner = (void*)(msg & (~1));
16238         msg_conv.is_owned = (msg & 1) || (msg == 0);
16239         msg_conv = ClosingSigned_clone(&msg_conv);
16240         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
16241         *ret_copy = MessageSendEvent_send_closing_signed(node_id_ref, msg_conv);
16242         uint64_t ret_ref = (uint64_t)ret_copy;
16243         return ret_ref;
16244 }
16245
16246 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1shutdown(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
16247         LDKPublicKey node_id_ref;
16248         CHECK((*env)->GetArrayLength(env, node_id) == 33);
16249         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
16250         LDKShutdown msg_conv;
16251         msg_conv.inner = (void*)(msg & (~1));
16252         msg_conv.is_owned = (msg & 1) || (msg == 0);
16253         msg_conv = Shutdown_clone(&msg_conv);
16254         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
16255         *ret_copy = MessageSendEvent_send_shutdown(node_id_ref, msg_conv);
16256         uint64_t ret_ref = (uint64_t)ret_copy;
16257         return ret_ref;
16258 }
16259
16260 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1channel_1reestablish(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
16261         LDKPublicKey node_id_ref;
16262         CHECK((*env)->GetArrayLength(env, node_id) == 33);
16263         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
16264         LDKChannelReestablish msg_conv;
16265         msg_conv.inner = (void*)(msg & (~1));
16266         msg_conv.is_owned = (msg & 1) || (msg == 0);
16267         msg_conv = ChannelReestablish_clone(&msg_conv);
16268         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
16269         *ret_copy = MessageSendEvent_send_channel_reestablish(node_id_ref, msg_conv);
16270         uint64_t ret_ref = (uint64_t)ret_copy;
16271         return ret_ref;
16272 }
16273
16274 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1broadcast_1channel_1announcement(JNIEnv *env, jclass clz, int64_t msg, int64_t update_msg) {
16275         LDKChannelAnnouncement msg_conv;
16276         msg_conv.inner = (void*)(msg & (~1));
16277         msg_conv.is_owned = (msg & 1) || (msg == 0);
16278         msg_conv = ChannelAnnouncement_clone(&msg_conv);
16279         LDKChannelUpdate update_msg_conv;
16280         update_msg_conv.inner = (void*)(update_msg & (~1));
16281         update_msg_conv.is_owned = (update_msg & 1) || (update_msg == 0);
16282         update_msg_conv = ChannelUpdate_clone(&update_msg_conv);
16283         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
16284         *ret_copy = MessageSendEvent_broadcast_channel_announcement(msg_conv, update_msg_conv);
16285         uint64_t ret_ref = (uint64_t)ret_copy;
16286         return ret_ref;
16287 }
16288
16289 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1broadcast_1node_1announcement(JNIEnv *env, jclass clz, int64_t msg) {
16290         LDKNodeAnnouncement msg_conv;
16291         msg_conv.inner = (void*)(msg & (~1));
16292         msg_conv.is_owned = (msg & 1) || (msg == 0);
16293         msg_conv = NodeAnnouncement_clone(&msg_conv);
16294         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
16295         *ret_copy = MessageSendEvent_broadcast_node_announcement(msg_conv);
16296         uint64_t ret_ref = (uint64_t)ret_copy;
16297         return ret_ref;
16298 }
16299
16300 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1broadcast_1channel_1update(JNIEnv *env, jclass clz, int64_t msg) {
16301         LDKChannelUpdate msg_conv;
16302         msg_conv.inner = (void*)(msg & (~1));
16303         msg_conv.is_owned = (msg & 1) || (msg == 0);
16304         msg_conv = ChannelUpdate_clone(&msg_conv);
16305         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
16306         *ret_copy = MessageSendEvent_broadcast_channel_update(msg_conv);
16307         uint64_t ret_ref = (uint64_t)ret_copy;
16308         return ret_ref;
16309 }
16310
16311 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1channel_1update(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
16312         LDKPublicKey node_id_ref;
16313         CHECK((*env)->GetArrayLength(env, node_id) == 33);
16314         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
16315         LDKChannelUpdate msg_conv;
16316         msg_conv.inner = (void*)(msg & (~1));
16317         msg_conv.is_owned = (msg & 1) || (msg == 0);
16318         msg_conv = ChannelUpdate_clone(&msg_conv);
16319         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
16320         *ret_copy = MessageSendEvent_send_channel_update(node_id_ref, msg_conv);
16321         uint64_t ret_ref = (uint64_t)ret_copy;
16322         return ret_ref;
16323 }
16324
16325 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1handle_1error(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t action) {
16326         LDKPublicKey node_id_ref;
16327         CHECK((*env)->GetArrayLength(env, node_id) == 33);
16328         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
16329         void* action_ptr = (void*)(((uint64_t)action) & ~1);
16330         CHECK_ACCESS(action_ptr);
16331         LDKErrorAction action_conv = *(LDKErrorAction*)(action_ptr);
16332         action_conv = ErrorAction_clone((LDKErrorAction*)(((uint64_t)action) & ~1));
16333         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
16334         *ret_copy = MessageSendEvent_handle_error(node_id_ref, action_conv);
16335         uint64_t ret_ref = (uint64_t)ret_copy;
16336         return ret_ref;
16337 }
16338
16339 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) {
16340         LDKPublicKey node_id_ref;
16341         CHECK((*env)->GetArrayLength(env, node_id) == 33);
16342         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
16343         LDKQueryChannelRange msg_conv;
16344         msg_conv.inner = (void*)(msg & (~1));
16345         msg_conv.is_owned = (msg & 1) || (msg == 0);
16346         msg_conv = QueryChannelRange_clone(&msg_conv);
16347         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
16348         *ret_copy = MessageSendEvent_send_channel_range_query(node_id_ref, msg_conv);
16349         uint64_t ret_ref = (uint64_t)ret_copy;
16350         return ret_ref;
16351 }
16352
16353 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) {
16354         LDKPublicKey node_id_ref;
16355         CHECK((*env)->GetArrayLength(env, node_id) == 33);
16356         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
16357         LDKQueryShortChannelIds msg_conv;
16358         msg_conv.inner = (void*)(msg & (~1));
16359         msg_conv.is_owned = (msg & 1) || (msg == 0);
16360         msg_conv = QueryShortChannelIds_clone(&msg_conv);
16361         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
16362         *ret_copy = MessageSendEvent_send_short_ids_query(node_id_ref, msg_conv);
16363         uint64_t ret_ref = (uint64_t)ret_copy;
16364         return ret_ref;
16365 }
16366
16367 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) {
16368         LDKPublicKey node_id_ref;
16369         CHECK((*env)->GetArrayLength(env, node_id) == 33);
16370         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
16371         LDKReplyChannelRange msg_conv;
16372         msg_conv.inner = (void*)(msg & (~1));
16373         msg_conv.is_owned = (msg & 1) || (msg == 0);
16374         msg_conv = ReplyChannelRange_clone(&msg_conv);
16375         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
16376         *ret_copy = MessageSendEvent_send_reply_channel_range(node_id_ref, msg_conv);
16377         uint64_t ret_ref = (uint64_t)ret_copy;
16378         return ret_ref;
16379 }
16380
16381 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageSendEventsProvider_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
16382         if ((this_ptr & 1) != 0) return;
16383         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
16384         CHECK_ACCESS(this_ptr_ptr);
16385         LDKMessageSendEventsProvider this_ptr_conv = *(LDKMessageSendEventsProvider*)(this_ptr_ptr);
16386         FREE((void*)this_ptr);
16387         MessageSendEventsProvider_free(this_ptr_conv);
16388 }
16389
16390 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventsProvider_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
16391         if ((this_ptr & 1) != 0) return;
16392         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
16393         CHECK_ACCESS(this_ptr_ptr);
16394         LDKEventsProvider this_ptr_conv = *(LDKEventsProvider*)(this_ptr_ptr);
16395         FREE((void*)this_ptr);
16396         EventsProvider_free(this_ptr_conv);
16397 }
16398
16399 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
16400         if ((this_ptr & 1) != 0) return;
16401         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
16402         CHECK_ACCESS(this_ptr_ptr);
16403         LDKEventHandler this_ptr_conv = *(LDKEventHandler*)(this_ptr_ptr);
16404         FREE((void*)this_ptr);
16405         EventHandler_free(this_ptr_conv);
16406 }
16407
16408 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_APIError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
16409         if ((this_ptr & 1) != 0) return;
16410         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
16411         CHECK_ACCESS(this_ptr_ptr);
16412         LDKAPIError this_ptr_conv = *(LDKAPIError*)(this_ptr_ptr);
16413         FREE((void*)this_ptr);
16414         APIError_free(this_ptr_conv);
16415 }
16416
16417 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16418         LDKAPIError* orig_conv = (LDKAPIError*)orig;
16419         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
16420         *ret_copy = APIError_clone(orig_conv);
16421         uint64_t ret_ref = (uint64_t)ret_copy;
16422         return ret_ref;
16423 }
16424
16425 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1apimisuse_1error(JNIEnv *env, jclass clz, jstring err) {
16426         LDKStr err_conv = java_to_owned_str(env, err);
16427         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
16428         *ret_copy = APIError_apimisuse_error(err_conv);
16429         uint64_t ret_ref = (uint64_t)ret_copy;
16430         return ret_ref;
16431 }
16432
16433 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1fee_1rate_1too_1high(JNIEnv *env, jclass clz, jstring err, int32_t feerate) {
16434         LDKStr err_conv = java_to_owned_str(env, err);
16435         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
16436         *ret_copy = APIError_fee_rate_too_high(err_conv, feerate);
16437         uint64_t ret_ref = (uint64_t)ret_copy;
16438         return ret_ref;
16439 }
16440
16441 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1route_1error(JNIEnv *env, jclass clz, jstring err) {
16442         LDKStr err_conv = java_to_owned_str(env, err);
16443         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
16444         *ret_copy = APIError_route_error(err_conv);
16445         uint64_t ret_ref = (uint64_t)ret_copy;
16446         return ret_ref;
16447 }
16448
16449 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1channel_1unavailable(JNIEnv *env, jclass clz, jstring err) {
16450         LDKStr err_conv = java_to_owned_str(env, err);
16451         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
16452         *ret_copy = APIError_channel_unavailable(err_conv);
16453         uint64_t ret_ref = (uint64_t)ret_copy;
16454         return ret_ref;
16455 }
16456
16457 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1monitor_1update_1failed(JNIEnv *env, jclass clz) {
16458         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
16459         *ret_copy = APIError_monitor_update_failed();
16460         uint64_t ret_ref = (uint64_t)ret_copy;
16461         return ret_ref;
16462 }
16463
16464 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1incompatible_1shutdown_1script(JNIEnv *env, jclass clz, int64_t script) {
16465         LDKShutdownScript script_conv;
16466         script_conv.inner = (void*)(script & (~1));
16467         script_conv.is_owned = (script & 1) || (script == 0);
16468         script_conv = ShutdownScript_clone(&script_conv);
16469         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
16470         *ret_copy = APIError_incompatible_shutdown_script(script_conv);
16471         uint64_t ret_ref = (uint64_t)ret_copy;
16472         return ret_ref;
16473 }
16474
16475 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_sign(JNIEnv *env, jclass clz, int8_tArray msg, int8_tArray sk) {
16476         LDKu8slice msg_ref;
16477         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
16478         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
16479         unsigned char sk_arr[32];
16480         CHECK((*env)->GetArrayLength(env, sk) == 32);
16481         (*env)->GetByteArrayRegion(env, sk, 0, 32, sk_arr);
16482         unsigned char (*sk_ref)[32] = &sk_arr;
16483         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
16484         *ret_conv = sign(msg_ref, sk_ref);
16485         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
16486         return (uint64_t)ret_conv;
16487 }
16488
16489 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_recover_1pk(JNIEnv *env, jclass clz, int8_tArray msg, jstring sig) {
16490         LDKu8slice msg_ref;
16491         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
16492         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
16493         LDKStr sig_conv = java_to_owned_str(env, sig);
16494         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
16495         *ret_conv = recover_pk(msg_ref, sig_conv);
16496         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
16497         return (uint64_t)ret_conv;
16498 }
16499
16500 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_verify(JNIEnv *env, jclass clz, int8_tArray msg, jstring sig, int8_tArray pk) {
16501         LDKu8slice msg_ref;
16502         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
16503         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
16504         LDKStr sig_conv = java_to_owned_str(env, sig);
16505         LDKPublicKey pk_ref;
16506         CHECK((*env)->GetArrayLength(env, pk) == 33);
16507         (*env)->GetByteArrayRegion(env, pk, 0, 33, pk_ref.compressed_form);
16508         jboolean ret_val = verify(msg_ref, sig_conv, pk_ref);
16509         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
16510         return ret_val;
16511 }
16512
16513 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16514         LDKLevel* orig_conv = (LDKLevel*)(orig & ~1);
16515         jclass ret_conv = LDKLevel_to_java(env, Level_clone(orig_conv));
16516         return ret_conv;
16517 }
16518
16519 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1trace(JNIEnv *env, jclass clz) {
16520         jclass ret_conv = LDKLevel_to_java(env, Level_trace());
16521         return ret_conv;
16522 }
16523
16524 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1debug(JNIEnv *env, jclass clz) {
16525         jclass ret_conv = LDKLevel_to_java(env, Level_debug());
16526         return ret_conv;
16527 }
16528
16529 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1info(JNIEnv *env, jclass clz) {
16530         jclass ret_conv = LDKLevel_to_java(env, Level_info());
16531         return ret_conv;
16532 }
16533
16534 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1warn(JNIEnv *env, jclass clz) {
16535         jclass ret_conv = LDKLevel_to_java(env, Level_warn());
16536         return ret_conv;
16537 }
16538
16539 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1error(JNIEnv *env, jclass clz) {
16540         jclass ret_conv = LDKLevel_to_java(env, Level_error());
16541         return ret_conv;
16542 }
16543
16544 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Level_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
16545         LDKLevel* a_conv = (LDKLevel*)(a & ~1);
16546         LDKLevel* b_conv = (LDKLevel*)(b & ~1);
16547         jboolean ret_val = Level_eq(a_conv, b_conv);
16548         return ret_val;
16549 }
16550
16551 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Level_1hash(JNIEnv *env, jclass clz, int64_t o) {
16552         LDKLevel* o_conv = (LDKLevel*)(o & ~1);
16553         int64_t ret_val = Level_hash(o_conv);
16554         return ret_val;
16555 }
16556
16557 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1max(JNIEnv *env, jclass clz) {
16558         jclass ret_conv = LDKLevel_to_java(env, Level_max());
16559         return ret_conv;
16560 }
16561
16562 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Logger_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
16563         if ((this_ptr & 1) != 0) return;
16564         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
16565         CHECK_ACCESS(this_ptr_ptr);
16566         LDKLogger this_ptr_conv = *(LDKLogger*)(this_ptr_ptr);
16567         FREE((void*)this_ptr);
16568         Logger_free(this_ptr_conv);
16569 }
16570
16571 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
16572         LDKChannelHandshakeConfig this_obj_conv;
16573         this_obj_conv.inner = (void*)(this_obj & (~1));
16574         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16575         ChannelHandshakeConfig_free(this_obj_conv);
16576 }
16577
16578 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
16579         LDKChannelHandshakeConfig this_ptr_conv;
16580         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16581         this_ptr_conv.is_owned = false;
16582         int32_t ret_val = ChannelHandshakeConfig_get_minimum_depth(&this_ptr_conv);
16583         return ret_val;
16584 }
16585
16586 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
16587         LDKChannelHandshakeConfig this_ptr_conv;
16588         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16589         this_ptr_conv.is_owned = false;
16590         ChannelHandshakeConfig_set_minimum_depth(&this_ptr_conv, val);
16591 }
16592
16593 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1our_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
16594         LDKChannelHandshakeConfig this_ptr_conv;
16595         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16596         this_ptr_conv.is_owned = false;
16597         int16_t ret_val = ChannelHandshakeConfig_get_our_to_self_delay(&this_ptr_conv);
16598         return ret_val;
16599 }
16600
16601 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) {
16602         LDKChannelHandshakeConfig this_ptr_conv;
16603         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16604         this_ptr_conv.is_owned = false;
16605         ChannelHandshakeConfig_set_our_to_self_delay(&this_ptr_conv, val);
16606 }
16607
16608 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1our_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
16609         LDKChannelHandshakeConfig this_ptr_conv;
16610         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16611         this_ptr_conv.is_owned = false;
16612         int64_t ret_val = ChannelHandshakeConfig_get_our_htlc_minimum_msat(&this_ptr_conv);
16613         return ret_val;
16614 }
16615
16616 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) {
16617         LDKChannelHandshakeConfig this_ptr_conv;
16618         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16619         this_ptr_conv.is_owned = false;
16620         ChannelHandshakeConfig_set_our_htlc_minimum_msat(&this_ptr_conv, val);
16621 }
16622
16623 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) {
16624         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_new(minimum_depth_arg, our_to_self_delay_arg, our_htlc_minimum_msat_arg);
16625         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16626         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16627         uint64_t ret_ref = (uint64_t)ret_var.inner;
16628         if (ret_var.is_owned) {
16629                 ret_ref |= 1;
16630         }
16631         return ret_ref;
16632 }
16633
16634 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16635         LDKChannelHandshakeConfig orig_conv;
16636         orig_conv.inner = (void*)(orig & (~1));
16637         orig_conv.is_owned = false;
16638         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(&orig_conv);
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_ChannelHandshakeConfig_1default(JNIEnv *env, jclass clz) {
16649         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_default();
16650         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16651         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16652         uint64_t ret_ref = (uint64_t)ret_var.inner;
16653         if (ret_var.is_owned) {
16654                 ret_ref |= 1;
16655         }
16656         return ret_ref;
16657 }
16658
16659 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
16660         LDKChannelHandshakeLimits this_obj_conv;
16661         this_obj_conv.inner = (void*)(this_obj & (~1));
16662         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16663         ChannelHandshakeLimits_free(this_obj_conv);
16664 }
16665
16666 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
16667         LDKChannelHandshakeLimits this_ptr_conv;
16668         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16669         this_ptr_conv.is_owned = false;
16670         int64_t ret_val = ChannelHandshakeLimits_get_min_funding_satoshis(&this_ptr_conv);
16671         return ret_val;
16672 }
16673
16674 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1min_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16675         LDKChannelHandshakeLimits this_ptr_conv;
16676         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16677         this_ptr_conv.is_owned = false;
16678         ChannelHandshakeLimits_set_min_funding_satoshis(&this_ptr_conv, val);
16679 }
16680
16681 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
16682         LDKChannelHandshakeLimits this_ptr_conv;
16683         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16684         this_ptr_conv.is_owned = false;
16685         int64_t ret_val = ChannelHandshakeLimits_get_max_htlc_minimum_msat(&this_ptr_conv);
16686         return ret_val;
16687 }
16688
16689 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) {
16690         LDKChannelHandshakeLimits this_ptr_conv;
16691         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16692         this_ptr_conv.is_owned = false;
16693         ChannelHandshakeLimits_set_max_htlc_minimum_msat(&this_ptr_conv, val);
16694 }
16695
16696 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) {
16697         LDKChannelHandshakeLimits this_ptr_conv;
16698         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16699         this_ptr_conv.is_owned = false;
16700         int64_t ret_val = ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(&this_ptr_conv);
16701         return ret_val;
16702 }
16703
16704 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) {
16705         LDKChannelHandshakeLimits this_ptr_conv;
16706         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16707         this_ptr_conv.is_owned = false;
16708         ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
16709 }
16710
16711 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
16712         LDKChannelHandshakeLimits this_ptr_conv;
16713         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16714         this_ptr_conv.is_owned = false;
16715         int64_t ret_val = ChannelHandshakeLimits_get_max_channel_reserve_satoshis(&this_ptr_conv);
16716         return ret_val;
16717 }
16718
16719 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) {
16720         LDKChannelHandshakeLimits this_ptr_conv;
16721         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16722         this_ptr_conv.is_owned = false;
16723         ChannelHandshakeLimits_set_max_channel_reserve_satoshis(&this_ptr_conv, val);
16724 }
16725
16726 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
16727         LDKChannelHandshakeLimits this_ptr_conv;
16728         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16729         this_ptr_conv.is_owned = false;
16730         int16_t ret_val = ChannelHandshakeLimits_get_min_max_accepted_htlcs(&this_ptr_conv);
16731         return ret_val;
16732 }
16733
16734 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) {
16735         LDKChannelHandshakeLimits this_ptr_conv;
16736         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16737         this_ptr_conv.is_owned = false;
16738         ChannelHandshakeLimits_set_min_max_accepted_htlcs(&this_ptr_conv, val);
16739 }
16740
16741 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
16742         LDKChannelHandshakeLimits this_ptr_conv;
16743         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16744         this_ptr_conv.is_owned = false;
16745         int32_t ret_val = ChannelHandshakeLimits_get_max_minimum_depth(&this_ptr_conv);
16746         return ret_val;
16747 }
16748
16749 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1max_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
16750         LDKChannelHandshakeLimits this_ptr_conv;
16751         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16752         this_ptr_conv.is_owned = false;
16753         ChannelHandshakeLimits_set_max_minimum_depth(&this_ptr_conv, val);
16754 }
16755
16756 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1force_1announced_1channel_1preference(JNIEnv *env, jclass clz, int64_t this_ptr) {
16757         LDKChannelHandshakeLimits this_ptr_conv;
16758         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16759         this_ptr_conv.is_owned = false;
16760         jboolean ret_val = ChannelHandshakeLimits_get_force_announced_channel_preference(&this_ptr_conv);
16761         return ret_val;
16762 }
16763
16764 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1force_1announced_1channel_1preference(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
16765         LDKChannelHandshakeLimits this_ptr_conv;
16766         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16767         this_ptr_conv.is_owned = false;
16768         ChannelHandshakeLimits_set_force_announced_channel_preference(&this_ptr_conv, val);
16769 }
16770
16771 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1their_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
16772         LDKChannelHandshakeLimits this_ptr_conv;
16773         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16774         this_ptr_conv.is_owned = false;
16775         int16_t ret_val = ChannelHandshakeLimits_get_their_to_self_delay(&this_ptr_conv);
16776         return ret_val;
16777 }
16778
16779 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) {
16780         LDKChannelHandshakeLimits this_ptr_conv;
16781         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16782         this_ptr_conv.is_owned = false;
16783         ChannelHandshakeLimits_set_their_to_self_delay(&this_ptr_conv, val);
16784 }
16785
16786 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) {
16787         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);
16788         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16789         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16790         uint64_t ret_ref = (uint64_t)ret_var.inner;
16791         if (ret_var.is_owned) {
16792                 ret_ref |= 1;
16793         }
16794         return ret_ref;
16795 }
16796
16797 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16798         LDKChannelHandshakeLimits orig_conv;
16799         orig_conv.inner = (void*)(orig & (~1));
16800         orig_conv.is_owned = false;
16801         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(&orig_conv);
16802         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16803         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16804         uint64_t ret_ref = (uint64_t)ret_var.inner;
16805         if (ret_var.is_owned) {
16806                 ret_ref |= 1;
16807         }
16808         return ret_ref;
16809 }
16810
16811 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1default(JNIEnv *env, jclass clz) {
16812         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_default();
16813         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16814         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16815         uint64_t ret_ref = (uint64_t)ret_var.inner;
16816         if (ret_var.is_owned) {
16817                 ret_ref |= 1;
16818         }
16819         return ret_ref;
16820 }
16821
16822 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
16823         LDKChannelConfig this_obj_conv;
16824         this_obj_conv.inner = (void*)(this_obj & (~1));
16825         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16826         ChannelConfig_free(this_obj_conv);
16827 }
16828
16829 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1forwarding_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
16830         LDKChannelConfig this_ptr_conv;
16831         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16832         this_ptr_conv.is_owned = false;
16833         int32_t ret_val = ChannelConfig_get_forwarding_fee_proportional_millionths(&this_ptr_conv);
16834         return ret_val;
16835 }
16836
16837 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) {
16838         LDKChannelConfig this_ptr_conv;
16839         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16840         this_ptr_conv.is_owned = false;
16841         ChannelConfig_set_forwarding_fee_proportional_millionths(&this_ptr_conv, val);
16842 }
16843
16844 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1forwarding_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
16845         LDKChannelConfig this_ptr_conv;
16846         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16847         this_ptr_conv.is_owned = false;
16848         int32_t ret_val = ChannelConfig_get_forwarding_fee_base_msat(&this_ptr_conv);
16849         return ret_val;
16850 }
16851
16852 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) {
16853         LDKChannelConfig this_ptr_conv;
16854         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16855         this_ptr_conv.is_owned = false;
16856         ChannelConfig_set_forwarding_fee_base_msat(&this_ptr_conv, val);
16857 }
16858
16859 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
16860         LDKChannelConfig this_ptr_conv;
16861         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16862         this_ptr_conv.is_owned = false;
16863         int16_t ret_val = ChannelConfig_get_cltv_expiry_delta(&this_ptr_conv);
16864         return ret_val;
16865 }
16866
16867 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
16868         LDKChannelConfig this_ptr_conv;
16869         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16870         this_ptr_conv.is_owned = false;
16871         ChannelConfig_set_cltv_expiry_delta(&this_ptr_conv, val);
16872 }
16873
16874 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1announced_1channel(JNIEnv *env, jclass clz, int64_t this_ptr) {
16875         LDKChannelConfig this_ptr_conv;
16876         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16877         this_ptr_conv.is_owned = false;
16878         jboolean ret_val = ChannelConfig_get_announced_channel(&this_ptr_conv);
16879         return ret_val;
16880 }
16881
16882 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1announced_1channel(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
16883         LDKChannelConfig this_ptr_conv;
16884         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16885         this_ptr_conv.is_owned = false;
16886         ChannelConfig_set_announced_channel(&this_ptr_conv, val);
16887 }
16888
16889 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1commit_1upfront_1shutdown_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
16890         LDKChannelConfig this_ptr_conv;
16891         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16892         this_ptr_conv.is_owned = false;
16893         jboolean ret_val = ChannelConfig_get_commit_upfront_shutdown_pubkey(&this_ptr_conv);
16894         return ret_val;
16895 }
16896
16897 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1commit_1upfront_1shutdown_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
16898         LDKChannelConfig this_ptr_conv;
16899         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16900         this_ptr_conv.is_owned = false;
16901         ChannelConfig_set_commit_upfront_shutdown_pubkey(&this_ptr_conv, val);
16902 }
16903
16904 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1max_1dust_1htlc_1exposure_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
16905         LDKChannelConfig this_ptr_conv;
16906         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16907         this_ptr_conv.is_owned = false;
16908         int64_t ret_val = ChannelConfig_get_max_dust_htlc_exposure_msat(&this_ptr_conv);
16909         return ret_val;
16910 }
16911
16912 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) {
16913         LDKChannelConfig this_ptr_conv;
16914         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16915         this_ptr_conv.is_owned = false;
16916         ChannelConfig_set_max_dust_htlc_exposure_msat(&this_ptr_conv, val);
16917 }
16918
16919 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) {
16920         LDKChannelConfig this_ptr_conv;
16921         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16922         this_ptr_conv.is_owned = false;
16923         int64_t ret_val = ChannelConfig_get_force_close_avoidance_max_fee_satoshis(&this_ptr_conv);
16924         return ret_val;
16925 }
16926
16927 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) {
16928         LDKChannelConfig this_ptr_conv;
16929         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16930         this_ptr_conv.is_owned = false;
16931         ChannelConfig_set_force_close_avoidance_max_fee_satoshis(&this_ptr_conv, val);
16932 }
16933
16934 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) {
16935         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);
16936         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16937         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16938         uint64_t ret_ref = (uint64_t)ret_var.inner;
16939         if (ret_var.is_owned) {
16940                 ret_ref |= 1;
16941         }
16942         return ret_ref;
16943 }
16944
16945 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16946         LDKChannelConfig orig_conv;
16947         orig_conv.inner = (void*)(orig & (~1));
16948         orig_conv.is_owned = false;
16949         LDKChannelConfig ret_var = ChannelConfig_clone(&orig_conv);
16950         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16951         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16952         uint64_t ret_ref = (uint64_t)ret_var.inner;
16953         if (ret_var.is_owned) {
16954                 ret_ref |= 1;
16955         }
16956         return ret_ref;
16957 }
16958
16959 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1default(JNIEnv *env, jclass clz) {
16960         LDKChannelConfig ret_var = ChannelConfig_default();
16961         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16962         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16963         uint64_t ret_ref = (uint64_t)ret_var.inner;
16964         if (ret_var.is_owned) {
16965                 ret_ref |= 1;
16966         }
16967         return ret_ref;
16968 }
16969
16970 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1write(JNIEnv *env, jclass clz, int64_t obj) {
16971         LDKChannelConfig obj_conv;
16972         obj_conv.inner = (void*)(obj & (~1));
16973         obj_conv.is_owned = false;
16974         LDKCVec_u8Z ret_var = ChannelConfig_write(&obj_conv);
16975         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
16976         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
16977         CVec_u8Z_free(ret_var);
16978         return ret_arr;
16979 }
16980
16981 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
16982         LDKu8slice ser_ref;
16983         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
16984         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
16985         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
16986         *ret_conv = ChannelConfig_read(ser_ref);
16987         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
16988         return (uint64_t)ret_conv;
16989 }
16990
16991 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
16992         LDKUserConfig this_obj_conv;
16993         this_obj_conv.inner = (void*)(this_obj & (~1));
16994         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16995         UserConfig_free(this_obj_conv);
16996 }
16997
16998 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1own_1channel_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
16999         LDKUserConfig this_ptr_conv;
17000         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17001         this_ptr_conv.is_owned = false;
17002         LDKChannelHandshakeConfig ret_var = UserConfig_get_own_channel_config(&this_ptr_conv);
17003         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17004         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17005         uint64_t ret_ref = (uint64_t)ret_var.inner;
17006         if (ret_var.is_owned) {
17007                 ret_ref |= 1;
17008         }
17009         return ret_ref;
17010 }
17011
17012 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1own_1channel_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17013         LDKUserConfig this_ptr_conv;
17014         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17015         this_ptr_conv.is_owned = false;
17016         LDKChannelHandshakeConfig val_conv;
17017         val_conv.inner = (void*)(val & (~1));
17018         val_conv.is_owned = (val & 1) || (val == 0);
17019         val_conv = ChannelHandshakeConfig_clone(&val_conv);
17020         UserConfig_set_own_channel_config(&this_ptr_conv, val_conv);
17021 }
17022
17023 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1peer_1channel_1config_1limits(JNIEnv *env, jclass clz, int64_t this_ptr) {
17024         LDKUserConfig this_ptr_conv;
17025         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17026         this_ptr_conv.is_owned = false;
17027         LDKChannelHandshakeLimits ret_var = UserConfig_get_peer_channel_config_limits(&this_ptr_conv);
17028         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17029         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17030         uint64_t ret_ref = (uint64_t)ret_var.inner;
17031         if (ret_var.is_owned) {
17032                 ret_ref |= 1;
17033         }
17034         return ret_ref;
17035 }
17036
17037 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) {
17038         LDKUserConfig this_ptr_conv;
17039         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17040         this_ptr_conv.is_owned = false;
17041         LDKChannelHandshakeLimits val_conv;
17042         val_conv.inner = (void*)(val & (~1));
17043         val_conv.is_owned = (val & 1) || (val == 0);
17044         val_conv = ChannelHandshakeLimits_clone(&val_conv);
17045         UserConfig_set_peer_channel_config_limits(&this_ptr_conv, val_conv);
17046 }
17047
17048 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1channel_1options(JNIEnv *env, jclass clz, int64_t this_ptr) {
17049         LDKUserConfig this_ptr_conv;
17050         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17051         this_ptr_conv.is_owned = false;
17052         LDKChannelConfig ret_var = UserConfig_get_channel_options(&this_ptr_conv);
17053         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17054         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17055         uint64_t ret_ref = (uint64_t)ret_var.inner;
17056         if (ret_var.is_owned) {
17057                 ret_ref |= 1;
17058         }
17059         return ret_ref;
17060 }
17061
17062 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1channel_1options(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17063         LDKUserConfig this_ptr_conv;
17064         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17065         this_ptr_conv.is_owned = false;
17066         LDKChannelConfig val_conv;
17067         val_conv.inner = (void*)(val & (~1));
17068         val_conv.is_owned = (val & 1) || (val == 0);
17069         val_conv = ChannelConfig_clone(&val_conv);
17070         UserConfig_set_channel_options(&this_ptr_conv, val_conv);
17071 }
17072
17073 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1accept_1forwards_1to_1priv_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
17074         LDKUserConfig this_ptr_conv;
17075         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17076         this_ptr_conv.is_owned = false;
17077         jboolean ret_val = UserConfig_get_accept_forwards_to_priv_channels(&this_ptr_conv);
17078         return ret_val;
17079 }
17080
17081 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) {
17082         LDKUserConfig this_ptr_conv;
17083         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17084         this_ptr_conv.is_owned = false;
17085         UserConfig_set_accept_forwards_to_priv_channels(&this_ptr_conv, val);
17086 }
17087
17088 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) {
17089         LDKChannelHandshakeConfig own_channel_config_arg_conv;
17090         own_channel_config_arg_conv.inner = (void*)(own_channel_config_arg & (~1));
17091         own_channel_config_arg_conv.is_owned = (own_channel_config_arg & 1) || (own_channel_config_arg == 0);
17092         own_channel_config_arg_conv = ChannelHandshakeConfig_clone(&own_channel_config_arg_conv);
17093         LDKChannelHandshakeLimits peer_channel_config_limits_arg_conv;
17094         peer_channel_config_limits_arg_conv.inner = (void*)(peer_channel_config_limits_arg & (~1));
17095         peer_channel_config_limits_arg_conv.is_owned = (peer_channel_config_limits_arg & 1) || (peer_channel_config_limits_arg == 0);
17096         peer_channel_config_limits_arg_conv = ChannelHandshakeLimits_clone(&peer_channel_config_limits_arg_conv);
17097         LDKChannelConfig channel_options_arg_conv;
17098         channel_options_arg_conv.inner = (void*)(channel_options_arg & (~1));
17099         channel_options_arg_conv.is_owned = (channel_options_arg & 1) || (channel_options_arg == 0);
17100         channel_options_arg_conv = ChannelConfig_clone(&channel_options_arg_conv);
17101         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);
17102         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17103         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17104         uint64_t ret_ref = (uint64_t)ret_var.inner;
17105         if (ret_var.is_owned) {
17106                 ret_ref |= 1;
17107         }
17108         return ret_ref;
17109 }
17110
17111 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17112         LDKUserConfig orig_conv;
17113         orig_conv.inner = (void*)(orig & (~1));
17114         orig_conv.is_owned = false;
17115         LDKUserConfig ret_var = UserConfig_clone(&orig_conv);
17116         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17117         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17118         uint64_t ret_ref = (uint64_t)ret_var.inner;
17119         if (ret_var.is_owned) {
17120                 ret_ref |= 1;
17121         }
17122         return ret_ref;
17123 }
17124
17125 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1default(JNIEnv *env, jclass clz) {
17126         LDKUserConfig ret_var = UserConfig_default();
17127         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17128         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17129         uint64_t ret_ref = (uint64_t)ret_var.inner;
17130         if (ret_var.is_owned) {
17131                 ret_ref |= 1;
17132         }
17133         return ret_ref;
17134 }
17135
17136 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BestBlock_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17137         LDKBestBlock this_obj_conv;
17138         this_obj_conv.inner = (void*)(this_obj & (~1));
17139         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17140         BestBlock_free(this_obj_conv);
17141 }
17142
17143 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17144         LDKBestBlock orig_conv;
17145         orig_conv.inner = (void*)(orig & (~1));
17146         orig_conv.is_owned = false;
17147         LDKBestBlock ret_var = BestBlock_clone(&orig_conv);
17148         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17149         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17150         uint64_t ret_ref = (uint64_t)ret_var.inner;
17151         if (ret_var.is_owned) {
17152                 ret_ref |= 1;
17153         }
17154         return ret_ref;
17155 }
17156
17157 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1from_1genesis(JNIEnv *env, jclass clz, jclass network) {
17158         LDKNetwork network_conv = LDKNetwork_from_java(env, network);
17159         LDKBestBlock ret_var = BestBlock_from_genesis(network_conv);
17160         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17161         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17162         uint64_t ret_ref = (uint64_t)ret_var.inner;
17163         if (ret_var.is_owned) {
17164                 ret_ref |= 1;
17165         }
17166         return ret_ref;
17167 }
17168
17169 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1new(JNIEnv *env, jclass clz, int8_tArray block_hash, int32_t height) {
17170         LDKThirtyTwoBytes block_hash_ref;
17171         CHECK((*env)->GetArrayLength(env, block_hash) == 32);
17172         (*env)->GetByteArrayRegion(env, block_hash, 0, 32, block_hash_ref.data);
17173         LDKBestBlock ret_var = BestBlock_new(block_hash_ref, height);
17174         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17175         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17176         uint64_t ret_ref = (uint64_t)ret_var.inner;
17177         if (ret_var.is_owned) {
17178                 ret_ref |= 1;
17179         }
17180         return ret_ref;
17181 }
17182
17183 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BestBlock_1block_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
17184         LDKBestBlock this_arg_conv;
17185         this_arg_conv.inner = (void*)(this_arg & (~1));
17186         this_arg_conv.is_owned = false;
17187         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
17188         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, BestBlock_block_hash(&this_arg_conv).data);
17189         return ret_arr;
17190 }
17191
17192 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1height(JNIEnv *env, jclass clz, int64_t this_arg) {
17193         LDKBestBlock this_arg_conv;
17194         this_arg_conv.inner = (void*)(this_arg & (~1));
17195         this_arg_conv.is_owned = false;
17196         int32_t ret_val = BestBlock_height(&this_arg_conv);
17197         return ret_val;
17198 }
17199
17200 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_AccessError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17201         LDKAccessError* orig_conv = (LDKAccessError*)(orig & ~1);
17202         jclass ret_conv = LDKAccessError_to_java(env, AccessError_clone(orig_conv));
17203         return ret_conv;
17204 }
17205
17206 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_AccessError_1unknown_1chain(JNIEnv *env, jclass clz) {
17207         jclass ret_conv = LDKAccessError_to_java(env, AccessError_unknown_chain());
17208         return ret_conv;
17209 }
17210
17211 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_AccessError_1unknown_1tx(JNIEnv *env, jclass clz) {
17212         jclass ret_conv = LDKAccessError_to_java(env, AccessError_unknown_tx());
17213         return ret_conv;
17214 }
17215
17216 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Access_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
17217         if ((this_ptr & 1) != 0) return;
17218         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
17219         CHECK_ACCESS(this_ptr_ptr);
17220         LDKAccess this_ptr_conv = *(LDKAccess*)(this_ptr_ptr);
17221         FREE((void*)this_ptr);
17222         Access_free(this_ptr_conv);
17223 }
17224
17225 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Listen_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
17226         if ((this_ptr & 1) != 0) return;
17227         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
17228         CHECK_ACCESS(this_ptr_ptr);
17229         LDKListen this_ptr_conv = *(LDKListen*)(this_ptr_ptr);
17230         FREE((void*)this_ptr);
17231         Listen_free(this_ptr_conv);
17232 }
17233
17234 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Confirm_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
17235         if ((this_ptr & 1) != 0) return;
17236         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
17237         CHECK_ACCESS(this_ptr_ptr);
17238         LDKConfirm this_ptr_conv = *(LDKConfirm*)(this_ptr_ptr);
17239         FREE((void*)this_ptr);
17240         Confirm_free(this_ptr_conv);
17241 }
17242
17243 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateErr_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17244         LDKChannelMonitorUpdateErr* orig_conv = (LDKChannelMonitorUpdateErr*)(orig & ~1);
17245         jclass ret_conv = LDKChannelMonitorUpdateErr_to_java(env, ChannelMonitorUpdateErr_clone(orig_conv));
17246         return ret_conv;
17247 }
17248
17249 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateErr_1temporary_1failure(JNIEnv *env, jclass clz) {
17250         jclass ret_conv = LDKChannelMonitorUpdateErr_to_java(env, ChannelMonitorUpdateErr_temporary_failure());
17251         return ret_conv;
17252 }
17253
17254 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateErr_1permanent_1failure(JNIEnv *env, jclass clz) {
17255         jclass ret_conv = LDKChannelMonitorUpdateErr_to_java(env, ChannelMonitorUpdateErr_permanent_failure());
17256         return ret_conv;
17257 }
17258
17259 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Watch_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
17260         if ((this_ptr & 1) != 0) return;
17261         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
17262         CHECK_ACCESS(this_ptr_ptr);
17263         LDKWatch this_ptr_conv = *(LDKWatch*)(this_ptr_ptr);
17264         FREE((void*)this_ptr);
17265         Watch_free(this_ptr_conv);
17266 }
17267
17268 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Filter_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
17269         if ((this_ptr & 1) != 0) return;
17270         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
17271         CHECK_ACCESS(this_ptr_ptr);
17272         LDKFilter this_ptr_conv = *(LDKFilter*)(this_ptr_ptr);
17273         FREE((void*)this_ptr);
17274         Filter_free(this_ptr_conv);
17275 }
17276
17277 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17278         LDKWatchedOutput this_obj_conv;
17279         this_obj_conv.inner = (void*)(this_obj & (~1));
17280         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17281         WatchedOutput_free(this_obj_conv);
17282 }
17283
17284 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1block_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
17285         LDKWatchedOutput this_ptr_conv;
17286         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17287         this_ptr_conv.is_owned = false;
17288         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
17289         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, WatchedOutput_get_block_hash(&this_ptr_conv).data);
17290         return ret_arr;
17291 }
17292
17293 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1block_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17294         LDKWatchedOutput this_ptr_conv;
17295         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17296         this_ptr_conv.is_owned = false;
17297         LDKThirtyTwoBytes val_ref;
17298         CHECK((*env)->GetArrayLength(env, val) == 32);
17299         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
17300         WatchedOutput_set_block_hash(&this_ptr_conv, val_ref);
17301 }
17302
17303 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
17304         LDKWatchedOutput this_ptr_conv;
17305         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17306         this_ptr_conv.is_owned = false;
17307         LDKOutPoint ret_var = WatchedOutput_get_outpoint(&this_ptr_conv);
17308         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17309         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17310         uint64_t ret_ref = (uint64_t)ret_var.inner;
17311         if (ret_var.is_owned) {
17312                 ret_ref |= 1;
17313         }
17314         return ret_ref;
17315 }
17316
17317 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17318         LDKWatchedOutput this_ptr_conv;
17319         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17320         this_ptr_conv.is_owned = false;
17321         LDKOutPoint val_conv;
17322         val_conv.inner = (void*)(val & (~1));
17323         val_conv.is_owned = (val & 1) || (val == 0);
17324         val_conv = OutPoint_clone(&val_conv);
17325         WatchedOutput_set_outpoint(&this_ptr_conv, val_conv);
17326 }
17327
17328 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1script_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
17329         LDKWatchedOutput this_ptr_conv;
17330         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17331         this_ptr_conv.is_owned = false;
17332         LDKu8slice ret_var = WatchedOutput_get_script_pubkey(&this_ptr_conv);
17333         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17334         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17335         return ret_arr;
17336 }
17337
17338 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1script_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17339         LDKWatchedOutput this_ptr_conv;
17340         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17341         this_ptr_conv.is_owned = false;
17342         LDKCVec_u8Z val_ref;
17343         val_ref.datalen = (*env)->GetArrayLength(env, val);
17344         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
17345         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
17346         WatchedOutput_set_script_pubkey(&this_ptr_conv, val_ref);
17347 }
17348
17349 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) {
17350         LDKThirtyTwoBytes block_hash_arg_ref;
17351         CHECK((*env)->GetArrayLength(env, block_hash_arg) == 32);
17352         (*env)->GetByteArrayRegion(env, block_hash_arg, 0, 32, block_hash_arg_ref.data);
17353         LDKOutPoint outpoint_arg_conv;
17354         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
17355         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
17356         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
17357         LDKCVec_u8Z script_pubkey_arg_ref;
17358         script_pubkey_arg_ref.datalen = (*env)->GetArrayLength(env, script_pubkey_arg);
17359         script_pubkey_arg_ref.data = MALLOC(script_pubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
17360         (*env)->GetByteArrayRegion(env, script_pubkey_arg, 0, script_pubkey_arg_ref.datalen, script_pubkey_arg_ref.data);
17361         LDKWatchedOutput ret_var = WatchedOutput_new(block_hash_arg_ref, outpoint_arg_conv, script_pubkey_arg_ref);
17362         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17363         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17364         uint64_t ret_ref = (uint64_t)ret_var.inner;
17365         if (ret_var.is_owned) {
17366                 ret_ref |= 1;
17367         }
17368         return ret_ref;
17369 }
17370
17371 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17372         LDKWatchedOutput orig_conv;
17373         orig_conv.inner = (void*)(orig & (~1));
17374         orig_conv.is_owned = false;
17375         LDKWatchedOutput ret_var = WatchedOutput_clone(&orig_conv);
17376         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17377         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17378         uint64_t ret_ref = (uint64_t)ret_var.inner;
17379         if (ret_var.is_owned) {
17380                 ret_ref |= 1;
17381         }
17382         return ret_ref;
17383 }
17384
17385 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1hash(JNIEnv *env, jclass clz, int64_t o) {
17386         LDKWatchedOutput o_conv;
17387         o_conv.inner = (void*)(o & (~1));
17388         o_conv.is_owned = false;
17389         int64_t ret_val = WatchedOutput_hash(&o_conv);
17390         return ret_val;
17391 }
17392
17393 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BroadcasterInterface_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
17394         if ((this_ptr & 1) != 0) return;
17395         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
17396         CHECK_ACCESS(this_ptr_ptr);
17397         LDKBroadcasterInterface this_ptr_conv = *(LDKBroadcasterInterface*)(this_ptr_ptr);
17398         FREE((void*)this_ptr);
17399         BroadcasterInterface_free(this_ptr_conv);
17400 }
17401
17402 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17403         LDKConfirmationTarget* orig_conv = (LDKConfirmationTarget*)(orig & ~1);
17404         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_clone(orig_conv));
17405         return ret_conv;
17406 }
17407
17408 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1background(JNIEnv *env, jclass clz) {
17409         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_background());
17410         return ret_conv;
17411 }
17412
17413 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1normal(JNIEnv *env, jclass clz) {
17414         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_normal());
17415         return ret_conv;
17416 }
17417
17418 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1high_1priority(JNIEnv *env, jclass clz) {
17419         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_high_priority());
17420         return ret_conv;
17421 }
17422
17423 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
17424         LDKConfirmationTarget* a_conv = (LDKConfirmationTarget*)(a & ~1);
17425         LDKConfirmationTarget* b_conv = (LDKConfirmationTarget*)(b & ~1);
17426         jboolean ret_val = ConfirmationTarget_eq(a_conv, b_conv);
17427         return ret_val;
17428 }
17429
17430 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FeeEstimator_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
17431         if ((this_ptr & 1) != 0) return;
17432         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
17433         CHECK_ACCESS(this_ptr_ptr);
17434         LDKFeeEstimator this_ptr_conv = *(LDKFeeEstimator*)(this_ptr_ptr);
17435         FREE((void*)this_ptr);
17436         FeeEstimator_free(this_ptr_conv);
17437 }
17438
17439 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Persist_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
17440         if ((this_ptr & 1) != 0) return;
17441         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
17442         CHECK_ACCESS(this_ptr_ptr);
17443         LDKPersist this_ptr_conv = *(LDKPersist*)(this_ptr_ptr);
17444         FREE((void*)this_ptr);
17445         Persist_free(this_ptr_conv);
17446 }
17447
17448 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LockedChannelMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17449         LDKLockedChannelMonitor this_obj_conv;
17450         this_obj_conv.inner = (void*)(this_obj & (~1));
17451         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17452         LockedChannelMonitor_free(this_obj_conv);
17453 }
17454
17455 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17456         LDKChainMonitor this_obj_conv;
17457         this_obj_conv.inner = (void*)(this_obj & (~1));
17458         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17459         ChainMonitor_free(this_obj_conv);
17460 }
17461
17462 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) {
17463         void* chain_source_ptr = (void*)(((uint64_t)chain_source) & ~1);
17464         CHECK_ACCESS(chain_source_ptr);
17465         LDKCOption_FilterZ chain_source_conv = *(LDKCOption_FilterZ*)(chain_source_ptr);
17466         // Warning: we may need a move here but no clone is available for LDKCOption_FilterZ
17467         if (chain_source_conv.tag == LDKCOption_FilterZ_Some) {
17468                 // Manually implement clone for Java trait instances
17469                 if (chain_source_conv.some.free == LDKFilter_JCalls_free) {
17470                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
17471                         LDKFilter_JCalls_cloned(&chain_source_conv.some);
17472                 }
17473         }
17474         void* broadcaster_ptr = (void*)(((uint64_t)broadcaster) & ~1);
17475         CHECK_ACCESS(broadcaster_ptr);
17476         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
17477         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
17478                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
17479                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
17480         }
17481         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
17482         CHECK_ACCESS(logger_ptr);
17483         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
17484         if (logger_conv.free == LDKLogger_JCalls_free) {
17485                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
17486                 LDKLogger_JCalls_cloned(&logger_conv);
17487         }
17488         void* feeest_ptr = (void*)(((uint64_t)feeest) & ~1);
17489         CHECK_ACCESS(feeest_ptr);
17490         LDKFeeEstimator feeest_conv = *(LDKFeeEstimator*)(feeest_ptr);
17491         if (feeest_conv.free == LDKFeeEstimator_JCalls_free) {
17492                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
17493                 LDKFeeEstimator_JCalls_cloned(&feeest_conv);
17494         }
17495         void* persister_ptr = (void*)(((uint64_t)persister) & ~1);
17496         CHECK_ACCESS(persister_ptr);
17497         LDKPersist persister_conv = *(LDKPersist*)(persister_ptr);
17498         if (persister_conv.free == LDKPersist_JCalls_free) {
17499                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
17500                 LDKPersist_JCalls_cloned(&persister_conv);
17501         }
17502         LDKChainMonitor ret_var = ChainMonitor_new(chain_source_conv, broadcaster_conv, logger_conv, feeest_conv, persister_conv);
17503         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17504         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17505         uint64_t ret_ref = (uint64_t)ret_var.inner;
17506         if (ret_var.is_owned) {
17507                 ret_ref |= 1;
17508         }
17509         return ret_ref;
17510 }
17511
17512 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) {
17513         LDKChainMonitor this_arg_conv;
17514         this_arg_conv.inner = (void*)(this_arg & (~1));
17515         this_arg_conv.is_owned = false;
17516         LDKCVec_ChannelDetailsZ ignored_channels_constr;
17517         ignored_channels_constr.datalen = (*env)->GetArrayLength(env, ignored_channels);
17518         if (ignored_channels_constr.datalen > 0)
17519                 ignored_channels_constr.data = MALLOC(ignored_channels_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
17520         else
17521                 ignored_channels_constr.data = NULL;
17522         int64_t* ignored_channels_vals = (*env)->GetLongArrayElements (env, ignored_channels, NULL);
17523         for (size_t q = 0; q < ignored_channels_constr.datalen; q++) {
17524                 int64_t ignored_channels_conv_16 = ignored_channels_vals[q];
17525                 LDKChannelDetails ignored_channels_conv_16_conv;
17526                 ignored_channels_conv_16_conv.inner = (void*)(ignored_channels_conv_16 & (~1));
17527                 ignored_channels_conv_16_conv.is_owned = (ignored_channels_conv_16 & 1) || (ignored_channels_conv_16 == 0);
17528                 ignored_channels_conv_16_conv = ChannelDetails_clone(&ignored_channels_conv_16_conv);
17529                 ignored_channels_constr.data[q] = ignored_channels_conv_16_conv;
17530         }
17531         (*env)->ReleaseLongArrayElements(env, ignored_channels, ignored_channels_vals, 0);
17532         LDKCVec_BalanceZ ret_var = ChainMonitor_get_claimable_balances(&this_arg_conv, ignored_channels_constr);
17533         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
17534         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
17535         for (size_t j = 0; j < ret_var.datalen; j++) {
17536                 LDKBalance *ret_conv_9_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
17537                 *ret_conv_9_copy = ret_var.data[j];
17538                 uint64_t ret_conv_9_ref = (uint64_t)ret_conv_9_copy;
17539                 ret_arr_ptr[j] = ret_conv_9_ref;
17540         }
17541         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
17542         FREE(ret_var.data);
17543         return ret_arr;
17544 }
17545
17546 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1get_1monitor(JNIEnv *env, jclass clz, int64_t this_arg, int64_t funding_txo) {
17547         LDKChainMonitor this_arg_conv;
17548         this_arg_conv.inner = (void*)(this_arg & (~1));
17549         this_arg_conv.is_owned = false;
17550         LDKOutPoint funding_txo_conv;
17551         funding_txo_conv.inner = (void*)(funding_txo & (~1));
17552         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
17553         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
17554         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
17555         *ret_conv = ChainMonitor_get_monitor(&this_arg_conv, funding_txo_conv);
17556         return (uint64_t)ret_conv;
17557 }
17558
17559 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1list_1monitors(JNIEnv *env, jclass clz, int64_t this_arg) {
17560         LDKChainMonitor this_arg_conv;
17561         this_arg_conv.inner = (void*)(this_arg & (~1));
17562         this_arg_conv.is_owned = false;
17563         LDKCVec_OutPointZ ret_var = ChainMonitor_list_monitors(&this_arg_conv);
17564         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
17565         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
17566         for (size_t k = 0; k < ret_var.datalen; k++) {
17567                 LDKOutPoint ret_conv_10_var = ret_var.data[k];
17568                 CHECK((((uint64_t)ret_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17569                 CHECK((((uint64_t)&ret_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17570                 uint64_t ret_conv_10_ref = (uint64_t)ret_conv_10_var.inner;
17571                 if (ret_conv_10_var.is_owned) {
17572                         ret_conv_10_ref |= 1;
17573                 }
17574                 ret_arr_ptr[k] = ret_conv_10_ref;
17575         }
17576         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
17577         FREE(ret_var.data);
17578         return ret_arr;
17579 }
17580
17581 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Listen(JNIEnv *env, jclass clz, int64_t this_arg) {
17582         LDKChainMonitor this_arg_conv;
17583         this_arg_conv.inner = (void*)(this_arg & (~1));
17584         this_arg_conv.is_owned = false;
17585         LDKListen* ret_ret =MALLOC(sizeof(LDKListen), "LDKListen");
17586         *ret_ret = ChainMonitor_as_Listen(&this_arg_conv);
17587         return (uint64_t)ret_ret;
17588 }
17589
17590 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Confirm(JNIEnv *env, jclass clz, int64_t this_arg) {
17591         LDKChainMonitor this_arg_conv;
17592         this_arg_conv.inner = (void*)(this_arg & (~1));
17593         this_arg_conv.is_owned = false;
17594         LDKConfirm* ret_ret =MALLOC(sizeof(LDKConfirm), "LDKConfirm");
17595         *ret_ret = ChainMonitor_as_Confirm(&this_arg_conv);
17596         return (uint64_t)ret_ret;
17597 }
17598
17599 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Watch(JNIEnv *env, jclass clz, int64_t this_arg) {
17600         LDKChainMonitor this_arg_conv;
17601         this_arg_conv.inner = (void*)(this_arg & (~1));
17602         this_arg_conv.is_owned = false;
17603         LDKWatch* ret_ret =MALLOC(sizeof(LDKWatch), "LDKWatch");
17604         *ret_ret = ChainMonitor_as_Watch(&this_arg_conv);
17605         return (uint64_t)ret_ret;
17606 }
17607
17608 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1EventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
17609         LDKChainMonitor this_arg_conv;
17610         this_arg_conv.inner = (void*)(this_arg & (~1));
17611         this_arg_conv.is_owned = false;
17612         LDKEventsProvider* ret_ret =MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
17613         *ret_ret = ChainMonitor_as_EventsProvider(&this_arg_conv);
17614         return (uint64_t)ret_ret;
17615 }
17616
17617 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17618         LDKChannelMonitorUpdate this_obj_conv;
17619         this_obj_conv.inner = (void*)(this_obj & (~1));
17620         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17621         ChannelMonitorUpdate_free(this_obj_conv);
17622 }
17623
17624 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1get_1update_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
17625         LDKChannelMonitorUpdate this_ptr_conv;
17626         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17627         this_ptr_conv.is_owned = false;
17628         int64_t ret_val = ChannelMonitorUpdate_get_update_id(&this_ptr_conv);
17629         return ret_val;
17630 }
17631
17632 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1set_1update_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17633         LDKChannelMonitorUpdate this_ptr_conv;
17634         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17635         this_ptr_conv.is_owned = false;
17636         ChannelMonitorUpdate_set_update_id(&this_ptr_conv, val);
17637 }
17638
17639 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17640         LDKChannelMonitorUpdate orig_conv;
17641         orig_conv.inner = (void*)(orig & (~1));
17642         orig_conv.is_owned = false;
17643         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(&orig_conv);
17644         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17645         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17646         uint64_t ret_ref = (uint64_t)ret_var.inner;
17647         if (ret_var.is_owned) {
17648                 ret_ref |= 1;
17649         }
17650         return ret_ref;
17651 }
17652
17653 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
17654         LDKChannelMonitorUpdate obj_conv;
17655         obj_conv.inner = (void*)(obj & (~1));
17656         obj_conv.is_owned = false;
17657         LDKCVec_u8Z ret_var = ChannelMonitorUpdate_write(&obj_conv);
17658         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17659         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17660         CVec_u8Z_free(ret_var);
17661         return ret_arr;
17662 }
17663
17664 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17665         LDKu8slice ser_ref;
17666         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17667         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17668         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
17669         *ret_conv = ChannelMonitorUpdate_read(ser_ref);
17670         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17671         return (uint64_t)ret_conv;
17672 }
17673
17674 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorUpdateError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17675         LDKMonitorUpdateError this_obj_conv;
17676         this_obj_conv.inner = (void*)(this_obj & (~1));
17677         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17678         MonitorUpdateError_free(this_obj_conv);
17679 }
17680
17681 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorUpdateError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17682         LDKMonitorUpdateError orig_conv;
17683         orig_conv.inner = (void*)(orig & (~1));
17684         orig_conv.is_owned = false;
17685         LDKMonitorUpdateError ret_var = MonitorUpdateError_clone(&orig_conv);
17686         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17687         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17688         uint64_t ret_ref = (uint64_t)ret_var.inner;
17689         if (ret_var.is_owned) {
17690                 ret_ref |= 1;
17691         }
17692         return ret_ref;
17693 }
17694
17695 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
17696         if ((this_ptr & 1) != 0) return;
17697         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
17698         CHECK_ACCESS(this_ptr_ptr);
17699         LDKMonitorEvent this_ptr_conv = *(LDKMonitorEvent*)(this_ptr_ptr);
17700         FREE((void*)this_ptr);
17701         MonitorEvent_free(this_ptr_conv);
17702 }
17703
17704 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17705         LDKMonitorEvent* orig_conv = (LDKMonitorEvent*)orig;
17706         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
17707         *ret_copy = MonitorEvent_clone(orig_conv);
17708         uint64_t ret_ref = (uint64_t)ret_copy;
17709         return ret_ref;
17710 }
17711
17712 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1htlcevent(JNIEnv *env, jclass clz, int64_t a) {
17713         LDKHTLCUpdate a_conv;
17714         a_conv.inner = (void*)(a & (~1));
17715         a_conv.is_owned = (a & 1) || (a == 0);
17716         a_conv = HTLCUpdate_clone(&a_conv);
17717         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
17718         *ret_copy = MonitorEvent_htlcevent(a_conv);
17719         uint64_t ret_ref = (uint64_t)ret_copy;
17720         return ret_ref;
17721 }
17722
17723 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1commitment_1tx_1confirmed(JNIEnv *env, jclass clz, int64_t a) {
17724         LDKOutPoint a_conv;
17725         a_conv.inner = (void*)(a & (~1));
17726         a_conv.is_owned = (a & 1) || (a == 0);
17727         a_conv = OutPoint_clone(&a_conv);
17728         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
17729         *ret_copy = MonitorEvent_commitment_tx_confirmed(a_conv);
17730         uint64_t ret_ref = (uint64_t)ret_copy;
17731         return ret_ref;
17732 }
17733
17734 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17735         LDKHTLCUpdate this_obj_conv;
17736         this_obj_conv.inner = (void*)(this_obj & (~1));
17737         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17738         HTLCUpdate_free(this_obj_conv);
17739 }
17740
17741 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17742         LDKHTLCUpdate orig_conv;
17743         orig_conv.inner = (void*)(orig & (~1));
17744         orig_conv.is_owned = false;
17745         LDKHTLCUpdate ret_var = HTLCUpdate_clone(&orig_conv);
17746         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17747         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17748         uint64_t ret_ref = (uint64_t)ret_var.inner;
17749         if (ret_var.is_owned) {
17750                 ret_ref |= 1;
17751         }
17752         return ret_ref;
17753 }
17754
17755 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
17756         LDKHTLCUpdate obj_conv;
17757         obj_conv.inner = (void*)(obj & (~1));
17758         obj_conv.is_owned = false;
17759         LDKCVec_u8Z ret_var = HTLCUpdate_write(&obj_conv);
17760         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17761         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17762         CVec_u8Z_free(ret_var);
17763         return ret_arr;
17764 }
17765
17766 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17767         LDKu8slice ser_ref;
17768         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17769         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17770         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
17771         *ret_conv = HTLCUpdate_read(ser_ref);
17772         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17773         return (uint64_t)ret_conv;
17774 }
17775
17776 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Balance_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
17777         if ((this_ptr & 1) != 0) return;
17778         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
17779         CHECK_ACCESS(this_ptr_ptr);
17780         LDKBalance this_ptr_conv = *(LDKBalance*)(this_ptr_ptr);
17781         FREE((void*)this_ptr);
17782         Balance_free(this_ptr_conv);
17783 }
17784
17785 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17786         LDKBalance* orig_conv = (LDKBalance*)orig;
17787         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
17788         *ret_copy = Balance_clone(orig_conv);
17789         uint64_t ret_ref = (uint64_t)ret_copy;
17790         return ret_ref;
17791 }
17792
17793 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1claimable_1on_1channel_1close(JNIEnv *env, jclass clz, int64_t claimable_amount_satoshis) {
17794         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
17795         *ret_copy = Balance_claimable_on_channel_close(claimable_amount_satoshis);
17796         uint64_t ret_ref = (uint64_t)ret_copy;
17797         return ret_ref;
17798 }
17799
17800 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) {
17801         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
17802         *ret_copy = Balance_claimable_awaiting_confirmations(claimable_amount_satoshis, confirmation_height);
17803         uint64_t ret_ref = (uint64_t)ret_copy;
17804         return ret_ref;
17805 }
17806
17807 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) {
17808         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
17809         *ret_copy = Balance_contentious_claimable(claimable_amount_satoshis, timeout_height);
17810         uint64_t ret_ref = (uint64_t)ret_copy;
17811         return ret_ref;
17812 }
17813
17814 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) {
17815         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
17816         *ret_copy = Balance_maybe_claimable_htlcawaiting_timeout(claimable_amount_satoshis, claimable_height);
17817         uint64_t ret_ref = (uint64_t)ret_copy;
17818         return ret_ref;
17819 }
17820
17821 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Balance_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
17822         LDKBalance* a_conv = (LDKBalance*)a;
17823         LDKBalance* b_conv = (LDKBalance*)b;
17824         jboolean ret_val = Balance_eq(a_conv, b_conv);
17825         return ret_val;
17826 }
17827
17828 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17829         LDKChannelMonitor this_obj_conv;
17830         this_obj_conv.inner = (void*)(this_obj & (~1));
17831         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17832         ChannelMonitor_free(this_obj_conv);
17833 }
17834
17835 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17836         LDKChannelMonitor orig_conv;
17837         orig_conv.inner = (void*)(orig & (~1));
17838         orig_conv.is_owned = false;
17839         LDKChannelMonitor ret_var = ChannelMonitor_clone(&orig_conv);
17840         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17841         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17842         uint64_t ret_ref = (uint64_t)ret_var.inner;
17843         if (ret_var.is_owned) {
17844                 ret_ref |= 1;
17845         }
17846         return ret_ref;
17847 }
17848
17849 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1write(JNIEnv *env, jclass clz, int64_t obj) {
17850         LDKChannelMonitor obj_conv;
17851         obj_conv.inner = (void*)(obj & (~1));
17852         obj_conv.is_owned = false;
17853         LDKCVec_u8Z ret_var = ChannelMonitor_write(&obj_conv);
17854         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17855         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17856         CVec_u8Z_free(ret_var);
17857         return ret_arr;
17858 }
17859
17860 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) {
17861         LDKChannelMonitor this_arg_conv;
17862         this_arg_conv.inner = (void*)(this_arg & (~1));
17863         this_arg_conv.is_owned = false;
17864         LDKChannelMonitorUpdate updates_conv;
17865         updates_conv.inner = (void*)(updates & (~1));
17866         updates_conv.is_owned = false;
17867         void* broadcaster_ptr = (void*)(((uint64_t)broadcaster) & ~1);
17868         if (!(broadcaster & 1)) { CHECK_ACCESS(broadcaster_ptr); }
17869         LDKBroadcasterInterface* broadcaster_conv = (LDKBroadcasterInterface*)broadcaster_ptr;
17870         void* fee_estimator_ptr = (void*)(((uint64_t)fee_estimator) & ~1);
17871         if (!(fee_estimator & 1)) { CHECK_ACCESS(fee_estimator_ptr); }
17872         LDKFeeEstimator* fee_estimator_conv = (LDKFeeEstimator*)fee_estimator_ptr;
17873         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
17874         if (!(logger & 1)) { CHECK_ACCESS(logger_ptr); }
17875         LDKLogger* logger_conv = (LDKLogger*)logger_ptr;
17876         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
17877         *ret_conv = ChannelMonitor_update_monitor(&this_arg_conv, &updates_conv, broadcaster_conv, fee_estimator_conv, logger_conv);
17878         return (uint64_t)ret_conv;
17879 }
17880
17881 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1latest_1update_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
17882         LDKChannelMonitor this_arg_conv;
17883         this_arg_conv.inner = (void*)(this_arg & (~1));
17884         this_arg_conv.is_owned = false;
17885         int64_t ret_val = ChannelMonitor_get_latest_update_id(&this_arg_conv);
17886         return ret_val;
17887 }
17888
17889 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_arg) {
17890         LDKChannelMonitor this_arg_conv;
17891         this_arg_conv.inner = (void*)(this_arg & (~1));
17892         this_arg_conv.is_owned = false;
17893         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
17894         *ret_conv = ChannelMonitor_get_funding_txo(&this_arg_conv);
17895         return ((uint64_t)ret_conv);
17896 }
17897
17898 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1outputs_1to_1watch(JNIEnv *env, jclass clz, int64_t this_arg) {
17899         LDKChannelMonitor this_arg_conv;
17900         this_arg_conv.inner = (void*)(this_arg & (~1));
17901         this_arg_conv.is_owned = false;
17902         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ ret_var = ChannelMonitor_get_outputs_to_watch(&this_arg_conv);
17903         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
17904         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
17905         for (size_t o = 0; o < ret_var.datalen; o++) {
17906                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv_40_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
17907                 *ret_conv_40_conv = ret_var.data[o];
17908                 ret_arr_ptr[o] = ((uint64_t)ret_conv_40_conv);
17909         }
17910         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
17911         FREE(ret_var.data);
17912         return ret_arr;
17913 }
17914
17915 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1load_1outputs_1to_1watch(JNIEnv *env, jclass clz, int64_t this_arg, int64_t filter) {
17916         LDKChannelMonitor this_arg_conv;
17917         this_arg_conv.inner = (void*)(this_arg & (~1));
17918         this_arg_conv.is_owned = false;
17919         void* filter_ptr = (void*)(((uint64_t)filter) & ~1);
17920         if (!(filter & 1)) { CHECK_ACCESS(filter_ptr); }
17921         LDKFilter* filter_conv = (LDKFilter*)filter_ptr;
17922         ChannelMonitor_load_outputs_to_watch(&this_arg_conv, filter_conv);
17923 }
17924
17925 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1and_1clear_1pending_1monitor_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
17926         LDKChannelMonitor this_arg_conv;
17927         this_arg_conv.inner = (void*)(this_arg & (~1));
17928         this_arg_conv.is_owned = false;
17929         LDKCVec_MonitorEventZ ret_var = ChannelMonitor_get_and_clear_pending_monitor_events(&this_arg_conv);
17930         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
17931         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
17932         for (size_t o = 0; o < ret_var.datalen; o++) {
17933                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
17934                 *ret_conv_14_copy = ret_var.data[o];
17935                 uint64_t ret_conv_14_ref = (uint64_t)ret_conv_14_copy;
17936                 ret_arr_ptr[o] = ret_conv_14_ref;
17937         }
17938         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
17939         FREE(ret_var.data);
17940         return ret_arr;
17941 }
17942
17943 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1and_1clear_1pending_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
17944         LDKChannelMonitor this_arg_conv;
17945         this_arg_conv.inner = (void*)(this_arg & (~1));
17946         this_arg_conv.is_owned = false;
17947         LDKCVec_EventZ ret_var = ChannelMonitor_get_and_clear_pending_events(&this_arg_conv);
17948         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
17949         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
17950         for (size_t h = 0; h < ret_var.datalen; h++) {
17951                 LDKEvent *ret_conv_7_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
17952                 *ret_conv_7_copy = ret_var.data[h];
17953                 uint64_t ret_conv_7_ref = (uint64_t)ret_conv_7_copy;
17954                 ret_arr_ptr[h] = ret_conv_7_ref;
17955         }
17956         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
17957         FREE(ret_var.data);
17958         return ret_arr;
17959 }
17960
17961 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) {
17962         LDKChannelMonitor this_arg_conv;
17963         this_arg_conv.inner = (void*)(this_arg & (~1));
17964         this_arg_conv.is_owned = false;
17965         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
17966         if (!(logger & 1)) { CHECK_ACCESS(logger_ptr); }
17967         LDKLogger* logger_conv = (LDKLogger*)logger_ptr;
17968         LDKCVec_TransactionZ ret_var = ChannelMonitor_get_latest_holder_commitment_txn(&this_arg_conv, logger_conv);
17969         jobjectArray ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
17970         ;
17971         for (size_t i = 0; i < ret_var.datalen; i++) {
17972                 LDKTransaction ret_conv_8_var = ret_var.data[i];
17973                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, ret_conv_8_var.datalen);
17974                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, ret_conv_8_var.datalen, ret_conv_8_var.data);
17975                 Transaction_free(ret_conv_8_var);
17976                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
17977         }
17978         FREE(ret_var.data);
17979         return ret_arr;
17980 }
17981
17982 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) {
17983         LDKChannelMonitor this_arg_conv;
17984         this_arg_conv.inner = (void*)(this_arg & (~1));
17985         this_arg_conv.is_owned = false;
17986         unsigned char header_arr[80];
17987         CHECK((*env)->GetArrayLength(env, header) == 80);
17988         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
17989         unsigned char (*header_ref)[80] = &header_arr;
17990         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
17991         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
17992         if (txdata_constr.datalen > 0)
17993                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
17994         else
17995                 txdata_constr.data = NULL;
17996         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
17997         for (size_t c = 0; c < txdata_constr.datalen; c++) {
17998                 int64_t txdata_conv_28 = txdata_vals[c];
17999                 void* txdata_conv_28_ptr = (void*)(((uint64_t)txdata_conv_28) & ~1);
18000                 CHECK_ACCESS(txdata_conv_28_ptr);
18001                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
18002                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_28) & ~1));
18003                 txdata_constr.data[c] = txdata_conv_28_conv;
18004         }
18005         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
18006         void* broadcaster_ptr = (void*)(((uint64_t)broadcaster) & ~1);
18007         CHECK_ACCESS(broadcaster_ptr);
18008         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
18009         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
18010                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
18011                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
18012         }
18013         void* fee_estimator_ptr = (void*)(((uint64_t)fee_estimator) & ~1);
18014         CHECK_ACCESS(fee_estimator_ptr);
18015         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
18016         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
18017                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
18018                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
18019         }
18020         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
18021         CHECK_ACCESS(logger_ptr);
18022         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
18023         if (logger_conv.free == LDKLogger_JCalls_free) {
18024                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
18025                 LDKLogger_JCalls_cloned(&logger_conv);
18026         }
18027         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);
18028         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
18029         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
18030         for (size_t n = 0; n < ret_var.datalen; n++) {
18031                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
18032                 *ret_conv_39_conv = ret_var.data[n];
18033                 ret_arr_ptr[n] = ((uint64_t)ret_conv_39_conv);
18034         }
18035         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
18036         FREE(ret_var.data);
18037         return ret_arr;
18038 }
18039
18040 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) {
18041         LDKChannelMonitor this_arg_conv;
18042         this_arg_conv.inner = (void*)(this_arg & (~1));
18043         this_arg_conv.is_owned = false;
18044         unsigned char header_arr[80];
18045         CHECK((*env)->GetArrayLength(env, header) == 80);
18046         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
18047         unsigned char (*header_ref)[80] = &header_arr;
18048         void* broadcaster_ptr = (void*)(((uint64_t)broadcaster) & ~1);
18049         CHECK_ACCESS(broadcaster_ptr);
18050         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
18051         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
18052                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
18053                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
18054         }
18055         void* fee_estimator_ptr = (void*)(((uint64_t)fee_estimator) & ~1);
18056         CHECK_ACCESS(fee_estimator_ptr);
18057         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
18058         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
18059                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
18060                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
18061         }
18062         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
18063         CHECK_ACCESS(logger_ptr);
18064         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
18065         if (logger_conv.free == LDKLogger_JCalls_free) {
18066                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
18067                 LDKLogger_JCalls_cloned(&logger_conv);
18068         }
18069         ChannelMonitor_block_disconnected(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
18070 }
18071
18072 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) {
18073         LDKChannelMonitor this_arg_conv;
18074         this_arg_conv.inner = (void*)(this_arg & (~1));
18075         this_arg_conv.is_owned = false;
18076         unsigned char header_arr[80];
18077         CHECK((*env)->GetArrayLength(env, header) == 80);
18078         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
18079         unsigned char (*header_ref)[80] = &header_arr;
18080         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
18081         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
18082         if (txdata_constr.datalen > 0)
18083                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
18084         else
18085                 txdata_constr.data = NULL;
18086         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
18087         for (size_t c = 0; c < txdata_constr.datalen; c++) {
18088                 int64_t txdata_conv_28 = txdata_vals[c];
18089                 void* txdata_conv_28_ptr = (void*)(((uint64_t)txdata_conv_28) & ~1);
18090                 CHECK_ACCESS(txdata_conv_28_ptr);
18091                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
18092                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_28) & ~1));
18093                 txdata_constr.data[c] = txdata_conv_28_conv;
18094         }
18095         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
18096         void* broadcaster_ptr = (void*)(((uint64_t)broadcaster) & ~1);
18097         CHECK_ACCESS(broadcaster_ptr);
18098         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
18099         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
18100                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
18101                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
18102         }
18103         void* fee_estimator_ptr = (void*)(((uint64_t)fee_estimator) & ~1);
18104         CHECK_ACCESS(fee_estimator_ptr);
18105         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
18106         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
18107                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
18108                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
18109         }
18110         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
18111         CHECK_ACCESS(logger_ptr);
18112         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
18113         if (logger_conv.free == LDKLogger_JCalls_free) {
18114                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
18115                 LDKLogger_JCalls_cloned(&logger_conv);
18116         }
18117         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);
18118         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
18119         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
18120         for (size_t n = 0; n < ret_var.datalen; n++) {
18121                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
18122                 *ret_conv_39_conv = ret_var.data[n];
18123                 ret_arr_ptr[n] = ((uint64_t)ret_conv_39_conv);
18124         }
18125         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
18126         FREE(ret_var.data);
18127         return ret_arr;
18128 }
18129
18130 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) {
18131         LDKChannelMonitor this_arg_conv;
18132         this_arg_conv.inner = (void*)(this_arg & (~1));
18133         this_arg_conv.is_owned = false;
18134         unsigned char txid_arr[32];
18135         CHECK((*env)->GetArrayLength(env, txid) == 32);
18136         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
18137         unsigned char (*txid_ref)[32] = &txid_arr;
18138         void* broadcaster_ptr = (void*)(((uint64_t)broadcaster) & ~1);
18139         CHECK_ACCESS(broadcaster_ptr);
18140         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
18141         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
18142                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
18143                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
18144         }
18145         void* fee_estimator_ptr = (void*)(((uint64_t)fee_estimator) & ~1);
18146         CHECK_ACCESS(fee_estimator_ptr);
18147         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
18148         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
18149                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
18150                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
18151         }
18152         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
18153         CHECK_ACCESS(logger_ptr);
18154         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
18155         if (logger_conv.free == LDKLogger_JCalls_free) {
18156                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
18157                 LDKLogger_JCalls_cloned(&logger_conv);
18158         }
18159         ChannelMonitor_transaction_unconfirmed(&this_arg_conv, txid_ref, broadcaster_conv, fee_estimator_conv, logger_conv);
18160 }
18161
18162 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) {
18163         LDKChannelMonitor this_arg_conv;
18164         this_arg_conv.inner = (void*)(this_arg & (~1));
18165         this_arg_conv.is_owned = false;
18166         unsigned char header_arr[80];
18167         CHECK((*env)->GetArrayLength(env, header) == 80);
18168         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
18169         unsigned char (*header_ref)[80] = &header_arr;
18170         void* broadcaster_ptr = (void*)(((uint64_t)broadcaster) & ~1);
18171         CHECK_ACCESS(broadcaster_ptr);
18172         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
18173         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
18174                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
18175                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
18176         }
18177         void* fee_estimator_ptr = (void*)(((uint64_t)fee_estimator) & ~1);
18178         CHECK_ACCESS(fee_estimator_ptr);
18179         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
18180         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
18181                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
18182                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
18183         }
18184         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
18185         CHECK_ACCESS(logger_ptr);
18186         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
18187         if (logger_conv.free == LDKLogger_JCalls_free) {
18188                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
18189                 LDKLogger_JCalls_cloned(&logger_conv);
18190         }
18191         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ ret_var = ChannelMonitor_best_block_updated(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
18192         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
18193         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
18194         for (size_t n = 0; n < ret_var.datalen; n++) {
18195                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
18196                 *ret_conv_39_conv = ret_var.data[n];
18197                 ret_arr_ptr[n] = ((uint64_t)ret_conv_39_conv);
18198         }
18199         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
18200         FREE(ret_var.data);
18201         return ret_arr;
18202 }
18203
18204 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1relevant_1txids(JNIEnv *env, jclass clz, int64_t this_arg) {
18205         LDKChannelMonitor this_arg_conv;
18206         this_arg_conv.inner = (void*)(this_arg & (~1));
18207         this_arg_conv.is_owned = false;
18208         LDKCVec_TxidZ ret_var = ChannelMonitor_get_relevant_txids(&this_arg_conv);
18209         jobjectArray ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
18210         ;
18211         for (size_t i = 0; i < ret_var.datalen; i++) {
18212                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 32);
18213                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 32, ret_var.data[i].data);
18214                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
18215         }
18216         FREE(ret_var.data);
18217         return ret_arr;
18218 }
18219
18220 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1current_1best_1block(JNIEnv *env, jclass clz, int64_t this_arg) {
18221         LDKChannelMonitor this_arg_conv;
18222         this_arg_conv.inner = (void*)(this_arg & (~1));
18223         this_arg_conv.is_owned = false;
18224         LDKBestBlock ret_var = ChannelMonitor_current_best_block(&this_arg_conv);
18225         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18226         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18227         uint64_t ret_ref = (uint64_t)ret_var.inner;
18228         if (ret_var.is_owned) {
18229                 ret_ref |= 1;
18230         }
18231         return ret_ref;
18232 }
18233
18234 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1claimable_1balances(JNIEnv *env, jclass clz, int64_t this_arg) {
18235         LDKChannelMonitor this_arg_conv;
18236         this_arg_conv.inner = (void*)(this_arg & (~1));
18237         this_arg_conv.is_owned = false;
18238         LDKCVec_BalanceZ ret_var = ChannelMonitor_get_claimable_balances(&this_arg_conv);
18239         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
18240         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
18241         for (size_t j = 0; j < ret_var.datalen; j++) {
18242                 LDKBalance *ret_conv_9_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
18243                 *ret_conv_9_copy = ret_var.data[j];
18244                 uint64_t ret_conv_9_ref = (uint64_t)ret_conv_9_copy;
18245                 ret_arr_ptr[j] = ret_conv_9_ref;
18246         }
18247         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
18248         FREE(ret_var.data);
18249         return ret_arr;
18250 }
18251
18252 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
18253         LDKu8slice ser_ref;
18254         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
18255         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
18256         void* arg_ptr = (void*)(((uint64_t)arg) & ~1);
18257         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
18258         LDKKeysInterface* arg_conv = (LDKKeysInterface*)arg_ptr;
18259         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
18260         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_read(ser_ref, arg_conv);
18261         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
18262         return (uint64_t)ret_conv;
18263 }
18264
18265 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18266         LDKOutPoint this_obj_conv;
18267         this_obj_conv.inner = (void*)(this_obj & (~1));
18268         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18269         OutPoint_free(this_obj_conv);
18270 }
18271
18272 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1get_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
18273         LDKOutPoint this_ptr_conv;
18274         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18275         this_ptr_conv.is_owned = false;
18276         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18277         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OutPoint_get_txid(&this_ptr_conv));
18278         return ret_arr;
18279 }
18280
18281 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1set_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18282         LDKOutPoint this_ptr_conv;
18283         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18284         this_ptr_conv.is_owned = false;
18285         LDKThirtyTwoBytes val_ref;
18286         CHECK((*env)->GetArrayLength(env, val) == 32);
18287         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18288         OutPoint_set_txid(&this_ptr_conv, val_ref);
18289 }
18290
18291 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1get_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
18292         LDKOutPoint this_ptr_conv;
18293         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18294         this_ptr_conv.is_owned = false;
18295         int16_t ret_val = OutPoint_get_index(&this_ptr_conv);
18296         return ret_val;
18297 }
18298
18299 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1set_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
18300         LDKOutPoint this_ptr_conv;
18301         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18302         this_ptr_conv.is_owned = false;
18303         OutPoint_set_index(&this_ptr_conv, val);
18304 }
18305
18306 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1new(JNIEnv *env, jclass clz, int8_tArray txid_arg, int16_t index_arg) {
18307         LDKThirtyTwoBytes txid_arg_ref;
18308         CHECK((*env)->GetArrayLength(env, txid_arg) == 32);
18309         (*env)->GetByteArrayRegion(env, txid_arg, 0, 32, txid_arg_ref.data);
18310         LDKOutPoint ret_var = OutPoint_new(txid_arg_ref, index_arg);
18311         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18312         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18313         uint64_t ret_ref = (uint64_t)ret_var.inner;
18314         if (ret_var.is_owned) {
18315                 ret_ref |= 1;
18316         }
18317         return ret_ref;
18318 }
18319
18320 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18321         LDKOutPoint orig_conv;
18322         orig_conv.inner = (void*)(orig & (~1));
18323         orig_conv.is_owned = false;
18324         LDKOutPoint ret_var = OutPoint_clone(&orig_conv);
18325         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18326         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18327         uint64_t ret_ref = (uint64_t)ret_var.inner;
18328         if (ret_var.is_owned) {
18329                 ret_ref |= 1;
18330         }
18331         return ret_ref;
18332 }
18333
18334 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_OutPoint_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
18335         LDKOutPoint a_conv;
18336         a_conv.inner = (void*)(a & (~1));
18337         a_conv.is_owned = false;
18338         LDKOutPoint b_conv;
18339         b_conv.inner = (void*)(b & (~1));
18340         b_conv.is_owned = false;
18341         jboolean ret_val = OutPoint_eq(&a_conv, &b_conv);
18342         return ret_val;
18343 }
18344
18345 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1hash(JNIEnv *env, jclass clz, int64_t o) {
18346         LDKOutPoint o_conv;
18347         o_conv.inner = (void*)(o & (~1));
18348         o_conv.is_owned = false;
18349         int64_t ret_val = OutPoint_hash(&o_conv);
18350         return ret_val;
18351 }
18352
18353 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1to_1channel_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
18354         LDKOutPoint this_arg_conv;
18355         this_arg_conv.inner = (void*)(this_arg & (~1));
18356         this_arg_conv.is_owned = false;
18357         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18358         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, OutPoint_to_channel_id(&this_arg_conv).data);
18359         return ret_arr;
18360 }
18361
18362 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1write(JNIEnv *env, jclass clz, int64_t obj) {
18363         LDKOutPoint obj_conv;
18364         obj_conv.inner = (void*)(obj & (~1));
18365         obj_conv.is_owned = false;
18366         LDKCVec_u8Z ret_var = OutPoint_write(&obj_conv);
18367         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
18368         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
18369         CVec_u8Z_free(ret_var);
18370         return ret_arr;
18371 }
18372
18373 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
18374         LDKu8slice ser_ref;
18375         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
18376         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
18377         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
18378         *ret_conv = OutPoint_read(ser_ref);
18379         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
18380         return (uint64_t)ret_conv;
18381 }
18382
18383 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18384         LDKDelayedPaymentOutputDescriptor this_obj_conv;
18385         this_obj_conv.inner = (void*)(this_obj & (~1));
18386         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18387         DelayedPaymentOutputDescriptor_free(this_obj_conv);
18388 }
18389
18390 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
18391         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
18392         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18393         this_ptr_conv.is_owned = false;
18394         LDKOutPoint ret_var = DelayedPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
18395         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18396         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18397         uint64_t ret_ref = (uint64_t)ret_var.inner;
18398         if (ret_var.is_owned) {
18399                 ret_ref |= 1;
18400         }
18401         return ret_ref;
18402 }
18403
18404 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18405         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
18406         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18407         this_ptr_conv.is_owned = false;
18408         LDKOutPoint val_conv;
18409         val_conv.inner = (void*)(val & (~1));
18410         val_conv.is_owned = (val & 1) || (val == 0);
18411         val_conv = OutPoint_clone(&val_conv);
18412         DelayedPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
18413 }
18414
18415 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
18416         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
18417         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18418         this_ptr_conv.is_owned = false;
18419         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
18420         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DelayedPaymentOutputDescriptor_get_per_commitment_point(&this_ptr_conv).compressed_form);
18421         return ret_arr;
18422 }
18423
18424 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18425         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
18426         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18427         this_ptr_conv.is_owned = false;
18428         LDKPublicKey val_ref;
18429         CHECK((*env)->GetArrayLength(env, val) == 33);
18430         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
18431         DelayedPaymentOutputDescriptor_set_per_commitment_point(&this_ptr_conv, val_ref);
18432 }
18433
18434 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
18435         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
18436         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18437         this_ptr_conv.is_owned = false;
18438         int16_t ret_val = DelayedPaymentOutputDescriptor_get_to_self_delay(&this_ptr_conv);
18439         return ret_val;
18440 }
18441
18442 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
18443         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
18444         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18445         this_ptr_conv.is_owned = false;
18446         DelayedPaymentOutputDescriptor_set_to_self_delay(&this_ptr_conv, val);
18447 }
18448
18449 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1output(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18450         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
18451         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18452         this_ptr_conv.is_owned = false;
18453         void* val_ptr = (void*)(((uint64_t)val) & ~1);
18454         CHECK_ACCESS(val_ptr);
18455         LDKTxOut val_conv = *(LDKTxOut*)(val_ptr);
18456         val_conv = TxOut_clone((LDKTxOut*)(((uint64_t)val) & ~1));
18457         DelayedPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
18458 }
18459
18460 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1revocation_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
18461         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
18462         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18463         this_ptr_conv.is_owned = false;
18464         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
18465         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DelayedPaymentOutputDescriptor_get_revocation_pubkey(&this_ptr_conv).compressed_form);
18466         return ret_arr;
18467 }
18468
18469 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1revocation_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18470         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
18471         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18472         this_ptr_conv.is_owned = false;
18473         LDKPublicKey val_ref;
18474         CHECK((*env)->GetArrayLength(env, val) == 33);
18475         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
18476         DelayedPaymentOutputDescriptor_set_revocation_pubkey(&this_ptr_conv, val_ref);
18477 }
18478
18479 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18480         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
18481         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18482         this_ptr_conv.is_owned = false;
18483         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18484         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *DelayedPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv));
18485         return ret_arr;
18486 }
18487
18488 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18489         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
18490         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18491         this_ptr_conv.is_owned = false;
18492         LDKThirtyTwoBytes val_ref;
18493         CHECK((*env)->GetArrayLength(env, val) == 32);
18494         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18495         DelayedPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
18496 }
18497
18498 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
18499         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
18500         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18501         this_ptr_conv.is_owned = false;
18502         int64_t ret_val = DelayedPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
18503         return ret_val;
18504 }
18505
18506 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18507         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
18508         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18509         this_ptr_conv.is_owned = false;
18510         DelayedPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
18511 }
18512
18513 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) {
18514         LDKOutPoint outpoint_arg_conv;
18515         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
18516         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
18517         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
18518         LDKPublicKey per_commitment_point_arg_ref;
18519         CHECK((*env)->GetArrayLength(env, per_commitment_point_arg) == 33);
18520         (*env)->GetByteArrayRegion(env, per_commitment_point_arg, 0, 33, per_commitment_point_arg_ref.compressed_form);
18521         void* output_arg_ptr = (void*)(((uint64_t)output_arg) & ~1);
18522         CHECK_ACCESS(output_arg_ptr);
18523         LDKTxOut output_arg_conv = *(LDKTxOut*)(output_arg_ptr);
18524         output_arg_conv = TxOut_clone((LDKTxOut*)(((uint64_t)output_arg) & ~1));
18525         LDKPublicKey revocation_pubkey_arg_ref;
18526         CHECK((*env)->GetArrayLength(env, revocation_pubkey_arg) == 33);
18527         (*env)->GetByteArrayRegion(env, revocation_pubkey_arg, 0, 33, revocation_pubkey_arg_ref.compressed_form);
18528         LDKThirtyTwoBytes channel_keys_id_arg_ref;
18529         CHECK((*env)->GetArrayLength(env, channel_keys_id_arg) == 32);
18530         (*env)->GetByteArrayRegion(env, channel_keys_id_arg, 0, 32, channel_keys_id_arg_ref.data);
18531         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);
18532         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18533         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18534         uint64_t ret_ref = (uint64_t)ret_var.inner;
18535         if (ret_var.is_owned) {
18536                 ret_ref |= 1;
18537         }
18538         return ret_ref;
18539 }
18540
18541 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18542         LDKDelayedPaymentOutputDescriptor orig_conv;
18543         orig_conv.inner = (void*)(orig & (~1));
18544         orig_conv.is_owned = false;
18545         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(&orig_conv);
18546         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18547         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18548         uint64_t ret_ref = (uint64_t)ret_var.inner;
18549         if (ret_var.is_owned) {
18550                 ret_ref |= 1;
18551         }
18552         return ret_ref;
18553 }
18554
18555 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
18556         LDKDelayedPaymentOutputDescriptor obj_conv;
18557         obj_conv.inner = (void*)(obj & (~1));
18558         obj_conv.is_owned = false;
18559         LDKCVec_u8Z ret_var = DelayedPaymentOutputDescriptor_write(&obj_conv);
18560         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
18561         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
18562         CVec_u8Z_free(ret_var);
18563         return ret_arr;
18564 }
18565
18566 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
18567         LDKu8slice ser_ref;
18568         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
18569         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
18570         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
18571         *ret_conv = DelayedPaymentOutputDescriptor_read(ser_ref);
18572         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
18573         return (uint64_t)ret_conv;
18574 }
18575
18576 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18577         LDKStaticPaymentOutputDescriptor this_obj_conv;
18578         this_obj_conv.inner = (void*)(this_obj & (~1));
18579         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18580         StaticPaymentOutputDescriptor_free(this_obj_conv);
18581 }
18582
18583 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
18584         LDKStaticPaymentOutputDescriptor this_ptr_conv;
18585         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18586         this_ptr_conv.is_owned = false;
18587         LDKOutPoint ret_var = StaticPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
18588         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18589         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18590         uint64_t ret_ref = (uint64_t)ret_var.inner;
18591         if (ret_var.is_owned) {
18592                 ret_ref |= 1;
18593         }
18594         return ret_ref;
18595 }
18596
18597 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18598         LDKStaticPaymentOutputDescriptor this_ptr_conv;
18599         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18600         this_ptr_conv.is_owned = false;
18601         LDKOutPoint val_conv;
18602         val_conv.inner = (void*)(val & (~1));
18603         val_conv.is_owned = (val & 1) || (val == 0);
18604         val_conv = OutPoint_clone(&val_conv);
18605         StaticPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
18606 }
18607
18608 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1output(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18609         LDKStaticPaymentOutputDescriptor this_ptr_conv;
18610         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18611         this_ptr_conv.is_owned = false;
18612         void* val_ptr = (void*)(((uint64_t)val) & ~1);
18613         CHECK_ACCESS(val_ptr);
18614         LDKTxOut val_conv = *(LDKTxOut*)(val_ptr);
18615         val_conv = TxOut_clone((LDKTxOut*)(((uint64_t)val) & ~1));
18616         StaticPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
18617 }
18618
18619 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18620         LDKStaticPaymentOutputDescriptor this_ptr_conv;
18621         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18622         this_ptr_conv.is_owned = false;
18623         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18624         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *StaticPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv));
18625         return ret_arr;
18626 }
18627
18628 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18629         LDKStaticPaymentOutputDescriptor this_ptr_conv;
18630         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18631         this_ptr_conv.is_owned = false;
18632         LDKThirtyTwoBytes val_ref;
18633         CHECK((*env)->GetArrayLength(env, val) == 32);
18634         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18635         StaticPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
18636 }
18637
18638 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
18639         LDKStaticPaymentOutputDescriptor this_ptr_conv;
18640         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18641         this_ptr_conv.is_owned = false;
18642         int64_t ret_val = StaticPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
18643         return ret_val;
18644 }
18645
18646 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18647         LDKStaticPaymentOutputDescriptor this_ptr_conv;
18648         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18649         this_ptr_conv.is_owned = false;
18650         StaticPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
18651 }
18652
18653 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) {
18654         LDKOutPoint outpoint_arg_conv;
18655         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
18656         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
18657         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
18658         void* output_arg_ptr = (void*)(((uint64_t)output_arg) & ~1);
18659         CHECK_ACCESS(output_arg_ptr);
18660         LDKTxOut output_arg_conv = *(LDKTxOut*)(output_arg_ptr);
18661         output_arg_conv = TxOut_clone((LDKTxOut*)(((uint64_t)output_arg) & ~1));
18662         LDKThirtyTwoBytes channel_keys_id_arg_ref;
18663         CHECK((*env)->GetArrayLength(env, channel_keys_id_arg) == 32);
18664         (*env)->GetByteArrayRegion(env, channel_keys_id_arg, 0, 32, channel_keys_id_arg_ref.data);
18665         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_new(outpoint_arg_conv, output_arg_conv, channel_keys_id_arg_ref, channel_value_satoshis_arg);
18666         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18667         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18668         uint64_t ret_ref = (uint64_t)ret_var.inner;
18669         if (ret_var.is_owned) {
18670                 ret_ref |= 1;
18671         }
18672         return ret_ref;
18673 }
18674
18675 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18676         LDKStaticPaymentOutputDescriptor orig_conv;
18677         orig_conv.inner = (void*)(orig & (~1));
18678         orig_conv.is_owned = false;
18679         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(&orig_conv);
18680         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18681         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18682         uint64_t ret_ref = (uint64_t)ret_var.inner;
18683         if (ret_var.is_owned) {
18684                 ret_ref |= 1;
18685         }
18686         return ret_ref;
18687 }
18688
18689 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
18690         LDKStaticPaymentOutputDescriptor obj_conv;
18691         obj_conv.inner = (void*)(obj & (~1));
18692         obj_conv.is_owned = false;
18693         LDKCVec_u8Z ret_var = StaticPaymentOutputDescriptor_write(&obj_conv);
18694         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
18695         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
18696         CVec_u8Z_free(ret_var);
18697         return ret_arr;
18698 }
18699
18700 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
18701         LDKu8slice ser_ref;
18702         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
18703         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
18704         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
18705         *ret_conv = StaticPaymentOutputDescriptor_read(ser_ref);
18706         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
18707         return (uint64_t)ret_conv;
18708 }
18709
18710 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
18711         if ((this_ptr & 1) != 0) return;
18712         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
18713         CHECK_ACCESS(this_ptr_ptr);
18714         LDKSpendableOutputDescriptor this_ptr_conv = *(LDKSpendableOutputDescriptor*)(this_ptr_ptr);
18715         FREE((void*)this_ptr);
18716         SpendableOutputDescriptor_free(this_ptr_conv);
18717 }
18718
18719 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18720         LDKSpendableOutputDescriptor* orig_conv = (LDKSpendableOutputDescriptor*)orig;
18721         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
18722         *ret_copy = SpendableOutputDescriptor_clone(orig_conv);
18723         uint64_t ret_ref = (uint64_t)ret_copy;
18724         return ret_ref;
18725 }
18726
18727 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1static_1output(JNIEnv *env, jclass clz, int64_t outpoint, int64_t output) {
18728         LDKOutPoint outpoint_conv;
18729         outpoint_conv.inner = (void*)(outpoint & (~1));
18730         outpoint_conv.is_owned = (outpoint & 1) || (outpoint == 0);
18731         outpoint_conv = OutPoint_clone(&outpoint_conv);
18732         void* output_ptr = (void*)(((uint64_t)output) & ~1);
18733         CHECK_ACCESS(output_ptr);
18734         LDKTxOut output_conv = *(LDKTxOut*)(output_ptr);
18735         output_conv = TxOut_clone((LDKTxOut*)(((uint64_t)output) & ~1));
18736         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
18737         *ret_copy = SpendableOutputDescriptor_static_output(outpoint_conv, output_conv);
18738         uint64_t ret_ref = (uint64_t)ret_copy;
18739         return ret_ref;
18740 }
18741
18742 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1delayed_1payment_1output(JNIEnv *env, jclass clz, int64_t a) {
18743         LDKDelayedPaymentOutputDescriptor a_conv;
18744         a_conv.inner = (void*)(a & (~1));
18745         a_conv.is_owned = (a & 1) || (a == 0);
18746         a_conv = DelayedPaymentOutputDescriptor_clone(&a_conv);
18747         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
18748         *ret_copy = SpendableOutputDescriptor_delayed_payment_output(a_conv);
18749         uint64_t ret_ref = (uint64_t)ret_copy;
18750         return ret_ref;
18751 }
18752
18753 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1static_1payment_1output(JNIEnv *env, jclass clz, int64_t a) {
18754         LDKStaticPaymentOutputDescriptor a_conv;
18755         a_conv.inner = (void*)(a & (~1));
18756         a_conv.is_owned = (a & 1) || (a == 0);
18757         a_conv = StaticPaymentOutputDescriptor_clone(&a_conv);
18758         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
18759         *ret_copy = SpendableOutputDescriptor_static_payment_output(a_conv);
18760         uint64_t ret_ref = (uint64_t)ret_copy;
18761         return ret_ref;
18762 }
18763
18764 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
18765         LDKSpendableOutputDescriptor* obj_conv = (LDKSpendableOutputDescriptor*)obj;
18766         LDKCVec_u8Z ret_var = SpendableOutputDescriptor_write(obj_conv);
18767         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
18768         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
18769         CVec_u8Z_free(ret_var);
18770         return ret_arr;
18771 }
18772
18773 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
18774         LDKu8slice ser_ref;
18775         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
18776         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
18777         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
18778         *ret_conv = SpendableOutputDescriptor_read(ser_ref);
18779         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
18780         return (uint64_t)ret_conv;
18781 }
18782
18783 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BaseSign_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
18784         if ((this_ptr & 1) != 0) return;
18785         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
18786         CHECK_ACCESS(this_ptr_ptr);
18787         LDKBaseSign this_ptr_conv = *(LDKBaseSign*)(this_ptr_ptr);
18788         FREE((void*)this_ptr);
18789         BaseSign_free(this_ptr_conv);
18790 }
18791
18792 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sign_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18793         void* orig_ptr = (void*)(((uint64_t)orig) & ~1);
18794         if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
18795         LDKSign* orig_conv = (LDKSign*)orig_ptr;
18796         LDKSign* ret_ret =MALLOC(sizeof(LDKSign), "LDKSign");
18797         *ret_ret = Sign_clone(orig_conv);
18798         return (uint64_t)ret_ret;
18799 }
18800
18801 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Sign_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
18802         if ((this_ptr & 1) != 0) return;
18803         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
18804         CHECK_ACCESS(this_ptr_ptr);
18805         LDKSign this_ptr_conv = *(LDKSign*)(this_ptr_ptr);
18806         FREE((void*)this_ptr);
18807         Sign_free(this_ptr_conv);
18808 }
18809
18810 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_KeysInterface_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
18811         if ((this_ptr & 1) != 0) return;
18812         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
18813         CHECK_ACCESS(this_ptr_ptr);
18814         LDKKeysInterface this_ptr_conv = *(LDKKeysInterface*)(this_ptr_ptr);
18815         FREE((void*)this_ptr);
18816         KeysInterface_free(this_ptr_conv);
18817 }
18818
18819 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18820         LDKInMemorySigner this_obj_conv;
18821         this_obj_conv.inner = (void*)(this_obj & (~1));
18822         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18823         InMemorySigner_free(this_obj_conv);
18824 }
18825
18826 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1funding_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
18827         LDKInMemorySigner this_ptr_conv;
18828         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18829         this_ptr_conv.is_owned = false;
18830         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18831         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_funding_key(&this_ptr_conv));
18832         return ret_arr;
18833 }
18834
18835 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1funding_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18836         LDKInMemorySigner this_ptr_conv;
18837         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18838         this_ptr_conv.is_owned = false;
18839         LDKSecretKey val_ref;
18840         CHECK((*env)->GetArrayLength(env, val) == 32);
18841         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
18842         InMemorySigner_set_funding_key(&this_ptr_conv, val_ref);
18843 }
18844
18845 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1revocation_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
18846         LDKInMemorySigner this_ptr_conv;
18847         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18848         this_ptr_conv.is_owned = false;
18849         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18850         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_revocation_base_key(&this_ptr_conv));
18851         return ret_arr;
18852 }
18853
18854 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1revocation_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18855         LDKInMemorySigner this_ptr_conv;
18856         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18857         this_ptr_conv.is_owned = false;
18858         LDKSecretKey val_ref;
18859         CHECK((*env)->GetArrayLength(env, val) == 32);
18860         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
18861         InMemorySigner_set_revocation_base_key(&this_ptr_conv, val_ref);
18862 }
18863
18864 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
18865         LDKInMemorySigner this_ptr_conv;
18866         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18867         this_ptr_conv.is_owned = false;
18868         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18869         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_payment_key(&this_ptr_conv));
18870         return ret_arr;
18871 }
18872
18873 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18874         LDKInMemorySigner this_ptr_conv;
18875         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18876         this_ptr_conv.is_owned = false;
18877         LDKSecretKey val_ref;
18878         CHECK((*env)->GetArrayLength(env, val) == 32);
18879         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
18880         InMemorySigner_set_payment_key(&this_ptr_conv, val_ref);
18881 }
18882
18883 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1delayed_1payment_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
18884         LDKInMemorySigner this_ptr_conv;
18885         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18886         this_ptr_conv.is_owned = false;
18887         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18888         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_delayed_payment_base_key(&this_ptr_conv));
18889         return ret_arr;
18890 }
18891
18892 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) {
18893         LDKInMemorySigner this_ptr_conv;
18894         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18895         this_ptr_conv.is_owned = false;
18896         LDKSecretKey val_ref;
18897         CHECK((*env)->GetArrayLength(env, val) == 32);
18898         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
18899         InMemorySigner_set_delayed_payment_base_key(&this_ptr_conv, val_ref);
18900 }
18901
18902 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1htlc_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
18903         LDKInMemorySigner this_ptr_conv;
18904         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18905         this_ptr_conv.is_owned = false;
18906         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18907         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_htlc_base_key(&this_ptr_conv));
18908         return ret_arr;
18909 }
18910
18911 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1htlc_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18912         LDKInMemorySigner this_ptr_conv;
18913         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18914         this_ptr_conv.is_owned = false;
18915         LDKSecretKey val_ref;
18916         CHECK((*env)->GetArrayLength(env, val) == 32);
18917         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
18918         InMemorySigner_set_htlc_base_key(&this_ptr_conv, val_ref);
18919 }
18920
18921 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1commitment_1seed(JNIEnv *env, jclass clz, int64_t this_ptr) {
18922         LDKInMemorySigner this_ptr_conv;
18923         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18924         this_ptr_conv.is_owned = false;
18925         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18926         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_commitment_seed(&this_ptr_conv));
18927         return ret_arr;
18928 }
18929
18930 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1commitment_1seed(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18931         LDKInMemorySigner this_ptr_conv;
18932         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18933         this_ptr_conv.is_owned = false;
18934         LDKThirtyTwoBytes val_ref;
18935         CHECK((*env)->GetArrayLength(env, val) == 32);
18936         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18937         InMemorySigner_set_commitment_seed(&this_ptr_conv, val_ref);
18938 }
18939
18940 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18941         LDKInMemorySigner orig_conv;
18942         orig_conv.inner = (void*)(orig & (~1));
18943         orig_conv.is_owned = false;
18944         LDKInMemorySigner ret_var = InMemorySigner_clone(&orig_conv);
18945         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18946         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18947         uint64_t ret_ref = (uint64_t)ret_var.inner;
18948         if (ret_var.is_owned) {
18949                 ret_ref |= 1;
18950         }
18951         return ret_ref;
18952 }
18953
18954 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) {
18955         LDKSecretKey funding_key_ref;
18956         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
18957         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_ref.bytes);
18958         LDKSecretKey revocation_base_key_ref;
18959         CHECK((*env)->GetArrayLength(env, revocation_base_key) == 32);
18960         (*env)->GetByteArrayRegion(env, revocation_base_key, 0, 32, revocation_base_key_ref.bytes);
18961         LDKSecretKey payment_key_ref;
18962         CHECK((*env)->GetArrayLength(env, payment_key) == 32);
18963         (*env)->GetByteArrayRegion(env, payment_key, 0, 32, payment_key_ref.bytes);
18964         LDKSecretKey delayed_payment_base_key_ref;
18965         CHECK((*env)->GetArrayLength(env, delayed_payment_base_key) == 32);
18966         (*env)->GetByteArrayRegion(env, delayed_payment_base_key, 0, 32, delayed_payment_base_key_ref.bytes);
18967         LDKSecretKey htlc_base_key_ref;
18968         CHECK((*env)->GetArrayLength(env, htlc_base_key) == 32);
18969         (*env)->GetByteArrayRegion(env, htlc_base_key, 0, 32, htlc_base_key_ref.bytes);
18970         LDKThirtyTwoBytes commitment_seed_ref;
18971         CHECK((*env)->GetArrayLength(env, commitment_seed) == 32);
18972         (*env)->GetByteArrayRegion(env, commitment_seed, 0, 32, commitment_seed_ref.data);
18973         LDKThirtyTwoBytes channel_keys_id_ref;
18974         CHECK((*env)->GetArrayLength(env, channel_keys_id) == 32);
18975         (*env)->GetByteArrayRegion(env, channel_keys_id, 0, 32, channel_keys_id_ref.data);
18976         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);
18977         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18978         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18979         uint64_t ret_ref = (uint64_t)ret_var.inner;
18980         if (ret_var.is_owned) {
18981                 ret_ref |= 1;
18982         }
18983         return ret_ref;
18984 }
18985
18986 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1counterparty_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
18987         LDKInMemorySigner this_arg_conv;
18988         this_arg_conv.inner = (void*)(this_arg & (~1));
18989         this_arg_conv.is_owned = false;
18990         LDKChannelPublicKeys ret_var = InMemorySigner_counterparty_pubkeys(&this_arg_conv);
18991         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18992         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18993         uint64_t ret_ref = (uint64_t)ret_var.inner;
18994         if (ret_var.is_owned) {
18995                 ret_ref |= 1;
18996         }
18997         return ret_ref;
18998 }
18999
19000 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1counterparty_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
19001         LDKInMemorySigner this_arg_conv;
19002         this_arg_conv.inner = (void*)(this_arg & (~1));
19003         this_arg_conv.is_owned = false;
19004         int16_t ret_val = InMemorySigner_counterparty_selected_contest_delay(&this_arg_conv);
19005         return ret_val;
19006 }
19007
19008 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1holder_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
19009         LDKInMemorySigner this_arg_conv;
19010         this_arg_conv.inner = (void*)(this_arg & (~1));
19011         this_arg_conv.is_owned = false;
19012         int16_t ret_val = InMemorySigner_holder_selected_contest_delay(&this_arg_conv);
19013         return ret_val;
19014 }
19015
19016 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_arg) {
19017         LDKInMemorySigner this_arg_conv;
19018         this_arg_conv.inner = (void*)(this_arg & (~1));
19019         this_arg_conv.is_owned = false;
19020         jboolean ret_val = InMemorySigner_is_outbound(&this_arg_conv);
19021         return ret_val;
19022 }
19023
19024 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_arg) {
19025         LDKInMemorySigner this_arg_conv;
19026         this_arg_conv.inner = (void*)(this_arg & (~1));
19027         this_arg_conv.is_owned = false;
19028         LDKOutPoint ret_var = InMemorySigner_funding_outpoint(&this_arg_conv);
19029         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19030         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19031         uint64_t ret_ref = (uint64_t)ret_var.inner;
19032         if (ret_var.is_owned) {
19033                 ret_ref |= 1;
19034         }
19035         return ret_ref;
19036 }
19037
19038 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1channel_1parameters(JNIEnv *env, jclass clz, int64_t this_arg) {
19039         LDKInMemorySigner this_arg_conv;
19040         this_arg_conv.inner = (void*)(this_arg & (~1));
19041         this_arg_conv.is_owned = false;
19042         LDKChannelTransactionParameters ret_var = InMemorySigner_get_channel_parameters(&this_arg_conv);
19043         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19044         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19045         uint64_t ret_ref = (uint64_t)ret_var.inner;
19046         if (ret_var.is_owned) {
19047                 ret_ref |= 1;
19048         }
19049         return ret_ref;
19050 }
19051
19052 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) {
19053         LDKInMemorySigner this_arg_conv;
19054         this_arg_conv.inner = (void*)(this_arg & (~1));
19055         this_arg_conv.is_owned = false;
19056         LDKTransaction spend_tx_ref;
19057         spend_tx_ref.datalen = (*env)->GetArrayLength(env, spend_tx);
19058         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
19059         (*env)->GetByteArrayRegion(env, spend_tx, 0, spend_tx_ref.datalen, spend_tx_ref.data);
19060         spend_tx_ref.data_is_owned = true;
19061         LDKStaticPaymentOutputDescriptor descriptor_conv;
19062         descriptor_conv.inner = (void*)(descriptor & (~1));
19063         descriptor_conv.is_owned = false;
19064         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
19065         *ret_conv = InMemorySigner_sign_counterparty_payment_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
19066         return (uint64_t)ret_conv;
19067 }
19068
19069 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) {
19070         LDKInMemorySigner this_arg_conv;
19071         this_arg_conv.inner = (void*)(this_arg & (~1));
19072         this_arg_conv.is_owned = false;
19073         LDKTransaction spend_tx_ref;
19074         spend_tx_ref.datalen = (*env)->GetArrayLength(env, spend_tx);
19075         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
19076         (*env)->GetByteArrayRegion(env, spend_tx, 0, spend_tx_ref.datalen, spend_tx_ref.data);
19077         spend_tx_ref.data_is_owned = true;
19078         LDKDelayedPaymentOutputDescriptor descriptor_conv;
19079         descriptor_conv.inner = (void*)(descriptor & (~1));
19080         descriptor_conv.is_owned = false;
19081         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
19082         *ret_conv = InMemorySigner_sign_dynamic_p2wsh_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
19083         return (uint64_t)ret_conv;
19084 }
19085
19086 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1as_1BaseSign(JNIEnv *env, jclass clz, int64_t this_arg) {
19087         LDKInMemorySigner this_arg_conv;
19088         this_arg_conv.inner = (void*)(this_arg & (~1));
19089         this_arg_conv.is_owned = false;
19090         LDKBaseSign* ret_ret =MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
19091         *ret_ret = InMemorySigner_as_BaseSign(&this_arg_conv);
19092         return (uint64_t)ret_ret;
19093 }
19094
19095 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1as_1Sign(JNIEnv *env, jclass clz, int64_t this_arg) {
19096         LDKInMemorySigner this_arg_conv;
19097         this_arg_conv.inner = (void*)(this_arg & (~1));
19098         this_arg_conv.is_owned = false;
19099         LDKSign* ret_ret =MALLOC(sizeof(LDKSign), "LDKSign");
19100         *ret_ret = InMemorySigner_as_Sign(&this_arg_conv);
19101         return (uint64_t)ret_ret;
19102 }
19103
19104 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1write(JNIEnv *env, jclass clz, int64_t obj) {
19105         LDKInMemorySigner obj_conv;
19106         obj_conv.inner = (void*)(obj & (~1));
19107         obj_conv.is_owned = false;
19108         LDKCVec_u8Z ret_var = InMemorySigner_write(&obj_conv);
19109         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
19110         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
19111         CVec_u8Z_free(ret_var);
19112         return ret_arr;
19113 }
19114
19115 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
19116         LDKu8slice ser_ref;
19117         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
19118         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
19119         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
19120         *ret_conv = InMemorySigner_read(ser_ref);
19121         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
19122         return (uint64_t)ret_conv;
19123 }
19124
19125 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_KeysManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19126         LDKKeysManager this_obj_conv;
19127         this_obj_conv.inner = (void*)(this_obj & (~1));
19128         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19129         KeysManager_free(this_obj_conv);
19130 }
19131
19132 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) {
19133         unsigned char seed_arr[32];
19134         CHECK((*env)->GetArrayLength(env, seed) == 32);
19135         (*env)->GetByteArrayRegion(env, seed, 0, 32, seed_arr);
19136         unsigned char (*seed_ref)[32] = &seed_arr;
19137         LDKKeysManager ret_var = KeysManager_new(seed_ref, starting_time_secs, starting_time_nanos);
19138         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19139         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19140         uint64_t ret_ref = (uint64_t)ret_var.inner;
19141         if (ret_var.is_owned) {
19142                 ret_ref |= 1;
19143         }
19144         return ret_ref;
19145 }
19146
19147 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) {
19148         LDKKeysManager this_arg_conv;
19149         this_arg_conv.inner = (void*)(this_arg & (~1));
19150         this_arg_conv.is_owned = false;
19151         unsigned char params_arr[32];
19152         CHECK((*env)->GetArrayLength(env, params) == 32);
19153         (*env)->GetByteArrayRegion(env, params, 0, 32, params_arr);
19154         unsigned char (*params_ref)[32] = &params_arr;
19155         LDKInMemorySigner ret_var = KeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
19156         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19157         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19158         uint64_t ret_ref = (uint64_t)ret_var.inner;
19159         if (ret_var.is_owned) {
19160                 ret_ref |= 1;
19161         }
19162         return ret_ref;
19163 }
19164
19165 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) {
19166         LDKKeysManager this_arg_conv;
19167         this_arg_conv.inner = (void*)(this_arg & (~1));
19168         this_arg_conv.is_owned = false;
19169         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
19170         descriptors_constr.datalen = (*env)->GetArrayLength(env, descriptors);
19171         if (descriptors_constr.datalen > 0)
19172                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
19173         else
19174                 descriptors_constr.data = NULL;
19175         int64_t* descriptors_vals = (*env)->GetLongArrayElements (env, descriptors, NULL);
19176         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
19177                 int64_t descriptors_conv_27 = descriptors_vals[b];
19178                 void* descriptors_conv_27_ptr = (void*)(((uint64_t)descriptors_conv_27) & ~1);
19179                 CHECK_ACCESS(descriptors_conv_27_ptr);
19180                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(descriptors_conv_27_ptr);
19181                 descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uint64_t)descriptors_conv_27) & ~1));
19182                 descriptors_constr.data[b] = descriptors_conv_27_conv;
19183         }
19184         (*env)->ReleaseLongArrayElements(env, descriptors, descriptors_vals, 0);
19185         LDKCVec_TxOutZ outputs_constr;
19186         outputs_constr.datalen = (*env)->GetArrayLength(env, outputs);
19187         if (outputs_constr.datalen > 0)
19188                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
19189         else
19190                 outputs_constr.data = NULL;
19191         int64_t* outputs_vals = (*env)->GetLongArrayElements (env, outputs, NULL);
19192         for (size_t h = 0; h < outputs_constr.datalen; h++) {
19193                 int64_t outputs_conv_7 = outputs_vals[h];
19194                 void* outputs_conv_7_ptr = (void*)(((uint64_t)outputs_conv_7) & ~1);
19195                 CHECK_ACCESS(outputs_conv_7_ptr);
19196                 LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(outputs_conv_7_ptr);
19197                 outputs_conv_7_conv = TxOut_clone((LDKTxOut*)(((uint64_t)outputs_conv_7) & ~1));
19198                 outputs_constr.data[h] = outputs_conv_7_conv;
19199         }
19200         (*env)->ReleaseLongArrayElements(env, outputs, outputs_vals, 0);
19201         LDKCVec_u8Z change_destination_script_ref;
19202         change_destination_script_ref.datalen = (*env)->GetArrayLength(env, change_destination_script);
19203         change_destination_script_ref.data = MALLOC(change_destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
19204         (*env)->GetByteArrayRegion(env, change_destination_script, 0, change_destination_script_ref.datalen, change_destination_script_ref.data);
19205         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
19206         *ret_conv = KeysManager_spend_spendable_outputs(&this_arg_conv, descriptors_constr, outputs_constr, change_destination_script_ref, feerate_sat_per_1000_weight);
19207         return (uint64_t)ret_conv;
19208 }
19209
19210 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysManager_1as_1KeysInterface(JNIEnv *env, jclass clz, int64_t this_arg) {
19211         LDKKeysManager this_arg_conv;
19212         this_arg_conv.inner = (void*)(this_arg & (~1));
19213         this_arg_conv.is_owned = false;
19214         LDKKeysInterface* ret_ret =MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
19215         *ret_ret = KeysManager_as_KeysInterface(&this_arg_conv);
19216         return (uint64_t)ret_ret;
19217 }
19218
19219 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentId_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19220         LDKPaymentId this_obj_conv;
19221         this_obj_conv.inner = (void*)(this_obj & (~1));
19222         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19223         PaymentId_free(this_obj_conv);
19224 }
19225
19226 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentId_1hash(JNIEnv *env, jclass clz, int64_t o) {
19227         LDKPaymentId o_conv;
19228         o_conv.inner = (void*)(o & (~1));
19229         o_conv.is_owned = false;
19230         int64_t ret_val = PaymentId_hash(&o_conv);
19231         return ret_val;
19232 }
19233
19234 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentId_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19235         LDKPaymentId orig_conv;
19236         orig_conv.inner = (void*)(orig & (~1));
19237         orig_conv.is_owned = false;
19238         LDKPaymentId ret_var = PaymentId_clone(&orig_conv);
19239         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19240         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19241         uint64_t ret_ref = (uint64_t)ret_var.inner;
19242         if (ret_var.is_owned) {
19243                 ret_ref |= 1;
19244         }
19245         return ret_ref;
19246 }
19247
19248 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PaymentId_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
19249         LDKPaymentId a_conv;
19250         a_conv.inner = (void*)(a & (~1));
19251         a_conv.is_owned = false;
19252         LDKPaymentId b_conv;
19253         b_conv.inner = (void*)(b & (~1));
19254         b_conv.is_owned = false;
19255         jboolean ret_val = PaymentId_eq(&a_conv, &b_conv);
19256         return ret_val;
19257 }
19258
19259 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PaymentId_1write(JNIEnv *env, jclass clz, int64_t obj) {
19260         LDKPaymentId obj_conv;
19261         obj_conv.inner = (void*)(obj & (~1));
19262         obj_conv.is_owned = false;
19263         LDKCVec_u8Z ret_var = PaymentId_write(&obj_conv);
19264         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
19265         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
19266         CVec_u8Z_free(ret_var);
19267         return ret_arr;
19268 }
19269
19270 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentId_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
19271         LDKu8slice ser_ref;
19272         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
19273         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
19274         LDKCResult_PaymentIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdDecodeErrorZ), "LDKCResult_PaymentIdDecodeErrorZ");
19275         *ret_conv = PaymentId_read(ser_ref);
19276         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
19277         return (uint64_t)ret_conv;
19278 }
19279
19280 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19281         LDKChannelManager this_obj_conv;
19282         this_obj_conv.inner = (void*)(this_obj & (~1));
19283         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19284         ChannelManager_free(this_obj_conv);
19285 }
19286
19287 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19288         LDKChainParameters this_obj_conv;
19289         this_obj_conv.inner = (void*)(this_obj & (~1));
19290         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19291         ChainParameters_free(this_obj_conv);
19292 }
19293
19294 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChainParameters_1get_1network(JNIEnv *env, jclass clz, int64_t this_ptr) {
19295         LDKChainParameters this_ptr_conv;
19296         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19297         this_ptr_conv.is_owned = false;
19298         jclass ret_conv = LDKNetwork_to_java(env, ChainParameters_get_network(&this_ptr_conv));
19299         return ret_conv;
19300 }
19301
19302 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1set_1network(JNIEnv *env, jclass clz, int64_t this_ptr, jclass val) {
19303         LDKChainParameters this_ptr_conv;
19304         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19305         this_ptr_conv.is_owned = false;
19306         LDKNetwork val_conv = LDKNetwork_from_java(env, val);
19307         ChainParameters_set_network(&this_ptr_conv, val_conv);
19308 }
19309
19310 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1get_1best_1block(JNIEnv *env, jclass clz, int64_t this_ptr) {
19311         LDKChainParameters this_ptr_conv;
19312         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19313         this_ptr_conv.is_owned = false;
19314         LDKBestBlock ret_var = ChainParameters_get_best_block(&this_ptr_conv);
19315         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19316         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19317         uint64_t ret_ref = (uint64_t)ret_var.inner;
19318         if (ret_var.is_owned) {
19319                 ret_ref |= 1;
19320         }
19321         return ret_ref;
19322 }
19323
19324 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1set_1best_1block(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19325         LDKChainParameters this_ptr_conv;
19326         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19327         this_ptr_conv.is_owned = false;
19328         LDKBestBlock val_conv;
19329         val_conv.inner = (void*)(val & (~1));
19330         val_conv.is_owned = (val & 1) || (val == 0);
19331         val_conv = BestBlock_clone(&val_conv);
19332         ChainParameters_set_best_block(&this_ptr_conv, val_conv);
19333 }
19334
19335 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1new(JNIEnv *env, jclass clz, jclass network_arg, int64_t best_block_arg) {
19336         LDKNetwork network_arg_conv = LDKNetwork_from_java(env, network_arg);
19337         LDKBestBlock best_block_arg_conv;
19338         best_block_arg_conv.inner = (void*)(best_block_arg & (~1));
19339         best_block_arg_conv.is_owned = (best_block_arg & 1) || (best_block_arg == 0);
19340         best_block_arg_conv = BestBlock_clone(&best_block_arg_conv);
19341         LDKChainParameters ret_var = ChainParameters_new(network_arg_conv, best_block_arg_conv);
19342         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19343         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19344         uint64_t ret_ref = (uint64_t)ret_var.inner;
19345         if (ret_var.is_owned) {
19346                 ret_ref |= 1;
19347         }
19348         return ret_ref;
19349 }
19350
19351 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19352         LDKChainParameters orig_conv;
19353         orig_conv.inner = (void*)(orig & (~1));
19354         orig_conv.is_owned = false;
19355         LDKChainParameters ret_var = ChainParameters_clone(&orig_conv);
19356         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19357         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19358         uint64_t ret_ref = (uint64_t)ret_var.inner;
19359         if (ret_var.is_owned) {
19360                 ret_ref |= 1;
19361         }
19362         return ret_ref;
19363 }
19364
19365 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19366         LDKCounterpartyForwardingInfo this_obj_conv;
19367         this_obj_conv.inner = (void*)(this_obj & (~1));
19368         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19369         CounterpartyForwardingInfo_free(this_obj_conv);
19370 }
19371
19372 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1get_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
19373         LDKCounterpartyForwardingInfo this_ptr_conv;
19374         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19375         this_ptr_conv.is_owned = false;
19376         int32_t ret_val = CounterpartyForwardingInfo_get_fee_base_msat(&this_ptr_conv);
19377         return ret_val;
19378 }
19379
19380 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1set_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
19381         LDKCounterpartyForwardingInfo this_ptr_conv;
19382         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19383         this_ptr_conv.is_owned = false;
19384         CounterpartyForwardingInfo_set_fee_base_msat(&this_ptr_conv, val);
19385 }
19386
19387 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1get_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
19388         LDKCounterpartyForwardingInfo this_ptr_conv;
19389         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19390         this_ptr_conv.is_owned = false;
19391         int32_t ret_val = CounterpartyForwardingInfo_get_fee_proportional_millionths(&this_ptr_conv);
19392         return ret_val;
19393 }
19394
19395 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1set_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
19396         LDKCounterpartyForwardingInfo this_ptr_conv;
19397         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19398         this_ptr_conv.is_owned = false;
19399         CounterpartyForwardingInfo_set_fee_proportional_millionths(&this_ptr_conv, val);
19400 }
19401
19402 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
19403         LDKCounterpartyForwardingInfo this_ptr_conv;
19404         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19405         this_ptr_conv.is_owned = false;
19406         int16_t ret_val = CounterpartyForwardingInfo_get_cltv_expiry_delta(&this_ptr_conv);
19407         return ret_val;
19408 }
19409
19410 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
19411         LDKCounterpartyForwardingInfo this_ptr_conv;
19412         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19413         this_ptr_conv.is_owned = false;
19414         CounterpartyForwardingInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
19415 }
19416
19417 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) {
19418         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_new(fee_base_msat_arg, fee_proportional_millionths_arg, cltv_expiry_delta_arg);
19419         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19420         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19421         uint64_t ret_ref = (uint64_t)ret_var.inner;
19422         if (ret_var.is_owned) {
19423                 ret_ref |= 1;
19424         }
19425         return ret_ref;
19426 }
19427
19428 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19429         LDKCounterpartyForwardingInfo orig_conv;
19430         orig_conv.inner = (void*)(orig & (~1));
19431         orig_conv.is_owned = false;
19432         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_clone(&orig_conv);
19433         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19434         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19435         uint64_t ret_ref = (uint64_t)ret_var.inner;
19436         if (ret_var.is_owned) {
19437                 ret_ref |= 1;
19438         }
19439         return ret_ref;
19440 }
19441
19442 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19443         LDKChannelCounterparty this_obj_conv;
19444         this_obj_conv.inner = (void*)(this_obj & (~1));
19445         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19446         ChannelCounterparty_free(this_obj_conv);
19447 }
19448
19449 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
19450         LDKChannelCounterparty this_ptr_conv;
19451         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19452         this_ptr_conv.is_owned = false;
19453         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
19454         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelCounterparty_get_node_id(&this_ptr_conv).compressed_form);
19455         return ret_arr;
19456 }
19457
19458 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19459         LDKChannelCounterparty this_ptr_conv;
19460         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19461         this_ptr_conv.is_owned = false;
19462         LDKPublicKey val_ref;
19463         CHECK((*env)->GetArrayLength(env, val) == 33);
19464         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
19465         ChannelCounterparty_set_node_id(&this_ptr_conv, val_ref);
19466 }
19467
19468 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
19469         LDKChannelCounterparty this_ptr_conv;
19470         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19471         this_ptr_conv.is_owned = false;
19472         LDKInitFeatures ret_var = ChannelCounterparty_get_features(&this_ptr_conv);
19473         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19474         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19475         uint64_t ret_ref = (uint64_t)ret_var.inner;
19476         if (ret_var.is_owned) {
19477                 ret_ref |= 1;
19478         }
19479         return ret_ref;
19480 }
19481
19482 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19483         LDKChannelCounterparty this_ptr_conv;
19484         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19485         this_ptr_conv.is_owned = false;
19486         LDKInitFeatures val_conv;
19487         val_conv.inner = (void*)(val & (~1));
19488         val_conv.is_owned = (val & 1) || (val == 0);
19489         val_conv = InitFeatures_clone(&val_conv);
19490         ChannelCounterparty_set_features(&this_ptr_conv, val_conv);
19491 }
19492
19493 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr) {
19494         LDKChannelCounterparty this_ptr_conv;
19495         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19496         this_ptr_conv.is_owned = false;
19497         int64_t ret_val = ChannelCounterparty_get_unspendable_punishment_reserve(&this_ptr_conv);
19498         return ret_val;
19499 }
19500
19501 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19502         LDKChannelCounterparty this_ptr_conv;
19503         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19504         this_ptr_conv.is_owned = false;
19505         ChannelCounterparty_set_unspendable_punishment_reserve(&this_ptr_conv, val);
19506 }
19507
19508 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1forwarding_1info(JNIEnv *env, jclass clz, int64_t this_ptr) {
19509         LDKChannelCounterparty this_ptr_conv;
19510         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19511         this_ptr_conv.is_owned = false;
19512         LDKCounterpartyForwardingInfo ret_var = ChannelCounterparty_get_forwarding_info(&this_ptr_conv);
19513         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19514         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19515         uint64_t ret_ref = (uint64_t)ret_var.inner;
19516         if (ret_var.is_owned) {
19517                 ret_ref |= 1;
19518         }
19519         return ret_ref;
19520 }
19521
19522 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1forwarding_1info(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19523         LDKChannelCounterparty this_ptr_conv;
19524         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19525         this_ptr_conv.is_owned = false;
19526         LDKCounterpartyForwardingInfo val_conv;
19527         val_conv.inner = (void*)(val & (~1));
19528         val_conv.is_owned = (val & 1) || (val == 0);
19529         val_conv = CounterpartyForwardingInfo_clone(&val_conv);
19530         ChannelCounterparty_set_forwarding_info(&this_ptr_conv, val_conv);
19531 }
19532
19533 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) {
19534         LDKPublicKey node_id_arg_ref;
19535         CHECK((*env)->GetArrayLength(env, node_id_arg) == 33);
19536         (*env)->GetByteArrayRegion(env, node_id_arg, 0, 33, node_id_arg_ref.compressed_form);
19537         LDKInitFeatures features_arg_conv;
19538         features_arg_conv.inner = (void*)(features_arg & (~1));
19539         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
19540         features_arg_conv = InitFeatures_clone(&features_arg_conv);
19541         LDKCounterpartyForwardingInfo forwarding_info_arg_conv;
19542         forwarding_info_arg_conv.inner = (void*)(forwarding_info_arg & (~1));
19543         forwarding_info_arg_conv.is_owned = (forwarding_info_arg & 1) || (forwarding_info_arg == 0);
19544         forwarding_info_arg_conv = CounterpartyForwardingInfo_clone(&forwarding_info_arg_conv);
19545         LDKChannelCounterparty ret_var = ChannelCounterparty_new(node_id_arg_ref, features_arg_conv, unspendable_punishment_reserve_arg, forwarding_info_arg_conv);
19546         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19547         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19548         uint64_t ret_ref = (uint64_t)ret_var.inner;
19549         if (ret_var.is_owned) {
19550                 ret_ref |= 1;
19551         }
19552         return ret_ref;
19553 }
19554
19555 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19556         LDKChannelCounterparty orig_conv;
19557         orig_conv.inner = (void*)(orig & (~1));
19558         orig_conv.is_owned = false;
19559         LDKChannelCounterparty ret_var = ChannelCounterparty_clone(&orig_conv);
19560         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19561         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19562         uint64_t ret_ref = (uint64_t)ret_var.inner;
19563         if (ret_var.is_owned) {
19564                 ret_ref |= 1;
19565         }
19566         return ret_ref;
19567 }
19568
19569 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19570         LDKChannelDetails this_obj_conv;
19571         this_obj_conv.inner = (void*)(this_obj & (~1));
19572         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19573         ChannelDetails_free(this_obj_conv);
19574 }
19575
19576 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
19577         LDKChannelDetails this_ptr_conv;
19578         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19579         this_ptr_conv.is_owned = false;
19580         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
19581         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ChannelDetails_get_channel_id(&this_ptr_conv));
19582         return ret_arr;
19583 }
19584
19585 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19586         LDKChannelDetails this_ptr_conv;
19587         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19588         this_ptr_conv.is_owned = false;
19589         LDKThirtyTwoBytes val_ref;
19590         CHECK((*env)->GetArrayLength(env, val) == 32);
19591         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
19592         ChannelDetails_set_channel_id(&this_ptr_conv, val_ref);
19593 }
19594
19595 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1counterparty(JNIEnv *env, jclass clz, int64_t this_ptr) {
19596         LDKChannelDetails this_ptr_conv;
19597         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19598         this_ptr_conv.is_owned = false;
19599         LDKChannelCounterparty ret_var = ChannelDetails_get_counterparty(&this_ptr_conv);
19600         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19601         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19602         uint64_t ret_ref = (uint64_t)ret_var.inner;
19603         if (ret_var.is_owned) {
19604                 ret_ref |= 1;
19605         }
19606         return ret_ref;
19607 }
19608
19609 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1counterparty(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19610         LDKChannelDetails this_ptr_conv;
19611         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19612         this_ptr_conv.is_owned = false;
19613         LDKChannelCounterparty val_conv;
19614         val_conv.inner = (void*)(val & (~1));
19615         val_conv.is_owned = (val & 1) || (val == 0);
19616         val_conv = ChannelCounterparty_clone(&val_conv);
19617         ChannelDetails_set_counterparty(&this_ptr_conv, val_conv);
19618 }
19619
19620 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_ptr) {
19621         LDKChannelDetails this_ptr_conv;
19622         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19623         this_ptr_conv.is_owned = false;
19624         LDKOutPoint ret_var = ChannelDetails_get_funding_txo(&this_ptr_conv);
19625         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19626         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19627         uint64_t ret_ref = (uint64_t)ret_var.inner;
19628         if (ret_var.is_owned) {
19629                 ret_ref |= 1;
19630         }
19631         return ret_ref;
19632 }
19633
19634 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19635         LDKChannelDetails this_ptr_conv;
19636         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19637         this_ptr_conv.is_owned = false;
19638         LDKOutPoint val_conv;
19639         val_conv.inner = (void*)(val & (~1));
19640         val_conv.is_owned = (val & 1) || (val == 0);
19641         val_conv = OutPoint_clone(&val_conv);
19642         ChannelDetails_set_funding_txo(&this_ptr_conv, val_conv);
19643 }
19644
19645 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
19646         LDKChannelDetails this_ptr_conv;
19647         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19648         this_ptr_conv.is_owned = false;
19649         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
19650         *ret_copy = ChannelDetails_get_short_channel_id(&this_ptr_conv);
19651         uint64_t ret_ref = (uint64_t)ret_copy;
19652         return ret_ref;
19653 }
19654
19655 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19656         LDKChannelDetails this_ptr_conv;
19657         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19658         this_ptr_conv.is_owned = false;
19659         void* val_ptr = (void*)(((uint64_t)val) & ~1);
19660         CHECK_ACCESS(val_ptr);
19661         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
19662         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1));
19663         ChannelDetails_set_short_channel_id(&this_ptr_conv, val_conv);
19664 }
19665
19666 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
19667         LDKChannelDetails this_ptr_conv;
19668         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19669         this_ptr_conv.is_owned = false;
19670         int64_t ret_val = ChannelDetails_get_channel_value_satoshis(&this_ptr_conv);
19671         return ret_val;
19672 }
19673
19674 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19675         LDKChannelDetails this_ptr_conv;
19676         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19677         this_ptr_conv.is_owned = false;
19678         ChannelDetails_set_channel_value_satoshis(&this_ptr_conv, val);
19679 }
19680
19681 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr) {
19682         LDKChannelDetails this_ptr_conv;
19683         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19684         this_ptr_conv.is_owned = false;
19685         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
19686         *ret_copy = ChannelDetails_get_unspendable_punishment_reserve(&this_ptr_conv);
19687         uint64_t ret_ref = (uint64_t)ret_copy;
19688         return ret_ref;
19689 }
19690
19691 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19692         LDKChannelDetails this_ptr_conv;
19693         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19694         this_ptr_conv.is_owned = false;
19695         void* val_ptr = (void*)(((uint64_t)val) & ~1);
19696         CHECK_ACCESS(val_ptr);
19697         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
19698         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1));
19699         ChannelDetails_set_unspendable_punishment_reserve(&this_ptr_conv, val_conv);
19700 }
19701
19702 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1user_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
19703         LDKChannelDetails this_ptr_conv;
19704         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19705         this_ptr_conv.is_owned = false;
19706         int64_t ret_val = ChannelDetails_get_user_channel_id(&this_ptr_conv);
19707         return ret_val;
19708 }
19709
19710 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1user_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19711         LDKChannelDetails this_ptr_conv;
19712         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19713         this_ptr_conv.is_owned = false;
19714         ChannelDetails_set_user_channel_id(&this_ptr_conv, val);
19715 }
19716
19717 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1outbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
19718         LDKChannelDetails this_ptr_conv;
19719         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19720         this_ptr_conv.is_owned = false;
19721         int64_t ret_val = ChannelDetails_get_outbound_capacity_msat(&this_ptr_conv);
19722         return ret_val;
19723 }
19724
19725 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1outbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19726         LDKChannelDetails this_ptr_conv;
19727         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19728         this_ptr_conv.is_owned = false;
19729         ChannelDetails_set_outbound_capacity_msat(&this_ptr_conv, val);
19730 }
19731
19732 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
19733         LDKChannelDetails this_ptr_conv;
19734         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19735         this_ptr_conv.is_owned = false;
19736         int64_t ret_val = ChannelDetails_get_inbound_capacity_msat(&this_ptr_conv);
19737         return ret_val;
19738 }
19739
19740 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1inbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19741         LDKChannelDetails this_ptr_conv;
19742         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19743         this_ptr_conv.is_owned = false;
19744         ChannelDetails_set_inbound_capacity_msat(&this_ptr_conv, val);
19745 }
19746
19747 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1confirmations_1required(JNIEnv *env, jclass clz, int64_t this_ptr) {
19748         LDKChannelDetails this_ptr_conv;
19749         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19750         this_ptr_conv.is_owned = false;
19751         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
19752         *ret_copy = ChannelDetails_get_confirmations_required(&this_ptr_conv);
19753         uint64_t ret_ref = (uint64_t)ret_copy;
19754         return ret_ref;
19755 }
19756
19757 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1confirmations_1required(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19758         LDKChannelDetails this_ptr_conv;
19759         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19760         this_ptr_conv.is_owned = false;
19761         void* val_ptr = (void*)(((uint64_t)val) & ~1);
19762         CHECK_ACCESS(val_ptr);
19763         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
19764         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uint64_t)val) & ~1));
19765         ChannelDetails_set_confirmations_required(&this_ptr_conv, val_conv);
19766 }
19767
19768 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1force_1close_1spend_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
19769         LDKChannelDetails this_ptr_conv;
19770         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19771         this_ptr_conv.is_owned = false;
19772         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
19773         *ret_copy = ChannelDetails_get_force_close_spend_delay(&this_ptr_conv);
19774         uint64_t ret_ref = (uint64_t)ret_copy;
19775         return ret_ref;
19776 }
19777
19778 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) {
19779         LDKChannelDetails this_ptr_conv;
19780         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19781         this_ptr_conv.is_owned = false;
19782         void* val_ptr = (void*)(((uint64_t)val) & ~1);
19783         CHECK_ACCESS(val_ptr);
19784         LDKCOption_u16Z val_conv = *(LDKCOption_u16Z*)(val_ptr);
19785         val_conv = COption_u16Z_clone((LDKCOption_u16Z*)(((uint64_t)val) & ~1));
19786         ChannelDetails_set_force_close_spend_delay(&this_ptr_conv, val_conv);
19787 }
19788
19789 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_ptr) {
19790         LDKChannelDetails this_ptr_conv;
19791         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19792         this_ptr_conv.is_owned = false;
19793         jboolean ret_val = ChannelDetails_get_is_outbound(&this_ptr_conv);
19794         return ret_val;
19795 }
19796
19797 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
19798         LDKChannelDetails this_ptr_conv;
19799         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19800         this_ptr_conv.is_owned = false;
19801         ChannelDetails_set_is_outbound(&this_ptr_conv, val);
19802 }
19803
19804 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1funding_1locked(JNIEnv *env, jclass clz, int64_t this_ptr) {
19805         LDKChannelDetails this_ptr_conv;
19806         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19807         this_ptr_conv.is_owned = false;
19808         jboolean ret_val = ChannelDetails_get_is_funding_locked(&this_ptr_conv);
19809         return ret_val;
19810 }
19811
19812 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1funding_1locked(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
19813         LDKChannelDetails this_ptr_conv;
19814         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19815         this_ptr_conv.is_owned = false;
19816         ChannelDetails_set_is_funding_locked(&this_ptr_conv, val);
19817 }
19818
19819 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1usable(JNIEnv *env, jclass clz, int64_t this_ptr) {
19820         LDKChannelDetails this_ptr_conv;
19821         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19822         this_ptr_conv.is_owned = false;
19823         jboolean ret_val = ChannelDetails_get_is_usable(&this_ptr_conv);
19824         return ret_val;
19825 }
19826
19827 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1usable(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
19828         LDKChannelDetails this_ptr_conv;
19829         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19830         this_ptr_conv.is_owned = false;
19831         ChannelDetails_set_is_usable(&this_ptr_conv, val);
19832 }
19833
19834 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1public(JNIEnv *env, jclass clz, int64_t this_ptr) {
19835         LDKChannelDetails this_ptr_conv;
19836         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19837         this_ptr_conv.is_owned = false;
19838         jboolean ret_val = ChannelDetails_get_is_public(&this_ptr_conv);
19839         return ret_val;
19840 }
19841
19842 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1public(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
19843         LDKChannelDetails this_ptr_conv;
19844         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19845         this_ptr_conv.is_owned = false;
19846         ChannelDetails_set_is_public(&this_ptr_conv, val);
19847 }
19848
19849 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) {
19850         LDKThirtyTwoBytes channel_id_arg_ref;
19851         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
19852         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
19853         LDKChannelCounterparty counterparty_arg_conv;
19854         counterparty_arg_conv.inner = (void*)(counterparty_arg & (~1));
19855         counterparty_arg_conv.is_owned = (counterparty_arg & 1) || (counterparty_arg == 0);
19856         counterparty_arg_conv = ChannelCounterparty_clone(&counterparty_arg_conv);
19857         LDKOutPoint funding_txo_arg_conv;
19858         funding_txo_arg_conv.inner = (void*)(funding_txo_arg & (~1));
19859         funding_txo_arg_conv.is_owned = (funding_txo_arg & 1) || (funding_txo_arg == 0);
19860         funding_txo_arg_conv = OutPoint_clone(&funding_txo_arg_conv);
19861         void* short_channel_id_arg_ptr = (void*)(((uint64_t)short_channel_id_arg) & ~1);
19862         CHECK_ACCESS(short_channel_id_arg_ptr);
19863         LDKCOption_u64Z short_channel_id_arg_conv = *(LDKCOption_u64Z*)(short_channel_id_arg_ptr);
19864         short_channel_id_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)short_channel_id_arg) & ~1));
19865         void* unspendable_punishment_reserve_arg_ptr = (void*)(((uint64_t)unspendable_punishment_reserve_arg) & ~1);
19866         CHECK_ACCESS(unspendable_punishment_reserve_arg_ptr);
19867         LDKCOption_u64Z unspendable_punishment_reserve_arg_conv = *(LDKCOption_u64Z*)(unspendable_punishment_reserve_arg_ptr);
19868         void* confirmations_required_arg_ptr = (void*)(((uint64_t)confirmations_required_arg) & ~1);
19869         CHECK_ACCESS(confirmations_required_arg_ptr);
19870         LDKCOption_u32Z confirmations_required_arg_conv = *(LDKCOption_u32Z*)(confirmations_required_arg_ptr);
19871         confirmations_required_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uint64_t)confirmations_required_arg) & ~1));
19872         void* force_close_spend_delay_arg_ptr = (void*)(((uint64_t)force_close_spend_delay_arg) & ~1);
19873         CHECK_ACCESS(force_close_spend_delay_arg_ptr);
19874         LDKCOption_u16Z force_close_spend_delay_arg_conv = *(LDKCOption_u16Z*)(force_close_spend_delay_arg_ptr);
19875         force_close_spend_delay_arg_conv = COption_u16Z_clone((LDKCOption_u16Z*)(((uint64_t)force_close_spend_delay_arg) & ~1));
19876         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);
19877         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19878         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19879         uint64_t ret_ref = (uint64_t)ret_var.inner;
19880         if (ret_var.is_owned) {
19881                 ret_ref |= 1;
19882         }
19883         return ret_ref;
19884 }
19885
19886 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19887         LDKChannelDetails orig_conv;
19888         orig_conv.inner = (void*)(orig & (~1));
19889         orig_conv.is_owned = false;
19890         LDKChannelDetails ret_var = ChannelDetails_clone(&orig_conv);
19891         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19892         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19893         uint64_t ret_ref = (uint64_t)ret_var.inner;
19894         if (ret_var.is_owned) {
19895                 ret_ref |= 1;
19896         }
19897         return ret_ref;
19898 }
19899
19900 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
19901         if ((this_ptr & 1) != 0) return;
19902         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
19903         CHECK_ACCESS(this_ptr_ptr);
19904         LDKPaymentSendFailure this_ptr_conv = *(LDKPaymentSendFailure*)(this_ptr_ptr);
19905         FREE((void*)this_ptr);
19906         PaymentSendFailure_free(this_ptr_conv);
19907 }
19908
19909 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19910         LDKPaymentSendFailure* orig_conv = (LDKPaymentSendFailure*)orig;
19911         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
19912         *ret_copy = PaymentSendFailure_clone(orig_conv);
19913         uint64_t ret_ref = (uint64_t)ret_copy;
19914         return ret_ref;
19915 }
19916
19917 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1parameter_1error(JNIEnv *env, jclass clz, int64_t a) {
19918         void* a_ptr = (void*)(((uint64_t)a) & ~1);
19919         CHECK_ACCESS(a_ptr);
19920         LDKAPIError a_conv = *(LDKAPIError*)(a_ptr);
19921         a_conv = APIError_clone((LDKAPIError*)(((uint64_t)a) & ~1));
19922         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
19923         *ret_copy = PaymentSendFailure_parameter_error(a_conv);
19924         uint64_t ret_ref = (uint64_t)ret_copy;
19925         return ret_ref;
19926 }
19927
19928 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1path_1parameter_1error(JNIEnv *env, jclass clz, int64_tArray a) {
19929         LDKCVec_CResult_NoneAPIErrorZZ a_constr;
19930         a_constr.datalen = (*env)->GetArrayLength(env, a);
19931         if (a_constr.datalen > 0)
19932                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
19933         else
19934                 a_constr.data = NULL;
19935         int64_t* a_vals = (*env)->GetLongArrayElements (env, a, NULL);
19936         for (size_t w = 0; w < a_constr.datalen; w++) {
19937                 int64_t a_conv_22 = a_vals[w];
19938                 void* a_conv_22_ptr = (void*)(((uint64_t)a_conv_22) & ~1);
19939                 CHECK_ACCESS(a_conv_22_ptr);
19940                 LDKCResult_NoneAPIErrorZ a_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(a_conv_22_ptr);
19941                 a_conv_22_conv = CResult_NoneAPIErrorZ_clone((LDKCResult_NoneAPIErrorZ*)(((uint64_t)a_conv_22) & ~1));
19942                 a_constr.data[w] = a_conv_22_conv;
19943         }
19944         (*env)->ReleaseLongArrayElements(env, a, a_vals, 0);
19945         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
19946         *ret_copy = PaymentSendFailure_path_parameter_error(a_constr);
19947         uint64_t ret_ref = (uint64_t)ret_copy;
19948         return ret_ref;
19949 }
19950
19951 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1all_1failed_1retry_1safe(JNIEnv *env, jclass clz, int64_tArray a) {
19952         LDKCVec_APIErrorZ a_constr;
19953         a_constr.datalen = (*env)->GetArrayLength(env, a);
19954         if (a_constr.datalen > 0)
19955                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
19956         else
19957                 a_constr.data = NULL;
19958         int64_t* a_vals = (*env)->GetLongArrayElements (env, a, NULL);
19959         for (size_t k = 0; k < a_constr.datalen; k++) {
19960                 int64_t a_conv_10 = a_vals[k];
19961                 void* a_conv_10_ptr = (void*)(((uint64_t)a_conv_10) & ~1);
19962                 CHECK_ACCESS(a_conv_10_ptr);
19963                 LDKAPIError a_conv_10_conv = *(LDKAPIError*)(a_conv_10_ptr);
19964                 a_conv_10_conv = APIError_clone((LDKAPIError*)(((uint64_t)a_conv_10) & ~1));
19965                 a_constr.data[k] = a_conv_10_conv;
19966         }
19967         (*env)->ReleaseLongArrayElements(env, a, a_vals, 0);
19968         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
19969         *ret_copy = PaymentSendFailure_all_failed_retry_safe(a_constr);
19970         uint64_t ret_ref = (uint64_t)ret_copy;
19971         return ret_ref;
19972 }
19973
19974 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1partial_1failure(JNIEnv *env, jclass clz, int64_tArray a) {
19975         LDKCVec_CResult_NoneAPIErrorZZ a_constr;
19976         a_constr.datalen = (*env)->GetArrayLength(env, a);
19977         if (a_constr.datalen > 0)
19978                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
19979         else
19980                 a_constr.data = NULL;
19981         int64_t* a_vals = (*env)->GetLongArrayElements (env, a, NULL);
19982         for (size_t w = 0; w < a_constr.datalen; w++) {
19983                 int64_t a_conv_22 = a_vals[w];
19984                 void* a_conv_22_ptr = (void*)(((uint64_t)a_conv_22) & ~1);
19985                 CHECK_ACCESS(a_conv_22_ptr);
19986                 LDKCResult_NoneAPIErrorZ a_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(a_conv_22_ptr);
19987                 a_conv_22_conv = CResult_NoneAPIErrorZ_clone((LDKCResult_NoneAPIErrorZ*)(((uint64_t)a_conv_22) & ~1));
19988                 a_constr.data[w] = a_conv_22_conv;
19989         }
19990         (*env)->ReleaseLongArrayElements(env, a, a_vals, 0);
19991         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
19992         *ret_copy = PaymentSendFailure_partial_failure(a_constr);
19993         uint64_t ret_ref = (uint64_t)ret_copy;
19994         return ret_ref;
19995 }
19996
19997 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) {
19998         void* fee_est_ptr = (void*)(((uint64_t)fee_est) & ~1);
19999         CHECK_ACCESS(fee_est_ptr);
20000         LDKFeeEstimator fee_est_conv = *(LDKFeeEstimator*)(fee_est_ptr);
20001         if (fee_est_conv.free == LDKFeeEstimator_JCalls_free) {
20002                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
20003                 LDKFeeEstimator_JCalls_cloned(&fee_est_conv);
20004         }
20005         void* chain_monitor_ptr = (void*)(((uint64_t)chain_monitor) & ~1);
20006         CHECK_ACCESS(chain_monitor_ptr);
20007         LDKWatch chain_monitor_conv = *(LDKWatch*)(chain_monitor_ptr);
20008         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
20009                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
20010                 LDKWatch_JCalls_cloned(&chain_monitor_conv);
20011         }
20012         void* tx_broadcaster_ptr = (void*)(((uint64_t)tx_broadcaster) & ~1);
20013         CHECK_ACCESS(tx_broadcaster_ptr);
20014         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(tx_broadcaster_ptr);
20015         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
20016                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
20017                 LDKBroadcasterInterface_JCalls_cloned(&tx_broadcaster_conv);
20018         }
20019         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
20020         CHECK_ACCESS(logger_ptr);
20021         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
20022         if (logger_conv.free == LDKLogger_JCalls_free) {
20023                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
20024                 LDKLogger_JCalls_cloned(&logger_conv);
20025         }
20026         void* keys_manager_ptr = (void*)(((uint64_t)keys_manager) & ~1);
20027         CHECK_ACCESS(keys_manager_ptr);
20028         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
20029         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
20030                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
20031                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
20032         }
20033         LDKUserConfig config_conv;
20034         config_conv.inner = (void*)(config & (~1));
20035         config_conv.is_owned = (config & 1) || (config == 0);
20036         config_conv = UserConfig_clone(&config_conv);
20037         LDKChainParameters params_conv;
20038         params_conv.inner = (void*)(params & (~1));
20039         params_conv.is_owned = (params & 1) || (params == 0);
20040         params_conv = ChainParameters_clone(&params_conv);
20041         LDKChannelManager ret_var = ChannelManager_new(fee_est_conv, chain_monitor_conv, tx_broadcaster_conv, logger_conv, keys_manager_conv, config_conv, params_conv);
20042         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20043         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20044         uint64_t ret_ref = (uint64_t)ret_var.inner;
20045         if (ret_var.is_owned) {
20046                 ret_ref |= 1;
20047         }
20048         return ret_ref;
20049 }
20050
20051 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1current_1default_1configuration(JNIEnv *env, jclass clz, int64_t this_arg) {
20052         LDKChannelManager this_arg_conv;
20053         this_arg_conv.inner = (void*)(this_arg & (~1));
20054         this_arg_conv.is_owned = false;
20055         LDKUserConfig ret_var = ChannelManager_get_current_default_configuration(&this_arg_conv);
20056         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20057         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20058         uint64_t ret_ref = (uint64_t)ret_var.inner;
20059         if (ret_var.is_owned) {
20060                 ret_ref |= 1;
20061         }
20062         return ret_ref;
20063 }
20064
20065 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) {
20066         LDKChannelManager this_arg_conv;
20067         this_arg_conv.inner = (void*)(this_arg & (~1));
20068         this_arg_conv.is_owned = false;
20069         LDKPublicKey their_network_key_ref;
20070         CHECK((*env)->GetArrayLength(env, their_network_key) == 33);
20071         (*env)->GetByteArrayRegion(env, their_network_key, 0, 33, their_network_key_ref.compressed_form);
20072         LDKUserConfig override_config_conv;
20073         override_config_conv.inner = (void*)(override_config & (~1));
20074         override_config_conv.is_owned = (override_config & 1) || (override_config == 0);
20075         override_config_conv = UserConfig_clone(&override_config_conv);
20076         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
20077         *ret_conv = ChannelManager_create_channel(&this_arg_conv, their_network_key_ref, channel_value_satoshis, push_msat, user_channel_id, override_config_conv);
20078         return (uint64_t)ret_conv;
20079 }
20080
20081 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
20082         LDKChannelManager this_arg_conv;
20083         this_arg_conv.inner = (void*)(this_arg & (~1));
20084         this_arg_conv.is_owned = false;
20085         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_channels(&this_arg_conv);
20086         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
20087         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
20088         for (size_t q = 0; q < ret_var.datalen; q++) {
20089                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
20090                 CHECK((((uint64_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20091                 CHECK((((uint64_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20092                 uint64_t ret_conv_16_ref = (uint64_t)ret_conv_16_var.inner;
20093                 if (ret_conv_16_var.is_owned) {
20094                         ret_conv_16_ref |= 1;
20095                 }
20096                 ret_arr_ptr[q] = ret_conv_16_ref;
20097         }
20098         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
20099         FREE(ret_var.data);
20100         return ret_arr;
20101 }
20102
20103 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1usable_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
20104         LDKChannelManager this_arg_conv;
20105         this_arg_conv.inner = (void*)(this_arg & (~1));
20106         this_arg_conv.is_owned = false;
20107         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_usable_channels(&this_arg_conv);
20108         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
20109         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
20110         for (size_t q = 0; q < ret_var.datalen; q++) {
20111                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
20112                 CHECK((((uint64_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20113                 CHECK((((uint64_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20114                 uint64_t ret_conv_16_ref = (uint64_t)ret_conv_16_var.inner;
20115                 if (ret_conv_16_var.is_owned) {
20116                         ret_conv_16_ref |= 1;
20117                 }
20118                 ret_arr_ptr[q] = ret_conv_16_ref;
20119         }
20120         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
20121         FREE(ret_var.data);
20122         return ret_arr;
20123 }
20124
20125 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1close_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray channel_id) {
20126         LDKChannelManager this_arg_conv;
20127         this_arg_conv.inner = (void*)(this_arg & (~1));
20128         this_arg_conv.is_owned = false;
20129         unsigned char channel_id_arr[32];
20130         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
20131         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
20132         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
20133         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
20134         *ret_conv = ChannelManager_close_channel(&this_arg_conv, channel_id_ref);
20135         return (uint64_t)ret_conv;
20136 }
20137
20138 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) {
20139         LDKChannelManager this_arg_conv;
20140         this_arg_conv.inner = (void*)(this_arg & (~1));
20141         this_arg_conv.is_owned = false;
20142         unsigned char channel_id_arr[32];
20143         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
20144         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
20145         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
20146         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
20147         *ret_conv = ChannelManager_close_channel_with_target_feerate(&this_arg_conv, channel_id_ref, target_feerate_sats_per_1000_weight);
20148         return (uint64_t)ret_conv;
20149 }
20150
20151 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) {
20152         LDKChannelManager this_arg_conv;
20153         this_arg_conv.inner = (void*)(this_arg & (~1));
20154         this_arg_conv.is_owned = false;
20155         unsigned char channel_id_arr[32];
20156         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
20157         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
20158         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
20159         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
20160         *ret_conv = ChannelManager_force_close_channel(&this_arg_conv, channel_id_ref);
20161         return (uint64_t)ret_conv;
20162 }
20163
20164 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1force_1close_1all_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
20165         LDKChannelManager this_arg_conv;
20166         this_arg_conv.inner = (void*)(this_arg & (~1));
20167         this_arg_conv.is_owned = false;
20168         ChannelManager_force_close_all_channels(&this_arg_conv);
20169 }
20170
20171 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) {
20172         LDKChannelManager this_arg_conv;
20173         this_arg_conv.inner = (void*)(this_arg & (~1));
20174         this_arg_conv.is_owned = false;
20175         LDKRoute route_conv;
20176         route_conv.inner = (void*)(route & (~1));
20177         route_conv.is_owned = false;
20178         LDKThirtyTwoBytes payment_hash_ref;
20179         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
20180         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
20181         LDKThirtyTwoBytes payment_secret_ref;
20182         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
20183         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
20184         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
20185         *ret_conv = ChannelManager_send_payment(&this_arg_conv, &route_conv, payment_hash_ref, payment_secret_ref);
20186         return (uint64_t)ret_conv;
20187 }
20188
20189 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) {
20190         LDKChannelManager this_arg_conv;
20191         this_arg_conv.inner = (void*)(this_arg & (~1));
20192         this_arg_conv.is_owned = false;
20193         LDKRoute route_conv;
20194         route_conv.inner = (void*)(route & (~1));
20195         route_conv.is_owned = false;
20196         LDKPaymentId payment_id_conv;
20197         payment_id_conv.inner = (void*)(payment_id & (~1));
20198         payment_id_conv.is_owned = (payment_id & 1) || (payment_id == 0);
20199         payment_id_conv = PaymentId_clone(&payment_id_conv);
20200         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
20201         *ret_conv = ChannelManager_retry_payment(&this_arg_conv, &route_conv, payment_id_conv);
20202         return (uint64_t)ret_conv;
20203 }
20204
20205 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) {
20206         LDKChannelManager this_arg_conv;
20207         this_arg_conv.inner = (void*)(this_arg & (~1));
20208         this_arg_conv.is_owned = false;
20209         LDKRoute route_conv;
20210         route_conv.inner = (void*)(route & (~1));
20211         route_conv.is_owned = false;
20212         LDKThirtyTwoBytes payment_preimage_ref;
20213         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
20214         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
20215         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
20216         *ret_conv = ChannelManager_send_spontaneous_payment(&this_arg_conv, &route_conv, payment_preimage_ref);
20217         return (uint64_t)ret_conv;
20218 }
20219
20220 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) {
20221         LDKChannelManager this_arg_conv;
20222         this_arg_conv.inner = (void*)(this_arg & (~1));
20223         this_arg_conv.is_owned = false;
20224         unsigned char temporary_channel_id_arr[32];
20225         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
20226         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_arr);
20227         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
20228         LDKTransaction funding_transaction_ref;
20229         funding_transaction_ref.datalen = (*env)->GetArrayLength(env, funding_transaction);
20230         funding_transaction_ref.data = MALLOC(funding_transaction_ref.datalen, "LDKTransaction Bytes");
20231         (*env)->GetByteArrayRegion(env, funding_transaction, 0, funding_transaction_ref.datalen, funding_transaction_ref.data);
20232         funding_transaction_ref.data_is_owned = true;
20233         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
20234         *ret_conv = ChannelManager_funding_transaction_generated(&this_arg_conv, temporary_channel_id_ref, funding_transaction_ref);
20235         return (uint64_t)ret_conv;
20236 }
20237
20238 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) {
20239         LDKChannelManager this_arg_conv;
20240         this_arg_conv.inner = (void*)(this_arg & (~1));
20241         this_arg_conv.is_owned = false;
20242         LDKThreeBytes rgb_ref;
20243         CHECK((*env)->GetArrayLength(env, rgb) == 3);
20244         (*env)->GetByteArrayRegion(env, rgb, 0, 3, rgb_ref.data);
20245         LDKThirtyTwoBytes alias_ref;
20246         CHECK((*env)->GetArrayLength(env, alias) == 32);
20247         (*env)->GetByteArrayRegion(env, alias, 0, 32, alias_ref.data);
20248         LDKCVec_NetAddressZ addresses_constr;
20249         addresses_constr.datalen = (*env)->GetArrayLength(env, addresses);
20250         if (addresses_constr.datalen > 0)
20251                 addresses_constr.data = MALLOC(addresses_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
20252         else
20253                 addresses_constr.data = NULL;
20254         int64_t* addresses_vals = (*env)->GetLongArrayElements (env, addresses, NULL);
20255         for (size_t m = 0; m < addresses_constr.datalen; m++) {
20256                 int64_t addresses_conv_12 = addresses_vals[m];
20257                 void* addresses_conv_12_ptr = (void*)(((uint64_t)addresses_conv_12) & ~1);
20258                 CHECK_ACCESS(addresses_conv_12_ptr);
20259                 LDKNetAddress addresses_conv_12_conv = *(LDKNetAddress*)(addresses_conv_12_ptr);
20260                 addresses_constr.data[m] = addresses_conv_12_conv;
20261         }
20262         (*env)->ReleaseLongArrayElements(env, addresses, addresses_vals, 0);
20263         ChannelManager_broadcast_node_announcement(&this_arg_conv, rgb_ref, alias_ref, addresses_constr);
20264 }
20265
20266 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1process_1pending_1htlc_1forwards(JNIEnv *env, jclass clz, int64_t this_arg) {
20267         LDKChannelManager this_arg_conv;
20268         this_arg_conv.inner = (void*)(this_arg & (~1));
20269         this_arg_conv.is_owned = false;
20270         ChannelManager_process_pending_htlc_forwards(&this_arg_conv);
20271 }
20272
20273 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1timer_1tick_1occurred(JNIEnv *env, jclass clz, int64_t this_arg) {
20274         LDKChannelManager this_arg_conv;
20275         this_arg_conv.inner = (void*)(this_arg & (~1));
20276         this_arg_conv.is_owned = false;
20277         ChannelManager_timer_tick_occurred(&this_arg_conv);
20278 }
20279
20280 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelManager_1fail_1htlc_1backwards(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_hash) {
20281         LDKChannelManager this_arg_conv;
20282         this_arg_conv.inner = (void*)(this_arg & (~1));
20283         this_arg_conv.is_owned = false;
20284         unsigned char payment_hash_arr[32];
20285         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
20286         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_arr);
20287         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
20288         jboolean ret_val = ChannelManager_fail_htlc_backwards(&this_arg_conv, payment_hash_ref);
20289         return ret_val;
20290 }
20291
20292 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelManager_1claim_1funds(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_preimage) {
20293         LDKChannelManager this_arg_conv;
20294         this_arg_conv.inner = (void*)(this_arg & (~1));
20295         this_arg_conv.is_owned = false;
20296         LDKThirtyTwoBytes payment_preimage_ref;
20297         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
20298         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
20299         jboolean ret_val = ChannelManager_claim_funds(&this_arg_conv, payment_preimage_ref);
20300         return ret_val;
20301 }
20302
20303 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1our_1node_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
20304         LDKChannelManager this_arg_conv;
20305         this_arg_conv.inner = (void*)(this_arg & (~1));
20306         this_arg_conv.is_owned = false;
20307         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
20308         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelManager_get_our_node_id(&this_arg_conv).compressed_form);
20309         return ret_arr;
20310 }
20311
20312 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) {
20313         LDKChannelManager this_arg_conv;
20314         this_arg_conv.inner = (void*)(this_arg & (~1));
20315         this_arg_conv.is_owned = false;
20316         LDKOutPoint funding_txo_conv;
20317         funding_txo_conv.inner = (void*)(funding_txo & (~1));
20318         funding_txo_conv.is_owned = false;
20319         ChannelManager_channel_monitor_updated(&this_arg_conv, &funding_txo_conv, highest_applied_update_id);
20320 }
20321
20322 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) {
20323         LDKChannelManager this_arg_conv;
20324         this_arg_conv.inner = (void*)(this_arg & (~1));
20325         this_arg_conv.is_owned = false;
20326         void* min_value_msat_ptr = (void*)(((uint64_t)min_value_msat) & ~1);
20327         CHECK_ACCESS(min_value_msat_ptr);
20328         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
20329         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)min_value_msat) & ~1));
20330         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
20331         *ret_conv = ChannelManager_create_inbound_payment(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs, user_payment_id);
20332         return ((uint64_t)ret_conv);
20333 }
20334
20335 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) {
20336         LDKChannelManager this_arg_conv;
20337         this_arg_conv.inner = (void*)(this_arg & (~1));
20338         this_arg_conv.is_owned = false;
20339         LDKThirtyTwoBytes payment_hash_ref;
20340         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
20341         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
20342         void* min_value_msat_ptr = (void*)(((uint64_t)min_value_msat) & ~1);
20343         CHECK_ACCESS(min_value_msat_ptr);
20344         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
20345         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)min_value_msat) & ~1));
20346         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
20347         *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);
20348         return (uint64_t)ret_conv;
20349 }
20350
20351 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
20352         LDKChannelManager this_arg_conv;
20353         this_arg_conv.inner = (void*)(this_arg & (~1));
20354         this_arg_conv.is_owned = false;
20355         LDKMessageSendEventsProvider* ret_ret =MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
20356         *ret_ret = ChannelManager_as_MessageSendEventsProvider(&this_arg_conv);
20357         return (uint64_t)ret_ret;
20358 }
20359
20360 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1EventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
20361         LDKChannelManager this_arg_conv;
20362         this_arg_conv.inner = (void*)(this_arg & (~1));
20363         this_arg_conv.is_owned = false;
20364         LDKEventsProvider* ret_ret =MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
20365         *ret_ret = ChannelManager_as_EventsProvider(&this_arg_conv);
20366         return (uint64_t)ret_ret;
20367 }
20368
20369 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Listen(JNIEnv *env, jclass clz, int64_t this_arg) {
20370         LDKChannelManager this_arg_conv;
20371         this_arg_conv.inner = (void*)(this_arg & (~1));
20372         this_arg_conv.is_owned = false;
20373         LDKListen* ret_ret =MALLOC(sizeof(LDKListen), "LDKListen");
20374         *ret_ret = ChannelManager_as_Listen(&this_arg_conv);
20375         return (uint64_t)ret_ret;
20376 }
20377
20378 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Confirm(JNIEnv *env, jclass clz, int64_t this_arg) {
20379         LDKChannelManager this_arg_conv;
20380         this_arg_conv.inner = (void*)(this_arg & (~1));
20381         this_arg_conv.is_owned = false;
20382         LDKConfirm* ret_ret =MALLOC(sizeof(LDKConfirm), "LDKConfirm");
20383         *ret_ret = ChannelManager_as_Confirm(&this_arg_conv);
20384         return (uint64_t)ret_ret;
20385 }
20386
20387 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) {
20388         LDKChannelManager this_arg_conv;
20389         this_arg_conv.inner = (void*)(this_arg & (~1));
20390         this_arg_conv.is_owned = false;
20391         jboolean ret_val = ChannelManager_await_persistable_update_timeout(&this_arg_conv, max_wait);
20392         return ret_val;
20393 }
20394
20395 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1await_1persistable_1update(JNIEnv *env, jclass clz, int64_t this_arg) {
20396         LDKChannelManager this_arg_conv;
20397         this_arg_conv.inner = (void*)(this_arg & (~1));
20398         this_arg_conv.is_owned = false;
20399         ChannelManager_await_persistable_update(&this_arg_conv);
20400 }
20401
20402 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1current_1best_1block(JNIEnv *env, jclass clz, int64_t this_arg) {
20403         LDKChannelManager this_arg_conv;
20404         this_arg_conv.inner = (void*)(this_arg & (~1));
20405         this_arg_conv.is_owned = false;
20406         LDKBestBlock ret_var = ChannelManager_current_best_block(&this_arg_conv);
20407         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20408         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20409         uint64_t ret_ref = (uint64_t)ret_var.inner;
20410         if (ret_var.is_owned) {
20411                 ret_ref |= 1;
20412         }
20413         return ret_ref;
20414 }
20415
20416 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1ChannelMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
20417         LDKChannelManager this_arg_conv;
20418         this_arg_conv.inner = (void*)(this_arg & (~1));
20419         this_arg_conv.is_owned = false;
20420         LDKChannelMessageHandler* ret_ret =MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
20421         *ret_ret = ChannelManager_as_ChannelMessageHandler(&this_arg_conv);
20422         return (uint64_t)ret_ret;
20423 }
20424
20425 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1write(JNIEnv *env, jclass clz, int64_t obj) {
20426         LDKChannelManager obj_conv;
20427         obj_conv.inner = (void*)(obj & (~1));
20428         obj_conv.is_owned = false;
20429         LDKCVec_u8Z ret_var = ChannelManager_write(&obj_conv);
20430         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20431         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20432         CVec_u8Z_free(ret_var);
20433         return ret_arr;
20434 }
20435
20436 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20437         LDKChannelManagerReadArgs this_obj_conv;
20438         this_obj_conv.inner = (void*)(this_obj & (~1));
20439         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20440         ChannelManagerReadArgs_free(this_obj_conv);
20441 }
20442
20443 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1keys_1manager(JNIEnv *env, jclass clz, int64_t this_ptr) {
20444         LDKChannelManagerReadArgs this_ptr_conv;
20445         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20446         this_ptr_conv.is_owned = false;
20447         uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_keys_manager(&this_ptr_conv);
20448         return ret_ret;
20449 }
20450
20451 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1keys_1manager(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20452         LDKChannelManagerReadArgs this_ptr_conv;
20453         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20454         this_ptr_conv.is_owned = false;
20455         void* val_ptr = (void*)(((uint64_t)val) & ~1);
20456         CHECK_ACCESS(val_ptr);
20457         LDKKeysInterface val_conv = *(LDKKeysInterface*)(val_ptr);
20458         if (val_conv.free == LDKKeysInterface_JCalls_free) {
20459                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
20460                 LDKKeysInterface_JCalls_cloned(&val_conv);
20461         }
20462         ChannelManagerReadArgs_set_keys_manager(&this_ptr_conv, val_conv);
20463 }
20464
20465 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1fee_1estimator(JNIEnv *env, jclass clz, int64_t this_ptr) {
20466         LDKChannelManagerReadArgs this_ptr_conv;
20467         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20468         this_ptr_conv.is_owned = false;
20469         uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_fee_estimator(&this_ptr_conv);
20470         return ret_ret;
20471 }
20472
20473 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1fee_1estimator(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20474         LDKChannelManagerReadArgs this_ptr_conv;
20475         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20476         this_ptr_conv.is_owned = false;
20477         void* val_ptr = (void*)(((uint64_t)val) & ~1);
20478         CHECK_ACCESS(val_ptr);
20479         LDKFeeEstimator val_conv = *(LDKFeeEstimator*)(val_ptr);
20480         if (val_conv.free == LDKFeeEstimator_JCalls_free) {
20481                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
20482                 LDKFeeEstimator_JCalls_cloned(&val_conv);
20483         }
20484         ChannelManagerReadArgs_set_fee_estimator(&this_ptr_conv, val_conv);
20485 }
20486
20487 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1chain_1monitor(JNIEnv *env, jclass clz, int64_t this_ptr) {
20488         LDKChannelManagerReadArgs this_ptr_conv;
20489         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20490         this_ptr_conv.is_owned = false;
20491         uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_chain_monitor(&this_ptr_conv);
20492         return ret_ret;
20493 }
20494
20495 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1chain_1monitor(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20496         LDKChannelManagerReadArgs this_ptr_conv;
20497         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20498         this_ptr_conv.is_owned = false;
20499         void* val_ptr = (void*)(((uint64_t)val) & ~1);
20500         CHECK_ACCESS(val_ptr);
20501         LDKWatch val_conv = *(LDKWatch*)(val_ptr);
20502         if (val_conv.free == LDKWatch_JCalls_free) {
20503                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
20504                 LDKWatch_JCalls_cloned(&val_conv);
20505         }
20506         ChannelManagerReadArgs_set_chain_monitor(&this_ptr_conv, val_conv);
20507 }
20508
20509 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1tx_1broadcaster(JNIEnv *env, jclass clz, int64_t this_ptr) {
20510         LDKChannelManagerReadArgs this_ptr_conv;
20511         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20512         this_ptr_conv.is_owned = false;
20513         uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_tx_broadcaster(&this_ptr_conv);
20514         return ret_ret;
20515 }
20516
20517 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1tx_1broadcaster(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20518         LDKChannelManagerReadArgs this_ptr_conv;
20519         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20520         this_ptr_conv.is_owned = false;
20521         void* val_ptr = (void*)(((uint64_t)val) & ~1);
20522         CHECK_ACCESS(val_ptr);
20523         LDKBroadcasterInterface val_conv = *(LDKBroadcasterInterface*)(val_ptr);
20524         if (val_conv.free == LDKBroadcasterInterface_JCalls_free) {
20525                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
20526                 LDKBroadcasterInterface_JCalls_cloned(&val_conv);
20527         }
20528         ChannelManagerReadArgs_set_tx_broadcaster(&this_ptr_conv, val_conv);
20529 }
20530
20531 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1logger(JNIEnv *env, jclass clz, int64_t this_ptr) {
20532         LDKChannelManagerReadArgs this_ptr_conv;
20533         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20534         this_ptr_conv.is_owned = false;
20535         uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_logger(&this_ptr_conv);
20536         return ret_ret;
20537 }
20538
20539 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1logger(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20540         LDKChannelManagerReadArgs this_ptr_conv;
20541         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20542         this_ptr_conv.is_owned = false;
20543         void* val_ptr = (void*)(((uint64_t)val) & ~1);
20544         CHECK_ACCESS(val_ptr);
20545         LDKLogger val_conv = *(LDKLogger*)(val_ptr);
20546         if (val_conv.free == LDKLogger_JCalls_free) {
20547                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
20548                 LDKLogger_JCalls_cloned(&val_conv);
20549         }
20550         ChannelManagerReadArgs_set_logger(&this_ptr_conv, val_conv);
20551 }
20552
20553 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1default_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
20554         LDKChannelManagerReadArgs this_ptr_conv;
20555         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20556         this_ptr_conv.is_owned = false;
20557         LDKUserConfig ret_var = ChannelManagerReadArgs_get_default_config(&this_ptr_conv);
20558         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20559         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20560         uint64_t ret_ref = (uint64_t)ret_var.inner;
20561         if (ret_var.is_owned) {
20562                 ret_ref |= 1;
20563         }
20564         return ret_ref;
20565 }
20566
20567 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1default_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20568         LDKChannelManagerReadArgs this_ptr_conv;
20569         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20570         this_ptr_conv.is_owned = false;
20571         LDKUserConfig val_conv;
20572         val_conv.inner = (void*)(val & (~1));
20573         val_conv.is_owned = (val & 1) || (val == 0);
20574         val_conv = UserConfig_clone(&val_conv);
20575         ChannelManagerReadArgs_set_default_config(&this_ptr_conv, val_conv);
20576 }
20577
20578 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) {
20579         void* keys_manager_ptr = (void*)(((uint64_t)keys_manager) & ~1);
20580         CHECK_ACCESS(keys_manager_ptr);
20581         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
20582         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
20583                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
20584                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
20585         }
20586         void* fee_estimator_ptr = (void*)(((uint64_t)fee_estimator) & ~1);
20587         CHECK_ACCESS(fee_estimator_ptr);
20588         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
20589         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
20590                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
20591                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
20592         }
20593         void* chain_monitor_ptr = (void*)(((uint64_t)chain_monitor) & ~1);
20594         CHECK_ACCESS(chain_monitor_ptr);
20595         LDKWatch chain_monitor_conv = *(LDKWatch*)(chain_monitor_ptr);
20596         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
20597                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
20598                 LDKWatch_JCalls_cloned(&chain_monitor_conv);
20599         }
20600         void* tx_broadcaster_ptr = (void*)(((uint64_t)tx_broadcaster) & ~1);
20601         CHECK_ACCESS(tx_broadcaster_ptr);
20602         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(tx_broadcaster_ptr);
20603         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
20604                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
20605                 LDKBroadcasterInterface_JCalls_cloned(&tx_broadcaster_conv);
20606         }
20607         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
20608         CHECK_ACCESS(logger_ptr);
20609         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
20610         if (logger_conv.free == LDKLogger_JCalls_free) {
20611                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
20612                 LDKLogger_JCalls_cloned(&logger_conv);
20613         }
20614         LDKUserConfig default_config_conv;
20615         default_config_conv.inner = (void*)(default_config & (~1));
20616         default_config_conv.is_owned = (default_config & 1) || (default_config == 0);
20617         default_config_conv = UserConfig_clone(&default_config_conv);
20618         LDKCVec_ChannelMonitorZ channel_monitors_constr;
20619         channel_monitors_constr.datalen = (*env)->GetArrayLength(env, channel_monitors);
20620         if (channel_monitors_constr.datalen > 0)
20621                 channel_monitors_constr.data = MALLOC(channel_monitors_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
20622         else
20623                 channel_monitors_constr.data = NULL;
20624         int64_t* channel_monitors_vals = (*env)->GetLongArrayElements (env, channel_monitors, NULL);
20625         for (size_t q = 0; q < channel_monitors_constr.datalen; q++) {
20626                 int64_t channel_monitors_conv_16 = channel_monitors_vals[q];
20627                 LDKChannelMonitor channel_monitors_conv_16_conv;
20628                 channel_monitors_conv_16_conv.inner = (void*)(channel_monitors_conv_16 & (~1));
20629                 channel_monitors_conv_16_conv.is_owned = (channel_monitors_conv_16 & 1) || (channel_monitors_conv_16 == 0);
20630                 channel_monitors_constr.data[q] = channel_monitors_conv_16_conv;
20631         }
20632         (*env)->ReleaseLongArrayElements(env, channel_monitors, channel_monitors_vals, 0);
20633         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);
20634         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20635         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20636         uint64_t ret_ref = (uint64_t)ret_var.inner;
20637         if (ret_var.is_owned) {
20638                 ret_ref |= 1;
20639         }
20640         return ret_ref;
20641 }
20642
20643 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
20644         LDKu8slice ser_ref;
20645         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20646         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20647         LDKChannelManagerReadArgs arg_conv;
20648         arg_conv.inner = (void*)(arg & (~1));
20649         arg_conv.is_owned = (arg & 1) || (arg == 0);
20650         // Warning: we need a move here but no clone is available for LDKChannelManagerReadArgs
20651         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
20652         *ret_conv = C2Tuple_BlockHashChannelManagerZ_read(ser_ref, arg_conv);
20653         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20654         return (uint64_t)ret_conv;
20655 }
20656
20657 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DecodeError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20658         LDKDecodeError this_obj_conv;
20659         this_obj_conv.inner = (void*)(this_obj & (~1));
20660         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20661         DecodeError_free(this_obj_conv);
20662 }
20663
20664 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20665         LDKDecodeError orig_conv;
20666         orig_conv.inner = (void*)(orig & (~1));
20667         orig_conv.is_owned = false;
20668         LDKDecodeError ret_var = DecodeError_clone(&orig_conv);
20669         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20670         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20671         uint64_t ret_ref = (uint64_t)ret_var.inner;
20672         if (ret_var.is_owned) {
20673                 ret_ref |= 1;
20674         }
20675         return ret_ref;
20676 }
20677
20678 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20679         LDKInit this_obj_conv;
20680         this_obj_conv.inner = (void*)(this_obj & (~1));
20681         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20682         Init_free(this_obj_conv);
20683 }
20684
20685 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
20686         LDKInit this_ptr_conv;
20687         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20688         this_ptr_conv.is_owned = false;
20689         LDKInitFeatures ret_var = Init_get_features(&this_ptr_conv);
20690         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20691         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20692         uint64_t ret_ref = (uint64_t)ret_var.inner;
20693         if (ret_var.is_owned) {
20694                 ret_ref |= 1;
20695         }
20696         return ret_ref;
20697 }
20698
20699 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20700         LDKInit this_ptr_conv;
20701         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20702         this_ptr_conv.is_owned = false;
20703         LDKInitFeatures val_conv;
20704         val_conv.inner = (void*)(val & (~1));
20705         val_conv.is_owned = (val & 1) || (val == 0);
20706         val_conv = InitFeatures_clone(&val_conv);
20707         Init_set_features(&this_ptr_conv, val_conv);
20708 }
20709
20710 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1new(JNIEnv *env, jclass clz, int64_t features_arg) {
20711         LDKInitFeatures features_arg_conv;
20712         features_arg_conv.inner = (void*)(features_arg & (~1));
20713         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
20714         features_arg_conv = InitFeatures_clone(&features_arg_conv);
20715         LDKInit ret_var = Init_new(features_arg_conv);
20716         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20717         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20718         uint64_t ret_ref = (uint64_t)ret_var.inner;
20719         if (ret_var.is_owned) {
20720                 ret_ref |= 1;
20721         }
20722         return ret_ref;
20723 }
20724
20725 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20726         LDKInit orig_conv;
20727         orig_conv.inner = (void*)(orig & (~1));
20728         orig_conv.is_owned = false;
20729         LDKInit ret_var = Init_clone(&orig_conv);
20730         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20731         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20732         uint64_t ret_ref = (uint64_t)ret_var.inner;
20733         if (ret_var.is_owned) {
20734                 ret_ref |= 1;
20735         }
20736         return ret_ref;
20737 }
20738
20739 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20740         LDKErrorMessage this_obj_conv;
20741         this_obj_conv.inner = (void*)(this_obj & (~1));
20742         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20743         ErrorMessage_free(this_obj_conv);
20744 }
20745
20746 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
20747         LDKErrorMessage this_ptr_conv;
20748         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20749         this_ptr_conv.is_owned = false;
20750         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
20751         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ErrorMessage_get_channel_id(&this_ptr_conv));
20752         return ret_arr;
20753 }
20754
20755 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20756         LDKErrorMessage this_ptr_conv;
20757         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20758         this_ptr_conv.is_owned = false;
20759         LDKThirtyTwoBytes val_ref;
20760         CHECK((*env)->GetArrayLength(env, val) == 32);
20761         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
20762         ErrorMessage_set_channel_id(&this_ptr_conv, val_ref);
20763 }
20764
20765 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1get_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
20766         LDKErrorMessage this_ptr_conv;
20767         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20768         this_ptr_conv.is_owned = false;
20769         LDKStr ret_str = ErrorMessage_get_data(&this_ptr_conv);
20770         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
20771         Str_free(ret_str);
20772         return ret_conv;
20773 }
20774
20775 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1set_1data(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
20776         LDKErrorMessage this_ptr_conv;
20777         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20778         this_ptr_conv.is_owned = false;
20779         LDKStr val_conv = java_to_owned_str(env, val);
20780         ErrorMessage_set_data(&this_ptr_conv, val_conv);
20781 }
20782
20783 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, jstring data_arg) {
20784         LDKThirtyTwoBytes channel_id_arg_ref;
20785         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
20786         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
20787         LDKStr data_arg_conv = java_to_owned_str(env, data_arg);
20788         LDKErrorMessage ret_var = ErrorMessage_new(channel_id_arg_ref, data_arg_conv);
20789         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20790         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20791         uint64_t ret_ref = (uint64_t)ret_var.inner;
20792         if (ret_var.is_owned) {
20793                 ret_ref |= 1;
20794         }
20795         return ret_ref;
20796 }
20797
20798 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20799         LDKErrorMessage orig_conv;
20800         orig_conv.inner = (void*)(orig & (~1));
20801         orig_conv.is_owned = false;
20802         LDKErrorMessage ret_var = ErrorMessage_clone(&orig_conv);
20803         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20804         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20805         uint64_t ret_ref = (uint64_t)ret_var.inner;
20806         if (ret_var.is_owned) {
20807                 ret_ref |= 1;
20808         }
20809         return ret_ref;
20810 }
20811
20812 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20813         LDKPing this_obj_conv;
20814         this_obj_conv.inner = (void*)(this_obj & (~1));
20815         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20816         Ping_free(this_obj_conv);
20817 }
20818
20819 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Ping_1get_1ponglen(JNIEnv *env, jclass clz, int64_t this_ptr) {
20820         LDKPing this_ptr_conv;
20821         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20822         this_ptr_conv.is_owned = false;
20823         int16_t ret_val = Ping_get_ponglen(&this_ptr_conv);
20824         return ret_val;
20825 }
20826
20827 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1set_1ponglen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
20828         LDKPing this_ptr_conv;
20829         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20830         this_ptr_conv.is_owned = false;
20831         Ping_set_ponglen(&this_ptr_conv, val);
20832 }
20833
20834 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Ping_1get_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr) {
20835         LDKPing this_ptr_conv;
20836         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20837         this_ptr_conv.is_owned = false;
20838         int16_t ret_val = Ping_get_byteslen(&this_ptr_conv);
20839         return ret_val;
20840 }
20841
20842 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1set_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
20843         LDKPing this_ptr_conv;
20844         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20845         this_ptr_conv.is_owned = false;
20846         Ping_set_byteslen(&this_ptr_conv, val);
20847 }
20848
20849 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1new(JNIEnv *env, jclass clz, int16_t ponglen_arg, int16_t byteslen_arg) {
20850         LDKPing ret_var = Ping_new(ponglen_arg, byteslen_arg);
20851         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20852         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20853         uint64_t ret_ref = (uint64_t)ret_var.inner;
20854         if (ret_var.is_owned) {
20855                 ret_ref |= 1;
20856         }
20857         return ret_ref;
20858 }
20859
20860 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20861         LDKPing orig_conv;
20862         orig_conv.inner = (void*)(orig & (~1));
20863         orig_conv.is_owned = false;
20864         LDKPing ret_var = Ping_clone(&orig_conv);
20865         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20866         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20867         uint64_t ret_ref = (uint64_t)ret_var.inner;
20868         if (ret_var.is_owned) {
20869                 ret_ref |= 1;
20870         }
20871         return ret_ref;
20872 }
20873
20874 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Pong_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20875         LDKPong this_obj_conv;
20876         this_obj_conv.inner = (void*)(this_obj & (~1));
20877         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20878         Pong_free(this_obj_conv);
20879 }
20880
20881 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Pong_1get_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr) {
20882         LDKPong this_ptr_conv;
20883         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20884         this_ptr_conv.is_owned = false;
20885         int16_t ret_val = Pong_get_byteslen(&this_ptr_conv);
20886         return ret_val;
20887 }
20888
20889 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Pong_1set_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
20890         LDKPong this_ptr_conv;
20891         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20892         this_ptr_conv.is_owned = false;
20893         Pong_set_byteslen(&this_ptr_conv, val);
20894 }
20895
20896 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1new(JNIEnv *env, jclass clz, int16_t byteslen_arg) {
20897         LDKPong ret_var = Pong_new(byteslen_arg);
20898         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20899         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20900         uint64_t ret_ref = (uint64_t)ret_var.inner;
20901         if (ret_var.is_owned) {
20902                 ret_ref |= 1;
20903         }
20904         return ret_ref;
20905 }
20906
20907 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20908         LDKPong orig_conv;
20909         orig_conv.inner = (void*)(orig & (~1));
20910         orig_conv.is_owned = false;
20911         LDKPong ret_var = Pong_clone(&orig_conv);
20912         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20913         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20914         uint64_t ret_ref = (uint64_t)ret_var.inner;
20915         if (ret_var.is_owned) {
20916                 ret_ref |= 1;
20917         }
20918         return ret_ref;
20919 }
20920
20921 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20922         LDKOpenChannel this_obj_conv;
20923         this_obj_conv.inner = (void*)(this_obj & (~1));
20924         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20925         OpenChannel_free(this_obj_conv);
20926 }
20927
20928 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
20929         LDKOpenChannel this_ptr_conv;
20930         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20931         this_ptr_conv.is_owned = false;
20932         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
20933         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OpenChannel_get_chain_hash(&this_ptr_conv));
20934         return ret_arr;
20935 }
20936
20937 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20938         LDKOpenChannel this_ptr_conv;
20939         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20940         this_ptr_conv.is_owned = false;
20941         LDKThirtyTwoBytes val_ref;
20942         CHECK((*env)->GetArrayLength(env, val) == 32);
20943         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
20944         OpenChannel_set_chain_hash(&this_ptr_conv, val_ref);
20945 }
20946
20947 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
20948         LDKOpenChannel this_ptr_conv;
20949         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20950         this_ptr_conv.is_owned = false;
20951         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
20952         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OpenChannel_get_temporary_channel_id(&this_ptr_conv));
20953         return ret_arr;
20954 }
20955
20956 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20957         LDKOpenChannel this_ptr_conv;
20958         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20959         this_ptr_conv.is_owned = false;
20960         LDKThirtyTwoBytes val_ref;
20961         CHECK((*env)->GetArrayLength(env, val) == 32);
20962         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
20963         OpenChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
20964 }
20965
20966 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
20967         LDKOpenChannel this_ptr_conv;
20968         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20969         this_ptr_conv.is_owned = false;
20970         int64_t ret_val = OpenChannel_get_funding_satoshis(&this_ptr_conv);
20971         return ret_val;
20972 }
20973
20974 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20975         LDKOpenChannel this_ptr_conv;
20976         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20977         this_ptr_conv.is_owned = false;
20978         OpenChannel_set_funding_satoshis(&this_ptr_conv, val);
20979 }
20980
20981 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1push_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
20982         LDKOpenChannel this_ptr_conv;
20983         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20984         this_ptr_conv.is_owned = false;
20985         int64_t ret_val = OpenChannel_get_push_msat(&this_ptr_conv);
20986         return ret_val;
20987 }
20988
20989 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1push_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20990         LDKOpenChannel this_ptr_conv;
20991         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20992         this_ptr_conv.is_owned = false;
20993         OpenChannel_set_push_msat(&this_ptr_conv, val);
20994 }
20995
20996 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
20997         LDKOpenChannel this_ptr_conv;
20998         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20999         this_ptr_conv.is_owned = false;
21000         int64_t ret_val = OpenChannel_get_dust_limit_satoshis(&this_ptr_conv);
21001         return ret_val;
21002 }
21003
21004 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
21005         LDKOpenChannel this_ptr_conv;
21006         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21007         this_ptr_conv.is_owned = false;
21008         OpenChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
21009 }
21010
21011 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) {
21012         LDKOpenChannel this_ptr_conv;
21013         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21014         this_ptr_conv.is_owned = false;
21015         int64_t ret_val = OpenChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
21016         return ret_val;
21017 }
21018
21019 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) {
21020         LDKOpenChannel this_ptr_conv;
21021         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21022         this_ptr_conv.is_owned = false;
21023         OpenChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
21024 }
21025
21026 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
21027         LDKOpenChannel this_ptr_conv;
21028         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21029         this_ptr_conv.is_owned = false;
21030         int64_t ret_val = OpenChannel_get_channel_reserve_satoshis(&this_ptr_conv);
21031         return ret_val;
21032 }
21033
21034 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
21035         LDKOpenChannel this_ptr_conv;
21036         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21037         this_ptr_conv.is_owned = false;
21038         OpenChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
21039 }
21040
21041 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
21042         LDKOpenChannel this_ptr_conv;
21043         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21044         this_ptr_conv.is_owned = false;
21045         int64_t ret_val = OpenChannel_get_htlc_minimum_msat(&this_ptr_conv);
21046         return ret_val;
21047 }
21048
21049 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
21050         LDKOpenChannel this_ptr_conv;
21051         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21052         this_ptr_conv.is_owned = false;
21053         OpenChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
21054 }
21055
21056 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr) {
21057         LDKOpenChannel this_ptr_conv;
21058         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21059         this_ptr_conv.is_owned = false;
21060         int32_t ret_val = OpenChannel_get_feerate_per_kw(&this_ptr_conv);
21061         return ret_val;
21062 }
21063
21064 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
21065         LDKOpenChannel this_ptr_conv;
21066         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21067         this_ptr_conv.is_owned = false;
21068         OpenChannel_set_feerate_per_kw(&this_ptr_conv, val);
21069 }
21070
21071 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
21072         LDKOpenChannel this_ptr_conv;
21073         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21074         this_ptr_conv.is_owned = false;
21075         int16_t ret_val = OpenChannel_get_to_self_delay(&this_ptr_conv);
21076         return ret_val;
21077 }
21078
21079 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
21080         LDKOpenChannel this_ptr_conv;
21081         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21082         this_ptr_conv.is_owned = false;
21083         OpenChannel_set_to_self_delay(&this_ptr_conv, val);
21084 }
21085
21086 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
21087         LDKOpenChannel this_ptr_conv;
21088         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21089         this_ptr_conv.is_owned = false;
21090         int16_t ret_val = OpenChannel_get_max_accepted_htlcs(&this_ptr_conv);
21091         return ret_val;
21092 }
21093
21094 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
21095         LDKOpenChannel this_ptr_conv;
21096         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21097         this_ptr_conv.is_owned = false;
21098         OpenChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
21099 }
21100
21101 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
21102         LDKOpenChannel this_ptr_conv;
21103         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21104         this_ptr_conv.is_owned = false;
21105         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
21106         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_funding_pubkey(&this_ptr_conv).compressed_form);
21107         return ret_arr;
21108 }
21109
21110 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21111         LDKOpenChannel this_ptr_conv;
21112         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21113         this_ptr_conv.is_owned = false;
21114         LDKPublicKey val_ref;
21115         CHECK((*env)->GetArrayLength(env, val) == 33);
21116         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
21117         OpenChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
21118 }
21119
21120 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
21121         LDKOpenChannel this_ptr_conv;
21122         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21123         this_ptr_conv.is_owned = false;
21124         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
21125         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form);
21126         return ret_arr;
21127 }
21128
21129 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21130         LDKOpenChannel this_ptr_conv;
21131         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21132         this_ptr_conv.is_owned = false;
21133         LDKPublicKey val_ref;
21134         CHECK((*env)->GetArrayLength(env, val) == 33);
21135         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
21136         OpenChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
21137 }
21138
21139 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
21140         LDKOpenChannel this_ptr_conv;
21141         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21142         this_ptr_conv.is_owned = false;
21143         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
21144         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_payment_point(&this_ptr_conv).compressed_form);
21145         return ret_arr;
21146 }
21147
21148 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21149         LDKOpenChannel this_ptr_conv;
21150         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21151         this_ptr_conv.is_owned = false;
21152         LDKPublicKey val_ref;
21153         CHECK((*env)->GetArrayLength(env, val) == 33);
21154         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
21155         OpenChannel_set_payment_point(&this_ptr_conv, val_ref);
21156 }
21157
21158 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
21159         LDKOpenChannel this_ptr_conv;
21160         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21161         this_ptr_conv.is_owned = false;
21162         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
21163         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
21164         return ret_arr;
21165 }
21166
21167 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21168         LDKOpenChannel this_ptr_conv;
21169         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21170         this_ptr_conv.is_owned = false;
21171         LDKPublicKey val_ref;
21172         CHECK((*env)->GetArrayLength(env, val) == 33);
21173         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
21174         OpenChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
21175 }
21176
21177 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
21178         LDKOpenChannel this_ptr_conv;
21179         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21180         this_ptr_conv.is_owned = false;
21181         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
21182         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form);
21183         return ret_arr;
21184 }
21185
21186 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21187         LDKOpenChannel this_ptr_conv;
21188         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21189         this_ptr_conv.is_owned = false;
21190         LDKPublicKey val_ref;
21191         CHECK((*env)->GetArrayLength(env, val) == 33);
21192         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
21193         OpenChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
21194 }
21195
21196 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1first_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
21197         LDKOpenChannel this_ptr_conv;
21198         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21199         this_ptr_conv.is_owned = false;
21200         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
21201         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form);
21202         return ret_arr;
21203 }
21204
21205 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) {
21206         LDKOpenChannel this_ptr_conv;
21207         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21208         this_ptr_conv.is_owned = false;
21209         LDKPublicKey val_ref;
21210         CHECK((*env)->GetArrayLength(env, val) == 33);
21211         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
21212         OpenChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
21213 }
21214
21215 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1flags(JNIEnv *env, jclass clz, int64_t this_ptr) {
21216         LDKOpenChannel this_ptr_conv;
21217         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21218         this_ptr_conv.is_owned = false;
21219         int8_t ret_val = OpenChannel_get_channel_flags(&this_ptr_conv);
21220         return ret_val;
21221 }
21222
21223 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1flags(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
21224         LDKOpenChannel this_ptr_conv;
21225         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21226         this_ptr_conv.is_owned = false;
21227         OpenChannel_set_channel_flags(&this_ptr_conv, val);
21228 }
21229
21230 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21231         LDKOpenChannel orig_conv;
21232         orig_conv.inner = (void*)(orig & (~1));
21233         orig_conv.is_owned = false;
21234         LDKOpenChannel ret_var = OpenChannel_clone(&orig_conv);
21235         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21236         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21237         uint64_t ret_ref = (uint64_t)ret_var.inner;
21238         if (ret_var.is_owned) {
21239                 ret_ref |= 1;
21240         }
21241         return ret_ref;
21242 }
21243
21244 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
21245         LDKAcceptChannel this_obj_conv;
21246         this_obj_conv.inner = (void*)(this_obj & (~1));
21247         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21248         AcceptChannel_free(this_obj_conv);
21249 }
21250
21251 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
21252         LDKAcceptChannel this_ptr_conv;
21253         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21254         this_ptr_conv.is_owned = false;
21255         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
21256         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *AcceptChannel_get_temporary_channel_id(&this_ptr_conv));
21257         return ret_arr;
21258 }
21259
21260 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21261         LDKAcceptChannel this_ptr_conv;
21262         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21263         this_ptr_conv.is_owned = false;
21264         LDKThirtyTwoBytes val_ref;
21265         CHECK((*env)->GetArrayLength(env, val) == 32);
21266         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
21267         AcceptChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
21268 }
21269
21270 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
21271         LDKAcceptChannel this_ptr_conv;
21272         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21273         this_ptr_conv.is_owned = false;
21274         int64_t ret_val = AcceptChannel_get_dust_limit_satoshis(&this_ptr_conv);
21275         return ret_val;
21276 }
21277
21278 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
21279         LDKAcceptChannel this_ptr_conv;
21280         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21281         this_ptr_conv.is_owned = false;
21282         AcceptChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
21283 }
21284
21285 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) {
21286         LDKAcceptChannel this_ptr_conv;
21287         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21288         this_ptr_conv.is_owned = false;
21289         int64_t ret_val = AcceptChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
21290         return ret_val;
21291 }
21292
21293 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) {
21294         LDKAcceptChannel this_ptr_conv;
21295         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21296         this_ptr_conv.is_owned = false;
21297         AcceptChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
21298 }
21299
21300 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
21301         LDKAcceptChannel this_ptr_conv;
21302         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21303         this_ptr_conv.is_owned = false;
21304         int64_t ret_val = AcceptChannel_get_channel_reserve_satoshis(&this_ptr_conv);
21305         return ret_val;
21306 }
21307
21308 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
21309         LDKAcceptChannel this_ptr_conv;
21310         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21311         this_ptr_conv.is_owned = false;
21312         AcceptChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
21313 }
21314
21315 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
21316         LDKAcceptChannel this_ptr_conv;
21317         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21318         this_ptr_conv.is_owned = false;
21319         int64_t ret_val = AcceptChannel_get_htlc_minimum_msat(&this_ptr_conv);
21320         return ret_val;
21321 }
21322
21323 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
21324         LDKAcceptChannel this_ptr_conv;
21325         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21326         this_ptr_conv.is_owned = false;
21327         AcceptChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
21328 }
21329
21330 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
21331         LDKAcceptChannel this_ptr_conv;
21332         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21333         this_ptr_conv.is_owned = false;
21334         int32_t ret_val = AcceptChannel_get_minimum_depth(&this_ptr_conv);
21335         return ret_val;
21336 }
21337
21338 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
21339         LDKAcceptChannel this_ptr_conv;
21340         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21341         this_ptr_conv.is_owned = false;
21342         AcceptChannel_set_minimum_depth(&this_ptr_conv, val);
21343 }
21344
21345 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
21346         LDKAcceptChannel this_ptr_conv;
21347         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21348         this_ptr_conv.is_owned = false;
21349         int16_t ret_val = AcceptChannel_get_to_self_delay(&this_ptr_conv);
21350         return ret_val;
21351 }
21352
21353 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
21354         LDKAcceptChannel this_ptr_conv;
21355         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21356         this_ptr_conv.is_owned = false;
21357         AcceptChannel_set_to_self_delay(&this_ptr_conv, val);
21358 }
21359
21360 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
21361         LDKAcceptChannel this_ptr_conv;
21362         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21363         this_ptr_conv.is_owned = false;
21364         int16_t ret_val = AcceptChannel_get_max_accepted_htlcs(&this_ptr_conv);
21365         return ret_val;
21366 }
21367
21368 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
21369         LDKAcceptChannel this_ptr_conv;
21370         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21371         this_ptr_conv.is_owned = false;
21372         AcceptChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
21373 }
21374
21375 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
21376         LDKAcceptChannel this_ptr_conv;
21377         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21378         this_ptr_conv.is_owned = false;
21379         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
21380         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_funding_pubkey(&this_ptr_conv).compressed_form);
21381         return ret_arr;
21382 }
21383
21384 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21385         LDKAcceptChannel this_ptr_conv;
21386         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21387         this_ptr_conv.is_owned = false;
21388         LDKPublicKey val_ref;
21389         CHECK((*env)->GetArrayLength(env, val) == 33);
21390         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
21391         AcceptChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
21392 }
21393
21394 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
21395         LDKAcceptChannel this_ptr_conv;
21396         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21397         this_ptr_conv.is_owned = false;
21398         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
21399         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form);
21400         return ret_arr;
21401 }
21402
21403 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21404         LDKAcceptChannel this_ptr_conv;
21405         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21406         this_ptr_conv.is_owned = false;
21407         LDKPublicKey val_ref;
21408         CHECK((*env)->GetArrayLength(env, val) == 33);
21409         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
21410         AcceptChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
21411 }
21412
21413 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
21414         LDKAcceptChannel this_ptr_conv;
21415         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21416         this_ptr_conv.is_owned = false;
21417         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
21418         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_payment_point(&this_ptr_conv).compressed_form);
21419         return ret_arr;
21420 }
21421
21422 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21423         LDKAcceptChannel this_ptr_conv;
21424         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21425         this_ptr_conv.is_owned = false;
21426         LDKPublicKey val_ref;
21427         CHECK((*env)->GetArrayLength(env, val) == 33);
21428         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
21429         AcceptChannel_set_payment_point(&this_ptr_conv, val_ref);
21430 }
21431
21432 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
21433         LDKAcceptChannel this_ptr_conv;
21434         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21435         this_ptr_conv.is_owned = false;
21436         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
21437         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
21438         return ret_arr;
21439 }
21440
21441 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21442         LDKAcceptChannel this_ptr_conv;
21443         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21444         this_ptr_conv.is_owned = false;
21445         LDKPublicKey val_ref;
21446         CHECK((*env)->GetArrayLength(env, val) == 33);
21447         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
21448         AcceptChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
21449 }
21450
21451 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
21452         LDKAcceptChannel this_ptr_conv;
21453         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21454         this_ptr_conv.is_owned = false;
21455         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
21456         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form);
21457         return ret_arr;
21458 }
21459
21460 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21461         LDKAcceptChannel this_ptr_conv;
21462         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21463         this_ptr_conv.is_owned = false;
21464         LDKPublicKey val_ref;
21465         CHECK((*env)->GetArrayLength(env, val) == 33);
21466         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
21467         AcceptChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
21468 }
21469
21470 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1first_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
21471         LDKAcceptChannel this_ptr_conv;
21472         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21473         this_ptr_conv.is_owned = false;
21474         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
21475         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form);
21476         return ret_arr;
21477 }
21478
21479 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) {
21480         LDKAcceptChannel this_ptr_conv;
21481         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21482         this_ptr_conv.is_owned = false;
21483         LDKPublicKey val_ref;
21484         CHECK((*env)->GetArrayLength(env, val) == 33);
21485         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
21486         AcceptChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
21487 }
21488
21489 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21490         LDKAcceptChannel orig_conv;
21491         orig_conv.inner = (void*)(orig & (~1));
21492         orig_conv.is_owned = false;
21493         LDKAcceptChannel ret_var = AcceptChannel_clone(&orig_conv);
21494         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21495         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21496         uint64_t ret_ref = (uint64_t)ret_var.inner;
21497         if (ret_var.is_owned) {
21498                 ret_ref |= 1;
21499         }
21500         return ret_ref;
21501 }
21502
21503 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
21504         LDKFundingCreated this_obj_conv;
21505         this_obj_conv.inner = (void*)(this_obj & (~1));
21506         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21507         FundingCreated_free(this_obj_conv);
21508 }
21509
21510 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
21511         LDKFundingCreated this_ptr_conv;
21512         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21513         this_ptr_conv.is_owned = false;
21514         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
21515         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingCreated_get_temporary_channel_id(&this_ptr_conv));
21516         return ret_arr;
21517 }
21518
21519 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21520         LDKFundingCreated this_ptr_conv;
21521         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21522         this_ptr_conv.is_owned = false;
21523         LDKThirtyTwoBytes val_ref;
21524         CHECK((*env)->GetArrayLength(env, val) == 32);
21525         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
21526         FundingCreated_set_temporary_channel_id(&this_ptr_conv, val_ref);
21527 }
21528
21529 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1funding_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
21530         LDKFundingCreated this_ptr_conv;
21531         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21532         this_ptr_conv.is_owned = false;
21533         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
21534         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingCreated_get_funding_txid(&this_ptr_conv));
21535         return ret_arr;
21536 }
21537
21538 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1funding_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21539         LDKFundingCreated this_ptr_conv;
21540         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21541         this_ptr_conv.is_owned = false;
21542         LDKThirtyTwoBytes val_ref;
21543         CHECK((*env)->GetArrayLength(env, val) == 32);
21544         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
21545         FundingCreated_set_funding_txid(&this_ptr_conv, val_ref);
21546 }
21547
21548 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1funding_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
21549         LDKFundingCreated this_ptr_conv;
21550         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21551         this_ptr_conv.is_owned = false;
21552         int16_t ret_val = FundingCreated_get_funding_output_index(&this_ptr_conv);
21553         return ret_val;
21554 }
21555
21556 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1funding_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
21557         LDKFundingCreated this_ptr_conv;
21558         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21559         this_ptr_conv.is_owned = false;
21560         FundingCreated_set_funding_output_index(&this_ptr_conv, val);
21561 }
21562
21563 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
21564         LDKFundingCreated this_ptr_conv;
21565         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21566         this_ptr_conv.is_owned = false;
21567         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
21568         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, FundingCreated_get_signature(&this_ptr_conv).compact_form);
21569         return ret_arr;
21570 }
21571
21572 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21573         LDKFundingCreated this_ptr_conv;
21574         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21575         this_ptr_conv.is_owned = false;
21576         LDKSignature val_ref;
21577         CHECK((*env)->GetArrayLength(env, val) == 64);
21578         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
21579         FundingCreated_set_signature(&this_ptr_conv, val_ref);
21580 }
21581
21582 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) {
21583         LDKThirtyTwoBytes temporary_channel_id_arg_ref;
21584         CHECK((*env)->GetArrayLength(env, temporary_channel_id_arg) == 32);
21585         (*env)->GetByteArrayRegion(env, temporary_channel_id_arg, 0, 32, temporary_channel_id_arg_ref.data);
21586         LDKThirtyTwoBytes funding_txid_arg_ref;
21587         CHECK((*env)->GetArrayLength(env, funding_txid_arg) == 32);
21588         (*env)->GetByteArrayRegion(env, funding_txid_arg, 0, 32, funding_txid_arg_ref.data);
21589         LDKSignature signature_arg_ref;
21590         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
21591         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
21592         LDKFundingCreated ret_var = FundingCreated_new(temporary_channel_id_arg_ref, funding_txid_arg_ref, funding_output_index_arg, signature_arg_ref);
21593         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21594         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21595         uint64_t ret_ref = (uint64_t)ret_var.inner;
21596         if (ret_var.is_owned) {
21597                 ret_ref |= 1;
21598         }
21599         return ret_ref;
21600 }
21601
21602 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21603         LDKFundingCreated orig_conv;
21604         orig_conv.inner = (void*)(orig & (~1));
21605         orig_conv.is_owned = false;
21606         LDKFundingCreated ret_var = FundingCreated_clone(&orig_conv);
21607         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21608         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21609         uint64_t ret_ref = (uint64_t)ret_var.inner;
21610         if (ret_var.is_owned) {
21611                 ret_ref |= 1;
21612         }
21613         return ret_ref;
21614 }
21615
21616 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
21617         LDKFundingSigned this_obj_conv;
21618         this_obj_conv.inner = (void*)(this_obj & (~1));
21619         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21620         FundingSigned_free(this_obj_conv);
21621 }
21622
21623 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
21624         LDKFundingSigned this_ptr_conv;
21625         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21626         this_ptr_conv.is_owned = false;
21627         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
21628         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingSigned_get_channel_id(&this_ptr_conv));
21629         return ret_arr;
21630 }
21631
21632 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21633         LDKFundingSigned this_ptr_conv;
21634         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21635         this_ptr_conv.is_owned = false;
21636         LDKThirtyTwoBytes val_ref;
21637         CHECK((*env)->GetArrayLength(env, val) == 32);
21638         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
21639         FundingSigned_set_channel_id(&this_ptr_conv, val_ref);
21640 }
21641
21642 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
21643         LDKFundingSigned this_ptr_conv;
21644         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21645         this_ptr_conv.is_owned = false;
21646         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
21647         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, FundingSigned_get_signature(&this_ptr_conv).compact_form);
21648         return ret_arr;
21649 }
21650
21651 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21652         LDKFundingSigned this_ptr_conv;
21653         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21654         this_ptr_conv.is_owned = false;
21655         LDKSignature val_ref;
21656         CHECK((*env)->GetArrayLength(env, val) == 64);
21657         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
21658         FundingSigned_set_signature(&this_ptr_conv, val_ref);
21659 }
21660
21661 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray signature_arg) {
21662         LDKThirtyTwoBytes channel_id_arg_ref;
21663         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
21664         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
21665         LDKSignature signature_arg_ref;
21666         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
21667         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
21668         LDKFundingSigned ret_var = FundingSigned_new(channel_id_arg_ref, signature_arg_ref);
21669         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21670         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21671         uint64_t ret_ref = (uint64_t)ret_var.inner;
21672         if (ret_var.is_owned) {
21673                 ret_ref |= 1;
21674         }
21675         return ret_ref;
21676 }
21677
21678 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21679         LDKFundingSigned orig_conv;
21680         orig_conv.inner = (void*)(orig & (~1));
21681         orig_conv.is_owned = false;
21682         LDKFundingSigned ret_var = FundingSigned_clone(&orig_conv);
21683         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21684         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21685         uint64_t ret_ref = (uint64_t)ret_var.inner;
21686         if (ret_var.is_owned) {
21687                 ret_ref |= 1;
21688         }
21689         return ret_ref;
21690 }
21691
21692 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingLocked_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
21693         LDKFundingLocked this_obj_conv;
21694         this_obj_conv.inner = (void*)(this_obj & (~1));
21695         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21696         FundingLocked_free(this_obj_conv);
21697 }
21698
21699 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingLocked_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
21700         LDKFundingLocked this_ptr_conv;
21701         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21702         this_ptr_conv.is_owned = false;
21703         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
21704         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingLocked_get_channel_id(&this_ptr_conv));
21705         return ret_arr;
21706 }
21707
21708 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingLocked_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21709         LDKFundingLocked this_ptr_conv;
21710         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21711         this_ptr_conv.is_owned = false;
21712         LDKThirtyTwoBytes val_ref;
21713         CHECK((*env)->GetArrayLength(env, val) == 32);
21714         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
21715         FundingLocked_set_channel_id(&this_ptr_conv, val_ref);
21716 }
21717
21718 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingLocked_1get_1next_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
21719         LDKFundingLocked this_ptr_conv;
21720         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21721         this_ptr_conv.is_owned = false;
21722         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
21723         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, FundingLocked_get_next_per_commitment_point(&this_ptr_conv).compressed_form);
21724         return ret_arr;
21725 }
21726
21727 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) {
21728         LDKFundingLocked this_ptr_conv;
21729         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21730         this_ptr_conv.is_owned = false;
21731         LDKPublicKey val_ref;
21732         CHECK((*env)->GetArrayLength(env, val) == 33);
21733         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
21734         FundingLocked_set_next_per_commitment_point(&this_ptr_conv, val_ref);
21735 }
21736
21737 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) {
21738         LDKThirtyTwoBytes channel_id_arg_ref;
21739         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
21740         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
21741         LDKPublicKey next_per_commitment_point_arg_ref;
21742         CHECK((*env)->GetArrayLength(env, next_per_commitment_point_arg) == 33);
21743         (*env)->GetByteArrayRegion(env, next_per_commitment_point_arg, 0, 33, next_per_commitment_point_arg_ref.compressed_form);
21744         LDKFundingLocked ret_var = FundingLocked_new(channel_id_arg_ref, next_per_commitment_point_arg_ref);
21745         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21746         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21747         uint64_t ret_ref = (uint64_t)ret_var.inner;
21748         if (ret_var.is_owned) {
21749                 ret_ref |= 1;
21750         }
21751         return ret_ref;
21752 }
21753
21754 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingLocked_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21755         LDKFundingLocked orig_conv;
21756         orig_conv.inner = (void*)(orig & (~1));
21757         orig_conv.is_owned = false;
21758         LDKFundingLocked ret_var = FundingLocked_clone(&orig_conv);
21759         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21760         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21761         uint64_t ret_ref = (uint64_t)ret_var.inner;
21762         if (ret_var.is_owned) {
21763                 ret_ref |= 1;
21764         }
21765         return ret_ref;
21766 }
21767
21768 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
21769         LDKShutdown this_obj_conv;
21770         this_obj_conv.inner = (void*)(this_obj & (~1));
21771         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21772         Shutdown_free(this_obj_conv);
21773 }
21774
21775 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
21776         LDKShutdown this_ptr_conv;
21777         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21778         this_ptr_conv.is_owned = false;
21779         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
21780         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *Shutdown_get_channel_id(&this_ptr_conv));
21781         return ret_arr;
21782 }
21783
21784 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21785         LDKShutdown this_ptr_conv;
21786         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21787         this_ptr_conv.is_owned = false;
21788         LDKThirtyTwoBytes val_ref;
21789         CHECK((*env)->GetArrayLength(env, val) == 32);
21790         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
21791         Shutdown_set_channel_id(&this_ptr_conv, val_ref);
21792 }
21793
21794 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1get_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
21795         LDKShutdown this_ptr_conv;
21796         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21797         this_ptr_conv.is_owned = false;
21798         LDKu8slice ret_var = Shutdown_get_scriptpubkey(&this_ptr_conv);
21799         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21800         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21801         return ret_arr;
21802 }
21803
21804 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1set_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21805         LDKShutdown this_ptr_conv;
21806         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21807         this_ptr_conv.is_owned = false;
21808         LDKCVec_u8Z val_ref;
21809         val_ref.datalen = (*env)->GetArrayLength(env, val);
21810         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
21811         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
21812         Shutdown_set_scriptpubkey(&this_ptr_conv, val_ref);
21813 }
21814
21815 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray scriptpubkey_arg) {
21816         LDKThirtyTwoBytes channel_id_arg_ref;
21817         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
21818         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
21819         LDKCVec_u8Z scriptpubkey_arg_ref;
21820         scriptpubkey_arg_ref.datalen = (*env)->GetArrayLength(env, scriptpubkey_arg);
21821         scriptpubkey_arg_ref.data = MALLOC(scriptpubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
21822         (*env)->GetByteArrayRegion(env, scriptpubkey_arg, 0, scriptpubkey_arg_ref.datalen, scriptpubkey_arg_ref.data);
21823         LDKShutdown ret_var = Shutdown_new(channel_id_arg_ref, scriptpubkey_arg_ref);
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 int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21834         LDKShutdown orig_conv;
21835         orig_conv.inner = (void*)(orig & (~1));
21836         orig_conv.is_owned = false;
21837         LDKShutdown ret_var = Shutdown_clone(&orig_conv);
21838         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21839         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21840         uint64_t ret_ref = (uint64_t)ret_var.inner;
21841         if (ret_var.is_owned) {
21842                 ret_ref |= 1;
21843         }
21844         return ret_ref;
21845 }
21846
21847 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
21848         LDKClosingSignedFeeRange this_obj_conv;
21849         this_obj_conv.inner = (void*)(this_obj & (~1));
21850         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21851         ClosingSignedFeeRange_free(this_obj_conv);
21852 }
21853
21854 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1get_1min_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
21855         LDKClosingSignedFeeRange this_ptr_conv;
21856         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21857         this_ptr_conv.is_owned = false;
21858         int64_t ret_val = ClosingSignedFeeRange_get_min_fee_satoshis(&this_ptr_conv);
21859         return ret_val;
21860 }
21861
21862 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1set_1min_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
21863         LDKClosingSignedFeeRange this_ptr_conv;
21864         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21865         this_ptr_conv.is_owned = false;
21866         ClosingSignedFeeRange_set_min_fee_satoshis(&this_ptr_conv, val);
21867 }
21868
21869 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1get_1max_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
21870         LDKClosingSignedFeeRange this_ptr_conv;
21871         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21872         this_ptr_conv.is_owned = false;
21873         int64_t ret_val = ClosingSignedFeeRange_get_max_fee_satoshis(&this_ptr_conv);
21874         return ret_val;
21875 }
21876
21877 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1set_1max_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
21878         LDKClosingSignedFeeRange this_ptr_conv;
21879         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21880         this_ptr_conv.is_owned = false;
21881         ClosingSignedFeeRange_set_max_fee_satoshis(&this_ptr_conv, val);
21882 }
21883
21884 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) {
21885         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_new(min_fee_satoshis_arg, max_fee_satoshis_arg);
21886         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21887         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21888         uint64_t ret_ref = (uint64_t)ret_var.inner;
21889         if (ret_var.is_owned) {
21890                 ret_ref |= 1;
21891         }
21892         return ret_ref;
21893 }
21894
21895 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21896         LDKClosingSignedFeeRange orig_conv;
21897         orig_conv.inner = (void*)(orig & (~1));
21898         orig_conv.is_owned = false;
21899         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_clone(&orig_conv);
21900         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21901         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21902         uint64_t ret_ref = (uint64_t)ret_var.inner;
21903         if (ret_var.is_owned) {
21904                 ret_ref |= 1;
21905         }
21906         return ret_ref;
21907 }
21908
21909 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
21910         LDKClosingSigned this_obj_conv;
21911         this_obj_conv.inner = (void*)(this_obj & (~1));
21912         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21913         ClosingSigned_free(this_obj_conv);
21914 }
21915
21916 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
21917         LDKClosingSigned this_ptr_conv;
21918         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21919         this_ptr_conv.is_owned = false;
21920         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
21921         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ClosingSigned_get_channel_id(&this_ptr_conv));
21922         return ret_arr;
21923 }
21924
21925 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21926         LDKClosingSigned this_ptr_conv;
21927         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21928         this_ptr_conv.is_owned = false;
21929         LDKThirtyTwoBytes val_ref;
21930         CHECK((*env)->GetArrayLength(env, val) == 32);
21931         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
21932         ClosingSigned_set_channel_id(&this_ptr_conv, val_ref);
21933 }
21934
21935 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
21936         LDKClosingSigned this_ptr_conv;
21937         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21938         this_ptr_conv.is_owned = false;
21939         int64_t ret_val = ClosingSigned_get_fee_satoshis(&this_ptr_conv);
21940         return ret_val;
21941 }
21942
21943 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
21944         LDKClosingSigned this_ptr_conv;
21945         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21946         this_ptr_conv.is_owned = false;
21947         ClosingSigned_set_fee_satoshis(&this_ptr_conv, val);
21948 }
21949
21950 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
21951         LDKClosingSigned this_ptr_conv;
21952         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21953         this_ptr_conv.is_owned = false;
21954         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
21955         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ClosingSigned_get_signature(&this_ptr_conv).compact_form);
21956         return ret_arr;
21957 }
21958
21959 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21960         LDKClosingSigned this_ptr_conv;
21961         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21962         this_ptr_conv.is_owned = false;
21963         LDKSignature val_ref;
21964         CHECK((*env)->GetArrayLength(env, val) == 64);
21965         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
21966         ClosingSigned_set_signature(&this_ptr_conv, val_ref);
21967 }
21968
21969 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1fee_1range(JNIEnv *env, jclass clz, int64_t this_ptr) {
21970         LDKClosingSigned this_ptr_conv;
21971         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21972         this_ptr_conv.is_owned = false;
21973         LDKClosingSignedFeeRange ret_var = ClosingSigned_get_fee_range(&this_ptr_conv);
21974         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21975         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21976         uint64_t ret_ref = (uint64_t)ret_var.inner;
21977         if (ret_var.is_owned) {
21978                 ret_ref |= 1;
21979         }
21980         return ret_ref;
21981 }
21982
21983 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1fee_1range(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
21984         LDKClosingSigned this_ptr_conv;
21985         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21986         this_ptr_conv.is_owned = false;
21987         LDKClosingSignedFeeRange val_conv;
21988         val_conv.inner = (void*)(val & (~1));
21989         val_conv.is_owned = (val & 1) || (val == 0);
21990         val_conv = ClosingSignedFeeRange_clone(&val_conv);
21991         ClosingSigned_set_fee_range(&this_ptr_conv, val_conv);
21992 }
21993
21994 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) {
21995         LDKThirtyTwoBytes channel_id_arg_ref;
21996         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
21997         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
21998         LDKSignature signature_arg_ref;
21999         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
22000         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
22001         LDKClosingSignedFeeRange fee_range_arg_conv;
22002         fee_range_arg_conv.inner = (void*)(fee_range_arg & (~1));
22003         fee_range_arg_conv.is_owned = (fee_range_arg & 1) || (fee_range_arg == 0);
22004         fee_range_arg_conv = ClosingSignedFeeRange_clone(&fee_range_arg_conv);
22005         LDKClosingSigned ret_var = ClosingSigned_new(channel_id_arg_ref, fee_satoshis_arg, signature_arg_ref, fee_range_arg_conv);
22006         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22007         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22008         uint64_t ret_ref = (uint64_t)ret_var.inner;
22009         if (ret_var.is_owned) {
22010                 ret_ref |= 1;
22011         }
22012         return ret_ref;
22013 }
22014
22015 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22016         LDKClosingSigned orig_conv;
22017         orig_conv.inner = (void*)(orig & (~1));
22018         orig_conv.is_owned = false;
22019         LDKClosingSigned ret_var = ClosingSigned_clone(&orig_conv);
22020         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22021         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22022         uint64_t ret_ref = (uint64_t)ret_var.inner;
22023         if (ret_var.is_owned) {
22024                 ret_ref |= 1;
22025         }
22026         return ret_ref;
22027 }
22028
22029 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22030         LDKUpdateAddHTLC this_obj_conv;
22031         this_obj_conv.inner = (void*)(this_obj & (~1));
22032         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22033         UpdateAddHTLC_free(this_obj_conv);
22034 }
22035
22036 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
22037         LDKUpdateAddHTLC this_ptr_conv;
22038         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22039         this_ptr_conv.is_owned = false;
22040         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
22041         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateAddHTLC_get_channel_id(&this_ptr_conv));
22042         return ret_arr;
22043 }
22044
22045 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22046         LDKUpdateAddHTLC this_ptr_conv;
22047         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22048         this_ptr_conv.is_owned = false;
22049         LDKThirtyTwoBytes val_ref;
22050         CHECK((*env)->GetArrayLength(env, val) == 32);
22051         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
22052         UpdateAddHTLC_set_channel_id(&this_ptr_conv, val_ref);
22053 }
22054
22055 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
22056         LDKUpdateAddHTLC this_ptr_conv;
22057         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22058         this_ptr_conv.is_owned = false;
22059         int64_t ret_val = UpdateAddHTLC_get_htlc_id(&this_ptr_conv);
22060         return ret_val;
22061 }
22062
22063 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
22064         LDKUpdateAddHTLC this_ptr_conv;
22065         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22066         this_ptr_conv.is_owned = false;
22067         UpdateAddHTLC_set_htlc_id(&this_ptr_conv, val);
22068 }
22069
22070 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
22071         LDKUpdateAddHTLC this_ptr_conv;
22072         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22073         this_ptr_conv.is_owned = false;
22074         int64_t ret_val = UpdateAddHTLC_get_amount_msat(&this_ptr_conv);
22075         return ret_val;
22076 }
22077
22078 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
22079         LDKUpdateAddHTLC this_ptr_conv;
22080         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22081         this_ptr_conv.is_owned = false;
22082         UpdateAddHTLC_set_amount_msat(&this_ptr_conv, val);
22083 }
22084
22085 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
22086         LDKUpdateAddHTLC this_ptr_conv;
22087         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22088         this_ptr_conv.is_owned = false;
22089         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
22090         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateAddHTLC_get_payment_hash(&this_ptr_conv));
22091         return ret_arr;
22092 }
22093
22094 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22095         LDKUpdateAddHTLC this_ptr_conv;
22096         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22097         this_ptr_conv.is_owned = false;
22098         LDKThirtyTwoBytes val_ref;
22099         CHECK((*env)->GetArrayLength(env, val) == 32);
22100         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
22101         UpdateAddHTLC_set_payment_hash(&this_ptr_conv, val_ref);
22102 }
22103
22104 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr) {
22105         LDKUpdateAddHTLC this_ptr_conv;
22106         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22107         this_ptr_conv.is_owned = false;
22108         int32_t ret_val = UpdateAddHTLC_get_cltv_expiry(&this_ptr_conv);
22109         return ret_val;
22110 }
22111
22112 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
22113         LDKUpdateAddHTLC this_ptr_conv;
22114         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22115         this_ptr_conv.is_owned = false;
22116         UpdateAddHTLC_set_cltv_expiry(&this_ptr_conv, val);
22117 }
22118
22119 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22120         LDKUpdateAddHTLC orig_conv;
22121         orig_conv.inner = (void*)(orig & (~1));
22122         orig_conv.is_owned = false;
22123         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(&orig_conv);
22124         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22125         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22126         uint64_t ret_ref = (uint64_t)ret_var.inner;
22127         if (ret_var.is_owned) {
22128                 ret_ref |= 1;
22129         }
22130         return ret_ref;
22131 }
22132
22133 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22134         LDKUpdateFulfillHTLC this_obj_conv;
22135         this_obj_conv.inner = (void*)(this_obj & (~1));
22136         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22137         UpdateFulfillHTLC_free(this_obj_conv);
22138 }
22139
22140 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
22141         LDKUpdateFulfillHTLC this_ptr_conv;
22142         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22143         this_ptr_conv.is_owned = false;
22144         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
22145         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFulfillHTLC_get_channel_id(&this_ptr_conv));
22146         return ret_arr;
22147 }
22148
22149 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22150         LDKUpdateFulfillHTLC this_ptr_conv;
22151         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22152         this_ptr_conv.is_owned = false;
22153         LDKThirtyTwoBytes val_ref;
22154         CHECK((*env)->GetArrayLength(env, val) == 32);
22155         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
22156         UpdateFulfillHTLC_set_channel_id(&this_ptr_conv, val_ref);
22157 }
22158
22159 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
22160         LDKUpdateFulfillHTLC this_ptr_conv;
22161         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22162         this_ptr_conv.is_owned = false;
22163         int64_t ret_val = UpdateFulfillHTLC_get_htlc_id(&this_ptr_conv);
22164         return ret_val;
22165 }
22166
22167 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
22168         LDKUpdateFulfillHTLC this_ptr_conv;
22169         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22170         this_ptr_conv.is_owned = false;
22171         UpdateFulfillHTLC_set_htlc_id(&this_ptr_conv, val);
22172 }
22173
22174 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1payment_1preimage(JNIEnv *env, jclass clz, int64_t this_ptr) {
22175         LDKUpdateFulfillHTLC this_ptr_conv;
22176         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22177         this_ptr_conv.is_owned = false;
22178         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
22179         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFulfillHTLC_get_payment_preimage(&this_ptr_conv));
22180         return ret_arr;
22181 }
22182
22183 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1payment_1preimage(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22184         LDKUpdateFulfillHTLC this_ptr_conv;
22185         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22186         this_ptr_conv.is_owned = false;
22187         LDKThirtyTwoBytes val_ref;
22188         CHECK((*env)->GetArrayLength(env, val) == 32);
22189         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
22190         UpdateFulfillHTLC_set_payment_preimage(&this_ptr_conv, val_ref);
22191 }
22192
22193 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) {
22194         LDKThirtyTwoBytes channel_id_arg_ref;
22195         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
22196         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
22197         LDKThirtyTwoBytes payment_preimage_arg_ref;
22198         CHECK((*env)->GetArrayLength(env, payment_preimage_arg) == 32);
22199         (*env)->GetByteArrayRegion(env, payment_preimage_arg, 0, 32, payment_preimage_arg_ref.data);
22200         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_new(channel_id_arg_ref, htlc_id_arg, payment_preimage_arg_ref);
22201         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22202         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22203         uint64_t ret_ref = (uint64_t)ret_var.inner;
22204         if (ret_var.is_owned) {
22205                 ret_ref |= 1;
22206         }
22207         return ret_ref;
22208 }
22209
22210 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22211         LDKUpdateFulfillHTLC orig_conv;
22212         orig_conv.inner = (void*)(orig & (~1));
22213         orig_conv.is_owned = false;
22214         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(&orig_conv);
22215         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22216         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22217         uint64_t ret_ref = (uint64_t)ret_var.inner;
22218         if (ret_var.is_owned) {
22219                 ret_ref |= 1;
22220         }
22221         return ret_ref;
22222 }
22223
22224 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22225         LDKUpdateFailHTLC this_obj_conv;
22226         this_obj_conv.inner = (void*)(this_obj & (~1));
22227         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22228         UpdateFailHTLC_free(this_obj_conv);
22229 }
22230
22231 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
22232         LDKUpdateFailHTLC this_ptr_conv;
22233         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22234         this_ptr_conv.is_owned = false;
22235         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
22236         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFailHTLC_get_channel_id(&this_ptr_conv));
22237         return ret_arr;
22238 }
22239
22240 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22241         LDKUpdateFailHTLC this_ptr_conv;
22242         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22243         this_ptr_conv.is_owned = false;
22244         LDKThirtyTwoBytes val_ref;
22245         CHECK((*env)->GetArrayLength(env, val) == 32);
22246         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
22247         UpdateFailHTLC_set_channel_id(&this_ptr_conv, val_ref);
22248 }
22249
22250 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
22251         LDKUpdateFailHTLC this_ptr_conv;
22252         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22253         this_ptr_conv.is_owned = false;
22254         int64_t ret_val = UpdateFailHTLC_get_htlc_id(&this_ptr_conv);
22255         return ret_val;
22256 }
22257
22258 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
22259         LDKUpdateFailHTLC this_ptr_conv;
22260         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22261         this_ptr_conv.is_owned = false;
22262         UpdateFailHTLC_set_htlc_id(&this_ptr_conv, val);
22263 }
22264
22265 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22266         LDKUpdateFailHTLC orig_conv;
22267         orig_conv.inner = (void*)(orig & (~1));
22268         orig_conv.is_owned = false;
22269         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(&orig_conv);
22270         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22271         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22272         uint64_t ret_ref = (uint64_t)ret_var.inner;
22273         if (ret_var.is_owned) {
22274                 ret_ref |= 1;
22275         }
22276         return ret_ref;
22277 }
22278
22279 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22280         LDKUpdateFailMalformedHTLC this_obj_conv;
22281         this_obj_conv.inner = (void*)(this_obj & (~1));
22282         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22283         UpdateFailMalformedHTLC_free(this_obj_conv);
22284 }
22285
22286 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
22287         LDKUpdateFailMalformedHTLC this_ptr_conv;
22288         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22289         this_ptr_conv.is_owned = false;
22290         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
22291         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFailMalformedHTLC_get_channel_id(&this_ptr_conv));
22292         return ret_arr;
22293 }
22294
22295 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22296         LDKUpdateFailMalformedHTLC this_ptr_conv;
22297         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22298         this_ptr_conv.is_owned = false;
22299         LDKThirtyTwoBytes val_ref;
22300         CHECK((*env)->GetArrayLength(env, val) == 32);
22301         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
22302         UpdateFailMalformedHTLC_set_channel_id(&this_ptr_conv, val_ref);
22303 }
22304
22305 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
22306         LDKUpdateFailMalformedHTLC this_ptr_conv;
22307         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22308         this_ptr_conv.is_owned = false;
22309         int64_t ret_val = UpdateFailMalformedHTLC_get_htlc_id(&this_ptr_conv);
22310         return ret_val;
22311 }
22312
22313 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
22314         LDKUpdateFailMalformedHTLC this_ptr_conv;
22315         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22316         this_ptr_conv.is_owned = false;
22317         UpdateFailMalformedHTLC_set_htlc_id(&this_ptr_conv, val);
22318 }
22319
22320 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1failure_1code(JNIEnv *env, jclass clz, int64_t this_ptr) {
22321         LDKUpdateFailMalformedHTLC this_ptr_conv;
22322         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22323         this_ptr_conv.is_owned = false;
22324         int16_t ret_val = UpdateFailMalformedHTLC_get_failure_code(&this_ptr_conv);
22325         return ret_val;
22326 }
22327
22328 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1failure_1code(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
22329         LDKUpdateFailMalformedHTLC this_ptr_conv;
22330         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22331         this_ptr_conv.is_owned = false;
22332         UpdateFailMalformedHTLC_set_failure_code(&this_ptr_conv, val);
22333 }
22334
22335 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22336         LDKUpdateFailMalformedHTLC orig_conv;
22337         orig_conv.inner = (void*)(orig & (~1));
22338         orig_conv.is_owned = false;
22339         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(&orig_conv);
22340         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22341         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22342         uint64_t ret_ref = (uint64_t)ret_var.inner;
22343         if (ret_var.is_owned) {
22344                 ret_ref |= 1;
22345         }
22346         return ret_ref;
22347 }
22348
22349 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22350         LDKCommitmentSigned this_obj_conv;
22351         this_obj_conv.inner = (void*)(this_obj & (~1));
22352         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22353         CommitmentSigned_free(this_obj_conv);
22354 }
22355
22356 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
22357         LDKCommitmentSigned this_ptr_conv;
22358         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22359         this_ptr_conv.is_owned = false;
22360         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
22361         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *CommitmentSigned_get_channel_id(&this_ptr_conv));
22362         return ret_arr;
22363 }
22364
22365 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22366         LDKCommitmentSigned this_ptr_conv;
22367         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22368         this_ptr_conv.is_owned = false;
22369         LDKThirtyTwoBytes val_ref;
22370         CHECK((*env)->GetArrayLength(env, val) == 32);
22371         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
22372         CommitmentSigned_set_channel_id(&this_ptr_conv, val_ref);
22373 }
22374
22375 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
22376         LDKCommitmentSigned this_ptr_conv;
22377         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22378         this_ptr_conv.is_owned = false;
22379         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
22380         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, CommitmentSigned_get_signature(&this_ptr_conv).compact_form);
22381         return ret_arr;
22382 }
22383
22384 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22385         LDKCommitmentSigned this_ptr_conv;
22386         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22387         this_ptr_conv.is_owned = false;
22388         LDKSignature val_ref;
22389         CHECK((*env)->GetArrayLength(env, val) == 64);
22390         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
22391         CommitmentSigned_set_signature(&this_ptr_conv, val_ref);
22392 }
22393
22394 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1htlc_1signatures(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
22395         LDKCommitmentSigned this_ptr_conv;
22396         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22397         this_ptr_conv.is_owned = false;
22398         LDKCVec_SignatureZ val_constr;
22399         val_constr.datalen = (*env)->GetArrayLength(env, val);
22400         if (val_constr.datalen > 0)
22401                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
22402         else
22403                 val_constr.data = NULL;
22404         for (size_t i = 0; i < val_constr.datalen; i++) {
22405                 int8_tArray val_conv_8 = (*env)->GetObjectArrayElement(env, val, i);
22406                 LDKSignature val_conv_8_ref;
22407                 CHECK((*env)->GetArrayLength(env, val_conv_8) == 64);
22408                 (*env)->GetByteArrayRegion(env, val_conv_8, 0, 64, val_conv_8_ref.compact_form);
22409                 val_constr.data[i] = val_conv_8_ref;
22410         }
22411         CommitmentSigned_set_htlc_signatures(&this_ptr_conv, val_constr);
22412 }
22413
22414 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) {
22415         LDKThirtyTwoBytes channel_id_arg_ref;
22416         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
22417         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
22418         LDKSignature signature_arg_ref;
22419         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
22420         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
22421         LDKCVec_SignatureZ htlc_signatures_arg_constr;
22422         htlc_signatures_arg_constr.datalen = (*env)->GetArrayLength(env, htlc_signatures_arg);
22423         if (htlc_signatures_arg_constr.datalen > 0)
22424                 htlc_signatures_arg_constr.data = MALLOC(htlc_signatures_arg_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
22425         else
22426                 htlc_signatures_arg_constr.data = NULL;
22427         for (size_t i = 0; i < htlc_signatures_arg_constr.datalen; i++) {
22428                 int8_tArray htlc_signatures_arg_conv_8 = (*env)->GetObjectArrayElement(env, htlc_signatures_arg, i);
22429                 LDKSignature htlc_signatures_arg_conv_8_ref;
22430                 CHECK((*env)->GetArrayLength(env, htlc_signatures_arg_conv_8) == 64);
22431                 (*env)->GetByteArrayRegion(env, htlc_signatures_arg_conv_8, 0, 64, htlc_signatures_arg_conv_8_ref.compact_form);
22432                 htlc_signatures_arg_constr.data[i] = htlc_signatures_arg_conv_8_ref;
22433         }
22434         LDKCommitmentSigned ret_var = CommitmentSigned_new(channel_id_arg_ref, signature_arg_ref, htlc_signatures_arg_constr);
22435         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22436         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22437         uint64_t ret_ref = (uint64_t)ret_var.inner;
22438         if (ret_var.is_owned) {
22439                 ret_ref |= 1;
22440         }
22441         return ret_ref;
22442 }
22443
22444 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22445         LDKCommitmentSigned orig_conv;
22446         orig_conv.inner = (void*)(orig & (~1));
22447         orig_conv.is_owned = false;
22448         LDKCommitmentSigned ret_var = CommitmentSigned_clone(&orig_conv);
22449         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22450         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22451         uint64_t ret_ref = (uint64_t)ret_var.inner;
22452         if (ret_var.is_owned) {
22453                 ret_ref |= 1;
22454         }
22455         return ret_ref;
22456 }
22457
22458 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22459         LDKRevokeAndACK this_obj_conv;
22460         this_obj_conv.inner = (void*)(this_obj & (~1));
22461         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22462         RevokeAndACK_free(this_obj_conv);
22463 }
22464
22465 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
22466         LDKRevokeAndACK this_ptr_conv;
22467         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22468         this_ptr_conv.is_owned = false;
22469         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
22470         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *RevokeAndACK_get_channel_id(&this_ptr_conv));
22471         return ret_arr;
22472 }
22473
22474 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22475         LDKRevokeAndACK this_ptr_conv;
22476         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22477         this_ptr_conv.is_owned = false;
22478         LDKThirtyTwoBytes val_ref;
22479         CHECK((*env)->GetArrayLength(env, val) == 32);
22480         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
22481         RevokeAndACK_set_channel_id(&this_ptr_conv, val_ref);
22482 }
22483
22484 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr) {
22485         LDKRevokeAndACK this_ptr_conv;
22486         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22487         this_ptr_conv.is_owned = false;
22488         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
22489         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *RevokeAndACK_get_per_commitment_secret(&this_ptr_conv));
22490         return ret_arr;
22491 }
22492
22493 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1set_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22494         LDKRevokeAndACK this_ptr_conv;
22495         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22496         this_ptr_conv.is_owned = false;
22497         LDKThirtyTwoBytes val_ref;
22498         CHECK((*env)->GetArrayLength(env, val) == 32);
22499         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
22500         RevokeAndACK_set_per_commitment_secret(&this_ptr_conv, val_ref);
22501 }
22502
22503 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1next_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
22504         LDKRevokeAndACK this_ptr_conv;
22505         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22506         this_ptr_conv.is_owned = false;
22507         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
22508         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RevokeAndACK_get_next_per_commitment_point(&this_ptr_conv).compressed_form);
22509         return ret_arr;
22510 }
22511
22512 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) {
22513         LDKRevokeAndACK this_ptr_conv;
22514         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22515         this_ptr_conv.is_owned = false;
22516         LDKPublicKey val_ref;
22517         CHECK((*env)->GetArrayLength(env, val) == 33);
22518         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
22519         RevokeAndACK_set_next_per_commitment_point(&this_ptr_conv, val_ref);
22520 }
22521
22522 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) {
22523         LDKThirtyTwoBytes channel_id_arg_ref;
22524         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
22525         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
22526         LDKThirtyTwoBytes per_commitment_secret_arg_ref;
22527         CHECK((*env)->GetArrayLength(env, per_commitment_secret_arg) == 32);
22528         (*env)->GetByteArrayRegion(env, per_commitment_secret_arg, 0, 32, per_commitment_secret_arg_ref.data);
22529         LDKPublicKey next_per_commitment_point_arg_ref;
22530         CHECK((*env)->GetArrayLength(env, next_per_commitment_point_arg) == 33);
22531         (*env)->GetByteArrayRegion(env, next_per_commitment_point_arg, 0, 33, next_per_commitment_point_arg_ref.compressed_form);
22532         LDKRevokeAndACK ret_var = RevokeAndACK_new(channel_id_arg_ref, per_commitment_secret_arg_ref, next_per_commitment_point_arg_ref);
22533         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22534         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22535         uint64_t ret_ref = (uint64_t)ret_var.inner;
22536         if (ret_var.is_owned) {
22537                 ret_ref |= 1;
22538         }
22539         return ret_ref;
22540 }
22541
22542 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22543         LDKRevokeAndACK orig_conv;
22544         orig_conv.inner = (void*)(orig & (~1));
22545         orig_conv.is_owned = false;
22546         LDKRevokeAndACK ret_var = RevokeAndACK_clone(&orig_conv);
22547         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22548         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22549         uint64_t ret_ref = (uint64_t)ret_var.inner;
22550         if (ret_var.is_owned) {
22551                 ret_ref |= 1;
22552         }
22553         return ret_ref;
22554 }
22555
22556 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22557         LDKUpdateFee this_obj_conv;
22558         this_obj_conv.inner = (void*)(this_obj & (~1));
22559         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22560         UpdateFee_free(this_obj_conv);
22561 }
22562
22563 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFee_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
22564         LDKUpdateFee this_ptr_conv;
22565         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22566         this_ptr_conv.is_owned = false;
22567         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
22568         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFee_get_channel_id(&this_ptr_conv));
22569         return ret_arr;
22570 }
22571
22572 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22573         LDKUpdateFee this_ptr_conv;
22574         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22575         this_ptr_conv.is_owned = false;
22576         LDKThirtyTwoBytes val_ref;
22577         CHECK((*env)->GetArrayLength(env, val) == 32);
22578         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
22579         UpdateFee_set_channel_id(&this_ptr_conv, val_ref);
22580 }
22581
22582 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1get_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr) {
22583         LDKUpdateFee this_ptr_conv;
22584         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22585         this_ptr_conv.is_owned = false;
22586         int32_t ret_val = UpdateFee_get_feerate_per_kw(&this_ptr_conv);
22587         return ret_val;
22588 }
22589
22590 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1set_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
22591         LDKUpdateFee this_ptr_conv;
22592         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22593         this_ptr_conv.is_owned = false;
22594         UpdateFee_set_feerate_per_kw(&this_ptr_conv, val);
22595 }
22596
22597 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) {
22598         LDKThirtyTwoBytes channel_id_arg_ref;
22599         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
22600         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
22601         LDKUpdateFee ret_var = UpdateFee_new(channel_id_arg_ref, feerate_per_kw_arg);
22602         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22603         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22604         uint64_t ret_ref = (uint64_t)ret_var.inner;
22605         if (ret_var.is_owned) {
22606                 ret_ref |= 1;
22607         }
22608         return ret_ref;
22609 }
22610
22611 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22612         LDKUpdateFee orig_conv;
22613         orig_conv.inner = (void*)(orig & (~1));
22614         orig_conv.is_owned = false;
22615         LDKUpdateFee ret_var = UpdateFee_clone(&orig_conv);
22616         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22617         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22618         uint64_t ret_ref = (uint64_t)ret_var.inner;
22619         if (ret_var.is_owned) {
22620                 ret_ref |= 1;
22621         }
22622         return ret_ref;
22623 }
22624
22625 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22626         LDKDataLossProtect this_obj_conv;
22627         this_obj_conv.inner = (void*)(this_obj & (~1));
22628         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22629         DataLossProtect_free(this_obj_conv);
22630 }
22631
22632 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1get_1your_1last_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr) {
22633         LDKDataLossProtect this_ptr_conv;
22634         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22635         this_ptr_conv.is_owned = false;
22636         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
22637         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *DataLossProtect_get_your_last_per_commitment_secret(&this_ptr_conv));
22638         return ret_arr;
22639 }
22640
22641 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) {
22642         LDKDataLossProtect this_ptr_conv;
22643         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22644         this_ptr_conv.is_owned = false;
22645         LDKThirtyTwoBytes val_ref;
22646         CHECK((*env)->GetArrayLength(env, val) == 32);
22647         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
22648         DataLossProtect_set_your_last_per_commitment_secret(&this_ptr_conv, val_ref);
22649 }
22650
22651 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1get_1my_1current_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
22652         LDKDataLossProtect this_ptr_conv;
22653         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22654         this_ptr_conv.is_owned = false;
22655         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
22656         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DataLossProtect_get_my_current_per_commitment_point(&this_ptr_conv).compressed_form);
22657         return ret_arr;
22658 }
22659
22660 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) {
22661         LDKDataLossProtect this_ptr_conv;
22662         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22663         this_ptr_conv.is_owned = false;
22664         LDKPublicKey val_ref;
22665         CHECK((*env)->GetArrayLength(env, val) == 33);
22666         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
22667         DataLossProtect_set_my_current_per_commitment_point(&this_ptr_conv, val_ref);
22668 }
22669
22670 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) {
22671         LDKThirtyTwoBytes your_last_per_commitment_secret_arg_ref;
22672         CHECK((*env)->GetArrayLength(env, your_last_per_commitment_secret_arg) == 32);
22673         (*env)->GetByteArrayRegion(env, your_last_per_commitment_secret_arg, 0, 32, your_last_per_commitment_secret_arg_ref.data);
22674         LDKPublicKey my_current_per_commitment_point_arg_ref;
22675         CHECK((*env)->GetArrayLength(env, my_current_per_commitment_point_arg) == 33);
22676         (*env)->GetByteArrayRegion(env, my_current_per_commitment_point_arg, 0, 33, my_current_per_commitment_point_arg_ref.compressed_form);
22677         LDKDataLossProtect ret_var = DataLossProtect_new(your_last_per_commitment_secret_arg_ref, my_current_per_commitment_point_arg_ref);
22678         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22679         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22680         uint64_t ret_ref = (uint64_t)ret_var.inner;
22681         if (ret_var.is_owned) {
22682                 ret_ref |= 1;
22683         }
22684         return ret_ref;
22685 }
22686
22687 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22688         LDKDataLossProtect orig_conv;
22689         orig_conv.inner = (void*)(orig & (~1));
22690         orig_conv.is_owned = false;
22691         LDKDataLossProtect ret_var = DataLossProtect_clone(&orig_conv);
22692         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22693         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22694         uint64_t ret_ref = (uint64_t)ret_var.inner;
22695         if (ret_var.is_owned) {
22696                 ret_ref |= 1;
22697         }
22698         return ret_ref;
22699 }
22700
22701 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22702         LDKChannelReestablish this_obj_conv;
22703         this_obj_conv.inner = (void*)(this_obj & (~1));
22704         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22705         ChannelReestablish_free(this_obj_conv);
22706 }
22707
22708 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
22709         LDKChannelReestablish this_ptr_conv;
22710         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22711         this_ptr_conv.is_owned = false;
22712         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
22713         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ChannelReestablish_get_channel_id(&this_ptr_conv));
22714         return ret_arr;
22715 }
22716
22717 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22718         LDKChannelReestablish this_ptr_conv;
22719         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22720         this_ptr_conv.is_owned = false;
22721         LDKThirtyTwoBytes val_ref;
22722         CHECK((*env)->GetArrayLength(env, val) == 32);
22723         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
22724         ChannelReestablish_set_channel_id(&this_ptr_conv, val_ref);
22725 }
22726
22727 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1next_1local_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_ptr) {
22728         LDKChannelReestablish this_ptr_conv;
22729         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22730         this_ptr_conv.is_owned = false;
22731         int64_t ret_val = ChannelReestablish_get_next_local_commitment_number(&this_ptr_conv);
22732         return ret_val;
22733 }
22734
22735 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) {
22736         LDKChannelReestablish this_ptr_conv;
22737         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22738         this_ptr_conv.is_owned = false;
22739         ChannelReestablish_set_next_local_commitment_number(&this_ptr_conv, val);
22740 }
22741
22742 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1next_1remote_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_ptr) {
22743         LDKChannelReestablish this_ptr_conv;
22744         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22745         this_ptr_conv.is_owned = false;
22746         int64_t ret_val = ChannelReestablish_get_next_remote_commitment_number(&this_ptr_conv);
22747         return ret_val;
22748 }
22749
22750 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) {
22751         LDKChannelReestablish this_ptr_conv;
22752         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22753         this_ptr_conv.is_owned = false;
22754         ChannelReestablish_set_next_remote_commitment_number(&this_ptr_conv, val);
22755 }
22756
22757 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22758         LDKChannelReestablish orig_conv;
22759         orig_conv.inner = (void*)(orig & (~1));
22760         orig_conv.is_owned = false;
22761         LDKChannelReestablish ret_var = ChannelReestablish_clone(&orig_conv);
22762         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22763         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22764         uint64_t ret_ref = (uint64_t)ret_var.inner;
22765         if (ret_var.is_owned) {
22766                 ret_ref |= 1;
22767         }
22768         return ret_ref;
22769 }
22770
22771 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22772         LDKAnnouncementSignatures this_obj_conv;
22773         this_obj_conv.inner = (void*)(this_obj & (~1));
22774         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22775         AnnouncementSignatures_free(this_obj_conv);
22776 }
22777
22778 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
22779         LDKAnnouncementSignatures this_ptr_conv;
22780         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22781         this_ptr_conv.is_owned = false;
22782         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
22783         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *AnnouncementSignatures_get_channel_id(&this_ptr_conv));
22784         return ret_arr;
22785 }
22786
22787 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22788         LDKAnnouncementSignatures this_ptr_conv;
22789         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22790         this_ptr_conv.is_owned = false;
22791         LDKThirtyTwoBytes val_ref;
22792         CHECK((*env)->GetArrayLength(env, val) == 32);
22793         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
22794         AnnouncementSignatures_set_channel_id(&this_ptr_conv, val_ref);
22795 }
22796
22797 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
22798         LDKAnnouncementSignatures this_ptr_conv;
22799         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22800         this_ptr_conv.is_owned = false;
22801         int64_t ret_val = AnnouncementSignatures_get_short_channel_id(&this_ptr_conv);
22802         return ret_val;
22803 }
22804
22805 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
22806         LDKAnnouncementSignatures this_ptr_conv;
22807         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22808         this_ptr_conv.is_owned = false;
22809         AnnouncementSignatures_set_short_channel_id(&this_ptr_conv, val);
22810 }
22811
22812 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1node_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
22813         LDKAnnouncementSignatures this_ptr_conv;
22814         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22815         this_ptr_conv.is_owned = false;
22816         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
22817         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, AnnouncementSignatures_get_node_signature(&this_ptr_conv).compact_form);
22818         return ret_arr;
22819 }
22820
22821 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1node_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22822         LDKAnnouncementSignatures this_ptr_conv;
22823         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22824         this_ptr_conv.is_owned = false;
22825         LDKSignature val_ref;
22826         CHECK((*env)->GetArrayLength(env, val) == 64);
22827         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
22828         AnnouncementSignatures_set_node_signature(&this_ptr_conv, val_ref);
22829 }
22830
22831 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1bitcoin_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
22832         LDKAnnouncementSignatures this_ptr_conv;
22833         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22834         this_ptr_conv.is_owned = false;
22835         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
22836         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, AnnouncementSignatures_get_bitcoin_signature(&this_ptr_conv).compact_form);
22837         return ret_arr;
22838 }
22839
22840 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1bitcoin_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22841         LDKAnnouncementSignatures this_ptr_conv;
22842         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22843         this_ptr_conv.is_owned = false;
22844         LDKSignature val_ref;
22845         CHECK((*env)->GetArrayLength(env, val) == 64);
22846         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
22847         AnnouncementSignatures_set_bitcoin_signature(&this_ptr_conv, val_ref);
22848 }
22849
22850 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) {
22851         LDKThirtyTwoBytes channel_id_arg_ref;
22852         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
22853         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
22854         LDKSignature node_signature_arg_ref;
22855         CHECK((*env)->GetArrayLength(env, node_signature_arg) == 64);
22856         (*env)->GetByteArrayRegion(env, node_signature_arg, 0, 64, node_signature_arg_ref.compact_form);
22857         LDKSignature bitcoin_signature_arg_ref;
22858         CHECK((*env)->GetArrayLength(env, bitcoin_signature_arg) == 64);
22859         (*env)->GetByteArrayRegion(env, bitcoin_signature_arg, 0, 64, bitcoin_signature_arg_ref.compact_form);
22860         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_new(channel_id_arg_ref, short_channel_id_arg, node_signature_arg_ref, bitcoin_signature_arg_ref);
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 int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22871         LDKAnnouncementSignatures orig_conv;
22872         orig_conv.inner = (void*)(orig & (~1));
22873         orig_conv.is_owned = false;
22874         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(&orig_conv);
22875         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22876         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22877         uint64_t ret_ref = (uint64_t)ret_var.inner;
22878         if (ret_var.is_owned) {
22879                 ret_ref |= 1;
22880         }
22881         return ret_ref;
22882 }
22883
22884 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetAddress_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
22885         if ((this_ptr & 1) != 0) return;
22886         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
22887         CHECK_ACCESS(this_ptr_ptr);
22888         LDKNetAddress this_ptr_conv = *(LDKNetAddress*)(this_ptr_ptr);
22889         FREE((void*)this_ptr);
22890         NetAddress_free(this_ptr_conv);
22891 }
22892
22893 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22894         LDKNetAddress* orig_conv = (LDKNetAddress*)orig;
22895         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
22896         *ret_copy = NetAddress_clone(orig_conv);
22897         uint64_t ret_ref = (uint64_t)ret_copy;
22898         return ret_ref;
22899 }
22900
22901 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1ipv4(JNIEnv *env, jclass clz, int8_tArray addr, int16_t port) {
22902         LDKFourBytes addr_ref;
22903         CHECK((*env)->GetArrayLength(env, addr) == 4);
22904         (*env)->GetByteArrayRegion(env, addr, 0, 4, addr_ref.data);
22905         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
22906         *ret_copy = NetAddress_ipv4(addr_ref, port);
22907         uint64_t ret_ref = (uint64_t)ret_copy;
22908         return ret_ref;
22909 }
22910
22911 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1ipv6(JNIEnv *env, jclass clz, int8_tArray addr, int16_t port) {
22912         LDKSixteenBytes addr_ref;
22913         CHECK((*env)->GetArrayLength(env, addr) == 16);
22914         (*env)->GetByteArrayRegion(env, addr, 0, 16, addr_ref.data);
22915         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
22916         *ret_copy = NetAddress_ipv6(addr_ref, port);
22917         uint64_t ret_ref = (uint64_t)ret_copy;
22918         return ret_ref;
22919 }
22920
22921 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1onion_1v2(JNIEnv *env, jclass clz, int8_tArray addr, int16_t port) {
22922         LDKTenBytes addr_ref;
22923         CHECK((*env)->GetArrayLength(env, addr) == 10);
22924         (*env)->GetByteArrayRegion(env, addr, 0, 10, addr_ref.data);
22925         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
22926         *ret_copy = NetAddress_onion_v2(addr_ref, port);
22927         uint64_t ret_ref = (uint64_t)ret_copy;
22928         return ret_ref;
22929 }
22930
22931 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) {
22932         LDKThirtyTwoBytes ed25519_pubkey_ref;
22933         CHECK((*env)->GetArrayLength(env, ed25519_pubkey) == 32);
22934         (*env)->GetByteArrayRegion(env, ed25519_pubkey, 0, 32, ed25519_pubkey_ref.data);
22935         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
22936         *ret_copy = NetAddress_onion_v3(ed25519_pubkey_ref, checksum, version, port);
22937         uint64_t ret_ref = (uint64_t)ret_copy;
22938         return ret_ref;
22939 }
22940
22941 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetAddress_1write(JNIEnv *env, jclass clz, int64_t obj) {
22942         LDKNetAddress* obj_conv = (LDKNetAddress*)obj;
22943         LDKCVec_u8Z ret_var = NetAddress_write(obj_conv);
22944         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22945         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22946         CVec_u8Z_free(ret_var);
22947         return ret_arr;
22948 }
22949
22950 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Result_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
22951         LDKu8slice ser_ref;
22952         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
22953         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
22954         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
22955         *ret_conv = Result_read(ser_ref);
22956         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
22957         return (uint64_t)ret_conv;
22958 }
22959
22960 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
22961         LDKu8slice ser_ref;
22962         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
22963         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
22964         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
22965         *ret_conv = NetAddress_read(ser_ref);
22966         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
22967         return (uint64_t)ret_conv;
22968 }
22969
22970 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22971         LDKUnsignedNodeAnnouncement this_obj_conv;
22972         this_obj_conv.inner = (void*)(this_obj & (~1));
22973         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22974         UnsignedNodeAnnouncement_free(this_obj_conv);
22975 }
22976
22977 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
22978         LDKUnsignedNodeAnnouncement this_ptr_conv;
22979         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22980         this_ptr_conv.is_owned = false;
22981         LDKNodeFeatures ret_var = UnsignedNodeAnnouncement_get_features(&this_ptr_conv);
22982         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22983         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22984         uint64_t ret_ref = (uint64_t)ret_var.inner;
22985         if (ret_var.is_owned) {
22986                 ret_ref |= 1;
22987         }
22988         return ret_ref;
22989 }
22990
22991 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
22992         LDKUnsignedNodeAnnouncement this_ptr_conv;
22993         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22994         this_ptr_conv.is_owned = false;
22995         LDKNodeFeatures val_conv;
22996         val_conv.inner = (void*)(val & (~1));
22997         val_conv.is_owned = (val & 1) || (val == 0);
22998         val_conv = NodeFeatures_clone(&val_conv);
22999         UnsignedNodeAnnouncement_set_features(&this_ptr_conv, val_conv);
23000 }
23001
23002 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
23003         LDKUnsignedNodeAnnouncement this_ptr_conv;
23004         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23005         this_ptr_conv.is_owned = false;
23006         int32_t ret_val = UnsignedNodeAnnouncement_get_timestamp(&this_ptr_conv);
23007         return ret_val;
23008 }
23009
23010 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
23011         LDKUnsignedNodeAnnouncement this_ptr_conv;
23012         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23013         this_ptr_conv.is_owned = false;
23014         UnsignedNodeAnnouncement_set_timestamp(&this_ptr_conv, val);
23015 }
23016
23017 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
23018         LDKUnsignedNodeAnnouncement this_ptr_conv;
23019         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23020         this_ptr_conv.is_owned = false;
23021         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
23022         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedNodeAnnouncement_get_node_id(&this_ptr_conv).compressed_form);
23023         return ret_arr;
23024 }
23025
23026 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
23027         LDKUnsignedNodeAnnouncement this_ptr_conv;
23028         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23029         this_ptr_conv.is_owned = false;
23030         LDKPublicKey val_ref;
23031         CHECK((*env)->GetArrayLength(env, val) == 33);
23032         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
23033         UnsignedNodeAnnouncement_set_node_id(&this_ptr_conv, val_ref);
23034 }
23035
23036 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr) {
23037         LDKUnsignedNodeAnnouncement this_ptr_conv;
23038         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23039         this_ptr_conv.is_owned = false;
23040         int8_tArray ret_arr = (*env)->NewByteArray(env, 3);
23041         (*env)->SetByteArrayRegion(env, ret_arr, 0, 3, *UnsignedNodeAnnouncement_get_rgb(&this_ptr_conv));
23042         return ret_arr;
23043 }
23044
23045 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
23046         LDKUnsignedNodeAnnouncement this_ptr_conv;
23047         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23048         this_ptr_conv.is_owned = false;
23049         LDKThreeBytes val_ref;
23050         CHECK((*env)->GetArrayLength(env, val) == 3);
23051         (*env)->GetByteArrayRegion(env, val, 0, 3, val_ref.data);
23052         UnsignedNodeAnnouncement_set_rgb(&this_ptr_conv, val_ref);
23053 }
23054
23055 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
23056         LDKUnsignedNodeAnnouncement this_ptr_conv;
23057         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23058         this_ptr_conv.is_owned = false;
23059         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
23060         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedNodeAnnouncement_get_alias(&this_ptr_conv));
23061         return ret_arr;
23062 }
23063
23064 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
23065         LDKUnsignedNodeAnnouncement this_ptr_conv;
23066         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23067         this_ptr_conv.is_owned = false;
23068         LDKThirtyTwoBytes val_ref;
23069         CHECK((*env)->GetArrayLength(env, val) == 32);
23070         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
23071         UnsignedNodeAnnouncement_set_alias(&this_ptr_conv, val_ref);
23072 }
23073
23074 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1addresses(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
23075         LDKUnsignedNodeAnnouncement this_ptr_conv;
23076         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23077         this_ptr_conv.is_owned = false;
23078         LDKCVec_NetAddressZ val_constr;
23079         val_constr.datalen = (*env)->GetArrayLength(env, val);
23080         if (val_constr.datalen > 0)
23081                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
23082         else
23083                 val_constr.data = NULL;
23084         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
23085         for (size_t m = 0; m < val_constr.datalen; m++) {
23086                 int64_t val_conv_12 = val_vals[m];
23087                 void* val_conv_12_ptr = (void*)(((uint64_t)val_conv_12) & ~1);
23088                 CHECK_ACCESS(val_conv_12_ptr);
23089                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(val_conv_12_ptr);
23090                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)val_conv_12) & ~1));
23091                 val_constr.data[m] = val_conv_12_conv;
23092         }
23093         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
23094         UnsignedNodeAnnouncement_set_addresses(&this_ptr_conv, val_constr);
23095 }
23096
23097 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23098         LDKUnsignedNodeAnnouncement orig_conv;
23099         orig_conv.inner = (void*)(orig & (~1));
23100         orig_conv.is_owned = false;
23101         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(&orig_conv);
23102         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23103         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23104         uint64_t ret_ref = (uint64_t)ret_var.inner;
23105         if (ret_var.is_owned) {
23106                 ret_ref |= 1;
23107         }
23108         return ret_ref;
23109 }
23110
23111 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23112         LDKNodeAnnouncement this_obj_conv;
23113         this_obj_conv.inner = (void*)(this_obj & (~1));
23114         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23115         NodeAnnouncement_free(this_obj_conv);
23116 }
23117
23118 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
23119         LDKNodeAnnouncement this_ptr_conv;
23120         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23121         this_ptr_conv.is_owned = false;
23122         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
23123         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, NodeAnnouncement_get_signature(&this_ptr_conv).compact_form);
23124         return ret_arr;
23125 }
23126
23127 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
23128         LDKNodeAnnouncement this_ptr_conv;
23129         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23130         this_ptr_conv.is_owned = false;
23131         LDKSignature val_ref;
23132         CHECK((*env)->GetArrayLength(env, val) == 64);
23133         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
23134         NodeAnnouncement_set_signature(&this_ptr_conv, val_ref);
23135 }
23136
23137 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
23138         LDKNodeAnnouncement this_ptr_conv;
23139         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23140         this_ptr_conv.is_owned = false;
23141         LDKUnsignedNodeAnnouncement ret_var = NodeAnnouncement_get_contents(&this_ptr_conv);
23142         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23143         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23144         uint64_t ret_ref = (uint64_t)ret_var.inner;
23145         if (ret_var.is_owned) {
23146                 ret_ref |= 1;
23147         }
23148         return ret_ref;
23149 }
23150
23151 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23152         LDKNodeAnnouncement this_ptr_conv;
23153         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23154         this_ptr_conv.is_owned = false;
23155         LDKUnsignedNodeAnnouncement val_conv;
23156         val_conv.inner = (void*)(val & (~1));
23157         val_conv.is_owned = (val & 1) || (val == 0);
23158         val_conv = UnsignedNodeAnnouncement_clone(&val_conv);
23159         NodeAnnouncement_set_contents(&this_ptr_conv, val_conv);
23160 }
23161
23162 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1new(JNIEnv *env, jclass clz, int8_tArray signature_arg, int64_t contents_arg) {
23163         LDKSignature signature_arg_ref;
23164         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
23165         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
23166         LDKUnsignedNodeAnnouncement contents_arg_conv;
23167         contents_arg_conv.inner = (void*)(contents_arg & (~1));
23168         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
23169         contents_arg_conv = UnsignedNodeAnnouncement_clone(&contents_arg_conv);
23170         LDKNodeAnnouncement ret_var = NodeAnnouncement_new(signature_arg_ref, contents_arg_conv);
23171         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23172         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23173         uint64_t ret_ref = (uint64_t)ret_var.inner;
23174         if (ret_var.is_owned) {
23175                 ret_ref |= 1;
23176         }
23177         return ret_ref;
23178 }
23179
23180 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23181         LDKNodeAnnouncement orig_conv;
23182         orig_conv.inner = (void*)(orig & (~1));
23183         orig_conv.is_owned = false;
23184         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(&orig_conv);
23185         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23186         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23187         uint64_t ret_ref = (uint64_t)ret_var.inner;
23188         if (ret_var.is_owned) {
23189                 ret_ref |= 1;
23190         }
23191         return ret_ref;
23192 }
23193
23194 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23195         LDKUnsignedChannelAnnouncement this_obj_conv;
23196         this_obj_conv.inner = (void*)(this_obj & (~1));
23197         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23198         UnsignedChannelAnnouncement_free(this_obj_conv);
23199 }
23200
23201 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
23202         LDKUnsignedChannelAnnouncement this_ptr_conv;
23203         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23204         this_ptr_conv.is_owned = false;
23205         LDKChannelFeatures ret_var = UnsignedChannelAnnouncement_get_features(&this_ptr_conv);
23206         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23207         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23208         uint64_t ret_ref = (uint64_t)ret_var.inner;
23209         if (ret_var.is_owned) {
23210                 ret_ref |= 1;
23211         }
23212         return ret_ref;
23213 }
23214
23215 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23216         LDKUnsignedChannelAnnouncement this_ptr_conv;
23217         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23218         this_ptr_conv.is_owned = false;
23219         LDKChannelFeatures val_conv;
23220         val_conv.inner = (void*)(val & (~1));
23221         val_conv.is_owned = (val & 1) || (val == 0);
23222         val_conv = ChannelFeatures_clone(&val_conv);
23223         UnsignedChannelAnnouncement_set_features(&this_ptr_conv, val_conv);
23224 }
23225
23226 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
23227         LDKUnsignedChannelAnnouncement this_ptr_conv;
23228         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23229         this_ptr_conv.is_owned = false;
23230         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
23231         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedChannelAnnouncement_get_chain_hash(&this_ptr_conv));
23232         return ret_arr;
23233 }
23234
23235 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
23236         LDKUnsignedChannelAnnouncement this_ptr_conv;
23237         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23238         this_ptr_conv.is_owned = false;
23239         LDKThirtyTwoBytes val_ref;
23240         CHECK((*env)->GetArrayLength(env, val) == 32);
23241         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
23242         UnsignedChannelAnnouncement_set_chain_hash(&this_ptr_conv, val_ref);
23243 }
23244
23245 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
23246         LDKUnsignedChannelAnnouncement this_ptr_conv;
23247         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23248         this_ptr_conv.is_owned = false;
23249         int64_t ret_val = UnsignedChannelAnnouncement_get_short_channel_id(&this_ptr_conv);
23250         return ret_val;
23251 }
23252
23253 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23254         LDKUnsignedChannelAnnouncement this_ptr_conv;
23255         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23256         this_ptr_conv.is_owned = false;
23257         UnsignedChannelAnnouncement_set_short_channel_id(&this_ptr_conv, val);
23258 }
23259
23260 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1node_1id_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
23261         LDKUnsignedChannelAnnouncement this_ptr_conv;
23262         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23263         this_ptr_conv.is_owned = false;
23264         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
23265         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_node_id_1(&this_ptr_conv).compressed_form);
23266         return ret_arr;
23267 }
23268
23269 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1node_1id_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
23270         LDKUnsignedChannelAnnouncement this_ptr_conv;
23271         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23272         this_ptr_conv.is_owned = false;
23273         LDKPublicKey val_ref;
23274         CHECK((*env)->GetArrayLength(env, val) == 33);
23275         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
23276         UnsignedChannelAnnouncement_set_node_id_1(&this_ptr_conv, val_ref);
23277 }
23278
23279 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1node_1id_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
23280         LDKUnsignedChannelAnnouncement this_ptr_conv;
23281         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23282         this_ptr_conv.is_owned = false;
23283         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
23284         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_node_id_2(&this_ptr_conv).compressed_form);
23285         return ret_arr;
23286 }
23287
23288 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1node_1id_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
23289         LDKUnsignedChannelAnnouncement this_ptr_conv;
23290         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23291         this_ptr_conv.is_owned = false;
23292         LDKPublicKey val_ref;
23293         CHECK((*env)->GetArrayLength(env, val) == 33);
23294         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
23295         UnsignedChannelAnnouncement_set_node_id_2(&this_ptr_conv, val_ref);
23296 }
23297
23298 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1bitcoin_1key_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
23299         LDKUnsignedChannelAnnouncement this_ptr_conv;
23300         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23301         this_ptr_conv.is_owned = false;
23302         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
23303         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_bitcoin_key_1(&this_ptr_conv).compressed_form);
23304         return ret_arr;
23305 }
23306
23307 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1bitcoin_1key_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
23308         LDKUnsignedChannelAnnouncement this_ptr_conv;
23309         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23310         this_ptr_conv.is_owned = false;
23311         LDKPublicKey val_ref;
23312         CHECK((*env)->GetArrayLength(env, val) == 33);
23313         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
23314         UnsignedChannelAnnouncement_set_bitcoin_key_1(&this_ptr_conv, val_ref);
23315 }
23316
23317 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1bitcoin_1key_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
23318         LDKUnsignedChannelAnnouncement this_ptr_conv;
23319         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23320         this_ptr_conv.is_owned = false;
23321         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
23322         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_bitcoin_key_2(&this_ptr_conv).compressed_form);
23323         return ret_arr;
23324 }
23325
23326 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1bitcoin_1key_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
23327         LDKUnsignedChannelAnnouncement this_ptr_conv;
23328         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23329         this_ptr_conv.is_owned = false;
23330         LDKPublicKey val_ref;
23331         CHECK((*env)->GetArrayLength(env, val) == 33);
23332         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
23333         UnsignedChannelAnnouncement_set_bitcoin_key_2(&this_ptr_conv, val_ref);
23334 }
23335
23336 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23337         LDKUnsignedChannelAnnouncement orig_conv;
23338         orig_conv.inner = (void*)(orig & (~1));
23339         orig_conv.is_owned = false;
23340         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(&orig_conv);
23341         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23342         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23343         uint64_t ret_ref = (uint64_t)ret_var.inner;
23344         if (ret_var.is_owned) {
23345                 ret_ref |= 1;
23346         }
23347         return ret_ref;
23348 }
23349
23350 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23351         LDKChannelAnnouncement this_obj_conv;
23352         this_obj_conv.inner = (void*)(this_obj & (~1));
23353         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23354         ChannelAnnouncement_free(this_obj_conv);
23355 }
23356
23357 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1node_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
23358         LDKChannelAnnouncement this_ptr_conv;
23359         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23360         this_ptr_conv.is_owned = false;
23361         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
23362         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_node_signature_1(&this_ptr_conv).compact_form);
23363         return ret_arr;
23364 }
23365
23366 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1node_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
23367         LDKChannelAnnouncement this_ptr_conv;
23368         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23369         this_ptr_conv.is_owned = false;
23370         LDKSignature val_ref;
23371         CHECK((*env)->GetArrayLength(env, val) == 64);
23372         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
23373         ChannelAnnouncement_set_node_signature_1(&this_ptr_conv, val_ref);
23374 }
23375
23376 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1node_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
23377         LDKChannelAnnouncement this_ptr_conv;
23378         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23379         this_ptr_conv.is_owned = false;
23380         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
23381         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_node_signature_2(&this_ptr_conv).compact_form);
23382         return ret_arr;
23383 }
23384
23385 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1node_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
23386         LDKChannelAnnouncement this_ptr_conv;
23387         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23388         this_ptr_conv.is_owned = false;
23389         LDKSignature val_ref;
23390         CHECK((*env)->GetArrayLength(env, val) == 64);
23391         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
23392         ChannelAnnouncement_set_node_signature_2(&this_ptr_conv, val_ref);
23393 }
23394
23395 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1bitcoin_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
23396         LDKChannelAnnouncement this_ptr_conv;
23397         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23398         this_ptr_conv.is_owned = false;
23399         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
23400         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_bitcoin_signature_1(&this_ptr_conv).compact_form);
23401         return ret_arr;
23402 }
23403
23404 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1bitcoin_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
23405         LDKChannelAnnouncement this_ptr_conv;
23406         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23407         this_ptr_conv.is_owned = false;
23408         LDKSignature val_ref;
23409         CHECK((*env)->GetArrayLength(env, val) == 64);
23410         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
23411         ChannelAnnouncement_set_bitcoin_signature_1(&this_ptr_conv, val_ref);
23412 }
23413
23414 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1bitcoin_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
23415         LDKChannelAnnouncement this_ptr_conv;
23416         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23417         this_ptr_conv.is_owned = false;
23418         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
23419         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_bitcoin_signature_2(&this_ptr_conv).compact_form);
23420         return ret_arr;
23421 }
23422
23423 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1bitcoin_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
23424         LDKChannelAnnouncement this_ptr_conv;
23425         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23426         this_ptr_conv.is_owned = false;
23427         LDKSignature val_ref;
23428         CHECK((*env)->GetArrayLength(env, val) == 64);
23429         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
23430         ChannelAnnouncement_set_bitcoin_signature_2(&this_ptr_conv, val_ref);
23431 }
23432
23433 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
23434         LDKChannelAnnouncement this_ptr_conv;
23435         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23436         this_ptr_conv.is_owned = false;
23437         LDKUnsignedChannelAnnouncement ret_var = ChannelAnnouncement_get_contents(&this_ptr_conv);
23438         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23439         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23440         uint64_t ret_ref = (uint64_t)ret_var.inner;
23441         if (ret_var.is_owned) {
23442                 ret_ref |= 1;
23443         }
23444         return ret_ref;
23445 }
23446
23447 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23448         LDKChannelAnnouncement this_ptr_conv;
23449         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23450         this_ptr_conv.is_owned = false;
23451         LDKUnsignedChannelAnnouncement val_conv;
23452         val_conv.inner = (void*)(val & (~1));
23453         val_conv.is_owned = (val & 1) || (val == 0);
23454         val_conv = UnsignedChannelAnnouncement_clone(&val_conv);
23455         ChannelAnnouncement_set_contents(&this_ptr_conv, val_conv);
23456 }
23457
23458 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) {
23459         LDKSignature node_signature_1_arg_ref;
23460         CHECK((*env)->GetArrayLength(env, node_signature_1_arg) == 64);
23461         (*env)->GetByteArrayRegion(env, node_signature_1_arg, 0, 64, node_signature_1_arg_ref.compact_form);
23462         LDKSignature node_signature_2_arg_ref;
23463         CHECK((*env)->GetArrayLength(env, node_signature_2_arg) == 64);
23464         (*env)->GetByteArrayRegion(env, node_signature_2_arg, 0, 64, node_signature_2_arg_ref.compact_form);
23465         LDKSignature bitcoin_signature_1_arg_ref;
23466         CHECK((*env)->GetArrayLength(env, bitcoin_signature_1_arg) == 64);
23467         (*env)->GetByteArrayRegion(env, bitcoin_signature_1_arg, 0, 64, bitcoin_signature_1_arg_ref.compact_form);
23468         LDKSignature bitcoin_signature_2_arg_ref;
23469         CHECK((*env)->GetArrayLength(env, bitcoin_signature_2_arg) == 64);
23470         (*env)->GetByteArrayRegion(env, bitcoin_signature_2_arg, 0, 64, bitcoin_signature_2_arg_ref.compact_form);
23471         LDKUnsignedChannelAnnouncement contents_arg_conv;
23472         contents_arg_conv.inner = (void*)(contents_arg & (~1));
23473         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
23474         contents_arg_conv = UnsignedChannelAnnouncement_clone(&contents_arg_conv);
23475         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);
23476         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23477         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23478         uint64_t ret_ref = (uint64_t)ret_var.inner;
23479         if (ret_var.is_owned) {
23480                 ret_ref |= 1;
23481         }
23482         return ret_ref;
23483 }
23484
23485 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23486         LDKChannelAnnouncement orig_conv;
23487         orig_conv.inner = (void*)(orig & (~1));
23488         orig_conv.is_owned = false;
23489         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(&orig_conv);
23490         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23491         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23492         uint64_t ret_ref = (uint64_t)ret_var.inner;
23493         if (ret_var.is_owned) {
23494                 ret_ref |= 1;
23495         }
23496         return ret_ref;
23497 }
23498
23499 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23500         LDKUnsignedChannelUpdate this_obj_conv;
23501         this_obj_conv.inner = (void*)(this_obj & (~1));
23502         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23503         UnsignedChannelUpdate_free(this_obj_conv);
23504 }
23505
23506 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
23507         LDKUnsignedChannelUpdate this_ptr_conv;
23508         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23509         this_ptr_conv.is_owned = false;
23510         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
23511         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedChannelUpdate_get_chain_hash(&this_ptr_conv));
23512         return ret_arr;
23513 }
23514
23515 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
23516         LDKUnsignedChannelUpdate this_ptr_conv;
23517         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23518         this_ptr_conv.is_owned = false;
23519         LDKThirtyTwoBytes val_ref;
23520         CHECK((*env)->GetArrayLength(env, val) == 32);
23521         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
23522         UnsignedChannelUpdate_set_chain_hash(&this_ptr_conv, val_ref);
23523 }
23524
23525 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
23526         LDKUnsignedChannelUpdate this_ptr_conv;
23527         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23528         this_ptr_conv.is_owned = false;
23529         int64_t ret_val = UnsignedChannelUpdate_get_short_channel_id(&this_ptr_conv);
23530         return ret_val;
23531 }
23532
23533 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23534         LDKUnsignedChannelUpdate this_ptr_conv;
23535         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23536         this_ptr_conv.is_owned = false;
23537         UnsignedChannelUpdate_set_short_channel_id(&this_ptr_conv, val);
23538 }
23539
23540 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
23541         LDKUnsignedChannelUpdate this_ptr_conv;
23542         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23543         this_ptr_conv.is_owned = false;
23544         int32_t ret_val = UnsignedChannelUpdate_get_timestamp(&this_ptr_conv);
23545         return ret_val;
23546 }
23547
23548 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
23549         LDKUnsignedChannelUpdate this_ptr_conv;
23550         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23551         this_ptr_conv.is_owned = false;
23552         UnsignedChannelUpdate_set_timestamp(&this_ptr_conv, val);
23553 }
23554
23555 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1flags(JNIEnv *env, jclass clz, int64_t this_ptr) {
23556         LDKUnsignedChannelUpdate this_ptr_conv;
23557         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23558         this_ptr_conv.is_owned = false;
23559         int8_t ret_val = UnsignedChannelUpdate_get_flags(&this_ptr_conv);
23560         return ret_val;
23561 }
23562
23563 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1flags(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
23564         LDKUnsignedChannelUpdate this_ptr_conv;
23565         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23566         this_ptr_conv.is_owned = false;
23567         UnsignedChannelUpdate_set_flags(&this_ptr_conv, val);
23568 }
23569
23570 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
23571         LDKUnsignedChannelUpdate this_ptr_conv;
23572         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23573         this_ptr_conv.is_owned = false;
23574         int16_t ret_val = UnsignedChannelUpdate_get_cltv_expiry_delta(&this_ptr_conv);
23575         return ret_val;
23576 }
23577
23578 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
23579         LDKUnsignedChannelUpdate this_ptr_conv;
23580         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23581         this_ptr_conv.is_owned = false;
23582         UnsignedChannelUpdate_set_cltv_expiry_delta(&this_ptr_conv, val);
23583 }
23584
23585 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
23586         LDKUnsignedChannelUpdate this_ptr_conv;
23587         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23588         this_ptr_conv.is_owned = false;
23589         int64_t ret_val = UnsignedChannelUpdate_get_htlc_minimum_msat(&this_ptr_conv);
23590         return ret_val;
23591 }
23592
23593 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23594         LDKUnsignedChannelUpdate this_ptr_conv;
23595         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23596         this_ptr_conv.is_owned = false;
23597         UnsignedChannelUpdate_set_htlc_minimum_msat(&this_ptr_conv, val);
23598 }
23599
23600 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
23601         LDKUnsignedChannelUpdate this_ptr_conv;
23602         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23603         this_ptr_conv.is_owned = false;
23604         int32_t ret_val = UnsignedChannelUpdate_get_fee_base_msat(&this_ptr_conv);
23605         return ret_val;
23606 }
23607
23608 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
23609         LDKUnsignedChannelUpdate this_ptr_conv;
23610         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23611         this_ptr_conv.is_owned = false;
23612         UnsignedChannelUpdate_set_fee_base_msat(&this_ptr_conv, val);
23613 }
23614
23615 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
23616         LDKUnsignedChannelUpdate this_ptr_conv;
23617         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23618         this_ptr_conv.is_owned = false;
23619         int32_t ret_val = UnsignedChannelUpdate_get_fee_proportional_millionths(&this_ptr_conv);
23620         return ret_val;
23621 }
23622
23623 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
23624         LDKUnsignedChannelUpdate this_ptr_conv;
23625         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23626         this_ptr_conv.is_owned = false;
23627         UnsignedChannelUpdate_set_fee_proportional_millionths(&this_ptr_conv, val);
23628 }
23629
23630 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23631         LDKUnsignedChannelUpdate orig_conv;
23632         orig_conv.inner = (void*)(orig & (~1));
23633         orig_conv.is_owned = false;
23634         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(&orig_conv);
23635         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23636         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23637         uint64_t ret_ref = (uint64_t)ret_var.inner;
23638         if (ret_var.is_owned) {
23639                 ret_ref |= 1;
23640         }
23641         return ret_ref;
23642 }
23643
23644 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23645         LDKChannelUpdate this_obj_conv;
23646         this_obj_conv.inner = (void*)(this_obj & (~1));
23647         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23648         ChannelUpdate_free(this_obj_conv);
23649 }
23650
23651 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
23652         LDKChannelUpdate this_ptr_conv;
23653         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23654         this_ptr_conv.is_owned = false;
23655         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
23656         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelUpdate_get_signature(&this_ptr_conv).compact_form);
23657         return ret_arr;
23658 }
23659
23660 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
23661         LDKChannelUpdate this_ptr_conv;
23662         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23663         this_ptr_conv.is_owned = false;
23664         LDKSignature val_ref;
23665         CHECK((*env)->GetArrayLength(env, val) == 64);
23666         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
23667         ChannelUpdate_set_signature(&this_ptr_conv, val_ref);
23668 }
23669
23670 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
23671         LDKChannelUpdate this_ptr_conv;
23672         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23673         this_ptr_conv.is_owned = false;
23674         LDKUnsignedChannelUpdate ret_var = ChannelUpdate_get_contents(&this_ptr_conv);
23675         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23676         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23677         uint64_t ret_ref = (uint64_t)ret_var.inner;
23678         if (ret_var.is_owned) {
23679                 ret_ref |= 1;
23680         }
23681         return ret_ref;
23682 }
23683
23684 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23685         LDKChannelUpdate this_ptr_conv;
23686         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23687         this_ptr_conv.is_owned = false;
23688         LDKUnsignedChannelUpdate val_conv;
23689         val_conv.inner = (void*)(val & (~1));
23690         val_conv.is_owned = (val & 1) || (val == 0);
23691         val_conv = UnsignedChannelUpdate_clone(&val_conv);
23692         ChannelUpdate_set_contents(&this_ptr_conv, val_conv);
23693 }
23694
23695 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1new(JNIEnv *env, jclass clz, int8_tArray signature_arg, int64_t contents_arg) {
23696         LDKSignature signature_arg_ref;
23697         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
23698         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
23699         LDKUnsignedChannelUpdate contents_arg_conv;
23700         contents_arg_conv.inner = (void*)(contents_arg & (~1));
23701         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
23702         contents_arg_conv = UnsignedChannelUpdate_clone(&contents_arg_conv);
23703         LDKChannelUpdate ret_var = ChannelUpdate_new(signature_arg_ref, contents_arg_conv);
23704         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23705         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23706         uint64_t ret_ref = (uint64_t)ret_var.inner;
23707         if (ret_var.is_owned) {
23708                 ret_ref |= 1;
23709         }
23710         return ret_ref;
23711 }
23712
23713 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23714         LDKChannelUpdate orig_conv;
23715         orig_conv.inner = (void*)(orig & (~1));
23716         orig_conv.is_owned = false;
23717         LDKChannelUpdate ret_var = ChannelUpdate_clone(&orig_conv);
23718         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23719         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23720         uint64_t ret_ref = (uint64_t)ret_var.inner;
23721         if (ret_var.is_owned) {
23722                 ret_ref |= 1;
23723         }
23724         return ret_ref;
23725 }
23726
23727 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23728         LDKQueryChannelRange this_obj_conv;
23729         this_obj_conv.inner = (void*)(this_obj & (~1));
23730         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23731         QueryChannelRange_free(this_obj_conv);
23732 }
23733
23734 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
23735         LDKQueryChannelRange this_ptr_conv;
23736         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23737         this_ptr_conv.is_owned = false;
23738         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
23739         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *QueryChannelRange_get_chain_hash(&this_ptr_conv));
23740         return ret_arr;
23741 }
23742
23743 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
23744         LDKQueryChannelRange this_ptr_conv;
23745         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23746         this_ptr_conv.is_owned = false;
23747         LDKThirtyTwoBytes val_ref;
23748         CHECK((*env)->GetArrayLength(env, val) == 32);
23749         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
23750         QueryChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
23751 }
23752
23753 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr) {
23754         LDKQueryChannelRange this_ptr_conv;
23755         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23756         this_ptr_conv.is_owned = false;
23757         int32_t ret_val = QueryChannelRange_get_first_blocknum(&this_ptr_conv);
23758         return ret_val;
23759 }
23760
23761 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
23762         LDKQueryChannelRange this_ptr_conv;
23763         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23764         this_ptr_conv.is_owned = false;
23765         QueryChannelRange_set_first_blocknum(&this_ptr_conv, val);
23766 }
23767
23768 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr) {
23769         LDKQueryChannelRange this_ptr_conv;
23770         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23771         this_ptr_conv.is_owned = false;
23772         int32_t ret_val = QueryChannelRange_get_number_of_blocks(&this_ptr_conv);
23773         return ret_val;
23774 }
23775
23776 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
23777         LDKQueryChannelRange this_ptr_conv;
23778         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23779         this_ptr_conv.is_owned = false;
23780         QueryChannelRange_set_number_of_blocks(&this_ptr_conv, val);
23781 }
23782
23783 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) {
23784         LDKThirtyTwoBytes chain_hash_arg_ref;
23785         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
23786         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
23787         LDKQueryChannelRange ret_var = QueryChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg);
23788         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23789         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23790         uint64_t ret_ref = (uint64_t)ret_var.inner;
23791         if (ret_var.is_owned) {
23792                 ret_ref |= 1;
23793         }
23794         return ret_ref;
23795 }
23796
23797 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23798         LDKQueryChannelRange orig_conv;
23799         orig_conv.inner = (void*)(orig & (~1));
23800         orig_conv.is_owned = false;
23801         LDKQueryChannelRange ret_var = QueryChannelRange_clone(&orig_conv);
23802         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23803         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23804         uint64_t ret_ref = (uint64_t)ret_var.inner;
23805         if (ret_var.is_owned) {
23806                 ret_ref |= 1;
23807         }
23808         return ret_ref;
23809 }
23810
23811 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23812         LDKReplyChannelRange this_obj_conv;
23813         this_obj_conv.inner = (void*)(this_obj & (~1));
23814         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23815         ReplyChannelRange_free(this_obj_conv);
23816 }
23817
23818 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
23819         LDKReplyChannelRange this_ptr_conv;
23820         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23821         this_ptr_conv.is_owned = false;
23822         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
23823         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ReplyChannelRange_get_chain_hash(&this_ptr_conv));
23824         return ret_arr;
23825 }
23826
23827 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
23828         LDKReplyChannelRange this_ptr_conv;
23829         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23830         this_ptr_conv.is_owned = false;
23831         LDKThirtyTwoBytes val_ref;
23832         CHECK((*env)->GetArrayLength(env, val) == 32);
23833         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
23834         ReplyChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
23835 }
23836
23837 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr) {
23838         LDKReplyChannelRange this_ptr_conv;
23839         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23840         this_ptr_conv.is_owned = false;
23841         int32_t ret_val = ReplyChannelRange_get_first_blocknum(&this_ptr_conv);
23842         return ret_val;
23843 }
23844
23845 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
23846         LDKReplyChannelRange this_ptr_conv;
23847         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23848         this_ptr_conv.is_owned = false;
23849         ReplyChannelRange_set_first_blocknum(&this_ptr_conv, val);
23850 }
23851
23852 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr) {
23853         LDKReplyChannelRange this_ptr_conv;
23854         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23855         this_ptr_conv.is_owned = false;
23856         int32_t ret_val = ReplyChannelRange_get_number_of_blocks(&this_ptr_conv);
23857         return ret_val;
23858 }
23859
23860 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
23861         LDKReplyChannelRange this_ptr_conv;
23862         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23863         this_ptr_conv.is_owned = false;
23864         ReplyChannelRange_set_number_of_blocks(&this_ptr_conv, val);
23865 }
23866
23867 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1sync_1complete(JNIEnv *env, jclass clz, int64_t this_ptr) {
23868         LDKReplyChannelRange this_ptr_conv;
23869         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23870         this_ptr_conv.is_owned = false;
23871         jboolean ret_val = ReplyChannelRange_get_sync_complete(&this_ptr_conv);
23872         return ret_val;
23873 }
23874
23875 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1sync_1complete(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
23876         LDKReplyChannelRange this_ptr_conv;
23877         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23878         this_ptr_conv.is_owned = false;
23879         ReplyChannelRange_set_sync_complete(&this_ptr_conv, val);
23880 }
23881
23882 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
23883         LDKReplyChannelRange this_ptr_conv;
23884         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23885         this_ptr_conv.is_owned = false;
23886         LDKCVec_u64Z val_constr;
23887         val_constr.datalen = (*env)->GetArrayLength(env, val);
23888         if (val_constr.datalen > 0)
23889                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
23890         else
23891                 val_constr.data = NULL;
23892         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
23893         for (size_t g = 0; g < val_constr.datalen; g++) {
23894                 int64_t val_conv_6 = val_vals[g];
23895                 val_constr.data[g] = val_conv_6;
23896         }
23897         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
23898         ReplyChannelRange_set_short_channel_ids(&this_ptr_conv, val_constr);
23899 }
23900
23901 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) {
23902         LDKThirtyTwoBytes chain_hash_arg_ref;
23903         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
23904         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
23905         LDKCVec_u64Z short_channel_ids_arg_constr;
23906         short_channel_ids_arg_constr.datalen = (*env)->GetArrayLength(env, short_channel_ids_arg);
23907         if (short_channel_ids_arg_constr.datalen > 0)
23908                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
23909         else
23910                 short_channel_ids_arg_constr.data = NULL;
23911         int64_t* short_channel_ids_arg_vals = (*env)->GetLongArrayElements (env, short_channel_ids_arg, NULL);
23912         for (size_t g = 0; g < short_channel_ids_arg_constr.datalen; g++) {
23913                 int64_t short_channel_ids_arg_conv_6 = short_channel_ids_arg_vals[g];
23914                 short_channel_ids_arg_constr.data[g] = short_channel_ids_arg_conv_6;
23915         }
23916         (*env)->ReleaseLongArrayElements(env, short_channel_ids_arg, short_channel_ids_arg_vals, 0);
23917         LDKReplyChannelRange ret_var = ReplyChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg, sync_complete_arg, short_channel_ids_arg_constr);
23918         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23919         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23920         uint64_t ret_ref = (uint64_t)ret_var.inner;
23921         if (ret_var.is_owned) {
23922                 ret_ref |= 1;
23923         }
23924         return ret_ref;
23925 }
23926
23927 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23928         LDKReplyChannelRange orig_conv;
23929         orig_conv.inner = (void*)(orig & (~1));
23930         orig_conv.is_owned = false;
23931         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(&orig_conv);
23932         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23933         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23934         uint64_t ret_ref = (uint64_t)ret_var.inner;
23935         if (ret_var.is_owned) {
23936                 ret_ref |= 1;
23937         }
23938         return ret_ref;
23939 }
23940
23941 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23942         LDKQueryShortChannelIds this_obj_conv;
23943         this_obj_conv.inner = (void*)(this_obj & (~1));
23944         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23945         QueryShortChannelIds_free(this_obj_conv);
23946 }
23947
23948 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
23949         LDKQueryShortChannelIds this_ptr_conv;
23950         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23951         this_ptr_conv.is_owned = false;
23952         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
23953         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *QueryShortChannelIds_get_chain_hash(&this_ptr_conv));
23954         return ret_arr;
23955 }
23956
23957 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
23958         LDKQueryShortChannelIds this_ptr_conv;
23959         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23960         this_ptr_conv.is_owned = false;
23961         LDKThirtyTwoBytes val_ref;
23962         CHECK((*env)->GetArrayLength(env, val) == 32);
23963         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
23964         QueryShortChannelIds_set_chain_hash(&this_ptr_conv, val_ref);
23965 }
23966
23967 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1set_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
23968         LDKQueryShortChannelIds this_ptr_conv;
23969         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23970         this_ptr_conv.is_owned = false;
23971         LDKCVec_u64Z val_constr;
23972         val_constr.datalen = (*env)->GetArrayLength(env, val);
23973         if (val_constr.datalen > 0)
23974                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
23975         else
23976                 val_constr.data = NULL;
23977         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
23978         for (size_t g = 0; g < val_constr.datalen; g++) {
23979                 int64_t val_conv_6 = val_vals[g];
23980                 val_constr.data[g] = val_conv_6;
23981         }
23982         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
23983         QueryShortChannelIds_set_short_channel_ids(&this_ptr_conv, val_constr);
23984 }
23985
23986 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) {
23987         LDKThirtyTwoBytes chain_hash_arg_ref;
23988         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
23989         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
23990         LDKCVec_u64Z short_channel_ids_arg_constr;
23991         short_channel_ids_arg_constr.datalen = (*env)->GetArrayLength(env, short_channel_ids_arg);
23992         if (short_channel_ids_arg_constr.datalen > 0)
23993                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
23994         else
23995                 short_channel_ids_arg_constr.data = NULL;
23996         int64_t* short_channel_ids_arg_vals = (*env)->GetLongArrayElements (env, short_channel_ids_arg, NULL);
23997         for (size_t g = 0; g < short_channel_ids_arg_constr.datalen; g++) {
23998                 int64_t short_channel_ids_arg_conv_6 = short_channel_ids_arg_vals[g];
23999                 short_channel_ids_arg_constr.data[g] = short_channel_ids_arg_conv_6;
24000         }
24001         (*env)->ReleaseLongArrayElements(env, short_channel_ids_arg, short_channel_ids_arg_vals, 0);
24002         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_new(chain_hash_arg_ref, short_channel_ids_arg_constr);
24003         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24004         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24005         uint64_t ret_ref = (uint64_t)ret_var.inner;
24006         if (ret_var.is_owned) {
24007                 ret_ref |= 1;
24008         }
24009         return ret_ref;
24010 }
24011
24012 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24013         LDKQueryShortChannelIds orig_conv;
24014         orig_conv.inner = (void*)(orig & (~1));
24015         orig_conv.is_owned = false;
24016         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(&orig_conv);
24017         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24018         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24019         uint64_t ret_ref = (uint64_t)ret_var.inner;
24020         if (ret_var.is_owned) {
24021                 ret_ref |= 1;
24022         }
24023         return ret_ref;
24024 }
24025
24026 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24027         LDKReplyShortChannelIdsEnd this_obj_conv;
24028         this_obj_conv.inner = (void*)(this_obj & (~1));
24029         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24030         ReplyShortChannelIdsEnd_free(this_obj_conv);
24031 }
24032
24033 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
24034         LDKReplyShortChannelIdsEnd this_ptr_conv;
24035         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24036         this_ptr_conv.is_owned = false;
24037         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
24038         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ReplyShortChannelIdsEnd_get_chain_hash(&this_ptr_conv));
24039         return ret_arr;
24040 }
24041
24042 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
24043         LDKReplyShortChannelIdsEnd this_ptr_conv;
24044         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24045         this_ptr_conv.is_owned = false;
24046         LDKThirtyTwoBytes val_ref;
24047         CHECK((*env)->GetArrayLength(env, val) == 32);
24048         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
24049         ReplyShortChannelIdsEnd_set_chain_hash(&this_ptr_conv, val_ref);
24050 }
24051
24052 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1get_1full_1information(JNIEnv *env, jclass clz, int64_t this_ptr) {
24053         LDKReplyShortChannelIdsEnd this_ptr_conv;
24054         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24055         this_ptr_conv.is_owned = false;
24056         jboolean ret_val = ReplyShortChannelIdsEnd_get_full_information(&this_ptr_conv);
24057         return ret_val;
24058 }
24059
24060 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1set_1full_1information(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
24061         LDKReplyShortChannelIdsEnd this_ptr_conv;
24062         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24063         this_ptr_conv.is_owned = false;
24064         ReplyShortChannelIdsEnd_set_full_information(&this_ptr_conv, val);
24065 }
24066
24067 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1new(JNIEnv *env, jclass clz, int8_tArray chain_hash_arg, jboolean full_information_arg) {
24068         LDKThirtyTwoBytes chain_hash_arg_ref;
24069         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
24070         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
24071         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_new(chain_hash_arg_ref, full_information_arg);
24072         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24073         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24074         uint64_t ret_ref = (uint64_t)ret_var.inner;
24075         if (ret_var.is_owned) {
24076                 ret_ref |= 1;
24077         }
24078         return ret_ref;
24079 }
24080
24081 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24082         LDKReplyShortChannelIdsEnd orig_conv;
24083         orig_conv.inner = (void*)(orig & (~1));
24084         orig_conv.is_owned = false;
24085         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(&orig_conv);
24086         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24087         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24088         uint64_t ret_ref = (uint64_t)ret_var.inner;
24089         if (ret_var.is_owned) {
24090                 ret_ref |= 1;
24091         }
24092         return ret_ref;
24093 }
24094
24095 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24096         LDKGossipTimestampFilter this_obj_conv;
24097         this_obj_conv.inner = (void*)(this_obj & (~1));
24098         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24099         GossipTimestampFilter_free(this_obj_conv);
24100 }
24101
24102 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
24103         LDKGossipTimestampFilter this_ptr_conv;
24104         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24105         this_ptr_conv.is_owned = false;
24106         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
24107         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *GossipTimestampFilter_get_chain_hash(&this_ptr_conv));
24108         return ret_arr;
24109 }
24110
24111 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
24112         LDKGossipTimestampFilter this_ptr_conv;
24113         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24114         this_ptr_conv.is_owned = false;
24115         LDKThirtyTwoBytes val_ref;
24116         CHECK((*env)->GetArrayLength(env, val) == 32);
24117         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
24118         GossipTimestampFilter_set_chain_hash(&this_ptr_conv, val_ref);
24119 }
24120
24121 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1first_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
24122         LDKGossipTimestampFilter this_ptr_conv;
24123         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24124         this_ptr_conv.is_owned = false;
24125         int32_t ret_val = GossipTimestampFilter_get_first_timestamp(&this_ptr_conv);
24126         return ret_val;
24127 }
24128
24129 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1first_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
24130         LDKGossipTimestampFilter this_ptr_conv;
24131         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24132         this_ptr_conv.is_owned = false;
24133         GossipTimestampFilter_set_first_timestamp(&this_ptr_conv, val);
24134 }
24135
24136 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1timestamp_1range(JNIEnv *env, jclass clz, int64_t this_ptr) {
24137         LDKGossipTimestampFilter this_ptr_conv;
24138         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24139         this_ptr_conv.is_owned = false;
24140         int32_t ret_val = GossipTimestampFilter_get_timestamp_range(&this_ptr_conv);
24141         return ret_val;
24142 }
24143
24144 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1timestamp_1range(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
24145         LDKGossipTimestampFilter this_ptr_conv;
24146         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24147         this_ptr_conv.is_owned = false;
24148         GossipTimestampFilter_set_timestamp_range(&this_ptr_conv, val);
24149 }
24150
24151 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) {
24152         LDKThirtyTwoBytes chain_hash_arg_ref;
24153         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
24154         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
24155         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_new(chain_hash_arg_ref, first_timestamp_arg, timestamp_range_arg);
24156         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24157         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24158         uint64_t ret_ref = (uint64_t)ret_var.inner;
24159         if (ret_var.is_owned) {
24160                 ret_ref |= 1;
24161         }
24162         return ret_ref;
24163 }
24164
24165 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24166         LDKGossipTimestampFilter orig_conv;
24167         orig_conv.inner = (void*)(orig & (~1));
24168         orig_conv.is_owned = false;
24169         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(&orig_conv);
24170         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24171         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24172         uint64_t ret_ref = (uint64_t)ret_var.inner;
24173         if (ret_var.is_owned) {
24174                 ret_ref |= 1;
24175         }
24176         return ret_ref;
24177 }
24178
24179 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorAction_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
24180         if ((this_ptr & 1) != 0) return;
24181         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
24182         CHECK_ACCESS(this_ptr_ptr);
24183         LDKErrorAction this_ptr_conv = *(LDKErrorAction*)(this_ptr_ptr);
24184         FREE((void*)this_ptr);
24185         ErrorAction_free(this_ptr_conv);
24186 }
24187
24188 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24189         LDKErrorAction* orig_conv = (LDKErrorAction*)orig;
24190         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
24191         *ret_copy = ErrorAction_clone(orig_conv);
24192         uint64_t ret_ref = (uint64_t)ret_copy;
24193         return ret_ref;
24194 }
24195
24196 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1disconnect_1peer(JNIEnv *env, jclass clz, int64_t msg) {
24197         LDKErrorMessage msg_conv;
24198         msg_conv.inner = (void*)(msg & (~1));
24199         msg_conv.is_owned = (msg & 1) || (msg == 0);
24200         msg_conv = ErrorMessage_clone(&msg_conv);
24201         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
24202         *ret_copy = ErrorAction_disconnect_peer(msg_conv);
24203         uint64_t ret_ref = (uint64_t)ret_copy;
24204         return ret_ref;
24205 }
24206
24207 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1ignore_1error(JNIEnv *env, jclass clz) {
24208         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
24209         *ret_copy = ErrorAction_ignore_error();
24210         uint64_t ret_ref = (uint64_t)ret_copy;
24211         return ret_ref;
24212 }
24213
24214 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1ignore_1and_1log(JNIEnv *env, jclass clz, jclass a) {
24215         LDKLevel a_conv = LDKLevel_from_java(env, a);
24216         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
24217         *ret_copy = ErrorAction_ignore_and_log(a_conv);
24218         uint64_t ret_ref = (uint64_t)ret_copy;
24219         return ret_ref;
24220 }
24221
24222 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1send_1error_1message(JNIEnv *env, jclass clz, int64_t msg) {
24223         LDKErrorMessage msg_conv;
24224         msg_conv.inner = (void*)(msg & (~1));
24225         msg_conv.is_owned = (msg & 1) || (msg == 0);
24226         msg_conv = ErrorMessage_clone(&msg_conv);
24227         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
24228         *ret_copy = ErrorAction_send_error_message(msg_conv);
24229         uint64_t ret_ref = (uint64_t)ret_copy;
24230         return ret_ref;
24231 }
24232
24233 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24234         LDKLightningError this_obj_conv;
24235         this_obj_conv.inner = (void*)(this_obj & (~1));
24236         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24237         LightningError_free(this_obj_conv);
24238 }
24239
24240 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_LightningError_1get_1err(JNIEnv *env, jclass clz, int64_t this_ptr) {
24241         LDKLightningError this_ptr_conv;
24242         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24243         this_ptr_conv.is_owned = false;
24244         LDKStr ret_str = LightningError_get_err(&this_ptr_conv);
24245         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
24246         Str_free(ret_str);
24247         return ret_conv;
24248 }
24249
24250 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1set_1err(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
24251         LDKLightningError this_ptr_conv;
24252         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24253         this_ptr_conv.is_owned = false;
24254         LDKStr val_conv = java_to_owned_str(env, val);
24255         LightningError_set_err(&this_ptr_conv, val_conv);
24256 }
24257
24258 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1get_1action(JNIEnv *env, jclass clz, int64_t this_ptr) {
24259         LDKLightningError this_ptr_conv;
24260         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24261         this_ptr_conv.is_owned = false;
24262         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
24263         *ret_copy = LightningError_get_action(&this_ptr_conv);
24264         uint64_t ret_ref = (uint64_t)ret_copy;
24265         return ret_ref;
24266 }
24267
24268 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1set_1action(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24269         LDKLightningError this_ptr_conv;
24270         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24271         this_ptr_conv.is_owned = false;
24272         void* val_ptr = (void*)(((uint64_t)val) & ~1);
24273         CHECK_ACCESS(val_ptr);
24274         LDKErrorAction val_conv = *(LDKErrorAction*)(val_ptr);
24275         val_conv = ErrorAction_clone((LDKErrorAction*)(((uint64_t)val) & ~1));
24276         LightningError_set_action(&this_ptr_conv, val_conv);
24277 }
24278
24279 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1new(JNIEnv *env, jclass clz, jstring err_arg, int64_t action_arg) {
24280         LDKStr err_arg_conv = java_to_owned_str(env, err_arg);
24281         void* action_arg_ptr = (void*)(((uint64_t)action_arg) & ~1);
24282         CHECK_ACCESS(action_arg_ptr);
24283         LDKErrorAction action_arg_conv = *(LDKErrorAction*)(action_arg_ptr);
24284         action_arg_conv = ErrorAction_clone((LDKErrorAction*)(((uint64_t)action_arg) & ~1));
24285         LDKLightningError ret_var = LightningError_new(err_arg_conv, action_arg_conv);
24286         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24287         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24288         uint64_t ret_ref = (uint64_t)ret_var.inner;
24289         if (ret_var.is_owned) {
24290                 ret_ref |= 1;
24291         }
24292         return ret_ref;
24293 }
24294
24295 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24296         LDKLightningError orig_conv;
24297         orig_conv.inner = (void*)(orig & (~1));
24298         orig_conv.is_owned = false;
24299         LDKLightningError ret_var = LightningError_clone(&orig_conv);
24300         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24301         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24302         uint64_t ret_ref = (uint64_t)ret_var.inner;
24303         if (ret_var.is_owned) {
24304                 ret_ref |= 1;
24305         }
24306         return ret_ref;
24307 }
24308
24309 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24310         LDKCommitmentUpdate this_obj_conv;
24311         this_obj_conv.inner = (void*)(this_obj & (~1));
24312         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24313         CommitmentUpdate_free(this_obj_conv);
24314 }
24315
24316 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1add_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
24317         LDKCommitmentUpdate this_ptr_conv;
24318         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24319         this_ptr_conv.is_owned = false;
24320         LDKCVec_UpdateAddHTLCZ ret_var = CommitmentUpdate_get_update_add_htlcs(&this_ptr_conv);
24321         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
24322         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
24323         for (size_t p = 0; p < ret_var.datalen; p++) {
24324                 LDKUpdateAddHTLC ret_conv_15_var = ret_var.data[p];
24325                 CHECK((((uint64_t)ret_conv_15_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24326                 CHECK((((uint64_t)&ret_conv_15_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24327                 uint64_t ret_conv_15_ref = (uint64_t)ret_conv_15_var.inner;
24328                 if (ret_conv_15_var.is_owned) {
24329                         ret_conv_15_ref |= 1;
24330                 }
24331                 ret_arr_ptr[p] = ret_conv_15_ref;
24332         }
24333         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
24334         FREE(ret_var.data);
24335         return ret_arr;
24336 }
24337
24338 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1add_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
24339         LDKCommitmentUpdate this_ptr_conv;
24340         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24341         this_ptr_conv.is_owned = false;
24342         LDKCVec_UpdateAddHTLCZ val_constr;
24343         val_constr.datalen = (*env)->GetArrayLength(env, val);
24344         if (val_constr.datalen > 0)
24345                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
24346         else
24347                 val_constr.data = NULL;
24348         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
24349         for (size_t p = 0; p < val_constr.datalen; p++) {
24350                 int64_t val_conv_15 = val_vals[p];
24351                 LDKUpdateAddHTLC val_conv_15_conv;
24352                 val_conv_15_conv.inner = (void*)(val_conv_15 & (~1));
24353                 val_conv_15_conv.is_owned = (val_conv_15 & 1) || (val_conv_15 == 0);
24354                 val_conv_15_conv = UpdateAddHTLC_clone(&val_conv_15_conv);
24355                 val_constr.data[p] = val_conv_15_conv;
24356         }
24357         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
24358         CommitmentUpdate_set_update_add_htlcs(&this_ptr_conv, val_constr);
24359 }
24360
24361 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fulfill_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
24362         LDKCommitmentUpdate this_ptr_conv;
24363         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24364         this_ptr_conv.is_owned = false;
24365         LDKCVec_UpdateFulfillHTLCZ ret_var = CommitmentUpdate_get_update_fulfill_htlcs(&this_ptr_conv);
24366         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
24367         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
24368         for (size_t t = 0; t < ret_var.datalen; t++) {
24369                 LDKUpdateFulfillHTLC ret_conv_19_var = ret_var.data[t];
24370                 CHECK((((uint64_t)ret_conv_19_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24371                 CHECK((((uint64_t)&ret_conv_19_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24372                 uint64_t ret_conv_19_ref = (uint64_t)ret_conv_19_var.inner;
24373                 if (ret_conv_19_var.is_owned) {
24374                         ret_conv_19_ref |= 1;
24375                 }
24376                 ret_arr_ptr[t] = ret_conv_19_ref;
24377         }
24378         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
24379         FREE(ret_var.data);
24380         return ret_arr;
24381 }
24382
24383 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fulfill_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
24384         LDKCommitmentUpdate this_ptr_conv;
24385         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24386         this_ptr_conv.is_owned = false;
24387         LDKCVec_UpdateFulfillHTLCZ val_constr;
24388         val_constr.datalen = (*env)->GetArrayLength(env, val);
24389         if (val_constr.datalen > 0)
24390                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
24391         else
24392                 val_constr.data = NULL;
24393         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
24394         for (size_t t = 0; t < val_constr.datalen; t++) {
24395                 int64_t val_conv_19 = val_vals[t];
24396                 LDKUpdateFulfillHTLC val_conv_19_conv;
24397                 val_conv_19_conv.inner = (void*)(val_conv_19 & (~1));
24398                 val_conv_19_conv.is_owned = (val_conv_19 & 1) || (val_conv_19 == 0);
24399                 val_conv_19_conv = UpdateFulfillHTLC_clone(&val_conv_19_conv);
24400                 val_constr.data[t] = val_conv_19_conv;
24401         }
24402         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
24403         CommitmentUpdate_set_update_fulfill_htlcs(&this_ptr_conv, val_constr);
24404 }
24405
24406 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fail_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
24407         LDKCommitmentUpdate this_ptr_conv;
24408         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24409         this_ptr_conv.is_owned = false;
24410         LDKCVec_UpdateFailHTLCZ ret_var = CommitmentUpdate_get_update_fail_htlcs(&this_ptr_conv);
24411         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
24412         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
24413         for (size_t q = 0; q < ret_var.datalen; q++) {
24414                 LDKUpdateFailHTLC ret_conv_16_var = ret_var.data[q];
24415                 CHECK((((uint64_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24416                 CHECK((((uint64_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24417                 uint64_t ret_conv_16_ref = (uint64_t)ret_conv_16_var.inner;
24418                 if (ret_conv_16_var.is_owned) {
24419                         ret_conv_16_ref |= 1;
24420                 }
24421                 ret_arr_ptr[q] = ret_conv_16_ref;
24422         }
24423         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
24424         FREE(ret_var.data);
24425         return ret_arr;
24426 }
24427
24428 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fail_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
24429         LDKCommitmentUpdate this_ptr_conv;
24430         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24431         this_ptr_conv.is_owned = false;
24432         LDKCVec_UpdateFailHTLCZ val_constr;
24433         val_constr.datalen = (*env)->GetArrayLength(env, val);
24434         if (val_constr.datalen > 0)
24435                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
24436         else
24437                 val_constr.data = NULL;
24438         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
24439         for (size_t q = 0; q < val_constr.datalen; q++) {
24440                 int64_t val_conv_16 = val_vals[q];
24441                 LDKUpdateFailHTLC val_conv_16_conv;
24442                 val_conv_16_conv.inner = (void*)(val_conv_16 & (~1));
24443                 val_conv_16_conv.is_owned = (val_conv_16 & 1) || (val_conv_16 == 0);
24444                 val_conv_16_conv = UpdateFailHTLC_clone(&val_conv_16_conv);
24445                 val_constr.data[q] = val_conv_16_conv;
24446         }
24447         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
24448         CommitmentUpdate_set_update_fail_htlcs(&this_ptr_conv, val_constr);
24449 }
24450
24451 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fail_1malformed_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
24452         LDKCommitmentUpdate this_ptr_conv;
24453         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24454         this_ptr_conv.is_owned = false;
24455         LDKCVec_UpdateFailMalformedHTLCZ ret_var = CommitmentUpdate_get_update_fail_malformed_htlcs(&this_ptr_conv);
24456         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
24457         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
24458         for (size_t z = 0; z < ret_var.datalen; z++) {
24459                 LDKUpdateFailMalformedHTLC ret_conv_25_var = ret_var.data[z];
24460                 CHECK((((uint64_t)ret_conv_25_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24461                 CHECK((((uint64_t)&ret_conv_25_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24462                 uint64_t ret_conv_25_ref = (uint64_t)ret_conv_25_var.inner;
24463                 if (ret_conv_25_var.is_owned) {
24464                         ret_conv_25_ref |= 1;
24465                 }
24466                 ret_arr_ptr[z] = ret_conv_25_ref;
24467         }
24468         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
24469         FREE(ret_var.data);
24470         return ret_arr;
24471 }
24472
24473 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) {
24474         LDKCommitmentUpdate this_ptr_conv;
24475         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24476         this_ptr_conv.is_owned = false;
24477         LDKCVec_UpdateFailMalformedHTLCZ val_constr;
24478         val_constr.datalen = (*env)->GetArrayLength(env, val);
24479         if (val_constr.datalen > 0)
24480                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
24481         else
24482                 val_constr.data = NULL;
24483         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
24484         for (size_t z = 0; z < val_constr.datalen; z++) {
24485                 int64_t val_conv_25 = val_vals[z];
24486                 LDKUpdateFailMalformedHTLC val_conv_25_conv;
24487                 val_conv_25_conv.inner = (void*)(val_conv_25 & (~1));
24488                 val_conv_25_conv.is_owned = (val_conv_25 & 1) || (val_conv_25 == 0);
24489                 val_conv_25_conv = UpdateFailMalformedHTLC_clone(&val_conv_25_conv);
24490                 val_constr.data[z] = val_conv_25_conv;
24491         }
24492         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
24493         CommitmentUpdate_set_update_fail_malformed_htlcs(&this_ptr_conv, val_constr);
24494 }
24495
24496 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fee(JNIEnv *env, jclass clz, int64_t this_ptr) {
24497         LDKCommitmentUpdate this_ptr_conv;
24498         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24499         this_ptr_conv.is_owned = false;
24500         LDKUpdateFee ret_var = CommitmentUpdate_get_update_fee(&this_ptr_conv);
24501         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24502         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24503         uint64_t ret_ref = (uint64_t)ret_var.inner;
24504         if (ret_var.is_owned) {
24505                 ret_ref |= 1;
24506         }
24507         return ret_ref;
24508 }
24509
24510 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fee(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24511         LDKCommitmentUpdate this_ptr_conv;
24512         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24513         this_ptr_conv.is_owned = false;
24514         LDKUpdateFee val_conv;
24515         val_conv.inner = (void*)(val & (~1));
24516         val_conv.is_owned = (val & 1) || (val == 0);
24517         val_conv = UpdateFee_clone(&val_conv);
24518         CommitmentUpdate_set_update_fee(&this_ptr_conv, val_conv);
24519 }
24520
24521 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1commitment_1signed(JNIEnv *env, jclass clz, int64_t this_ptr) {
24522         LDKCommitmentUpdate this_ptr_conv;
24523         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24524         this_ptr_conv.is_owned = false;
24525         LDKCommitmentSigned ret_var = CommitmentUpdate_get_commitment_signed(&this_ptr_conv);
24526         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24527         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24528         uint64_t ret_ref = (uint64_t)ret_var.inner;
24529         if (ret_var.is_owned) {
24530                 ret_ref |= 1;
24531         }
24532         return ret_ref;
24533 }
24534
24535 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1commitment_1signed(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24536         LDKCommitmentUpdate this_ptr_conv;
24537         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24538         this_ptr_conv.is_owned = false;
24539         LDKCommitmentSigned val_conv;
24540         val_conv.inner = (void*)(val & (~1));
24541         val_conv.is_owned = (val & 1) || (val == 0);
24542         val_conv = CommitmentSigned_clone(&val_conv);
24543         CommitmentUpdate_set_commitment_signed(&this_ptr_conv, val_conv);
24544 }
24545
24546 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) {
24547         LDKCVec_UpdateAddHTLCZ update_add_htlcs_arg_constr;
24548         update_add_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_add_htlcs_arg);
24549         if (update_add_htlcs_arg_constr.datalen > 0)
24550                 update_add_htlcs_arg_constr.data = MALLOC(update_add_htlcs_arg_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
24551         else
24552                 update_add_htlcs_arg_constr.data = NULL;
24553         int64_t* update_add_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_add_htlcs_arg, NULL);
24554         for (size_t p = 0; p < update_add_htlcs_arg_constr.datalen; p++) {
24555                 int64_t update_add_htlcs_arg_conv_15 = update_add_htlcs_arg_vals[p];
24556                 LDKUpdateAddHTLC update_add_htlcs_arg_conv_15_conv;
24557                 update_add_htlcs_arg_conv_15_conv.inner = (void*)(update_add_htlcs_arg_conv_15 & (~1));
24558                 update_add_htlcs_arg_conv_15_conv.is_owned = (update_add_htlcs_arg_conv_15 & 1) || (update_add_htlcs_arg_conv_15 == 0);
24559                 update_add_htlcs_arg_conv_15_conv = UpdateAddHTLC_clone(&update_add_htlcs_arg_conv_15_conv);
24560                 update_add_htlcs_arg_constr.data[p] = update_add_htlcs_arg_conv_15_conv;
24561         }
24562         (*env)->ReleaseLongArrayElements(env, update_add_htlcs_arg, update_add_htlcs_arg_vals, 0);
24563         LDKCVec_UpdateFulfillHTLCZ update_fulfill_htlcs_arg_constr;
24564         update_fulfill_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fulfill_htlcs_arg);
24565         if (update_fulfill_htlcs_arg_constr.datalen > 0)
24566                 update_fulfill_htlcs_arg_constr.data = MALLOC(update_fulfill_htlcs_arg_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
24567         else
24568                 update_fulfill_htlcs_arg_constr.data = NULL;
24569         int64_t* update_fulfill_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fulfill_htlcs_arg, NULL);
24570         for (size_t t = 0; t < update_fulfill_htlcs_arg_constr.datalen; t++) {
24571                 int64_t update_fulfill_htlcs_arg_conv_19 = update_fulfill_htlcs_arg_vals[t];
24572                 LDKUpdateFulfillHTLC update_fulfill_htlcs_arg_conv_19_conv;
24573                 update_fulfill_htlcs_arg_conv_19_conv.inner = (void*)(update_fulfill_htlcs_arg_conv_19 & (~1));
24574                 update_fulfill_htlcs_arg_conv_19_conv.is_owned = (update_fulfill_htlcs_arg_conv_19 & 1) || (update_fulfill_htlcs_arg_conv_19 == 0);
24575                 update_fulfill_htlcs_arg_conv_19_conv = UpdateFulfillHTLC_clone(&update_fulfill_htlcs_arg_conv_19_conv);
24576                 update_fulfill_htlcs_arg_constr.data[t] = update_fulfill_htlcs_arg_conv_19_conv;
24577         }
24578         (*env)->ReleaseLongArrayElements(env, update_fulfill_htlcs_arg, update_fulfill_htlcs_arg_vals, 0);
24579         LDKCVec_UpdateFailHTLCZ update_fail_htlcs_arg_constr;
24580         update_fail_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fail_htlcs_arg);
24581         if (update_fail_htlcs_arg_constr.datalen > 0)
24582                 update_fail_htlcs_arg_constr.data = MALLOC(update_fail_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
24583         else
24584                 update_fail_htlcs_arg_constr.data = NULL;
24585         int64_t* update_fail_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fail_htlcs_arg, NULL);
24586         for (size_t q = 0; q < update_fail_htlcs_arg_constr.datalen; q++) {
24587                 int64_t update_fail_htlcs_arg_conv_16 = update_fail_htlcs_arg_vals[q];
24588                 LDKUpdateFailHTLC update_fail_htlcs_arg_conv_16_conv;
24589                 update_fail_htlcs_arg_conv_16_conv.inner = (void*)(update_fail_htlcs_arg_conv_16 & (~1));
24590                 update_fail_htlcs_arg_conv_16_conv.is_owned = (update_fail_htlcs_arg_conv_16 & 1) || (update_fail_htlcs_arg_conv_16 == 0);
24591                 update_fail_htlcs_arg_conv_16_conv = UpdateFailHTLC_clone(&update_fail_htlcs_arg_conv_16_conv);
24592                 update_fail_htlcs_arg_constr.data[q] = update_fail_htlcs_arg_conv_16_conv;
24593         }
24594         (*env)->ReleaseLongArrayElements(env, update_fail_htlcs_arg, update_fail_htlcs_arg_vals, 0);
24595         LDKCVec_UpdateFailMalformedHTLCZ update_fail_malformed_htlcs_arg_constr;
24596         update_fail_malformed_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fail_malformed_htlcs_arg);
24597         if (update_fail_malformed_htlcs_arg_constr.datalen > 0)
24598                 update_fail_malformed_htlcs_arg_constr.data = MALLOC(update_fail_malformed_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
24599         else
24600                 update_fail_malformed_htlcs_arg_constr.data = NULL;
24601         int64_t* update_fail_malformed_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fail_malformed_htlcs_arg, NULL);
24602         for (size_t z = 0; z < update_fail_malformed_htlcs_arg_constr.datalen; z++) {
24603                 int64_t update_fail_malformed_htlcs_arg_conv_25 = update_fail_malformed_htlcs_arg_vals[z];
24604                 LDKUpdateFailMalformedHTLC update_fail_malformed_htlcs_arg_conv_25_conv;
24605                 update_fail_malformed_htlcs_arg_conv_25_conv.inner = (void*)(update_fail_malformed_htlcs_arg_conv_25 & (~1));
24606                 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);
24607                 update_fail_malformed_htlcs_arg_conv_25_conv = UpdateFailMalformedHTLC_clone(&update_fail_malformed_htlcs_arg_conv_25_conv);
24608                 update_fail_malformed_htlcs_arg_constr.data[z] = update_fail_malformed_htlcs_arg_conv_25_conv;
24609         }
24610         (*env)->ReleaseLongArrayElements(env, update_fail_malformed_htlcs_arg, update_fail_malformed_htlcs_arg_vals, 0);
24611         LDKUpdateFee update_fee_arg_conv;
24612         update_fee_arg_conv.inner = (void*)(update_fee_arg & (~1));
24613         update_fee_arg_conv.is_owned = (update_fee_arg & 1) || (update_fee_arg == 0);
24614         update_fee_arg_conv = UpdateFee_clone(&update_fee_arg_conv);
24615         LDKCommitmentSigned commitment_signed_arg_conv;
24616         commitment_signed_arg_conv.inner = (void*)(commitment_signed_arg & (~1));
24617         commitment_signed_arg_conv.is_owned = (commitment_signed_arg & 1) || (commitment_signed_arg == 0);
24618         commitment_signed_arg_conv = CommitmentSigned_clone(&commitment_signed_arg_conv);
24619         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);
24620         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24621         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24622         uint64_t ret_ref = (uint64_t)ret_var.inner;
24623         if (ret_var.is_owned) {
24624                 ret_ref |= 1;
24625         }
24626         return ret_ref;
24627 }
24628
24629 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24630         LDKCommitmentUpdate orig_conv;
24631         orig_conv.inner = (void*)(orig & (~1));
24632         orig_conv.is_owned = false;
24633         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(&orig_conv);
24634         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24635         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24636         uint64_t ret_ref = (uint64_t)ret_var.inner;
24637         if (ret_var.is_owned) {
24638                 ret_ref |= 1;
24639         }
24640         return ret_ref;
24641 }
24642
24643 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
24644         if ((this_ptr & 1) != 0) return;
24645         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
24646         CHECK_ACCESS(this_ptr_ptr);
24647         LDKChannelMessageHandler this_ptr_conv = *(LDKChannelMessageHandler*)(this_ptr_ptr);
24648         FREE((void*)this_ptr);
24649         ChannelMessageHandler_free(this_ptr_conv);
24650 }
24651
24652 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
24653         if ((this_ptr & 1) != 0) return;
24654         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
24655         CHECK_ACCESS(this_ptr_ptr);
24656         LDKRoutingMessageHandler this_ptr_conv = *(LDKRoutingMessageHandler*)(this_ptr_ptr);
24657         FREE((void*)this_ptr);
24658         RoutingMessageHandler_free(this_ptr_conv);
24659 }
24660
24661 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1write(JNIEnv *env, jclass clz, int64_t obj) {
24662         LDKAcceptChannel obj_conv;
24663         obj_conv.inner = (void*)(obj & (~1));
24664         obj_conv.is_owned = false;
24665         LDKCVec_u8Z ret_var = AcceptChannel_write(&obj_conv);
24666         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24667         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24668         CVec_u8Z_free(ret_var);
24669         return ret_arr;
24670 }
24671
24672 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24673         LDKu8slice ser_ref;
24674         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24675         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24676         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
24677         *ret_conv = AcceptChannel_read(ser_ref);
24678         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24679         return (uint64_t)ret_conv;
24680 }
24681
24682 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
24683         LDKAnnouncementSignatures obj_conv;
24684         obj_conv.inner = (void*)(obj & (~1));
24685         obj_conv.is_owned = false;
24686         LDKCVec_u8Z ret_var = AnnouncementSignatures_write(&obj_conv);
24687         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24688         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24689         CVec_u8Z_free(ret_var);
24690         return ret_arr;
24691 }
24692
24693 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24694         LDKu8slice ser_ref;
24695         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24696         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24697         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
24698         *ret_conv = AnnouncementSignatures_read(ser_ref);
24699         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24700         return (uint64_t)ret_conv;
24701 }
24702
24703 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1write(JNIEnv *env, jclass clz, int64_t obj) {
24704         LDKChannelReestablish obj_conv;
24705         obj_conv.inner = (void*)(obj & (~1));
24706         obj_conv.is_owned = false;
24707         LDKCVec_u8Z ret_var = ChannelReestablish_write(&obj_conv);
24708         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24709         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24710         CVec_u8Z_free(ret_var);
24711         return ret_arr;
24712 }
24713
24714 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24715         LDKu8slice ser_ref;
24716         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24717         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24718         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
24719         *ret_conv = ChannelReestablish_read(ser_ref);
24720         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24721         return (uint64_t)ret_conv;
24722 }
24723
24724 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
24725         LDKClosingSigned obj_conv;
24726         obj_conv.inner = (void*)(obj & (~1));
24727         obj_conv.is_owned = false;
24728         LDKCVec_u8Z ret_var = ClosingSigned_write(&obj_conv);
24729         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24730         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24731         CVec_u8Z_free(ret_var);
24732         return ret_arr;
24733 }
24734
24735 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24736         LDKu8slice ser_ref;
24737         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24738         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24739         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
24740         *ret_conv = ClosingSigned_read(ser_ref);
24741         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24742         return (uint64_t)ret_conv;
24743 }
24744
24745 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
24746         LDKClosingSignedFeeRange obj_conv;
24747         obj_conv.inner = (void*)(obj & (~1));
24748         obj_conv.is_owned = false;
24749         LDKCVec_u8Z ret_var = ClosingSignedFeeRange_write(&obj_conv);
24750         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24751         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24752         CVec_u8Z_free(ret_var);
24753         return ret_arr;
24754 }
24755
24756 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24757         LDKu8slice ser_ref;
24758         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24759         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24760         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
24761         *ret_conv = ClosingSignedFeeRange_read(ser_ref);
24762         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24763         return (uint64_t)ret_conv;
24764 }
24765
24766 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
24767         LDKCommitmentSigned obj_conv;
24768         obj_conv.inner = (void*)(obj & (~1));
24769         obj_conv.is_owned = false;
24770         LDKCVec_u8Z ret_var = CommitmentSigned_write(&obj_conv);
24771         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24772         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24773         CVec_u8Z_free(ret_var);
24774         return ret_arr;
24775 }
24776
24777 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24778         LDKu8slice ser_ref;
24779         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24780         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24781         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
24782         *ret_conv = CommitmentSigned_read(ser_ref);
24783         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24784         return (uint64_t)ret_conv;
24785 }
24786
24787 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1write(JNIEnv *env, jclass clz, int64_t obj) {
24788         LDKFundingCreated obj_conv;
24789         obj_conv.inner = (void*)(obj & (~1));
24790         obj_conv.is_owned = false;
24791         LDKCVec_u8Z ret_var = FundingCreated_write(&obj_conv);
24792         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24793         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24794         CVec_u8Z_free(ret_var);
24795         return ret_arr;
24796 }
24797
24798 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24799         LDKu8slice ser_ref;
24800         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24801         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24802         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
24803         *ret_conv = FundingCreated_read(ser_ref);
24804         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24805         return (uint64_t)ret_conv;
24806 }
24807
24808 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
24809         LDKFundingSigned obj_conv;
24810         obj_conv.inner = (void*)(obj & (~1));
24811         obj_conv.is_owned = false;
24812         LDKCVec_u8Z ret_var = FundingSigned_write(&obj_conv);
24813         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24814         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24815         CVec_u8Z_free(ret_var);
24816         return ret_arr;
24817 }
24818
24819 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24820         LDKu8slice ser_ref;
24821         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24822         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24823         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
24824         *ret_conv = FundingSigned_read(ser_ref);
24825         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24826         return (uint64_t)ret_conv;
24827 }
24828
24829 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingLocked_1write(JNIEnv *env, jclass clz, int64_t obj) {
24830         LDKFundingLocked obj_conv;
24831         obj_conv.inner = (void*)(obj & (~1));
24832         obj_conv.is_owned = false;
24833         LDKCVec_u8Z ret_var = FundingLocked_write(&obj_conv);
24834         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24835         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24836         CVec_u8Z_free(ret_var);
24837         return ret_arr;
24838 }
24839
24840 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingLocked_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24841         LDKu8slice ser_ref;
24842         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24843         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24844         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
24845         *ret_conv = FundingLocked_read(ser_ref);
24846         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24847         return (uint64_t)ret_conv;
24848 }
24849
24850 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Init_1write(JNIEnv *env, jclass clz, int64_t obj) {
24851         LDKInit obj_conv;
24852         obj_conv.inner = (void*)(obj & (~1));
24853         obj_conv.is_owned = false;
24854         LDKCVec_u8Z ret_var = Init_write(&obj_conv);
24855         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24856         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24857         CVec_u8Z_free(ret_var);
24858         return ret_arr;
24859 }
24860
24861 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24862         LDKu8slice ser_ref;
24863         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24864         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24865         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
24866         *ret_conv = Init_read(ser_ref);
24867         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24868         return (uint64_t)ret_conv;
24869 }
24870
24871 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1write(JNIEnv *env, jclass clz, int64_t obj) {
24872         LDKOpenChannel obj_conv;
24873         obj_conv.inner = (void*)(obj & (~1));
24874         obj_conv.is_owned = false;
24875         LDKCVec_u8Z ret_var = OpenChannel_write(&obj_conv);
24876         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24877         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24878         CVec_u8Z_free(ret_var);
24879         return ret_arr;
24880 }
24881
24882 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24883         LDKu8slice ser_ref;
24884         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24885         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24886         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
24887         *ret_conv = OpenChannel_read(ser_ref);
24888         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24889         return (uint64_t)ret_conv;
24890 }
24891
24892 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1write(JNIEnv *env, jclass clz, int64_t obj) {
24893         LDKRevokeAndACK obj_conv;
24894         obj_conv.inner = (void*)(obj & (~1));
24895         obj_conv.is_owned = false;
24896         LDKCVec_u8Z ret_var = RevokeAndACK_write(&obj_conv);
24897         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24898         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24899         CVec_u8Z_free(ret_var);
24900         return ret_arr;
24901 }
24902
24903 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24904         LDKu8slice ser_ref;
24905         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24906         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24907         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
24908         *ret_conv = RevokeAndACK_read(ser_ref);
24909         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24910         return (uint64_t)ret_conv;
24911 }
24912
24913 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1write(JNIEnv *env, jclass clz, int64_t obj) {
24914         LDKShutdown obj_conv;
24915         obj_conv.inner = (void*)(obj & (~1));
24916         obj_conv.is_owned = false;
24917         LDKCVec_u8Z ret_var = Shutdown_write(&obj_conv);
24918         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24919         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24920         CVec_u8Z_free(ret_var);
24921         return ret_arr;
24922 }
24923
24924 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24925         LDKu8slice ser_ref;
24926         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24927         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24928         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
24929         *ret_conv = Shutdown_read(ser_ref);
24930         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24931         return (uint64_t)ret_conv;
24932 }
24933
24934 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
24935         LDKUpdateFailHTLC obj_conv;
24936         obj_conv.inner = (void*)(obj & (~1));
24937         obj_conv.is_owned = false;
24938         LDKCVec_u8Z ret_var = UpdateFailHTLC_write(&obj_conv);
24939         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24940         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24941         CVec_u8Z_free(ret_var);
24942         return ret_arr;
24943 }
24944
24945 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24946         LDKu8slice ser_ref;
24947         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24948         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24949         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
24950         *ret_conv = UpdateFailHTLC_read(ser_ref);
24951         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24952         return (uint64_t)ret_conv;
24953 }
24954
24955 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
24956         LDKUpdateFailMalformedHTLC obj_conv;
24957         obj_conv.inner = (void*)(obj & (~1));
24958         obj_conv.is_owned = false;
24959         LDKCVec_u8Z ret_var = UpdateFailMalformedHTLC_write(&obj_conv);
24960         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24961         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24962         CVec_u8Z_free(ret_var);
24963         return ret_arr;
24964 }
24965
24966 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24967         LDKu8slice ser_ref;
24968         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24969         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24970         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
24971         *ret_conv = UpdateFailMalformedHTLC_read(ser_ref);
24972         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24973         return (uint64_t)ret_conv;
24974 }
24975
24976 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFee_1write(JNIEnv *env, jclass clz, int64_t obj) {
24977         LDKUpdateFee obj_conv;
24978         obj_conv.inner = (void*)(obj & (~1));
24979         obj_conv.is_owned = false;
24980         LDKCVec_u8Z ret_var = UpdateFee_write(&obj_conv);
24981         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24982         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24983         CVec_u8Z_free(ret_var);
24984         return ret_arr;
24985 }
24986
24987 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24988         LDKu8slice ser_ref;
24989         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24990         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24991         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
24992         *ret_conv = UpdateFee_read(ser_ref);
24993         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24994         return (uint64_t)ret_conv;
24995 }
24996
24997 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
24998         LDKUpdateFulfillHTLC obj_conv;
24999         obj_conv.inner = (void*)(obj & (~1));
25000         obj_conv.is_owned = false;
25001         LDKCVec_u8Z ret_var = UpdateFulfillHTLC_write(&obj_conv);
25002         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
25003         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
25004         CVec_u8Z_free(ret_var);
25005         return ret_arr;
25006 }
25007
25008 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
25009         LDKu8slice ser_ref;
25010         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
25011         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
25012         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
25013         *ret_conv = UpdateFulfillHTLC_read(ser_ref);
25014         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
25015         return (uint64_t)ret_conv;
25016 }
25017
25018 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
25019         LDKUpdateAddHTLC obj_conv;
25020         obj_conv.inner = (void*)(obj & (~1));
25021         obj_conv.is_owned = false;
25022         LDKCVec_u8Z ret_var = UpdateAddHTLC_write(&obj_conv);
25023         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
25024         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
25025         CVec_u8Z_free(ret_var);
25026         return ret_arr;
25027 }
25028
25029 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
25030         LDKu8slice ser_ref;
25031         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
25032         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
25033         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
25034         *ret_conv = UpdateAddHTLC_read(ser_ref);
25035         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
25036         return (uint64_t)ret_conv;
25037 }
25038
25039 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Ping_1write(JNIEnv *env, jclass clz, int64_t obj) {
25040         LDKPing obj_conv;
25041         obj_conv.inner = (void*)(obj & (~1));
25042         obj_conv.is_owned = false;
25043         LDKCVec_u8Z ret_var = Ping_write(&obj_conv);
25044         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
25045         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
25046         CVec_u8Z_free(ret_var);
25047         return ret_arr;
25048 }
25049
25050 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
25051         LDKu8slice ser_ref;
25052         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
25053         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
25054         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
25055         *ret_conv = Ping_read(ser_ref);
25056         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
25057         return (uint64_t)ret_conv;
25058 }
25059
25060 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Pong_1write(JNIEnv *env, jclass clz, int64_t obj) {
25061         LDKPong obj_conv;
25062         obj_conv.inner = (void*)(obj & (~1));
25063         obj_conv.is_owned = false;
25064         LDKCVec_u8Z ret_var = Pong_write(&obj_conv);
25065         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
25066         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
25067         CVec_u8Z_free(ret_var);
25068         return ret_arr;
25069 }
25070
25071 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
25072         LDKu8slice ser_ref;
25073         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
25074         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
25075         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
25076         *ret_conv = Pong_read(ser_ref);
25077         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
25078         return (uint64_t)ret_conv;
25079 }
25080
25081 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
25082         LDKUnsignedChannelAnnouncement obj_conv;
25083         obj_conv.inner = (void*)(obj & (~1));
25084         obj_conv.is_owned = false;
25085         LDKCVec_u8Z ret_var = UnsignedChannelAnnouncement_write(&obj_conv);
25086         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
25087         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
25088         CVec_u8Z_free(ret_var);
25089         return ret_arr;
25090 }
25091
25092 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
25093         LDKu8slice ser_ref;
25094         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
25095         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
25096         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
25097         *ret_conv = UnsignedChannelAnnouncement_read(ser_ref);
25098         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
25099         return (uint64_t)ret_conv;
25100 }
25101
25102 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
25103         LDKChannelAnnouncement obj_conv;
25104         obj_conv.inner = (void*)(obj & (~1));
25105         obj_conv.is_owned = false;
25106         LDKCVec_u8Z ret_var = ChannelAnnouncement_write(&obj_conv);
25107         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
25108         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
25109         CVec_u8Z_free(ret_var);
25110         return ret_arr;
25111 }
25112
25113 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
25114         LDKu8slice ser_ref;
25115         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
25116         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
25117         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
25118         *ret_conv = ChannelAnnouncement_read(ser_ref);
25119         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
25120         return (uint64_t)ret_conv;
25121 }
25122
25123 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
25124         LDKUnsignedChannelUpdate obj_conv;
25125         obj_conv.inner = (void*)(obj & (~1));
25126         obj_conv.is_owned = false;
25127         LDKCVec_u8Z ret_var = UnsignedChannelUpdate_write(&obj_conv);
25128         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
25129         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
25130         CVec_u8Z_free(ret_var);
25131         return ret_arr;
25132 }
25133
25134 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
25135         LDKu8slice ser_ref;
25136         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
25137         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
25138         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
25139         *ret_conv = UnsignedChannelUpdate_read(ser_ref);
25140         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
25141         return (uint64_t)ret_conv;
25142 }
25143
25144 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
25145         LDKChannelUpdate obj_conv;
25146         obj_conv.inner = (void*)(obj & (~1));
25147         obj_conv.is_owned = false;
25148         LDKCVec_u8Z ret_var = ChannelUpdate_write(&obj_conv);
25149         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
25150         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
25151         CVec_u8Z_free(ret_var);
25152         return ret_arr;
25153 }
25154
25155 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
25156         LDKu8slice ser_ref;
25157         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
25158         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
25159         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
25160         *ret_conv = ChannelUpdate_read(ser_ref);
25161         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
25162         return (uint64_t)ret_conv;
25163 }
25164
25165 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1write(JNIEnv *env, jclass clz, int64_t obj) {
25166         LDKErrorMessage obj_conv;
25167         obj_conv.inner = (void*)(obj & (~1));
25168         obj_conv.is_owned = false;
25169         LDKCVec_u8Z ret_var = ErrorMessage_write(&obj_conv);
25170         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
25171         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
25172         CVec_u8Z_free(ret_var);
25173         return ret_arr;
25174 }
25175
25176 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
25177         LDKu8slice ser_ref;
25178         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
25179         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
25180         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
25181         *ret_conv = ErrorMessage_read(ser_ref);
25182         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
25183         return (uint64_t)ret_conv;
25184 }
25185
25186 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
25187         LDKUnsignedNodeAnnouncement obj_conv;
25188         obj_conv.inner = (void*)(obj & (~1));
25189         obj_conv.is_owned = false;
25190         LDKCVec_u8Z ret_var = UnsignedNodeAnnouncement_write(&obj_conv);
25191         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
25192         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
25193         CVec_u8Z_free(ret_var);
25194         return ret_arr;
25195 }
25196
25197 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
25198         LDKu8slice ser_ref;
25199         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
25200         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
25201         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
25202         *ret_conv = UnsignedNodeAnnouncement_read(ser_ref);
25203         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
25204         return (uint64_t)ret_conv;
25205 }
25206
25207 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
25208         LDKNodeAnnouncement obj_conv;
25209         obj_conv.inner = (void*)(obj & (~1));
25210         obj_conv.is_owned = false;
25211         LDKCVec_u8Z ret_var = NodeAnnouncement_write(&obj_conv);
25212         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
25213         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
25214         CVec_u8Z_free(ret_var);
25215         return ret_arr;
25216 }
25217
25218 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
25219         LDKu8slice ser_ref;
25220         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
25221         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
25222         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
25223         *ret_conv = NodeAnnouncement_read(ser_ref);
25224         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
25225         return (uint64_t)ret_conv;
25226 }
25227
25228 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
25229         LDKu8slice ser_ref;
25230         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
25231         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
25232         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
25233         *ret_conv = QueryShortChannelIds_read(ser_ref);
25234         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
25235         return (uint64_t)ret_conv;
25236 }
25237
25238 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1write(JNIEnv *env, jclass clz, int64_t obj) {
25239         LDKQueryShortChannelIds obj_conv;
25240         obj_conv.inner = (void*)(obj & (~1));
25241         obj_conv.is_owned = false;
25242         LDKCVec_u8Z ret_var = QueryShortChannelIds_write(&obj_conv);
25243         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
25244         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
25245         CVec_u8Z_free(ret_var);
25246         return ret_arr;
25247 }
25248
25249 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1write(JNIEnv *env, jclass clz, int64_t obj) {
25250         LDKReplyShortChannelIdsEnd obj_conv;
25251         obj_conv.inner = (void*)(obj & (~1));
25252         obj_conv.is_owned = false;
25253         LDKCVec_u8Z ret_var = ReplyShortChannelIdsEnd_write(&obj_conv);
25254         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
25255         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
25256         CVec_u8Z_free(ret_var);
25257         return ret_arr;
25258 }
25259
25260 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
25261         LDKu8slice ser_ref;
25262         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
25263         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
25264         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
25265         *ret_conv = ReplyShortChannelIdsEnd_read(ser_ref);
25266         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
25267         return (uint64_t)ret_conv;
25268 }
25269
25270 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1end_1blocknum(JNIEnv *env, jclass clz, int64_t this_arg) {
25271         LDKQueryChannelRange this_arg_conv;
25272         this_arg_conv.inner = (void*)(this_arg & (~1));
25273         this_arg_conv.is_owned = false;
25274         int32_t ret_val = QueryChannelRange_end_blocknum(&this_arg_conv);
25275         return ret_val;
25276 }
25277
25278 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
25279         LDKQueryChannelRange obj_conv;
25280         obj_conv.inner = (void*)(obj & (~1));
25281         obj_conv.is_owned = false;
25282         LDKCVec_u8Z ret_var = QueryChannelRange_write(&obj_conv);
25283         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
25284         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
25285         CVec_u8Z_free(ret_var);
25286         return ret_arr;
25287 }
25288
25289 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
25290         LDKu8slice ser_ref;
25291         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
25292         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
25293         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
25294         *ret_conv = QueryChannelRange_read(ser_ref);
25295         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
25296         return (uint64_t)ret_conv;
25297 }
25298
25299 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
25300         LDKu8slice ser_ref;
25301         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
25302         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
25303         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
25304         *ret_conv = ReplyChannelRange_read(ser_ref);
25305         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
25306         return (uint64_t)ret_conv;
25307 }
25308
25309 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
25310         LDKReplyChannelRange obj_conv;
25311         obj_conv.inner = (void*)(obj & (~1));
25312         obj_conv.is_owned = false;
25313         LDKCVec_u8Z ret_var = ReplyChannelRange_write(&obj_conv);
25314         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
25315         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
25316         CVec_u8Z_free(ret_var);
25317         return ret_arr;
25318 }
25319
25320 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1write(JNIEnv *env, jclass clz, int64_t obj) {
25321         LDKGossipTimestampFilter obj_conv;
25322         obj_conv.inner = (void*)(obj & (~1));
25323         obj_conv.is_owned = false;
25324         LDKCVec_u8Z ret_var = GossipTimestampFilter_write(&obj_conv);
25325         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
25326         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
25327         CVec_u8Z_free(ret_var);
25328         return ret_arr;
25329 }
25330
25331 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
25332         LDKu8slice ser_ref;
25333         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
25334         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
25335         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
25336         *ret_conv = GossipTimestampFilter_read(ser_ref);
25337         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
25338         return (uint64_t)ret_conv;
25339 }
25340
25341 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CustomMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
25342         if ((this_ptr & 1) != 0) return;
25343         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
25344         CHECK_ACCESS(this_ptr_ptr);
25345         LDKCustomMessageHandler this_ptr_conv = *(LDKCustomMessageHandler*)(this_ptr_ptr);
25346         FREE((void*)this_ptr);
25347         CustomMessageHandler_free(this_ptr_conv);
25348 }
25349
25350 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25351         LDKIgnoringMessageHandler this_obj_conv;
25352         this_obj_conv.inner = (void*)(this_obj & (~1));
25353         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25354         IgnoringMessageHandler_free(this_obj_conv);
25355 }
25356
25357 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1new(JNIEnv *env, jclass clz) {
25358         LDKIgnoringMessageHandler ret_var = IgnoringMessageHandler_new();
25359         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25360         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25361         uint64_t ret_ref = (uint64_t)ret_var.inner;
25362         if (ret_var.is_owned) {
25363                 ret_ref |= 1;
25364         }
25365         return ret_ref;
25366 }
25367
25368 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
25369         LDKIgnoringMessageHandler this_arg_conv;
25370         this_arg_conv.inner = (void*)(this_arg & (~1));
25371         this_arg_conv.is_owned = false;
25372         LDKMessageSendEventsProvider* ret_ret =MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
25373         *ret_ret = IgnoringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
25374         return (uint64_t)ret_ret;
25375 }
25376
25377 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1RoutingMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
25378         LDKIgnoringMessageHandler this_arg_conv;
25379         this_arg_conv.inner = (void*)(this_arg & (~1));
25380         this_arg_conv.is_owned = false;
25381         LDKRoutingMessageHandler* ret_ret =MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
25382         *ret_ret = IgnoringMessageHandler_as_RoutingMessageHandler(&this_arg_conv);
25383         return (uint64_t)ret_ret;
25384 }
25385
25386 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1CustomMessageReader(JNIEnv *env, jclass clz, int64_t this_arg) {
25387         LDKIgnoringMessageHandler this_arg_conv;
25388         this_arg_conv.inner = (void*)(this_arg & (~1));
25389         this_arg_conv.is_owned = false;
25390         LDKCustomMessageReader* ret_ret =MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader");
25391         *ret_ret = IgnoringMessageHandler_as_CustomMessageReader(&this_arg_conv);
25392         return (uint64_t)ret_ret;
25393 }
25394
25395 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1CustomMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
25396         LDKIgnoringMessageHandler this_arg_conv;
25397         this_arg_conv.inner = (void*)(this_arg & (~1));
25398         this_arg_conv.is_owned = false;
25399         LDKCustomMessageHandler* ret_ret =MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler");
25400         *ret_ret = IgnoringMessageHandler_as_CustomMessageHandler(&this_arg_conv);
25401         return (uint64_t)ret_ret;
25402 }
25403
25404 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25405         LDKErroringMessageHandler this_obj_conv;
25406         this_obj_conv.inner = (void*)(this_obj & (~1));
25407         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25408         ErroringMessageHandler_free(this_obj_conv);
25409 }
25410
25411 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1new(JNIEnv *env, jclass clz) {
25412         LDKErroringMessageHandler ret_var = ErroringMessageHandler_new();
25413         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25414         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25415         uint64_t ret_ref = (uint64_t)ret_var.inner;
25416         if (ret_var.is_owned) {
25417                 ret_ref |= 1;
25418         }
25419         return ret_ref;
25420 }
25421
25422 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
25423         LDKErroringMessageHandler this_arg_conv;
25424         this_arg_conv.inner = (void*)(this_arg & (~1));
25425         this_arg_conv.is_owned = false;
25426         LDKMessageSendEventsProvider* ret_ret =MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
25427         *ret_ret = ErroringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
25428         return (uint64_t)ret_ret;
25429 }
25430
25431 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1as_1ChannelMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
25432         LDKErroringMessageHandler this_arg_conv;
25433         this_arg_conv.inner = (void*)(this_arg & (~1));
25434         this_arg_conv.is_owned = false;
25435         LDKChannelMessageHandler* ret_ret =MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
25436         *ret_ret = ErroringMessageHandler_as_ChannelMessageHandler(&this_arg_conv);
25437         return (uint64_t)ret_ret;
25438 }
25439
25440 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25441         LDKMessageHandler this_obj_conv;
25442         this_obj_conv.inner = (void*)(this_obj & (~1));
25443         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25444         MessageHandler_free(this_obj_conv);
25445 }
25446
25447 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1chan_1handler(JNIEnv *env, jclass clz, int64_t this_ptr) {
25448         LDKMessageHandler this_ptr_conv;
25449         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25450         this_ptr_conv.is_owned = false;
25451         uint64_t ret_ret = (uint64_t)MessageHandler_get_chan_handler(&this_ptr_conv);
25452         return ret_ret;
25453 }
25454
25455 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1chan_1handler(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25456         LDKMessageHandler this_ptr_conv;
25457         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25458         this_ptr_conv.is_owned = false;
25459         void* val_ptr = (void*)(((uint64_t)val) & ~1);
25460         CHECK_ACCESS(val_ptr);
25461         LDKChannelMessageHandler val_conv = *(LDKChannelMessageHandler*)(val_ptr);
25462         if (val_conv.free == LDKChannelMessageHandler_JCalls_free) {
25463                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25464                 LDKChannelMessageHandler_JCalls_cloned(&val_conv);
25465         }
25466         MessageHandler_set_chan_handler(&this_ptr_conv, val_conv);
25467 }
25468
25469 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1route_1handler(JNIEnv *env, jclass clz, int64_t this_ptr) {
25470         LDKMessageHandler this_ptr_conv;
25471         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25472         this_ptr_conv.is_owned = false;
25473         uint64_t ret_ret = (uint64_t)MessageHandler_get_route_handler(&this_ptr_conv);
25474         return ret_ret;
25475 }
25476
25477 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1route_1handler(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25478         LDKMessageHandler this_ptr_conv;
25479         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25480         this_ptr_conv.is_owned = false;
25481         void* val_ptr = (void*)(((uint64_t)val) & ~1);
25482         CHECK_ACCESS(val_ptr);
25483         LDKRoutingMessageHandler val_conv = *(LDKRoutingMessageHandler*)(val_ptr);
25484         if (val_conv.free == LDKRoutingMessageHandler_JCalls_free) {
25485                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25486                 LDKRoutingMessageHandler_JCalls_cloned(&val_conv);
25487         }
25488         MessageHandler_set_route_handler(&this_ptr_conv, val_conv);
25489 }
25490
25491 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) {
25492         void* chan_handler_arg_ptr = (void*)(((uint64_t)chan_handler_arg) & ~1);
25493         CHECK_ACCESS(chan_handler_arg_ptr);
25494         LDKChannelMessageHandler chan_handler_arg_conv = *(LDKChannelMessageHandler*)(chan_handler_arg_ptr);
25495         if (chan_handler_arg_conv.free == LDKChannelMessageHandler_JCalls_free) {
25496                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25497                 LDKChannelMessageHandler_JCalls_cloned(&chan_handler_arg_conv);
25498         }
25499         void* route_handler_arg_ptr = (void*)(((uint64_t)route_handler_arg) & ~1);
25500         CHECK_ACCESS(route_handler_arg_ptr);
25501         LDKRoutingMessageHandler route_handler_arg_conv = *(LDKRoutingMessageHandler*)(route_handler_arg_ptr);
25502         if (route_handler_arg_conv.free == LDKRoutingMessageHandler_JCalls_free) {
25503                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25504                 LDKRoutingMessageHandler_JCalls_cloned(&route_handler_arg_conv);
25505         }
25506         LDKMessageHandler ret_var = MessageHandler_new(chan_handler_arg_conv, route_handler_arg_conv);
25507         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25508         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25509         uint64_t ret_ref = (uint64_t)ret_var.inner;
25510         if (ret_var.is_owned) {
25511                 ret_ref |= 1;
25512         }
25513         return ret_ref;
25514 }
25515
25516 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25517         void* orig_ptr = (void*)(((uint64_t)orig) & ~1);
25518         if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
25519         LDKSocketDescriptor* orig_conv = (LDKSocketDescriptor*)orig_ptr;
25520         LDKSocketDescriptor* ret_ret =MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
25521         *ret_ret = SocketDescriptor_clone(orig_conv);
25522         return (uint64_t)ret_ret;
25523 }
25524
25525 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
25526         if ((this_ptr & 1) != 0) return;
25527         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
25528         CHECK_ACCESS(this_ptr_ptr);
25529         LDKSocketDescriptor this_ptr_conv = *(LDKSocketDescriptor*)(this_ptr_ptr);
25530         FREE((void*)this_ptr);
25531         SocketDescriptor_free(this_ptr_conv);
25532 }
25533
25534 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25535         LDKPeerHandleError this_obj_conv;
25536         this_obj_conv.inner = (void*)(this_obj & (~1));
25537         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25538         PeerHandleError_free(this_obj_conv);
25539 }
25540
25541 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1get_1no_1connection_1possible(JNIEnv *env, jclass clz, int64_t this_ptr) {
25542         LDKPeerHandleError this_ptr_conv;
25543         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25544         this_ptr_conv.is_owned = false;
25545         jboolean ret_val = PeerHandleError_get_no_connection_possible(&this_ptr_conv);
25546         return ret_val;
25547 }
25548
25549 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1set_1no_1connection_1possible(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
25550         LDKPeerHandleError this_ptr_conv;
25551         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25552         this_ptr_conv.is_owned = false;
25553         PeerHandleError_set_no_connection_possible(&this_ptr_conv, val);
25554 }
25555
25556 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1new(JNIEnv *env, jclass clz, jboolean no_connection_possible_arg) {
25557         LDKPeerHandleError ret_var = PeerHandleError_new(no_connection_possible_arg);
25558         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25559         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25560         uint64_t ret_ref = (uint64_t)ret_var.inner;
25561         if (ret_var.is_owned) {
25562                 ret_ref |= 1;
25563         }
25564         return ret_ref;
25565 }
25566
25567 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25568         LDKPeerHandleError orig_conv;
25569         orig_conv.inner = (void*)(orig & (~1));
25570         orig_conv.is_owned = false;
25571         LDKPeerHandleError ret_var = PeerHandleError_clone(&orig_conv);
25572         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25573         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25574         uint64_t ret_ref = (uint64_t)ret_var.inner;
25575         if (ret_var.is_owned) {
25576                 ret_ref |= 1;
25577         }
25578         return ret_ref;
25579 }
25580
25581 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25582         LDKPeerManager this_obj_conv;
25583         this_obj_conv.inner = (void*)(this_obj & (~1));
25584         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25585         PeerManager_free(this_obj_conv);
25586 }
25587
25588 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) {
25589         LDKMessageHandler message_handler_conv;
25590         message_handler_conv.inner = (void*)(message_handler & (~1));
25591         message_handler_conv.is_owned = (message_handler & 1) || (message_handler == 0);
25592         // Warning: we need a move here but no clone is available for LDKMessageHandler
25593         LDKSecretKey our_node_secret_ref;
25594         CHECK((*env)->GetArrayLength(env, our_node_secret) == 32);
25595         (*env)->GetByteArrayRegion(env, our_node_secret, 0, 32, our_node_secret_ref.bytes);
25596         unsigned char ephemeral_random_data_arr[32];
25597         CHECK((*env)->GetArrayLength(env, ephemeral_random_data) == 32);
25598         (*env)->GetByteArrayRegion(env, ephemeral_random_data, 0, 32, ephemeral_random_data_arr);
25599         unsigned char (*ephemeral_random_data_ref)[32] = &ephemeral_random_data_arr;
25600         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
25601         CHECK_ACCESS(logger_ptr);
25602         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
25603         if (logger_conv.free == LDKLogger_JCalls_free) {
25604                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25605                 LDKLogger_JCalls_cloned(&logger_conv);
25606         }
25607         void* custom_message_handler_ptr = (void*)(((uint64_t)custom_message_handler) & ~1);
25608         CHECK_ACCESS(custom_message_handler_ptr);
25609         LDKCustomMessageHandler custom_message_handler_conv = *(LDKCustomMessageHandler*)(custom_message_handler_ptr);
25610         if (custom_message_handler_conv.free == LDKCustomMessageHandler_JCalls_free) {
25611                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25612                 LDKCustomMessageHandler_JCalls_cloned(&custom_message_handler_conv);
25613         }
25614         LDKPeerManager ret_var = PeerManager_new(message_handler_conv, our_node_secret_ref, ephemeral_random_data_ref, logger_conv, custom_message_handler_conv);
25615         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25616         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25617         uint64_t ret_ref = (uint64_t)ret_var.inner;
25618         if (ret_var.is_owned) {
25619                 ret_ref |= 1;
25620         }
25621         return ret_ref;
25622 }
25623
25624 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_PeerManager_1get_1peer_1node_1ids(JNIEnv *env, jclass clz, int64_t this_arg) {
25625         LDKPeerManager this_arg_conv;
25626         this_arg_conv.inner = (void*)(this_arg & (~1));
25627         this_arg_conv.is_owned = false;
25628         LDKCVec_PublicKeyZ ret_var = PeerManager_get_peer_node_ids(&this_arg_conv);
25629         jobjectArray ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
25630         ;
25631         for (size_t i = 0; i < ret_var.datalen; i++) {
25632                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 33);
25633                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 33, ret_var.data[i].compressed_form);
25634                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
25635         }
25636         FREE(ret_var.data);
25637         return ret_arr;
25638 }
25639
25640 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) {
25641         LDKPeerManager this_arg_conv;
25642         this_arg_conv.inner = (void*)(this_arg & (~1));
25643         this_arg_conv.is_owned = false;
25644         LDKPublicKey their_node_id_ref;
25645         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
25646         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
25647         void* descriptor_ptr = (void*)(((uint64_t)descriptor) & ~1);
25648         CHECK_ACCESS(descriptor_ptr);
25649         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(descriptor_ptr);
25650         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
25651                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25652                 LDKSocketDescriptor_JCalls_cloned(&descriptor_conv);
25653         }
25654         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
25655         *ret_conv = PeerManager_new_outbound_connection(&this_arg_conv, their_node_id_ref, descriptor_conv);
25656         return (uint64_t)ret_conv;
25657 }
25658
25659 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerManager_1new_1inbound_1connection(JNIEnv *env, jclass clz, int64_t this_arg, int64_t descriptor) {
25660         LDKPeerManager this_arg_conv;
25661         this_arg_conv.inner = (void*)(this_arg & (~1));
25662         this_arg_conv.is_owned = false;
25663         void* descriptor_ptr = (void*)(((uint64_t)descriptor) & ~1);
25664         CHECK_ACCESS(descriptor_ptr);
25665         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(descriptor_ptr);
25666         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
25667                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25668                 LDKSocketDescriptor_JCalls_cloned(&descriptor_conv);
25669         }
25670         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
25671         *ret_conv = PeerManager_new_inbound_connection(&this_arg_conv, descriptor_conv);
25672         return (uint64_t)ret_conv;
25673 }
25674
25675 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) {
25676         LDKPeerManager this_arg_conv;
25677         this_arg_conv.inner = (void*)(this_arg & (~1));
25678         this_arg_conv.is_owned = false;
25679         void* descriptor_ptr = (void*)(((uint64_t)descriptor) & ~1);
25680         if (!(descriptor & 1)) { CHECK_ACCESS(descriptor_ptr); }
25681         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor_ptr;
25682         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
25683         *ret_conv = PeerManager_write_buffer_space_avail(&this_arg_conv, descriptor_conv);
25684         return (uint64_t)ret_conv;
25685 }
25686
25687 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) {
25688         LDKPeerManager this_arg_conv;
25689         this_arg_conv.inner = (void*)(this_arg & (~1));
25690         this_arg_conv.is_owned = false;
25691         void* peer_descriptor_ptr = (void*)(((uint64_t)peer_descriptor) & ~1);
25692         if (!(peer_descriptor & 1)) { CHECK_ACCESS(peer_descriptor_ptr); }
25693         LDKSocketDescriptor* peer_descriptor_conv = (LDKSocketDescriptor*)peer_descriptor_ptr;
25694         LDKu8slice data_ref;
25695         data_ref.datalen = (*env)->GetArrayLength(env, data);
25696         data_ref.data = (*env)->GetByteArrayElements (env, data, NULL);
25697         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
25698         *ret_conv = PeerManager_read_event(&this_arg_conv, peer_descriptor_conv, data_ref);
25699         (*env)->ReleaseByteArrayElements(env, data, (int8_t*)data_ref.data, 0);
25700         return (uint64_t)ret_conv;
25701 }
25702
25703 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1process_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
25704         LDKPeerManager this_arg_conv;
25705         this_arg_conv.inner = (void*)(this_arg & (~1));
25706         this_arg_conv.is_owned = false;
25707         PeerManager_process_events(&this_arg_conv);
25708 }
25709
25710 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1socket_1disconnected(JNIEnv *env, jclass clz, int64_t this_arg, int64_t descriptor) {
25711         LDKPeerManager this_arg_conv;
25712         this_arg_conv.inner = (void*)(this_arg & (~1));
25713         this_arg_conv.is_owned = false;
25714         void* descriptor_ptr = (void*)(((uint64_t)descriptor) & ~1);
25715         if (!(descriptor & 1)) { CHECK_ACCESS(descriptor_ptr); }
25716         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor_ptr;
25717         PeerManager_socket_disconnected(&this_arg_conv, descriptor_conv);
25718 }
25719
25720 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) {
25721         LDKPeerManager this_arg_conv;
25722         this_arg_conv.inner = (void*)(this_arg & (~1));
25723         this_arg_conv.is_owned = false;
25724         LDKPublicKey node_id_ref;
25725         CHECK((*env)->GetArrayLength(env, node_id) == 33);
25726         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
25727         PeerManager_disconnect_by_node_id(&this_arg_conv, node_id_ref, no_connection_possible);
25728 }
25729
25730 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1timer_1tick_1occurred(JNIEnv *env, jclass clz, int64_t this_arg) {
25731         LDKPeerManager this_arg_conv;
25732         this_arg_conv.inner = (void*)(this_arg & (~1));
25733         this_arg_conv.is_owned = false;
25734         PeerManager_timer_tick_occurred(&this_arg_conv);
25735 }
25736
25737 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_build_1commitment_1secret(JNIEnv *env, jclass clz, int8_tArray commitment_seed, int64_t idx) {
25738         unsigned char commitment_seed_arr[32];
25739         CHECK((*env)->GetArrayLength(env, commitment_seed) == 32);
25740         (*env)->GetByteArrayRegion(env, commitment_seed, 0, 32, commitment_seed_arr);
25741         unsigned char (*commitment_seed_ref)[32] = &commitment_seed_arr;
25742         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
25743         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, build_commitment_secret(commitment_seed_ref, idx).data);
25744         return ret_arr;
25745 }
25746
25747 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) {
25748         LDKCVec_u8Z to_holder_script_ref;
25749         to_holder_script_ref.datalen = (*env)->GetArrayLength(env, to_holder_script);
25750         to_holder_script_ref.data = MALLOC(to_holder_script_ref.datalen, "LDKCVec_u8Z Bytes");
25751         (*env)->GetByteArrayRegion(env, to_holder_script, 0, to_holder_script_ref.datalen, to_holder_script_ref.data);
25752         LDKCVec_u8Z to_counterparty_script_ref;
25753         to_counterparty_script_ref.datalen = (*env)->GetArrayLength(env, to_counterparty_script);
25754         to_counterparty_script_ref.data = MALLOC(to_counterparty_script_ref.datalen, "LDKCVec_u8Z Bytes");
25755         (*env)->GetByteArrayRegion(env, to_counterparty_script, 0, to_counterparty_script_ref.datalen, to_counterparty_script_ref.data);
25756         LDKOutPoint funding_outpoint_conv;
25757         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
25758         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
25759         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
25760         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);
25761         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
25762         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
25763         Transaction_free(ret_var);
25764         return ret_arr;
25765 }
25766
25767 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) {
25768         LDKPublicKey per_commitment_point_ref;
25769         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
25770         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
25771         unsigned char base_secret_arr[32];
25772         CHECK((*env)->GetArrayLength(env, base_secret) == 32);
25773         (*env)->GetByteArrayRegion(env, base_secret, 0, 32, base_secret_arr);
25774         unsigned char (*base_secret_ref)[32] = &base_secret_arr;
25775         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
25776         *ret_conv = derive_private_key(per_commitment_point_ref, base_secret_ref);
25777         return (uint64_t)ret_conv;
25778 }
25779
25780 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) {
25781         LDKPublicKey per_commitment_point_ref;
25782         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
25783         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
25784         LDKPublicKey base_point_ref;
25785         CHECK((*env)->GetArrayLength(env, base_point) == 33);
25786         (*env)->GetByteArrayRegion(env, base_point, 0, 33, base_point_ref.compressed_form);
25787         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
25788         *ret_conv = derive_public_key(per_commitment_point_ref, base_point_ref);
25789         return (uint64_t)ret_conv;
25790 }
25791
25792 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) {
25793         unsigned char per_commitment_secret_arr[32];
25794         CHECK((*env)->GetArrayLength(env, per_commitment_secret) == 32);
25795         (*env)->GetByteArrayRegion(env, per_commitment_secret, 0, 32, per_commitment_secret_arr);
25796         unsigned char (*per_commitment_secret_ref)[32] = &per_commitment_secret_arr;
25797         unsigned char countersignatory_revocation_base_secret_arr[32];
25798         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base_secret) == 32);
25799         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base_secret, 0, 32, countersignatory_revocation_base_secret_arr);
25800         unsigned char (*countersignatory_revocation_base_secret_ref)[32] = &countersignatory_revocation_base_secret_arr;
25801         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
25802         *ret_conv = derive_private_revocation_key(per_commitment_secret_ref, countersignatory_revocation_base_secret_ref);
25803         return (uint64_t)ret_conv;
25804 }
25805
25806 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) {
25807         LDKPublicKey per_commitment_point_ref;
25808         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
25809         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
25810         LDKPublicKey countersignatory_revocation_base_point_ref;
25811         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base_point) == 33);
25812         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base_point, 0, 33, countersignatory_revocation_base_point_ref.compressed_form);
25813         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
25814         *ret_conv = derive_public_revocation_key(per_commitment_point_ref, countersignatory_revocation_base_point_ref);
25815         return (uint64_t)ret_conv;
25816 }
25817
25818 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25819         LDKTxCreationKeys this_obj_conv;
25820         this_obj_conv.inner = (void*)(this_obj & (~1));
25821         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25822         TxCreationKeys_free(this_obj_conv);
25823 }
25824
25825 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
25826         LDKTxCreationKeys this_ptr_conv;
25827         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25828         this_ptr_conv.is_owned = false;
25829         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
25830         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_per_commitment_point(&this_ptr_conv).compressed_form);
25831         return ret_arr;
25832 }
25833
25834 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
25835         LDKTxCreationKeys this_ptr_conv;
25836         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25837         this_ptr_conv.is_owned = false;
25838         LDKPublicKey val_ref;
25839         CHECK((*env)->GetArrayLength(env, val) == 33);
25840         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
25841         TxCreationKeys_set_per_commitment_point(&this_ptr_conv, val_ref);
25842 }
25843
25844 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1revocation_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
25845         LDKTxCreationKeys this_ptr_conv;
25846         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25847         this_ptr_conv.is_owned = false;
25848         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
25849         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_revocation_key(&this_ptr_conv).compressed_form);
25850         return ret_arr;
25851 }
25852
25853 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1revocation_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
25854         LDKTxCreationKeys this_ptr_conv;
25855         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25856         this_ptr_conv.is_owned = false;
25857         LDKPublicKey val_ref;
25858         CHECK((*env)->GetArrayLength(env, val) == 33);
25859         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
25860         TxCreationKeys_set_revocation_key(&this_ptr_conv, val_ref);
25861 }
25862
25863 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1broadcaster_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
25864         LDKTxCreationKeys this_ptr_conv;
25865         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25866         this_ptr_conv.is_owned = false;
25867         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
25868         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_broadcaster_htlc_key(&this_ptr_conv).compressed_form);
25869         return ret_arr;
25870 }
25871
25872 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1broadcaster_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
25873         LDKTxCreationKeys this_ptr_conv;
25874         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25875         this_ptr_conv.is_owned = false;
25876         LDKPublicKey val_ref;
25877         CHECK((*env)->GetArrayLength(env, val) == 33);
25878         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
25879         TxCreationKeys_set_broadcaster_htlc_key(&this_ptr_conv, val_ref);
25880 }
25881
25882 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1countersignatory_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
25883         LDKTxCreationKeys this_ptr_conv;
25884         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25885         this_ptr_conv.is_owned = false;
25886         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
25887         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_countersignatory_htlc_key(&this_ptr_conv).compressed_form);
25888         return ret_arr;
25889 }
25890
25891 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1countersignatory_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
25892         LDKTxCreationKeys this_ptr_conv;
25893         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25894         this_ptr_conv.is_owned = false;
25895         LDKPublicKey val_ref;
25896         CHECK((*env)->GetArrayLength(env, val) == 33);
25897         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
25898         TxCreationKeys_set_countersignatory_htlc_key(&this_ptr_conv, val_ref);
25899 }
25900
25901 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1broadcaster_1delayed_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
25902         LDKTxCreationKeys this_ptr_conv;
25903         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25904         this_ptr_conv.is_owned = false;
25905         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
25906         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_broadcaster_delayed_payment_key(&this_ptr_conv).compressed_form);
25907         return ret_arr;
25908 }
25909
25910 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) {
25911         LDKTxCreationKeys this_ptr_conv;
25912         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25913         this_ptr_conv.is_owned = false;
25914         LDKPublicKey val_ref;
25915         CHECK((*env)->GetArrayLength(env, val) == 33);
25916         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
25917         TxCreationKeys_set_broadcaster_delayed_payment_key(&this_ptr_conv, val_ref);
25918 }
25919
25920 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) {
25921         LDKPublicKey per_commitment_point_arg_ref;
25922         CHECK((*env)->GetArrayLength(env, per_commitment_point_arg) == 33);
25923         (*env)->GetByteArrayRegion(env, per_commitment_point_arg, 0, 33, per_commitment_point_arg_ref.compressed_form);
25924         LDKPublicKey revocation_key_arg_ref;
25925         CHECK((*env)->GetArrayLength(env, revocation_key_arg) == 33);
25926         (*env)->GetByteArrayRegion(env, revocation_key_arg, 0, 33, revocation_key_arg_ref.compressed_form);
25927         LDKPublicKey broadcaster_htlc_key_arg_ref;
25928         CHECK((*env)->GetArrayLength(env, broadcaster_htlc_key_arg) == 33);
25929         (*env)->GetByteArrayRegion(env, broadcaster_htlc_key_arg, 0, 33, broadcaster_htlc_key_arg_ref.compressed_form);
25930         LDKPublicKey countersignatory_htlc_key_arg_ref;
25931         CHECK((*env)->GetArrayLength(env, countersignatory_htlc_key_arg) == 33);
25932         (*env)->GetByteArrayRegion(env, countersignatory_htlc_key_arg, 0, 33, countersignatory_htlc_key_arg_ref.compressed_form);
25933         LDKPublicKey broadcaster_delayed_payment_key_arg_ref;
25934         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key_arg) == 33);
25935         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key_arg, 0, 33, broadcaster_delayed_payment_key_arg_ref.compressed_form);
25936         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);
25937         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25938         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25939         uint64_t ret_ref = (uint64_t)ret_var.inner;
25940         if (ret_var.is_owned) {
25941                 ret_ref |= 1;
25942         }
25943         return ret_ref;
25944 }
25945
25946 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25947         LDKTxCreationKeys orig_conv;
25948         orig_conv.inner = (void*)(orig & (~1));
25949         orig_conv.is_owned = false;
25950         LDKTxCreationKeys ret_var = TxCreationKeys_clone(&orig_conv);
25951         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25952         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25953         uint64_t ret_ref = (uint64_t)ret_var.inner;
25954         if (ret_var.is_owned) {
25955                 ret_ref |= 1;
25956         }
25957         return ret_ref;
25958 }
25959
25960 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1write(JNIEnv *env, jclass clz, int64_t obj) {
25961         LDKTxCreationKeys obj_conv;
25962         obj_conv.inner = (void*)(obj & (~1));
25963         obj_conv.is_owned = false;
25964         LDKCVec_u8Z ret_var = TxCreationKeys_write(&obj_conv);
25965         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
25966         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
25967         CVec_u8Z_free(ret_var);
25968         return ret_arr;
25969 }
25970
25971 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
25972         LDKu8slice ser_ref;
25973         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
25974         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
25975         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
25976         *ret_conv = TxCreationKeys_read(ser_ref);
25977         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
25978         return (uint64_t)ret_conv;
25979 }
25980
25981 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25982         LDKChannelPublicKeys this_obj_conv;
25983         this_obj_conv.inner = (void*)(this_obj & (~1));
25984         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25985         ChannelPublicKeys_free(this_obj_conv);
25986 }
25987
25988 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
25989         LDKChannelPublicKeys this_ptr_conv;
25990         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25991         this_ptr_conv.is_owned = false;
25992         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
25993         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_funding_pubkey(&this_ptr_conv).compressed_form);
25994         return ret_arr;
25995 }
25996
25997 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
25998         LDKChannelPublicKeys this_ptr_conv;
25999         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26000         this_ptr_conv.is_owned = false;
26001         LDKPublicKey val_ref;
26002         CHECK((*env)->GetArrayLength(env, val) == 33);
26003         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
26004         ChannelPublicKeys_set_funding_pubkey(&this_ptr_conv, val_ref);
26005 }
26006
26007 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
26008         LDKChannelPublicKeys this_ptr_conv;
26009         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26010         this_ptr_conv.is_owned = false;
26011         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
26012         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_revocation_basepoint(&this_ptr_conv).compressed_form);
26013         return ret_arr;
26014 }
26015
26016 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
26017         LDKChannelPublicKeys this_ptr_conv;
26018         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26019         this_ptr_conv.is_owned = false;
26020         LDKPublicKey val_ref;
26021         CHECK((*env)->GetArrayLength(env, val) == 33);
26022         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
26023         ChannelPublicKeys_set_revocation_basepoint(&this_ptr_conv, val_ref);
26024 }
26025
26026 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
26027         LDKChannelPublicKeys this_ptr_conv;
26028         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26029         this_ptr_conv.is_owned = false;
26030         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
26031         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_payment_point(&this_ptr_conv).compressed_form);
26032         return ret_arr;
26033 }
26034
26035 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
26036         LDKChannelPublicKeys this_ptr_conv;
26037         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26038         this_ptr_conv.is_owned = false;
26039         LDKPublicKey val_ref;
26040         CHECK((*env)->GetArrayLength(env, val) == 33);
26041         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
26042         ChannelPublicKeys_set_payment_point(&this_ptr_conv, val_ref);
26043 }
26044
26045 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
26046         LDKChannelPublicKeys this_ptr_conv;
26047         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26048         this_ptr_conv.is_owned = false;
26049         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
26050         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
26051         return ret_arr;
26052 }
26053
26054 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
26055         LDKChannelPublicKeys this_ptr_conv;
26056         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26057         this_ptr_conv.is_owned = false;
26058         LDKPublicKey val_ref;
26059         CHECK((*env)->GetArrayLength(env, val) == 33);
26060         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
26061         ChannelPublicKeys_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
26062 }
26063
26064 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
26065         LDKChannelPublicKeys this_ptr_conv;
26066         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26067         this_ptr_conv.is_owned = false;
26068         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
26069         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_htlc_basepoint(&this_ptr_conv).compressed_form);
26070         return ret_arr;
26071 }
26072
26073 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
26074         LDKChannelPublicKeys this_ptr_conv;
26075         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26076         this_ptr_conv.is_owned = false;
26077         LDKPublicKey val_ref;
26078         CHECK((*env)->GetArrayLength(env, val) == 33);
26079         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
26080         ChannelPublicKeys_set_htlc_basepoint(&this_ptr_conv, val_ref);
26081 }
26082
26083 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) {
26084         LDKPublicKey funding_pubkey_arg_ref;
26085         CHECK((*env)->GetArrayLength(env, funding_pubkey_arg) == 33);
26086         (*env)->GetByteArrayRegion(env, funding_pubkey_arg, 0, 33, funding_pubkey_arg_ref.compressed_form);
26087         LDKPublicKey revocation_basepoint_arg_ref;
26088         CHECK((*env)->GetArrayLength(env, revocation_basepoint_arg) == 33);
26089         (*env)->GetByteArrayRegion(env, revocation_basepoint_arg, 0, 33, revocation_basepoint_arg_ref.compressed_form);
26090         LDKPublicKey payment_point_arg_ref;
26091         CHECK((*env)->GetArrayLength(env, payment_point_arg) == 33);
26092         (*env)->GetByteArrayRegion(env, payment_point_arg, 0, 33, payment_point_arg_ref.compressed_form);
26093         LDKPublicKey delayed_payment_basepoint_arg_ref;
26094         CHECK((*env)->GetArrayLength(env, delayed_payment_basepoint_arg) == 33);
26095         (*env)->GetByteArrayRegion(env, delayed_payment_basepoint_arg, 0, 33, delayed_payment_basepoint_arg_ref.compressed_form);
26096         LDKPublicKey htlc_basepoint_arg_ref;
26097         CHECK((*env)->GetArrayLength(env, htlc_basepoint_arg) == 33);
26098         (*env)->GetByteArrayRegion(env, htlc_basepoint_arg, 0, 33, htlc_basepoint_arg_ref.compressed_form);
26099         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);
26100         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26101         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26102         uint64_t ret_ref = (uint64_t)ret_var.inner;
26103         if (ret_var.is_owned) {
26104                 ret_ref |= 1;
26105         }
26106         return ret_ref;
26107 }
26108
26109 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26110         LDKChannelPublicKeys orig_conv;
26111         orig_conv.inner = (void*)(orig & (~1));
26112         orig_conv.is_owned = false;
26113         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(&orig_conv);
26114         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26115         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26116         uint64_t ret_ref = (uint64_t)ret_var.inner;
26117         if (ret_var.is_owned) {
26118                 ret_ref |= 1;
26119         }
26120         return ret_ref;
26121 }
26122
26123 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1write(JNIEnv *env, jclass clz, int64_t obj) {
26124         LDKChannelPublicKeys obj_conv;
26125         obj_conv.inner = (void*)(obj & (~1));
26126         obj_conv.is_owned = false;
26127         LDKCVec_u8Z ret_var = ChannelPublicKeys_write(&obj_conv);
26128         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26129         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26130         CVec_u8Z_free(ret_var);
26131         return ret_arr;
26132 }
26133
26134 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
26135         LDKu8slice ser_ref;
26136         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
26137         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
26138         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
26139         *ret_conv = ChannelPublicKeys_read(ser_ref);
26140         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
26141         return (uint64_t)ret_conv;
26142 }
26143
26144 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) {
26145         LDKPublicKey per_commitment_point_ref;
26146         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
26147         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
26148         LDKPublicKey broadcaster_delayed_payment_base_ref;
26149         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_base) == 33);
26150         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_base, 0, 33, broadcaster_delayed_payment_base_ref.compressed_form);
26151         LDKPublicKey broadcaster_htlc_base_ref;
26152         CHECK((*env)->GetArrayLength(env, broadcaster_htlc_base) == 33);
26153         (*env)->GetByteArrayRegion(env, broadcaster_htlc_base, 0, 33, broadcaster_htlc_base_ref.compressed_form);
26154         LDKPublicKey countersignatory_revocation_base_ref;
26155         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base) == 33);
26156         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base, 0, 33, countersignatory_revocation_base_ref.compressed_form);
26157         LDKPublicKey countersignatory_htlc_base_ref;
26158         CHECK((*env)->GetArrayLength(env, countersignatory_htlc_base) == 33);
26159         (*env)->GetByteArrayRegion(env, countersignatory_htlc_base, 0, 33, countersignatory_htlc_base_ref.compressed_form);
26160         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
26161         *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);
26162         return (uint64_t)ret_conv;
26163 }
26164
26165 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) {
26166         LDKPublicKey per_commitment_point_ref;
26167         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
26168         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
26169         LDKChannelPublicKeys broadcaster_keys_conv;
26170         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
26171         broadcaster_keys_conv.is_owned = false;
26172         LDKChannelPublicKeys countersignatory_keys_conv;
26173         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
26174         countersignatory_keys_conv.is_owned = false;
26175         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
26176         *ret_conv = TxCreationKeys_from_channel_static_keys(per_commitment_point_ref, &broadcaster_keys_conv, &countersignatory_keys_conv);
26177         return (uint64_t)ret_conv;
26178 }
26179
26180 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) {
26181         LDKPublicKey revocation_key_ref;
26182         CHECK((*env)->GetArrayLength(env, revocation_key) == 33);
26183         (*env)->GetByteArrayRegion(env, revocation_key, 0, 33, revocation_key_ref.compressed_form);
26184         LDKPublicKey broadcaster_delayed_payment_key_ref;
26185         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key) == 33);
26186         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key, 0, 33, broadcaster_delayed_payment_key_ref.compressed_form);
26187         LDKCVec_u8Z ret_var = get_revokeable_redeemscript(revocation_key_ref, contest_delay, broadcaster_delayed_payment_key_ref);
26188         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26189         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26190         CVec_u8Z_free(ret_var);
26191         return ret_arr;
26192 }
26193
26194 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26195         LDKHTLCOutputInCommitment this_obj_conv;
26196         this_obj_conv.inner = (void*)(this_obj & (~1));
26197         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26198         HTLCOutputInCommitment_free(this_obj_conv);
26199 }
26200
26201 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1offered(JNIEnv *env, jclass clz, int64_t this_ptr) {
26202         LDKHTLCOutputInCommitment this_ptr_conv;
26203         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26204         this_ptr_conv.is_owned = false;
26205         jboolean ret_val = HTLCOutputInCommitment_get_offered(&this_ptr_conv);
26206         return ret_val;
26207 }
26208
26209 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1offered(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
26210         LDKHTLCOutputInCommitment this_ptr_conv;
26211         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26212         this_ptr_conv.is_owned = false;
26213         HTLCOutputInCommitment_set_offered(&this_ptr_conv, val);
26214 }
26215
26216 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
26217         LDKHTLCOutputInCommitment this_ptr_conv;
26218         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26219         this_ptr_conv.is_owned = false;
26220         int64_t ret_val = HTLCOutputInCommitment_get_amount_msat(&this_ptr_conv);
26221         return ret_val;
26222 }
26223
26224 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
26225         LDKHTLCOutputInCommitment this_ptr_conv;
26226         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26227         this_ptr_conv.is_owned = false;
26228         HTLCOutputInCommitment_set_amount_msat(&this_ptr_conv, val);
26229 }
26230
26231 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr) {
26232         LDKHTLCOutputInCommitment this_ptr_conv;
26233         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26234         this_ptr_conv.is_owned = false;
26235         int32_t ret_val = HTLCOutputInCommitment_get_cltv_expiry(&this_ptr_conv);
26236         return ret_val;
26237 }
26238
26239 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
26240         LDKHTLCOutputInCommitment this_ptr_conv;
26241         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26242         this_ptr_conv.is_owned = false;
26243         HTLCOutputInCommitment_set_cltv_expiry(&this_ptr_conv, val);
26244 }
26245
26246 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
26247         LDKHTLCOutputInCommitment this_ptr_conv;
26248         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26249         this_ptr_conv.is_owned = false;
26250         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
26251         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *HTLCOutputInCommitment_get_payment_hash(&this_ptr_conv));
26252         return ret_arr;
26253 }
26254
26255 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
26256         LDKHTLCOutputInCommitment this_ptr_conv;
26257         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26258         this_ptr_conv.is_owned = false;
26259         LDKThirtyTwoBytes val_ref;
26260         CHECK((*env)->GetArrayLength(env, val) == 32);
26261         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
26262         HTLCOutputInCommitment_set_payment_hash(&this_ptr_conv, val_ref);
26263 }
26264
26265 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1transaction_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
26266         LDKHTLCOutputInCommitment this_ptr_conv;
26267         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26268         this_ptr_conv.is_owned = false;
26269         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
26270         *ret_copy = HTLCOutputInCommitment_get_transaction_output_index(&this_ptr_conv);
26271         uint64_t ret_ref = (uint64_t)ret_copy;
26272         return ret_ref;
26273 }
26274
26275 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1transaction_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
26276         LDKHTLCOutputInCommitment this_ptr_conv;
26277         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26278         this_ptr_conv.is_owned = false;
26279         void* val_ptr = (void*)(((uint64_t)val) & ~1);
26280         CHECK_ACCESS(val_ptr);
26281         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
26282         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uint64_t)val) & ~1));
26283         HTLCOutputInCommitment_set_transaction_output_index(&this_ptr_conv, val_conv);
26284 }
26285
26286 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) {
26287         LDKThirtyTwoBytes payment_hash_arg_ref;
26288         CHECK((*env)->GetArrayLength(env, payment_hash_arg) == 32);
26289         (*env)->GetByteArrayRegion(env, payment_hash_arg, 0, 32, payment_hash_arg_ref.data);
26290         void* transaction_output_index_arg_ptr = (void*)(((uint64_t)transaction_output_index_arg) & ~1);
26291         CHECK_ACCESS(transaction_output_index_arg_ptr);
26292         LDKCOption_u32Z transaction_output_index_arg_conv = *(LDKCOption_u32Z*)(transaction_output_index_arg_ptr);
26293         transaction_output_index_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uint64_t)transaction_output_index_arg) & ~1));
26294         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_new(offered_arg, amount_msat_arg, cltv_expiry_arg, payment_hash_arg_ref, transaction_output_index_arg_conv);
26295         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26296         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26297         uint64_t ret_ref = (uint64_t)ret_var.inner;
26298         if (ret_var.is_owned) {
26299                 ret_ref |= 1;
26300         }
26301         return ret_ref;
26302 }
26303
26304 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26305         LDKHTLCOutputInCommitment orig_conv;
26306         orig_conv.inner = (void*)(orig & (~1));
26307         orig_conv.is_owned = false;
26308         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(&orig_conv);
26309         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26310         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26311         uint64_t ret_ref = (uint64_t)ret_var.inner;
26312         if (ret_var.is_owned) {
26313                 ret_ref |= 1;
26314         }
26315         return ret_ref;
26316 }
26317
26318 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1write(JNIEnv *env, jclass clz, int64_t obj) {
26319         LDKHTLCOutputInCommitment obj_conv;
26320         obj_conv.inner = (void*)(obj & (~1));
26321         obj_conv.is_owned = false;
26322         LDKCVec_u8Z ret_var = HTLCOutputInCommitment_write(&obj_conv);
26323         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26324         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26325         CVec_u8Z_free(ret_var);
26326         return ret_arr;
26327 }
26328
26329 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
26330         LDKu8slice ser_ref;
26331         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
26332         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
26333         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
26334         *ret_conv = HTLCOutputInCommitment_read(ser_ref);
26335         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
26336         return (uint64_t)ret_conv;
26337 }
26338
26339 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_get_1htlc_1redeemscript(JNIEnv *env, jclass clz, int64_t htlc, int64_t keys) {
26340         LDKHTLCOutputInCommitment htlc_conv;
26341         htlc_conv.inner = (void*)(htlc & (~1));
26342         htlc_conv.is_owned = false;
26343         LDKTxCreationKeys keys_conv;
26344         keys_conv.inner = (void*)(keys & (~1));
26345         keys_conv.is_owned = false;
26346         LDKCVec_u8Z ret_var = get_htlc_redeemscript(&htlc_conv, &keys_conv);
26347         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26348         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26349         CVec_u8Z_free(ret_var);
26350         return ret_arr;
26351 }
26352
26353 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_make_1funding_1redeemscript(JNIEnv *env, jclass clz, int8_tArray broadcaster, int8_tArray countersignatory) {
26354         LDKPublicKey broadcaster_ref;
26355         CHECK((*env)->GetArrayLength(env, broadcaster) == 33);
26356         (*env)->GetByteArrayRegion(env, broadcaster, 0, 33, broadcaster_ref.compressed_form);
26357         LDKPublicKey countersignatory_ref;
26358         CHECK((*env)->GetArrayLength(env, countersignatory) == 33);
26359         (*env)->GetByteArrayRegion(env, countersignatory, 0, 33, countersignatory_ref.compressed_form);
26360         LDKCVec_u8Z ret_var = make_funding_redeemscript(broadcaster_ref, countersignatory_ref);
26361         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26362         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26363         CVec_u8Z_free(ret_var);
26364         return ret_arr;
26365 }
26366
26367 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) {
26368         unsigned char commitment_txid_arr[32];
26369         CHECK((*env)->GetArrayLength(env, commitment_txid) == 32);
26370         (*env)->GetByteArrayRegion(env, commitment_txid, 0, 32, commitment_txid_arr);
26371         unsigned char (*commitment_txid_ref)[32] = &commitment_txid_arr;
26372         LDKHTLCOutputInCommitment htlc_conv;
26373         htlc_conv.inner = (void*)(htlc & (~1));
26374         htlc_conv.is_owned = false;
26375         LDKPublicKey broadcaster_delayed_payment_key_ref;
26376         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key) == 33);
26377         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key, 0, 33, broadcaster_delayed_payment_key_ref.compressed_form);
26378         LDKPublicKey revocation_key_ref;
26379         CHECK((*env)->GetArrayLength(env, revocation_key) == 33);
26380         (*env)->GetByteArrayRegion(env, revocation_key, 0, 33, revocation_key_ref.compressed_form);
26381         LDKTransaction ret_var = build_htlc_transaction(commitment_txid_ref, feerate_per_kw, contest_delay, &htlc_conv, broadcaster_delayed_payment_key_ref, revocation_key_ref);
26382         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26383         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26384         Transaction_free(ret_var);
26385         return ret_arr;
26386 }
26387
26388 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26389         LDKChannelTransactionParameters this_obj_conv;
26390         this_obj_conv.inner = (void*)(this_obj & (~1));
26391         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26392         ChannelTransactionParameters_free(this_obj_conv);
26393 }
26394
26395 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1holder_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr) {
26396         LDKChannelTransactionParameters this_ptr_conv;
26397         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26398         this_ptr_conv.is_owned = false;
26399         LDKChannelPublicKeys ret_var = ChannelTransactionParameters_get_holder_pubkeys(&this_ptr_conv);
26400         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26401         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26402         uint64_t ret_ref = (uint64_t)ret_var.inner;
26403         if (ret_var.is_owned) {
26404                 ret_ref |= 1;
26405         }
26406         return ret_ref;
26407 }
26408
26409 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1holder_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
26410         LDKChannelTransactionParameters this_ptr_conv;
26411         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26412         this_ptr_conv.is_owned = false;
26413         LDKChannelPublicKeys val_conv;
26414         val_conv.inner = (void*)(val & (~1));
26415         val_conv.is_owned = (val & 1) || (val == 0);
26416         val_conv = ChannelPublicKeys_clone(&val_conv);
26417         ChannelTransactionParameters_set_holder_pubkeys(&this_ptr_conv, val_conv);
26418 }
26419
26420 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1holder_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
26421         LDKChannelTransactionParameters this_ptr_conv;
26422         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26423         this_ptr_conv.is_owned = false;
26424         int16_t ret_val = ChannelTransactionParameters_get_holder_selected_contest_delay(&this_ptr_conv);
26425         return ret_val;
26426 }
26427
26428 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) {
26429         LDKChannelTransactionParameters this_ptr_conv;
26430         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26431         this_ptr_conv.is_owned = false;
26432         ChannelTransactionParameters_set_holder_selected_contest_delay(&this_ptr_conv, val);
26433 }
26434
26435 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1is_1outbound_1from_1holder(JNIEnv *env, jclass clz, int64_t this_ptr) {
26436         LDKChannelTransactionParameters this_ptr_conv;
26437         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26438         this_ptr_conv.is_owned = false;
26439         jboolean ret_val = ChannelTransactionParameters_get_is_outbound_from_holder(&this_ptr_conv);
26440         return ret_val;
26441 }
26442
26443 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1is_1outbound_1from_1holder(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
26444         LDKChannelTransactionParameters this_ptr_conv;
26445         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26446         this_ptr_conv.is_owned = false;
26447         ChannelTransactionParameters_set_is_outbound_from_holder(&this_ptr_conv, val);
26448 }
26449
26450 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1counterparty_1parameters(JNIEnv *env, jclass clz, int64_t this_ptr) {
26451         LDKChannelTransactionParameters this_ptr_conv;
26452         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26453         this_ptr_conv.is_owned = false;
26454         LDKCounterpartyChannelTransactionParameters ret_var = ChannelTransactionParameters_get_counterparty_parameters(&this_ptr_conv);
26455         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26456         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26457         uint64_t ret_ref = (uint64_t)ret_var.inner;
26458         if (ret_var.is_owned) {
26459                 ret_ref |= 1;
26460         }
26461         return ret_ref;
26462 }
26463
26464 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1counterparty_1parameters(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
26465         LDKChannelTransactionParameters this_ptr_conv;
26466         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26467         this_ptr_conv.is_owned = false;
26468         LDKCounterpartyChannelTransactionParameters val_conv;
26469         val_conv.inner = (void*)(val & (~1));
26470         val_conv.is_owned = (val & 1) || (val == 0);
26471         val_conv = CounterpartyChannelTransactionParameters_clone(&val_conv);
26472         ChannelTransactionParameters_set_counterparty_parameters(&this_ptr_conv, val_conv);
26473 }
26474
26475 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
26476         LDKChannelTransactionParameters this_ptr_conv;
26477         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26478         this_ptr_conv.is_owned = false;
26479         LDKOutPoint ret_var = ChannelTransactionParameters_get_funding_outpoint(&this_ptr_conv);
26480         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26481         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26482         uint64_t ret_ref = (uint64_t)ret_var.inner;
26483         if (ret_var.is_owned) {
26484                 ret_ref |= 1;
26485         }
26486         return ret_ref;
26487 }
26488
26489 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
26490         LDKChannelTransactionParameters this_ptr_conv;
26491         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26492         this_ptr_conv.is_owned = false;
26493         LDKOutPoint val_conv;
26494         val_conv.inner = (void*)(val & (~1));
26495         val_conv.is_owned = (val & 1) || (val == 0);
26496         val_conv = OutPoint_clone(&val_conv);
26497         ChannelTransactionParameters_set_funding_outpoint(&this_ptr_conv, val_conv);
26498 }
26499
26500 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) {
26501         LDKChannelPublicKeys holder_pubkeys_arg_conv;
26502         holder_pubkeys_arg_conv.inner = (void*)(holder_pubkeys_arg & (~1));
26503         holder_pubkeys_arg_conv.is_owned = (holder_pubkeys_arg & 1) || (holder_pubkeys_arg == 0);
26504         holder_pubkeys_arg_conv = ChannelPublicKeys_clone(&holder_pubkeys_arg_conv);
26505         LDKCounterpartyChannelTransactionParameters counterparty_parameters_arg_conv;
26506         counterparty_parameters_arg_conv.inner = (void*)(counterparty_parameters_arg & (~1));
26507         counterparty_parameters_arg_conv.is_owned = (counterparty_parameters_arg & 1) || (counterparty_parameters_arg == 0);
26508         counterparty_parameters_arg_conv = CounterpartyChannelTransactionParameters_clone(&counterparty_parameters_arg_conv);
26509         LDKOutPoint funding_outpoint_arg_conv;
26510         funding_outpoint_arg_conv.inner = (void*)(funding_outpoint_arg & (~1));
26511         funding_outpoint_arg_conv.is_owned = (funding_outpoint_arg & 1) || (funding_outpoint_arg == 0);
26512         funding_outpoint_arg_conv = OutPoint_clone(&funding_outpoint_arg_conv);
26513         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);
26514         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26515         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26516         uint64_t ret_ref = (uint64_t)ret_var.inner;
26517         if (ret_var.is_owned) {
26518                 ret_ref |= 1;
26519         }
26520         return ret_ref;
26521 }
26522
26523 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26524         LDKChannelTransactionParameters orig_conv;
26525         orig_conv.inner = (void*)(orig & (~1));
26526         orig_conv.is_owned = false;
26527         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(&orig_conv);
26528         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26529         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26530         uint64_t ret_ref = (uint64_t)ret_var.inner;
26531         if (ret_var.is_owned) {
26532                 ret_ref |= 1;
26533         }
26534         return ret_ref;
26535 }
26536
26537 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26538         LDKCounterpartyChannelTransactionParameters this_obj_conv;
26539         this_obj_conv.inner = (void*)(this_obj & (~1));
26540         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26541         CounterpartyChannelTransactionParameters_free(this_obj_conv);
26542 }
26543
26544 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1get_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr) {
26545         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
26546         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26547         this_ptr_conv.is_owned = false;
26548         LDKChannelPublicKeys ret_var = CounterpartyChannelTransactionParameters_get_pubkeys(&this_ptr_conv);
26549         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26550         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26551         uint64_t ret_ref = (uint64_t)ret_var.inner;
26552         if (ret_var.is_owned) {
26553                 ret_ref |= 1;
26554         }
26555         return ret_ref;
26556 }
26557
26558 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1set_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
26559         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
26560         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26561         this_ptr_conv.is_owned = false;
26562         LDKChannelPublicKeys val_conv;
26563         val_conv.inner = (void*)(val & (~1));
26564         val_conv.is_owned = (val & 1) || (val == 0);
26565         val_conv = ChannelPublicKeys_clone(&val_conv);
26566         CounterpartyChannelTransactionParameters_set_pubkeys(&this_ptr_conv, val_conv);
26567 }
26568
26569 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1get_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
26570         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
26571         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26572         this_ptr_conv.is_owned = false;
26573         int16_t ret_val = CounterpartyChannelTransactionParameters_get_selected_contest_delay(&this_ptr_conv);
26574         return ret_val;
26575 }
26576
26577 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1set_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
26578         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
26579         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26580         this_ptr_conv.is_owned = false;
26581         CounterpartyChannelTransactionParameters_set_selected_contest_delay(&this_ptr_conv, val);
26582 }
26583
26584 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) {
26585         LDKChannelPublicKeys pubkeys_arg_conv;
26586         pubkeys_arg_conv.inner = (void*)(pubkeys_arg & (~1));
26587         pubkeys_arg_conv.is_owned = (pubkeys_arg & 1) || (pubkeys_arg == 0);
26588         pubkeys_arg_conv = ChannelPublicKeys_clone(&pubkeys_arg_conv);
26589         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_new(pubkeys_arg_conv, selected_contest_delay_arg);
26590         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26591         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26592         uint64_t ret_ref = (uint64_t)ret_var.inner;
26593         if (ret_var.is_owned) {
26594                 ret_ref |= 1;
26595         }
26596         return ret_ref;
26597 }
26598
26599 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26600         LDKCounterpartyChannelTransactionParameters orig_conv;
26601         orig_conv.inner = (void*)(orig & (~1));
26602         orig_conv.is_owned = false;
26603         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(&orig_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 jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1is_1populated(JNIEnv *env, jclass clz, int64_t this_arg) {
26614         LDKChannelTransactionParameters this_arg_conv;
26615         this_arg_conv.inner = (void*)(this_arg & (~1));
26616         this_arg_conv.is_owned = false;
26617         jboolean ret_val = ChannelTransactionParameters_is_populated(&this_arg_conv);
26618         return ret_val;
26619 }
26620
26621 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1as_1holder_1broadcastable(JNIEnv *env, jclass clz, int64_t this_arg) {
26622         LDKChannelTransactionParameters this_arg_conv;
26623         this_arg_conv.inner = (void*)(this_arg & (~1));
26624         this_arg_conv.is_owned = false;
26625         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_holder_broadcastable(&this_arg_conv);
26626         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26627         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26628         uint64_t ret_ref = (uint64_t)ret_var.inner;
26629         if (ret_var.is_owned) {
26630                 ret_ref |= 1;
26631         }
26632         return ret_ref;
26633 }
26634
26635 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1as_1counterparty_1broadcastable(JNIEnv *env, jclass clz, int64_t this_arg) {
26636         LDKChannelTransactionParameters this_arg_conv;
26637         this_arg_conv.inner = (void*)(this_arg & (~1));
26638         this_arg_conv.is_owned = false;
26639         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_counterparty_broadcastable(&this_arg_conv);
26640         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26641         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26642         uint64_t ret_ref = (uint64_t)ret_var.inner;
26643         if (ret_var.is_owned) {
26644                 ret_ref |= 1;
26645         }
26646         return ret_ref;
26647 }
26648
26649 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
26650         LDKCounterpartyChannelTransactionParameters obj_conv;
26651         obj_conv.inner = (void*)(obj & (~1));
26652         obj_conv.is_owned = false;
26653         LDKCVec_u8Z ret_var = CounterpartyChannelTransactionParameters_write(&obj_conv);
26654         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26655         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26656         CVec_u8Z_free(ret_var);
26657         return ret_arr;
26658 }
26659
26660 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
26661         LDKu8slice ser_ref;
26662         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
26663         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
26664         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
26665         *ret_conv = CounterpartyChannelTransactionParameters_read(ser_ref);
26666         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
26667         return (uint64_t)ret_conv;
26668 }
26669
26670 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
26671         LDKChannelTransactionParameters obj_conv;
26672         obj_conv.inner = (void*)(obj & (~1));
26673         obj_conv.is_owned = false;
26674         LDKCVec_u8Z ret_var = ChannelTransactionParameters_write(&obj_conv);
26675         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26676         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26677         CVec_u8Z_free(ret_var);
26678         return ret_arr;
26679 }
26680
26681 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
26682         LDKu8slice ser_ref;
26683         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
26684         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
26685         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
26686         *ret_conv = ChannelTransactionParameters_read(ser_ref);
26687         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
26688         return (uint64_t)ret_conv;
26689 }
26690
26691 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26692         LDKDirectedChannelTransactionParameters this_obj_conv;
26693         this_obj_conv.inner = (void*)(this_obj & (~1));
26694         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26695         DirectedChannelTransactionParameters_free(this_obj_conv);
26696 }
26697
26698 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1broadcaster_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
26699         LDKDirectedChannelTransactionParameters this_arg_conv;
26700         this_arg_conv.inner = (void*)(this_arg & (~1));
26701         this_arg_conv.is_owned = false;
26702         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_broadcaster_pubkeys(&this_arg_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_DirectedChannelTransactionParameters_1countersignatory_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
26713         LDKDirectedChannelTransactionParameters this_arg_conv;
26714         this_arg_conv.inner = (void*)(this_arg & (~1));
26715         this_arg_conv.is_owned = false;
26716         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_countersignatory_pubkeys(&this_arg_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 int16_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
26727         LDKDirectedChannelTransactionParameters this_arg_conv;
26728         this_arg_conv.inner = (void*)(this_arg & (~1));
26729         this_arg_conv.is_owned = false;
26730         int16_t ret_val = DirectedChannelTransactionParameters_contest_delay(&this_arg_conv);
26731         return ret_val;
26732 }
26733
26734 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_arg) {
26735         LDKDirectedChannelTransactionParameters this_arg_conv;
26736         this_arg_conv.inner = (void*)(this_arg & (~1));
26737         this_arg_conv.is_owned = false;
26738         jboolean ret_val = DirectedChannelTransactionParameters_is_outbound(&this_arg_conv);
26739         return ret_val;
26740 }
26741
26742 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_arg) {
26743         LDKDirectedChannelTransactionParameters this_arg_conv;
26744         this_arg_conv.inner = (void*)(this_arg & (~1));
26745         this_arg_conv.is_owned = false;
26746         LDKOutPoint ret_var = DirectedChannelTransactionParameters_funding_outpoint(&this_arg_conv);
26747         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26748         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26749         uint64_t ret_ref = (uint64_t)ret_var.inner;
26750         if (ret_var.is_owned) {
26751                 ret_ref |= 1;
26752         }
26753         return ret_ref;
26754 }
26755
26756 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26757         LDKHolderCommitmentTransaction this_obj_conv;
26758         this_obj_conv.inner = (void*)(this_obj & (~1));
26759         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26760         HolderCommitmentTransaction_free(this_obj_conv);
26761 }
26762
26763 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1get_1counterparty_1sig(JNIEnv *env, jclass clz, int64_t this_ptr) {
26764         LDKHolderCommitmentTransaction this_ptr_conv;
26765         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26766         this_ptr_conv.is_owned = false;
26767         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
26768         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, HolderCommitmentTransaction_get_counterparty_sig(&this_ptr_conv).compact_form);
26769         return ret_arr;
26770 }
26771
26772 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1counterparty_1sig(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
26773         LDKHolderCommitmentTransaction this_ptr_conv;
26774         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26775         this_ptr_conv.is_owned = false;
26776         LDKSignature val_ref;
26777         CHECK((*env)->GetArrayLength(env, val) == 64);
26778         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
26779         HolderCommitmentTransaction_set_counterparty_sig(&this_ptr_conv, val_ref);
26780 }
26781
26782 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1counterparty_1htlc_1sigs(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
26783         LDKHolderCommitmentTransaction this_ptr_conv;
26784         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26785         this_ptr_conv.is_owned = false;
26786         LDKCVec_SignatureZ val_constr;
26787         val_constr.datalen = (*env)->GetArrayLength(env, val);
26788         if (val_constr.datalen > 0)
26789                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
26790         else
26791                 val_constr.data = NULL;
26792         for (size_t i = 0; i < val_constr.datalen; i++) {
26793                 int8_tArray val_conv_8 = (*env)->GetObjectArrayElement(env, val, i);
26794                 LDKSignature val_conv_8_ref;
26795                 CHECK((*env)->GetArrayLength(env, val_conv_8) == 64);
26796                 (*env)->GetByteArrayRegion(env, val_conv_8, 0, 64, val_conv_8_ref.compact_form);
26797                 val_constr.data[i] = val_conv_8_ref;
26798         }
26799         HolderCommitmentTransaction_set_counterparty_htlc_sigs(&this_ptr_conv, val_constr);
26800 }
26801
26802 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26803         LDKHolderCommitmentTransaction orig_conv;
26804         orig_conv.inner = (void*)(orig & (~1));
26805         orig_conv.is_owned = false;
26806         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(&orig_conv);
26807         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26808         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26809         uint64_t ret_ref = (uint64_t)ret_var.inner;
26810         if (ret_var.is_owned) {
26811                 ret_ref |= 1;
26812         }
26813         return ret_ref;
26814 }
26815
26816 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
26817         LDKHolderCommitmentTransaction obj_conv;
26818         obj_conv.inner = (void*)(obj & (~1));
26819         obj_conv.is_owned = false;
26820         LDKCVec_u8Z ret_var = HolderCommitmentTransaction_write(&obj_conv);
26821         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26822         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26823         CVec_u8Z_free(ret_var);
26824         return ret_arr;
26825 }
26826
26827 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
26828         LDKu8slice ser_ref;
26829         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
26830         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
26831         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
26832         *ret_conv = HolderCommitmentTransaction_read(ser_ref);
26833         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
26834         return (uint64_t)ret_conv;
26835 }
26836
26837 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) {
26838         LDKCommitmentTransaction commitment_tx_conv;
26839         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
26840         commitment_tx_conv.is_owned = (commitment_tx & 1) || (commitment_tx == 0);
26841         commitment_tx_conv = CommitmentTransaction_clone(&commitment_tx_conv);
26842         LDKSignature counterparty_sig_ref;
26843         CHECK((*env)->GetArrayLength(env, counterparty_sig) == 64);
26844         (*env)->GetByteArrayRegion(env, counterparty_sig, 0, 64, counterparty_sig_ref.compact_form);
26845         LDKCVec_SignatureZ counterparty_htlc_sigs_constr;
26846         counterparty_htlc_sigs_constr.datalen = (*env)->GetArrayLength(env, counterparty_htlc_sigs);
26847         if (counterparty_htlc_sigs_constr.datalen > 0)
26848                 counterparty_htlc_sigs_constr.data = MALLOC(counterparty_htlc_sigs_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
26849         else
26850                 counterparty_htlc_sigs_constr.data = NULL;
26851         for (size_t i = 0; i < counterparty_htlc_sigs_constr.datalen; i++) {
26852                 int8_tArray counterparty_htlc_sigs_conv_8 = (*env)->GetObjectArrayElement(env, counterparty_htlc_sigs, i);
26853                 LDKSignature counterparty_htlc_sigs_conv_8_ref;
26854                 CHECK((*env)->GetArrayLength(env, counterparty_htlc_sigs_conv_8) == 64);
26855                 (*env)->GetByteArrayRegion(env, counterparty_htlc_sigs_conv_8, 0, 64, counterparty_htlc_sigs_conv_8_ref.compact_form);
26856                 counterparty_htlc_sigs_constr.data[i] = counterparty_htlc_sigs_conv_8_ref;
26857         }
26858         LDKPublicKey holder_funding_key_ref;
26859         CHECK((*env)->GetArrayLength(env, holder_funding_key) == 33);
26860         (*env)->GetByteArrayRegion(env, holder_funding_key, 0, 33, holder_funding_key_ref.compressed_form);
26861         LDKPublicKey counterparty_funding_key_ref;
26862         CHECK((*env)->GetArrayLength(env, counterparty_funding_key) == 33);
26863         (*env)->GetByteArrayRegion(env, counterparty_funding_key, 0, 33, counterparty_funding_key_ref.compressed_form);
26864         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_new(commitment_tx_conv, counterparty_sig_ref, counterparty_htlc_sigs_constr, holder_funding_key_ref, counterparty_funding_key_ref);
26865         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26866         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26867         uint64_t ret_ref = (uint64_t)ret_var.inner;
26868         if (ret_var.is_owned) {
26869                 ret_ref |= 1;
26870         }
26871         return ret_ref;
26872 }
26873
26874 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26875         LDKBuiltCommitmentTransaction this_obj_conv;
26876         this_obj_conv.inner = (void*)(this_obj & (~1));
26877         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26878         BuiltCommitmentTransaction_free(this_obj_conv);
26879 }
26880
26881 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1get_1transaction(JNIEnv *env, jclass clz, int64_t this_ptr) {
26882         LDKBuiltCommitmentTransaction this_ptr_conv;
26883         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26884         this_ptr_conv.is_owned = false;
26885         LDKTransaction ret_var = BuiltCommitmentTransaction_get_transaction(&this_ptr_conv);
26886         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26887         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26888         Transaction_free(ret_var);
26889         return ret_arr;
26890 }
26891
26892 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1set_1transaction(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
26893         LDKBuiltCommitmentTransaction this_ptr_conv;
26894         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26895         this_ptr_conv.is_owned = false;
26896         LDKTransaction val_ref;
26897         val_ref.datalen = (*env)->GetArrayLength(env, val);
26898         val_ref.data = MALLOC(val_ref.datalen, "LDKTransaction Bytes");
26899         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
26900         val_ref.data_is_owned = true;
26901         BuiltCommitmentTransaction_set_transaction(&this_ptr_conv, val_ref);
26902 }
26903
26904 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1get_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
26905         LDKBuiltCommitmentTransaction this_ptr_conv;
26906         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26907         this_ptr_conv.is_owned = false;
26908         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
26909         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *BuiltCommitmentTransaction_get_txid(&this_ptr_conv));
26910         return ret_arr;
26911 }
26912
26913 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1set_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
26914         LDKBuiltCommitmentTransaction this_ptr_conv;
26915         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26916         this_ptr_conv.is_owned = false;
26917         LDKThirtyTwoBytes val_ref;
26918         CHECK((*env)->GetArrayLength(env, val) == 32);
26919         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
26920         BuiltCommitmentTransaction_set_txid(&this_ptr_conv, val_ref);
26921 }
26922
26923 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1new(JNIEnv *env, jclass clz, int8_tArray transaction_arg, int8_tArray txid_arg) {
26924         LDKTransaction transaction_arg_ref;
26925         transaction_arg_ref.datalen = (*env)->GetArrayLength(env, transaction_arg);
26926         transaction_arg_ref.data = MALLOC(transaction_arg_ref.datalen, "LDKTransaction Bytes");
26927         (*env)->GetByteArrayRegion(env, transaction_arg, 0, transaction_arg_ref.datalen, transaction_arg_ref.data);
26928         transaction_arg_ref.data_is_owned = true;
26929         LDKThirtyTwoBytes txid_arg_ref;
26930         CHECK((*env)->GetArrayLength(env, txid_arg) == 32);
26931         (*env)->GetByteArrayRegion(env, txid_arg, 0, 32, txid_arg_ref.data);
26932         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_new(transaction_arg_ref, txid_arg_ref);
26933         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26934         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26935         uint64_t ret_ref = (uint64_t)ret_var.inner;
26936         if (ret_var.is_owned) {
26937                 ret_ref |= 1;
26938         }
26939         return ret_ref;
26940 }
26941
26942 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26943         LDKBuiltCommitmentTransaction orig_conv;
26944         orig_conv.inner = (void*)(orig & (~1));
26945         orig_conv.is_owned = false;
26946         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(&orig_conv);
26947         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26948         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26949         uint64_t ret_ref = (uint64_t)ret_var.inner;
26950         if (ret_var.is_owned) {
26951                 ret_ref |= 1;
26952         }
26953         return ret_ref;
26954 }
26955
26956 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
26957         LDKBuiltCommitmentTransaction obj_conv;
26958         obj_conv.inner = (void*)(obj & (~1));
26959         obj_conv.is_owned = false;
26960         LDKCVec_u8Z ret_var = BuiltCommitmentTransaction_write(&obj_conv);
26961         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26962         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26963         CVec_u8Z_free(ret_var);
26964         return ret_arr;
26965 }
26966
26967 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
26968         LDKu8slice ser_ref;
26969         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
26970         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
26971         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
26972         *ret_conv = BuiltCommitmentTransaction_read(ser_ref);
26973         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
26974         return (uint64_t)ret_conv;
26975 }
26976
26977 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) {
26978         LDKBuiltCommitmentTransaction this_arg_conv;
26979         this_arg_conv.inner = (void*)(this_arg & (~1));
26980         this_arg_conv.is_owned = false;
26981         LDKu8slice funding_redeemscript_ref;
26982         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
26983         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
26984         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
26985         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, BuiltCommitmentTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data);
26986         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
26987         return ret_arr;
26988 }
26989
26990 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) {
26991         LDKBuiltCommitmentTransaction this_arg_conv;
26992         this_arg_conv.inner = (void*)(this_arg & (~1));
26993         this_arg_conv.is_owned = false;
26994         unsigned char funding_key_arr[32];
26995         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
26996         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_arr);
26997         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
26998         LDKu8slice funding_redeemscript_ref;
26999         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
27000         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
27001         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
27002         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, BuiltCommitmentTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form);
27003         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
27004         return ret_arr;
27005 }
27006
27007 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27008         LDKClosingTransaction this_obj_conv;
27009         this_obj_conv.inner = (void*)(this_obj & (~1));
27010         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27011         ClosingTransaction_free(this_obj_conv);
27012 }
27013
27014 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27015         LDKClosingTransaction orig_conv;
27016         orig_conv.inner = (void*)(orig & (~1));
27017         orig_conv.is_owned = false;
27018         LDKClosingTransaction ret_var = ClosingTransaction_clone(&orig_conv);
27019         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27020         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27021         uint64_t ret_ref = (uint64_t)ret_var.inner;
27022         if (ret_var.is_owned) {
27023                 ret_ref |= 1;
27024         }
27025         return ret_ref;
27026 }
27027
27028 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1hash(JNIEnv *env, jclass clz, int64_t o) {
27029         LDKClosingTransaction o_conv;
27030         o_conv.inner = (void*)(o & (~1));
27031         o_conv.is_owned = false;
27032         int64_t ret_val = ClosingTransaction_hash(&o_conv);
27033         return ret_val;
27034 }
27035
27036 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) {
27037         LDKCVec_u8Z to_holder_script_ref;
27038         to_holder_script_ref.datalen = (*env)->GetArrayLength(env, to_holder_script);
27039         to_holder_script_ref.data = MALLOC(to_holder_script_ref.datalen, "LDKCVec_u8Z Bytes");
27040         (*env)->GetByteArrayRegion(env, to_holder_script, 0, to_holder_script_ref.datalen, to_holder_script_ref.data);
27041         LDKCVec_u8Z to_counterparty_script_ref;
27042         to_counterparty_script_ref.datalen = (*env)->GetArrayLength(env, to_counterparty_script);
27043         to_counterparty_script_ref.data = MALLOC(to_counterparty_script_ref.datalen, "LDKCVec_u8Z Bytes");
27044         (*env)->GetByteArrayRegion(env, to_counterparty_script, 0, to_counterparty_script_ref.datalen, to_counterparty_script_ref.data);
27045         LDKOutPoint funding_outpoint_conv;
27046         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
27047         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
27048         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
27049         LDKClosingTransaction ret_var = ClosingTransaction_new(to_holder_value_sat, to_counterparty_value_sat, to_holder_script_ref, to_counterparty_script_ref, funding_outpoint_conv);
27050         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27051         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27052         uint64_t ret_ref = (uint64_t)ret_var.inner;
27053         if (ret_var.is_owned) {
27054                 ret_ref |= 1;
27055         }
27056         return ret_ref;
27057 }
27058
27059 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1trust(JNIEnv *env, jclass clz, int64_t this_arg) {
27060         LDKClosingTransaction this_arg_conv;
27061         this_arg_conv.inner = (void*)(this_arg & (~1));
27062         this_arg_conv.is_owned = false;
27063         LDKTrustedClosingTransaction ret_var = ClosingTransaction_trust(&this_arg_conv);
27064         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27065         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27066         uint64_t ret_ref = (uint64_t)ret_var.inner;
27067         if (ret_var.is_owned) {
27068                 ret_ref |= 1;
27069         }
27070         return ret_ref;
27071 }
27072
27073 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1verify(JNIEnv *env, jclass clz, int64_t this_arg, int64_t funding_outpoint) {
27074         LDKClosingTransaction this_arg_conv;
27075         this_arg_conv.inner = (void*)(this_arg & (~1));
27076         this_arg_conv.is_owned = false;
27077         LDKOutPoint funding_outpoint_conv;
27078         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
27079         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
27080         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
27081         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
27082         *ret_conv = ClosingTransaction_verify(&this_arg_conv, funding_outpoint_conv);
27083         return (uint64_t)ret_conv;
27084 }
27085
27086 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1holder_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
27087         LDKClosingTransaction this_arg_conv;
27088         this_arg_conv.inner = (void*)(this_arg & (~1));
27089         this_arg_conv.is_owned = false;
27090         int64_t ret_val = ClosingTransaction_to_holder_value_sat(&this_arg_conv);
27091         return ret_val;
27092 }
27093
27094 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1counterparty_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
27095         LDKClosingTransaction this_arg_conv;
27096         this_arg_conv.inner = (void*)(this_arg & (~1));
27097         this_arg_conv.is_owned = false;
27098         int64_t ret_val = ClosingTransaction_to_counterparty_value_sat(&this_arg_conv);
27099         return ret_val;
27100 }
27101
27102 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1holder_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
27103         LDKClosingTransaction this_arg_conv;
27104         this_arg_conv.inner = (void*)(this_arg & (~1));
27105         this_arg_conv.is_owned = false;
27106         LDKu8slice ret_var = ClosingTransaction_to_holder_script(&this_arg_conv);
27107         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
27108         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
27109         return ret_arr;
27110 }
27111
27112 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1counterparty_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
27113         LDKClosingTransaction this_arg_conv;
27114         this_arg_conv.inner = (void*)(this_arg & (~1));
27115         this_arg_conv.is_owned = false;
27116         LDKu8slice ret_var = ClosingTransaction_to_counterparty_script(&this_arg_conv);
27117         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
27118         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
27119         return ret_arr;
27120 }
27121
27122 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TrustedClosingTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27123         LDKTrustedClosingTransaction this_obj_conv;
27124         this_obj_conv.inner = (void*)(this_obj & (~1));
27125         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27126         TrustedClosingTransaction_free(this_obj_conv);
27127 }
27128
27129 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TrustedClosingTransaction_1built_1transaction(JNIEnv *env, jclass clz, int64_t this_arg) {
27130         LDKTrustedClosingTransaction this_arg_conv;
27131         this_arg_conv.inner = (void*)(this_arg & (~1));
27132         this_arg_conv.is_owned = false;
27133         LDKTransaction ret_var = TrustedClosingTransaction_built_transaction(&this_arg_conv);
27134         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
27135         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
27136         Transaction_free(ret_var);
27137         return ret_arr;
27138 }
27139
27140 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) {
27141         LDKTrustedClosingTransaction this_arg_conv;
27142         this_arg_conv.inner = (void*)(this_arg & (~1));
27143         this_arg_conv.is_owned = false;
27144         LDKu8slice funding_redeemscript_ref;
27145         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
27146         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
27147         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
27148         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, TrustedClosingTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data);
27149         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
27150         return ret_arr;
27151 }
27152
27153 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) {
27154         LDKTrustedClosingTransaction this_arg_conv;
27155         this_arg_conv.inner = (void*)(this_arg & (~1));
27156         this_arg_conv.is_owned = false;
27157         unsigned char funding_key_arr[32];
27158         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
27159         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_arr);
27160         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
27161         LDKu8slice funding_redeemscript_ref;
27162         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
27163         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
27164         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
27165         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, TrustedClosingTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form);
27166         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
27167         return ret_arr;
27168 }
27169
27170 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27171         LDKCommitmentTransaction this_obj_conv;
27172         this_obj_conv.inner = (void*)(this_obj & (~1));
27173         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27174         CommitmentTransaction_free(this_obj_conv);
27175 }
27176
27177 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27178         LDKCommitmentTransaction orig_conv;
27179         orig_conv.inner = (void*)(orig & (~1));
27180         orig_conv.is_owned = false;
27181         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(&orig_conv);
27182         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27183         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27184         uint64_t ret_ref = (uint64_t)ret_var.inner;
27185         if (ret_var.is_owned) {
27186                 ret_ref |= 1;
27187         }
27188         return ret_ref;
27189 }
27190
27191 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
27192         LDKCommitmentTransaction obj_conv;
27193         obj_conv.inner = (void*)(obj & (~1));
27194         obj_conv.is_owned = false;
27195         LDKCVec_u8Z ret_var = CommitmentTransaction_write(&obj_conv);
27196         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
27197         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
27198         CVec_u8Z_free(ret_var);
27199         return ret_arr;
27200 }
27201
27202 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
27203         LDKu8slice ser_ref;
27204         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
27205         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
27206         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
27207         *ret_conv = CommitmentTransaction_read(ser_ref);
27208         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
27209         return (uint64_t)ret_conv;
27210 }
27211
27212 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_arg) {
27213         LDKCommitmentTransaction this_arg_conv;
27214         this_arg_conv.inner = (void*)(this_arg & (~1));
27215         this_arg_conv.is_owned = false;
27216         int64_t ret_val = CommitmentTransaction_commitment_number(&this_arg_conv);
27217         return ret_val;
27218 }
27219
27220 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1to_1broadcaster_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
27221         LDKCommitmentTransaction this_arg_conv;
27222         this_arg_conv.inner = (void*)(this_arg & (~1));
27223         this_arg_conv.is_owned = false;
27224         int64_t ret_val = CommitmentTransaction_to_broadcaster_value_sat(&this_arg_conv);
27225         return ret_val;
27226 }
27227
27228 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1to_1countersignatory_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
27229         LDKCommitmentTransaction this_arg_conv;
27230         this_arg_conv.inner = (void*)(this_arg & (~1));
27231         this_arg_conv.is_owned = false;
27232         int64_t ret_val = CommitmentTransaction_to_countersignatory_value_sat(&this_arg_conv);
27233         return ret_val;
27234 }
27235
27236 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_arg) {
27237         LDKCommitmentTransaction this_arg_conv;
27238         this_arg_conv.inner = (void*)(this_arg & (~1));
27239         this_arg_conv.is_owned = false;
27240         int32_t ret_val = CommitmentTransaction_feerate_per_kw(&this_arg_conv);
27241         return ret_val;
27242 }
27243
27244 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1trust(JNIEnv *env, jclass clz, int64_t this_arg) {
27245         LDKCommitmentTransaction this_arg_conv;
27246         this_arg_conv.inner = (void*)(this_arg & (~1));
27247         this_arg_conv.is_owned = false;
27248         LDKTrustedCommitmentTransaction ret_var = CommitmentTransaction_trust(&this_arg_conv);
27249         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27250         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27251         uint64_t ret_ref = (uint64_t)ret_var.inner;
27252         if (ret_var.is_owned) {
27253                 ret_ref |= 1;
27254         }
27255         return ret_ref;
27256 }
27257
27258 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) {
27259         LDKCommitmentTransaction this_arg_conv;
27260         this_arg_conv.inner = (void*)(this_arg & (~1));
27261         this_arg_conv.is_owned = false;
27262         LDKDirectedChannelTransactionParameters channel_parameters_conv;
27263         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
27264         channel_parameters_conv.is_owned = false;
27265         LDKChannelPublicKeys broadcaster_keys_conv;
27266         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
27267         broadcaster_keys_conv.is_owned = false;
27268         LDKChannelPublicKeys countersignatory_keys_conv;
27269         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
27270         countersignatory_keys_conv.is_owned = false;
27271         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
27272         *ret_conv = CommitmentTransaction_verify(&this_arg_conv, &channel_parameters_conv, &broadcaster_keys_conv, &countersignatory_keys_conv);
27273         return (uint64_t)ret_conv;
27274 }
27275
27276 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27277         LDKTrustedCommitmentTransaction this_obj_conv;
27278         this_obj_conv.inner = (void*)(this_obj & (~1));
27279         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27280         TrustedCommitmentTransaction_free(this_obj_conv);
27281 }
27282
27283 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1txid(JNIEnv *env, jclass clz, int64_t this_arg) {
27284         LDKTrustedCommitmentTransaction this_arg_conv;
27285         this_arg_conv.inner = (void*)(this_arg & (~1));
27286         this_arg_conv.is_owned = false;
27287         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
27288         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, TrustedCommitmentTransaction_txid(&this_arg_conv).data);
27289         return ret_arr;
27290 }
27291
27292 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1built_1transaction(JNIEnv *env, jclass clz, int64_t this_arg) {
27293         LDKTrustedCommitmentTransaction this_arg_conv;
27294         this_arg_conv.inner = (void*)(this_arg & (~1));
27295         this_arg_conv.is_owned = false;
27296         LDKBuiltCommitmentTransaction ret_var = TrustedCommitmentTransaction_built_transaction(&this_arg_conv);
27297         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27298         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27299         uint64_t ret_ref = (uint64_t)ret_var.inner;
27300         if (ret_var.is_owned) {
27301                 ret_ref |= 1;
27302         }
27303         return ret_ref;
27304 }
27305
27306 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1keys(JNIEnv *env, jclass clz, int64_t this_arg) {
27307         LDKTrustedCommitmentTransaction this_arg_conv;
27308         this_arg_conv.inner = (void*)(this_arg & (~1));
27309         this_arg_conv.is_owned = false;
27310         LDKTxCreationKeys ret_var = TrustedCommitmentTransaction_keys(&this_arg_conv);
27311         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27312         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27313         uint64_t ret_ref = (uint64_t)ret_var.inner;
27314         if (ret_var.is_owned) {
27315                 ret_ref |= 1;
27316         }
27317         return ret_ref;
27318 }
27319
27320 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) {
27321         LDKTrustedCommitmentTransaction this_arg_conv;
27322         this_arg_conv.inner = (void*)(this_arg & (~1));
27323         this_arg_conv.is_owned = false;
27324         unsigned char htlc_base_key_arr[32];
27325         CHECK((*env)->GetArrayLength(env, htlc_base_key) == 32);
27326         (*env)->GetByteArrayRegion(env, htlc_base_key, 0, 32, htlc_base_key_arr);
27327         unsigned char (*htlc_base_key_ref)[32] = &htlc_base_key_arr;
27328         LDKDirectedChannelTransactionParameters channel_parameters_conv;
27329         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
27330         channel_parameters_conv.is_owned = false;
27331         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
27332         *ret_conv = TrustedCommitmentTransaction_get_htlc_sigs(&this_arg_conv, htlc_base_key_ref, &channel_parameters_conv);
27333         return (uint64_t)ret_conv;
27334 }
27335
27336 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) {
27337         LDKPublicKey broadcaster_payment_basepoint_ref;
27338         CHECK((*env)->GetArrayLength(env, broadcaster_payment_basepoint) == 33);
27339         (*env)->GetByteArrayRegion(env, broadcaster_payment_basepoint, 0, 33, broadcaster_payment_basepoint_ref.compressed_form);
27340         LDKPublicKey countersignatory_payment_basepoint_ref;
27341         CHECK((*env)->GetArrayLength(env, countersignatory_payment_basepoint) == 33);
27342         (*env)->GetByteArrayRegion(env, countersignatory_payment_basepoint, 0, 33, countersignatory_payment_basepoint_ref.compressed_form);
27343         int64_t ret_val = get_commitment_transaction_number_obscure_factor(broadcaster_payment_basepoint_ref, countersignatory_payment_basepoint_ref, outbound_from_broadcaster);
27344         return ret_val;
27345 }
27346
27347 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
27348         LDKInitFeatures a_conv;
27349         a_conv.inner = (void*)(a & (~1));
27350         a_conv.is_owned = false;
27351         LDKInitFeatures b_conv;
27352         b_conv.inner = (void*)(b & (~1));
27353         b_conv.is_owned = false;
27354         jboolean ret_val = InitFeatures_eq(&a_conv, &b_conv);
27355         return ret_val;
27356 }
27357
27358 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
27359         LDKNodeFeatures a_conv;
27360         a_conv.inner = (void*)(a & (~1));
27361         a_conv.is_owned = false;
27362         LDKNodeFeatures b_conv;
27363         b_conv.inner = (void*)(b & (~1));
27364         b_conv.is_owned = false;
27365         jboolean ret_val = NodeFeatures_eq(&a_conv, &b_conv);
27366         return ret_val;
27367 }
27368
27369 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
27370         LDKChannelFeatures a_conv;
27371         a_conv.inner = (void*)(a & (~1));
27372         a_conv.is_owned = false;
27373         LDKChannelFeatures b_conv;
27374         b_conv.inner = (void*)(b & (~1));
27375         b_conv.is_owned = false;
27376         jboolean ret_val = ChannelFeatures_eq(&a_conv, &b_conv);
27377         return ret_val;
27378 }
27379
27380 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
27381         LDKInvoiceFeatures a_conv;
27382         a_conv.inner = (void*)(a & (~1));
27383         a_conv.is_owned = false;
27384         LDKInvoiceFeatures b_conv;
27385         b_conv.inner = (void*)(b & (~1));
27386         b_conv.is_owned = false;
27387         jboolean ret_val = InvoiceFeatures_eq(&a_conv, &b_conv);
27388         return ret_val;
27389 }
27390
27391 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27392         LDKInitFeatures orig_conv;
27393         orig_conv.inner = (void*)(orig & (~1));
27394         orig_conv.is_owned = false;
27395         LDKInitFeatures ret_var = InitFeatures_clone(&orig_conv);
27396         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27397         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27398         uint64_t ret_ref = (uint64_t)ret_var.inner;
27399         if (ret_var.is_owned) {
27400                 ret_ref |= 1;
27401         }
27402         return ret_ref;
27403 }
27404
27405 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27406         LDKNodeFeatures orig_conv;
27407         orig_conv.inner = (void*)(orig & (~1));
27408         orig_conv.is_owned = false;
27409         LDKNodeFeatures ret_var = NodeFeatures_clone(&orig_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 int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27420         LDKChannelFeatures orig_conv;
27421         orig_conv.inner = (void*)(orig & (~1));
27422         orig_conv.is_owned = false;
27423         LDKChannelFeatures ret_var = ChannelFeatures_clone(&orig_conv);
27424         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27425         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27426         uint64_t ret_ref = (uint64_t)ret_var.inner;
27427         if (ret_var.is_owned) {
27428                 ret_ref |= 1;
27429         }
27430         return ret_ref;
27431 }
27432
27433 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27434         LDKInvoiceFeatures orig_conv;
27435         orig_conv.inner = (void*)(orig & (~1));
27436         orig_conv.is_owned = false;
27437         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(&orig_conv);
27438         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27439         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27440         uint64_t ret_ref = (uint64_t)ret_var.inner;
27441         if (ret_var.is_owned) {
27442                 ret_ref |= 1;
27443         }
27444         return ret_ref;
27445 }
27446
27447 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27448         LDKInitFeatures this_obj_conv;
27449         this_obj_conv.inner = (void*)(this_obj & (~1));
27450         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27451         InitFeatures_free(this_obj_conv);
27452 }
27453
27454 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27455         LDKNodeFeatures this_obj_conv;
27456         this_obj_conv.inner = (void*)(this_obj & (~1));
27457         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27458         NodeFeatures_free(this_obj_conv);
27459 }
27460
27461 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27462         LDKChannelFeatures this_obj_conv;
27463         this_obj_conv.inner = (void*)(this_obj & (~1));
27464         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27465         ChannelFeatures_free(this_obj_conv);
27466 }
27467
27468 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27469         LDKInvoiceFeatures this_obj_conv;
27470         this_obj_conv.inner = (void*)(this_obj & (~1));
27471         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27472         InvoiceFeatures_free(this_obj_conv);
27473 }
27474
27475 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1empty(JNIEnv *env, jclass clz) {
27476         LDKInitFeatures ret_var = InitFeatures_empty();
27477         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27478         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27479         uint64_t ret_ref = (uint64_t)ret_var.inner;
27480         if (ret_var.is_owned) {
27481                 ret_ref |= 1;
27482         }
27483         return ret_ref;
27484 }
27485
27486 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1known(JNIEnv *env, jclass clz) {
27487         LDKInitFeatures ret_var = InitFeatures_known();
27488         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27489         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27490         uint64_t ret_ref = (uint64_t)ret_var.inner;
27491         if (ret_var.is_owned) {
27492                 ret_ref |= 1;
27493         }
27494         return ret_ref;
27495 }
27496
27497 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
27498         LDKInitFeatures this_arg_conv;
27499         this_arg_conv.inner = (void*)(this_arg & (~1));
27500         this_arg_conv.is_owned = false;
27501         jboolean ret_val = InitFeatures_requires_unknown_bits(&this_arg_conv);
27502         return ret_val;
27503 }
27504
27505 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1empty(JNIEnv *env, jclass clz) {
27506         LDKNodeFeatures ret_var = NodeFeatures_empty();
27507         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27508         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27509         uint64_t ret_ref = (uint64_t)ret_var.inner;
27510         if (ret_var.is_owned) {
27511                 ret_ref |= 1;
27512         }
27513         return ret_ref;
27514 }
27515
27516 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1known(JNIEnv *env, jclass clz) {
27517         LDKNodeFeatures ret_var = NodeFeatures_known();
27518         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27519         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27520         uint64_t ret_ref = (uint64_t)ret_var.inner;
27521         if (ret_var.is_owned) {
27522                 ret_ref |= 1;
27523         }
27524         return ret_ref;
27525 }
27526
27527 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
27528         LDKNodeFeatures this_arg_conv;
27529         this_arg_conv.inner = (void*)(this_arg & (~1));
27530         this_arg_conv.is_owned = false;
27531         jboolean ret_val = NodeFeatures_requires_unknown_bits(&this_arg_conv);
27532         return ret_val;
27533 }
27534
27535 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1empty(JNIEnv *env, jclass clz) {
27536         LDKChannelFeatures ret_var = ChannelFeatures_empty();
27537         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27538         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27539         uint64_t ret_ref = (uint64_t)ret_var.inner;
27540         if (ret_var.is_owned) {
27541                 ret_ref |= 1;
27542         }
27543         return ret_ref;
27544 }
27545
27546 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1known(JNIEnv *env, jclass clz) {
27547         LDKChannelFeatures ret_var = ChannelFeatures_known();
27548         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27549         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27550         uint64_t ret_ref = (uint64_t)ret_var.inner;
27551         if (ret_var.is_owned) {
27552                 ret_ref |= 1;
27553         }
27554         return ret_ref;
27555 }
27556
27557 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
27558         LDKChannelFeatures this_arg_conv;
27559         this_arg_conv.inner = (void*)(this_arg & (~1));
27560         this_arg_conv.is_owned = false;
27561         jboolean ret_val = ChannelFeatures_requires_unknown_bits(&this_arg_conv);
27562         return ret_val;
27563 }
27564
27565 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1empty(JNIEnv *env, jclass clz) {
27566         LDKInvoiceFeatures ret_var = InvoiceFeatures_empty();
27567         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27568         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27569         uint64_t ret_ref = (uint64_t)ret_var.inner;
27570         if (ret_var.is_owned) {
27571                 ret_ref |= 1;
27572         }
27573         return ret_ref;
27574 }
27575
27576 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1known(JNIEnv *env, jclass clz) {
27577         LDKInvoiceFeatures ret_var = InvoiceFeatures_known();
27578         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27579         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27580         uint64_t ret_ref = (uint64_t)ret_var.inner;
27581         if (ret_var.is_owned) {
27582                 ret_ref |= 1;
27583         }
27584         return ret_ref;
27585 }
27586
27587 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
27588         LDKInvoiceFeatures this_arg_conv;
27589         this_arg_conv.inner = (void*)(this_arg & (~1));
27590         this_arg_conv.is_owned = false;
27591         jboolean ret_val = InvoiceFeatures_requires_unknown_bits(&this_arg_conv);
27592         return ret_val;
27593 }
27594
27595 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
27596         LDKInitFeatures this_arg_conv;
27597         this_arg_conv.inner = (void*)(this_arg & (~1));
27598         this_arg_conv.is_owned = false;
27599         jboolean ret_val = InitFeatures_supports_payment_secret(&this_arg_conv);
27600         return ret_val;
27601 }
27602
27603 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
27604         LDKNodeFeatures this_arg_conv;
27605         this_arg_conv.inner = (void*)(this_arg & (~1));
27606         this_arg_conv.is_owned = false;
27607         jboolean ret_val = NodeFeatures_supports_payment_secret(&this_arg_conv);
27608         return ret_val;
27609 }
27610
27611 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1supports_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
27612         LDKInvoiceFeatures this_arg_conv;
27613         this_arg_conv.inner = (void*)(this_arg & (~1));
27614         this_arg_conv.is_owned = false;
27615         jboolean ret_val = InvoiceFeatures_supports_payment_secret(&this_arg_conv);
27616         return ret_val;
27617 }
27618
27619 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InitFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
27620         LDKInitFeatures obj_conv;
27621         obj_conv.inner = (void*)(obj & (~1));
27622         obj_conv.is_owned = false;
27623         LDKCVec_u8Z ret_var = InitFeatures_write(&obj_conv);
27624         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
27625         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
27626         CVec_u8Z_free(ret_var);
27627         return ret_arr;
27628 }
27629
27630 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
27631         LDKNodeFeatures obj_conv;
27632         obj_conv.inner = (void*)(obj & (~1));
27633         obj_conv.is_owned = false;
27634         LDKCVec_u8Z ret_var = NodeFeatures_write(&obj_conv);
27635         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
27636         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
27637         CVec_u8Z_free(ret_var);
27638         return ret_arr;
27639 }
27640
27641 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
27642         LDKChannelFeatures obj_conv;
27643         obj_conv.inner = (void*)(obj & (~1));
27644         obj_conv.is_owned = false;
27645         LDKCVec_u8Z ret_var = ChannelFeatures_write(&obj_conv);
27646         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
27647         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
27648         CVec_u8Z_free(ret_var);
27649         return ret_arr;
27650 }
27651
27652 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
27653         LDKInvoiceFeatures obj_conv;
27654         obj_conv.inner = (void*)(obj & (~1));
27655         obj_conv.is_owned = false;
27656         LDKCVec_u8Z ret_var = InvoiceFeatures_write(&obj_conv);
27657         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
27658         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
27659         CVec_u8Z_free(ret_var);
27660         return ret_arr;
27661 }
27662
27663 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
27664         LDKu8slice ser_ref;
27665         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
27666         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
27667         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
27668         *ret_conv = InitFeatures_read(ser_ref);
27669         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
27670         return (uint64_t)ret_conv;
27671 }
27672
27673 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
27674         LDKu8slice ser_ref;
27675         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
27676         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
27677         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
27678         *ret_conv = NodeFeatures_read(ser_ref);
27679         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
27680         return (uint64_t)ret_conv;
27681 }
27682
27683 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
27684         LDKu8slice ser_ref;
27685         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
27686         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
27687         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
27688         *ret_conv = ChannelFeatures_read(ser_ref);
27689         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
27690         return (uint64_t)ret_conv;
27691 }
27692
27693 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
27694         LDKu8slice ser_ref;
27695         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
27696         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
27697         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
27698         *ret_conv = InvoiceFeatures_read(ser_ref);
27699         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
27700         return (uint64_t)ret_conv;
27701 }
27702
27703 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27704         LDKShutdownScript this_obj_conv;
27705         this_obj_conv.inner = (void*)(this_obj & (~1));
27706         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27707         ShutdownScript_free(this_obj_conv);
27708 }
27709
27710 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27711         LDKShutdownScript orig_conv;
27712         orig_conv.inner = (void*)(orig & (~1));
27713         orig_conv.is_owned = false;
27714         LDKShutdownScript ret_var = ShutdownScript_clone(&orig_conv);
27715         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27716         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27717         uint64_t ret_ref = (uint64_t)ret_var.inner;
27718         if (ret_var.is_owned) {
27719                 ret_ref |= 1;
27720         }
27721         return ret_ref;
27722 }
27723
27724 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27725         LDKInvalidShutdownScript this_obj_conv;
27726         this_obj_conv.inner = (void*)(this_obj & (~1));
27727         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27728         InvalidShutdownScript_free(this_obj_conv);
27729 }
27730
27731 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1get_1script(JNIEnv *env, jclass clz, int64_t this_ptr) {
27732         LDKInvalidShutdownScript this_ptr_conv;
27733         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27734         this_ptr_conv.is_owned = false;
27735         LDKu8slice ret_var = InvalidShutdownScript_get_script(&this_ptr_conv);
27736         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
27737         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
27738         return ret_arr;
27739 }
27740
27741 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1set_1script(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
27742         LDKInvalidShutdownScript this_ptr_conv;
27743         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27744         this_ptr_conv.is_owned = false;
27745         LDKCVec_u8Z val_ref;
27746         val_ref.datalen = (*env)->GetArrayLength(env, val);
27747         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
27748         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
27749         InvalidShutdownScript_set_script(&this_ptr_conv, val_ref);
27750 }
27751
27752 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1new(JNIEnv *env, jclass clz, int8_tArray script_arg) {
27753         LDKCVec_u8Z script_arg_ref;
27754         script_arg_ref.datalen = (*env)->GetArrayLength(env, script_arg);
27755         script_arg_ref.data = MALLOC(script_arg_ref.datalen, "LDKCVec_u8Z Bytes");
27756         (*env)->GetByteArrayRegion(env, script_arg, 0, script_arg_ref.datalen, script_arg_ref.data);
27757         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_new(script_arg_ref);
27758         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27759         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27760         uint64_t ret_ref = (uint64_t)ret_var.inner;
27761         if (ret_var.is_owned) {
27762                 ret_ref |= 1;
27763         }
27764         return ret_ref;
27765 }
27766
27767 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27768         LDKInvalidShutdownScript orig_conv;
27769         orig_conv.inner = (void*)(orig & (~1));
27770         orig_conv.is_owned = false;
27771         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_clone(&orig_conv);
27772         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27773         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27774         uint64_t ret_ref = (uint64_t)ret_var.inner;
27775         if (ret_var.is_owned) {
27776                 ret_ref |= 1;
27777         }
27778         return ret_ref;
27779 }
27780
27781 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1write(JNIEnv *env, jclass clz, int64_t obj) {
27782         LDKShutdownScript obj_conv;
27783         obj_conv.inner = (void*)(obj & (~1));
27784         obj_conv.is_owned = false;
27785         LDKCVec_u8Z ret_var = ShutdownScript_write(&obj_conv);
27786         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
27787         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
27788         CVec_u8Z_free(ret_var);
27789         return ret_arr;
27790 }
27791
27792 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
27793         LDKu8slice ser_ref;
27794         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
27795         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
27796         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
27797         *ret_conv = ShutdownScript_read(ser_ref);
27798         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
27799         return (uint64_t)ret_conv;
27800 }
27801
27802 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1new_1p2wpkh(JNIEnv *env, jclass clz, int8_tArray pubkey_hash) {
27803         unsigned char pubkey_hash_arr[20];
27804         CHECK((*env)->GetArrayLength(env, pubkey_hash) == 20);
27805         (*env)->GetByteArrayRegion(env, pubkey_hash, 0, 20, pubkey_hash_arr);
27806         unsigned char (*pubkey_hash_ref)[20] = &pubkey_hash_arr;
27807         LDKShutdownScript ret_var = ShutdownScript_new_p2wpkh(pubkey_hash_ref);
27808         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27809         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27810         uint64_t ret_ref = (uint64_t)ret_var.inner;
27811         if (ret_var.is_owned) {
27812                 ret_ref |= 1;
27813         }
27814         return ret_ref;
27815 }
27816
27817 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1new_1p2wsh(JNIEnv *env, jclass clz, int8_tArray script_hash) {
27818         unsigned char script_hash_arr[32];
27819         CHECK((*env)->GetArrayLength(env, script_hash) == 32);
27820         (*env)->GetByteArrayRegion(env, script_hash, 0, 32, script_hash_arr);
27821         unsigned char (*script_hash_ref)[32] = &script_hash_arr;
27822         LDKShutdownScript ret_var = ShutdownScript_new_p2wsh(script_hash_ref);
27823         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27824         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27825         uint64_t ret_ref = (uint64_t)ret_var.inner;
27826         if (ret_var.is_owned) {
27827                 ret_ref |= 1;
27828         }
27829         return ret_ref;
27830 }
27831
27832 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1new_1witness_1program(JNIEnv *env, jclass clz, int8_t version, int8_tArray program) {
27833         LDKu8slice program_ref;
27834         program_ref.datalen = (*env)->GetArrayLength(env, program);
27835         program_ref.data = (*env)->GetByteArrayElements (env, program, NULL);
27836         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
27837         *ret_conv = ShutdownScript_new_witness_program(version, program_ref);
27838         (*env)->ReleaseByteArrayElements(env, program, (int8_t*)program_ref.data, 0);
27839         return (uint64_t)ret_conv;
27840 }
27841
27842 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1into_1inner(JNIEnv *env, jclass clz, int64_t this_arg) {
27843         LDKShutdownScript this_arg_conv;
27844         this_arg_conv.inner = (void*)(this_arg & (~1));
27845         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
27846         this_arg_conv = ShutdownScript_clone(&this_arg_conv);
27847         LDKCVec_u8Z ret_var = ShutdownScript_into_inner(this_arg_conv);
27848         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
27849         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
27850         CVec_u8Z_free(ret_var);
27851         return ret_arr;
27852 }
27853
27854 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1as_1legacy_1pubkey(JNIEnv *env, jclass clz, int64_t this_arg) {
27855         LDKShutdownScript this_arg_conv;
27856         this_arg_conv.inner = (void*)(this_arg & (~1));
27857         this_arg_conv.is_owned = false;
27858         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
27859         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ShutdownScript_as_legacy_pubkey(&this_arg_conv).compressed_form);
27860         return ret_arr;
27861 }
27862
27863 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1is_1compatible(JNIEnv *env, jclass clz, int64_t this_arg, int64_t features) {
27864         LDKShutdownScript this_arg_conv;
27865         this_arg_conv.inner = (void*)(this_arg & (~1));
27866         this_arg_conv.is_owned = false;
27867         LDKInitFeatures features_conv;
27868         features_conv.inner = (void*)(features & (~1));
27869         features_conv.is_owned = false;
27870         jboolean ret_val = ShutdownScript_is_compatible(&this_arg_conv, &features_conv);
27871         return ret_val;
27872 }
27873
27874 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CustomMessageReader_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
27875         if ((this_ptr & 1) != 0) return;
27876         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
27877         CHECK_ACCESS(this_ptr_ptr);
27878         LDKCustomMessageReader this_ptr_conv = *(LDKCustomMessageReader*)(this_ptr_ptr);
27879         FREE((void*)this_ptr);
27880         CustomMessageReader_free(this_ptr_conv);
27881 }
27882
27883 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Type_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27884         void* orig_ptr = (void*)(((uint64_t)orig) & ~1);
27885         if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
27886         LDKType* orig_conv = (LDKType*)orig_ptr;
27887         LDKType* ret_ret =MALLOC(sizeof(LDKType), "LDKType");
27888         *ret_ret = Type_clone(orig_conv);
27889         return (uint64_t)ret_ret;
27890 }
27891
27892 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Type_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
27893         if ((this_ptr & 1) != 0) return;
27894         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
27895         CHECK_ACCESS(this_ptr_ptr);
27896         LDKType this_ptr_conv = *(LDKType*)(this_ptr_ptr);
27897         FREE((void*)this_ptr);
27898         Type_free(this_ptr_conv);
27899 }
27900
27901 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Score_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
27902         if ((this_ptr & 1) != 0) return;
27903         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
27904         CHECK_ACCESS(this_ptr_ptr);
27905         LDKScore this_ptr_conv = *(LDKScore*)(this_ptr_ptr);
27906         FREE((void*)this_ptr);
27907         Score_free(this_ptr_conv);
27908 }
27909
27910 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeId_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27911         LDKNodeId this_obj_conv;
27912         this_obj_conv.inner = (void*)(this_obj & (~1));
27913         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27914         NodeId_free(this_obj_conv);
27915 }
27916
27917 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27918         LDKNodeId orig_conv;
27919         orig_conv.inner = (void*)(orig & (~1));
27920         orig_conv.is_owned = false;
27921         LDKNodeId ret_var = NodeId_clone(&orig_conv);
27922         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27923         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27924         uint64_t ret_ref = (uint64_t)ret_var.inner;
27925         if (ret_var.is_owned) {
27926                 ret_ref |= 1;
27927         }
27928         return ret_ref;
27929 }
27930
27931 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1from_1pubkey(JNIEnv *env, jclass clz, int8_tArray pubkey) {
27932         LDKPublicKey pubkey_ref;
27933         CHECK((*env)->GetArrayLength(env, pubkey) == 33);
27934         (*env)->GetByteArrayRegion(env, pubkey, 0, 33, pubkey_ref.compressed_form);
27935         LDKNodeId ret_var = NodeId_from_pubkey(pubkey_ref);
27936         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27937         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27938         uint64_t ret_ref = (uint64_t)ret_var.inner;
27939         if (ret_var.is_owned) {
27940                 ret_ref |= 1;
27941         }
27942         return ret_ref;
27943 }
27944
27945 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeId_1as_1slice(JNIEnv *env, jclass clz, int64_t this_arg) {
27946         LDKNodeId this_arg_conv;
27947         this_arg_conv.inner = (void*)(this_arg & (~1));
27948         this_arg_conv.is_owned = false;
27949         LDKu8slice ret_var = NodeId_as_slice(&this_arg_conv);
27950         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
27951         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
27952         return ret_arr;
27953 }
27954
27955 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1hash(JNIEnv *env, jclass clz, int64_t o) {
27956         LDKNodeId o_conv;
27957         o_conv.inner = (void*)(o & (~1));
27958         o_conv.is_owned = false;
27959         int64_t ret_val = NodeId_hash(&o_conv);
27960         return ret_val;
27961 }
27962
27963 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeId_1write(JNIEnv *env, jclass clz, int64_t obj) {
27964         LDKNodeId obj_conv;
27965         obj_conv.inner = (void*)(obj & (~1));
27966         obj_conv.is_owned = false;
27967         LDKCVec_u8Z ret_var = NodeId_write(&obj_conv);
27968         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
27969         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
27970         CVec_u8Z_free(ret_var);
27971         return ret_arr;
27972 }
27973
27974 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
27975         LDKu8slice ser_ref;
27976         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
27977         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
27978         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
27979         *ret_conv = NodeId_read(ser_ref);
27980         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
27981         return (uint64_t)ret_conv;
27982 }
27983
27984 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27985         LDKNetworkGraph this_obj_conv;
27986         this_obj_conv.inner = (void*)(this_obj & (~1));
27987         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27988         NetworkGraph_free(this_obj_conv);
27989 }
27990
27991 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27992         LDKNetworkGraph orig_conv;
27993         orig_conv.inner = (void*)(orig & (~1));
27994         orig_conv.is_owned = false;
27995         LDKNetworkGraph ret_var = NetworkGraph_clone(&orig_conv);
27996         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27997         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27998         uint64_t ret_ref = (uint64_t)ret_var.inner;
27999         if (ret_var.is_owned) {
28000                 ret_ref |= 1;
28001         }
28002         return ret_ref;
28003 }
28004
28005 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReadOnlyNetworkGraph_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28006         LDKReadOnlyNetworkGraph this_obj_conv;
28007         this_obj_conv.inner = (void*)(this_obj & (~1));
28008         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28009         ReadOnlyNetworkGraph_free(this_obj_conv);
28010 }
28011
28012 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
28013         if ((this_ptr & 1) != 0) return;
28014         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
28015         CHECK_ACCESS(this_ptr_ptr);
28016         LDKNetworkUpdate this_ptr_conv = *(LDKNetworkUpdate*)(this_ptr_ptr);
28017         FREE((void*)this_ptr);
28018         NetworkUpdate_free(this_ptr_conv);
28019 }
28020
28021 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28022         LDKNetworkUpdate* orig_conv = (LDKNetworkUpdate*)orig;
28023         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
28024         *ret_copy = NetworkUpdate_clone(orig_conv);
28025         uint64_t ret_ref = (uint64_t)ret_copy;
28026         return ret_ref;
28027 }
28028
28029 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1channel_1update_1message(JNIEnv *env, jclass clz, int64_t msg) {
28030         LDKChannelUpdate msg_conv;
28031         msg_conv.inner = (void*)(msg & (~1));
28032         msg_conv.is_owned = (msg & 1) || (msg == 0);
28033         msg_conv = ChannelUpdate_clone(&msg_conv);
28034         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
28035         *ret_copy = NetworkUpdate_channel_update_message(msg_conv);
28036         uint64_t ret_ref = (uint64_t)ret_copy;
28037         return ret_ref;
28038 }
28039
28040 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1channel_1closed(JNIEnv *env, jclass clz, int64_t short_channel_id, jboolean is_permanent) {
28041         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
28042         *ret_copy = NetworkUpdate_channel_closed(short_channel_id, is_permanent);
28043         uint64_t ret_ref = (uint64_t)ret_copy;
28044         return ret_ref;
28045 }
28046
28047 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1node_1failure(JNIEnv *env, jclass clz, int8_tArray node_id, jboolean is_permanent) {
28048         LDKPublicKey node_id_ref;
28049         CHECK((*env)->GetArrayLength(env, node_id) == 33);
28050         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
28051         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
28052         *ret_copy = NetworkUpdate_node_failure(node_id_ref, is_permanent);
28053         uint64_t ret_ref = (uint64_t)ret_copy;
28054         return ret_ref;
28055 }
28056
28057 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
28058         LDKNetworkUpdate* obj_conv = (LDKNetworkUpdate*)obj;
28059         LDKCVec_u8Z ret_var = NetworkUpdate_write(obj_conv);
28060         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
28061         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
28062         CVec_u8Z_free(ret_var);
28063         return ret_arr;
28064 }
28065
28066 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1as_1EventHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
28067         LDKNetGraphMsgHandler this_arg_conv;
28068         this_arg_conv.inner = (void*)(this_arg & (~1));
28069         this_arg_conv.is_owned = false;
28070         LDKEventHandler* ret_ret =MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
28071         *ret_ret = NetGraphMsgHandler_as_EventHandler(&this_arg_conv);
28072         return (uint64_t)ret_ret;
28073 }
28074
28075 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28076         LDKNetGraphMsgHandler this_obj_conv;
28077         this_obj_conv.inner = (void*)(this_obj & (~1));
28078         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28079         NetGraphMsgHandler_free(this_obj_conv);
28080 }
28081
28082 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1get_1network_1graph(JNIEnv *env, jclass clz, int64_t this_ptr) {
28083         LDKNetGraphMsgHandler this_ptr_conv;
28084         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28085         this_ptr_conv.is_owned = false;
28086         LDKNetworkGraph ret_var = NetGraphMsgHandler_get_network_graph(&this_ptr_conv);
28087         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28088         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28089         uint64_t ret_ref = (uint64_t)ret_var.inner;
28090         if (ret_var.is_owned) {
28091                 ret_ref |= 1;
28092         }
28093         return ret_ref;
28094 }
28095
28096 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1set_1network_1graph(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28097         LDKNetGraphMsgHandler this_ptr_conv;
28098         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28099         this_ptr_conv.is_owned = false;
28100         LDKNetworkGraph val_conv;
28101         val_conv.inner = (void*)(val & (~1));
28102         val_conv.is_owned = (val & 1) || (val == 0);
28103         val_conv = NetworkGraph_clone(&val_conv);
28104         NetGraphMsgHandler_set_network_graph(&this_ptr_conv, val_conv);
28105 }
28106
28107 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) {
28108         LDKNetworkGraph network_graph_conv;
28109         network_graph_conv.inner = (void*)(network_graph & (~1));
28110         network_graph_conv.is_owned = (network_graph & 1) || (network_graph == 0);
28111         network_graph_conv = NetworkGraph_clone(&network_graph_conv);
28112         void* chain_access_ptr = (void*)(((uint64_t)chain_access) & ~1);
28113         CHECK_ACCESS(chain_access_ptr);
28114         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
28115         // Warning: we may need a move here but no clone is available for LDKCOption_AccessZ
28116         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
28117                 // Manually implement clone for Java trait instances
28118                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
28119                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
28120                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
28121                 }
28122         }
28123         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
28124         CHECK_ACCESS(logger_ptr);
28125         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
28126         if (logger_conv.free == LDKLogger_JCalls_free) {
28127                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
28128                 LDKLogger_JCalls_cloned(&logger_conv);
28129         }
28130         LDKNetGraphMsgHandler ret_var = NetGraphMsgHandler_new(network_graph_conv, chain_access_conv, logger_conv);
28131         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28132         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28133         uint64_t ret_ref = (uint64_t)ret_var.inner;
28134         if (ret_var.is_owned) {
28135                 ret_ref |= 1;
28136         }
28137         return ret_ref;
28138 }
28139
28140 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1add_1chain_1access(JNIEnv *env, jclass clz, int64_t this_arg, int64_t chain_access) {
28141         LDKNetGraphMsgHandler this_arg_conv;
28142         this_arg_conv.inner = (void*)(this_arg & (~1));
28143         this_arg_conv.is_owned = false;
28144         void* chain_access_ptr = (void*)(((uint64_t)chain_access) & ~1);
28145         CHECK_ACCESS(chain_access_ptr);
28146         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
28147         // Warning: we may need a move here but no clone is available for LDKCOption_AccessZ
28148         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
28149                 // Manually implement clone for Java trait instances
28150                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
28151                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
28152                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
28153                 }
28154         }
28155         NetGraphMsgHandler_add_chain_access(&this_arg_conv, chain_access_conv);
28156 }
28157
28158 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1as_1RoutingMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
28159         LDKNetGraphMsgHandler this_arg_conv;
28160         this_arg_conv.inner = (void*)(this_arg & (~1));
28161         this_arg_conv.is_owned = false;
28162         LDKRoutingMessageHandler* ret_ret =MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
28163         *ret_ret = NetGraphMsgHandler_as_RoutingMessageHandler(&this_arg_conv);
28164         return (uint64_t)ret_ret;
28165 }
28166
28167 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
28168         LDKNetGraphMsgHandler this_arg_conv;
28169         this_arg_conv.inner = (void*)(this_arg & (~1));
28170         this_arg_conv.is_owned = false;
28171         LDKMessageSendEventsProvider* ret_ret =MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
28172         *ret_ret = NetGraphMsgHandler_as_MessageSendEventsProvider(&this_arg_conv);
28173         return (uint64_t)ret_ret;
28174 }
28175
28176 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28177         LDKDirectionalChannelInfo this_obj_conv;
28178         this_obj_conv.inner = (void*)(this_obj & (~1));
28179         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28180         DirectionalChannelInfo_free(this_obj_conv);
28181 }
28182
28183 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr) {
28184         LDKDirectionalChannelInfo this_ptr_conv;
28185         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28186         this_ptr_conv.is_owned = false;
28187         int32_t ret_val = DirectionalChannelInfo_get_last_update(&this_ptr_conv);
28188         return ret_val;
28189 }
28190
28191 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
28192         LDKDirectionalChannelInfo this_ptr_conv;
28193         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28194         this_ptr_conv.is_owned = false;
28195         DirectionalChannelInfo_set_last_update(&this_ptr_conv, val);
28196 }
28197
28198 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1enabled(JNIEnv *env, jclass clz, int64_t this_ptr) {
28199         LDKDirectionalChannelInfo this_ptr_conv;
28200         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28201         this_ptr_conv.is_owned = false;
28202         jboolean ret_val = DirectionalChannelInfo_get_enabled(&this_ptr_conv);
28203         return ret_val;
28204 }
28205
28206 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1enabled(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
28207         LDKDirectionalChannelInfo this_ptr_conv;
28208         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28209         this_ptr_conv.is_owned = false;
28210         DirectionalChannelInfo_set_enabled(&this_ptr_conv, val);
28211 }
28212
28213 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
28214         LDKDirectionalChannelInfo this_ptr_conv;
28215         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28216         this_ptr_conv.is_owned = false;
28217         int16_t ret_val = DirectionalChannelInfo_get_cltv_expiry_delta(&this_ptr_conv);
28218         return ret_val;
28219 }
28220
28221 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
28222         LDKDirectionalChannelInfo this_ptr_conv;
28223         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28224         this_ptr_conv.is_owned = false;
28225         DirectionalChannelInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
28226 }
28227
28228 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
28229         LDKDirectionalChannelInfo this_ptr_conv;
28230         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28231         this_ptr_conv.is_owned = false;
28232         int64_t ret_val = DirectionalChannelInfo_get_htlc_minimum_msat(&this_ptr_conv);
28233         return ret_val;
28234 }
28235
28236 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28237         LDKDirectionalChannelInfo this_ptr_conv;
28238         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28239         this_ptr_conv.is_owned = false;
28240         DirectionalChannelInfo_set_htlc_minimum_msat(&this_ptr_conv, val);
28241 }
28242
28243 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
28244         LDKDirectionalChannelInfo this_ptr_conv;
28245         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28246         this_ptr_conv.is_owned = false;
28247         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
28248         *ret_copy = DirectionalChannelInfo_get_htlc_maximum_msat(&this_ptr_conv);
28249         uint64_t ret_ref = (uint64_t)ret_copy;
28250         return ret_ref;
28251 }
28252
28253 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28254         LDKDirectionalChannelInfo this_ptr_conv;
28255         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28256         this_ptr_conv.is_owned = false;
28257         void* val_ptr = (void*)(((uint64_t)val) & ~1);
28258         CHECK_ACCESS(val_ptr);
28259         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
28260         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1));
28261         DirectionalChannelInfo_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
28262 }
28263
28264 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
28265         LDKDirectionalChannelInfo this_ptr_conv;
28266         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28267         this_ptr_conv.is_owned = false;
28268         LDKRoutingFees ret_var = DirectionalChannelInfo_get_fees(&this_ptr_conv);
28269         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28270         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28271         uint64_t ret_ref = (uint64_t)ret_var.inner;
28272         if (ret_var.is_owned) {
28273                 ret_ref |= 1;
28274         }
28275         return ret_ref;
28276 }
28277
28278 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1fees(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28279         LDKDirectionalChannelInfo this_ptr_conv;
28280         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28281         this_ptr_conv.is_owned = false;
28282         LDKRoutingFees val_conv;
28283         val_conv.inner = (void*)(val & (~1));
28284         val_conv.is_owned = (val & 1) || (val == 0);
28285         val_conv = RoutingFees_clone(&val_conv);
28286         DirectionalChannelInfo_set_fees(&this_ptr_conv, val_conv);
28287 }
28288
28289 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1last_1update_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
28290         LDKDirectionalChannelInfo this_ptr_conv;
28291         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28292         this_ptr_conv.is_owned = false;
28293         LDKChannelUpdate ret_var = DirectionalChannelInfo_get_last_update_message(&this_ptr_conv);
28294         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28295         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28296         uint64_t ret_ref = (uint64_t)ret_var.inner;
28297         if (ret_var.is_owned) {
28298                 ret_ref |= 1;
28299         }
28300         return ret_ref;
28301 }
28302
28303 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1last_1update_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28304         LDKDirectionalChannelInfo this_ptr_conv;
28305         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28306         this_ptr_conv.is_owned = false;
28307         LDKChannelUpdate val_conv;
28308         val_conv.inner = (void*)(val & (~1));
28309         val_conv.is_owned = (val & 1) || (val == 0);
28310         val_conv = ChannelUpdate_clone(&val_conv);
28311         DirectionalChannelInfo_set_last_update_message(&this_ptr_conv, val_conv);
28312 }
28313
28314 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) {
28315         void* htlc_maximum_msat_arg_ptr = (void*)(((uint64_t)htlc_maximum_msat_arg) & ~1);
28316         CHECK_ACCESS(htlc_maximum_msat_arg_ptr);
28317         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_maximum_msat_arg_ptr);
28318         htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)htlc_maximum_msat_arg) & ~1));
28319         LDKRoutingFees fees_arg_conv;
28320         fees_arg_conv.inner = (void*)(fees_arg & (~1));
28321         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
28322         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
28323         LDKChannelUpdate last_update_message_arg_conv;
28324         last_update_message_arg_conv.inner = (void*)(last_update_message_arg & (~1));
28325         last_update_message_arg_conv.is_owned = (last_update_message_arg & 1) || (last_update_message_arg == 0);
28326         last_update_message_arg_conv = ChannelUpdate_clone(&last_update_message_arg_conv);
28327         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);
28328         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28329         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28330         uint64_t ret_ref = (uint64_t)ret_var.inner;
28331         if (ret_var.is_owned) {
28332                 ret_ref |= 1;
28333         }
28334         return ret_ref;
28335 }
28336
28337 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28338         LDKDirectionalChannelInfo orig_conv;
28339         orig_conv.inner = (void*)(orig & (~1));
28340         orig_conv.is_owned = false;
28341         LDKDirectionalChannelInfo ret_var = DirectionalChannelInfo_clone(&orig_conv);
28342         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28343         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28344         uint64_t ret_ref = (uint64_t)ret_var.inner;
28345         if (ret_var.is_owned) {
28346                 ret_ref |= 1;
28347         }
28348         return ret_ref;
28349 }
28350
28351 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
28352         LDKDirectionalChannelInfo obj_conv;
28353         obj_conv.inner = (void*)(obj & (~1));
28354         obj_conv.is_owned = false;
28355         LDKCVec_u8Z ret_var = DirectionalChannelInfo_write(&obj_conv);
28356         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
28357         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
28358         CVec_u8Z_free(ret_var);
28359         return ret_arr;
28360 }
28361
28362 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
28363         LDKu8slice ser_ref;
28364         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
28365         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
28366         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
28367         *ret_conv = DirectionalChannelInfo_read(ser_ref);
28368         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
28369         return (uint64_t)ret_conv;
28370 }
28371
28372 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28373         LDKChannelInfo this_obj_conv;
28374         this_obj_conv.inner = (void*)(this_obj & (~1));
28375         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28376         ChannelInfo_free(this_obj_conv);
28377 }
28378
28379 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
28380         LDKChannelInfo this_ptr_conv;
28381         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28382         this_ptr_conv.is_owned = false;
28383         LDKChannelFeatures ret_var = ChannelInfo_get_features(&this_ptr_conv);
28384         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28385         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28386         uint64_t ret_ref = (uint64_t)ret_var.inner;
28387         if (ret_var.is_owned) {
28388                 ret_ref |= 1;
28389         }
28390         return ret_ref;
28391 }
28392
28393 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28394         LDKChannelInfo this_ptr_conv;
28395         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28396         this_ptr_conv.is_owned = false;
28397         LDKChannelFeatures val_conv;
28398         val_conv.inner = (void*)(val & (~1));
28399         val_conv.is_owned = (val & 1) || (val == 0);
28400         val_conv = ChannelFeatures_clone(&val_conv);
28401         ChannelInfo_set_features(&this_ptr_conv, val_conv);
28402 }
28403
28404 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1node_1one(JNIEnv *env, jclass clz, int64_t this_ptr) {
28405         LDKChannelInfo this_ptr_conv;
28406         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28407         this_ptr_conv.is_owned = false;
28408         LDKNodeId ret_var = ChannelInfo_get_node_one(&this_ptr_conv);
28409         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28410         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28411         uint64_t ret_ref = (uint64_t)ret_var.inner;
28412         if (ret_var.is_owned) {
28413                 ret_ref |= 1;
28414         }
28415         return ret_ref;
28416 }
28417
28418 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1node_1one(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28419         LDKChannelInfo this_ptr_conv;
28420         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28421         this_ptr_conv.is_owned = false;
28422         LDKNodeId val_conv;
28423         val_conv.inner = (void*)(val & (~1));
28424         val_conv.is_owned = (val & 1) || (val == 0);
28425         val_conv = NodeId_clone(&val_conv);
28426         ChannelInfo_set_node_one(&this_ptr_conv, val_conv);
28427 }
28428
28429 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1one_1to_1two(JNIEnv *env, jclass clz, int64_t this_ptr) {
28430         LDKChannelInfo this_ptr_conv;
28431         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28432         this_ptr_conv.is_owned = false;
28433         LDKDirectionalChannelInfo ret_var = ChannelInfo_get_one_to_two(&this_ptr_conv);
28434         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28435         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28436         uint64_t ret_ref = (uint64_t)ret_var.inner;
28437         if (ret_var.is_owned) {
28438                 ret_ref |= 1;
28439         }
28440         return ret_ref;
28441 }
28442
28443 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1one_1to_1two(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28444         LDKChannelInfo this_ptr_conv;
28445         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28446         this_ptr_conv.is_owned = false;
28447         LDKDirectionalChannelInfo val_conv;
28448         val_conv.inner = (void*)(val & (~1));
28449         val_conv.is_owned = (val & 1) || (val == 0);
28450         val_conv = DirectionalChannelInfo_clone(&val_conv);
28451         ChannelInfo_set_one_to_two(&this_ptr_conv, val_conv);
28452 }
28453
28454 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1node_1two(JNIEnv *env, jclass clz, int64_t this_ptr) {
28455         LDKChannelInfo this_ptr_conv;
28456         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28457         this_ptr_conv.is_owned = false;
28458         LDKNodeId ret_var = ChannelInfo_get_node_two(&this_ptr_conv);
28459         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28460         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28461         uint64_t ret_ref = (uint64_t)ret_var.inner;
28462         if (ret_var.is_owned) {
28463                 ret_ref |= 1;
28464         }
28465         return ret_ref;
28466 }
28467
28468 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1node_1two(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28469         LDKChannelInfo this_ptr_conv;
28470         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28471         this_ptr_conv.is_owned = false;
28472         LDKNodeId val_conv;
28473         val_conv.inner = (void*)(val & (~1));
28474         val_conv.is_owned = (val & 1) || (val == 0);
28475         val_conv = NodeId_clone(&val_conv);
28476         ChannelInfo_set_node_two(&this_ptr_conv, val_conv);
28477 }
28478
28479 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1two_1to_1one(JNIEnv *env, jclass clz, int64_t this_ptr) {
28480         LDKChannelInfo this_ptr_conv;
28481         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28482         this_ptr_conv.is_owned = false;
28483         LDKDirectionalChannelInfo ret_var = ChannelInfo_get_two_to_one(&this_ptr_conv);
28484         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28485         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28486         uint64_t ret_ref = (uint64_t)ret_var.inner;
28487         if (ret_var.is_owned) {
28488                 ret_ref |= 1;
28489         }
28490         return ret_ref;
28491 }
28492
28493 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1two_1to_1one(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28494         LDKChannelInfo this_ptr_conv;
28495         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28496         this_ptr_conv.is_owned = false;
28497         LDKDirectionalChannelInfo val_conv;
28498         val_conv.inner = (void*)(val & (~1));
28499         val_conv.is_owned = (val & 1) || (val == 0);
28500         val_conv = DirectionalChannelInfo_clone(&val_conv);
28501         ChannelInfo_set_two_to_one(&this_ptr_conv, val_conv);
28502 }
28503
28504 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1capacity_1sats(JNIEnv *env, jclass clz, int64_t this_ptr) {
28505         LDKChannelInfo this_ptr_conv;
28506         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28507         this_ptr_conv.is_owned = false;
28508         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
28509         *ret_copy = ChannelInfo_get_capacity_sats(&this_ptr_conv);
28510         uint64_t ret_ref = (uint64_t)ret_copy;
28511         return ret_ref;
28512 }
28513
28514 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1capacity_1sats(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28515         LDKChannelInfo this_ptr_conv;
28516         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28517         this_ptr_conv.is_owned = false;
28518         void* val_ptr = (void*)(((uint64_t)val) & ~1);
28519         CHECK_ACCESS(val_ptr);
28520         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
28521         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1));
28522         ChannelInfo_set_capacity_sats(&this_ptr_conv, val_conv);
28523 }
28524
28525 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
28526         LDKChannelInfo this_ptr_conv;
28527         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28528         this_ptr_conv.is_owned = false;
28529         LDKChannelAnnouncement ret_var = ChannelInfo_get_announcement_message(&this_ptr_conv);
28530         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28531         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28532         uint64_t ret_ref = (uint64_t)ret_var.inner;
28533         if (ret_var.is_owned) {
28534                 ret_ref |= 1;
28535         }
28536         return ret_ref;
28537 }
28538
28539 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28540         LDKChannelInfo this_ptr_conv;
28541         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28542         this_ptr_conv.is_owned = false;
28543         LDKChannelAnnouncement val_conv;
28544         val_conv.inner = (void*)(val & (~1));
28545         val_conv.is_owned = (val & 1) || (val == 0);
28546         val_conv = ChannelAnnouncement_clone(&val_conv);
28547         ChannelInfo_set_announcement_message(&this_ptr_conv, val_conv);
28548 }
28549
28550 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) {
28551         LDKChannelFeatures features_arg_conv;
28552         features_arg_conv.inner = (void*)(features_arg & (~1));
28553         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
28554         features_arg_conv = ChannelFeatures_clone(&features_arg_conv);
28555         LDKNodeId node_one_arg_conv;
28556         node_one_arg_conv.inner = (void*)(node_one_arg & (~1));
28557         node_one_arg_conv.is_owned = (node_one_arg & 1) || (node_one_arg == 0);
28558         node_one_arg_conv = NodeId_clone(&node_one_arg_conv);
28559         LDKDirectionalChannelInfo one_to_two_arg_conv;
28560         one_to_two_arg_conv.inner = (void*)(one_to_two_arg & (~1));
28561         one_to_two_arg_conv.is_owned = (one_to_two_arg & 1) || (one_to_two_arg == 0);
28562         one_to_two_arg_conv = DirectionalChannelInfo_clone(&one_to_two_arg_conv);
28563         LDKNodeId node_two_arg_conv;
28564         node_two_arg_conv.inner = (void*)(node_two_arg & (~1));
28565         node_two_arg_conv.is_owned = (node_two_arg & 1) || (node_two_arg == 0);
28566         node_two_arg_conv = NodeId_clone(&node_two_arg_conv);
28567         LDKDirectionalChannelInfo two_to_one_arg_conv;
28568         two_to_one_arg_conv.inner = (void*)(two_to_one_arg & (~1));
28569         two_to_one_arg_conv.is_owned = (two_to_one_arg & 1) || (two_to_one_arg == 0);
28570         two_to_one_arg_conv = DirectionalChannelInfo_clone(&two_to_one_arg_conv);
28571         void* capacity_sats_arg_ptr = (void*)(((uint64_t)capacity_sats_arg) & ~1);
28572         CHECK_ACCESS(capacity_sats_arg_ptr);
28573         LDKCOption_u64Z capacity_sats_arg_conv = *(LDKCOption_u64Z*)(capacity_sats_arg_ptr);
28574         capacity_sats_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)capacity_sats_arg) & ~1));
28575         LDKChannelAnnouncement announcement_message_arg_conv;
28576         announcement_message_arg_conv.inner = (void*)(announcement_message_arg & (~1));
28577         announcement_message_arg_conv.is_owned = (announcement_message_arg & 1) || (announcement_message_arg == 0);
28578         announcement_message_arg_conv = ChannelAnnouncement_clone(&announcement_message_arg_conv);
28579         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);
28580         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28581         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28582         uint64_t ret_ref = (uint64_t)ret_var.inner;
28583         if (ret_var.is_owned) {
28584                 ret_ref |= 1;
28585         }
28586         return ret_ref;
28587 }
28588
28589 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28590         LDKChannelInfo orig_conv;
28591         orig_conv.inner = (void*)(orig & (~1));
28592         orig_conv.is_owned = false;
28593         LDKChannelInfo ret_var = ChannelInfo_clone(&orig_conv);
28594         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28595         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28596         uint64_t ret_ref = (uint64_t)ret_var.inner;
28597         if (ret_var.is_owned) {
28598                 ret_ref |= 1;
28599         }
28600         return ret_ref;
28601 }
28602
28603 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
28604         LDKChannelInfo obj_conv;
28605         obj_conv.inner = (void*)(obj & (~1));
28606         obj_conv.is_owned = false;
28607         LDKCVec_u8Z ret_var = ChannelInfo_write(&obj_conv);
28608         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
28609         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
28610         CVec_u8Z_free(ret_var);
28611         return ret_arr;
28612 }
28613
28614 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
28615         LDKu8slice ser_ref;
28616         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
28617         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
28618         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
28619         *ret_conv = ChannelInfo_read(ser_ref);
28620         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
28621         return (uint64_t)ret_conv;
28622 }
28623
28624 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28625         LDKRoutingFees this_obj_conv;
28626         this_obj_conv.inner = (void*)(this_obj & (~1));
28627         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28628         RoutingFees_free(this_obj_conv);
28629 }
28630
28631 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1get_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
28632         LDKRoutingFees this_ptr_conv;
28633         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28634         this_ptr_conv.is_owned = false;
28635         int32_t ret_val = RoutingFees_get_base_msat(&this_ptr_conv);
28636         return ret_val;
28637 }
28638
28639 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1set_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
28640         LDKRoutingFees this_ptr_conv;
28641         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28642         this_ptr_conv.is_owned = false;
28643         RoutingFees_set_base_msat(&this_ptr_conv, val);
28644 }
28645
28646 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1get_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
28647         LDKRoutingFees this_ptr_conv;
28648         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28649         this_ptr_conv.is_owned = false;
28650         int32_t ret_val = RoutingFees_get_proportional_millionths(&this_ptr_conv);
28651         return ret_val;
28652 }
28653
28654 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1set_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
28655         LDKRoutingFees this_ptr_conv;
28656         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28657         this_ptr_conv.is_owned = false;
28658         RoutingFees_set_proportional_millionths(&this_ptr_conv, val);
28659 }
28660
28661 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) {
28662         LDKRoutingFees ret_var = RoutingFees_new(base_msat_arg, proportional_millionths_arg);
28663         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28664         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28665         uint64_t ret_ref = (uint64_t)ret_var.inner;
28666         if (ret_var.is_owned) {
28667                 ret_ref |= 1;
28668         }
28669         return ret_ref;
28670 }
28671
28672 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RoutingFees_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
28673         LDKRoutingFees a_conv;
28674         a_conv.inner = (void*)(a & (~1));
28675         a_conv.is_owned = false;
28676         LDKRoutingFees b_conv;
28677         b_conv.inner = (void*)(b & (~1));
28678         b_conv.is_owned = false;
28679         jboolean ret_val = RoutingFees_eq(&a_conv, &b_conv);
28680         return ret_val;
28681 }
28682
28683 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28684         LDKRoutingFees orig_conv;
28685         orig_conv.inner = (void*)(orig & (~1));
28686         orig_conv.is_owned = false;
28687         LDKRoutingFees ret_var = RoutingFees_clone(&orig_conv);
28688         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28689         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28690         uint64_t ret_ref = (uint64_t)ret_var.inner;
28691         if (ret_var.is_owned) {
28692                 ret_ref |= 1;
28693         }
28694         return ret_ref;
28695 }
28696
28697 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1hash(JNIEnv *env, jclass clz, int64_t o) {
28698         LDKRoutingFees o_conv;
28699         o_conv.inner = (void*)(o & (~1));
28700         o_conv.is_owned = false;
28701         int64_t ret_val = RoutingFees_hash(&o_conv);
28702         return ret_val;
28703 }
28704
28705 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RoutingFees_1write(JNIEnv *env, jclass clz, int64_t obj) {
28706         LDKRoutingFees obj_conv;
28707         obj_conv.inner = (void*)(obj & (~1));
28708         obj_conv.is_owned = false;
28709         LDKCVec_u8Z ret_var = RoutingFees_write(&obj_conv);
28710         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
28711         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
28712         CVec_u8Z_free(ret_var);
28713         return ret_arr;
28714 }
28715
28716 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
28717         LDKu8slice ser_ref;
28718         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
28719         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
28720         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
28721         *ret_conv = RoutingFees_read(ser_ref);
28722         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
28723         return (uint64_t)ret_conv;
28724 }
28725
28726 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28727         LDKNodeAnnouncementInfo this_obj_conv;
28728         this_obj_conv.inner = (void*)(this_obj & (~1));
28729         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28730         NodeAnnouncementInfo_free(this_obj_conv);
28731 }
28732
28733 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
28734         LDKNodeAnnouncementInfo this_ptr_conv;
28735         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28736         this_ptr_conv.is_owned = false;
28737         LDKNodeFeatures ret_var = NodeAnnouncementInfo_get_features(&this_ptr_conv);
28738         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28739         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28740         uint64_t ret_ref = (uint64_t)ret_var.inner;
28741         if (ret_var.is_owned) {
28742                 ret_ref |= 1;
28743         }
28744         return ret_ref;
28745 }
28746
28747 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28748         LDKNodeAnnouncementInfo this_ptr_conv;
28749         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28750         this_ptr_conv.is_owned = false;
28751         LDKNodeFeatures val_conv;
28752         val_conv.inner = (void*)(val & (~1));
28753         val_conv.is_owned = (val & 1) || (val == 0);
28754         val_conv = NodeFeatures_clone(&val_conv);
28755         NodeAnnouncementInfo_set_features(&this_ptr_conv, val_conv);
28756 }
28757
28758 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr) {
28759         LDKNodeAnnouncementInfo this_ptr_conv;
28760         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28761         this_ptr_conv.is_owned = false;
28762         int32_t ret_val = NodeAnnouncementInfo_get_last_update(&this_ptr_conv);
28763         return ret_val;
28764 }
28765
28766 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
28767         LDKNodeAnnouncementInfo this_ptr_conv;
28768         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28769         this_ptr_conv.is_owned = false;
28770         NodeAnnouncementInfo_set_last_update(&this_ptr_conv, val);
28771 }
28772
28773 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr) {
28774         LDKNodeAnnouncementInfo this_ptr_conv;
28775         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28776         this_ptr_conv.is_owned = false;
28777         int8_tArray ret_arr = (*env)->NewByteArray(env, 3);
28778         (*env)->SetByteArrayRegion(env, ret_arr, 0, 3, *NodeAnnouncementInfo_get_rgb(&this_ptr_conv));
28779         return ret_arr;
28780 }
28781
28782 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28783         LDKNodeAnnouncementInfo this_ptr_conv;
28784         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28785         this_ptr_conv.is_owned = false;
28786         LDKThreeBytes val_ref;
28787         CHECK((*env)->GetArrayLength(env, val) == 3);
28788         (*env)->GetByteArrayRegion(env, val, 0, 3, val_ref.data);
28789         NodeAnnouncementInfo_set_rgb(&this_ptr_conv, val_ref);
28790 }
28791
28792 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
28793         LDKNodeAnnouncementInfo this_ptr_conv;
28794         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28795         this_ptr_conv.is_owned = false;
28796         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
28797         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *NodeAnnouncementInfo_get_alias(&this_ptr_conv));
28798         return ret_arr;
28799 }
28800
28801 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28802         LDKNodeAnnouncementInfo this_ptr_conv;
28803         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28804         this_ptr_conv.is_owned = false;
28805         LDKThirtyTwoBytes val_ref;
28806         CHECK((*env)->GetArrayLength(env, val) == 32);
28807         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
28808         NodeAnnouncementInfo_set_alias(&this_ptr_conv, val_ref);
28809 }
28810
28811 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1addresses(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
28812         LDKNodeAnnouncementInfo this_ptr_conv;
28813         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28814         this_ptr_conv.is_owned = false;
28815         LDKCVec_NetAddressZ val_constr;
28816         val_constr.datalen = (*env)->GetArrayLength(env, val);
28817         if (val_constr.datalen > 0)
28818                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
28819         else
28820                 val_constr.data = NULL;
28821         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
28822         for (size_t m = 0; m < val_constr.datalen; m++) {
28823                 int64_t val_conv_12 = val_vals[m];
28824                 void* val_conv_12_ptr = (void*)(((uint64_t)val_conv_12) & ~1);
28825                 CHECK_ACCESS(val_conv_12_ptr);
28826                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(val_conv_12_ptr);
28827                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)val_conv_12) & ~1));
28828                 val_constr.data[m] = val_conv_12_conv;
28829         }
28830         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
28831         NodeAnnouncementInfo_set_addresses(&this_ptr_conv, val_constr);
28832 }
28833
28834 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
28835         LDKNodeAnnouncementInfo this_ptr_conv;
28836         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28837         this_ptr_conv.is_owned = false;
28838         LDKNodeAnnouncement ret_var = NodeAnnouncementInfo_get_announcement_message(&this_ptr_conv);
28839         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28840         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28841         uint64_t ret_ref = (uint64_t)ret_var.inner;
28842         if (ret_var.is_owned) {
28843                 ret_ref |= 1;
28844         }
28845         return ret_ref;
28846 }
28847
28848 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28849         LDKNodeAnnouncementInfo this_ptr_conv;
28850         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28851         this_ptr_conv.is_owned = false;
28852         LDKNodeAnnouncement val_conv;
28853         val_conv.inner = (void*)(val & (~1));
28854         val_conv.is_owned = (val & 1) || (val == 0);
28855         val_conv = NodeAnnouncement_clone(&val_conv);
28856         NodeAnnouncementInfo_set_announcement_message(&this_ptr_conv, val_conv);
28857 }
28858
28859 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) {
28860         LDKNodeFeatures features_arg_conv;
28861         features_arg_conv.inner = (void*)(features_arg & (~1));
28862         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
28863         features_arg_conv = NodeFeatures_clone(&features_arg_conv);
28864         LDKThreeBytes rgb_arg_ref;
28865         CHECK((*env)->GetArrayLength(env, rgb_arg) == 3);
28866         (*env)->GetByteArrayRegion(env, rgb_arg, 0, 3, rgb_arg_ref.data);
28867         LDKThirtyTwoBytes alias_arg_ref;
28868         CHECK((*env)->GetArrayLength(env, alias_arg) == 32);
28869         (*env)->GetByteArrayRegion(env, alias_arg, 0, 32, alias_arg_ref.data);
28870         LDKCVec_NetAddressZ addresses_arg_constr;
28871         addresses_arg_constr.datalen = (*env)->GetArrayLength(env, addresses_arg);
28872         if (addresses_arg_constr.datalen > 0)
28873                 addresses_arg_constr.data = MALLOC(addresses_arg_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
28874         else
28875                 addresses_arg_constr.data = NULL;
28876         int64_t* addresses_arg_vals = (*env)->GetLongArrayElements (env, addresses_arg, NULL);
28877         for (size_t m = 0; m < addresses_arg_constr.datalen; m++) {
28878                 int64_t addresses_arg_conv_12 = addresses_arg_vals[m];
28879                 void* addresses_arg_conv_12_ptr = (void*)(((uint64_t)addresses_arg_conv_12) & ~1);
28880                 CHECK_ACCESS(addresses_arg_conv_12_ptr);
28881                 LDKNetAddress addresses_arg_conv_12_conv = *(LDKNetAddress*)(addresses_arg_conv_12_ptr);
28882                 addresses_arg_constr.data[m] = addresses_arg_conv_12_conv;
28883         }
28884         (*env)->ReleaseLongArrayElements(env, addresses_arg, addresses_arg_vals, 0);
28885         LDKNodeAnnouncement announcement_message_arg_conv;
28886         announcement_message_arg_conv.inner = (void*)(announcement_message_arg & (~1));
28887         announcement_message_arg_conv.is_owned = (announcement_message_arg & 1) || (announcement_message_arg == 0);
28888         announcement_message_arg_conv = NodeAnnouncement_clone(&announcement_message_arg_conv);
28889         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_new(features_arg_conv, last_update_arg, rgb_arg_ref, alias_arg_ref, addresses_arg_constr, announcement_message_arg_conv);
28890         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28891         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28892         uint64_t ret_ref = (uint64_t)ret_var.inner;
28893         if (ret_var.is_owned) {
28894                 ret_ref |= 1;
28895         }
28896         return ret_ref;
28897 }
28898
28899 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28900         LDKNodeAnnouncementInfo orig_conv;
28901         orig_conv.inner = (void*)(orig & (~1));
28902         orig_conv.is_owned = false;
28903         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(&orig_conv);
28904         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28905         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28906         uint64_t ret_ref = (uint64_t)ret_var.inner;
28907         if (ret_var.is_owned) {
28908                 ret_ref |= 1;
28909         }
28910         return ret_ref;
28911 }
28912
28913 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
28914         LDKNodeAnnouncementInfo obj_conv;
28915         obj_conv.inner = (void*)(obj & (~1));
28916         obj_conv.is_owned = false;
28917         LDKCVec_u8Z ret_var = NodeAnnouncementInfo_write(&obj_conv);
28918         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
28919         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
28920         CVec_u8Z_free(ret_var);
28921         return ret_arr;
28922 }
28923
28924 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
28925         LDKu8slice ser_ref;
28926         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
28927         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
28928         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
28929         *ret_conv = NodeAnnouncementInfo_read(ser_ref);
28930         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
28931         return (uint64_t)ret_conv;
28932 }
28933
28934 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28935         LDKNodeInfo this_obj_conv;
28936         this_obj_conv.inner = (void*)(this_obj & (~1));
28937         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28938         NodeInfo_free(this_obj_conv);
28939 }
28940
28941 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
28942         LDKNodeInfo this_ptr_conv;
28943         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28944         this_ptr_conv.is_owned = false;
28945         LDKCVec_u64Z val_constr;
28946         val_constr.datalen = (*env)->GetArrayLength(env, val);
28947         if (val_constr.datalen > 0)
28948                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
28949         else
28950                 val_constr.data = NULL;
28951         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
28952         for (size_t g = 0; g < val_constr.datalen; g++) {
28953                 int64_t val_conv_6 = val_vals[g];
28954                 val_constr.data[g] = val_conv_6;
28955         }
28956         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
28957         NodeInfo_set_channels(&this_ptr_conv, val_constr);
28958 }
28959
28960 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1lowest_1inbound_1channel_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
28961         LDKNodeInfo this_ptr_conv;
28962         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28963         this_ptr_conv.is_owned = false;
28964         LDKRoutingFees ret_var = NodeInfo_get_lowest_inbound_channel_fees(&this_ptr_conv);
28965         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28966         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28967         uint64_t ret_ref = (uint64_t)ret_var.inner;
28968         if (ret_var.is_owned) {
28969                 ret_ref |= 1;
28970         }
28971         return ret_ref;
28972 }
28973
28974 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) {
28975         LDKNodeInfo this_ptr_conv;
28976         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28977         this_ptr_conv.is_owned = false;
28978         LDKRoutingFees val_conv;
28979         val_conv.inner = (void*)(val & (~1));
28980         val_conv.is_owned = (val & 1) || (val == 0);
28981         val_conv = RoutingFees_clone(&val_conv);
28982         NodeInfo_set_lowest_inbound_channel_fees(&this_ptr_conv, val_conv);
28983 }
28984
28985 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1announcement_1info(JNIEnv *env, jclass clz, int64_t this_ptr) {
28986         LDKNodeInfo this_ptr_conv;
28987         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28988         this_ptr_conv.is_owned = false;
28989         LDKNodeAnnouncementInfo ret_var = NodeInfo_get_announcement_info(&this_ptr_conv);
28990         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28991         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28992         uint64_t ret_ref = (uint64_t)ret_var.inner;
28993         if (ret_var.is_owned) {
28994                 ret_ref |= 1;
28995         }
28996         return ret_ref;
28997 }
28998
28999 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1announcement_1info(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29000         LDKNodeInfo this_ptr_conv;
29001         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29002         this_ptr_conv.is_owned = false;
29003         LDKNodeAnnouncementInfo val_conv;
29004         val_conv.inner = (void*)(val & (~1));
29005         val_conv.is_owned = (val & 1) || (val == 0);
29006         val_conv = NodeAnnouncementInfo_clone(&val_conv);
29007         NodeInfo_set_announcement_info(&this_ptr_conv, val_conv);
29008 }
29009
29010 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) {
29011         LDKCVec_u64Z channels_arg_constr;
29012         channels_arg_constr.datalen = (*env)->GetArrayLength(env, channels_arg);
29013         if (channels_arg_constr.datalen > 0)
29014                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
29015         else
29016                 channels_arg_constr.data = NULL;
29017         int64_t* channels_arg_vals = (*env)->GetLongArrayElements (env, channels_arg, NULL);
29018         for (size_t g = 0; g < channels_arg_constr.datalen; g++) {
29019                 int64_t channels_arg_conv_6 = channels_arg_vals[g];
29020                 channels_arg_constr.data[g] = channels_arg_conv_6;
29021         }
29022         (*env)->ReleaseLongArrayElements(env, channels_arg, channels_arg_vals, 0);
29023         LDKRoutingFees lowest_inbound_channel_fees_arg_conv;
29024         lowest_inbound_channel_fees_arg_conv.inner = (void*)(lowest_inbound_channel_fees_arg & (~1));
29025         lowest_inbound_channel_fees_arg_conv.is_owned = (lowest_inbound_channel_fees_arg & 1) || (lowest_inbound_channel_fees_arg == 0);
29026         lowest_inbound_channel_fees_arg_conv = RoutingFees_clone(&lowest_inbound_channel_fees_arg_conv);
29027         LDKNodeAnnouncementInfo announcement_info_arg_conv;
29028         announcement_info_arg_conv.inner = (void*)(announcement_info_arg & (~1));
29029         announcement_info_arg_conv.is_owned = (announcement_info_arg & 1) || (announcement_info_arg == 0);
29030         announcement_info_arg_conv = NodeAnnouncementInfo_clone(&announcement_info_arg_conv);
29031         LDKNodeInfo ret_var = NodeInfo_new(channels_arg_constr, lowest_inbound_channel_fees_arg_conv, announcement_info_arg_conv);
29032         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29033         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29034         uint64_t ret_ref = (uint64_t)ret_var.inner;
29035         if (ret_var.is_owned) {
29036                 ret_ref |= 1;
29037         }
29038         return ret_ref;
29039 }
29040
29041 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29042         LDKNodeInfo orig_conv;
29043         orig_conv.inner = (void*)(orig & (~1));
29044         orig_conv.is_owned = false;
29045         LDKNodeInfo ret_var = NodeInfo_clone(&orig_conv);
29046         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29047         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29048         uint64_t ret_ref = (uint64_t)ret_var.inner;
29049         if (ret_var.is_owned) {
29050                 ret_ref |= 1;
29051         }
29052         return ret_ref;
29053 }
29054
29055 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
29056         LDKNodeInfo obj_conv;
29057         obj_conv.inner = (void*)(obj & (~1));
29058         obj_conv.is_owned = false;
29059         LDKCVec_u8Z ret_var = NodeInfo_write(&obj_conv);
29060         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
29061         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
29062         CVec_u8Z_free(ret_var);
29063         return ret_arr;
29064 }
29065
29066 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
29067         LDKu8slice ser_ref;
29068         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
29069         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
29070         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
29071         *ret_conv = NodeInfo_read(ser_ref);
29072         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
29073         return (uint64_t)ret_conv;
29074 }
29075
29076 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1write(JNIEnv *env, jclass clz, int64_t obj) {
29077         LDKNetworkGraph obj_conv;
29078         obj_conv.inner = (void*)(obj & (~1));
29079         obj_conv.is_owned = false;
29080         LDKCVec_u8Z ret_var = NetworkGraph_write(&obj_conv);
29081         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
29082         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
29083         CVec_u8Z_free(ret_var);
29084         return ret_arr;
29085 }
29086
29087 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
29088         LDKu8slice ser_ref;
29089         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
29090         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
29091         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
29092         *ret_conv = NetworkGraph_read(ser_ref);
29093         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
29094         return (uint64_t)ret_conv;
29095 }
29096
29097 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1new(JNIEnv *env, jclass clz, int8_tArray genesis_hash) {
29098         LDKThirtyTwoBytes genesis_hash_ref;
29099         CHECK((*env)->GetArrayLength(env, genesis_hash) == 32);
29100         (*env)->GetByteArrayRegion(env, genesis_hash, 0, 32, genesis_hash_ref.data);
29101         LDKNetworkGraph ret_var = NetworkGraph_new(genesis_hash_ref);
29102         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29103         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29104         uint64_t ret_ref = (uint64_t)ret_var.inner;
29105         if (ret_var.is_owned) {
29106                 ret_ref |= 1;
29107         }
29108         return ret_ref;
29109 }
29110
29111 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1read_1only(JNIEnv *env, jclass clz, int64_t this_arg) {
29112         LDKNetworkGraph this_arg_conv;
29113         this_arg_conv.inner = (void*)(this_arg & (~1));
29114         this_arg_conv.is_owned = false;
29115         LDKReadOnlyNetworkGraph ret_var = NetworkGraph_read_only(&this_arg_conv);
29116         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29117         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29118         uint64_t ret_ref = (uint64_t)ret_var.inner;
29119         if (ret_var.is_owned) {
29120                 ret_ref |= 1;
29121         }
29122         return ret_ref;
29123 }
29124
29125 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) {
29126         LDKNetworkGraph this_arg_conv;
29127         this_arg_conv.inner = (void*)(this_arg & (~1));
29128         this_arg_conv.is_owned = false;
29129         LDKNodeAnnouncement msg_conv;
29130         msg_conv.inner = (void*)(msg & (~1));
29131         msg_conv.is_owned = false;
29132         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
29133         *ret_conv = NetworkGraph_update_node_from_announcement(&this_arg_conv, &msg_conv);
29134         return (uint64_t)ret_conv;
29135 }
29136
29137 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) {
29138         LDKNetworkGraph this_arg_conv;
29139         this_arg_conv.inner = (void*)(this_arg & (~1));
29140         this_arg_conv.is_owned = false;
29141         LDKUnsignedNodeAnnouncement msg_conv;
29142         msg_conv.inner = (void*)(msg & (~1));
29143         msg_conv.is_owned = false;
29144         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
29145         *ret_conv = NetworkGraph_update_node_from_unsigned_announcement(&this_arg_conv, &msg_conv);
29146         return (uint64_t)ret_conv;
29147 }
29148
29149 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) {
29150         LDKNetworkGraph this_arg_conv;
29151         this_arg_conv.inner = (void*)(this_arg & (~1));
29152         this_arg_conv.is_owned = false;
29153         LDKChannelAnnouncement msg_conv;
29154         msg_conv.inner = (void*)(msg & (~1));
29155         msg_conv.is_owned = false;
29156         void* chain_access_ptr = (void*)(((uint64_t)chain_access) & ~1);
29157         CHECK_ACCESS(chain_access_ptr);
29158         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
29159         // Warning: we may need a move here but no clone is available for LDKCOption_AccessZ
29160         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
29161                 // Manually implement clone for Java trait instances
29162                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
29163                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29164                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
29165                 }
29166         }
29167         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
29168         *ret_conv = NetworkGraph_update_channel_from_announcement(&this_arg_conv, &msg_conv, chain_access_conv);
29169         return (uint64_t)ret_conv;
29170 }
29171
29172 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) {
29173         LDKNetworkGraph this_arg_conv;
29174         this_arg_conv.inner = (void*)(this_arg & (~1));
29175         this_arg_conv.is_owned = false;
29176         LDKUnsignedChannelAnnouncement msg_conv;
29177         msg_conv.inner = (void*)(msg & (~1));
29178         msg_conv.is_owned = false;
29179         void* chain_access_ptr = (void*)(((uint64_t)chain_access) & ~1);
29180         CHECK_ACCESS(chain_access_ptr);
29181         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
29182         // Warning: we may need a move here but no clone is available for LDKCOption_AccessZ
29183         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
29184                 // Manually implement clone for Java trait instances
29185                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
29186                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29187                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
29188                 }
29189         }
29190         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
29191         *ret_conv = NetworkGraph_update_channel_from_unsigned_announcement(&this_arg_conv, &msg_conv, chain_access_conv);
29192         return (uint64_t)ret_conv;
29193 }
29194
29195 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) {
29196         LDKNetworkGraph this_arg_conv;
29197         this_arg_conv.inner = (void*)(this_arg & (~1));
29198         this_arg_conv.is_owned = false;
29199         NetworkGraph_close_channel_from_update(&this_arg_conv, short_channel_id, is_permanent);
29200 }
29201
29202 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) {
29203         LDKNetworkGraph this_arg_conv;
29204         this_arg_conv.inner = (void*)(this_arg & (~1));
29205         this_arg_conv.is_owned = false;
29206         LDKPublicKey _node_id_ref;
29207         CHECK((*env)->GetArrayLength(env, _node_id) == 33);
29208         (*env)->GetByteArrayRegion(env, _node_id, 0, 33, _node_id_ref.compressed_form);
29209         NetworkGraph_fail_node(&this_arg_conv, _node_id_ref, is_permanent);
29210 }
29211
29212 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1update_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
29213         LDKNetworkGraph this_arg_conv;
29214         this_arg_conv.inner = (void*)(this_arg & (~1));
29215         this_arg_conv.is_owned = false;
29216         LDKChannelUpdate msg_conv;
29217         msg_conv.inner = (void*)(msg & (~1));
29218         msg_conv.is_owned = false;
29219         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
29220         *ret_conv = NetworkGraph_update_channel(&this_arg_conv, &msg_conv);
29221         return (uint64_t)ret_conv;
29222 }
29223
29224 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1update_1channel_1unsigned(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
29225         LDKNetworkGraph this_arg_conv;
29226         this_arg_conv.inner = (void*)(this_arg & (~1));
29227         this_arg_conv.is_owned = false;
29228         LDKUnsignedChannelUpdate msg_conv;
29229         msg_conv.inner = (void*)(msg & (~1));
29230         msg_conv.is_owned = false;
29231         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
29232         *ret_conv = NetworkGraph_update_channel_unsigned(&this_arg_conv, &msg_conv);
29233         return (uint64_t)ret_conv;
29234 }
29235
29236 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReadOnlyNetworkGraph_1get_1addresses(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray pubkey) {
29237         LDKReadOnlyNetworkGraph this_arg_conv;
29238         this_arg_conv.inner = (void*)(this_arg & (~1));
29239         this_arg_conv.is_owned = false;
29240         LDKPublicKey pubkey_ref;
29241         CHECK((*env)->GetArrayLength(env, pubkey) == 33);
29242         (*env)->GetByteArrayRegion(env, pubkey, 0, 33, pubkey_ref.compressed_form);
29243         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
29244         *ret_copy = ReadOnlyNetworkGraph_get_addresses(&this_arg_conv, pubkey_ref);
29245         uint64_t ret_ref = (uint64_t)ret_copy;
29246         return ret_ref;
29247 }
29248
29249 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29250         LDKRouteHop this_obj_conv;
29251         this_obj_conv.inner = (void*)(this_obj & (~1));
29252         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29253         RouteHop_free(this_obj_conv);
29254 }
29255
29256 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
29257         LDKRouteHop this_ptr_conv;
29258         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29259         this_ptr_conv.is_owned = false;
29260         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
29261         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RouteHop_get_pubkey(&this_ptr_conv).compressed_form);
29262         return ret_arr;
29263 }
29264
29265 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
29266         LDKRouteHop this_ptr_conv;
29267         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29268         this_ptr_conv.is_owned = false;
29269         LDKPublicKey val_ref;
29270         CHECK((*env)->GetArrayLength(env, val) == 33);
29271         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
29272         RouteHop_set_pubkey(&this_ptr_conv, val_ref);
29273 }
29274
29275 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1node_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
29276         LDKRouteHop this_ptr_conv;
29277         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29278         this_ptr_conv.is_owned = false;
29279         LDKNodeFeatures ret_var = RouteHop_get_node_features(&this_ptr_conv);
29280         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29281         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29282         uint64_t ret_ref = (uint64_t)ret_var.inner;
29283         if (ret_var.is_owned) {
29284                 ret_ref |= 1;
29285         }
29286         return ret_ref;
29287 }
29288
29289 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1node_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29290         LDKRouteHop this_ptr_conv;
29291         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29292         this_ptr_conv.is_owned = false;
29293         LDKNodeFeatures val_conv;
29294         val_conv.inner = (void*)(val & (~1));
29295         val_conv.is_owned = (val & 1) || (val == 0);
29296         val_conv = NodeFeatures_clone(&val_conv);
29297         RouteHop_set_node_features(&this_ptr_conv, val_conv);
29298 }
29299
29300 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
29301         LDKRouteHop this_ptr_conv;
29302         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29303         this_ptr_conv.is_owned = false;
29304         int64_t ret_val = RouteHop_get_short_channel_id(&this_ptr_conv);
29305         return ret_val;
29306 }
29307
29308 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29309         LDKRouteHop this_ptr_conv;
29310         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29311         this_ptr_conv.is_owned = false;
29312         RouteHop_set_short_channel_id(&this_ptr_conv, val);
29313 }
29314
29315 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1channel_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
29316         LDKRouteHop this_ptr_conv;
29317         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29318         this_ptr_conv.is_owned = false;
29319         LDKChannelFeatures ret_var = RouteHop_get_channel_features(&this_ptr_conv);
29320         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29321         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29322         uint64_t ret_ref = (uint64_t)ret_var.inner;
29323         if (ret_var.is_owned) {
29324                 ret_ref |= 1;
29325         }
29326         return ret_ref;
29327 }
29328
29329 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1channel_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29330         LDKRouteHop this_ptr_conv;
29331         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29332         this_ptr_conv.is_owned = false;
29333         LDKChannelFeatures val_conv;
29334         val_conv.inner = (void*)(val & (~1));
29335         val_conv.is_owned = (val & 1) || (val == 0);
29336         val_conv = ChannelFeatures_clone(&val_conv);
29337         RouteHop_set_channel_features(&this_ptr_conv, val_conv);
29338 }
29339
29340 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1fee_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
29341         LDKRouteHop this_ptr_conv;
29342         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29343         this_ptr_conv.is_owned = false;
29344         int64_t ret_val = RouteHop_get_fee_msat(&this_ptr_conv);
29345         return ret_val;
29346 }
29347
29348 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1fee_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29349         LDKRouteHop this_ptr_conv;
29350         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29351         this_ptr_conv.is_owned = false;
29352         RouteHop_set_fee_msat(&this_ptr_conv, val);
29353 }
29354
29355 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
29356         LDKRouteHop this_ptr_conv;
29357         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29358         this_ptr_conv.is_owned = false;
29359         int32_t ret_val = RouteHop_get_cltv_expiry_delta(&this_ptr_conv);
29360         return ret_val;
29361 }
29362
29363 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
29364         LDKRouteHop this_ptr_conv;
29365         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29366         this_ptr_conv.is_owned = false;
29367         RouteHop_set_cltv_expiry_delta(&this_ptr_conv, val);
29368 }
29369
29370 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) {
29371         LDKPublicKey pubkey_arg_ref;
29372         CHECK((*env)->GetArrayLength(env, pubkey_arg) == 33);
29373         (*env)->GetByteArrayRegion(env, pubkey_arg, 0, 33, pubkey_arg_ref.compressed_form);
29374         LDKNodeFeatures node_features_arg_conv;
29375         node_features_arg_conv.inner = (void*)(node_features_arg & (~1));
29376         node_features_arg_conv.is_owned = (node_features_arg & 1) || (node_features_arg == 0);
29377         node_features_arg_conv = NodeFeatures_clone(&node_features_arg_conv);
29378         LDKChannelFeatures channel_features_arg_conv;
29379         channel_features_arg_conv.inner = (void*)(channel_features_arg & (~1));
29380         channel_features_arg_conv.is_owned = (channel_features_arg & 1) || (channel_features_arg == 0);
29381         channel_features_arg_conv = ChannelFeatures_clone(&channel_features_arg_conv);
29382         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);
29383         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29384         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29385         uint64_t ret_ref = (uint64_t)ret_var.inner;
29386         if (ret_var.is_owned) {
29387                 ret_ref |= 1;
29388         }
29389         return ret_ref;
29390 }
29391
29392 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29393         LDKRouteHop orig_conv;
29394         orig_conv.inner = (void*)(orig & (~1));
29395         orig_conv.is_owned = false;
29396         LDKRouteHop ret_var = RouteHop_clone(&orig_conv);
29397         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29398         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29399         uint64_t ret_ref = (uint64_t)ret_var.inner;
29400         if (ret_var.is_owned) {
29401                 ret_ref |= 1;
29402         }
29403         return ret_ref;
29404 }
29405
29406 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1hash(JNIEnv *env, jclass clz, int64_t o) {
29407         LDKRouteHop o_conv;
29408         o_conv.inner = (void*)(o & (~1));
29409         o_conv.is_owned = false;
29410         int64_t ret_val = RouteHop_hash(&o_conv);
29411         return ret_val;
29412 }
29413
29414 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHop_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
29415         LDKRouteHop a_conv;
29416         a_conv.inner = (void*)(a & (~1));
29417         a_conv.is_owned = false;
29418         LDKRouteHop b_conv;
29419         b_conv.inner = (void*)(b & (~1));
29420         b_conv.is_owned = false;
29421         jboolean ret_val = RouteHop_eq(&a_conv, &b_conv);
29422         return ret_val;
29423 }
29424
29425 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHop_1write(JNIEnv *env, jclass clz, int64_t obj) {
29426         LDKRouteHop obj_conv;
29427         obj_conv.inner = (void*)(obj & (~1));
29428         obj_conv.is_owned = false;
29429         LDKCVec_u8Z ret_var = RouteHop_write(&obj_conv);
29430         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
29431         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
29432         CVec_u8Z_free(ret_var);
29433         return ret_arr;
29434 }
29435
29436 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
29437         LDKu8slice ser_ref;
29438         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
29439         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
29440         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
29441         *ret_conv = RouteHop_read(ser_ref);
29442         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
29443         return (uint64_t)ret_conv;
29444 }
29445
29446 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29447         LDKRoute this_obj_conv;
29448         this_obj_conv.inner = (void*)(this_obj & (~1));
29449         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29450         Route_free(this_obj_conv);
29451 }
29452
29453 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_Route_1get_1paths(JNIEnv *env, jclass clz, int64_t this_ptr) {
29454         LDKRoute this_ptr_conv;
29455         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29456         this_ptr_conv.is_owned = false;
29457         LDKCVec_CVec_RouteHopZZ ret_var = Route_get_paths(&this_ptr_conv);
29458         jobjectArray ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_J_clz, NULL);
29459         ;
29460         for (size_t m = 0; m < ret_var.datalen; m++) {
29461                 LDKCVec_RouteHopZ ret_conv_12_var = ret_var.data[m];
29462                 int64_tArray ret_conv_12_arr = (*env)->NewLongArray(env, ret_conv_12_var.datalen);
29463                 int64_t *ret_conv_12_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_conv_12_arr, NULL);
29464                 for (size_t k = 0; k < ret_conv_12_var.datalen; k++) {
29465                         LDKRouteHop ret_conv_12_conv_10_var = ret_conv_12_var.data[k];
29466                         CHECK((((uint64_t)ret_conv_12_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29467                         CHECK((((uint64_t)&ret_conv_12_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29468                         uint64_t ret_conv_12_conv_10_ref = (uint64_t)ret_conv_12_conv_10_var.inner;
29469                         if (ret_conv_12_conv_10_var.is_owned) {
29470                                 ret_conv_12_conv_10_ref |= 1;
29471                         }
29472                         ret_conv_12_arr_ptr[k] = ret_conv_12_conv_10_ref;
29473                 }
29474                 (*env)->ReleasePrimitiveArrayCritical(env, ret_conv_12_arr, ret_conv_12_arr_ptr, 0);
29475                 FREE(ret_conv_12_var.data);
29476                 (*env)->SetObjectArrayElement(env, ret_arr, m, ret_conv_12_arr);
29477         }
29478         FREE(ret_var.data);
29479         return ret_arr;
29480 }
29481
29482 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1set_1paths(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
29483         LDKRoute this_ptr_conv;
29484         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29485         this_ptr_conv.is_owned = false;
29486         LDKCVec_CVec_RouteHopZZ val_constr;
29487         val_constr.datalen = (*env)->GetArrayLength(env, val);
29488         if (val_constr.datalen > 0)
29489                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
29490         else
29491                 val_constr.data = NULL;
29492         for (size_t m = 0; m < val_constr.datalen; m++) {
29493                 int64_tArray val_conv_12 = (*env)->GetObjectArrayElement(env, val, m);
29494                 LDKCVec_RouteHopZ val_conv_12_constr;
29495                 val_conv_12_constr.datalen = (*env)->GetArrayLength(env, val_conv_12);
29496                 if (val_conv_12_constr.datalen > 0)
29497                         val_conv_12_constr.data = MALLOC(val_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
29498                 else
29499                         val_conv_12_constr.data = NULL;
29500                 int64_t* val_conv_12_vals = (*env)->GetLongArrayElements (env, val_conv_12, NULL);
29501                 for (size_t k = 0; k < val_conv_12_constr.datalen; k++) {
29502                         int64_t val_conv_12_conv_10 = val_conv_12_vals[k];
29503                         LDKRouteHop val_conv_12_conv_10_conv;
29504                         val_conv_12_conv_10_conv.inner = (void*)(val_conv_12_conv_10 & (~1));
29505                         val_conv_12_conv_10_conv.is_owned = (val_conv_12_conv_10 & 1) || (val_conv_12_conv_10 == 0);
29506                         val_conv_12_conv_10_conv = RouteHop_clone(&val_conv_12_conv_10_conv);
29507                         val_conv_12_constr.data[k] = val_conv_12_conv_10_conv;
29508                 }
29509                 (*env)->ReleaseLongArrayElements(env, val_conv_12, val_conv_12_vals, 0);
29510                 val_constr.data[m] = val_conv_12_constr;
29511         }
29512         Route_set_paths(&this_ptr_conv, val_constr);
29513 }
29514
29515 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1new(JNIEnv *env, jclass clz, jobjectArray paths_arg) {
29516         LDKCVec_CVec_RouteHopZZ paths_arg_constr;
29517         paths_arg_constr.datalen = (*env)->GetArrayLength(env, paths_arg);
29518         if (paths_arg_constr.datalen > 0)
29519                 paths_arg_constr.data = MALLOC(paths_arg_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
29520         else
29521                 paths_arg_constr.data = NULL;
29522         for (size_t m = 0; m < paths_arg_constr.datalen; m++) {
29523                 int64_tArray paths_arg_conv_12 = (*env)->GetObjectArrayElement(env, paths_arg, m);
29524                 LDKCVec_RouteHopZ paths_arg_conv_12_constr;
29525                 paths_arg_conv_12_constr.datalen = (*env)->GetArrayLength(env, paths_arg_conv_12);
29526                 if (paths_arg_conv_12_constr.datalen > 0)
29527                         paths_arg_conv_12_constr.data = MALLOC(paths_arg_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
29528                 else
29529                         paths_arg_conv_12_constr.data = NULL;
29530                 int64_t* paths_arg_conv_12_vals = (*env)->GetLongArrayElements (env, paths_arg_conv_12, NULL);
29531                 for (size_t k = 0; k < paths_arg_conv_12_constr.datalen; k++) {
29532                         int64_t paths_arg_conv_12_conv_10 = paths_arg_conv_12_vals[k];
29533                         LDKRouteHop paths_arg_conv_12_conv_10_conv;
29534                         paths_arg_conv_12_conv_10_conv.inner = (void*)(paths_arg_conv_12_conv_10 & (~1));
29535                         paths_arg_conv_12_conv_10_conv.is_owned = (paths_arg_conv_12_conv_10 & 1) || (paths_arg_conv_12_conv_10 == 0);
29536                         paths_arg_conv_12_conv_10_conv = RouteHop_clone(&paths_arg_conv_12_conv_10_conv);
29537                         paths_arg_conv_12_constr.data[k] = paths_arg_conv_12_conv_10_conv;
29538                 }
29539                 (*env)->ReleaseLongArrayElements(env, paths_arg_conv_12, paths_arg_conv_12_vals, 0);
29540                 paths_arg_constr.data[m] = paths_arg_conv_12_constr;
29541         }
29542         LDKRoute ret_var = Route_new(paths_arg_constr);
29543         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29544         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29545         uint64_t ret_ref = (uint64_t)ret_var.inner;
29546         if (ret_var.is_owned) {
29547                 ret_ref |= 1;
29548         }
29549         return ret_ref;
29550 }
29551
29552 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29553         LDKRoute orig_conv;
29554         orig_conv.inner = (void*)(orig & (~1));
29555         orig_conv.is_owned = false;
29556         LDKRoute ret_var = Route_clone(&orig_conv);
29557         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29558         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29559         uint64_t ret_ref = (uint64_t)ret_var.inner;
29560         if (ret_var.is_owned) {
29561                 ret_ref |= 1;
29562         }
29563         return ret_ref;
29564 }
29565
29566 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1hash(JNIEnv *env, jclass clz, int64_t o) {
29567         LDKRoute o_conv;
29568         o_conv.inner = (void*)(o & (~1));
29569         o_conv.is_owned = false;
29570         int64_t ret_val = Route_hash(&o_conv);
29571         return ret_val;
29572 }
29573
29574 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Route_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
29575         LDKRoute a_conv;
29576         a_conv.inner = (void*)(a & (~1));
29577         a_conv.is_owned = false;
29578         LDKRoute b_conv;
29579         b_conv.inner = (void*)(b & (~1));
29580         b_conv.is_owned = false;
29581         jboolean ret_val = Route_eq(&a_conv, &b_conv);
29582         return ret_val;
29583 }
29584
29585 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1get_1total_1fees(JNIEnv *env, jclass clz, int64_t this_arg) {
29586         LDKRoute this_arg_conv;
29587         this_arg_conv.inner = (void*)(this_arg & (~1));
29588         this_arg_conv.is_owned = false;
29589         int64_t ret_val = Route_get_total_fees(&this_arg_conv);
29590         return ret_val;
29591 }
29592
29593 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1get_1total_1amount(JNIEnv *env, jclass clz, int64_t this_arg) {
29594         LDKRoute this_arg_conv;
29595         this_arg_conv.inner = (void*)(this_arg & (~1));
29596         this_arg_conv.is_owned = false;
29597         int64_t ret_val = Route_get_total_amount(&this_arg_conv);
29598         return ret_val;
29599 }
29600
29601 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Route_1write(JNIEnv *env, jclass clz, int64_t obj) {
29602         LDKRoute obj_conv;
29603         obj_conv.inner = (void*)(obj & (~1));
29604         obj_conv.is_owned = false;
29605         LDKCVec_u8Z ret_var = Route_write(&obj_conv);
29606         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
29607         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
29608         CVec_u8Z_free(ret_var);
29609         return ret_arr;
29610 }
29611
29612 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
29613         LDKu8slice ser_ref;
29614         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
29615         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
29616         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
29617         *ret_conv = Route_read(ser_ref);
29618         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
29619         return (uint64_t)ret_conv;
29620 }
29621
29622 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29623         LDKRouteHint this_obj_conv;
29624         this_obj_conv.inner = (void*)(this_obj & (~1));
29625         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29626         RouteHint_free(this_obj_conv);
29627 }
29628
29629 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29630         LDKRouteHint orig_conv;
29631         orig_conv.inner = (void*)(orig & (~1));
29632         orig_conv.is_owned = false;
29633         LDKRouteHint ret_var = RouteHint_clone(&orig_conv);
29634         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29635         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29636         uint64_t ret_ref = (uint64_t)ret_var.inner;
29637         if (ret_var.is_owned) {
29638                 ret_ref |= 1;
29639         }
29640         return ret_ref;
29641 }
29642
29643 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1hash(JNIEnv *env, jclass clz, int64_t o) {
29644         LDKRouteHint o_conv;
29645         o_conv.inner = (void*)(o & (~1));
29646         o_conv.is_owned = false;
29647         int64_t ret_val = RouteHint_hash(&o_conv);
29648         return ret_val;
29649 }
29650
29651 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHint_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
29652         LDKRouteHint a_conv;
29653         a_conv.inner = (void*)(a & (~1));
29654         a_conv.is_owned = false;
29655         LDKRouteHint b_conv;
29656         b_conv.inner = (void*)(b & (~1));
29657         b_conv.is_owned = false;
29658         jboolean ret_val = RouteHint_eq(&a_conv, &b_conv);
29659         return ret_val;
29660 }
29661
29662 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29663         LDKRouteHintHop this_obj_conv;
29664         this_obj_conv.inner = (void*)(this_obj & (~1));
29665         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29666         RouteHintHop_free(this_obj_conv);
29667 }
29668
29669 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1src_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
29670         LDKRouteHintHop this_ptr_conv;
29671         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29672         this_ptr_conv.is_owned = false;
29673         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
29674         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RouteHintHop_get_src_node_id(&this_ptr_conv).compressed_form);
29675         return ret_arr;
29676 }
29677
29678 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1src_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
29679         LDKRouteHintHop this_ptr_conv;
29680         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29681         this_ptr_conv.is_owned = false;
29682         LDKPublicKey val_ref;
29683         CHECK((*env)->GetArrayLength(env, val) == 33);
29684         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
29685         RouteHintHop_set_src_node_id(&this_ptr_conv, val_ref);
29686 }
29687
29688 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
29689         LDKRouteHintHop this_ptr_conv;
29690         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29691         this_ptr_conv.is_owned = false;
29692         int64_t ret_val = RouteHintHop_get_short_channel_id(&this_ptr_conv);
29693         return ret_val;
29694 }
29695
29696 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29697         LDKRouteHintHop this_ptr_conv;
29698         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29699         this_ptr_conv.is_owned = false;
29700         RouteHintHop_set_short_channel_id(&this_ptr_conv, val);
29701 }
29702
29703 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
29704         LDKRouteHintHop this_ptr_conv;
29705         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29706         this_ptr_conv.is_owned = false;
29707         LDKRoutingFees ret_var = RouteHintHop_get_fees(&this_ptr_conv);
29708         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29709         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29710         uint64_t ret_ref = (uint64_t)ret_var.inner;
29711         if (ret_var.is_owned) {
29712                 ret_ref |= 1;
29713         }
29714         return ret_ref;
29715 }
29716
29717 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1fees(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29718         LDKRouteHintHop this_ptr_conv;
29719         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29720         this_ptr_conv.is_owned = false;
29721         LDKRoutingFees val_conv;
29722         val_conv.inner = (void*)(val & (~1));
29723         val_conv.is_owned = (val & 1) || (val == 0);
29724         val_conv = RoutingFees_clone(&val_conv);
29725         RouteHintHop_set_fees(&this_ptr_conv, val_conv);
29726 }
29727
29728 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
29729         LDKRouteHintHop this_ptr_conv;
29730         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29731         this_ptr_conv.is_owned = false;
29732         int16_t ret_val = RouteHintHop_get_cltv_expiry_delta(&this_ptr_conv);
29733         return ret_val;
29734 }
29735
29736 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
29737         LDKRouteHintHop this_ptr_conv;
29738         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29739         this_ptr_conv.is_owned = false;
29740         RouteHintHop_set_cltv_expiry_delta(&this_ptr_conv, val);
29741 }
29742
29743 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
29744         LDKRouteHintHop this_ptr_conv;
29745         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29746         this_ptr_conv.is_owned = false;
29747         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
29748         *ret_copy = RouteHintHop_get_htlc_minimum_msat(&this_ptr_conv);
29749         uint64_t ret_ref = (uint64_t)ret_copy;
29750         return ret_ref;
29751 }
29752
29753 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29754         LDKRouteHintHop this_ptr_conv;
29755         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29756         this_ptr_conv.is_owned = false;
29757         void* val_ptr = (void*)(((uint64_t)val) & ~1);
29758         CHECK_ACCESS(val_ptr);
29759         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
29760         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1));
29761         RouteHintHop_set_htlc_minimum_msat(&this_ptr_conv, val_conv);
29762 }
29763
29764 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
29765         LDKRouteHintHop this_ptr_conv;
29766         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29767         this_ptr_conv.is_owned = false;
29768         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
29769         *ret_copy = RouteHintHop_get_htlc_maximum_msat(&this_ptr_conv);
29770         uint64_t ret_ref = (uint64_t)ret_copy;
29771         return ret_ref;
29772 }
29773
29774 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29775         LDKRouteHintHop this_ptr_conv;
29776         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29777         this_ptr_conv.is_owned = false;
29778         void* val_ptr = (void*)(((uint64_t)val) & ~1);
29779         CHECK_ACCESS(val_ptr);
29780         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
29781         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1));
29782         RouteHintHop_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
29783 }
29784
29785 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) {
29786         LDKPublicKey src_node_id_arg_ref;
29787         CHECK((*env)->GetArrayLength(env, src_node_id_arg) == 33);
29788         (*env)->GetByteArrayRegion(env, src_node_id_arg, 0, 33, src_node_id_arg_ref.compressed_form);
29789         LDKRoutingFees fees_arg_conv;
29790         fees_arg_conv.inner = (void*)(fees_arg & (~1));
29791         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
29792         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
29793         void* htlc_minimum_msat_arg_ptr = (void*)(((uint64_t)htlc_minimum_msat_arg) & ~1);
29794         CHECK_ACCESS(htlc_minimum_msat_arg_ptr);
29795         LDKCOption_u64Z htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_minimum_msat_arg_ptr);
29796         htlc_minimum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)htlc_minimum_msat_arg) & ~1));
29797         void* htlc_maximum_msat_arg_ptr = (void*)(((uint64_t)htlc_maximum_msat_arg) & ~1);
29798         CHECK_ACCESS(htlc_maximum_msat_arg_ptr);
29799         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_maximum_msat_arg_ptr);
29800         htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)htlc_maximum_msat_arg) & ~1));
29801         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);
29802         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29803         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29804         uint64_t ret_ref = (uint64_t)ret_var.inner;
29805         if (ret_var.is_owned) {
29806                 ret_ref |= 1;
29807         }
29808         return ret_ref;
29809 }
29810
29811 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29812         LDKRouteHintHop orig_conv;
29813         orig_conv.inner = (void*)(orig & (~1));
29814         orig_conv.is_owned = false;
29815         LDKRouteHintHop ret_var = RouteHintHop_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_RouteHintHop_1hash(JNIEnv *env, jclass clz, int64_t o) {
29826         LDKRouteHintHop o_conv;
29827         o_conv.inner = (void*)(o & (~1));
29828         o_conv.is_owned = false;
29829         int64_t ret_val = RouteHintHop_hash(&o_conv);
29830         return ret_val;
29831 }
29832
29833 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
29834         LDKRouteHintHop a_conv;
29835         a_conv.inner = (void*)(a & (~1));
29836         a_conv.is_owned = false;
29837         LDKRouteHintHop b_conv;
29838         b_conv.inner = (void*)(b & (~1));
29839         b_conv.is_owned = false;
29840         jboolean ret_val = RouteHintHop_eq(&a_conv, &b_conv);
29841         return ret_val;
29842 }
29843
29844 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) {
29845         LDKPublicKey our_node_pubkey_ref;
29846         CHECK((*env)->GetArrayLength(env, our_node_pubkey) == 33);
29847         (*env)->GetByteArrayRegion(env, our_node_pubkey, 0, 33, our_node_pubkey_ref.compressed_form);
29848         LDKNetworkGraph network_conv;
29849         network_conv.inner = (void*)(network & (~1));
29850         network_conv.is_owned = false;
29851         LDKPublicKey payee_ref;
29852         CHECK((*env)->GetArrayLength(env, payee) == 33);
29853         (*env)->GetByteArrayRegion(env, payee, 0, 33, payee_ref.compressed_form);
29854         LDKCVec_ChannelDetailsZ first_hops_constr;
29855         LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
29856         if (first_hops != NULL) {
29857                 first_hops_constr.datalen = (*env)->GetArrayLength(env, first_hops);
29858                 if (first_hops_constr.datalen > 0)
29859                         first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
29860                 else
29861                         first_hops_constr.data = NULL;
29862                 int64_t* first_hops_vals = (*env)->GetLongArrayElements (env, first_hops, NULL);
29863                 for (size_t q = 0; q < first_hops_constr.datalen; q++) {
29864                         int64_t first_hops_conv_16 = first_hops_vals[q];
29865                         LDKChannelDetails first_hops_conv_16_conv;
29866                         first_hops_conv_16_conv.inner = (void*)(first_hops_conv_16 & (~1));
29867                         first_hops_conv_16_conv.is_owned = (first_hops_conv_16 & 1) || (first_hops_conv_16 == 0);
29868                         first_hops_constr.data[q] = first_hops_conv_16_conv;
29869                 }
29870                 (*env)->ReleaseLongArrayElements(env, first_hops, first_hops_vals, 0);
29871                 first_hops_ptr = &first_hops_constr;
29872         }
29873         LDKCVec_RouteHintZ last_hops_constr;
29874         last_hops_constr.datalen = (*env)->GetArrayLength(env, last_hops);
29875         if (last_hops_constr.datalen > 0)
29876                 last_hops_constr.data = MALLOC(last_hops_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
29877         else
29878                 last_hops_constr.data = NULL;
29879         int64_t* last_hops_vals = (*env)->GetLongArrayElements (env, last_hops, NULL);
29880         for (size_t l = 0; l < last_hops_constr.datalen; l++) {
29881                 int64_t last_hops_conv_11 = last_hops_vals[l];
29882                 LDKRouteHint last_hops_conv_11_conv;
29883                 last_hops_conv_11_conv.inner = (void*)(last_hops_conv_11 & (~1));
29884                 last_hops_conv_11_conv.is_owned = (last_hops_conv_11 & 1) || (last_hops_conv_11 == 0);
29885                 last_hops_conv_11_conv = RouteHint_clone(&last_hops_conv_11_conv);
29886                 last_hops_constr.data[l] = last_hops_conv_11_conv;
29887         }
29888         (*env)->ReleaseLongArrayElements(env, last_hops, last_hops_vals, 0);
29889         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
29890         CHECK_ACCESS(logger_ptr);
29891         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
29892         if (logger_conv.free == LDKLogger_JCalls_free) {
29893                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29894                 LDKLogger_JCalls_cloned(&logger_conv);
29895         }
29896         void* scorer_ptr = (void*)(((uint64_t)scorer) & ~1);
29897         if (!(scorer & 1)) { CHECK_ACCESS(scorer_ptr); }
29898         LDKScore* scorer_conv = (LDKScore*)scorer_ptr;
29899         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
29900         *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);
29901         if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
29902         return (uint64_t)ret_conv;
29903 }
29904
29905 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) {
29906         LDKPublicKey our_node_pubkey_ref;
29907         CHECK((*env)->GetArrayLength(env, our_node_pubkey) == 33);
29908         (*env)->GetByteArrayRegion(env, our_node_pubkey, 0, 33, our_node_pubkey_ref.compressed_form);
29909         LDKNetworkGraph network_conv;
29910         network_conv.inner = (void*)(network & (~1));
29911         network_conv.is_owned = false;
29912         LDKPublicKey payee_ref;
29913         CHECK((*env)->GetArrayLength(env, payee) == 33);
29914         (*env)->GetByteArrayRegion(env, payee, 0, 33, payee_ref.compressed_form);
29915         LDKInvoiceFeatures payee_features_conv;
29916         payee_features_conv.inner = (void*)(payee_features & (~1));
29917         payee_features_conv.is_owned = (payee_features & 1) || (payee_features == 0);
29918         payee_features_conv = InvoiceFeatures_clone(&payee_features_conv);
29919         LDKCVec_ChannelDetailsZ first_hops_constr;
29920         LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
29921         if (first_hops != NULL) {
29922                 first_hops_constr.datalen = (*env)->GetArrayLength(env, first_hops);
29923                 if (first_hops_constr.datalen > 0)
29924                         first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
29925                 else
29926                         first_hops_constr.data = NULL;
29927                 int64_t* first_hops_vals = (*env)->GetLongArrayElements (env, first_hops, NULL);
29928                 for (size_t q = 0; q < first_hops_constr.datalen; q++) {
29929                         int64_t first_hops_conv_16 = first_hops_vals[q];
29930                         LDKChannelDetails first_hops_conv_16_conv;
29931                         first_hops_conv_16_conv.inner = (void*)(first_hops_conv_16 & (~1));
29932                         first_hops_conv_16_conv.is_owned = (first_hops_conv_16 & 1) || (first_hops_conv_16 == 0);
29933                         first_hops_constr.data[q] = first_hops_conv_16_conv;
29934                 }
29935                 (*env)->ReleaseLongArrayElements(env, first_hops, first_hops_vals, 0);
29936                 first_hops_ptr = &first_hops_constr;
29937         }
29938         LDKCVec_RouteHintZ last_hops_constr;
29939         last_hops_constr.datalen = (*env)->GetArrayLength(env, last_hops);
29940         if (last_hops_constr.datalen > 0)
29941                 last_hops_constr.data = MALLOC(last_hops_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
29942         else
29943                 last_hops_constr.data = NULL;
29944         int64_t* last_hops_vals = (*env)->GetLongArrayElements (env, last_hops, NULL);
29945         for (size_t l = 0; l < last_hops_constr.datalen; l++) {
29946                 int64_t last_hops_conv_11 = last_hops_vals[l];
29947                 LDKRouteHint last_hops_conv_11_conv;
29948                 last_hops_conv_11_conv.inner = (void*)(last_hops_conv_11 & (~1));
29949                 last_hops_conv_11_conv.is_owned = (last_hops_conv_11 & 1) || (last_hops_conv_11 == 0);
29950                 last_hops_conv_11_conv = RouteHint_clone(&last_hops_conv_11_conv);
29951                 last_hops_constr.data[l] = last_hops_conv_11_conv;
29952         }
29953         (*env)->ReleaseLongArrayElements(env, last_hops, last_hops_vals, 0);
29954         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
29955         CHECK_ACCESS(logger_ptr);
29956         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
29957         if (logger_conv.free == LDKLogger_JCalls_free) {
29958                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29959                 LDKLogger_JCalls_cloned(&logger_conv);
29960         }
29961         void* scorer_ptr = (void*)(((uint64_t)scorer) & ~1);
29962         if (!(scorer & 1)) { CHECK_ACCESS(scorer_ptr); }
29963         LDKScore* scorer_conv = (LDKScore*)scorer_ptr;
29964         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
29965         *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);
29966         if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
29967         return (uint64_t)ret_conv;
29968 }
29969
29970 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Scorer_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29971         LDKScorer this_obj_conv;
29972         this_obj_conv.inner = (void*)(this_obj & (~1));
29973         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29974         Scorer_free(this_obj_conv);
29975 }
29976
29977 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Scorer_1new(JNIEnv *env, jclass clz, int64_t base_penalty_msat) {
29978         LDKScorer ret_var = Scorer_new(base_penalty_msat);
29979         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29980         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29981         uint64_t ret_ref = (uint64_t)ret_var.inner;
29982         if (ret_var.is_owned) {
29983                 ret_ref |= 1;
29984         }
29985         return ret_ref;
29986 }
29987
29988 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Scorer_1default(JNIEnv *env, jclass clz) {
29989         LDKScorer ret_var = Scorer_default();
29990         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29991         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29992         uint64_t ret_ref = (uint64_t)ret_var.inner;
29993         if (ret_var.is_owned) {
29994                 ret_ref |= 1;
29995         }
29996         return ret_ref;
29997 }
29998
29999 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Scorer_1as_1Score(JNIEnv *env, jclass clz, int64_t this_arg) {
30000         LDKScorer this_arg_conv;
30001         this_arg_conv.inner = (void*)(this_arg & (~1));
30002         this_arg_conv.is_owned = false;
30003         LDKScore* ret_ret =MALLOC(sizeof(LDKScore), "LDKScore");
30004         *ret_ret = Scorer_as_Score(&this_arg_conv);
30005         return (uint64_t)ret_ret;
30006 }
30007
30008 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
30009         LDKFilesystemPersister this_obj_conv;
30010         this_obj_conv.inner = (void*)(this_obj & (~1));
30011         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30012         FilesystemPersister_free(this_obj_conv);
30013 }
30014
30015 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1new(JNIEnv *env, jclass clz, jstring path_to_channel_data) {
30016         LDKStr path_to_channel_data_conv = java_to_owned_str(env, path_to_channel_data);
30017         LDKFilesystemPersister ret_var = FilesystemPersister_new(path_to_channel_data_conv);
30018         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30019         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30020         uint64_t ret_ref = (uint64_t)ret_var.inner;
30021         if (ret_var.is_owned) {
30022                 ret_ref |= 1;
30023         }
30024         return ret_ref;
30025 }
30026
30027 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1get_1data_1dir(JNIEnv *env, jclass clz, int64_t this_arg) {
30028         LDKFilesystemPersister this_arg_conv;
30029         this_arg_conv.inner = (void*)(this_arg & (~1));
30030         this_arg_conv.is_owned = false;
30031         LDKStr ret_str = FilesystemPersister_get_data_dir(&this_arg_conv);
30032         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
30033         Str_free(ret_str);
30034         return ret_conv;
30035 }
30036
30037 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1persist_1manager(JNIEnv *env, jclass clz, jstring data_dir, int64_t manager) {
30038         LDKStr data_dir_conv = java_to_owned_str(env, data_dir);
30039         LDKChannelManager manager_conv;
30040         manager_conv.inner = (void*)(manager & (~1));
30041         manager_conv.is_owned = false;
30042         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
30043         *ret_conv = FilesystemPersister_persist_manager(data_dir_conv, &manager_conv);
30044         return (uint64_t)ret_conv;
30045 }
30046
30047 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1read_1channelmonitors(JNIEnv *env, jclass clz, int64_t this_arg, int64_t keys_manager) {
30048         LDKFilesystemPersister this_arg_conv;
30049         this_arg_conv.inner = (void*)(this_arg & (~1));
30050         this_arg_conv.is_owned = false;
30051         void* keys_manager_ptr = (void*)(((uint64_t)keys_manager) & ~1);
30052         CHECK_ACCESS(keys_manager_ptr);
30053         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
30054         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
30055                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30056                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
30057         }
30058         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
30059         *ret_conv = FilesystemPersister_read_channelmonitors(&this_arg_conv, keys_manager_conv);
30060         return (uint64_t)ret_conv;
30061 }
30062
30063 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1as_1Persist(JNIEnv *env, jclass clz, int64_t this_arg) {
30064         LDKFilesystemPersister this_arg_conv;
30065         this_arg_conv.inner = (void*)(this_arg & (~1));
30066         this_arg_conv.is_owned = false;
30067         LDKPersist* ret_ret =MALLOC(sizeof(LDKPersist), "LDKPersist");
30068         *ret_ret = FilesystemPersister_as_Persist(&this_arg_conv);
30069         return (uint64_t)ret_ret;
30070 }
30071
30072 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
30073         LDKBackgroundProcessor this_obj_conv;
30074         this_obj_conv.inner = (void*)(this_obj & (~1));
30075         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30076         BackgroundProcessor_free(this_obj_conv);
30077 }
30078
30079 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerPersister_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
30080         if ((this_ptr & 1) != 0) return;
30081         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
30082         CHECK_ACCESS(this_ptr_ptr);
30083         LDKChannelManagerPersister this_ptr_conv = *(LDKChannelManagerPersister*)(this_ptr_ptr);
30084         FREE((void*)this_ptr);
30085         ChannelManagerPersister_free(this_ptr_conv);
30086 }
30087
30088 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) {
30089         void* persister_ptr = (void*)(((uint64_t)persister) & ~1);
30090         CHECK_ACCESS(persister_ptr);
30091         LDKChannelManagerPersister persister_conv = *(LDKChannelManagerPersister*)(persister_ptr);
30092         if (persister_conv.free == LDKChannelManagerPersister_JCalls_free) {
30093                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30094                 LDKChannelManagerPersister_JCalls_cloned(&persister_conv);
30095         }
30096         void* event_handler_ptr = (void*)(((uint64_t)event_handler) & ~1);
30097         CHECK_ACCESS(event_handler_ptr);
30098         LDKEventHandler event_handler_conv = *(LDKEventHandler*)(event_handler_ptr);
30099         if (event_handler_conv.free == LDKEventHandler_JCalls_free) {
30100                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30101                 LDKEventHandler_JCalls_cloned(&event_handler_conv);
30102         }
30103         LDKChainMonitor chain_monitor_conv;
30104         chain_monitor_conv.inner = (void*)(chain_monitor & (~1));
30105         chain_monitor_conv.is_owned = false;
30106         LDKChannelManager channel_manager_conv;
30107         channel_manager_conv.inner = (void*)(channel_manager & (~1));
30108         channel_manager_conv.is_owned = false;
30109         LDKNetGraphMsgHandler net_graph_msg_handler_conv;
30110         net_graph_msg_handler_conv.inner = (void*)(net_graph_msg_handler & (~1));
30111         net_graph_msg_handler_conv.is_owned = (net_graph_msg_handler & 1) || (net_graph_msg_handler == 0);
30112         LDKPeerManager peer_manager_conv;
30113         peer_manager_conv.inner = (void*)(peer_manager & (~1));
30114         peer_manager_conv.is_owned = false;
30115         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
30116         CHECK_ACCESS(logger_ptr);
30117         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
30118         if (logger_conv.free == LDKLogger_JCalls_free) {
30119                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30120                 LDKLogger_JCalls_cloned(&logger_conv);
30121         }
30122         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);
30123         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30124         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30125         uint64_t ret_ref = (uint64_t)ret_var.inner;
30126         if (ret_var.is_owned) {
30127                 ret_ref |= 1;
30128         }
30129         return ret_ref;
30130 }
30131
30132 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1join(JNIEnv *env, jclass clz, int64_t this_arg) {
30133         LDKBackgroundProcessor this_arg_conv;
30134         this_arg_conv.inner = (void*)(this_arg & (~1));
30135         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
30136         // Warning: we need a move here but no clone is available for LDKBackgroundProcessor
30137         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
30138         *ret_conv = BackgroundProcessor_join(this_arg_conv);
30139         return (uint64_t)ret_conv;
30140 }
30141
30142 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1stop(JNIEnv *env, jclass clz, int64_t this_arg) {
30143         LDKBackgroundProcessor this_arg_conv;
30144         this_arg_conv.inner = (void*)(this_arg & (~1));
30145         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
30146         // Warning: we need a move here but no clone is available for LDKBackgroundProcessor
30147         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
30148         *ret_conv = BackgroundProcessor_stop(this_arg_conv);
30149         return (uint64_t)ret_conv;
30150 }
30151
30152 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_check_1platform(JNIEnv *env, jclass clz) {
30153         check_platform();
30154 }
30155
30156 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Invoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
30157         LDKInvoice this_obj_conv;
30158         this_obj_conv.inner = (void*)(this_obj & (~1));
30159         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30160         Invoice_free(this_obj_conv);
30161 }
30162
30163 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Invoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
30164         LDKInvoice a_conv;
30165         a_conv.inner = (void*)(a & (~1));
30166         a_conv.is_owned = false;
30167         LDKInvoice b_conv;
30168         b_conv.inner = (void*)(b & (~1));
30169         b_conv.is_owned = false;
30170         jboolean ret_val = Invoice_eq(&a_conv, &b_conv);
30171         return ret_val;
30172 }
30173
30174 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30175         LDKInvoice orig_conv;
30176         orig_conv.inner = (void*)(orig & (~1));
30177         orig_conv.is_owned = false;
30178         LDKInvoice ret_var = Invoice_clone(&orig_conv);
30179         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30180         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30181         uint64_t ret_ref = (uint64_t)ret_var.inner;
30182         if (ret_var.is_owned) {
30183                 ret_ref |= 1;
30184         }
30185         return ret_ref;
30186 }
30187
30188 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
30189         LDKSignedRawInvoice this_obj_conv;
30190         this_obj_conv.inner = (void*)(this_obj & (~1));
30191         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30192         SignedRawInvoice_free(this_obj_conv);
30193 }
30194
30195 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
30196         LDKSignedRawInvoice a_conv;
30197         a_conv.inner = (void*)(a & (~1));
30198         a_conv.is_owned = false;
30199         LDKSignedRawInvoice b_conv;
30200         b_conv.inner = (void*)(b & (~1));
30201         b_conv.is_owned = false;
30202         jboolean ret_val = SignedRawInvoice_eq(&a_conv, &b_conv);
30203         return ret_val;
30204 }
30205
30206 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30207         LDKSignedRawInvoice orig_conv;
30208         orig_conv.inner = (void*)(orig & (~1));
30209         orig_conv.is_owned = false;
30210         LDKSignedRawInvoice ret_var = SignedRawInvoice_clone(&orig_conv);
30211         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30212         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30213         uint64_t ret_ref = (uint64_t)ret_var.inner;
30214         if (ret_var.is_owned) {
30215                 ret_ref |= 1;
30216         }
30217         return ret_ref;
30218 }
30219
30220 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawInvoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
30221         LDKRawInvoice this_obj_conv;
30222         this_obj_conv.inner = (void*)(this_obj & (~1));
30223         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30224         RawInvoice_free(this_obj_conv);
30225 }
30226
30227 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1get_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
30228         LDKRawInvoice this_ptr_conv;
30229         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30230         this_ptr_conv.is_owned = false;
30231         LDKRawDataPart ret_var = RawInvoice_get_data(&this_ptr_conv);
30232         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30233         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30234         uint64_t ret_ref = (uint64_t)ret_var.inner;
30235         if (ret_var.is_owned) {
30236                 ret_ref |= 1;
30237         }
30238         return ret_ref;
30239 }
30240
30241 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawInvoice_1set_1data(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30242         LDKRawInvoice this_ptr_conv;
30243         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30244         this_ptr_conv.is_owned = false;
30245         LDKRawDataPart val_conv;
30246         val_conv.inner = (void*)(val & (~1));
30247         val_conv.is_owned = (val & 1) || (val == 0);
30248         val_conv = RawDataPart_clone(&val_conv);
30249         RawInvoice_set_data(&this_ptr_conv, val_conv);
30250 }
30251
30252 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RawInvoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
30253         LDKRawInvoice a_conv;
30254         a_conv.inner = (void*)(a & (~1));
30255         a_conv.is_owned = false;
30256         LDKRawInvoice b_conv;
30257         b_conv.inner = (void*)(b & (~1));
30258         b_conv.is_owned = false;
30259         jboolean ret_val = RawInvoice_eq(&a_conv, &b_conv);
30260         return ret_val;
30261 }
30262
30263 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30264         LDKRawInvoice orig_conv;
30265         orig_conv.inner = (void*)(orig & (~1));
30266         orig_conv.is_owned = false;
30267         LDKRawInvoice ret_var = RawInvoice_clone(&orig_conv);
30268         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30269         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30270         uint64_t ret_ref = (uint64_t)ret_var.inner;
30271         if (ret_var.is_owned) {
30272                 ret_ref |= 1;
30273         }
30274         return ret_ref;
30275 }
30276
30277 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawDataPart_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
30278         LDKRawDataPart this_obj_conv;
30279         this_obj_conv.inner = (void*)(this_obj & (~1));
30280         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30281         RawDataPart_free(this_obj_conv);
30282 }
30283
30284 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
30285         LDKRawDataPart this_ptr_conv;
30286         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30287         this_ptr_conv.is_owned = false;
30288         LDKPositiveTimestamp ret_var = RawDataPart_get_timestamp(&this_ptr_conv);
30289         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30290         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30291         uint64_t ret_ref = (uint64_t)ret_var.inner;
30292         if (ret_var.is_owned) {
30293                 ret_ref |= 1;
30294         }
30295         return ret_ref;
30296 }
30297
30298 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawDataPart_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30299         LDKRawDataPart this_ptr_conv;
30300         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30301         this_ptr_conv.is_owned = false;
30302         LDKPositiveTimestamp val_conv;
30303         val_conv.inner = (void*)(val & (~1));
30304         val_conv.is_owned = (val & 1) || (val == 0);
30305         val_conv = PositiveTimestamp_clone(&val_conv);
30306         RawDataPart_set_timestamp(&this_ptr_conv, val_conv);
30307 }
30308
30309 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RawDataPart_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
30310         LDKRawDataPart a_conv;
30311         a_conv.inner = (void*)(a & (~1));
30312         a_conv.is_owned = false;
30313         LDKRawDataPart b_conv;
30314         b_conv.inner = (void*)(b & (~1));
30315         b_conv.is_owned = false;
30316         jboolean ret_val = RawDataPart_eq(&a_conv, &b_conv);
30317         return ret_val;
30318 }
30319
30320 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30321         LDKRawDataPart orig_conv;
30322         orig_conv.inner = (void*)(orig & (~1));
30323         orig_conv.is_owned = false;
30324         LDKRawDataPart ret_var = RawDataPart_clone(&orig_conv);
30325         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30326         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30327         uint64_t ret_ref = (uint64_t)ret_var.inner;
30328         if (ret_var.is_owned) {
30329                 ret_ref |= 1;
30330         }
30331         return ret_ref;
30332 }
30333
30334 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
30335         LDKPositiveTimestamp this_obj_conv;
30336         this_obj_conv.inner = (void*)(this_obj & (~1));
30337         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30338         PositiveTimestamp_free(this_obj_conv);
30339 }
30340
30341 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
30342         LDKPositiveTimestamp a_conv;
30343         a_conv.inner = (void*)(a & (~1));
30344         a_conv.is_owned = false;
30345         LDKPositiveTimestamp b_conv;
30346         b_conv.inner = (void*)(b & (~1));
30347         b_conv.is_owned = false;
30348         jboolean ret_val = PositiveTimestamp_eq(&a_conv, &b_conv);
30349         return ret_val;
30350 }
30351
30352 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30353         LDKPositiveTimestamp orig_conv;
30354         orig_conv.inner = (void*)(orig & (~1));
30355         orig_conv.is_owned = false;
30356         LDKPositiveTimestamp ret_var = PositiveTimestamp_clone(&orig_conv);
30357         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30358         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30359         uint64_t ret_ref = (uint64_t)ret_var.inner;
30360         if (ret_var.is_owned) {
30361                 ret_ref |= 1;
30362         }
30363         return ret_ref;
30364 }
30365
30366 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30367         LDKSiPrefix* orig_conv = (LDKSiPrefix*)(orig & ~1);
30368         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_clone(orig_conv));
30369         return ret_conv;
30370 }
30371
30372 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1milli(JNIEnv *env, jclass clz) {
30373         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_milli());
30374         return ret_conv;
30375 }
30376
30377 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1micro(JNIEnv *env, jclass clz) {
30378         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_micro());
30379         return ret_conv;
30380 }
30381
30382 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1nano(JNIEnv *env, jclass clz) {
30383         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_nano());
30384         return ret_conv;
30385 }
30386
30387 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1pico(JNIEnv *env, jclass clz) {
30388         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_pico());
30389         return ret_conv;
30390 }
30391
30392 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SiPrefix_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
30393         LDKSiPrefix* a_conv = (LDKSiPrefix*)(a & ~1);
30394         LDKSiPrefix* b_conv = (LDKSiPrefix*)(b & ~1);
30395         jboolean ret_val = SiPrefix_eq(a_conv, b_conv);
30396         return ret_val;
30397 }
30398
30399 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SiPrefix_1multiplier(JNIEnv *env, jclass clz, int64_t this_arg) {
30400         LDKSiPrefix* this_arg_conv = (LDKSiPrefix*)(this_arg & ~1);
30401         int64_t ret_val = SiPrefix_multiplier(this_arg_conv);
30402         return ret_val;
30403 }
30404
30405 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30406         LDKCurrency* orig_conv = (LDKCurrency*)(orig & ~1);
30407         jclass ret_conv = LDKCurrency_to_java(env, Currency_clone(orig_conv));
30408         return ret_conv;
30409 }
30410
30411 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1bitcoin(JNIEnv *env, jclass clz) {
30412         jclass ret_conv = LDKCurrency_to_java(env, Currency_bitcoin());
30413         return ret_conv;
30414 }
30415
30416 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1bitcoin_1testnet(JNIEnv *env, jclass clz) {
30417         jclass ret_conv = LDKCurrency_to_java(env, Currency_bitcoin_testnet());
30418         return ret_conv;
30419 }
30420
30421 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1regtest(JNIEnv *env, jclass clz) {
30422         jclass ret_conv = LDKCurrency_to_java(env, Currency_regtest());
30423         return ret_conv;
30424 }
30425
30426 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1simnet(JNIEnv *env, jclass clz) {
30427         jclass ret_conv = LDKCurrency_to_java(env, Currency_simnet());
30428         return ret_conv;
30429 }
30430
30431 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1signet(JNIEnv *env, jclass clz) {
30432         jclass ret_conv = LDKCurrency_to_java(env, Currency_signet());
30433         return ret_conv;
30434 }
30435
30436 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Currency_1hash(JNIEnv *env, jclass clz, int64_t o) {
30437         LDKCurrency* o_conv = (LDKCurrency*)(o & ~1);
30438         int64_t ret_val = Currency_hash(o_conv);
30439         return ret_val;
30440 }
30441
30442 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Currency_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
30443         LDKCurrency* a_conv = (LDKCurrency*)(a & ~1);
30444         LDKCurrency* b_conv = (LDKCurrency*)(b & ~1);
30445         jboolean ret_val = Currency_eq(a_conv, b_conv);
30446         return ret_val;
30447 }
30448
30449 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Sha256_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
30450         LDKSha256 this_obj_conv;
30451         this_obj_conv.inner = (void*)(this_obj & (~1));
30452         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30453         Sha256_free(this_obj_conv);
30454 }
30455
30456 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sha256_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30457         LDKSha256 orig_conv;
30458         orig_conv.inner = (void*)(orig & (~1));
30459         orig_conv.is_owned = false;
30460         LDKSha256 ret_var = Sha256_clone(&orig_conv);
30461         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30462         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30463         uint64_t ret_ref = (uint64_t)ret_var.inner;
30464         if (ret_var.is_owned) {
30465                 ret_ref |= 1;
30466         }
30467         return ret_ref;
30468 }
30469
30470 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sha256_1hash(JNIEnv *env, jclass clz, int64_t o) {
30471         LDKSha256 o_conv;
30472         o_conv.inner = (void*)(o & (~1));
30473         o_conv.is_owned = false;
30474         int64_t ret_val = Sha256_hash(&o_conv);
30475         return ret_val;
30476 }
30477
30478 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Sha256_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
30479         LDKSha256 a_conv;
30480         a_conv.inner = (void*)(a & (~1));
30481         a_conv.is_owned = false;
30482         LDKSha256 b_conv;
30483         b_conv.inner = (void*)(b & (~1));
30484         b_conv.is_owned = false;
30485         jboolean ret_val = Sha256_eq(&a_conv, &b_conv);
30486         return ret_val;
30487 }
30488
30489 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Description_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
30490         LDKDescription this_obj_conv;
30491         this_obj_conv.inner = (void*)(this_obj & (~1));
30492         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30493         Description_free(this_obj_conv);
30494 }
30495
30496 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30497         LDKDescription orig_conv;
30498         orig_conv.inner = (void*)(orig & (~1));
30499         orig_conv.is_owned = false;
30500         LDKDescription ret_var = Description_clone(&orig_conv);
30501         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30502         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30503         uint64_t ret_ref = (uint64_t)ret_var.inner;
30504         if (ret_var.is_owned) {
30505                 ret_ref |= 1;
30506         }
30507         return ret_ref;
30508 }
30509
30510 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1hash(JNIEnv *env, jclass clz, int64_t o) {
30511         LDKDescription o_conv;
30512         o_conv.inner = (void*)(o & (~1));
30513         o_conv.is_owned = false;
30514         int64_t ret_val = Description_hash(&o_conv);
30515         return ret_val;
30516 }
30517
30518 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Description_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
30519         LDKDescription a_conv;
30520         a_conv.inner = (void*)(a & (~1));
30521         a_conv.is_owned = false;
30522         LDKDescription b_conv;
30523         b_conv.inner = (void*)(b & (~1));
30524         b_conv.is_owned = false;
30525         jboolean ret_val = Description_eq(&a_conv, &b_conv);
30526         return ret_val;
30527 }
30528
30529 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
30530         LDKPayeePubKey this_obj_conv;
30531         this_obj_conv.inner = (void*)(this_obj & (~1));
30532         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30533         PayeePubKey_free(this_obj_conv);
30534 }
30535
30536 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30537         LDKPayeePubKey orig_conv;
30538         orig_conv.inner = (void*)(orig & (~1));
30539         orig_conv.is_owned = false;
30540         LDKPayeePubKey ret_var = PayeePubKey_clone(&orig_conv);
30541         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30542         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30543         uint64_t ret_ref = (uint64_t)ret_var.inner;
30544         if (ret_var.is_owned) {
30545                 ret_ref |= 1;
30546         }
30547         return ret_ref;
30548 }
30549
30550 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1hash(JNIEnv *env, jclass clz, int64_t o) {
30551         LDKPayeePubKey o_conv;
30552         o_conv.inner = (void*)(o & (~1));
30553         o_conv.is_owned = false;
30554         int64_t ret_val = PayeePubKey_hash(&o_conv);
30555         return ret_val;
30556 }
30557
30558 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
30559         LDKPayeePubKey a_conv;
30560         a_conv.inner = (void*)(a & (~1));
30561         a_conv.is_owned = false;
30562         LDKPayeePubKey b_conv;
30563         b_conv.inner = (void*)(b & (~1));
30564         b_conv.is_owned = false;
30565         jboolean ret_val = PayeePubKey_eq(&a_conv, &b_conv);
30566         return ret_val;
30567 }
30568
30569 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
30570         LDKExpiryTime this_obj_conv;
30571         this_obj_conv.inner = (void*)(this_obj & (~1));
30572         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30573         ExpiryTime_free(this_obj_conv);
30574 }
30575
30576 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30577         LDKExpiryTime orig_conv;
30578         orig_conv.inner = (void*)(orig & (~1));
30579         orig_conv.is_owned = false;
30580         LDKExpiryTime ret_var = ExpiryTime_clone(&orig_conv);
30581         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30582         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30583         uint64_t ret_ref = (uint64_t)ret_var.inner;
30584         if (ret_var.is_owned) {
30585                 ret_ref |= 1;
30586         }
30587         return ret_ref;
30588 }
30589
30590 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1hash(JNIEnv *env, jclass clz, int64_t o) {
30591         LDKExpiryTime o_conv;
30592         o_conv.inner = (void*)(o & (~1));
30593         o_conv.is_owned = false;
30594         int64_t ret_val = ExpiryTime_hash(&o_conv);
30595         return ret_val;
30596 }
30597
30598 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
30599         LDKExpiryTime a_conv;
30600         a_conv.inner = (void*)(a & (~1));
30601         a_conv.is_owned = false;
30602         LDKExpiryTime b_conv;
30603         b_conv.inner = (void*)(b & (~1));
30604         b_conv.is_owned = false;
30605         jboolean ret_val = ExpiryTime_eq(&a_conv, &b_conv);
30606         return ret_val;
30607 }
30608
30609 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
30610         LDKMinFinalCltvExpiry this_obj_conv;
30611         this_obj_conv.inner = (void*)(this_obj & (~1));
30612         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30613         MinFinalCltvExpiry_free(this_obj_conv);
30614 }
30615
30616 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30617         LDKMinFinalCltvExpiry orig_conv;
30618         orig_conv.inner = (void*)(orig & (~1));
30619         orig_conv.is_owned = false;
30620         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_clone(&orig_conv);
30621         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30622         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30623         uint64_t ret_ref = (uint64_t)ret_var.inner;
30624         if (ret_var.is_owned) {
30625                 ret_ref |= 1;
30626         }
30627         return ret_ref;
30628 }
30629
30630 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1hash(JNIEnv *env, jclass clz, int64_t o) {
30631         LDKMinFinalCltvExpiry o_conv;
30632         o_conv.inner = (void*)(o & (~1));
30633         o_conv.is_owned = false;
30634         int64_t ret_val = MinFinalCltvExpiry_hash(&o_conv);
30635         return ret_val;
30636 }
30637
30638 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
30639         LDKMinFinalCltvExpiry a_conv;
30640         a_conv.inner = (void*)(a & (~1));
30641         a_conv.is_owned = false;
30642         LDKMinFinalCltvExpiry b_conv;
30643         b_conv.inner = (void*)(b & (~1));
30644         b_conv.is_owned = false;
30645         jboolean ret_val = MinFinalCltvExpiry_eq(&a_conv, &b_conv);
30646         return ret_val;
30647 }
30648
30649 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Fallback_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
30650         if ((this_ptr & 1) != 0) return;
30651         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
30652         CHECK_ACCESS(this_ptr_ptr);
30653         LDKFallback this_ptr_conv = *(LDKFallback*)(this_ptr_ptr);
30654         FREE((void*)this_ptr);
30655         Fallback_free(this_ptr_conv);
30656 }
30657
30658 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30659         LDKFallback* orig_conv = (LDKFallback*)orig;
30660         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
30661         *ret_copy = Fallback_clone(orig_conv);
30662         uint64_t ret_ref = (uint64_t)ret_copy;
30663         return ret_ref;
30664 }
30665
30666 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1seg_1wit_1program(JNIEnv *env, jclass clz, int8_t version, int8_tArray program) {
30667         
30668         LDKCVec_u8Z program_ref;
30669         program_ref.datalen = (*env)->GetArrayLength(env, program);
30670         program_ref.data = MALLOC(program_ref.datalen, "LDKCVec_u8Z Bytes");
30671         (*env)->GetByteArrayRegion(env, program, 0, program_ref.datalen, program_ref.data);
30672         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
30673         *ret_copy = Fallback_seg_wit_program((LDKu5){ ._0 = version }, program_ref);
30674         uint64_t ret_ref = (uint64_t)ret_copy;
30675         return ret_ref;
30676 }
30677
30678 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1pub_1key_1hash(JNIEnv *env, jclass clz, int8_tArray a) {
30679         LDKTwentyBytes a_ref;
30680         CHECK((*env)->GetArrayLength(env, a) == 20);
30681         (*env)->GetByteArrayRegion(env, a, 0, 20, a_ref.data);
30682         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
30683         *ret_copy = Fallback_pub_key_hash(a_ref);
30684         uint64_t ret_ref = (uint64_t)ret_copy;
30685         return ret_ref;
30686 }
30687
30688 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1script_1hash(JNIEnv *env, jclass clz, int8_tArray a) {
30689         LDKTwentyBytes a_ref;
30690         CHECK((*env)->GetArrayLength(env, a) == 20);
30691         (*env)->GetByteArrayRegion(env, a, 0, 20, a_ref.data);
30692         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
30693         *ret_copy = Fallback_script_hash(a_ref);
30694         uint64_t ret_ref = (uint64_t)ret_copy;
30695         return ret_ref;
30696 }
30697
30698 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1hash(JNIEnv *env, jclass clz, int64_t o) {
30699         LDKFallback* o_conv = (LDKFallback*)o;
30700         int64_t ret_val = Fallback_hash(o_conv);
30701         return ret_val;
30702 }
30703
30704 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Fallback_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
30705         LDKFallback* a_conv = (LDKFallback*)a;
30706         LDKFallback* b_conv = (LDKFallback*)b;
30707         jboolean ret_val = Fallback_eq(a_conv, b_conv);
30708         return ret_val;
30709 }
30710
30711 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
30712         LDKInvoiceSignature this_obj_conv;
30713         this_obj_conv.inner = (void*)(this_obj & (~1));
30714         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30715         InvoiceSignature_free(this_obj_conv);
30716 }
30717
30718 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30719         LDKInvoiceSignature orig_conv;
30720         orig_conv.inner = (void*)(orig & (~1));
30721         orig_conv.is_owned = false;
30722         LDKInvoiceSignature ret_var = InvoiceSignature_clone(&orig_conv);
30723         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30724         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30725         uint64_t ret_ref = (uint64_t)ret_var.inner;
30726         if (ret_var.is_owned) {
30727                 ret_ref |= 1;
30728         }
30729         return ret_ref;
30730 }
30731
30732 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
30733         LDKInvoiceSignature a_conv;
30734         a_conv.inner = (void*)(a & (~1));
30735         a_conv.is_owned = false;
30736         LDKInvoiceSignature b_conv;
30737         b_conv.inner = (void*)(b & (~1));
30738         b_conv.is_owned = false;
30739         jboolean ret_val = InvoiceSignature_eq(&a_conv, &b_conv);
30740         return ret_val;
30741 }
30742
30743 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
30744         LDKPrivateRoute this_obj_conv;
30745         this_obj_conv.inner = (void*)(this_obj & (~1));
30746         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30747         PrivateRoute_free(this_obj_conv);
30748 }
30749
30750 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30751         LDKPrivateRoute orig_conv;
30752         orig_conv.inner = (void*)(orig & (~1));
30753         orig_conv.is_owned = false;
30754         LDKPrivateRoute ret_var = PrivateRoute_clone(&orig_conv);
30755         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30756         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30757         uint64_t ret_ref = (uint64_t)ret_var.inner;
30758         if (ret_var.is_owned) {
30759                 ret_ref |= 1;
30760         }
30761         return ret_ref;
30762 }
30763
30764 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1hash(JNIEnv *env, jclass clz, int64_t o) {
30765         LDKPrivateRoute o_conv;
30766         o_conv.inner = (void*)(o & (~1));
30767         o_conv.is_owned = false;
30768         int64_t ret_val = PrivateRoute_hash(&o_conv);
30769         return ret_val;
30770 }
30771
30772 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
30773         LDKPrivateRoute a_conv;
30774         a_conv.inner = (void*)(a & (~1));
30775         a_conv.is_owned = false;
30776         LDKPrivateRoute b_conv;
30777         b_conv.inner = (void*)(b & (~1));
30778         b_conv.is_owned = false;
30779         jboolean ret_val = PrivateRoute_eq(&a_conv, &b_conv);
30780         return ret_val;
30781 }
30782
30783 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1into_1parts(JNIEnv *env, jclass clz, int64_t this_arg) {
30784         LDKSignedRawInvoice this_arg_conv;
30785         this_arg_conv.inner = (void*)(this_arg & (~1));
30786         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
30787         this_arg_conv = SignedRawInvoice_clone(&this_arg_conv);
30788         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
30789         *ret_conv = SignedRawInvoice_into_parts(this_arg_conv);
30790         return ((uint64_t)ret_conv);
30791 }
30792
30793 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1raw_1invoice(JNIEnv *env, jclass clz, int64_t this_arg) {
30794         LDKSignedRawInvoice this_arg_conv;
30795         this_arg_conv.inner = (void*)(this_arg & (~1));
30796         this_arg_conv.is_owned = false;
30797         LDKRawInvoice ret_var = SignedRawInvoice_raw_invoice(&this_arg_conv);
30798         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30799         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30800         uint64_t ret_ref = (uint64_t)ret_var.inner;
30801         if (ret_var.is_owned) {
30802                 ret_ref |= 1;
30803         }
30804         return ret_ref;
30805 }
30806
30807 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
30808         LDKSignedRawInvoice this_arg_conv;
30809         this_arg_conv.inner = (void*)(this_arg & (~1));
30810         this_arg_conv.is_owned = false;
30811         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
30812         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *SignedRawInvoice_hash(&this_arg_conv));
30813         return ret_arr;
30814 }
30815
30816 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
30817         LDKSignedRawInvoice this_arg_conv;
30818         this_arg_conv.inner = (void*)(this_arg & (~1));
30819         this_arg_conv.is_owned = false;
30820         LDKInvoiceSignature ret_var = SignedRawInvoice_signature(&this_arg_conv);
30821         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30822         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30823         uint64_t ret_ref = (uint64_t)ret_var.inner;
30824         if (ret_var.is_owned) {
30825                 ret_ref |= 1;
30826         }
30827         return ret_ref;
30828 }
30829
30830 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1recover_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
30831         LDKSignedRawInvoice this_arg_conv;
30832         this_arg_conv.inner = (void*)(this_arg & (~1));
30833         this_arg_conv.is_owned = false;
30834         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
30835         *ret_conv = SignedRawInvoice_recover_payee_pub_key(&this_arg_conv);
30836         return (uint64_t)ret_conv;
30837 }
30838
30839 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1check_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
30840         LDKSignedRawInvoice this_arg_conv;
30841         this_arg_conv.inner = (void*)(this_arg & (~1));
30842         this_arg_conv.is_owned = false;
30843         jboolean ret_val = SignedRawInvoice_check_signature(&this_arg_conv);
30844         return ret_val;
30845 }
30846
30847 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
30848         LDKRawInvoice this_arg_conv;
30849         this_arg_conv.inner = (void*)(this_arg & (~1));
30850         this_arg_conv.is_owned = false;
30851         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
30852         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, RawInvoice_hash(&this_arg_conv).data);
30853         return ret_arr;
30854 }
30855
30856 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
30857         LDKRawInvoice this_arg_conv;
30858         this_arg_conv.inner = (void*)(this_arg & (~1));
30859         this_arg_conv.is_owned = false;
30860         LDKSha256 ret_var = RawInvoice_payment_hash(&this_arg_conv);
30861         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30862         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30863         uint64_t ret_ref = (uint64_t)ret_var.inner;
30864         if (ret_var.is_owned) {
30865                 ret_ref |= 1;
30866         }
30867         return ret_ref;
30868 }
30869
30870 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1description(JNIEnv *env, jclass clz, int64_t this_arg) {
30871         LDKRawInvoice this_arg_conv;
30872         this_arg_conv.inner = (void*)(this_arg & (~1));
30873         this_arg_conv.is_owned = false;
30874         LDKDescription ret_var = RawInvoice_description(&this_arg_conv);
30875         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30876         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30877         uint64_t ret_ref = (uint64_t)ret_var.inner;
30878         if (ret_var.is_owned) {
30879                 ret_ref |= 1;
30880         }
30881         return ret_ref;
30882 }
30883
30884 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
30885         LDKRawInvoice this_arg_conv;
30886         this_arg_conv.inner = (void*)(this_arg & (~1));
30887         this_arg_conv.is_owned = false;
30888         LDKPayeePubKey ret_var = RawInvoice_payee_pub_key(&this_arg_conv);
30889         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30890         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30891         uint64_t ret_ref = (uint64_t)ret_var.inner;
30892         if (ret_var.is_owned) {
30893                 ret_ref |= 1;
30894         }
30895         return ret_ref;
30896 }
30897
30898 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1description_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
30899         LDKRawInvoice this_arg_conv;
30900         this_arg_conv.inner = (void*)(this_arg & (~1));
30901         this_arg_conv.is_owned = false;
30902         LDKSha256 ret_var = RawInvoice_description_hash(&this_arg_conv);
30903         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30904         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30905         uint64_t ret_ref = (uint64_t)ret_var.inner;
30906         if (ret_var.is_owned) {
30907                 ret_ref |= 1;
30908         }
30909         return ret_ref;
30910 }
30911
30912 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
30913         LDKRawInvoice this_arg_conv;
30914         this_arg_conv.inner = (void*)(this_arg & (~1));
30915         this_arg_conv.is_owned = false;
30916         LDKExpiryTime ret_var = RawInvoice_expiry_time(&this_arg_conv);
30917         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30918         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30919         uint64_t ret_ref = (uint64_t)ret_var.inner;
30920         if (ret_var.is_owned) {
30921                 ret_ref |= 1;
30922         }
30923         return ret_ref;
30924 }
30925
30926 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1min_1final_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_arg) {
30927         LDKRawInvoice this_arg_conv;
30928         this_arg_conv.inner = (void*)(this_arg & (~1));
30929         this_arg_conv.is_owned = false;
30930         LDKMinFinalCltvExpiry ret_var = RawInvoice_min_final_cltv_expiry(&this_arg_conv);
30931         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30932         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30933         uint64_t ret_ref = (uint64_t)ret_var.inner;
30934         if (ret_var.is_owned) {
30935                 ret_ref |= 1;
30936         }
30937         return ret_ref;
30938 }
30939
30940 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
30941         LDKRawInvoice this_arg_conv;
30942         this_arg_conv.inner = (void*)(this_arg & (~1));
30943         this_arg_conv.is_owned = false;
30944         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
30945         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, RawInvoice_payment_secret(&this_arg_conv).data);
30946         return ret_arr;
30947 }
30948
30949 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
30950         LDKRawInvoice this_arg_conv;
30951         this_arg_conv.inner = (void*)(this_arg & (~1));
30952         this_arg_conv.is_owned = false;
30953         LDKInvoiceFeatures ret_var = RawInvoice_features(&this_arg_conv);
30954         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30955         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30956         uint64_t ret_ref = (uint64_t)ret_var.inner;
30957         if (ret_var.is_owned) {
30958                 ret_ref |= 1;
30959         }
30960         return ret_ref;
30961 }
30962
30963 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1private_1routes(JNIEnv *env, jclass clz, int64_t this_arg) {
30964         LDKRawInvoice this_arg_conv;
30965         this_arg_conv.inner = (void*)(this_arg & (~1));
30966         this_arg_conv.is_owned = false;
30967         LDKCVec_PrivateRouteZ ret_var = RawInvoice_private_routes(&this_arg_conv);
30968         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
30969         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
30970         for (size_t o = 0; o < ret_var.datalen; o++) {
30971                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
30972                 CHECK((((uint64_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30973                 CHECK((((uint64_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30974                 uint64_t ret_conv_14_ref = (uint64_t)ret_conv_14_var.inner;
30975                 if (ret_conv_14_var.is_owned) {
30976                         ret_conv_14_ref |= 1;
30977                 }
30978                 ret_arr_ptr[o] = ret_conv_14_ref;
30979         }
30980         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
30981         FREE(ret_var.data);
30982         return ret_arr;
30983 }
30984
30985 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1amount_1pico_1btc(JNIEnv *env, jclass clz, int64_t this_arg) {
30986         LDKRawInvoice this_arg_conv;
30987         this_arg_conv.inner = (void*)(this_arg & (~1));
30988         this_arg_conv.is_owned = false;
30989         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
30990         *ret_copy = RawInvoice_amount_pico_btc(&this_arg_conv);
30991         uint64_t ret_ref = (uint64_t)ret_copy;
30992         return ret_ref;
30993 }
30994
30995 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_RawInvoice_1currency(JNIEnv *env, jclass clz, int64_t this_arg) {
30996         LDKRawInvoice this_arg_conv;
30997         this_arg_conv.inner = (void*)(this_arg & (~1));
30998         this_arg_conv.is_owned = false;
30999         jclass ret_conv = LDKCurrency_to_java(env, RawInvoice_currency(&this_arg_conv));
31000         return ret_conv;
31001 }
31002
31003 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1from_1unix_1timestamp(JNIEnv *env, jclass clz, int64_t unix_seconds) {
31004         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
31005         *ret_conv = PositiveTimestamp_from_unix_timestamp(unix_seconds);
31006         return (uint64_t)ret_conv;
31007 }
31008
31009 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1from_1system_1time(JNIEnv *env, jclass clz, int64_t time) {
31010         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
31011         *ret_conv = PositiveTimestamp_from_system_time(time);
31012         return (uint64_t)ret_conv;
31013 }
31014
31015 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1as_1unix_1timestamp(JNIEnv *env, jclass clz, int64_t this_arg) {
31016         LDKPositiveTimestamp this_arg_conv;
31017         this_arg_conv.inner = (void*)(this_arg & (~1));
31018         this_arg_conv.is_owned = false;
31019         int64_t ret_val = PositiveTimestamp_as_unix_timestamp(&this_arg_conv);
31020         return ret_val;
31021 }
31022
31023 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1as_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
31024         LDKPositiveTimestamp this_arg_conv;
31025         this_arg_conv.inner = (void*)(this_arg & (~1));
31026         this_arg_conv.is_owned = false;
31027         int64_t ret_val = PositiveTimestamp_as_time(&this_arg_conv);
31028         return ret_val;
31029 }
31030
31031 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1into_1signed_1raw(JNIEnv *env, jclass clz, int64_t this_arg) {
31032         LDKInvoice this_arg_conv;
31033         this_arg_conv.inner = (void*)(this_arg & (~1));
31034         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
31035         this_arg_conv = Invoice_clone(&this_arg_conv);
31036         LDKSignedRawInvoice ret_var = Invoice_into_signed_raw(this_arg_conv);
31037         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31038         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31039         uint64_t ret_ref = (uint64_t)ret_var.inner;
31040         if (ret_var.is_owned) {
31041                 ret_ref |= 1;
31042         }
31043         return ret_ref;
31044 }
31045
31046 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1check_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
31047         LDKInvoice this_arg_conv;
31048         this_arg_conv.inner = (void*)(this_arg & (~1));
31049         this_arg_conv.is_owned = false;
31050         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
31051         *ret_conv = Invoice_check_signature(&this_arg_conv);
31052         return (uint64_t)ret_conv;
31053 }
31054
31055 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1from_1signed(JNIEnv *env, jclass clz, int64_t signed_invoice) {
31056         LDKSignedRawInvoice signed_invoice_conv;
31057         signed_invoice_conv.inner = (void*)(signed_invoice & (~1));
31058         signed_invoice_conv.is_owned = (signed_invoice & 1) || (signed_invoice == 0);
31059         signed_invoice_conv = SignedRawInvoice_clone(&signed_invoice_conv);
31060         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
31061         *ret_conv = Invoice_from_signed(signed_invoice_conv);
31062         return (uint64_t)ret_conv;
31063 }
31064
31065 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1timestamp(JNIEnv *env, jclass clz, int64_t this_arg) {
31066         LDKInvoice this_arg_conv;
31067         this_arg_conv.inner = (void*)(this_arg & (~1));
31068         this_arg_conv.is_owned = false;
31069         int64_t ret_val = Invoice_timestamp(&this_arg_conv);
31070         return ret_val;
31071 }
31072
31073 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
31074         LDKInvoice this_arg_conv;
31075         this_arg_conv.inner = (void*)(this_arg & (~1));
31076         this_arg_conv.is_owned = false;
31077         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
31078         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *Invoice_payment_hash(&this_arg_conv));
31079         return ret_arr;
31080 }
31081
31082 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
31083         LDKInvoice this_arg_conv;
31084         this_arg_conv.inner = (void*)(this_arg & (~1));
31085         this_arg_conv.is_owned = false;
31086         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
31087         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, Invoice_payee_pub_key(&this_arg_conv).compressed_form);
31088         return ret_arr;
31089 }
31090
31091 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
31092         LDKInvoice this_arg_conv;
31093         this_arg_conv.inner = (void*)(this_arg & (~1));
31094         this_arg_conv.is_owned = false;
31095         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
31096         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, Invoice_payment_secret(&this_arg_conv).data);
31097         return ret_arr;
31098 }
31099
31100 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
31101         LDKInvoice this_arg_conv;
31102         this_arg_conv.inner = (void*)(this_arg & (~1));
31103         this_arg_conv.is_owned = false;
31104         LDKInvoiceFeatures ret_var = Invoice_features(&this_arg_conv);
31105         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31106         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31107         uint64_t ret_ref = (uint64_t)ret_var.inner;
31108         if (ret_var.is_owned) {
31109                 ret_ref |= 1;
31110         }
31111         return ret_ref;
31112 }
31113
31114 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1recover_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
31115         LDKInvoice this_arg_conv;
31116         this_arg_conv.inner = (void*)(this_arg & (~1));
31117         this_arg_conv.is_owned = false;
31118         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
31119         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, Invoice_recover_payee_pub_key(&this_arg_conv).compressed_form);
31120         return ret_arr;
31121 }
31122
31123 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
31124         LDKInvoice this_arg_conv;
31125         this_arg_conv.inner = (void*)(this_arg & (~1));
31126         this_arg_conv.is_owned = false;
31127         int64_t ret_val = Invoice_expiry_time(&this_arg_conv);
31128         return ret_val;
31129 }
31130
31131 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1min_1final_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_arg) {
31132         LDKInvoice this_arg_conv;
31133         this_arg_conv.inner = (void*)(this_arg & (~1));
31134         this_arg_conv.is_owned = false;
31135         int64_t ret_val = Invoice_min_final_cltv_expiry(&this_arg_conv);
31136         return ret_val;
31137 }
31138
31139 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1private_1routes(JNIEnv *env, jclass clz, int64_t this_arg) {
31140         LDKInvoice this_arg_conv;
31141         this_arg_conv.inner = (void*)(this_arg & (~1));
31142         this_arg_conv.is_owned = false;
31143         LDKCVec_PrivateRouteZ ret_var = Invoice_private_routes(&this_arg_conv);
31144         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
31145         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
31146         for (size_t o = 0; o < ret_var.datalen; o++) {
31147                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
31148                 CHECK((((uint64_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31149                 CHECK((((uint64_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31150                 uint64_t ret_conv_14_ref = (uint64_t)ret_conv_14_var.inner;
31151                 if (ret_conv_14_var.is_owned) {
31152                         ret_conv_14_ref |= 1;
31153                 }
31154                 ret_arr_ptr[o] = ret_conv_14_ref;
31155         }
31156         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
31157         FREE(ret_var.data);
31158         return ret_arr;
31159 }
31160
31161 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1route_1hints(JNIEnv *env, jclass clz, int64_t this_arg) {
31162         LDKInvoice this_arg_conv;
31163         this_arg_conv.inner = (void*)(this_arg & (~1));
31164         this_arg_conv.is_owned = false;
31165         LDKCVec_RouteHintZ ret_var = Invoice_route_hints(&this_arg_conv);
31166         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
31167         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
31168         for (size_t l = 0; l < ret_var.datalen; l++) {
31169                 LDKRouteHint ret_conv_11_var = ret_var.data[l];
31170                 CHECK((((uint64_t)ret_conv_11_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31171                 CHECK((((uint64_t)&ret_conv_11_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31172                 uint64_t ret_conv_11_ref = (uint64_t)ret_conv_11_var.inner;
31173                 if (ret_conv_11_var.is_owned) {
31174                         ret_conv_11_ref |= 1;
31175                 }
31176                 ret_arr_ptr[l] = ret_conv_11_ref;
31177         }
31178         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
31179         FREE(ret_var.data);
31180         return ret_arr;
31181 }
31182
31183 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Invoice_1currency(JNIEnv *env, jclass clz, int64_t this_arg) {
31184         LDKInvoice this_arg_conv;
31185         this_arg_conv.inner = (void*)(this_arg & (~1));
31186         this_arg_conv.is_owned = false;
31187         jclass ret_conv = LDKCurrency_to_java(env, Invoice_currency(&this_arg_conv));
31188         return ret_conv;
31189 }
31190
31191 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1amount_1pico_1btc(JNIEnv *env, jclass clz, int64_t this_arg) {
31192         LDKInvoice this_arg_conv;
31193         this_arg_conv.inner = (void*)(this_arg & (~1));
31194         this_arg_conv.is_owned = false;
31195         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
31196         *ret_copy = Invoice_amount_pico_btc(&this_arg_conv);
31197         uint64_t ret_ref = (uint64_t)ret_copy;
31198         return ret_ref;
31199 }
31200
31201 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1new(JNIEnv *env, jclass clz, jstring description) {
31202         LDKStr description_conv = java_to_owned_str(env, description);
31203         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
31204         *ret_conv = Description_new(description_conv);
31205         return (uint64_t)ret_conv;
31206 }
31207
31208 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Description_1into_1inner(JNIEnv *env, jclass clz, int64_t this_arg) {
31209         LDKDescription this_arg_conv;
31210         this_arg_conv.inner = (void*)(this_arg & (~1));
31211         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
31212         this_arg_conv = Description_clone(&this_arg_conv);
31213         LDKStr ret_str = Description_into_inner(this_arg_conv);
31214         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
31215         Str_free(ret_str);
31216         return ret_conv;
31217 }
31218
31219 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1from_1seconds(JNIEnv *env, jclass clz, int64_t seconds) {
31220         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
31221         *ret_conv = ExpiryTime_from_seconds(seconds);
31222         return (uint64_t)ret_conv;
31223 }
31224
31225 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1from_1duration(JNIEnv *env, jclass clz, int64_t duration) {
31226         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
31227         *ret_conv = ExpiryTime_from_duration(duration);
31228         return (uint64_t)ret_conv;
31229 }
31230
31231 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1as_1seconds(JNIEnv *env, jclass clz, int64_t this_arg) {
31232         LDKExpiryTime this_arg_conv;
31233         this_arg_conv.inner = (void*)(this_arg & (~1));
31234         this_arg_conv.is_owned = false;
31235         int64_t ret_val = ExpiryTime_as_seconds(&this_arg_conv);
31236         return ret_val;
31237 }
31238
31239 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1as_1duration(JNIEnv *env, jclass clz, int64_t this_arg) {
31240         LDKExpiryTime this_arg_conv;
31241         this_arg_conv.inner = (void*)(this_arg & (~1));
31242         this_arg_conv.is_owned = false;
31243         int64_t ret_val = ExpiryTime_as_duration(&this_arg_conv);
31244         return ret_val;
31245 }
31246
31247 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1new(JNIEnv *env, jclass clz, int64_t hops) {
31248         LDKRouteHint hops_conv;
31249         hops_conv.inner = (void*)(hops & (~1));
31250         hops_conv.is_owned = (hops & 1) || (hops == 0);
31251         hops_conv = RouteHint_clone(&hops_conv);
31252         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
31253         *ret_conv = PrivateRoute_new(hops_conv);
31254         return (uint64_t)ret_conv;
31255 }
31256
31257 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1into_1inner(JNIEnv *env, jclass clz, int64_t this_arg) {
31258         LDKPrivateRoute this_arg_conv;
31259         this_arg_conv.inner = (void*)(this_arg & (~1));
31260         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
31261         this_arg_conv = PrivateRoute_clone(&this_arg_conv);
31262         LDKRouteHint ret_var = PrivateRoute_into_inner(this_arg_conv);
31263         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31264         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31265         uint64_t ret_ref = (uint64_t)ret_var.inner;
31266         if (ret_var.is_owned) {
31267                 ret_ref |= 1;
31268         }
31269         return ret_ref;
31270 }
31271
31272 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31273         LDKCreationError* orig_conv = (LDKCreationError*)(orig & ~1);
31274         jclass ret_conv = LDKCreationError_to_java(env, CreationError_clone(orig_conv));
31275         return ret_conv;
31276 }
31277
31278 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1description_1too_1long(JNIEnv *env, jclass clz) {
31279         jclass ret_conv = LDKCreationError_to_java(env, CreationError_description_too_long());
31280         return ret_conv;
31281 }
31282
31283 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1route_1too_1long(JNIEnv *env, jclass clz) {
31284         jclass ret_conv = LDKCreationError_to_java(env, CreationError_route_too_long());
31285         return ret_conv;
31286 }
31287
31288 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1timestamp_1out_1of_1bounds(JNIEnv *env, jclass clz) {
31289         jclass ret_conv = LDKCreationError_to_java(env, CreationError_timestamp_out_of_bounds());
31290         return ret_conv;
31291 }
31292
31293 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1expiry_1time_1out_1of_1bounds(JNIEnv *env, jclass clz) {
31294         jclass ret_conv = LDKCreationError_to_java(env, CreationError_expiry_time_out_of_bounds());
31295         return ret_conv;
31296 }
31297
31298 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CreationError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
31299         LDKCreationError* a_conv = (LDKCreationError*)(a & ~1);
31300         LDKCreationError* b_conv = (LDKCreationError*)(b & ~1);
31301         jboolean ret_val = CreationError_eq(a_conv, b_conv);
31302         return ret_val;
31303 }
31304
31305 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_CreationError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
31306         LDKCreationError* o_conv = (LDKCreationError*)(o & ~1);
31307         LDKStr ret_str = CreationError_to_str(o_conv);
31308         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
31309         Str_free(ret_str);
31310         return ret_conv;
31311 }
31312
31313 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31314         LDKSemanticError* orig_conv = (LDKSemanticError*)(orig & ~1);
31315         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_clone(orig_conv));
31316         return ret_conv;
31317 }
31318
31319 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1no_1payment_1hash(JNIEnv *env, jclass clz) {
31320         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_no_payment_hash());
31321         return ret_conv;
31322 }
31323
31324 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1multiple_1payment_1hashes(JNIEnv *env, jclass clz) {
31325         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_multiple_payment_hashes());
31326         return ret_conv;
31327 }
31328
31329 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1no_1description(JNIEnv *env, jclass clz) {
31330         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_no_description());
31331         return ret_conv;
31332 }
31333
31334 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1multiple_1descriptions(JNIEnv *env, jclass clz) {
31335         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_multiple_descriptions());
31336         return ret_conv;
31337 }
31338
31339 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1no_1payment_1secret(JNIEnv *env, jclass clz) {
31340         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_no_payment_secret());
31341         return ret_conv;
31342 }
31343
31344 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1multiple_1payment_1secrets(JNIEnv *env, jclass clz) {
31345         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_multiple_payment_secrets());
31346         return ret_conv;
31347 }
31348
31349 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1invalid_1features(JNIEnv *env, jclass clz) {
31350         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_invalid_features());
31351         return ret_conv;
31352 }
31353
31354 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1invalid_1recovery_1id(JNIEnv *env, jclass clz) {
31355         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_invalid_recovery_id());
31356         return ret_conv;
31357 }
31358
31359 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1invalid_1signature(JNIEnv *env, jclass clz) {
31360         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_invalid_signature());
31361         return ret_conv;
31362 }
31363
31364 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1imprecise_1amount(JNIEnv *env, jclass clz) {
31365         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_imprecise_amount());
31366         return ret_conv;
31367 }
31368
31369 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SemanticError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
31370         LDKSemanticError* a_conv = (LDKSemanticError*)(a & ~1);
31371         LDKSemanticError* b_conv = (LDKSemanticError*)(b & ~1);
31372         jboolean ret_val = SemanticError_eq(a_conv, b_conv);
31373         return ret_val;
31374 }
31375
31376 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SemanticError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
31377         LDKSemanticError* o_conv = (LDKSemanticError*)(o & ~1);
31378         LDKStr ret_str = SemanticError_to_str(o_conv);
31379         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
31380         Str_free(ret_str);
31381         return ret_conv;
31382 }
31383
31384 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
31385         if ((this_ptr & 1) != 0) return;
31386         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
31387         CHECK_ACCESS(this_ptr_ptr);
31388         LDKSignOrCreationError this_ptr_conv = *(LDKSignOrCreationError*)(this_ptr_ptr);
31389         FREE((void*)this_ptr);
31390         SignOrCreationError_free(this_ptr_conv);
31391 }
31392
31393 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31394         LDKSignOrCreationError* orig_conv = (LDKSignOrCreationError*)orig;
31395         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
31396         *ret_copy = SignOrCreationError_clone(orig_conv);
31397         uint64_t ret_ref = (uint64_t)ret_copy;
31398         return ret_ref;
31399 }
31400
31401 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1sign_1error(JNIEnv *env, jclass clz) {
31402         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
31403         *ret_copy = SignOrCreationError_sign_error();
31404         uint64_t ret_ref = (uint64_t)ret_copy;
31405         return ret_ref;
31406 }
31407
31408 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1creation_1error(JNIEnv *env, jclass clz, jclass a) {
31409         LDKCreationError a_conv = LDKCreationError_from_java(env, a);
31410         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
31411         *ret_copy = SignOrCreationError_creation_error(a_conv);
31412         uint64_t ret_ref = (uint64_t)ret_copy;
31413         return ret_ref;
31414 }
31415
31416 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
31417         LDKSignOrCreationError* a_conv = (LDKSignOrCreationError*)a;
31418         LDKSignOrCreationError* b_conv = (LDKSignOrCreationError*)b;
31419         jboolean ret_val = SignOrCreationError_eq(a_conv, b_conv);
31420         return ret_val;
31421 }
31422
31423 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
31424         LDKSignOrCreationError* o_conv = (LDKSignOrCreationError*)o;
31425         LDKStr ret_str = SignOrCreationError_to_str(o_conv);
31426         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
31427         Str_free(ret_str);
31428         return ret_conv;
31429 }
31430
31431 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) {
31432         LDKChannelManager channelmanager_conv;
31433         channelmanager_conv.inner = (void*)(channelmanager & (~1));
31434         channelmanager_conv.is_owned = false;
31435         void* keys_manager_ptr = (void*)(((uint64_t)keys_manager) & ~1);
31436         CHECK_ACCESS(keys_manager_ptr);
31437         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
31438         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
31439                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
31440                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
31441         }
31442         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
31443         void* amt_msat_ptr = (void*)(((uint64_t)amt_msat) & ~1);
31444         CHECK_ACCESS(amt_msat_ptr);
31445         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
31446         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)amt_msat) & ~1));
31447         LDKStr description_conv = java_to_owned_str(env, description);
31448         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
31449         *ret_conv = create_invoice_from_channelmanager(&channelmanager_conv, keys_manager_conv, network_conv, amt_msat_conv, description_conv);
31450         return (uint64_t)ret_conv;
31451 }
31452
31453 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SiPrefix_1from_1str(JNIEnv *env, jclass clz, jstring s) {
31454         LDKStr s_conv = java_to_owned_str(env, s);
31455         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
31456         *ret_conv = SiPrefix_from_str(s_conv);
31457         return (uint64_t)ret_conv;
31458 }
31459
31460 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1from_1str(JNIEnv *env, jclass clz, jstring s) {
31461         LDKStr s_conv = java_to_owned_str(env, s);
31462         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
31463         *ret_conv = Invoice_from_str(s_conv);
31464         return (uint64_t)ret_conv;
31465 }
31466
31467 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1from_1str(JNIEnv *env, jclass clz, jstring s) {
31468         LDKStr s_conv = java_to_owned_str(env, s);
31469         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
31470         *ret_conv = SignedRawInvoice_from_str(s_conv);
31471         return (uint64_t)ret_conv;
31472 }
31473
31474 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Invoice_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
31475         LDKInvoice o_conv;
31476         o_conv.inner = (void*)(o & (~1));
31477         o_conv.is_owned = false;
31478         LDKStr ret_str = Invoice_to_str(&o_conv);
31479         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
31480         Str_free(ret_str);
31481         return ret_conv;
31482 }
31483
31484 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
31485         LDKSignedRawInvoice o_conv;
31486         o_conv.inner = (void*)(o & (~1));
31487         o_conv.is_owned = false;
31488         LDKStr ret_str = SignedRawInvoice_to_str(&o_conv);
31489         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
31490         Str_free(ret_str);
31491         return ret_conv;
31492 }
31493
31494 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Currency_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
31495         LDKCurrency* o_conv = (LDKCurrency*)(o & ~1);
31496         LDKStr ret_str = Currency_to_str(o_conv);
31497         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
31498         Str_free(ret_str);
31499         return ret_conv;
31500 }
31501
31502 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SiPrefix_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
31503         LDKSiPrefix* o_conv = (LDKSiPrefix*)(o & ~1);
31504         LDKStr ret_str = SiPrefix_to_str(o_conv);
31505         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
31506         Str_free(ret_str);
31507         return ret_conv;
31508 }
31509