Update auto-generated bindings to 0.0.99.1
[ldk-java] / src / main / jni / bindings.c
1 #define LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ LDKCVec_TransactionOutputsZ
2 #define CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free CVec_TransactionOutputsZ_free
3 #include <jni.h>
4 // On OSX jlong (ie long long) is not equivalent to int64_t, so we override here
5 #define int64_t jlong
6 #include "org_ldk_impl_bindings.h"
7 #include <lightning.h>
8 #include <string.h>
9 #include <stdatomic.h>
10 #include <stdlib.h>
11
12 #define DEBUG_PRINT(...) fprintf(stderr, __VA_ARGS__)
13 #define MALLOC(a, _) malloc(a)
14 #define FREE(p) if ((uint64_t)(p) > 1024) { free(p); }
15 #define DO_ASSERT(a) (void)(a)
16 #define CHECK(a)
17
18 static jmethodID ordinal_meth = NULL;
19 static jmethodID slicedef_meth = NULL;
20 static jclass slicedef_cls = NULL;
21 JNIEXPORT void Java_org_ldk_impl_bindings_init(JNIEnv * env, jclass _b, jclass enum_class, jclass slicedef_class) {
22         ordinal_meth = (*env)->GetMethodID(env, enum_class, "ordinal", "()I");
23         CHECK(ordinal_meth != NULL);
24         slicedef_meth = (*env)->GetMethodID(env, slicedef_class, "<init>", "(JJJ)V");
25         CHECK(slicedef_meth != NULL);
26         slicedef_cls = (*env)->NewGlobalRef(env, slicedef_class);
27         CHECK(slicedef_cls != NULL);
28 }
29
30 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_deref_1bool (JNIEnv * env, jclass _a, jlong ptr) {
31         return *((bool*)ptr);
32 }
33 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_deref_1long (JNIEnv * env, jclass _a, jlong ptr) {
34         return *((long*)ptr);
35 }
36 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_free_1heap_1ptr (JNIEnv * env, jclass _a, jlong ptr) {
37         FREE((void*)ptr);
38 }
39 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_read_1bytes (JNIEnv * env, jclass _b, jlong ptr, jlong len) {
40         jbyteArray ret_arr = (*env)->NewByteArray(env, len);
41         (*env)->SetByteArrayRegion(env, ret_arr, 0, len, (unsigned char*)ptr);
42         return ret_arr;
43 }
44 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_get_1u8_1slice_1bytes (JNIEnv * env, jclass _b, jlong slice_ptr) {
45         LDKu8slice *slice = (LDKu8slice*)slice_ptr;
46         jbyteArray ret_arr = (*env)->NewByteArray(env, slice->datalen);
47         (*env)->SetByteArrayRegion(env, ret_arr, 0, slice->datalen, slice->data);
48         return ret_arr;
49 }
50 JNIEXPORT int64_t impl_bindings_bytes_1to_1u8_1vec (JNIEnv * env, jclass _b, jbyteArray bytes) {
51         LDKCVec_u8Z *vec = (LDKCVec_u8Z*)MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8");
52         vec->datalen = (*env)->GetArrayLength(env, bytes);
53         vec->data = (uint8_t*)MALLOC(vec->datalen, "LDKCVec_u8Z Bytes");
54         (*env)->GetByteArrayRegion (env, bytes, 0, vec->datalen, vec->data);
55         return (uint64_t)vec;
56 }
57 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_txpointer_1get_1buffer (JNIEnv * env, jclass _b, jlong ptr) {
58         LDKTransaction *txdata = (LDKTransaction*)ptr;
59         LDKu8slice slice;
60         slice.data = txdata->data;
61         slice.datalen = txdata->datalen;
62         return Java_org_ldk_impl_bindings_get_1u8_1slice_1bytes(env, _b, (uint64_t)&slice);
63 }
64 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_new_1txpointer_1copy_1data (JNIEnv * env, jclass _b, jbyteArray bytes) {
65         LDKTransaction *txdata = (LDKTransaction*)MALLOC(sizeof(LDKTransaction), "LDKTransaction");
66         txdata->datalen = (*env)->GetArrayLength(env, bytes);
67         txdata->data = (uint8_t*)MALLOC(txdata->datalen, "Tx Data Bytes");
68         txdata->data_is_owned = false;
69         (*env)->GetByteArrayRegion (env, bytes, 0, txdata->datalen, txdata->data);
70         return (uint64_t)txdata;
71 }
72 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_txpointer_1free (JNIEnv * env, jclass _b, jlong ptr) {
73         LDKTransaction *tx = (LDKTransaction*)ptr;
74         tx->data_is_owned = true;
75         Transaction_free(*tx);
76         FREE((void*)ptr);
77 }
78 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_vec_1slice_1len (JNIEnv * env, jclass _a, jlong ptr) {
79         // Check offsets of a few Vec types are all consistent as we're meant to be generic across types
80         _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_SignatureZ, datalen), "Vec<*> needs to be mapped identically");
81         _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_MessageSendEventZ, datalen), "Vec<*> needs to be mapped identically");
82         _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_EventZ, datalen), "Vec<*> needs to be mapped identically");
83         _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_C2Tuple_usizeTransactionZZ, datalen), "Vec<*> needs to be mapped identically");
84         LDKCVec_u8Z *vec = (LDKCVec_u8Z*)ptr;
85         return (uint64_t)vec->datalen;
86 }
87 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_new_1empty_1slice_1vec (JNIEnv * env, jclass _b) {
88         // Check sizes of a few Vec types are all consistent as we're meant to be generic across types
89         _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_SignatureZ), "Vec<*> needs to be mapped identically");
90         _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_MessageSendEventZ), "Vec<*> needs to be mapped identically");
91         _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_EventZ), "Vec<*> needs to be mapped identically");
92         _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_C2Tuple_usizeTransactionZZ), "Vec<*> needs to be mapped identically");
93         LDKCVec_u8Z *vec = (LDKCVec_u8Z*)MALLOC(sizeof(LDKCVec_u8Z), "Empty LDKCVec");
94         vec->data = NULL;
95         vec->datalen = 0;
96         return (uint64_t)vec;
97 }
98
99 // We assume that CVec_u8Z and u8slice are the same size and layout (and thus pointers to the two can be mixed)
100 _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKu8slice), "Vec<u8> and [u8] need to have been mapped identically");
101 _Static_assert(offsetof(LDKCVec_u8Z, data) == offsetof(LDKu8slice, data), "Vec<u8> and [u8] need to have been mapped identically");
102 _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKu8slice, datalen), "Vec<u8> and [u8] need to have been mapped identically");
103
104 _Static_assert(sizeof(jlong) == sizeof(int64_t), "We assume that j-types are the same as C types");
105 _Static_assert(sizeof(jbyte) == sizeof(char), "We assume that j-types are the same as C types");
106 _Static_assert(sizeof(void*) <= 8, "Pointers must fit into 64 bits");
107
108 typedef jlongArray int64_tArray;
109 typedef jbyteArray int8_tArray;
110
111 static inline jstring str_ref_to_java(JNIEnv *env, const char* chars, size_t len) {
112         // Sadly we need to create a temporary because Java can't accept a char* without a 0-terminator
113         char* conv_buf = MALLOC(len + 1, "str conv buf");
114         memcpy(conv_buf, chars, len);
115         conv_buf[len] = 0;
116         jstring ret = (*env)->NewStringUTF(env, conv_buf);
117         FREE(conv_buf);
118         return ret;
119 }
120 static inline LDKStr java_to_owned_str(JNIEnv *env, jstring str) {
121         uint64_t str_len = (*env)->GetStringUTFLength(env, str);
122         char* newchars = MALLOC(str_len + 1, "String chars");
123         const char* jchars = (*env)->GetStringUTFChars(env, str, NULL);
124         memcpy(newchars, jchars, str_len);
125         newchars[str_len] = 0;
126         (*env)->ReleaseStringUTFChars(env, str, jchars);
127         LDKStr res = {
128                 .chars = newchars,
129                 .len = str_len,
130                 .chars_is_owned = true
131         };
132         return res;
133 }
134
135 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_get_1lib_1version_1string(JNIEnv *env, jclass _c) {
136         return str_ref_to_java(env, "v0.0.99.1", strlen("v0.0.99.1"));
137 }
138 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_get_1ldk_1c_1bindings_1version(JNIEnv *env, jclass _c) {
139         return str_ref_to_java(env, check_get_ldk_bindings_version(), strlen(check_get_ldk_bindings_version()));
140 }
141 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_get_1ldk_1version(JNIEnv *env, jclass _c) {
142         return str_ref_to_java(env, check_get_ldk_version(), strlen(check_get_ldk_version()));
143 }
144 static jclass arr_of_B_clz = NULL;
145 static jclass arr_of_J_clz = NULL;
146 JNIEXPORT void Java_org_ldk_impl_bindings_init_1class_1cache(JNIEnv * env, jclass clz) {
147         arr_of_B_clz = (*env)->FindClass(env, "[B");
148         CHECK(arr_of_B_clz != NULL);
149         arr_of_B_clz = (*env)->NewGlobalRef(env, arr_of_B_clz);
150         arr_of_J_clz = (*env)->FindClass(env, "[J");
151         CHECK(arr_of_J_clz != NULL);
152         arr_of_J_clz = (*env)->NewGlobalRef(env, arr_of_J_clz);
153 }
154 static inline struct LDKThirtyTwoBytes ThirtyTwoBytes_clone(const struct LDKThirtyTwoBytes *orig) { struct LDKThirtyTwoBytes ret; memcpy(ret.data, orig->data, 32); return ret; }
155 static inline LDKAccessError LDKAccessError_from_java(JNIEnv *env, jclass clz) {
156         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
157                 case 0: return LDKAccessError_UnknownChain;
158                 case 1: return LDKAccessError_UnknownTx;
159         }
160         abort();
161 }
162 static jclass AccessError_class = NULL;
163 static jfieldID AccessError_LDKAccessError_UnknownChain = NULL;
164 static jfieldID AccessError_LDKAccessError_UnknownTx = NULL;
165 JNIEXPORT void JNICALL Java_org_ldk_enums_AccessError_init (JNIEnv *env, jclass clz) {
166         AccessError_class = (*env)->NewGlobalRef(env, clz);
167         CHECK(AccessError_class != NULL);
168         AccessError_LDKAccessError_UnknownChain = (*env)->GetStaticFieldID(env, AccessError_class, "LDKAccessError_UnknownChain", "Lorg/ldk/enums/AccessError;");
169         CHECK(AccessError_LDKAccessError_UnknownChain != NULL);
170         AccessError_LDKAccessError_UnknownTx = (*env)->GetStaticFieldID(env, AccessError_class, "LDKAccessError_UnknownTx", "Lorg/ldk/enums/AccessError;");
171         CHECK(AccessError_LDKAccessError_UnknownTx != NULL);
172 }
173 static inline jclass LDKAccessError_to_java(JNIEnv *env, LDKAccessError val) {
174         switch (val) {
175                 case LDKAccessError_UnknownChain:
176                         return (*env)->GetStaticObjectField(env, AccessError_class, AccessError_LDKAccessError_UnknownChain);
177                 case LDKAccessError_UnknownTx:
178                         return (*env)->GetStaticObjectField(env, AccessError_class, AccessError_LDKAccessError_UnknownTx);
179                 default: abort();
180         }
181 }
182
183 static inline LDKChannelMonitorUpdateErr LDKChannelMonitorUpdateErr_from_java(JNIEnv *env, jclass clz) {
184         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
185                 case 0: return LDKChannelMonitorUpdateErr_TemporaryFailure;
186                 case 1: return LDKChannelMonitorUpdateErr_PermanentFailure;
187         }
188         abort();
189 }
190 static jclass ChannelMonitorUpdateErr_class = NULL;
191 static jfieldID ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_TemporaryFailure = NULL;
192 static jfieldID ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_PermanentFailure = NULL;
193 JNIEXPORT void JNICALL Java_org_ldk_enums_ChannelMonitorUpdateErr_init (JNIEnv *env, jclass clz) {
194         ChannelMonitorUpdateErr_class = (*env)->NewGlobalRef(env, clz);
195         CHECK(ChannelMonitorUpdateErr_class != NULL);
196         ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_TemporaryFailure = (*env)->GetStaticFieldID(env, ChannelMonitorUpdateErr_class, "LDKChannelMonitorUpdateErr_TemporaryFailure", "Lorg/ldk/enums/ChannelMonitorUpdateErr;");
197         CHECK(ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_TemporaryFailure != NULL);
198         ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_PermanentFailure = (*env)->GetStaticFieldID(env, ChannelMonitorUpdateErr_class, "LDKChannelMonitorUpdateErr_PermanentFailure", "Lorg/ldk/enums/ChannelMonitorUpdateErr;");
199         CHECK(ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_PermanentFailure != NULL);
200 }
201 static inline jclass LDKChannelMonitorUpdateErr_to_java(JNIEnv *env, LDKChannelMonitorUpdateErr val) {
202         switch (val) {
203                 case LDKChannelMonitorUpdateErr_TemporaryFailure:
204                         return (*env)->GetStaticObjectField(env, ChannelMonitorUpdateErr_class, ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_TemporaryFailure);
205                 case LDKChannelMonitorUpdateErr_PermanentFailure:
206                         return (*env)->GetStaticObjectField(env, ChannelMonitorUpdateErr_class, ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_PermanentFailure);
207                 default: abort();
208         }
209 }
210
211 static inline LDKConfirmationTarget LDKConfirmationTarget_from_java(JNIEnv *env, jclass clz) {
212         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
213                 case 0: return LDKConfirmationTarget_Background;
214                 case 1: return LDKConfirmationTarget_Normal;
215                 case 2: return LDKConfirmationTarget_HighPriority;
216         }
217         abort();
218 }
219 static jclass ConfirmationTarget_class = NULL;
220 static jfieldID ConfirmationTarget_LDKConfirmationTarget_Background = NULL;
221 static jfieldID ConfirmationTarget_LDKConfirmationTarget_Normal = NULL;
222 static jfieldID ConfirmationTarget_LDKConfirmationTarget_HighPriority = NULL;
223 JNIEXPORT void JNICALL Java_org_ldk_enums_ConfirmationTarget_init (JNIEnv *env, jclass clz) {
224         ConfirmationTarget_class = (*env)->NewGlobalRef(env, clz);
225         CHECK(ConfirmationTarget_class != NULL);
226         ConfirmationTarget_LDKConfirmationTarget_Background = (*env)->GetStaticFieldID(env, ConfirmationTarget_class, "LDKConfirmationTarget_Background", "Lorg/ldk/enums/ConfirmationTarget;");
227         CHECK(ConfirmationTarget_LDKConfirmationTarget_Background != NULL);
228         ConfirmationTarget_LDKConfirmationTarget_Normal = (*env)->GetStaticFieldID(env, ConfirmationTarget_class, "LDKConfirmationTarget_Normal", "Lorg/ldk/enums/ConfirmationTarget;");
229         CHECK(ConfirmationTarget_LDKConfirmationTarget_Normal != NULL);
230         ConfirmationTarget_LDKConfirmationTarget_HighPriority = (*env)->GetStaticFieldID(env, ConfirmationTarget_class, "LDKConfirmationTarget_HighPriority", "Lorg/ldk/enums/ConfirmationTarget;");
231         CHECK(ConfirmationTarget_LDKConfirmationTarget_HighPriority != NULL);
232 }
233 static inline jclass LDKConfirmationTarget_to_java(JNIEnv *env, LDKConfirmationTarget val) {
234         switch (val) {
235                 case LDKConfirmationTarget_Background:
236                         return (*env)->GetStaticObjectField(env, ConfirmationTarget_class, ConfirmationTarget_LDKConfirmationTarget_Background);
237                 case LDKConfirmationTarget_Normal:
238                         return (*env)->GetStaticObjectField(env, ConfirmationTarget_class, ConfirmationTarget_LDKConfirmationTarget_Normal);
239                 case LDKConfirmationTarget_HighPriority:
240                         return (*env)->GetStaticObjectField(env, ConfirmationTarget_class, ConfirmationTarget_LDKConfirmationTarget_HighPriority);
241                 default: abort();
242         }
243 }
244
245 static inline LDKCreationError LDKCreationError_from_java(JNIEnv *env, jclass clz) {
246         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
247                 case 0: return LDKCreationError_DescriptionTooLong;
248                 case 1: return LDKCreationError_RouteTooLong;
249                 case 2: return LDKCreationError_TimestampOutOfBounds;
250                 case 3: return LDKCreationError_ExpiryTimeOutOfBounds;
251         }
252         abort();
253 }
254 static jclass CreationError_class = NULL;
255 static jfieldID CreationError_LDKCreationError_DescriptionTooLong = NULL;
256 static jfieldID CreationError_LDKCreationError_RouteTooLong = NULL;
257 static jfieldID CreationError_LDKCreationError_TimestampOutOfBounds = NULL;
258 static jfieldID CreationError_LDKCreationError_ExpiryTimeOutOfBounds = NULL;
259 JNIEXPORT void JNICALL Java_org_ldk_enums_CreationError_init (JNIEnv *env, jclass clz) {
260         CreationError_class = (*env)->NewGlobalRef(env, clz);
261         CHECK(CreationError_class != NULL);
262         CreationError_LDKCreationError_DescriptionTooLong = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_DescriptionTooLong", "Lorg/ldk/enums/CreationError;");
263         CHECK(CreationError_LDKCreationError_DescriptionTooLong != NULL);
264         CreationError_LDKCreationError_RouteTooLong = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_RouteTooLong", "Lorg/ldk/enums/CreationError;");
265         CHECK(CreationError_LDKCreationError_RouteTooLong != NULL);
266         CreationError_LDKCreationError_TimestampOutOfBounds = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_TimestampOutOfBounds", "Lorg/ldk/enums/CreationError;");
267         CHECK(CreationError_LDKCreationError_TimestampOutOfBounds != NULL);
268         CreationError_LDKCreationError_ExpiryTimeOutOfBounds = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_ExpiryTimeOutOfBounds", "Lorg/ldk/enums/CreationError;");
269         CHECK(CreationError_LDKCreationError_ExpiryTimeOutOfBounds != NULL);
270 }
271 static inline jclass LDKCreationError_to_java(JNIEnv *env, LDKCreationError val) {
272         switch (val) {
273                 case LDKCreationError_DescriptionTooLong:
274                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_DescriptionTooLong);
275                 case LDKCreationError_RouteTooLong:
276                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_RouteTooLong);
277                 case LDKCreationError_TimestampOutOfBounds:
278                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_TimestampOutOfBounds);
279                 case LDKCreationError_ExpiryTimeOutOfBounds:
280                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_ExpiryTimeOutOfBounds);
281                 default: abort();
282         }
283 }
284
285 static inline LDKCurrency LDKCurrency_from_java(JNIEnv *env, jclass clz) {
286         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
287                 case 0: return LDKCurrency_Bitcoin;
288                 case 1: return LDKCurrency_BitcoinTestnet;
289                 case 2: return LDKCurrency_Regtest;
290                 case 3: return LDKCurrency_Simnet;
291                 case 4: return LDKCurrency_Signet;
292         }
293         abort();
294 }
295 static jclass Currency_class = NULL;
296 static jfieldID Currency_LDKCurrency_Bitcoin = NULL;
297 static jfieldID Currency_LDKCurrency_BitcoinTestnet = NULL;
298 static jfieldID Currency_LDKCurrency_Regtest = NULL;
299 static jfieldID Currency_LDKCurrency_Simnet = NULL;
300 static jfieldID Currency_LDKCurrency_Signet = NULL;
301 JNIEXPORT void JNICALL Java_org_ldk_enums_Currency_init (JNIEnv *env, jclass clz) {
302         Currency_class = (*env)->NewGlobalRef(env, clz);
303         CHECK(Currency_class != NULL);
304         Currency_LDKCurrency_Bitcoin = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_Bitcoin", "Lorg/ldk/enums/Currency;");
305         CHECK(Currency_LDKCurrency_Bitcoin != NULL);
306         Currency_LDKCurrency_BitcoinTestnet = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_BitcoinTestnet", "Lorg/ldk/enums/Currency;");
307         CHECK(Currency_LDKCurrency_BitcoinTestnet != NULL);
308         Currency_LDKCurrency_Regtest = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_Regtest", "Lorg/ldk/enums/Currency;");
309         CHECK(Currency_LDKCurrency_Regtest != NULL);
310         Currency_LDKCurrency_Simnet = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_Simnet", "Lorg/ldk/enums/Currency;");
311         CHECK(Currency_LDKCurrency_Simnet != NULL);
312         Currency_LDKCurrency_Signet = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_Signet", "Lorg/ldk/enums/Currency;");
313         CHECK(Currency_LDKCurrency_Signet != NULL);
314 }
315 static inline jclass LDKCurrency_to_java(JNIEnv *env, LDKCurrency val) {
316         switch (val) {
317                 case LDKCurrency_Bitcoin:
318                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_Bitcoin);
319                 case LDKCurrency_BitcoinTestnet:
320                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_BitcoinTestnet);
321                 case LDKCurrency_Regtest:
322                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_Regtest);
323                 case LDKCurrency_Simnet:
324                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_Simnet);
325                 case LDKCurrency_Signet:
326                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_Signet);
327                 default: abort();
328         }
329 }
330
331 static inline LDKIOError LDKIOError_from_java(JNIEnv *env, jclass clz) {
332         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
333                 case 0: return LDKIOError_NotFound;
334                 case 1: return LDKIOError_PermissionDenied;
335                 case 2: return LDKIOError_ConnectionRefused;
336                 case 3: return LDKIOError_ConnectionReset;
337                 case 4: return LDKIOError_ConnectionAborted;
338                 case 5: return LDKIOError_NotConnected;
339                 case 6: return LDKIOError_AddrInUse;
340                 case 7: return LDKIOError_AddrNotAvailable;
341                 case 8: return LDKIOError_BrokenPipe;
342                 case 9: return LDKIOError_AlreadyExists;
343                 case 10: return LDKIOError_WouldBlock;
344                 case 11: return LDKIOError_InvalidInput;
345                 case 12: return LDKIOError_InvalidData;
346                 case 13: return LDKIOError_TimedOut;
347                 case 14: return LDKIOError_WriteZero;
348                 case 15: return LDKIOError_Interrupted;
349                 case 16: return LDKIOError_Other;
350                 case 17: return LDKIOError_UnexpectedEof;
351         }
352         abort();
353 }
354 static jclass IOError_class = NULL;
355 static jfieldID IOError_LDKIOError_NotFound = NULL;
356 static jfieldID IOError_LDKIOError_PermissionDenied = NULL;
357 static jfieldID IOError_LDKIOError_ConnectionRefused = NULL;
358 static jfieldID IOError_LDKIOError_ConnectionReset = NULL;
359 static jfieldID IOError_LDKIOError_ConnectionAborted = NULL;
360 static jfieldID IOError_LDKIOError_NotConnected = NULL;
361 static jfieldID IOError_LDKIOError_AddrInUse = NULL;
362 static jfieldID IOError_LDKIOError_AddrNotAvailable = NULL;
363 static jfieldID IOError_LDKIOError_BrokenPipe = NULL;
364 static jfieldID IOError_LDKIOError_AlreadyExists = NULL;
365 static jfieldID IOError_LDKIOError_WouldBlock = NULL;
366 static jfieldID IOError_LDKIOError_InvalidInput = NULL;
367 static jfieldID IOError_LDKIOError_InvalidData = NULL;
368 static jfieldID IOError_LDKIOError_TimedOut = NULL;
369 static jfieldID IOError_LDKIOError_WriteZero = NULL;
370 static jfieldID IOError_LDKIOError_Interrupted = NULL;
371 static jfieldID IOError_LDKIOError_Other = NULL;
372 static jfieldID IOError_LDKIOError_UnexpectedEof = NULL;
373 JNIEXPORT void JNICALL Java_org_ldk_enums_IOError_init (JNIEnv *env, jclass clz) {
374         IOError_class = (*env)->NewGlobalRef(env, clz);
375         CHECK(IOError_class != NULL);
376         IOError_LDKIOError_NotFound = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_NotFound", "Lorg/ldk/enums/IOError;");
377         CHECK(IOError_LDKIOError_NotFound != NULL);
378         IOError_LDKIOError_PermissionDenied = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_PermissionDenied", "Lorg/ldk/enums/IOError;");
379         CHECK(IOError_LDKIOError_PermissionDenied != NULL);
380         IOError_LDKIOError_ConnectionRefused = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_ConnectionRefused", "Lorg/ldk/enums/IOError;");
381         CHECK(IOError_LDKIOError_ConnectionRefused != NULL);
382         IOError_LDKIOError_ConnectionReset = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_ConnectionReset", "Lorg/ldk/enums/IOError;");
383         CHECK(IOError_LDKIOError_ConnectionReset != NULL);
384         IOError_LDKIOError_ConnectionAborted = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_ConnectionAborted", "Lorg/ldk/enums/IOError;");
385         CHECK(IOError_LDKIOError_ConnectionAborted != NULL);
386         IOError_LDKIOError_NotConnected = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_NotConnected", "Lorg/ldk/enums/IOError;");
387         CHECK(IOError_LDKIOError_NotConnected != NULL);
388         IOError_LDKIOError_AddrInUse = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_AddrInUse", "Lorg/ldk/enums/IOError;");
389         CHECK(IOError_LDKIOError_AddrInUse != NULL);
390         IOError_LDKIOError_AddrNotAvailable = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_AddrNotAvailable", "Lorg/ldk/enums/IOError;");
391         CHECK(IOError_LDKIOError_AddrNotAvailable != NULL);
392         IOError_LDKIOError_BrokenPipe = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_BrokenPipe", "Lorg/ldk/enums/IOError;");
393         CHECK(IOError_LDKIOError_BrokenPipe != NULL);
394         IOError_LDKIOError_AlreadyExists = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_AlreadyExists", "Lorg/ldk/enums/IOError;");
395         CHECK(IOError_LDKIOError_AlreadyExists != NULL);
396         IOError_LDKIOError_WouldBlock = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_WouldBlock", "Lorg/ldk/enums/IOError;");
397         CHECK(IOError_LDKIOError_WouldBlock != NULL);
398         IOError_LDKIOError_InvalidInput = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_InvalidInput", "Lorg/ldk/enums/IOError;");
399         CHECK(IOError_LDKIOError_InvalidInput != NULL);
400         IOError_LDKIOError_InvalidData = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_InvalidData", "Lorg/ldk/enums/IOError;");
401         CHECK(IOError_LDKIOError_InvalidData != NULL);
402         IOError_LDKIOError_TimedOut = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_TimedOut", "Lorg/ldk/enums/IOError;");
403         CHECK(IOError_LDKIOError_TimedOut != NULL);
404         IOError_LDKIOError_WriteZero = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_WriteZero", "Lorg/ldk/enums/IOError;");
405         CHECK(IOError_LDKIOError_WriteZero != NULL);
406         IOError_LDKIOError_Interrupted = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_Interrupted", "Lorg/ldk/enums/IOError;");
407         CHECK(IOError_LDKIOError_Interrupted != NULL);
408         IOError_LDKIOError_Other = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_Other", "Lorg/ldk/enums/IOError;");
409         CHECK(IOError_LDKIOError_Other != NULL);
410         IOError_LDKIOError_UnexpectedEof = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_UnexpectedEof", "Lorg/ldk/enums/IOError;");
411         CHECK(IOError_LDKIOError_UnexpectedEof != NULL);
412 }
413 static inline jclass LDKIOError_to_java(JNIEnv *env, LDKIOError val) {
414         switch (val) {
415                 case LDKIOError_NotFound:
416                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_NotFound);
417                 case LDKIOError_PermissionDenied:
418                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_PermissionDenied);
419                 case LDKIOError_ConnectionRefused:
420                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_ConnectionRefused);
421                 case LDKIOError_ConnectionReset:
422                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_ConnectionReset);
423                 case LDKIOError_ConnectionAborted:
424                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_ConnectionAborted);
425                 case LDKIOError_NotConnected:
426                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_NotConnected);
427                 case LDKIOError_AddrInUse:
428                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_AddrInUse);
429                 case LDKIOError_AddrNotAvailable:
430                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_AddrNotAvailable);
431                 case LDKIOError_BrokenPipe:
432                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_BrokenPipe);
433                 case LDKIOError_AlreadyExists:
434                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_AlreadyExists);
435                 case LDKIOError_WouldBlock:
436                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_WouldBlock);
437                 case LDKIOError_InvalidInput:
438                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_InvalidInput);
439                 case LDKIOError_InvalidData:
440                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_InvalidData);
441                 case LDKIOError_TimedOut:
442                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_TimedOut);
443                 case LDKIOError_WriteZero:
444                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_WriteZero);
445                 case LDKIOError_Interrupted:
446                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_Interrupted);
447                 case LDKIOError_Other:
448                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_Other);
449                 case LDKIOError_UnexpectedEof:
450                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_UnexpectedEof);
451                 default: abort();
452         }
453 }
454
455 static inline LDKLevel LDKLevel_from_java(JNIEnv *env, jclass clz) {
456         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
457                 case 0: return LDKLevel_Trace;
458                 case 1: return LDKLevel_Debug;
459                 case 2: return LDKLevel_Info;
460                 case 3: return LDKLevel_Warn;
461                 case 4: return LDKLevel_Error;
462         }
463         abort();
464 }
465 static jclass Level_class = NULL;
466 static jfieldID Level_LDKLevel_Trace = NULL;
467 static jfieldID Level_LDKLevel_Debug = NULL;
468 static jfieldID Level_LDKLevel_Info = NULL;
469 static jfieldID Level_LDKLevel_Warn = NULL;
470 static jfieldID Level_LDKLevel_Error = NULL;
471 JNIEXPORT void JNICALL Java_org_ldk_enums_Level_init (JNIEnv *env, jclass clz) {
472         Level_class = (*env)->NewGlobalRef(env, clz);
473         CHECK(Level_class != NULL);
474         Level_LDKLevel_Trace = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Trace", "Lorg/ldk/enums/Level;");
475         CHECK(Level_LDKLevel_Trace != NULL);
476         Level_LDKLevel_Debug = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Debug", "Lorg/ldk/enums/Level;");
477         CHECK(Level_LDKLevel_Debug != NULL);
478         Level_LDKLevel_Info = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Info", "Lorg/ldk/enums/Level;");
479         CHECK(Level_LDKLevel_Info != NULL);
480         Level_LDKLevel_Warn = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Warn", "Lorg/ldk/enums/Level;");
481         CHECK(Level_LDKLevel_Warn != NULL);
482         Level_LDKLevel_Error = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Error", "Lorg/ldk/enums/Level;");
483         CHECK(Level_LDKLevel_Error != NULL);
484 }
485 static inline jclass LDKLevel_to_java(JNIEnv *env, LDKLevel val) {
486         switch (val) {
487                 case LDKLevel_Trace:
488                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Trace);
489                 case LDKLevel_Debug:
490                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Debug);
491                 case LDKLevel_Info:
492                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Info);
493                 case LDKLevel_Warn:
494                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Warn);
495                 case LDKLevel_Error:
496                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Error);
497                 default: abort();
498         }
499 }
500
501 static inline LDKNetwork LDKNetwork_from_java(JNIEnv *env, jclass clz) {
502         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
503                 case 0: return LDKNetwork_Bitcoin;
504                 case 1: return LDKNetwork_Testnet;
505                 case 2: return LDKNetwork_Regtest;
506                 case 3: return LDKNetwork_Signet;
507         }
508         abort();
509 }
510 static jclass Network_class = NULL;
511 static jfieldID Network_LDKNetwork_Bitcoin = NULL;
512 static jfieldID Network_LDKNetwork_Testnet = NULL;
513 static jfieldID Network_LDKNetwork_Regtest = NULL;
514 static jfieldID Network_LDKNetwork_Signet = NULL;
515 JNIEXPORT void JNICALL Java_org_ldk_enums_Network_init (JNIEnv *env, jclass clz) {
516         Network_class = (*env)->NewGlobalRef(env, clz);
517         CHECK(Network_class != NULL);
518         Network_LDKNetwork_Bitcoin = (*env)->GetStaticFieldID(env, Network_class, "LDKNetwork_Bitcoin", "Lorg/ldk/enums/Network;");
519         CHECK(Network_LDKNetwork_Bitcoin != NULL);
520         Network_LDKNetwork_Testnet = (*env)->GetStaticFieldID(env, Network_class, "LDKNetwork_Testnet", "Lorg/ldk/enums/Network;");
521         CHECK(Network_LDKNetwork_Testnet != NULL);
522         Network_LDKNetwork_Regtest = (*env)->GetStaticFieldID(env, Network_class, "LDKNetwork_Regtest", "Lorg/ldk/enums/Network;");
523         CHECK(Network_LDKNetwork_Regtest != NULL);
524         Network_LDKNetwork_Signet = (*env)->GetStaticFieldID(env, Network_class, "LDKNetwork_Signet", "Lorg/ldk/enums/Network;");
525         CHECK(Network_LDKNetwork_Signet != NULL);
526 }
527 static inline jclass LDKNetwork_to_java(JNIEnv *env, LDKNetwork val) {
528         switch (val) {
529                 case LDKNetwork_Bitcoin:
530                         return (*env)->GetStaticObjectField(env, Network_class, Network_LDKNetwork_Bitcoin);
531                 case LDKNetwork_Testnet:
532                         return (*env)->GetStaticObjectField(env, Network_class, Network_LDKNetwork_Testnet);
533                 case LDKNetwork_Regtest:
534                         return (*env)->GetStaticObjectField(env, Network_class, Network_LDKNetwork_Regtest);
535                 case LDKNetwork_Signet:
536                         return (*env)->GetStaticObjectField(env, Network_class, Network_LDKNetwork_Signet);
537                 default: abort();
538         }
539 }
540
541 static inline LDKSecp256k1Error LDKSecp256k1Error_from_java(JNIEnv *env, jclass clz) {
542         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
543                 case 0: return LDKSecp256k1Error_IncorrectSignature;
544                 case 1: return LDKSecp256k1Error_InvalidMessage;
545                 case 2: return LDKSecp256k1Error_InvalidPublicKey;
546                 case 3: return LDKSecp256k1Error_InvalidSignature;
547                 case 4: return LDKSecp256k1Error_InvalidSecretKey;
548                 case 5: return LDKSecp256k1Error_InvalidRecoveryId;
549                 case 6: return LDKSecp256k1Error_InvalidTweak;
550                 case 7: return LDKSecp256k1Error_TweakCheckFailed;
551                 case 8: return LDKSecp256k1Error_NotEnoughMemory;
552         }
553         abort();
554 }
555 static jclass Secp256k1Error_class = NULL;
556 static jfieldID Secp256k1Error_LDKSecp256k1Error_IncorrectSignature = NULL;
557 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidMessage = NULL;
558 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey = NULL;
559 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidSignature = NULL;
560 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey = NULL;
561 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId = NULL;
562 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidTweak = NULL;
563 static jfieldID Secp256k1Error_LDKSecp256k1Error_TweakCheckFailed = NULL;
564 static jfieldID Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory = NULL;
565 JNIEXPORT void JNICALL Java_org_ldk_enums_Secp256k1Error_init (JNIEnv *env, jclass clz) {
566         Secp256k1Error_class = (*env)->NewGlobalRef(env, clz);
567         CHECK(Secp256k1Error_class != NULL);
568         Secp256k1Error_LDKSecp256k1Error_IncorrectSignature = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_IncorrectSignature", "Lorg/ldk/enums/Secp256k1Error;");
569         CHECK(Secp256k1Error_LDKSecp256k1Error_IncorrectSignature != NULL);
570         Secp256k1Error_LDKSecp256k1Error_InvalidMessage = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidMessage", "Lorg/ldk/enums/Secp256k1Error;");
571         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidMessage != NULL);
572         Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidPublicKey", "Lorg/ldk/enums/Secp256k1Error;");
573         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey != NULL);
574         Secp256k1Error_LDKSecp256k1Error_InvalidSignature = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidSignature", "Lorg/ldk/enums/Secp256k1Error;");
575         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidSignature != NULL);
576         Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidSecretKey", "Lorg/ldk/enums/Secp256k1Error;");
577         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey != NULL);
578         Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidRecoveryId", "Lorg/ldk/enums/Secp256k1Error;");
579         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId != NULL);
580         Secp256k1Error_LDKSecp256k1Error_InvalidTweak = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidTweak", "Lorg/ldk/enums/Secp256k1Error;");
581         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidTweak != NULL);
582         Secp256k1Error_LDKSecp256k1Error_TweakCheckFailed = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_TweakCheckFailed", "Lorg/ldk/enums/Secp256k1Error;");
583         CHECK(Secp256k1Error_LDKSecp256k1Error_TweakCheckFailed != NULL);
584         Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_NotEnoughMemory", "Lorg/ldk/enums/Secp256k1Error;");
585         CHECK(Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory != NULL);
586 }
587 static inline jclass LDKSecp256k1Error_to_java(JNIEnv *env, LDKSecp256k1Error val) {
588         switch (val) {
589                 case LDKSecp256k1Error_IncorrectSignature:
590                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_IncorrectSignature);
591                 case LDKSecp256k1Error_InvalidMessage:
592                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidMessage);
593                 case LDKSecp256k1Error_InvalidPublicKey:
594                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey);
595                 case LDKSecp256k1Error_InvalidSignature:
596                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidSignature);
597                 case LDKSecp256k1Error_InvalidSecretKey:
598                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey);
599                 case LDKSecp256k1Error_InvalidRecoveryId:
600                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId);
601                 case LDKSecp256k1Error_InvalidTweak:
602                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidTweak);
603                 case LDKSecp256k1Error_TweakCheckFailed:
604                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_TweakCheckFailed);
605                 case LDKSecp256k1Error_NotEnoughMemory:
606                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory);
607                 default: abort();
608         }
609 }
610
611 static inline LDKSemanticError LDKSemanticError_from_java(JNIEnv *env, jclass clz) {
612         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
613                 case 0: return LDKSemanticError_NoPaymentHash;
614                 case 1: return LDKSemanticError_MultiplePaymentHashes;
615                 case 2: return LDKSemanticError_NoDescription;
616                 case 3: return LDKSemanticError_MultipleDescriptions;
617                 case 4: return LDKSemanticError_MultiplePaymentSecrets;
618                 case 5: return LDKSemanticError_InvalidFeatures;
619                 case 6: return LDKSemanticError_InvalidRecoveryId;
620                 case 7: return LDKSemanticError_InvalidSignature;
621         }
622         abort();
623 }
624 static jclass SemanticError_class = NULL;
625 static jfieldID SemanticError_LDKSemanticError_NoPaymentHash = NULL;
626 static jfieldID SemanticError_LDKSemanticError_MultiplePaymentHashes = NULL;
627 static jfieldID SemanticError_LDKSemanticError_NoDescription = NULL;
628 static jfieldID SemanticError_LDKSemanticError_MultipleDescriptions = NULL;
629 static jfieldID SemanticError_LDKSemanticError_MultiplePaymentSecrets = NULL;
630 static jfieldID SemanticError_LDKSemanticError_InvalidFeatures = NULL;
631 static jfieldID SemanticError_LDKSemanticError_InvalidRecoveryId = NULL;
632 static jfieldID SemanticError_LDKSemanticError_InvalidSignature = NULL;
633 JNIEXPORT void JNICALL Java_org_ldk_enums_SemanticError_init (JNIEnv *env, jclass clz) {
634         SemanticError_class = (*env)->NewGlobalRef(env, clz);
635         CHECK(SemanticError_class != NULL);
636         SemanticError_LDKSemanticError_NoPaymentHash = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_NoPaymentHash", "Lorg/ldk/enums/SemanticError;");
637         CHECK(SemanticError_LDKSemanticError_NoPaymentHash != NULL);
638         SemanticError_LDKSemanticError_MultiplePaymentHashes = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_MultiplePaymentHashes", "Lorg/ldk/enums/SemanticError;");
639         CHECK(SemanticError_LDKSemanticError_MultiplePaymentHashes != NULL);
640         SemanticError_LDKSemanticError_NoDescription = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_NoDescription", "Lorg/ldk/enums/SemanticError;");
641         CHECK(SemanticError_LDKSemanticError_NoDescription != NULL);
642         SemanticError_LDKSemanticError_MultipleDescriptions = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_MultipleDescriptions", "Lorg/ldk/enums/SemanticError;");
643         CHECK(SemanticError_LDKSemanticError_MultipleDescriptions != NULL);
644         SemanticError_LDKSemanticError_MultiplePaymentSecrets = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_MultiplePaymentSecrets", "Lorg/ldk/enums/SemanticError;");
645         CHECK(SemanticError_LDKSemanticError_MultiplePaymentSecrets != NULL);
646         SemanticError_LDKSemanticError_InvalidFeatures = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_InvalidFeatures", "Lorg/ldk/enums/SemanticError;");
647         CHECK(SemanticError_LDKSemanticError_InvalidFeatures != NULL);
648         SemanticError_LDKSemanticError_InvalidRecoveryId = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_InvalidRecoveryId", "Lorg/ldk/enums/SemanticError;");
649         CHECK(SemanticError_LDKSemanticError_InvalidRecoveryId != NULL);
650         SemanticError_LDKSemanticError_InvalidSignature = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_InvalidSignature", "Lorg/ldk/enums/SemanticError;");
651         CHECK(SemanticError_LDKSemanticError_InvalidSignature != NULL);
652 }
653 static inline jclass LDKSemanticError_to_java(JNIEnv *env, LDKSemanticError val) {
654         switch (val) {
655                 case LDKSemanticError_NoPaymentHash:
656                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_NoPaymentHash);
657                 case LDKSemanticError_MultiplePaymentHashes:
658                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_MultiplePaymentHashes);
659                 case LDKSemanticError_NoDescription:
660                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_NoDescription);
661                 case LDKSemanticError_MultipleDescriptions:
662                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_MultipleDescriptions);
663                 case LDKSemanticError_MultiplePaymentSecrets:
664                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_MultiplePaymentSecrets);
665                 case LDKSemanticError_InvalidFeatures:
666                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_InvalidFeatures);
667                 case LDKSemanticError_InvalidRecoveryId:
668                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_InvalidRecoveryId);
669                 case LDKSemanticError_InvalidSignature:
670                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_InvalidSignature);
671                 default: abort();
672         }
673 }
674
675 static inline LDKSiPrefix LDKSiPrefix_from_java(JNIEnv *env, jclass clz) {
676         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
677                 case 0: return LDKSiPrefix_Milli;
678                 case 1: return LDKSiPrefix_Micro;
679                 case 2: return LDKSiPrefix_Nano;
680                 case 3: return LDKSiPrefix_Pico;
681         }
682         abort();
683 }
684 static jclass SiPrefix_class = NULL;
685 static jfieldID SiPrefix_LDKSiPrefix_Milli = NULL;
686 static jfieldID SiPrefix_LDKSiPrefix_Micro = NULL;
687 static jfieldID SiPrefix_LDKSiPrefix_Nano = NULL;
688 static jfieldID SiPrefix_LDKSiPrefix_Pico = NULL;
689 JNIEXPORT void JNICALL Java_org_ldk_enums_SiPrefix_init (JNIEnv *env, jclass clz) {
690         SiPrefix_class = (*env)->NewGlobalRef(env, clz);
691         CHECK(SiPrefix_class != NULL);
692         SiPrefix_LDKSiPrefix_Milli = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Milli", "Lorg/ldk/enums/SiPrefix;");
693         CHECK(SiPrefix_LDKSiPrefix_Milli != NULL);
694         SiPrefix_LDKSiPrefix_Micro = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Micro", "Lorg/ldk/enums/SiPrefix;");
695         CHECK(SiPrefix_LDKSiPrefix_Micro != NULL);
696         SiPrefix_LDKSiPrefix_Nano = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Nano", "Lorg/ldk/enums/SiPrefix;");
697         CHECK(SiPrefix_LDKSiPrefix_Nano != NULL);
698         SiPrefix_LDKSiPrefix_Pico = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Pico", "Lorg/ldk/enums/SiPrefix;");
699         CHECK(SiPrefix_LDKSiPrefix_Pico != NULL);
700 }
701 static inline jclass LDKSiPrefix_to_java(JNIEnv *env, LDKSiPrefix val) {
702         switch (val) {
703                 case LDKSiPrefix_Milli:
704                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Milli);
705                 case LDKSiPrefix_Micro:
706                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Micro);
707                 case LDKSiPrefix_Nano:
708                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Nano);
709                 case LDKSiPrefix_Pico:
710                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Pico);
711                 default: abort();
712         }
713 }
714
715 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1u8Z_1new(JNIEnv *env, jclass clz, int8_tArray elems) {
716         LDKCVec_u8Z *ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
717         ret->datalen = (*env)->GetArrayLength(env, elems);
718         if (ret->datalen == 0) {
719                 ret->data = NULL;
720         } else {
721                 ret->data = MALLOC(sizeof(uint8_t) * ret->datalen, "LDKCVec_u8Z Data");
722                 int8_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
723                 for (size_t i = 0; i < ret->datalen; i++) {
724                         ret->data[i] = java_elems[i];
725                 }
726                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
727         }
728         return (uint64_t)ret;
729 }
730 static inline LDKCVec_u8Z CVec_u8Z_clone(const LDKCVec_u8Z *orig) {
731         LDKCVec_u8Z ret = { .data = MALLOC(sizeof(int8_t) * orig->datalen, "LDKCVec_u8Z clone bytes"), .datalen = orig->datalen };
732         memcpy(ret.data, orig->data, sizeof(int8_t) * ret.datalen);
733         return ret;
734 }
735 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SecretKeyErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
736         return ((LDKCResult_SecretKeyErrorZ*)arg)->result_ok;
737 }
738 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SecretKeyErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
739         LDKCResult_SecretKeyErrorZ *val = (LDKCResult_SecretKeyErrorZ*)(arg & ~1);
740         CHECK(val->result_ok);
741         int8_tArray res_arr = (*env)->NewByteArray(env, 32);
742         (*env)->SetByteArrayRegion(env, res_arr, 0, 32, (*val->contents.result).bytes);
743         return res_arr;
744 }
745 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SecretKeyErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
746         LDKCResult_SecretKeyErrorZ *val = (LDKCResult_SecretKeyErrorZ*)(arg & ~1);
747         CHECK(!val->result_ok);
748         jclass err_conv = LDKSecp256k1Error_to_java(env, (*val->contents.err));
749         return err_conv;
750 }
751 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PublicKeyErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
752         return ((LDKCResult_PublicKeyErrorZ*)arg)->result_ok;
753 }
754 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PublicKeyErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
755         LDKCResult_PublicKeyErrorZ *val = (LDKCResult_PublicKeyErrorZ*)(arg & ~1);
756         CHECK(val->result_ok);
757         int8_tArray res_arr = (*env)->NewByteArray(env, 33);
758         (*env)->SetByteArrayRegion(env, res_arr, 0, 33, (*val->contents.result).compressed_form);
759         return res_arr;
760 }
761 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PublicKeyErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
762         LDKCResult_PublicKeyErrorZ *val = (LDKCResult_PublicKeyErrorZ*)(arg & ~1);
763         CHECK(!val->result_ok);
764         jclass err_conv = LDKSecp256k1Error_to_java(env, (*val->contents.err));
765         return err_conv;
766 }
767 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
768         return ((LDKCResult_TxCreationKeysDecodeErrorZ*)arg)->result_ok;
769 }
770 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
771         LDKCResult_TxCreationKeysDecodeErrorZ *val = (LDKCResult_TxCreationKeysDecodeErrorZ*)(arg & ~1);
772         CHECK(val->result_ok);
773         LDKTxCreationKeys res_var = (*val->contents.result);
774         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
775         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
776         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
777         return res_ref;
778 }
779 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
780         LDKCResult_TxCreationKeysDecodeErrorZ *val = (LDKCResult_TxCreationKeysDecodeErrorZ*)(arg & ~1);
781         CHECK(!val->result_ok);
782         LDKDecodeError err_var = (*val->contents.err);
783         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
784         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
785         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
786         return err_ref;
787 }
788 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelPublicKeysDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
789         return ((LDKCResult_ChannelPublicKeysDecodeErrorZ*)arg)->result_ok;
790 }
791 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelPublicKeysDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
792         LDKCResult_ChannelPublicKeysDecodeErrorZ *val = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(arg & ~1);
793         CHECK(val->result_ok);
794         LDKChannelPublicKeys res_var = (*val->contents.result);
795         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
796         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
797         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
798         return res_ref;
799 }
800 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelPublicKeysDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
801         LDKCResult_ChannelPublicKeysDecodeErrorZ *val = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(arg & ~1);
802         CHECK(!val->result_ok);
803         LDKDecodeError err_var = (*val->contents.err);
804         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
805         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
806         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
807         return err_ref;
808 }
809 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
810         return ((LDKCResult_TxCreationKeysErrorZ*)arg)->result_ok;
811 }
812 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
813         LDKCResult_TxCreationKeysErrorZ *val = (LDKCResult_TxCreationKeysErrorZ*)(arg & ~1);
814         CHECK(val->result_ok);
815         LDKTxCreationKeys res_var = (*val->contents.result);
816         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
817         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
818         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
819         return res_ref;
820 }
821 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
822         LDKCResult_TxCreationKeysErrorZ *val = (LDKCResult_TxCreationKeysErrorZ*)(arg & ~1);
823         CHECK(!val->result_ok);
824         jclass err_conv = LDKSecp256k1Error_to_java(env, (*val->contents.err));
825         return err_conv;
826 }
827 static jclass LDKCOption_u32Z_Some_class = NULL;
828 static jmethodID LDKCOption_u32Z_Some_meth = NULL;
829 static jclass LDKCOption_u32Z_None_class = NULL;
830 static jmethodID LDKCOption_u32Z_None_meth = NULL;
831 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u32Z_init (JNIEnv *env, jclass clz) {
832         LDKCOption_u32Z_Some_class =
833                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_u32Z$Some;"));
834         CHECK(LDKCOption_u32Z_Some_class != NULL);
835         LDKCOption_u32Z_Some_meth = (*env)->GetMethodID(env, LDKCOption_u32Z_Some_class, "<init>", "(I)V");
836         CHECK(LDKCOption_u32Z_Some_meth != NULL);
837         LDKCOption_u32Z_None_class =
838                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_u32Z$None;"));
839         CHECK(LDKCOption_u32Z_None_class != NULL);
840         LDKCOption_u32Z_None_meth = (*env)->GetMethodID(env, LDKCOption_u32Z_None_class, "<init>", "()V");
841         CHECK(LDKCOption_u32Z_None_meth != NULL);
842 }
843 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u32Z_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
844         LDKCOption_u32Z *obj = (LDKCOption_u32Z*)(ptr & ~1);
845         switch(obj->tag) {
846                 case LDKCOption_u32Z_Some: {
847                         return (*env)->NewObject(env, LDKCOption_u32Z_Some_class, LDKCOption_u32Z_Some_meth, obj->some);
848                 }
849                 case LDKCOption_u32Z_None: {
850                         return (*env)->NewObject(env, LDKCOption_u32Z_None_class, LDKCOption_u32Z_None_meth);
851                 }
852                 default: abort();
853         }
854 }
855 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCOutputInCommitmentDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
856         return ((LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)arg)->result_ok;
857 }
858 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCOutputInCommitmentDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
859         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *val = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(arg & ~1);
860         CHECK(val->result_ok);
861         LDKHTLCOutputInCommitment res_var = (*val->contents.result);
862         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
863         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
864         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
865         return res_ref;
866 }
867 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCOutputInCommitmentDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
868         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *val = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(arg & ~1);
869         CHECK(!val->result_ok);
870         LDKDecodeError err_var = (*val->contents.err);
871         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
872         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
873         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
874         return err_ref;
875 }
876 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
877         return ((LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)arg)->result_ok;
878 }
879 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
880         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
881         CHECK(val->result_ok);
882         LDKCounterpartyChannelTransactionParameters res_var = (*val->contents.result);
883         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
884         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
885         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
886         return res_ref;
887 }
888 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
889         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
890         CHECK(!val->result_ok);
891         LDKDecodeError err_var = (*val->contents.err);
892         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
893         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
894         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
895         return err_ref;
896 }
897 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelTransactionParametersDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
898         return ((LDKCResult_ChannelTransactionParametersDecodeErrorZ*)arg)->result_ok;
899 }
900 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelTransactionParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
901         LDKCResult_ChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
902         CHECK(val->result_ok);
903         LDKChannelTransactionParameters res_var = (*val->contents.result);
904         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
905         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
906         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
907         return res_ref;
908 }
909 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelTransactionParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
910         LDKCResult_ChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
911         CHECK(!val->result_ok);
912         LDKDecodeError err_var = (*val->contents.err);
913         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
914         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
915         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
916         return err_ref;
917 }
918 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HolderCommitmentTransactionDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
919         return ((LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)arg)->result_ok;
920 }
921 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HolderCommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
922         LDKCResult_HolderCommitmentTransactionDecodeErrorZ *val = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(arg & ~1);
923         CHECK(val->result_ok);
924         LDKHolderCommitmentTransaction res_var = (*val->contents.result);
925         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
926         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
927         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
928         return res_ref;
929 }
930 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HolderCommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
931         LDKCResult_HolderCommitmentTransactionDecodeErrorZ *val = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(arg & ~1);
932         CHECK(!val->result_ok);
933         LDKDecodeError err_var = (*val->contents.err);
934         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
935         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
936         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
937         return err_ref;
938 }
939 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1BuiltCommitmentTransactionDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
940         return ((LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)arg)->result_ok;
941 }
942 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1BuiltCommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
943         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *val = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(arg & ~1);
944         CHECK(val->result_ok);
945         LDKBuiltCommitmentTransaction res_var = (*val->contents.result);
946         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
947         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
948         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
949         return res_ref;
950 }
951 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1BuiltCommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
952         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *val = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(arg & ~1);
953         CHECK(!val->result_ok);
954         LDKDecodeError err_var = (*val->contents.err);
955         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
956         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
957         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
958         return err_ref;
959 }
960 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentTransactionDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
961         return ((LDKCResult_CommitmentTransactionDecodeErrorZ*)arg)->result_ok;
962 }
963 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
964         LDKCResult_CommitmentTransactionDecodeErrorZ *val = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(arg & ~1);
965         CHECK(val->result_ok);
966         LDKCommitmentTransaction res_var = (*val->contents.result);
967         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
968         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
969         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
970         return res_ref;
971 }
972 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
973         LDKCResult_CommitmentTransactionDecodeErrorZ *val = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(arg & ~1);
974         CHECK(!val->result_ok);
975         LDKDecodeError err_var = (*val->contents.err);
976         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
977         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
978         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
979         return err_ref;
980 }
981 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TrustedCommitmentTransactionNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
982         return ((LDKCResult_TrustedCommitmentTransactionNoneZ*)arg)->result_ok;
983 }
984 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TrustedCommitmentTransactionNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
985         LDKCResult_TrustedCommitmentTransactionNoneZ *val = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(arg & ~1);
986         CHECK(val->result_ok);
987         LDKTrustedCommitmentTransaction res_var = (*val->contents.result);
988         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
989         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
990         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
991         return res_ref;
992 }
993 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TrustedCommitmentTransactionNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
994         LDKCResult_TrustedCommitmentTransactionNoneZ *val = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(arg & ~1);
995         CHECK(!val->result_ok);
996         return *val->contents.err;
997 }
998 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1SignatureZNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
999         return ((LDKCResult_CVec_SignatureZNoneZ*)arg)->result_ok;
1000 }
1001 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1SignatureZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1002         LDKCResult_CVec_SignatureZNoneZ *val = (LDKCResult_CVec_SignatureZNoneZ*)(arg & ~1);
1003         CHECK(val->result_ok);
1004         LDKCVec_SignatureZ res_var = (*val->contents.result);
1005         jobjectArray res_arr = (*env)->NewObjectArray(env, res_var.datalen, arr_of_B_clz, NULL);
1006         ;
1007         for (size_t i = 0; i < res_var.datalen; i++) {
1008                 int8_tArray res_conv_8_arr = (*env)->NewByteArray(env, 64);
1009                 (*env)->SetByteArrayRegion(env, res_conv_8_arr, 0, 64, res_var.data[i].compact_form);
1010                 (*env)->SetObjectArrayElement(env, res_arr, i, res_conv_8_arr);
1011         }
1012         return res_arr;
1013 }
1014 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1SignatureZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1015         LDKCResult_CVec_SignatureZNoneZ *val = (LDKCResult_CVec_SignatureZNoneZ*)(arg & ~1);
1016         CHECK(!val->result_ok);
1017         return *val->contents.err;
1018 }
1019 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1020         return ((LDKCResult_NoneErrorZ*)arg)->result_ok;
1021 }
1022 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1023         LDKCResult_NoneErrorZ *val = (LDKCResult_NoneErrorZ*)(arg & ~1);
1024         CHECK(val->result_ok);
1025         return *val->contents.result;
1026 }
1027 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1028         LDKCResult_NoneErrorZ *val = (LDKCResult_NoneErrorZ*)(arg & ~1);
1029         CHECK(!val->result_ok);
1030         jclass err_conv = LDKIOError_to_java(env, (*val->contents.err));
1031         return err_conv;
1032 }
1033 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteHopDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1034         return ((LDKCResult_RouteHopDecodeErrorZ*)arg)->result_ok;
1035 }
1036 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteHopDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1037         LDKCResult_RouteHopDecodeErrorZ *val = (LDKCResult_RouteHopDecodeErrorZ*)(arg & ~1);
1038         CHECK(val->result_ok);
1039         LDKRouteHop res_var = (*val->contents.result);
1040         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1041         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1042         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1043         return res_ref;
1044 }
1045 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteHopDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1046         LDKCResult_RouteHopDecodeErrorZ *val = (LDKCResult_RouteHopDecodeErrorZ*)(arg & ~1);
1047         CHECK(!val->result_ok);
1048         LDKDecodeError err_var = (*val->contents.err);
1049         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1050         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1051         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1052         return err_ref;
1053 }
1054 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1RouteHopZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1055         LDKCVec_RouteHopZ *ret = MALLOC(sizeof(LDKCVec_RouteHopZ), "LDKCVec_RouteHopZ");
1056         ret->datalen = (*env)->GetArrayLength(env, elems);
1057         if (ret->datalen == 0) {
1058                 ret->data = NULL;
1059         } else {
1060                 ret->data = MALLOC(sizeof(LDKRouteHop) * ret->datalen, "LDKCVec_RouteHopZ Data");
1061                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1062                 for (size_t i = 0; i < ret->datalen; i++) {
1063                         int64_t arr_elem = java_elems[i];
1064                         LDKRouteHop arr_elem_conv;
1065                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
1066                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
1067                         arr_elem_conv = RouteHop_clone(&arr_elem_conv);
1068                         ret->data[i] = arr_elem_conv;
1069                 }
1070                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1071         }
1072         return (uint64_t)ret;
1073 }
1074 static inline LDKCVec_RouteHopZ CVec_RouteHopZ_clone(const LDKCVec_RouteHopZ *orig) {
1075         LDKCVec_RouteHopZ ret = { .data = MALLOC(sizeof(LDKRouteHop) * orig->datalen, "LDKCVec_RouteHopZ clone bytes"), .datalen = orig->datalen };
1076         for (size_t i = 0; i < ret.datalen; i++) {
1077                 ret.data[i] = RouteHop_clone(&orig->data[i]);
1078         }
1079         return ret;
1080 }
1081 static inline LDKCVec_CVec_RouteHopZZ CVec_CVec_RouteHopZZ_clone(const LDKCVec_CVec_RouteHopZZ *orig) {
1082         LDKCVec_CVec_RouteHopZZ ret = { .data = MALLOC(sizeof(LDKCVec_RouteHopZ) * orig->datalen, "LDKCVec_CVec_RouteHopZZ clone bytes"), .datalen = orig->datalen };
1083         for (size_t i = 0; i < ret.datalen; i++) {
1084                 ret.data[i] = CVec_RouteHopZ_clone(&orig->data[i]);
1085         }
1086         return ret;
1087 }
1088 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1089         return ((LDKCResult_RouteDecodeErrorZ*)arg)->result_ok;
1090 }
1091 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1092         LDKCResult_RouteDecodeErrorZ *val = (LDKCResult_RouteDecodeErrorZ*)(arg & ~1);
1093         CHECK(val->result_ok);
1094         LDKRoute res_var = (*val->contents.result);
1095         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1096         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1097         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1098         return res_ref;
1099 }
1100 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1101         LDKCResult_RouteDecodeErrorZ *val = (LDKCResult_RouteDecodeErrorZ*)(arg & ~1);
1102         CHECK(!val->result_ok);
1103         LDKDecodeError err_var = (*val->contents.err);
1104         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1105         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1106         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1107         return err_ref;
1108 }
1109 static jclass LDKCOption_u64Z_Some_class = NULL;
1110 static jmethodID LDKCOption_u64Z_Some_meth = NULL;
1111 static jclass LDKCOption_u64Z_None_class = NULL;
1112 static jmethodID LDKCOption_u64Z_None_meth = NULL;
1113 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u64Z_init (JNIEnv *env, jclass clz) {
1114         LDKCOption_u64Z_Some_class =
1115                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_u64Z$Some;"));
1116         CHECK(LDKCOption_u64Z_Some_class != NULL);
1117         LDKCOption_u64Z_Some_meth = (*env)->GetMethodID(env, LDKCOption_u64Z_Some_class, "<init>", "(J)V");
1118         CHECK(LDKCOption_u64Z_Some_meth != NULL);
1119         LDKCOption_u64Z_None_class =
1120                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_u64Z$None;"));
1121         CHECK(LDKCOption_u64Z_None_class != NULL);
1122         LDKCOption_u64Z_None_meth = (*env)->GetMethodID(env, LDKCOption_u64Z_None_class, "<init>", "()V");
1123         CHECK(LDKCOption_u64Z_None_meth != NULL);
1124 }
1125 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u64Z_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1126         LDKCOption_u64Z *obj = (LDKCOption_u64Z*)(ptr & ~1);
1127         switch(obj->tag) {
1128                 case LDKCOption_u64Z_Some: {
1129                         return (*env)->NewObject(env, LDKCOption_u64Z_Some_class, LDKCOption_u64Z_Some_meth, obj->some);
1130                 }
1131                 case LDKCOption_u64Z_None: {
1132                         return (*env)->NewObject(env, LDKCOption_u64Z_None_class, LDKCOption_u64Z_None_meth);
1133                 }
1134                 default: abort();
1135         }
1136 }
1137 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1ChannelDetailsZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1138         LDKCVec_ChannelDetailsZ *ret = MALLOC(sizeof(LDKCVec_ChannelDetailsZ), "LDKCVec_ChannelDetailsZ");
1139         ret->datalen = (*env)->GetArrayLength(env, elems);
1140         if (ret->datalen == 0) {
1141                 ret->data = NULL;
1142         } else {
1143                 ret->data = MALLOC(sizeof(LDKChannelDetails) * ret->datalen, "LDKCVec_ChannelDetailsZ Data");
1144                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1145                 for (size_t i = 0; i < ret->datalen; i++) {
1146                         int64_t arr_elem = java_elems[i];
1147                         LDKChannelDetails arr_elem_conv;
1148                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
1149                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
1150                         arr_elem_conv = ChannelDetails_clone(&arr_elem_conv);
1151                         ret->data[i] = arr_elem_conv;
1152                 }
1153                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1154         }
1155         return (uint64_t)ret;
1156 }
1157 static inline LDKCVec_ChannelDetailsZ CVec_ChannelDetailsZ_clone(const LDKCVec_ChannelDetailsZ *orig) {
1158         LDKCVec_ChannelDetailsZ ret = { .data = MALLOC(sizeof(LDKChannelDetails) * orig->datalen, "LDKCVec_ChannelDetailsZ clone bytes"), .datalen = orig->datalen };
1159         for (size_t i = 0; i < ret.datalen; i++) {
1160                 ret.data[i] = ChannelDetails_clone(&orig->data[i]);
1161         }
1162         return ret;
1163 }
1164 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1RouteHintZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1165         LDKCVec_RouteHintZ *ret = MALLOC(sizeof(LDKCVec_RouteHintZ), "LDKCVec_RouteHintZ");
1166         ret->datalen = (*env)->GetArrayLength(env, elems);
1167         if (ret->datalen == 0) {
1168                 ret->data = NULL;
1169         } else {
1170                 ret->data = MALLOC(sizeof(LDKRouteHint) * ret->datalen, "LDKCVec_RouteHintZ Data");
1171                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1172                 for (size_t i = 0; i < ret->datalen; i++) {
1173                         int64_t arr_elem = java_elems[i];
1174                         LDKRouteHint arr_elem_conv;
1175                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
1176                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
1177                         arr_elem_conv = RouteHint_clone(&arr_elem_conv);
1178                         ret->data[i] = arr_elem_conv;
1179                 }
1180                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1181         }
1182         return (uint64_t)ret;
1183 }
1184 static inline LDKCVec_RouteHintZ CVec_RouteHintZ_clone(const LDKCVec_RouteHintZ *orig) {
1185         LDKCVec_RouteHintZ ret = { .data = MALLOC(sizeof(LDKRouteHint) * orig->datalen, "LDKCVec_RouteHintZ clone bytes"), .datalen = orig->datalen };
1186         for (size_t i = 0; i < ret.datalen; i++) {
1187                 ret.data[i] = RouteHint_clone(&orig->data[i]);
1188         }
1189         return ret;
1190 }
1191 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteLightningErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1192         return ((LDKCResult_RouteLightningErrorZ*)arg)->result_ok;
1193 }
1194 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1195         LDKCResult_RouteLightningErrorZ *val = (LDKCResult_RouteLightningErrorZ*)(arg & ~1);
1196         CHECK(val->result_ok);
1197         LDKRoute res_var = (*val->contents.result);
1198         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1199         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1200         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1201         return res_ref;
1202 }
1203 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1204         LDKCResult_RouteLightningErrorZ *val = (LDKCResult_RouteLightningErrorZ*)(arg & ~1);
1205         CHECK(!val->result_ok);
1206         LDKLightningError err_var = (*val->contents.err);
1207         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1208         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1209         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1210         return err_ref;
1211 }
1212 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxOutAccessErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1213         return ((LDKCResult_TxOutAccessErrorZ*)arg)->result_ok;
1214 }
1215 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxOutAccessErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1216         LDKCResult_TxOutAccessErrorZ *val = (LDKCResult_TxOutAccessErrorZ*)(arg & ~1);
1217         CHECK(val->result_ok);
1218         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
1219         return (uint64_t)res_ref;
1220 }
1221 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxOutAccessErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1222         LDKCResult_TxOutAccessErrorZ *val = (LDKCResult_TxOutAccessErrorZ*)(arg & ~1);
1223         CHECK(!val->result_ok);
1224         jclass err_conv = LDKAccessError_to_java(env, (*val->contents.err));
1225         return err_conv;
1226 }
1227 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1usizeTransactionZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
1228         LDKC2Tuple_usizeTransactionZ* ret = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
1229         ret->a = a;
1230         LDKTransaction b_ref;
1231         b_ref.datalen = (*env)->GetArrayLength(env, b);
1232         b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
1233         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
1234         b_ref.data_is_owned = false;
1235         ret->b = b_ref;
1236         return (uint64_t)ret;
1237 }
1238 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1usizeTransactionZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
1239         LDKC2Tuple_usizeTransactionZ *tuple = (LDKC2Tuple_usizeTransactionZ*)(ptr & ~1);
1240         return tuple->a;
1241 }
1242 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1usizeTransactionZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
1243         LDKC2Tuple_usizeTransactionZ *tuple = (LDKC2Tuple_usizeTransactionZ*)(ptr & ~1);
1244         LDKTransaction b_var = tuple->b;
1245         int8_tArray b_arr = (*env)->NewByteArray(env, b_var.datalen);
1246         (*env)->SetByteArrayRegion(env, b_arr, 0, b_var.datalen, b_var.data);
1247         return b_arr;
1248 }
1249 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1usizeTransactionZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1250         LDKCVec_C2Tuple_usizeTransactionZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_usizeTransactionZZ), "LDKCVec_C2Tuple_usizeTransactionZZ");
1251         ret->datalen = (*env)->GetArrayLength(env, elems);
1252         if (ret->datalen == 0) {
1253                 ret->data = NULL;
1254         } else {
1255                 ret->data = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ) * ret->datalen, "LDKCVec_C2Tuple_usizeTransactionZZ 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                         LDKC2Tuple_usizeTransactionZ arr_elem_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)arr_elem) & ~1);
1260                         arr_elem_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)arr_elem) & ~1));
1261                         ret->data[i] = arr_elem_conv;
1262                 }
1263                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1264         }
1265         return (uint64_t)ret;
1266 }
1267 static inline LDKCVec_C2Tuple_usizeTransactionZZ CVec_C2Tuple_usizeTransactionZZ_clone(const LDKCVec_C2Tuple_usizeTransactionZZ *orig) {
1268         LDKCVec_C2Tuple_usizeTransactionZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ) * orig->datalen, "LDKCVec_C2Tuple_usizeTransactionZZ clone bytes"), .datalen = orig->datalen };
1269         for (size_t i = 0; i < ret.datalen; i++) {
1270                 ret.data[i] = C2Tuple_usizeTransactionZ_clone(&orig->data[i]);
1271         }
1272         return ret;
1273 }
1274 static inline LDKCVec_TxidZ CVec_ThirtyTwoBytesZ_clone(const LDKCVec_TxidZ *orig) {
1275         LDKCVec_TxidZ ret = { .data = MALLOC(sizeof(LDKThirtyTwoBytes) * orig->datalen, "LDKCVec_TxidZ clone bytes"), .datalen = orig->datalen };
1276         for (size_t i = 0; i < ret.datalen; i++) {
1277                 ret.data[i] = ThirtyTwoBytes_clone(&orig->data[i]);
1278         }
1279         return ret;
1280 }
1281 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneChannelMonitorUpdateErrZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1282         return ((LDKCResult_NoneChannelMonitorUpdateErrZ*)arg)->result_ok;
1283 }
1284 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneChannelMonitorUpdateErrZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1285         LDKCResult_NoneChannelMonitorUpdateErrZ *val = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(arg & ~1);
1286         CHECK(val->result_ok);
1287         return *val->contents.result;
1288 }
1289 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneChannelMonitorUpdateErrZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1290         LDKCResult_NoneChannelMonitorUpdateErrZ *val = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(arg & ~1);
1291         CHECK(!val->result_ok);
1292         jclass err_conv = LDKChannelMonitorUpdateErr_to_java(env, (*val->contents.err));
1293         return err_conv;
1294 }
1295 static jclass LDKMonitorEvent_HTLCEvent_class = NULL;
1296 static jmethodID LDKMonitorEvent_HTLCEvent_meth = NULL;
1297 static jclass LDKMonitorEvent_CommitmentTxBroadcasted_class = NULL;
1298 static jmethodID LDKMonitorEvent_CommitmentTxBroadcasted_meth = NULL;
1299 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKMonitorEvent_init (JNIEnv *env, jclass clz) {
1300         LDKMonitorEvent_HTLCEvent_class =
1301                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMonitorEvent$HTLCEvent;"));
1302         CHECK(LDKMonitorEvent_HTLCEvent_class != NULL);
1303         LDKMonitorEvent_HTLCEvent_meth = (*env)->GetMethodID(env, LDKMonitorEvent_HTLCEvent_class, "<init>", "(J)V");
1304         CHECK(LDKMonitorEvent_HTLCEvent_meth != NULL);
1305         LDKMonitorEvent_CommitmentTxBroadcasted_class =
1306                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMonitorEvent$CommitmentTxBroadcasted;"));
1307         CHECK(LDKMonitorEvent_CommitmentTxBroadcasted_class != NULL);
1308         LDKMonitorEvent_CommitmentTxBroadcasted_meth = (*env)->GetMethodID(env, LDKMonitorEvent_CommitmentTxBroadcasted_class, "<init>", "(J)V");
1309         CHECK(LDKMonitorEvent_CommitmentTxBroadcasted_meth != NULL);
1310 }
1311 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKMonitorEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1312         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
1313         switch(obj->tag) {
1314                 case LDKMonitorEvent_HTLCEvent: {
1315                         LDKHTLCUpdate htlc_event_var = obj->htlc_event;
1316                         CHECK((((uint64_t)htlc_event_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1317                         CHECK((((uint64_t)&htlc_event_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1318                         uint64_t htlc_event_ref = (uint64_t)htlc_event_var.inner & ~1;
1319                         return (*env)->NewObject(env, LDKMonitorEvent_HTLCEvent_class, LDKMonitorEvent_HTLCEvent_meth, htlc_event_ref);
1320                 }
1321                 case LDKMonitorEvent_CommitmentTxBroadcasted: {
1322                         LDKOutPoint commitment_tx_broadcasted_var = obj->commitment_tx_broadcasted;
1323                         CHECK((((uint64_t)commitment_tx_broadcasted_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1324                         CHECK((((uint64_t)&commitment_tx_broadcasted_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1325                         uint64_t commitment_tx_broadcasted_ref = (uint64_t)commitment_tx_broadcasted_var.inner & ~1;
1326                         return (*env)->NewObject(env, LDKMonitorEvent_CommitmentTxBroadcasted_class, LDKMonitorEvent_CommitmentTxBroadcasted_meth, commitment_tx_broadcasted_ref);
1327                 }
1328                 default: abort();
1329         }
1330 }
1331 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1MonitorEventZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1332         LDKCVec_MonitorEventZ *ret = MALLOC(sizeof(LDKCVec_MonitorEventZ), "LDKCVec_MonitorEventZ");
1333         ret->datalen = (*env)->GetArrayLength(env, elems);
1334         if (ret->datalen == 0) {
1335                 ret->data = NULL;
1336         } else {
1337                 ret->data = MALLOC(sizeof(LDKMonitorEvent) * ret->datalen, "LDKCVec_MonitorEventZ Data");
1338                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1339                 for (size_t i = 0; i < ret->datalen; i++) {
1340                         int64_t arr_elem = java_elems[i];
1341                         LDKMonitorEvent arr_elem_conv = *(LDKMonitorEvent*)(((uint64_t)arr_elem) & ~1);
1342                         arr_elem_conv = MonitorEvent_clone((LDKMonitorEvent*)(((uint64_t)arr_elem) & ~1));
1343                         ret->data[i] = arr_elem_conv;
1344                 }
1345                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1346         }
1347         return (uint64_t)ret;
1348 }
1349 static inline LDKCVec_MonitorEventZ CVec_MonitorEventZ_clone(const LDKCVec_MonitorEventZ *orig) {
1350         LDKCVec_MonitorEventZ ret = { .data = MALLOC(sizeof(LDKMonitorEvent) * orig->datalen, "LDKCVec_MonitorEventZ clone bytes"), .datalen = orig->datalen };
1351         for (size_t i = 0; i < ret.datalen; i++) {
1352                 ret.data[i] = MonitorEvent_clone(&orig->data[i]);
1353         }
1354         return ret;
1355 }
1356 static jclass LDKCOption_C2Tuple_usizeTransactionZZ_Some_class = NULL;
1357 static jmethodID LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth = NULL;
1358 static jclass LDKCOption_C2Tuple_usizeTransactionZZ_None_class = NULL;
1359 static jmethodID LDKCOption_C2Tuple_usizeTransactionZZ_None_meth = NULL;
1360 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1C2Tuple_1usizeTransactionZZ_init (JNIEnv *env, jclass clz) {
1361         LDKCOption_C2Tuple_usizeTransactionZZ_Some_class =
1362                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_C2Tuple_usizeTransactionZZ$Some;"));
1363         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_Some_class != NULL);
1364         LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_C2Tuple_usizeTransactionZZ_Some_class, "<init>", "(J)V");
1365         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth != NULL);
1366         LDKCOption_C2Tuple_usizeTransactionZZ_None_class =
1367                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_C2Tuple_usizeTransactionZZ$None;"));
1368         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_None_class != NULL);
1369         LDKCOption_C2Tuple_usizeTransactionZZ_None_meth = (*env)->GetMethodID(env, LDKCOption_C2Tuple_usizeTransactionZZ_None_class, "<init>", "()V");
1370         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_None_meth != NULL);
1371 }
1372 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1C2Tuple_1usizeTransactionZZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1373         LDKCOption_C2Tuple_usizeTransactionZZ *obj = (LDKCOption_C2Tuple_usizeTransactionZZ*)(ptr & ~1);
1374         switch(obj->tag) {
1375                 case LDKCOption_C2Tuple_usizeTransactionZZ_Some: {
1376                         uint64_t some_ref = (uint64_t)(&obj->some) | 1;
1377                         return (*env)->NewObject(env, LDKCOption_C2Tuple_usizeTransactionZZ_Some_class, LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth, some_ref);
1378                 }
1379                 case LDKCOption_C2Tuple_usizeTransactionZZ_None: {
1380                         return (*env)->NewObject(env, LDKCOption_C2Tuple_usizeTransactionZZ_None_class, LDKCOption_C2Tuple_usizeTransactionZZ_None_meth);
1381                 }
1382                 default: abort();
1383         }
1384 }
1385 static jclass LDKSpendableOutputDescriptor_StaticOutput_class = NULL;
1386 static jmethodID LDKSpendableOutputDescriptor_StaticOutput_meth = NULL;
1387 static jclass LDKSpendableOutputDescriptor_DelayedPaymentOutput_class = NULL;
1388 static jmethodID LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth = NULL;
1389 static jclass LDKSpendableOutputDescriptor_StaticPaymentOutput_class = NULL;
1390 static jmethodID LDKSpendableOutputDescriptor_StaticPaymentOutput_meth = NULL;
1391 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKSpendableOutputDescriptor_init (JNIEnv *env, jclass clz) {
1392         LDKSpendableOutputDescriptor_StaticOutput_class =
1393                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKSpendableOutputDescriptor$StaticOutput;"));
1394         CHECK(LDKSpendableOutputDescriptor_StaticOutput_class != NULL);
1395         LDKSpendableOutputDescriptor_StaticOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_StaticOutput_class, "<init>", "(JJ)V");
1396         CHECK(LDKSpendableOutputDescriptor_StaticOutput_meth != NULL);
1397         LDKSpendableOutputDescriptor_DelayedPaymentOutput_class =
1398                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKSpendableOutputDescriptor$DelayedPaymentOutput;"));
1399         CHECK(LDKSpendableOutputDescriptor_DelayedPaymentOutput_class != NULL);
1400         LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_DelayedPaymentOutput_class, "<init>", "(J)V");
1401         CHECK(LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth != NULL);
1402         LDKSpendableOutputDescriptor_StaticPaymentOutput_class =
1403                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKSpendableOutputDescriptor$StaticPaymentOutput;"));
1404         CHECK(LDKSpendableOutputDescriptor_StaticPaymentOutput_class != NULL);
1405         LDKSpendableOutputDescriptor_StaticPaymentOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_StaticPaymentOutput_class, "<init>", "(J)V");
1406         CHECK(LDKSpendableOutputDescriptor_StaticPaymentOutput_meth != NULL);
1407 }
1408 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKSpendableOutputDescriptor_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1409         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)(ptr & ~1);
1410         switch(obj->tag) {
1411                 case LDKSpendableOutputDescriptor_StaticOutput: {
1412                         LDKOutPoint outpoint_var = obj->static_output.outpoint;
1413                         CHECK((((uint64_t)outpoint_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1414                         CHECK((((uint64_t)&outpoint_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1415                         uint64_t outpoint_ref = (uint64_t)outpoint_var.inner & ~1;
1416                         uint64_t output_ref = ((uint64_t)&obj->static_output.output) | 1;
1417                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_StaticOutput_class, LDKSpendableOutputDescriptor_StaticOutput_meth, outpoint_ref, (uint64_t)output_ref);
1418                 }
1419                 case LDKSpendableOutputDescriptor_DelayedPaymentOutput: {
1420                         LDKDelayedPaymentOutputDescriptor delayed_payment_output_var = obj->delayed_payment_output;
1421                         CHECK((((uint64_t)delayed_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1422                         CHECK((((uint64_t)&delayed_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1423                         uint64_t delayed_payment_output_ref = (uint64_t)delayed_payment_output_var.inner & ~1;
1424                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_DelayedPaymentOutput_class, LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth, delayed_payment_output_ref);
1425                 }
1426                 case LDKSpendableOutputDescriptor_StaticPaymentOutput: {
1427                         LDKStaticPaymentOutputDescriptor static_payment_output_var = obj->static_payment_output;
1428                         CHECK((((uint64_t)static_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1429                         CHECK((((uint64_t)&static_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1430                         uint64_t static_payment_output_ref = (uint64_t)static_payment_output_var.inner & ~1;
1431                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_StaticPaymentOutput_class, LDKSpendableOutputDescriptor_StaticPaymentOutput_meth, static_payment_output_ref);
1432                 }
1433                 default: abort();
1434         }
1435 }
1436 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1SpendableOutputDescriptorZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1437         LDKCVec_SpendableOutputDescriptorZ *ret = MALLOC(sizeof(LDKCVec_SpendableOutputDescriptorZ), "LDKCVec_SpendableOutputDescriptorZ");
1438         ret->datalen = (*env)->GetArrayLength(env, elems);
1439         if (ret->datalen == 0) {
1440                 ret->data = NULL;
1441         } else {
1442                 ret->data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * ret->datalen, "LDKCVec_SpendableOutputDescriptorZ Data");
1443                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1444                 for (size_t i = 0; i < ret->datalen; i++) {
1445                         int64_t arr_elem = java_elems[i];
1446                         LDKSpendableOutputDescriptor arr_elem_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)arr_elem) & ~1);
1447                         arr_elem_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uint64_t)arr_elem) & ~1));
1448                         ret->data[i] = arr_elem_conv;
1449                 }
1450                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1451         }
1452         return (uint64_t)ret;
1453 }
1454 static inline LDKCVec_SpendableOutputDescriptorZ CVec_SpendableOutputDescriptorZ_clone(const LDKCVec_SpendableOutputDescriptorZ *orig) {
1455         LDKCVec_SpendableOutputDescriptorZ ret = { .data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * orig->datalen, "LDKCVec_SpendableOutputDescriptorZ clone bytes"), .datalen = orig->datalen };
1456         for (size_t i = 0; i < ret.datalen; i++) {
1457                 ret.data[i] = SpendableOutputDescriptor_clone(&orig->data[i]);
1458         }
1459         return ret;
1460 }
1461 static jclass LDKErrorAction_DisconnectPeer_class = NULL;
1462 static jmethodID LDKErrorAction_DisconnectPeer_meth = NULL;
1463 static jclass LDKErrorAction_IgnoreError_class = NULL;
1464 static jmethodID LDKErrorAction_IgnoreError_meth = NULL;
1465 static jclass LDKErrorAction_IgnoreAndLog_class = NULL;
1466 static jmethodID LDKErrorAction_IgnoreAndLog_meth = NULL;
1467 static jclass LDKErrorAction_SendErrorMessage_class = NULL;
1468 static jmethodID LDKErrorAction_SendErrorMessage_meth = NULL;
1469 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKErrorAction_init (JNIEnv *env, jclass clz) {
1470         LDKErrorAction_DisconnectPeer_class =
1471                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKErrorAction$DisconnectPeer;"));
1472         CHECK(LDKErrorAction_DisconnectPeer_class != NULL);
1473         LDKErrorAction_DisconnectPeer_meth = (*env)->GetMethodID(env, LDKErrorAction_DisconnectPeer_class, "<init>", "(J)V");
1474         CHECK(LDKErrorAction_DisconnectPeer_meth != NULL);
1475         LDKErrorAction_IgnoreError_class =
1476                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKErrorAction$IgnoreError;"));
1477         CHECK(LDKErrorAction_IgnoreError_class != NULL);
1478         LDKErrorAction_IgnoreError_meth = (*env)->GetMethodID(env, LDKErrorAction_IgnoreError_class, "<init>", "()V");
1479         CHECK(LDKErrorAction_IgnoreError_meth != NULL);
1480         LDKErrorAction_IgnoreAndLog_class =
1481                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKErrorAction$IgnoreAndLog;"));
1482         CHECK(LDKErrorAction_IgnoreAndLog_class != NULL);
1483         LDKErrorAction_IgnoreAndLog_meth = (*env)->GetMethodID(env, LDKErrorAction_IgnoreAndLog_class, "<init>", "(Lorg/ldk/enums/Level;)V");
1484         CHECK(LDKErrorAction_IgnoreAndLog_meth != NULL);
1485         LDKErrorAction_SendErrorMessage_class =
1486                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKErrorAction$SendErrorMessage;"));
1487         CHECK(LDKErrorAction_SendErrorMessage_class != NULL);
1488         LDKErrorAction_SendErrorMessage_meth = (*env)->GetMethodID(env, LDKErrorAction_SendErrorMessage_class, "<init>", "(J)V");
1489         CHECK(LDKErrorAction_SendErrorMessage_meth != NULL);
1490 }
1491 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKErrorAction_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1492         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
1493         switch(obj->tag) {
1494                 case LDKErrorAction_DisconnectPeer: {
1495                         LDKErrorMessage msg_var = obj->disconnect_peer.msg;
1496                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1497                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1498                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1499                         return (*env)->NewObject(env, LDKErrorAction_DisconnectPeer_class, LDKErrorAction_DisconnectPeer_meth, msg_ref);
1500                 }
1501                 case LDKErrorAction_IgnoreError: {
1502                         return (*env)->NewObject(env, LDKErrorAction_IgnoreError_class, LDKErrorAction_IgnoreError_meth);
1503                 }
1504                 case LDKErrorAction_IgnoreAndLog: {
1505                         jclass ignore_and_log_conv = LDKLevel_to_java(env, obj->ignore_and_log);
1506                         return (*env)->NewObject(env, LDKErrorAction_IgnoreAndLog_class, LDKErrorAction_IgnoreAndLog_meth, ignore_and_log_conv);
1507                 }
1508                 case LDKErrorAction_SendErrorMessage: {
1509                         LDKErrorMessage msg_var = obj->send_error_message.msg;
1510                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1511                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1512                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1513                         return (*env)->NewObject(env, LDKErrorAction_SendErrorMessage_class, LDKErrorAction_SendErrorMessage_meth, msg_ref);
1514                 }
1515                 default: abort();
1516         }
1517 }
1518 static jclass LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class = NULL;
1519 static jmethodID LDKHTLCFailChannelUpdate_ChannelUpdateMessage_meth = NULL;
1520 static jclass LDKHTLCFailChannelUpdate_ChannelClosed_class = NULL;
1521 static jmethodID LDKHTLCFailChannelUpdate_ChannelClosed_meth = NULL;
1522 static jclass LDKHTLCFailChannelUpdate_NodeFailure_class = NULL;
1523 static jmethodID LDKHTLCFailChannelUpdate_NodeFailure_meth = NULL;
1524 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKHTLCFailChannelUpdate_init (JNIEnv *env, jclass clz) {
1525         LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class =
1526                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKHTLCFailChannelUpdate$ChannelUpdateMessage;"));
1527         CHECK(LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class != NULL);
1528         LDKHTLCFailChannelUpdate_ChannelUpdateMessage_meth = (*env)->GetMethodID(env, LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class, "<init>", "(J)V");
1529         CHECK(LDKHTLCFailChannelUpdate_ChannelUpdateMessage_meth != NULL);
1530         LDKHTLCFailChannelUpdate_ChannelClosed_class =
1531                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKHTLCFailChannelUpdate$ChannelClosed;"));
1532         CHECK(LDKHTLCFailChannelUpdate_ChannelClosed_class != NULL);
1533         LDKHTLCFailChannelUpdate_ChannelClosed_meth = (*env)->GetMethodID(env, LDKHTLCFailChannelUpdate_ChannelClosed_class, "<init>", "(JZ)V");
1534         CHECK(LDKHTLCFailChannelUpdate_ChannelClosed_meth != NULL);
1535         LDKHTLCFailChannelUpdate_NodeFailure_class =
1536                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKHTLCFailChannelUpdate$NodeFailure;"));
1537         CHECK(LDKHTLCFailChannelUpdate_NodeFailure_class != NULL);
1538         LDKHTLCFailChannelUpdate_NodeFailure_meth = (*env)->GetMethodID(env, LDKHTLCFailChannelUpdate_NodeFailure_class, "<init>", "([BZ)V");
1539         CHECK(LDKHTLCFailChannelUpdate_NodeFailure_meth != NULL);
1540 }
1541 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKHTLCFailChannelUpdate_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1542         LDKHTLCFailChannelUpdate *obj = (LDKHTLCFailChannelUpdate*)(ptr & ~1);
1543         switch(obj->tag) {
1544                 case LDKHTLCFailChannelUpdate_ChannelUpdateMessage: {
1545                         LDKChannelUpdate msg_var = obj->channel_update_message.msg;
1546                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1547                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1548                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1549                         return (*env)->NewObject(env, LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class, LDKHTLCFailChannelUpdate_ChannelUpdateMessage_meth, msg_ref);
1550                 }
1551                 case LDKHTLCFailChannelUpdate_ChannelClosed: {
1552                         return (*env)->NewObject(env, LDKHTLCFailChannelUpdate_ChannelClosed_class, LDKHTLCFailChannelUpdate_ChannelClosed_meth, obj->channel_closed.short_channel_id, obj->channel_closed.is_permanent);
1553                 }
1554                 case LDKHTLCFailChannelUpdate_NodeFailure: {
1555                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1556                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->node_failure.node_id.compressed_form);
1557                         return (*env)->NewObject(env, LDKHTLCFailChannelUpdate_NodeFailure_class, LDKHTLCFailChannelUpdate_NodeFailure_meth, node_id_arr, obj->node_failure.is_permanent);
1558                 }
1559                 default: abort();
1560         }
1561 }
1562 static jclass LDKMessageSendEvent_SendAcceptChannel_class = NULL;
1563 static jmethodID LDKMessageSendEvent_SendAcceptChannel_meth = NULL;
1564 static jclass LDKMessageSendEvent_SendOpenChannel_class = NULL;
1565 static jmethodID LDKMessageSendEvent_SendOpenChannel_meth = NULL;
1566 static jclass LDKMessageSendEvent_SendFundingCreated_class = NULL;
1567 static jmethodID LDKMessageSendEvent_SendFundingCreated_meth = NULL;
1568 static jclass LDKMessageSendEvent_SendFundingSigned_class = NULL;
1569 static jmethodID LDKMessageSendEvent_SendFundingSigned_meth = NULL;
1570 static jclass LDKMessageSendEvent_SendFundingLocked_class = NULL;
1571 static jmethodID LDKMessageSendEvent_SendFundingLocked_meth = NULL;
1572 static jclass LDKMessageSendEvent_SendAnnouncementSignatures_class = NULL;
1573 static jmethodID LDKMessageSendEvent_SendAnnouncementSignatures_meth = NULL;
1574 static jclass LDKMessageSendEvent_UpdateHTLCs_class = NULL;
1575 static jmethodID LDKMessageSendEvent_UpdateHTLCs_meth = NULL;
1576 static jclass LDKMessageSendEvent_SendRevokeAndACK_class = NULL;
1577 static jmethodID LDKMessageSendEvent_SendRevokeAndACK_meth = NULL;
1578 static jclass LDKMessageSendEvent_SendClosingSigned_class = NULL;
1579 static jmethodID LDKMessageSendEvent_SendClosingSigned_meth = NULL;
1580 static jclass LDKMessageSendEvent_SendShutdown_class = NULL;
1581 static jmethodID LDKMessageSendEvent_SendShutdown_meth = NULL;
1582 static jclass LDKMessageSendEvent_SendChannelReestablish_class = NULL;
1583 static jmethodID LDKMessageSendEvent_SendChannelReestablish_meth = NULL;
1584 static jclass LDKMessageSendEvent_BroadcastChannelAnnouncement_class = NULL;
1585 static jmethodID LDKMessageSendEvent_BroadcastChannelAnnouncement_meth = NULL;
1586 static jclass LDKMessageSendEvent_BroadcastNodeAnnouncement_class = NULL;
1587 static jmethodID LDKMessageSendEvent_BroadcastNodeAnnouncement_meth = NULL;
1588 static jclass LDKMessageSendEvent_BroadcastChannelUpdate_class = NULL;
1589 static jmethodID LDKMessageSendEvent_BroadcastChannelUpdate_meth = NULL;
1590 static jclass LDKMessageSendEvent_SendChannelUpdate_class = NULL;
1591 static jmethodID LDKMessageSendEvent_SendChannelUpdate_meth = NULL;
1592 static jclass LDKMessageSendEvent_HandleError_class = NULL;
1593 static jmethodID LDKMessageSendEvent_HandleError_meth = NULL;
1594 static jclass LDKMessageSendEvent_PaymentFailureNetworkUpdate_class = NULL;
1595 static jmethodID LDKMessageSendEvent_PaymentFailureNetworkUpdate_meth = NULL;
1596 static jclass LDKMessageSendEvent_SendChannelRangeQuery_class = NULL;
1597 static jmethodID LDKMessageSendEvent_SendChannelRangeQuery_meth = NULL;
1598 static jclass LDKMessageSendEvent_SendShortIdsQuery_class = NULL;
1599 static jmethodID LDKMessageSendEvent_SendShortIdsQuery_meth = NULL;
1600 static jclass LDKMessageSendEvent_SendReplyChannelRange_class = NULL;
1601 static jmethodID LDKMessageSendEvent_SendReplyChannelRange_meth = NULL;
1602 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKMessageSendEvent_init (JNIEnv *env, jclass clz) {
1603         LDKMessageSendEvent_SendAcceptChannel_class =
1604                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendAcceptChannel;"));
1605         CHECK(LDKMessageSendEvent_SendAcceptChannel_class != NULL);
1606         LDKMessageSendEvent_SendAcceptChannel_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendAcceptChannel_class, "<init>", "([BJ)V");
1607         CHECK(LDKMessageSendEvent_SendAcceptChannel_meth != NULL);
1608         LDKMessageSendEvent_SendOpenChannel_class =
1609                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendOpenChannel;"));
1610         CHECK(LDKMessageSendEvent_SendOpenChannel_class != NULL);
1611         LDKMessageSendEvent_SendOpenChannel_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendOpenChannel_class, "<init>", "([BJ)V");
1612         CHECK(LDKMessageSendEvent_SendOpenChannel_meth != NULL);
1613         LDKMessageSendEvent_SendFundingCreated_class =
1614                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendFundingCreated;"));
1615         CHECK(LDKMessageSendEvent_SendFundingCreated_class != NULL);
1616         LDKMessageSendEvent_SendFundingCreated_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingCreated_class, "<init>", "([BJ)V");
1617         CHECK(LDKMessageSendEvent_SendFundingCreated_meth != NULL);
1618         LDKMessageSendEvent_SendFundingSigned_class =
1619                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendFundingSigned;"));
1620         CHECK(LDKMessageSendEvent_SendFundingSigned_class != NULL);
1621         LDKMessageSendEvent_SendFundingSigned_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingSigned_class, "<init>", "([BJ)V");
1622         CHECK(LDKMessageSendEvent_SendFundingSigned_meth != NULL);
1623         LDKMessageSendEvent_SendFundingLocked_class =
1624                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendFundingLocked;"));
1625         CHECK(LDKMessageSendEvent_SendFundingLocked_class != NULL);
1626         LDKMessageSendEvent_SendFundingLocked_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingLocked_class, "<init>", "([BJ)V");
1627         CHECK(LDKMessageSendEvent_SendFundingLocked_meth != NULL);
1628         LDKMessageSendEvent_SendAnnouncementSignatures_class =
1629                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendAnnouncementSignatures;"));
1630         CHECK(LDKMessageSendEvent_SendAnnouncementSignatures_class != NULL);
1631         LDKMessageSendEvent_SendAnnouncementSignatures_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendAnnouncementSignatures_class, "<init>", "([BJ)V");
1632         CHECK(LDKMessageSendEvent_SendAnnouncementSignatures_meth != NULL);
1633         LDKMessageSendEvent_UpdateHTLCs_class =
1634                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$UpdateHTLCs;"));
1635         CHECK(LDKMessageSendEvent_UpdateHTLCs_class != NULL);
1636         LDKMessageSendEvent_UpdateHTLCs_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_UpdateHTLCs_class, "<init>", "([BJ)V");
1637         CHECK(LDKMessageSendEvent_UpdateHTLCs_meth != NULL);
1638         LDKMessageSendEvent_SendRevokeAndACK_class =
1639                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendRevokeAndACK;"));
1640         CHECK(LDKMessageSendEvent_SendRevokeAndACK_class != NULL);
1641         LDKMessageSendEvent_SendRevokeAndACK_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendRevokeAndACK_class, "<init>", "([BJ)V");
1642         CHECK(LDKMessageSendEvent_SendRevokeAndACK_meth != NULL);
1643         LDKMessageSendEvent_SendClosingSigned_class =
1644                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendClosingSigned;"));
1645         CHECK(LDKMessageSendEvent_SendClosingSigned_class != NULL);
1646         LDKMessageSendEvent_SendClosingSigned_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendClosingSigned_class, "<init>", "([BJ)V");
1647         CHECK(LDKMessageSendEvent_SendClosingSigned_meth != NULL);
1648         LDKMessageSendEvent_SendShutdown_class =
1649                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendShutdown;"));
1650         CHECK(LDKMessageSendEvent_SendShutdown_class != NULL);
1651         LDKMessageSendEvent_SendShutdown_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendShutdown_class, "<init>", "([BJ)V");
1652         CHECK(LDKMessageSendEvent_SendShutdown_meth != NULL);
1653         LDKMessageSendEvent_SendChannelReestablish_class =
1654                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendChannelReestablish;"));
1655         CHECK(LDKMessageSendEvent_SendChannelReestablish_class != NULL);
1656         LDKMessageSendEvent_SendChannelReestablish_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelReestablish_class, "<init>", "([BJ)V");
1657         CHECK(LDKMessageSendEvent_SendChannelReestablish_meth != NULL);
1658         LDKMessageSendEvent_BroadcastChannelAnnouncement_class =
1659                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$BroadcastChannelAnnouncement;"));
1660         CHECK(LDKMessageSendEvent_BroadcastChannelAnnouncement_class != NULL);
1661         LDKMessageSendEvent_BroadcastChannelAnnouncement_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastChannelAnnouncement_class, "<init>", "(JJ)V");
1662         CHECK(LDKMessageSendEvent_BroadcastChannelAnnouncement_meth != NULL);
1663         LDKMessageSendEvent_BroadcastNodeAnnouncement_class =
1664                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$BroadcastNodeAnnouncement;"));
1665         CHECK(LDKMessageSendEvent_BroadcastNodeAnnouncement_class != NULL);
1666         LDKMessageSendEvent_BroadcastNodeAnnouncement_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastNodeAnnouncement_class, "<init>", "(J)V");
1667         CHECK(LDKMessageSendEvent_BroadcastNodeAnnouncement_meth != NULL);
1668         LDKMessageSendEvent_BroadcastChannelUpdate_class =
1669                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$BroadcastChannelUpdate;"));
1670         CHECK(LDKMessageSendEvent_BroadcastChannelUpdate_class != NULL);
1671         LDKMessageSendEvent_BroadcastChannelUpdate_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastChannelUpdate_class, "<init>", "(J)V");
1672         CHECK(LDKMessageSendEvent_BroadcastChannelUpdate_meth != NULL);
1673         LDKMessageSendEvent_SendChannelUpdate_class =
1674                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendChannelUpdate;"));
1675         CHECK(LDKMessageSendEvent_SendChannelUpdate_class != NULL);
1676         LDKMessageSendEvent_SendChannelUpdate_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelUpdate_class, "<init>", "([BJ)V");
1677         CHECK(LDKMessageSendEvent_SendChannelUpdate_meth != NULL);
1678         LDKMessageSendEvent_HandleError_class =
1679                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$HandleError;"));
1680         CHECK(LDKMessageSendEvent_HandleError_class != NULL);
1681         LDKMessageSendEvent_HandleError_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_HandleError_class, "<init>", "([BJ)V");
1682         CHECK(LDKMessageSendEvent_HandleError_meth != NULL);
1683         LDKMessageSendEvent_PaymentFailureNetworkUpdate_class =
1684                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$PaymentFailureNetworkUpdate;"));
1685         CHECK(LDKMessageSendEvent_PaymentFailureNetworkUpdate_class != NULL);
1686         LDKMessageSendEvent_PaymentFailureNetworkUpdate_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_PaymentFailureNetworkUpdate_class, "<init>", "(J)V");
1687         CHECK(LDKMessageSendEvent_PaymentFailureNetworkUpdate_meth != NULL);
1688         LDKMessageSendEvent_SendChannelRangeQuery_class =
1689                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendChannelRangeQuery;"));
1690         CHECK(LDKMessageSendEvent_SendChannelRangeQuery_class != NULL);
1691         LDKMessageSendEvent_SendChannelRangeQuery_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelRangeQuery_class, "<init>", "([BJ)V");
1692         CHECK(LDKMessageSendEvent_SendChannelRangeQuery_meth != NULL);
1693         LDKMessageSendEvent_SendShortIdsQuery_class =
1694                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendShortIdsQuery;"));
1695         CHECK(LDKMessageSendEvent_SendShortIdsQuery_class != NULL);
1696         LDKMessageSendEvent_SendShortIdsQuery_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendShortIdsQuery_class, "<init>", "([BJ)V");
1697         CHECK(LDKMessageSendEvent_SendShortIdsQuery_meth != NULL);
1698         LDKMessageSendEvent_SendReplyChannelRange_class =
1699                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendReplyChannelRange;"));
1700         CHECK(LDKMessageSendEvent_SendReplyChannelRange_class != NULL);
1701         LDKMessageSendEvent_SendReplyChannelRange_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendReplyChannelRange_class, "<init>", "([BJ)V");
1702         CHECK(LDKMessageSendEvent_SendReplyChannelRange_meth != NULL);
1703 }
1704 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1705         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
1706         switch(obj->tag) {
1707                 case LDKMessageSendEvent_SendAcceptChannel: {
1708                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1709                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_accept_channel.node_id.compressed_form);
1710                         LDKAcceptChannel msg_var = obj->send_accept_channel.msg;
1711                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1712                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1713                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1714                         return (*env)->NewObject(env, LDKMessageSendEvent_SendAcceptChannel_class, LDKMessageSendEvent_SendAcceptChannel_meth, node_id_arr, msg_ref);
1715                 }
1716                 case LDKMessageSendEvent_SendOpenChannel: {
1717                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1718                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_open_channel.node_id.compressed_form);
1719                         LDKOpenChannel msg_var = obj->send_open_channel.msg;
1720                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1721                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1722                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1723                         return (*env)->NewObject(env, LDKMessageSendEvent_SendOpenChannel_class, LDKMessageSendEvent_SendOpenChannel_meth, node_id_arr, msg_ref);
1724                 }
1725                 case LDKMessageSendEvent_SendFundingCreated: {
1726                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1727                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_created.node_id.compressed_form);
1728                         LDKFundingCreated msg_var = obj->send_funding_created.msg;
1729                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1730                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1731                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1732                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingCreated_class, LDKMessageSendEvent_SendFundingCreated_meth, node_id_arr, msg_ref);
1733                 }
1734                 case LDKMessageSendEvent_SendFundingSigned: {
1735                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1736                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_signed.node_id.compressed_form);
1737                         LDKFundingSigned msg_var = obj->send_funding_signed.msg;
1738                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1739                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1740                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1741                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingSigned_class, LDKMessageSendEvent_SendFundingSigned_meth, node_id_arr, msg_ref);
1742                 }
1743                 case LDKMessageSendEvent_SendFundingLocked: {
1744                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1745                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_locked.node_id.compressed_form);
1746                         LDKFundingLocked msg_var = obj->send_funding_locked.msg;
1747                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1748                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1749                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1750                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingLocked_class, LDKMessageSendEvent_SendFundingLocked_meth, node_id_arr, msg_ref);
1751                 }
1752                 case LDKMessageSendEvent_SendAnnouncementSignatures: {
1753                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1754                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_announcement_signatures.node_id.compressed_form);
1755                         LDKAnnouncementSignatures msg_var = obj->send_announcement_signatures.msg;
1756                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1757                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1758                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1759                         return (*env)->NewObject(env, LDKMessageSendEvent_SendAnnouncementSignatures_class, LDKMessageSendEvent_SendAnnouncementSignatures_meth, node_id_arr, msg_ref);
1760                 }
1761                 case LDKMessageSendEvent_UpdateHTLCs: {
1762                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1763                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->update_htl_cs.node_id.compressed_form);
1764                         LDKCommitmentUpdate updates_var = obj->update_htl_cs.updates;
1765                         CHECK((((uint64_t)updates_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1766                         CHECK((((uint64_t)&updates_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1767                         uint64_t updates_ref = (uint64_t)updates_var.inner & ~1;
1768                         return (*env)->NewObject(env, LDKMessageSendEvent_UpdateHTLCs_class, LDKMessageSendEvent_UpdateHTLCs_meth, node_id_arr, updates_ref);
1769                 }
1770                 case LDKMessageSendEvent_SendRevokeAndACK: {
1771                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1772                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_revoke_and_ack.node_id.compressed_form);
1773                         LDKRevokeAndACK msg_var = obj->send_revoke_and_ack.msg;
1774                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1775                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1776                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1777                         return (*env)->NewObject(env, LDKMessageSendEvent_SendRevokeAndACK_class, LDKMessageSendEvent_SendRevokeAndACK_meth, node_id_arr, msg_ref);
1778                 }
1779                 case LDKMessageSendEvent_SendClosingSigned: {
1780                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1781                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_closing_signed.node_id.compressed_form);
1782                         LDKClosingSigned msg_var = obj->send_closing_signed.msg;
1783                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1784                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1785                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1786                         return (*env)->NewObject(env, LDKMessageSendEvent_SendClosingSigned_class, LDKMessageSendEvent_SendClosingSigned_meth, node_id_arr, msg_ref);
1787                 }
1788                 case LDKMessageSendEvent_SendShutdown: {
1789                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1790                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_shutdown.node_id.compressed_form);
1791                         LDKShutdown msg_var = obj->send_shutdown.msg;
1792                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1793                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1794                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1795                         return (*env)->NewObject(env, LDKMessageSendEvent_SendShutdown_class, LDKMessageSendEvent_SendShutdown_meth, node_id_arr, msg_ref);
1796                 }
1797                 case LDKMessageSendEvent_SendChannelReestablish: {
1798                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1799                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_reestablish.node_id.compressed_form);
1800                         LDKChannelReestablish msg_var = obj->send_channel_reestablish.msg;
1801                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1802                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1803                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1804                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelReestablish_class, LDKMessageSendEvent_SendChannelReestablish_meth, node_id_arr, msg_ref);
1805                 }
1806                 case LDKMessageSendEvent_BroadcastChannelAnnouncement: {
1807                         LDKChannelAnnouncement msg_var = obj->broadcast_channel_announcement.msg;
1808                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1809                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1810                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1811                         LDKChannelUpdate update_msg_var = obj->broadcast_channel_announcement.update_msg;
1812                         CHECK((((uint64_t)update_msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1813                         CHECK((((uint64_t)&update_msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1814                         uint64_t update_msg_ref = (uint64_t)update_msg_var.inner & ~1;
1815                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastChannelAnnouncement_class, LDKMessageSendEvent_BroadcastChannelAnnouncement_meth, msg_ref, update_msg_ref);
1816                 }
1817                 case LDKMessageSendEvent_BroadcastNodeAnnouncement: {
1818                         LDKNodeAnnouncement msg_var = obj->broadcast_node_announcement.msg;
1819                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1820                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1821                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1822                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastNodeAnnouncement_class, LDKMessageSendEvent_BroadcastNodeAnnouncement_meth, msg_ref);
1823                 }
1824                 case LDKMessageSendEvent_BroadcastChannelUpdate: {
1825                         LDKChannelUpdate msg_var = obj->broadcast_channel_update.msg;
1826                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1827                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1828                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1829                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastChannelUpdate_class, LDKMessageSendEvent_BroadcastChannelUpdate_meth, msg_ref);
1830                 }
1831                 case LDKMessageSendEvent_SendChannelUpdate: {
1832                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1833                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_update.node_id.compressed_form);
1834                         LDKChannelUpdate msg_var = obj->send_channel_update.msg;
1835                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1836                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1837                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1838                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelUpdate_class, LDKMessageSendEvent_SendChannelUpdate_meth, node_id_arr, msg_ref);
1839                 }
1840                 case LDKMessageSendEvent_HandleError: {
1841                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1842                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->handle_error.node_id.compressed_form);
1843                         uint64_t action_ref = ((uint64_t)&obj->handle_error.action) | 1;
1844                         return (*env)->NewObject(env, LDKMessageSendEvent_HandleError_class, LDKMessageSendEvent_HandleError_meth, node_id_arr, action_ref);
1845                 }
1846                 case LDKMessageSendEvent_PaymentFailureNetworkUpdate: {
1847                         uint64_t update_ref = ((uint64_t)&obj->payment_failure_network_update.update) | 1;
1848                         return (*env)->NewObject(env, LDKMessageSendEvent_PaymentFailureNetworkUpdate_class, LDKMessageSendEvent_PaymentFailureNetworkUpdate_meth, update_ref);
1849                 }
1850                 case LDKMessageSendEvent_SendChannelRangeQuery: {
1851                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1852                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_range_query.node_id.compressed_form);
1853                         LDKQueryChannelRange msg_var = obj->send_channel_range_query.msg;
1854                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1855                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1856                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1857                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelRangeQuery_class, LDKMessageSendEvent_SendChannelRangeQuery_meth, node_id_arr, msg_ref);
1858                 }
1859                 case LDKMessageSendEvent_SendShortIdsQuery: {
1860                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1861                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_short_ids_query.node_id.compressed_form);
1862                         LDKQueryShortChannelIds msg_var = obj->send_short_ids_query.msg;
1863                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1864                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1865                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1866                         return (*env)->NewObject(env, LDKMessageSendEvent_SendShortIdsQuery_class, LDKMessageSendEvent_SendShortIdsQuery_meth, node_id_arr, msg_ref);
1867                 }
1868                 case LDKMessageSendEvent_SendReplyChannelRange: {
1869                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1870                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_reply_channel_range.node_id.compressed_form);
1871                         LDKReplyChannelRange msg_var = obj->send_reply_channel_range.msg;
1872                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1873                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1874                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1875                         return (*env)->NewObject(env, LDKMessageSendEvent_SendReplyChannelRange_class, LDKMessageSendEvent_SendReplyChannelRange_meth, node_id_arr, msg_ref);
1876                 }
1877                 default: abort();
1878         }
1879 }
1880 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1MessageSendEventZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1881         LDKCVec_MessageSendEventZ *ret = MALLOC(sizeof(LDKCVec_MessageSendEventZ), "LDKCVec_MessageSendEventZ");
1882         ret->datalen = (*env)->GetArrayLength(env, elems);
1883         if (ret->datalen == 0) {
1884                 ret->data = NULL;
1885         } else {
1886                 ret->data = MALLOC(sizeof(LDKMessageSendEvent) * ret->datalen, "LDKCVec_MessageSendEventZ Data");
1887                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1888                 for (size_t i = 0; i < ret->datalen; i++) {
1889                         int64_t arr_elem = java_elems[i];
1890                         LDKMessageSendEvent arr_elem_conv = *(LDKMessageSendEvent*)(((uint64_t)arr_elem) & ~1);
1891                         arr_elem_conv = MessageSendEvent_clone((LDKMessageSendEvent*)(((uint64_t)arr_elem) & ~1));
1892                         ret->data[i] = arr_elem_conv;
1893                 }
1894                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1895         }
1896         return (uint64_t)ret;
1897 }
1898 static inline LDKCVec_MessageSendEventZ CVec_MessageSendEventZ_clone(const LDKCVec_MessageSendEventZ *orig) {
1899         LDKCVec_MessageSendEventZ ret = { .data = MALLOC(sizeof(LDKMessageSendEvent) * orig->datalen, "LDKCVec_MessageSendEventZ clone bytes"), .datalen = orig->datalen };
1900         for (size_t i = 0; i < ret.datalen; i++) {
1901                 ret.data[i] = MessageSendEvent_clone(&orig->data[i]);
1902         }
1903         return ret;
1904 }
1905 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitFeaturesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1906         return ((LDKCResult_InitFeaturesDecodeErrorZ*)arg)->result_ok;
1907 }
1908 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1909         LDKCResult_InitFeaturesDecodeErrorZ *val = (LDKCResult_InitFeaturesDecodeErrorZ*)(arg & ~1);
1910         CHECK(val->result_ok);
1911         LDKInitFeatures res_var = (*val->contents.result);
1912         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1913         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1914         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1915         return res_ref;
1916 }
1917 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1918         LDKCResult_InitFeaturesDecodeErrorZ *val = (LDKCResult_InitFeaturesDecodeErrorZ*)(arg & ~1);
1919         CHECK(!val->result_ok);
1920         LDKDecodeError err_var = (*val->contents.err);
1921         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1922         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1923         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1924         return err_ref;
1925 }
1926 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeFeaturesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1927         return ((LDKCResult_NodeFeaturesDecodeErrorZ*)arg)->result_ok;
1928 }
1929 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1930         LDKCResult_NodeFeaturesDecodeErrorZ *val = (LDKCResult_NodeFeaturesDecodeErrorZ*)(arg & ~1);
1931         CHECK(val->result_ok);
1932         LDKNodeFeatures res_var = (*val->contents.result);
1933         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1934         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1935         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1936         return res_ref;
1937 }
1938 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1939         LDKCResult_NodeFeaturesDecodeErrorZ *val = (LDKCResult_NodeFeaturesDecodeErrorZ*)(arg & ~1);
1940         CHECK(!val->result_ok);
1941         LDKDecodeError err_var = (*val->contents.err);
1942         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1943         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1944         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1945         return err_ref;
1946 }
1947 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelFeaturesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1948         return ((LDKCResult_ChannelFeaturesDecodeErrorZ*)arg)->result_ok;
1949 }
1950 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1951         LDKCResult_ChannelFeaturesDecodeErrorZ *val = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(arg & ~1);
1952         CHECK(val->result_ok);
1953         LDKChannelFeatures res_var = (*val->contents.result);
1954         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1955         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1956         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1957         return res_ref;
1958 }
1959 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1960         LDKCResult_ChannelFeaturesDecodeErrorZ *val = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(arg & ~1);
1961         CHECK(!val->result_ok);
1962         LDKDecodeError err_var = (*val->contents.err);
1963         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1964         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1965         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1966         return err_ref;
1967 }
1968 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceFeaturesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1969         return ((LDKCResult_InvoiceFeaturesDecodeErrorZ*)arg)->result_ok;
1970 }
1971 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1972         LDKCResult_InvoiceFeaturesDecodeErrorZ *val = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(arg & ~1);
1973         CHECK(val->result_ok);
1974         LDKInvoiceFeatures res_var = (*val->contents.result);
1975         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1976         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1977         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1978         return res_ref;
1979 }
1980 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1981         LDKCResult_InvoiceFeaturesDecodeErrorZ *val = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(arg & ~1);
1982         CHECK(!val->result_ok);
1983         LDKDecodeError err_var = (*val->contents.err);
1984         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1985         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1986         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1987         return err_ref;
1988 }
1989 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1990         return ((LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)arg)->result_ok;
1991 }
1992 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1993         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
1994         CHECK(val->result_ok);
1995         LDKDelayedPaymentOutputDescriptor res_var = (*val->contents.result);
1996         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1997         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1998         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1999         return res_ref;
2000 }
2001 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2002         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
2003         CHECK(!val->result_ok);
2004         LDKDecodeError err_var = (*val->contents.err);
2005         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2006         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2007         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
2008         return err_ref;
2009 }
2010 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2011         return ((LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)arg)->result_ok;
2012 }
2013 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2014         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
2015         CHECK(val->result_ok);
2016         LDKStaticPaymentOutputDescriptor res_var = (*val->contents.result);
2017         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2018         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2019         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
2020         return res_ref;
2021 }
2022 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2023         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
2024         CHECK(!val->result_ok);
2025         LDKDecodeError err_var = (*val->contents.err);
2026         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2027         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2028         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
2029         return err_ref;
2030 }
2031 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SpendableOutputDescriptorDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2032         return ((LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)arg)->result_ok;
2033 }
2034 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SpendableOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2035         LDKCResult_SpendableOutputDescriptorDecodeErrorZ *val = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(arg & ~1);
2036         CHECK(val->result_ok);
2037         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
2038         return res_ref;
2039 }
2040 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SpendableOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2041         LDKCResult_SpendableOutputDescriptorDecodeErrorZ *val = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(arg & ~1);
2042         CHECK(!val->result_ok);
2043         LDKDecodeError err_var = (*val->contents.err);
2044         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2045         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2046         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
2047         return err_ref;
2048 }
2049 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1SignatureCVec_1SignatureZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, jobjectArray b) {
2050         LDKC2Tuple_SignatureCVec_SignatureZZ* ret = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
2051         LDKSignature a_ref;
2052         CHECK((*env)->GetArrayLength(env, a) == 64);
2053         (*env)->GetByteArrayRegion(env, a, 0, 64, a_ref.compact_form);
2054         ret->a = a_ref;
2055         LDKCVec_SignatureZ b_constr;
2056         b_constr.datalen = (*env)->GetArrayLength(env, b);
2057         if (b_constr.datalen > 0)
2058                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
2059         else
2060                 b_constr.data = NULL;
2061         for (size_t i = 0; i < b_constr.datalen; i++) {
2062                 int8_tArray b_conv_8 = (*env)->GetObjectArrayElement(env, b, i);
2063                 LDKSignature b_conv_8_ref;
2064                 CHECK((*env)->GetArrayLength(env, b_conv_8) == 64);
2065                 (*env)->GetByteArrayRegion(env, b_conv_8, 0, 64, b_conv_8_ref.compact_form);
2066                 b_constr.data[i] = b_conv_8_ref;
2067         }
2068         ret->b = b_constr;
2069         return (uint64_t)ret;
2070 }
2071 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1SignatureCVec_1SignatureZZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
2072         LDKC2Tuple_SignatureCVec_SignatureZZ *tuple = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(ptr & ~1);
2073         int8_tArray a_arr = (*env)->NewByteArray(env, 64);
2074         (*env)->SetByteArrayRegion(env, a_arr, 0, 64, tuple->a.compact_form);
2075         return a_arr;
2076 }
2077 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1SignatureCVec_1SignatureZZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
2078         LDKC2Tuple_SignatureCVec_SignatureZZ *tuple = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(ptr & ~1);
2079         LDKCVec_SignatureZ b_var = tuple->b;
2080         jobjectArray b_arr = (*env)->NewObjectArray(env, b_var.datalen, arr_of_B_clz, NULL);
2081         ;
2082         for (size_t i = 0; i < b_var.datalen; i++) {
2083                 int8_tArray b_conv_8_arr = (*env)->NewByteArray(env, 64);
2084                 (*env)->SetByteArrayRegion(env, b_conv_8_arr, 0, 64, b_var.data[i].compact_form);
2085                 (*env)->SetObjectArrayElement(env, b_arr, i, b_conv_8_arr);
2086         }
2087         return b_arr;
2088 }
2089 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2090         return ((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)arg)->result_ok;
2091 }
2092 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2093         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *val = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(arg & ~1);
2094         CHECK(val->result_ok);
2095         uint64_t res_ref = (uint64_t)(&(*val->contents.result)) | 1;
2096         return res_ref;
2097 }
2098 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2099         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *val = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(arg & ~1);
2100         CHECK(!val->result_ok);
2101         return *val->contents.err;
2102 }
2103 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignatureNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2104         return ((LDKCResult_SignatureNoneZ*)arg)->result_ok;
2105 }
2106 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignatureNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2107         LDKCResult_SignatureNoneZ *val = (LDKCResult_SignatureNoneZ*)(arg & ~1);
2108         CHECK(val->result_ok);
2109         int8_tArray res_arr = (*env)->NewByteArray(env, 64);
2110         (*env)->SetByteArrayRegion(env, res_arr, 0, 64, (*val->contents.result).compact_form);
2111         return res_arr;
2112 }
2113 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignatureNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2114         LDKCResult_SignatureNoneZ *val = (LDKCResult_SignatureNoneZ*)(arg & ~1);
2115         CHECK(!val->result_ok);
2116         return *val->contents.err;
2117 }
2118 typedef struct LDKBaseSign_JCalls {
2119         atomic_size_t refcnt;
2120         JavaVM *vm;
2121         jweak o;
2122         jmethodID get_per_commitment_point_meth;
2123         jmethodID release_commitment_secret_meth;
2124         jmethodID channel_keys_id_meth;
2125         jmethodID sign_counterparty_commitment_meth;
2126         jmethodID sign_holder_commitment_and_htlcs_meth;
2127         jmethodID sign_justice_revoked_output_meth;
2128         jmethodID sign_justice_revoked_htlc_meth;
2129         jmethodID sign_counterparty_htlc_transaction_meth;
2130         jmethodID sign_closing_transaction_meth;
2131         jmethodID sign_channel_announcement_meth;
2132         jmethodID ready_channel_meth;
2133 } LDKBaseSign_JCalls;
2134 static void LDKBaseSign_JCalls_free(void* this_arg) {
2135         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2136         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2137                 JNIEnv *env;
2138                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2139                 if (get_jenv_res == JNI_EDETACHED) {
2140                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2141                 } else {
2142                         DO_ASSERT(get_jenv_res == JNI_OK);
2143                 }
2144                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
2145                 if (get_jenv_res == JNI_EDETACHED) {
2146                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2147                 }
2148                 FREE(j_calls);
2149         }
2150 }
2151 LDKPublicKey get_per_commitment_point_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
2152         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2153         JNIEnv *env;
2154         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2155         if (get_jenv_res == JNI_EDETACHED) {
2156                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2157         } else {
2158                 DO_ASSERT(get_jenv_res == JNI_OK);
2159         }
2160         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2161         CHECK(obj != NULL);
2162         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_per_commitment_point_meth, idx);
2163         if ((*env)->ExceptionCheck(env)) {
2164                 (*env)->ExceptionDescribe(env);
2165                 (*env)->FatalError(env, "A call to get_per_commitment_point in LDKBaseSign from rust threw an exception.");
2166         }
2167         LDKPublicKey ret_ref;
2168         CHECK((*env)->GetArrayLength(env, ret) == 33);
2169         (*env)->GetByteArrayRegion(env, ret, 0, 33, ret_ref.compressed_form);
2170         if (get_jenv_res == JNI_EDETACHED) {
2171                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2172         }
2173         return ret_ref;
2174 }
2175 LDKThirtyTwoBytes release_commitment_secret_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
2176         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2177         JNIEnv *env;
2178         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2179         if (get_jenv_res == JNI_EDETACHED) {
2180                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2181         } else {
2182                 DO_ASSERT(get_jenv_res == JNI_OK);
2183         }
2184         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2185         CHECK(obj != NULL);
2186         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->release_commitment_secret_meth, idx);
2187         if ((*env)->ExceptionCheck(env)) {
2188                 (*env)->ExceptionDescribe(env);
2189                 (*env)->FatalError(env, "A call to release_commitment_secret in LDKBaseSign from rust threw an exception.");
2190         }
2191         LDKThirtyTwoBytes ret_ref;
2192         CHECK((*env)->GetArrayLength(env, ret) == 32);
2193         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
2194         if (get_jenv_res == JNI_EDETACHED) {
2195                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2196         }
2197         return ret_ref;
2198 }
2199 LDKThirtyTwoBytes channel_keys_id_LDKBaseSign_jcall(const void* this_arg) {
2200         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2201         JNIEnv *env;
2202         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2203         if (get_jenv_res == JNI_EDETACHED) {
2204                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2205         } else {
2206                 DO_ASSERT(get_jenv_res == JNI_OK);
2207         }
2208         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2209         CHECK(obj != NULL);
2210         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->channel_keys_id_meth);
2211         if ((*env)->ExceptionCheck(env)) {
2212                 (*env)->ExceptionDescribe(env);
2213                 (*env)->FatalError(env, "A call to channel_keys_id in LDKBaseSign from rust threw an exception.");
2214         }
2215         LDKThirtyTwoBytes ret_ref;
2216         CHECK((*env)->GetArrayLength(env, ret) == 32);
2217         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
2218         if (get_jenv_res == JNI_EDETACHED) {
2219                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2220         }
2221         return ret_ref;
2222 }
2223 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKCommitmentTransaction * commitment_tx) {
2224         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2225         JNIEnv *env;
2226         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2227         if (get_jenv_res == JNI_EDETACHED) {
2228                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2229         } else {
2230                 DO_ASSERT(get_jenv_res == JNI_OK);
2231         }
2232         LDKCommitmentTransaction commitment_tx_var = *commitment_tx;
2233         commitment_tx_var = CommitmentTransaction_clone(commitment_tx);
2234         CHECK((((uint64_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2235         CHECK((((uint64_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2236         uint64_t commitment_tx_ref = (uint64_t)commitment_tx_var.inner;
2237         if (commitment_tx_var.is_owned) {
2238                 commitment_tx_ref |= 1;
2239         }
2240         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2241         CHECK(obj != NULL);
2242         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(*env)->CallLongMethod(env, obj, j_calls->sign_counterparty_commitment_meth, commitment_tx_ref);
2243         if ((*env)->ExceptionCheck(env)) {
2244                 (*env)->ExceptionDescribe(env);
2245                 (*env)->FatalError(env, "A call to sign_counterparty_commitment in LDKBaseSign from rust threw an exception.");
2246         }
2247         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1);
2248         ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1));
2249         if (get_jenv_res == JNI_EDETACHED) {
2250                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2251         }
2252         return ret_conv;
2253 }
2254 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_holder_commitment_and_htlcs_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * commitment_tx) {
2255         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2256         JNIEnv *env;
2257         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2258         if (get_jenv_res == JNI_EDETACHED) {
2259                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2260         } else {
2261                 DO_ASSERT(get_jenv_res == JNI_OK);
2262         }
2263         LDKHolderCommitmentTransaction commitment_tx_var = *commitment_tx;
2264         commitment_tx_var = HolderCommitmentTransaction_clone(commitment_tx);
2265         CHECK((((uint64_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2266         CHECK((((uint64_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2267         uint64_t commitment_tx_ref = (uint64_t)commitment_tx_var.inner;
2268         if (commitment_tx_var.is_owned) {
2269                 commitment_tx_ref |= 1;
2270         }
2271         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2272         CHECK(obj != NULL);
2273         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(*env)->CallLongMethod(env, obj, j_calls->sign_holder_commitment_and_htlcs_meth, commitment_tx_ref);
2274         if ((*env)->ExceptionCheck(env)) {
2275                 (*env)->ExceptionDescribe(env);
2276                 (*env)->FatalError(env, "A call to sign_holder_commitment_and_htlcs in LDKBaseSign from rust threw an exception.");
2277         }
2278         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1);
2279         ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1));
2280         if (get_jenv_res == JNI_EDETACHED) {
2281                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2282         }
2283         return ret_conv;
2284 }
2285 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]) {
2286         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2287         JNIEnv *env;
2288         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2289         if (get_jenv_res == JNI_EDETACHED) {
2290                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2291         } else {
2292                 DO_ASSERT(get_jenv_res == JNI_OK);
2293         }
2294         LDKTransaction justice_tx_var = justice_tx;
2295         int8_tArray justice_tx_arr = (*env)->NewByteArray(env, justice_tx_var.datalen);
2296         (*env)->SetByteArrayRegion(env, justice_tx_arr, 0, justice_tx_var.datalen, justice_tx_var.data);
2297         Transaction_free(justice_tx_var);
2298         int8_tArray per_commitment_key_arr = (*env)->NewByteArray(env, 32);
2299         (*env)->SetByteArrayRegion(env, per_commitment_key_arr, 0, 32, *per_commitment_key);
2300         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2301         CHECK(obj != NULL);
2302         LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)(*env)->CallLongMethod(env, obj, j_calls->sign_justice_revoked_output_meth, justice_tx_arr, input, amount, per_commitment_key_arr);
2303         if ((*env)->ExceptionCheck(env)) {
2304                 (*env)->ExceptionDescribe(env);
2305                 (*env)->FatalError(env, "A call to sign_justice_revoked_output in LDKBaseSign from rust threw an exception.");
2306         }
2307         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
2308         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
2309         if (get_jenv_res == JNI_EDETACHED) {
2310                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2311         }
2312         return ret_conv;
2313 }
2314 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) {
2315         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2316         JNIEnv *env;
2317         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2318         if (get_jenv_res == JNI_EDETACHED) {
2319                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2320         } else {
2321                 DO_ASSERT(get_jenv_res == JNI_OK);
2322         }
2323         LDKTransaction justice_tx_var = justice_tx;
2324         int8_tArray justice_tx_arr = (*env)->NewByteArray(env, justice_tx_var.datalen);
2325         (*env)->SetByteArrayRegion(env, justice_tx_arr, 0, justice_tx_var.datalen, justice_tx_var.data);
2326         Transaction_free(justice_tx_var);
2327         int8_tArray per_commitment_key_arr = (*env)->NewByteArray(env, 32);
2328         (*env)->SetByteArrayRegion(env, per_commitment_key_arr, 0, 32, *per_commitment_key);
2329         LDKHTLCOutputInCommitment htlc_var = *htlc;
2330         htlc_var = HTLCOutputInCommitment_clone(htlc);
2331         CHECK((((uint64_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2332         CHECK((((uint64_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2333         uint64_t htlc_ref = (uint64_t)htlc_var.inner;
2334         if (htlc_var.is_owned) {
2335                 htlc_ref |= 1;
2336         }
2337         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2338         CHECK(obj != NULL);
2339         LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)(*env)->CallLongMethod(env, obj, j_calls->sign_justice_revoked_htlc_meth, justice_tx_arr, input, amount, per_commitment_key_arr, htlc_ref);
2340         if ((*env)->ExceptionCheck(env)) {
2341                 (*env)->ExceptionDescribe(env);
2342                 (*env)->FatalError(env, "A call to sign_justice_revoked_htlc in LDKBaseSign from rust threw an exception.");
2343         }
2344         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
2345         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
2346         if (get_jenv_res == JNI_EDETACHED) {
2347                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2348         }
2349         return ret_conv;
2350 }
2351 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) {
2352         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2353         JNIEnv *env;
2354         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2355         if (get_jenv_res == JNI_EDETACHED) {
2356                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2357         } else {
2358                 DO_ASSERT(get_jenv_res == JNI_OK);
2359         }
2360         LDKTransaction htlc_tx_var = htlc_tx;
2361         int8_tArray htlc_tx_arr = (*env)->NewByteArray(env, htlc_tx_var.datalen);
2362         (*env)->SetByteArrayRegion(env, htlc_tx_arr, 0, htlc_tx_var.datalen, htlc_tx_var.data);
2363         Transaction_free(htlc_tx_var);
2364         int8_tArray per_commitment_point_arr = (*env)->NewByteArray(env, 33);
2365         (*env)->SetByteArrayRegion(env, per_commitment_point_arr, 0, 33, per_commitment_point.compressed_form);
2366         LDKHTLCOutputInCommitment htlc_var = *htlc;
2367         htlc_var = HTLCOutputInCommitment_clone(htlc);
2368         CHECK((((uint64_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2369         CHECK((((uint64_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2370         uint64_t htlc_ref = (uint64_t)htlc_var.inner;
2371         if (htlc_var.is_owned) {
2372                 htlc_ref |= 1;
2373         }
2374         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2375         CHECK(obj != NULL);
2376         LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)(*env)->CallLongMethod(env, obj, j_calls->sign_counterparty_htlc_transaction_meth, htlc_tx_arr, input, amount, per_commitment_point_arr, htlc_ref);
2377         if ((*env)->ExceptionCheck(env)) {
2378                 (*env)->ExceptionDescribe(env);
2379                 (*env)->FatalError(env, "A call to sign_counterparty_htlc_transaction in LDKBaseSign from rust threw an exception.");
2380         }
2381         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
2382         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
2383         if (get_jenv_res == JNI_EDETACHED) {
2384                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2385         }
2386         return ret_conv;
2387 }
2388 LDKCResult_SignatureNoneZ sign_closing_transaction_LDKBaseSign_jcall(const void* this_arg, LDKTransaction closing_tx) {
2389         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2390         JNIEnv *env;
2391         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2392         if (get_jenv_res == JNI_EDETACHED) {
2393                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2394         } else {
2395                 DO_ASSERT(get_jenv_res == JNI_OK);
2396         }
2397         LDKTransaction closing_tx_var = closing_tx;
2398         int8_tArray closing_tx_arr = (*env)->NewByteArray(env, closing_tx_var.datalen);
2399         (*env)->SetByteArrayRegion(env, closing_tx_arr, 0, closing_tx_var.datalen, closing_tx_var.data);
2400         Transaction_free(closing_tx_var);
2401         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2402         CHECK(obj != NULL);
2403         LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)(*env)->CallLongMethod(env, obj, j_calls->sign_closing_transaction_meth, closing_tx_arr);
2404         if ((*env)->ExceptionCheck(env)) {
2405                 (*env)->ExceptionDescribe(env);
2406                 (*env)->FatalError(env, "A call to sign_closing_transaction in LDKBaseSign from rust threw an exception.");
2407         }
2408         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
2409         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
2410         if (get_jenv_res == JNI_EDETACHED) {
2411                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2412         }
2413         return ret_conv;
2414 }
2415 LDKCResult_SignatureNoneZ sign_channel_announcement_LDKBaseSign_jcall(const void* this_arg, const LDKUnsignedChannelAnnouncement * msg) {
2416         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2417         JNIEnv *env;
2418         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2419         if (get_jenv_res == JNI_EDETACHED) {
2420                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2421         } else {
2422                 DO_ASSERT(get_jenv_res == JNI_OK);
2423         }
2424         LDKUnsignedChannelAnnouncement msg_var = *msg;
2425         msg_var = UnsignedChannelAnnouncement_clone(msg);
2426         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2427         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2428         uint64_t msg_ref = (uint64_t)msg_var.inner;
2429         if (msg_var.is_owned) {
2430                 msg_ref |= 1;
2431         }
2432         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2433         CHECK(obj != NULL);
2434         LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)(*env)->CallLongMethod(env, obj, j_calls->sign_channel_announcement_meth, msg_ref);
2435         if ((*env)->ExceptionCheck(env)) {
2436                 (*env)->ExceptionDescribe(env);
2437                 (*env)->FatalError(env, "A call to sign_channel_announcement in LDKBaseSign from rust threw an exception.");
2438         }
2439         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
2440         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
2441         if (get_jenv_res == JNI_EDETACHED) {
2442                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2443         }
2444         return ret_conv;
2445 }
2446 void ready_channel_LDKBaseSign_jcall(void* this_arg, const LDKChannelTransactionParameters * channel_parameters) {
2447         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2448         JNIEnv *env;
2449         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2450         if (get_jenv_res == JNI_EDETACHED) {
2451                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2452         } else {
2453                 DO_ASSERT(get_jenv_res == JNI_OK);
2454         }
2455         LDKChannelTransactionParameters channel_parameters_var = *channel_parameters;
2456         channel_parameters_var = ChannelTransactionParameters_clone(channel_parameters);
2457         CHECK((((uint64_t)channel_parameters_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2458         CHECK((((uint64_t)&channel_parameters_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2459         uint64_t channel_parameters_ref = (uint64_t)channel_parameters_var.inner;
2460         if (channel_parameters_var.is_owned) {
2461                 channel_parameters_ref |= 1;
2462         }
2463         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2464         CHECK(obj != NULL);
2465         (*env)->CallVoidMethod(env, obj, j_calls->ready_channel_meth, channel_parameters_ref);
2466         if ((*env)->ExceptionCheck(env)) {
2467                 (*env)->ExceptionDescribe(env);
2468                 (*env)->FatalError(env, "A call to ready_channel in LDKBaseSign from rust threw an exception.");
2469         }
2470         if (get_jenv_res == JNI_EDETACHED) {
2471                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2472         }
2473 }
2474 static void* LDKBaseSign_JCalls_clone(const void* this_arg) {
2475         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2476         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2477         return (void*) this_arg;
2478 }
2479 static inline LDKBaseSign LDKBaseSign_init (JNIEnv *env, jclass clz, jobject o, int64_t pubkeys) {
2480         jclass c = (*env)->GetObjectClass(env, o);
2481         CHECK(c != NULL);
2482         LDKBaseSign_JCalls *calls = MALLOC(sizeof(LDKBaseSign_JCalls), "LDKBaseSign_JCalls");
2483         atomic_init(&calls->refcnt, 1);
2484         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
2485         calls->o = (*env)->NewWeakGlobalRef(env, o);
2486         calls->get_per_commitment_point_meth = (*env)->GetMethodID(env, c, "get_per_commitment_point", "(J)[B");
2487         CHECK(calls->get_per_commitment_point_meth != NULL);
2488         calls->release_commitment_secret_meth = (*env)->GetMethodID(env, c, "release_commitment_secret", "(J)[B");
2489         CHECK(calls->release_commitment_secret_meth != NULL);
2490         calls->channel_keys_id_meth = (*env)->GetMethodID(env, c, "channel_keys_id", "()[B");
2491         CHECK(calls->channel_keys_id_meth != NULL);
2492         calls->sign_counterparty_commitment_meth = (*env)->GetMethodID(env, c, "sign_counterparty_commitment", "(J)J");
2493         CHECK(calls->sign_counterparty_commitment_meth != NULL);
2494         calls->sign_holder_commitment_and_htlcs_meth = (*env)->GetMethodID(env, c, "sign_holder_commitment_and_htlcs", "(J)J");
2495         CHECK(calls->sign_holder_commitment_and_htlcs_meth != NULL);
2496         calls->sign_justice_revoked_output_meth = (*env)->GetMethodID(env, c, "sign_justice_revoked_output", "([BJJ[B)J");
2497         CHECK(calls->sign_justice_revoked_output_meth != NULL);
2498         calls->sign_justice_revoked_htlc_meth = (*env)->GetMethodID(env, c, "sign_justice_revoked_htlc", "([BJJ[BJ)J");
2499         CHECK(calls->sign_justice_revoked_htlc_meth != NULL);
2500         calls->sign_counterparty_htlc_transaction_meth = (*env)->GetMethodID(env, c, "sign_counterparty_htlc_transaction", "([BJJ[BJ)J");
2501         CHECK(calls->sign_counterparty_htlc_transaction_meth != NULL);
2502         calls->sign_closing_transaction_meth = (*env)->GetMethodID(env, c, "sign_closing_transaction", "([B)J");
2503         CHECK(calls->sign_closing_transaction_meth != NULL);
2504         calls->sign_channel_announcement_meth = (*env)->GetMethodID(env, c, "sign_channel_announcement", "(J)J");
2505         CHECK(calls->sign_channel_announcement_meth != NULL);
2506         calls->ready_channel_meth = (*env)->GetMethodID(env, c, "ready_channel", "(J)V");
2507         CHECK(calls->ready_channel_meth != NULL);
2508
2509         LDKChannelPublicKeys pubkeys_conv;
2510         pubkeys_conv.inner = (void*)(pubkeys & (~1));
2511         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
2512         pubkeys_conv = ChannelPublicKeys_clone(&pubkeys_conv);
2513
2514         LDKBaseSign ret = {
2515                 .this_arg = (void*) calls,
2516                 .get_per_commitment_point = get_per_commitment_point_LDKBaseSign_jcall,
2517                 .release_commitment_secret = release_commitment_secret_LDKBaseSign_jcall,
2518                 .channel_keys_id = channel_keys_id_LDKBaseSign_jcall,
2519                 .sign_counterparty_commitment = sign_counterparty_commitment_LDKBaseSign_jcall,
2520                 .sign_holder_commitment_and_htlcs = sign_holder_commitment_and_htlcs_LDKBaseSign_jcall,
2521                 .sign_justice_revoked_output = sign_justice_revoked_output_LDKBaseSign_jcall,
2522                 .sign_justice_revoked_htlc = sign_justice_revoked_htlc_LDKBaseSign_jcall,
2523                 .sign_counterparty_htlc_transaction = sign_counterparty_htlc_transaction_LDKBaseSign_jcall,
2524                 .sign_closing_transaction = sign_closing_transaction_LDKBaseSign_jcall,
2525                 .sign_channel_announcement = sign_channel_announcement_LDKBaseSign_jcall,
2526                 .ready_channel = ready_channel_LDKBaseSign_jcall,
2527                 .free = LDKBaseSign_JCalls_free,
2528                 .pubkeys = pubkeys_conv,
2529                 .set_pubkeys = NULL,
2530         };
2531         return ret;
2532 }
2533 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKBaseSign_1new(JNIEnv *env, jclass clz, jobject o, int64_t pubkeys) {
2534         LDKBaseSign *res_ptr = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
2535         *res_ptr = LDKBaseSign_init(env, clz, o, pubkeys);
2536         return (uint64_t)res_ptr;
2537 }
2538 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) {
2539         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2540         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
2541         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, (this_arg_conv->get_per_commitment_point)(this_arg_conv->this_arg, idx).compressed_form);
2542         return ret_arr;
2543 }
2544
2545 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BaseSign_1release_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_arg, int64_t idx) {
2546         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2547         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
2548         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->release_commitment_secret)(this_arg_conv->this_arg, idx).data);
2549         return ret_arr;
2550 }
2551
2552 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BaseSign_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
2553         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2554         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
2555         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->channel_keys_id)(this_arg_conv->this_arg).data);
2556         return ret_arr;
2557 }
2558
2559 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) {
2560         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2561         LDKCommitmentTransaction commitment_tx_conv;
2562         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
2563         commitment_tx_conv.is_owned = false;
2564         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
2565         *ret_conv = (this_arg_conv->sign_counterparty_commitment)(this_arg_conv->this_arg, &commitment_tx_conv);
2566         return (uint64_t)ret_conv;
2567 }
2568
2569 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) {
2570         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2571         LDKHolderCommitmentTransaction commitment_tx_conv;
2572         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
2573         commitment_tx_conv.is_owned = false;
2574         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
2575         *ret_conv = (this_arg_conv->sign_holder_commitment_and_htlcs)(this_arg_conv->this_arg, &commitment_tx_conv);
2576         return (uint64_t)ret_conv;
2577 }
2578
2579 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) {
2580         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2581         LDKTransaction justice_tx_ref;
2582         justice_tx_ref.datalen = (*env)->GetArrayLength(env, justice_tx);
2583         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
2584         (*env)->GetByteArrayRegion(env, justice_tx, 0, justice_tx_ref.datalen, justice_tx_ref.data);
2585         justice_tx_ref.data_is_owned = true;
2586         unsigned char per_commitment_key_arr[32];
2587         CHECK((*env)->GetArrayLength(env, per_commitment_key) == 32);
2588         (*env)->GetByteArrayRegion(env, per_commitment_key, 0, 32, per_commitment_key_arr);
2589         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
2590         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2591         *ret_conv = (this_arg_conv->sign_justice_revoked_output)(this_arg_conv->this_arg, justice_tx_ref, input, amount, per_commitment_key_ref);
2592         return (uint64_t)ret_conv;
2593 }
2594
2595 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) {
2596         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2597         LDKTransaction justice_tx_ref;
2598         justice_tx_ref.datalen = (*env)->GetArrayLength(env, justice_tx);
2599         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
2600         (*env)->GetByteArrayRegion(env, justice_tx, 0, justice_tx_ref.datalen, justice_tx_ref.data);
2601         justice_tx_ref.data_is_owned = true;
2602         unsigned char per_commitment_key_arr[32];
2603         CHECK((*env)->GetArrayLength(env, per_commitment_key) == 32);
2604         (*env)->GetByteArrayRegion(env, per_commitment_key, 0, 32, per_commitment_key_arr);
2605         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
2606         LDKHTLCOutputInCommitment htlc_conv;
2607         htlc_conv.inner = (void*)(htlc & (~1));
2608         htlc_conv.is_owned = false;
2609         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2610         *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);
2611         return (uint64_t)ret_conv;
2612 }
2613
2614 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) {
2615         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2616         LDKTransaction htlc_tx_ref;
2617         htlc_tx_ref.datalen = (*env)->GetArrayLength(env, htlc_tx);
2618         htlc_tx_ref.data = MALLOC(htlc_tx_ref.datalen, "LDKTransaction Bytes");
2619         (*env)->GetByteArrayRegion(env, htlc_tx, 0, htlc_tx_ref.datalen, htlc_tx_ref.data);
2620         htlc_tx_ref.data_is_owned = true;
2621         LDKPublicKey per_commitment_point_ref;
2622         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
2623         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
2624         LDKHTLCOutputInCommitment htlc_conv;
2625         htlc_conv.inner = (void*)(htlc & (~1));
2626         htlc_conv.is_owned = false;
2627         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2628         *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);
2629         return (uint64_t)ret_conv;
2630 }
2631
2632 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1sign_1closing_1transaction(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray closing_tx) {
2633         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2634         LDKTransaction closing_tx_ref;
2635         closing_tx_ref.datalen = (*env)->GetArrayLength(env, closing_tx);
2636         closing_tx_ref.data = MALLOC(closing_tx_ref.datalen, "LDKTransaction Bytes");
2637         (*env)->GetByteArrayRegion(env, closing_tx, 0, closing_tx_ref.datalen, closing_tx_ref.data);
2638         closing_tx_ref.data_is_owned = true;
2639         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2640         *ret_conv = (this_arg_conv->sign_closing_transaction)(this_arg_conv->this_arg, closing_tx_ref);
2641         return (uint64_t)ret_conv;
2642 }
2643
2644 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1sign_1channel_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
2645         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2646         LDKUnsignedChannelAnnouncement msg_conv;
2647         msg_conv.inner = (void*)(msg & (~1));
2648         msg_conv.is_owned = false;
2649         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2650         *ret_conv = (this_arg_conv->sign_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
2651         return (uint64_t)ret_conv;
2652 }
2653
2654 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BaseSign_1ready_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t channel_parameters) {
2655         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2656         LDKChannelTransactionParameters channel_parameters_conv;
2657         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
2658         channel_parameters_conv.is_owned = false;
2659         (this_arg_conv->ready_channel)(this_arg_conv->this_arg, &channel_parameters_conv);
2660 }
2661
2662 LDKChannelPublicKeys LDKBaseSign_set_get_pubkeys(LDKBaseSign* this_arg) {
2663         if (this_arg->set_pubkeys != NULL)
2664                 this_arg->set_pubkeys(this_arg);
2665         return this_arg->pubkeys;
2666 }
2667 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1get_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
2668         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2669         LDKChannelPublicKeys ret_var = LDKBaseSign_set_get_pubkeys(this_arg_conv);
2670         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2671         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2672         uint64_t ret_ref = (uint64_t)ret_var.inner;
2673         if (ret_var.is_owned) {
2674                 ret_ref |= 1;
2675         }
2676         return ret_ref;
2677 }
2678
2679 typedef struct LDKSign_JCalls {
2680         atomic_size_t refcnt;
2681         JavaVM *vm;
2682         jweak o;
2683         LDKBaseSign_JCalls* BaseSign;
2684         jmethodID write_meth;
2685 } LDKSign_JCalls;
2686 static void LDKSign_JCalls_free(void* this_arg) {
2687         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
2688         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2689                 JNIEnv *env;
2690                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2691                 if (get_jenv_res == JNI_EDETACHED) {
2692                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2693                 } else {
2694                         DO_ASSERT(get_jenv_res == JNI_OK);
2695                 }
2696                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
2697                 if (get_jenv_res == JNI_EDETACHED) {
2698                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2699                 }
2700                 FREE(j_calls);
2701         }
2702 }
2703 LDKCVec_u8Z write_LDKSign_jcall(const void* this_arg) {
2704         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
2705         JNIEnv *env;
2706         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2707         if (get_jenv_res == JNI_EDETACHED) {
2708                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2709         } else {
2710                 DO_ASSERT(get_jenv_res == JNI_OK);
2711         }
2712         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2713         CHECK(obj != NULL);
2714         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->write_meth);
2715         if ((*env)->ExceptionCheck(env)) {
2716                 (*env)->ExceptionDescribe(env);
2717                 (*env)->FatalError(env, "A call to write in LDKSign from rust threw an exception.");
2718         }
2719         LDKCVec_u8Z ret_ref;
2720         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
2721         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
2722         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
2723         if (get_jenv_res == JNI_EDETACHED) {
2724                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2725         }
2726         return ret_ref;
2727 }
2728 static void* LDKSign_JCalls_clone(const void* this_arg) {
2729         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
2730         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2731         atomic_fetch_add_explicit(&j_calls->BaseSign->refcnt, 1, memory_order_release);
2732         return (void*) this_arg;
2733 }
2734 static inline LDKSign LDKSign_init (JNIEnv *env, jclass clz, jobject o, jobject BaseSign, int64_t pubkeys) {
2735         jclass c = (*env)->GetObjectClass(env, o);
2736         CHECK(c != NULL);
2737         LDKSign_JCalls *calls = MALLOC(sizeof(LDKSign_JCalls), "LDKSign_JCalls");
2738         atomic_init(&calls->refcnt, 1);
2739         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
2740         calls->o = (*env)->NewWeakGlobalRef(env, o);
2741         calls->write_meth = (*env)->GetMethodID(env, c, "write", "()[B");
2742         CHECK(calls->write_meth != NULL);
2743
2744         LDKChannelPublicKeys pubkeys_conv;
2745         pubkeys_conv.inner = (void*)(pubkeys & (~1));
2746         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
2747         pubkeys_conv = ChannelPublicKeys_clone(&pubkeys_conv);
2748
2749         LDKSign ret = {
2750                 .this_arg = (void*) calls,
2751                 .write = write_LDKSign_jcall,
2752                 .clone = LDKSign_JCalls_clone,
2753                 .free = LDKSign_JCalls_free,
2754                 .BaseSign = LDKBaseSign_init(env, clz, BaseSign, pubkeys),
2755         };
2756         calls->BaseSign = ret.BaseSign.this_arg;
2757         return ret;
2758 }
2759 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSign_1new(JNIEnv *env, jclass clz, jobject o, jobject BaseSign, int64_t pubkeys) {
2760         LDKSign *res_ptr = MALLOC(sizeof(LDKSign), "LDKSign");
2761         *res_ptr = LDKSign_init(env, clz, o, BaseSign, pubkeys);
2762         return (uint64_t)res_ptr;
2763 }
2764 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Sign_1write(JNIEnv *env, jclass clz, int64_t this_arg) {
2765         LDKSign* this_arg_conv = (LDKSign*)(((uint64_t)this_arg) & ~1);
2766         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
2767         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
2768         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
2769         CVec_u8Z_free(ret_var);
2770         return ret_arr;
2771 }
2772
2773 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2774         return ((LDKCResult_SignDecodeErrorZ*)arg)->result_ok;
2775 }
2776 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2777         LDKCResult_SignDecodeErrorZ *val = (LDKCResult_SignDecodeErrorZ*)(arg & ~1);
2778         CHECK(val->result_ok);
2779         LDKSign* ret = MALLOC(sizeof(LDKSign), "LDKSign");
2780         *ret = Sign_clone(&(*val->contents.result));
2781         return (uint64_t)ret;
2782 }
2783 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2784         LDKCResult_SignDecodeErrorZ *val = (LDKCResult_SignDecodeErrorZ*)(arg & ~1);
2785         CHECK(!val->result_ok);
2786         LDKDecodeError err_var = (*val->contents.err);
2787         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2788         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2789         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
2790         return err_ref;
2791 }
2792 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RecoverableSignatureNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2793         return ((LDKCResult_RecoverableSignatureNoneZ*)arg)->result_ok;
2794 }
2795 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RecoverableSignatureNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2796         LDKCResult_RecoverableSignatureNoneZ *val = (LDKCResult_RecoverableSignatureNoneZ*)(arg & ~1);
2797         CHECK(val->result_ok);
2798         int8_tArray es_arr = (*env)->NewByteArray(env, 68);
2799         (*env)->SetByteArrayRegion(env, es_arr, 0, 68, (*val->contents.result).serialized_form);
2800         return es_arr;
2801 }
2802 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RecoverableSignatureNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2803         LDKCResult_RecoverableSignatureNoneZ *val = (LDKCResult_RecoverableSignatureNoneZ*)(arg & ~1);
2804         CHECK(!val->result_ok);
2805         return *val->contents.err;
2806 }
2807 static inline LDKCVec_CVec_u8ZZ CVec_CVec_u8ZZ_clone(const LDKCVec_CVec_u8ZZ *orig) {
2808         LDKCVec_CVec_u8ZZ ret = { .data = MALLOC(sizeof(LDKCVec_u8Z) * orig->datalen, "LDKCVec_CVec_u8ZZ clone bytes"), .datalen = orig->datalen };
2809         for (size_t i = 0; i < ret.datalen; i++) {
2810                 ret.data[i] = CVec_u8Z_clone(&orig->data[i]);
2811         }
2812         return ret;
2813 }
2814 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1CVec_1u8ZZNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2815         return ((LDKCResult_CVec_CVec_u8ZZNoneZ*)arg)->result_ok;
2816 }
2817 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1CVec_1u8ZZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2818         LDKCResult_CVec_CVec_u8ZZNoneZ *val = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(arg & ~1);
2819         CHECK(val->result_ok);
2820         LDKCVec_CVec_u8ZZ res_var = (*val->contents.result);
2821         jobjectArray res_arr = (*env)->NewObjectArray(env, res_var.datalen, arr_of_B_clz, NULL);
2822         ;
2823         for (size_t i = 0; i < res_var.datalen; i++) {
2824                 LDKCVec_u8Z res_conv_8_var = res_var.data[i];
2825                 int8_tArray res_conv_8_arr = (*env)->NewByteArray(env, res_conv_8_var.datalen);
2826                 (*env)->SetByteArrayRegion(env, res_conv_8_arr, 0, res_conv_8_var.datalen, res_conv_8_var.data);
2827                 (*env)->SetObjectArrayElement(env, res_arr, i, res_conv_8_arr);
2828         }
2829         return res_arr;
2830 }
2831 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1CVec_1u8ZZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2832         LDKCResult_CVec_CVec_u8ZZNoneZ *val = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(arg & ~1);
2833         CHECK(!val->result_ok);
2834         return *val->contents.err;
2835 }
2836 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InMemorySignerDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2837         return ((LDKCResult_InMemorySignerDecodeErrorZ*)arg)->result_ok;
2838 }
2839 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InMemorySignerDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2840         LDKCResult_InMemorySignerDecodeErrorZ *val = (LDKCResult_InMemorySignerDecodeErrorZ*)(arg & ~1);
2841         CHECK(val->result_ok);
2842         LDKInMemorySigner res_var = (*val->contents.result);
2843         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2844         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2845         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
2846         return res_ref;
2847 }
2848 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InMemorySignerDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2849         LDKCResult_InMemorySignerDecodeErrorZ *val = (LDKCResult_InMemorySignerDecodeErrorZ*)(arg & ~1);
2850         CHECK(!val->result_ok);
2851         LDKDecodeError err_var = (*val->contents.err);
2852         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2853         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2854         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
2855         return err_ref;
2856 }
2857 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1TxOutZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
2858         LDKCVec_TxOutZ *ret = MALLOC(sizeof(LDKCVec_TxOutZ), "LDKCVec_TxOutZ");
2859         ret->datalen = (*env)->GetArrayLength(env, elems);
2860         if (ret->datalen == 0) {
2861                 ret->data = NULL;
2862         } else {
2863                 ret->data = MALLOC(sizeof(LDKTxOut) * ret->datalen, "LDKCVec_TxOutZ Data");
2864                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
2865                 for (size_t i = 0; i < ret->datalen; i++) {
2866                         int64_t arr_elem = java_elems[i];
2867                         LDKTxOut arr_elem_conv = *(LDKTxOut*)(((uint64_t)arr_elem) & ~1);
2868                         arr_elem_conv = TxOut_clone((LDKTxOut*)(((uint64_t)arr_elem) & ~1));
2869                         ret->data[i] = arr_elem_conv;
2870                 }
2871                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
2872         }
2873         return (uint64_t)ret;
2874 }
2875 static inline LDKCVec_TxOutZ CVec_TxOutZ_clone(const LDKCVec_TxOutZ *orig) {
2876         LDKCVec_TxOutZ ret = { .data = MALLOC(sizeof(LDKTxOut) * orig->datalen, "LDKCVec_TxOutZ clone bytes"), .datalen = orig->datalen };
2877         for (size_t i = 0; i < ret.datalen; i++) {
2878                 ret.data[i] = TxOut_clone(&orig->data[i]);
2879         }
2880         return ret;
2881 }
2882 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TransactionNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2883         return ((LDKCResult_TransactionNoneZ*)arg)->result_ok;
2884 }
2885 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TransactionNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2886         LDKCResult_TransactionNoneZ *val = (LDKCResult_TransactionNoneZ*)(arg & ~1);
2887         CHECK(val->result_ok);
2888         LDKTransaction res_var = (*val->contents.result);
2889         int8_tArray res_arr = (*env)->NewByteArray(env, res_var.datalen);
2890         (*env)->SetByteArrayRegion(env, res_arr, 0, res_var.datalen, res_var.data);
2891         return res_arr;
2892 }
2893 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TransactionNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2894         LDKCResult_TransactionNoneZ *val = (LDKCResult_TransactionNoneZ*)(arg & ~1);
2895         CHECK(!val->result_ok);
2896         return *val->contents.err;
2897 }
2898 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1BlockHashChannelMonitorZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
2899         LDKC2Tuple_BlockHashChannelMonitorZ* ret = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
2900         LDKThirtyTwoBytes a_ref;
2901         CHECK((*env)->GetArrayLength(env, a) == 32);
2902         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
2903         ret->a = a_ref;
2904         LDKChannelMonitor b_conv;
2905         b_conv.inner = (void*)(b & (~1));
2906         b_conv.is_owned = (b & 1) || (b == 0);
2907         b_conv = ChannelMonitor_clone(&b_conv);
2908         ret->b = b_conv;
2909         return (uint64_t)ret;
2910 }
2911 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1BlockHashChannelMonitorZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
2912         LDKC2Tuple_BlockHashChannelMonitorZ *tuple = (LDKC2Tuple_BlockHashChannelMonitorZ*)(ptr & ~1);
2913         int8_tArray a_arr = (*env)->NewByteArray(env, 32);
2914         (*env)->SetByteArrayRegion(env, a_arr, 0, 32, tuple->a.data);
2915         return a_arr;
2916 }
2917 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1BlockHashChannelMonitorZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
2918         LDKC2Tuple_BlockHashChannelMonitorZ *tuple = (LDKC2Tuple_BlockHashChannelMonitorZ*)(ptr & ~1);
2919         LDKChannelMonitor b_var = tuple->b;
2920         CHECK((((uint64_t)b_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2921         CHECK((((uint64_t)&b_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2922         uint64_t b_ref = (uint64_t)b_var.inner & ~1;
2923         return b_ref;
2924 }
2925 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1BlockHashChannelMonitorZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
2926         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_BlockHashChannelMonitorZZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ");
2927         ret->datalen = (*env)->GetArrayLength(env, elems);
2928         if (ret->datalen == 0) {
2929                 ret->data = NULL;
2930         } else {
2931                 ret->data = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ) * ret->datalen, "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Data");
2932                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
2933                 for (size_t i = 0; i < ret->datalen; i++) {
2934                         int64_t arr_elem = java_elems[i];
2935                         LDKC2Tuple_BlockHashChannelMonitorZ arr_elem_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)arr_elem) & ~1);
2936                         // Warning: we may need a move here but no clone is available for LDKC2Tuple_BlockHashChannelMonitorZ
2937                         ret->data[i] = arr_elem_conv;
2938                 }
2939                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
2940         }
2941         return (uint64_t)ret;
2942 }
2943 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2944         return ((LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)arg)->result_ok;
2945 }
2946 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2947         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *val = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(arg & ~1);
2948         CHECK(val->result_ok);
2949         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ res_var = (*val->contents.result);
2950         int64_tArray res_arr = (*env)->NewLongArray(env, res_var.datalen);
2951         int64_t *res_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, res_arr, NULL);
2952         for (size_t i = 0; i < res_var.datalen; i++) {
2953                 uint64_t res_conv_34_ref = (uint64_t)(&res_var.data[i]) | 1;
2954                 res_arr_ptr[i] = res_conv_34_ref;
2955         }
2956         (*env)->ReleasePrimitiveArrayCritical(env, res_arr, res_arr_ptr, 0);
2957         return res_arr;
2958 }
2959 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2960         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *val = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(arg & ~1);
2961         CHECK(!val->result_ok);
2962         jclass err_conv = LDKIOError_to_java(env, (*val->contents.err));
2963         return err_conv;
2964 }
2965 static jclass LDKCOption_u16Z_Some_class = NULL;
2966 static jmethodID LDKCOption_u16Z_Some_meth = NULL;
2967 static jclass LDKCOption_u16Z_None_class = NULL;
2968 static jmethodID LDKCOption_u16Z_None_meth = NULL;
2969 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u16Z_init (JNIEnv *env, jclass clz) {
2970         LDKCOption_u16Z_Some_class =
2971                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_u16Z$Some;"));
2972         CHECK(LDKCOption_u16Z_Some_class != NULL);
2973         LDKCOption_u16Z_Some_meth = (*env)->GetMethodID(env, LDKCOption_u16Z_Some_class, "<init>", "(S)V");
2974         CHECK(LDKCOption_u16Z_Some_meth != NULL);
2975         LDKCOption_u16Z_None_class =
2976                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_u16Z$None;"));
2977         CHECK(LDKCOption_u16Z_None_class != NULL);
2978         LDKCOption_u16Z_None_meth = (*env)->GetMethodID(env, LDKCOption_u16Z_None_class, "<init>", "()V");
2979         CHECK(LDKCOption_u16Z_None_meth != NULL);
2980 }
2981 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u16Z_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2982         LDKCOption_u16Z *obj = (LDKCOption_u16Z*)(ptr & ~1);
2983         switch(obj->tag) {
2984                 case LDKCOption_u16Z_Some: {
2985                         return (*env)->NewObject(env, LDKCOption_u16Z_Some_class, LDKCOption_u16Z_Some_meth, obj->some);
2986                 }
2987                 case LDKCOption_u16Z_None: {
2988                         return (*env)->NewObject(env, LDKCOption_u16Z_None_class, LDKCOption_u16Z_None_meth);
2989                 }
2990                 default: abort();
2991         }
2992 }
2993 static jclass LDKAPIError_APIMisuseError_class = NULL;
2994 static jmethodID LDKAPIError_APIMisuseError_meth = NULL;
2995 static jclass LDKAPIError_FeeRateTooHigh_class = NULL;
2996 static jmethodID LDKAPIError_FeeRateTooHigh_meth = NULL;
2997 static jclass LDKAPIError_RouteError_class = NULL;
2998 static jmethodID LDKAPIError_RouteError_meth = NULL;
2999 static jclass LDKAPIError_ChannelUnavailable_class = NULL;
3000 static jmethodID LDKAPIError_ChannelUnavailable_meth = NULL;
3001 static jclass LDKAPIError_MonitorUpdateFailed_class = NULL;
3002 static jmethodID LDKAPIError_MonitorUpdateFailed_meth = NULL;
3003 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKAPIError_init (JNIEnv *env, jclass clz) {
3004         LDKAPIError_APIMisuseError_class =
3005                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$APIMisuseError;"));
3006         CHECK(LDKAPIError_APIMisuseError_class != NULL);
3007         LDKAPIError_APIMisuseError_meth = (*env)->GetMethodID(env, LDKAPIError_APIMisuseError_class, "<init>", "(Ljava/lang/String;)V");
3008         CHECK(LDKAPIError_APIMisuseError_meth != NULL);
3009         LDKAPIError_FeeRateTooHigh_class =
3010                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$FeeRateTooHigh;"));
3011         CHECK(LDKAPIError_FeeRateTooHigh_class != NULL);
3012         LDKAPIError_FeeRateTooHigh_meth = (*env)->GetMethodID(env, LDKAPIError_FeeRateTooHigh_class, "<init>", "(Ljava/lang/String;I)V");
3013         CHECK(LDKAPIError_FeeRateTooHigh_meth != NULL);
3014         LDKAPIError_RouteError_class =
3015                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$RouteError;"));
3016         CHECK(LDKAPIError_RouteError_class != NULL);
3017         LDKAPIError_RouteError_meth = (*env)->GetMethodID(env, LDKAPIError_RouteError_class, "<init>", "(Ljava/lang/String;)V");
3018         CHECK(LDKAPIError_RouteError_meth != NULL);
3019         LDKAPIError_ChannelUnavailable_class =
3020                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$ChannelUnavailable;"));
3021         CHECK(LDKAPIError_ChannelUnavailable_class != NULL);
3022         LDKAPIError_ChannelUnavailable_meth = (*env)->GetMethodID(env, LDKAPIError_ChannelUnavailable_class, "<init>", "(Ljava/lang/String;)V");
3023         CHECK(LDKAPIError_ChannelUnavailable_meth != NULL);
3024         LDKAPIError_MonitorUpdateFailed_class =
3025                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$MonitorUpdateFailed;"));
3026         CHECK(LDKAPIError_MonitorUpdateFailed_class != NULL);
3027         LDKAPIError_MonitorUpdateFailed_meth = (*env)->GetMethodID(env, LDKAPIError_MonitorUpdateFailed_class, "<init>", "()V");
3028         CHECK(LDKAPIError_MonitorUpdateFailed_meth != NULL);
3029 }
3030 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKAPIError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3031         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
3032         switch(obj->tag) {
3033                 case LDKAPIError_APIMisuseError: {
3034                         LDKStr err_str = obj->api_misuse_error.err;
3035                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
3036                         return (*env)->NewObject(env, LDKAPIError_APIMisuseError_class, LDKAPIError_APIMisuseError_meth, err_conv);
3037                 }
3038                 case LDKAPIError_FeeRateTooHigh: {
3039                         LDKStr err_str = obj->fee_rate_too_high.err;
3040                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
3041                         return (*env)->NewObject(env, LDKAPIError_FeeRateTooHigh_class, LDKAPIError_FeeRateTooHigh_meth, err_conv, obj->fee_rate_too_high.feerate);
3042                 }
3043                 case LDKAPIError_RouteError: {
3044                         LDKStr err_str = obj->route_error.err;
3045                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
3046                         return (*env)->NewObject(env, LDKAPIError_RouteError_class, LDKAPIError_RouteError_meth, err_conv);
3047                 }
3048                 case LDKAPIError_ChannelUnavailable: {
3049                         LDKStr err_str = obj->channel_unavailable.err;
3050                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
3051                         return (*env)->NewObject(env, LDKAPIError_ChannelUnavailable_class, LDKAPIError_ChannelUnavailable_meth, err_conv);
3052                 }
3053                 case LDKAPIError_MonitorUpdateFailed: {
3054                         return (*env)->NewObject(env, LDKAPIError_MonitorUpdateFailed_class, LDKAPIError_MonitorUpdateFailed_meth);
3055                 }
3056                 default: abort();
3057         }
3058 }
3059 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneAPIErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3060         return ((LDKCResult_NoneAPIErrorZ*)arg)->result_ok;
3061 }
3062 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3063         LDKCResult_NoneAPIErrorZ *val = (LDKCResult_NoneAPIErrorZ*)(arg & ~1);
3064         CHECK(val->result_ok);
3065         return *val->contents.result;
3066 }
3067 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3068         LDKCResult_NoneAPIErrorZ *val = (LDKCResult_NoneAPIErrorZ*)(arg & ~1);
3069         CHECK(!val->result_ok);
3070         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
3071         return err_ref;
3072 }
3073 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1CResult_1NoneAPIErrorZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
3074         LDKCVec_CResult_NoneAPIErrorZZ *ret = MALLOC(sizeof(LDKCVec_CResult_NoneAPIErrorZZ), "LDKCVec_CResult_NoneAPIErrorZZ");
3075         ret->datalen = (*env)->GetArrayLength(env, elems);
3076         if (ret->datalen == 0) {
3077                 ret->data = NULL;
3078         } else {
3079                 ret->data = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ) * ret->datalen, "LDKCVec_CResult_NoneAPIErrorZZ Data");
3080                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3081                 for (size_t i = 0; i < ret->datalen; i++) {
3082                         int64_t arr_elem = java_elems[i];
3083                         LDKCResult_NoneAPIErrorZ arr_elem_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)arr_elem) & ~1);
3084                         arr_elem_conv = CResult_NoneAPIErrorZ_clone((LDKCResult_NoneAPIErrorZ*)(((uint64_t)arr_elem) & ~1));
3085                         ret->data[i] = arr_elem_conv;
3086                 }
3087                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3088         }
3089         return (uint64_t)ret;
3090 }
3091 static inline LDKCVec_CResult_NoneAPIErrorZZ CVec_CResult_NoneAPIErrorZZ_clone(const LDKCVec_CResult_NoneAPIErrorZZ *orig) {
3092         LDKCVec_CResult_NoneAPIErrorZZ ret = { .data = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ) * orig->datalen, "LDKCVec_CResult_NoneAPIErrorZZ clone bytes"), .datalen = orig->datalen };
3093         for (size_t i = 0; i < ret.datalen; i++) {
3094                 ret.data[i] = CResult_NoneAPIErrorZ_clone(&orig->data[i]);
3095         }
3096         return ret;
3097 }
3098 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1APIErrorZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
3099         LDKCVec_APIErrorZ *ret = MALLOC(sizeof(LDKCVec_APIErrorZ), "LDKCVec_APIErrorZ");
3100         ret->datalen = (*env)->GetArrayLength(env, elems);
3101         if (ret->datalen == 0) {
3102                 ret->data = NULL;
3103         } else {
3104                 ret->data = MALLOC(sizeof(LDKAPIError) * ret->datalen, "LDKCVec_APIErrorZ Data");
3105                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3106                 for (size_t i = 0; i < ret->datalen; i++) {
3107                         int64_t arr_elem = java_elems[i];
3108                         LDKAPIError arr_elem_conv = *(LDKAPIError*)(((uint64_t)arr_elem) & ~1);
3109                         arr_elem_conv = APIError_clone((LDKAPIError*)(((uint64_t)arr_elem) & ~1));
3110                         ret->data[i] = arr_elem_conv;
3111                 }
3112                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3113         }
3114         return (uint64_t)ret;
3115 }
3116 static inline LDKCVec_APIErrorZ CVec_APIErrorZ_clone(const LDKCVec_APIErrorZ *orig) {
3117         LDKCVec_APIErrorZ ret = { .data = MALLOC(sizeof(LDKAPIError) * orig->datalen, "LDKCVec_APIErrorZ clone bytes"), .datalen = orig->datalen };
3118         for (size_t i = 0; i < ret.datalen; i++) {
3119                 ret.data[i] = APIError_clone(&orig->data[i]);
3120         }
3121         return ret;
3122 }
3123 static jclass LDKPaymentSendFailure_ParameterError_class = NULL;
3124 static jmethodID LDKPaymentSendFailure_ParameterError_meth = NULL;
3125 static jclass LDKPaymentSendFailure_PathParameterError_class = NULL;
3126 static jmethodID LDKPaymentSendFailure_PathParameterError_meth = NULL;
3127 static jclass LDKPaymentSendFailure_AllFailedRetrySafe_class = NULL;
3128 static jmethodID LDKPaymentSendFailure_AllFailedRetrySafe_meth = NULL;
3129 static jclass LDKPaymentSendFailure_PartialFailure_class = NULL;
3130 static jmethodID LDKPaymentSendFailure_PartialFailure_meth = NULL;
3131 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKPaymentSendFailure_init (JNIEnv *env, jclass clz) {
3132         LDKPaymentSendFailure_ParameterError_class =
3133                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentSendFailure$ParameterError;"));
3134         CHECK(LDKPaymentSendFailure_ParameterError_class != NULL);
3135         LDKPaymentSendFailure_ParameterError_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_ParameterError_class, "<init>", "(J)V");
3136         CHECK(LDKPaymentSendFailure_ParameterError_meth != NULL);
3137         LDKPaymentSendFailure_PathParameterError_class =
3138                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentSendFailure$PathParameterError;"));
3139         CHECK(LDKPaymentSendFailure_PathParameterError_class != NULL);
3140         LDKPaymentSendFailure_PathParameterError_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_PathParameterError_class, "<init>", "([J)V");
3141         CHECK(LDKPaymentSendFailure_PathParameterError_meth != NULL);
3142         LDKPaymentSendFailure_AllFailedRetrySafe_class =
3143                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentSendFailure$AllFailedRetrySafe;"));
3144         CHECK(LDKPaymentSendFailure_AllFailedRetrySafe_class != NULL);
3145         LDKPaymentSendFailure_AllFailedRetrySafe_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_AllFailedRetrySafe_class, "<init>", "([J)V");
3146         CHECK(LDKPaymentSendFailure_AllFailedRetrySafe_meth != NULL);
3147         LDKPaymentSendFailure_PartialFailure_class =
3148                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentSendFailure$PartialFailure;"));
3149         CHECK(LDKPaymentSendFailure_PartialFailure_class != NULL);
3150         LDKPaymentSendFailure_PartialFailure_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_PartialFailure_class, "<init>", "([J)V");
3151         CHECK(LDKPaymentSendFailure_PartialFailure_meth != NULL);
3152 }
3153 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPaymentSendFailure_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3154         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
3155         switch(obj->tag) {
3156                 case LDKPaymentSendFailure_ParameterError: {
3157                         uint64_t parameter_error_ref = ((uint64_t)&obj->parameter_error) | 1;
3158                         return (*env)->NewObject(env, LDKPaymentSendFailure_ParameterError_class, LDKPaymentSendFailure_ParameterError_meth, parameter_error_ref);
3159                 }
3160                 case LDKPaymentSendFailure_PathParameterError: {
3161                         LDKCVec_CResult_NoneAPIErrorZZ path_parameter_error_var = obj->path_parameter_error;
3162                         int64_tArray path_parameter_error_arr = (*env)->NewLongArray(env, path_parameter_error_var.datalen);
3163                         int64_t *path_parameter_error_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_parameter_error_arr, NULL);
3164                         for (size_t w = 0; w < path_parameter_error_var.datalen; w++) {
3165                                 LDKCResult_NoneAPIErrorZ* path_parameter_error_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
3166                                 *path_parameter_error_conv_22_conv = path_parameter_error_var.data[w];
3167                                 *path_parameter_error_conv_22_conv = CResult_NoneAPIErrorZ_clone(path_parameter_error_conv_22_conv);
3168                                 path_parameter_error_arr_ptr[w] = (uint64_t)path_parameter_error_conv_22_conv;
3169                         }
3170                         (*env)->ReleasePrimitiveArrayCritical(env, path_parameter_error_arr, path_parameter_error_arr_ptr, 0);
3171                         return (*env)->NewObject(env, LDKPaymentSendFailure_PathParameterError_class, LDKPaymentSendFailure_PathParameterError_meth, path_parameter_error_arr);
3172                 }
3173                 case LDKPaymentSendFailure_AllFailedRetrySafe: {
3174                         LDKCVec_APIErrorZ all_failed_retry_safe_var = obj->all_failed_retry_safe;
3175                         int64_tArray all_failed_retry_safe_arr = (*env)->NewLongArray(env, all_failed_retry_safe_var.datalen);
3176                         int64_t *all_failed_retry_safe_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, all_failed_retry_safe_arr, NULL);
3177                         for (size_t k = 0; k < all_failed_retry_safe_var.datalen; k++) {
3178                                 uint64_t all_failed_retry_safe_conv_10_ref = ((uint64_t)&all_failed_retry_safe_var.data[k]) | 1;
3179                                 all_failed_retry_safe_arr_ptr[k] = all_failed_retry_safe_conv_10_ref;
3180                         }
3181                         (*env)->ReleasePrimitiveArrayCritical(env, all_failed_retry_safe_arr, all_failed_retry_safe_arr_ptr, 0);
3182                         return (*env)->NewObject(env, LDKPaymentSendFailure_AllFailedRetrySafe_class, LDKPaymentSendFailure_AllFailedRetrySafe_meth, all_failed_retry_safe_arr);
3183                 }
3184                 case LDKPaymentSendFailure_PartialFailure: {
3185                         LDKCVec_CResult_NoneAPIErrorZZ partial_failure_var = obj->partial_failure;
3186                         int64_tArray partial_failure_arr = (*env)->NewLongArray(env, partial_failure_var.datalen);
3187                         int64_t *partial_failure_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, partial_failure_arr, NULL);
3188                         for (size_t w = 0; w < partial_failure_var.datalen; w++) {
3189                                 LDKCResult_NoneAPIErrorZ* partial_failure_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
3190                                 *partial_failure_conv_22_conv = partial_failure_var.data[w];
3191                                 *partial_failure_conv_22_conv = CResult_NoneAPIErrorZ_clone(partial_failure_conv_22_conv);
3192                                 partial_failure_arr_ptr[w] = (uint64_t)partial_failure_conv_22_conv;
3193                         }
3194                         (*env)->ReleasePrimitiveArrayCritical(env, partial_failure_arr, partial_failure_arr_ptr, 0);
3195                         return (*env)->NewObject(env, LDKPaymentSendFailure_PartialFailure_class, LDKPaymentSendFailure_PartialFailure_meth, partial_failure_arr);
3196                 }
3197                 default: abort();
3198         }
3199 }
3200 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePaymentSendFailureZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3201         return ((LDKCResult_NonePaymentSendFailureZ*)arg)->result_ok;
3202 }
3203 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePaymentSendFailureZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3204         LDKCResult_NonePaymentSendFailureZ *val = (LDKCResult_NonePaymentSendFailureZ*)(arg & ~1);
3205         CHECK(val->result_ok);
3206         return *val->contents.result;
3207 }
3208 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePaymentSendFailureZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3209         LDKCResult_NonePaymentSendFailureZ *val = (LDKCResult_NonePaymentSendFailureZ*)(arg & ~1);
3210         CHECK(!val->result_ok);
3211         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
3212         return err_ref;
3213 }
3214 static jclass LDKNetAddress_IPv4_class = NULL;
3215 static jmethodID LDKNetAddress_IPv4_meth = NULL;
3216 static jclass LDKNetAddress_IPv6_class = NULL;
3217 static jmethodID LDKNetAddress_IPv6_meth = NULL;
3218 static jclass LDKNetAddress_OnionV2_class = NULL;
3219 static jmethodID LDKNetAddress_OnionV2_meth = NULL;
3220 static jclass LDKNetAddress_OnionV3_class = NULL;
3221 static jmethodID LDKNetAddress_OnionV3_meth = NULL;
3222 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKNetAddress_init (JNIEnv *env, jclass clz) {
3223         LDKNetAddress_IPv4_class =
3224                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$IPv4;"));
3225         CHECK(LDKNetAddress_IPv4_class != NULL);
3226         LDKNetAddress_IPv4_meth = (*env)->GetMethodID(env, LDKNetAddress_IPv4_class, "<init>", "([BS)V");
3227         CHECK(LDKNetAddress_IPv4_meth != NULL);
3228         LDKNetAddress_IPv6_class =
3229                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$IPv6;"));
3230         CHECK(LDKNetAddress_IPv6_class != NULL);
3231         LDKNetAddress_IPv6_meth = (*env)->GetMethodID(env, LDKNetAddress_IPv6_class, "<init>", "([BS)V");
3232         CHECK(LDKNetAddress_IPv6_meth != NULL);
3233         LDKNetAddress_OnionV2_class =
3234                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$OnionV2;"));
3235         CHECK(LDKNetAddress_OnionV2_class != NULL);
3236         LDKNetAddress_OnionV2_meth = (*env)->GetMethodID(env, LDKNetAddress_OnionV2_class, "<init>", "([BS)V");
3237         CHECK(LDKNetAddress_OnionV2_meth != NULL);
3238         LDKNetAddress_OnionV3_class =
3239                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$OnionV3;"));
3240         CHECK(LDKNetAddress_OnionV3_class != NULL);
3241         LDKNetAddress_OnionV3_meth = (*env)->GetMethodID(env, LDKNetAddress_OnionV3_class, "<init>", "([BSBS)V");
3242         CHECK(LDKNetAddress_OnionV3_meth != NULL);
3243 }
3244 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKNetAddress_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3245         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3246         switch(obj->tag) {
3247                 case LDKNetAddress_IPv4: {
3248                         int8_tArray addr_arr = (*env)->NewByteArray(env, 4);
3249                         (*env)->SetByteArrayRegion(env, addr_arr, 0, 4, obj->i_pv4.addr.data);
3250                         return (*env)->NewObject(env, LDKNetAddress_IPv4_class, LDKNetAddress_IPv4_meth, addr_arr, obj->i_pv4.port);
3251                 }
3252                 case LDKNetAddress_IPv6: {
3253                         int8_tArray addr_arr = (*env)->NewByteArray(env, 16);
3254                         (*env)->SetByteArrayRegion(env, addr_arr, 0, 16, obj->i_pv6.addr.data);
3255                         return (*env)->NewObject(env, LDKNetAddress_IPv6_class, LDKNetAddress_IPv6_meth, addr_arr, obj->i_pv6.port);
3256                 }
3257                 case LDKNetAddress_OnionV2: {
3258                         int8_tArray addr_arr = (*env)->NewByteArray(env, 10);
3259                         (*env)->SetByteArrayRegion(env, addr_arr, 0, 10, obj->onion_v2.addr.data);
3260                         return (*env)->NewObject(env, LDKNetAddress_OnionV2_class, LDKNetAddress_OnionV2_meth, addr_arr, obj->onion_v2.port);
3261                 }
3262                 case LDKNetAddress_OnionV3: {
3263                         int8_tArray ed25519_pubkey_arr = (*env)->NewByteArray(env, 32);
3264                         (*env)->SetByteArrayRegion(env, ed25519_pubkey_arr, 0, 32, obj->onion_v3.ed25519_pubkey.data);
3265                         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);
3266                 }
3267                 default: abort();
3268         }
3269 }
3270 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1NetAddressZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
3271         LDKCVec_NetAddressZ *ret = MALLOC(sizeof(LDKCVec_NetAddressZ), "LDKCVec_NetAddressZ");
3272         ret->datalen = (*env)->GetArrayLength(env, elems);
3273         if (ret->datalen == 0) {
3274                 ret->data = NULL;
3275         } else {
3276                 ret->data = MALLOC(sizeof(LDKNetAddress) * ret->datalen, "LDKCVec_NetAddressZ Data");
3277                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3278                 for (size_t i = 0; i < ret->datalen; i++) {
3279                         int64_t arr_elem = java_elems[i];
3280                         LDKNetAddress arr_elem_conv = *(LDKNetAddress*)(((uint64_t)arr_elem) & ~1);
3281                         arr_elem_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)arr_elem) & ~1));
3282                         ret->data[i] = arr_elem_conv;
3283                 }
3284                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3285         }
3286         return (uint64_t)ret;
3287 }
3288 static inline LDKCVec_NetAddressZ CVec_NetAddressZ_clone(const LDKCVec_NetAddressZ *orig) {
3289         LDKCVec_NetAddressZ ret = { .data = MALLOC(sizeof(LDKNetAddress) * orig->datalen, "LDKCVec_NetAddressZ clone bytes"), .datalen = orig->datalen };
3290         for (size_t i = 0; i < ret.datalen; i++) {
3291                 ret.data[i] = NetAddress_clone(&orig->data[i]);
3292         }
3293         return ret;
3294 }
3295 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1PaymentHashPaymentSecretZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int8_tArray b) {
3296         LDKC2Tuple_PaymentHashPaymentSecretZ* ret = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
3297         LDKThirtyTwoBytes a_ref;
3298         CHECK((*env)->GetArrayLength(env, a) == 32);
3299         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
3300         ret->a = a_ref;
3301         LDKThirtyTwoBytes b_ref;
3302         CHECK((*env)->GetArrayLength(env, b) == 32);
3303         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
3304         ret->b = b_ref;
3305         return (uint64_t)ret;
3306 }
3307 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1PaymentHashPaymentSecretZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
3308         LDKC2Tuple_PaymentHashPaymentSecretZ *tuple = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(ptr & ~1);
3309         int8_tArray a_arr = (*env)->NewByteArray(env, 32);
3310         (*env)->SetByteArrayRegion(env, a_arr, 0, 32, tuple->a.data);
3311         return a_arr;
3312 }
3313 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1PaymentHashPaymentSecretZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
3314         LDKC2Tuple_PaymentHashPaymentSecretZ *tuple = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(ptr & ~1);
3315         int8_tArray b_arr = (*env)->NewByteArray(env, 32);
3316         (*env)->SetByteArrayRegion(env, b_arr, 0, 32, tuple->b.data);
3317         return b_arr;
3318 }
3319 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentSecretAPIErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3320         return ((LDKCResult_PaymentSecretAPIErrorZ*)arg)->result_ok;
3321 }
3322 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentSecretAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3323         LDKCResult_PaymentSecretAPIErrorZ *val = (LDKCResult_PaymentSecretAPIErrorZ*)(arg & ~1);
3324         CHECK(val->result_ok);
3325         int8_tArray res_arr = (*env)->NewByteArray(env, 32);
3326         (*env)->SetByteArrayRegion(env, res_arr, 0, 32, (*val->contents.result).data);
3327         return res_arr;
3328 }
3329 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentSecretAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3330         LDKCResult_PaymentSecretAPIErrorZ *val = (LDKCResult_PaymentSecretAPIErrorZ*)(arg & ~1);
3331         CHECK(!val->result_ok);
3332         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
3333         return err_ref;
3334 }
3335 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1ChannelMonitorZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
3336         LDKCVec_ChannelMonitorZ *ret = MALLOC(sizeof(LDKCVec_ChannelMonitorZ), "LDKCVec_ChannelMonitorZ");
3337         ret->datalen = (*env)->GetArrayLength(env, elems);
3338         if (ret->datalen == 0) {
3339                 ret->data = NULL;
3340         } else {
3341                 ret->data = MALLOC(sizeof(LDKChannelMonitor) * ret->datalen, "LDKCVec_ChannelMonitorZ Data");
3342                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3343                 for (size_t i = 0; i < ret->datalen; i++) {
3344                         int64_t arr_elem = java_elems[i];
3345                         LDKChannelMonitor arr_elem_conv;
3346                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3347                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3348                         arr_elem_conv = ChannelMonitor_clone(&arr_elem_conv);
3349                         ret->data[i] = arr_elem_conv;
3350                 }
3351                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3352         }
3353         return (uint64_t)ret;
3354 }
3355 static inline LDKCVec_ChannelMonitorZ CVec_ChannelMonitorZ_clone(const LDKCVec_ChannelMonitorZ *orig) {
3356         LDKCVec_ChannelMonitorZ ret = { .data = MALLOC(sizeof(LDKChannelMonitor) * orig->datalen, "LDKCVec_ChannelMonitorZ clone bytes"), .datalen = orig->datalen };
3357         for (size_t i = 0; i < ret.datalen; i++) {
3358                 ret.data[i] = ChannelMonitor_clone(&orig->data[i]);
3359         }
3360         return ret;
3361 }
3362 typedef struct LDKWatch_JCalls {
3363         atomic_size_t refcnt;
3364         JavaVM *vm;
3365         jweak o;
3366         jmethodID watch_channel_meth;
3367         jmethodID update_channel_meth;
3368         jmethodID release_pending_monitor_events_meth;
3369 } LDKWatch_JCalls;
3370 static void LDKWatch_JCalls_free(void* this_arg) {
3371         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
3372         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3373                 JNIEnv *env;
3374                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3375                 if (get_jenv_res == JNI_EDETACHED) {
3376                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3377                 } else {
3378                         DO_ASSERT(get_jenv_res == JNI_OK);
3379                 }
3380                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
3381                 if (get_jenv_res == JNI_EDETACHED) {
3382                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3383                 }
3384                 FREE(j_calls);
3385         }
3386 }
3387 LDKCResult_NoneChannelMonitorUpdateErrZ watch_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitor monitor) {
3388         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
3389         JNIEnv *env;
3390         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3391         if (get_jenv_res == JNI_EDETACHED) {
3392                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3393         } else {
3394                 DO_ASSERT(get_jenv_res == JNI_OK);
3395         }
3396         LDKOutPoint funding_txo_var = funding_txo;
3397         CHECK((((uint64_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3398         CHECK((((uint64_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3399         uint64_t funding_txo_ref = (uint64_t)funding_txo_var.inner;
3400         if (funding_txo_var.is_owned) {
3401                 funding_txo_ref |= 1;
3402         }
3403         LDKChannelMonitor monitor_var = monitor;
3404         CHECK((((uint64_t)monitor_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3405         CHECK((((uint64_t)&monitor_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3406         uint64_t monitor_ref = (uint64_t)monitor_var.inner;
3407         if (monitor_var.is_owned) {
3408                 monitor_ref |= 1;
3409         }
3410         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3411         CHECK(obj != NULL);
3412         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(*env)->CallLongMethod(env, obj, j_calls->watch_channel_meth, funding_txo_ref, monitor_ref);
3413         if ((*env)->ExceptionCheck(env)) {
3414                 (*env)->ExceptionDescribe(env);
3415                 (*env)->FatalError(env, "A call to watch_channel in LDKWatch from rust threw an exception.");
3416         }
3417         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
3418         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
3419         if (get_jenv_res == JNI_EDETACHED) {
3420                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3421         }
3422         return ret_conv;
3423 }
3424 LDKCResult_NoneChannelMonitorUpdateErrZ update_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitorUpdate update) {
3425         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
3426         JNIEnv *env;
3427         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3428         if (get_jenv_res == JNI_EDETACHED) {
3429                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3430         } else {
3431                 DO_ASSERT(get_jenv_res == JNI_OK);
3432         }
3433         LDKOutPoint funding_txo_var = funding_txo;
3434         CHECK((((uint64_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3435         CHECK((((uint64_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3436         uint64_t funding_txo_ref = (uint64_t)funding_txo_var.inner;
3437         if (funding_txo_var.is_owned) {
3438                 funding_txo_ref |= 1;
3439         }
3440         LDKChannelMonitorUpdate update_var = update;
3441         CHECK((((uint64_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3442         CHECK((((uint64_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3443         uint64_t update_ref = (uint64_t)update_var.inner;
3444         if (update_var.is_owned) {
3445                 update_ref |= 1;
3446         }
3447         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3448         CHECK(obj != NULL);
3449         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(*env)->CallLongMethod(env, obj, j_calls->update_channel_meth, funding_txo_ref, update_ref);
3450         if ((*env)->ExceptionCheck(env)) {
3451                 (*env)->ExceptionDescribe(env);
3452                 (*env)->FatalError(env, "A call to update_channel in LDKWatch from rust threw an exception.");
3453         }
3454         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
3455         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
3456         if (get_jenv_res == JNI_EDETACHED) {
3457                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3458         }
3459         return ret_conv;
3460 }
3461 LDKCVec_MonitorEventZ release_pending_monitor_events_LDKWatch_jcall(const void* this_arg) {
3462         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
3463         JNIEnv *env;
3464         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3465         if (get_jenv_res == JNI_EDETACHED) {
3466                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3467         } else {
3468                 DO_ASSERT(get_jenv_res == JNI_OK);
3469         }
3470         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3471         CHECK(obj != NULL);
3472         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->release_pending_monitor_events_meth);
3473         if ((*env)->ExceptionCheck(env)) {
3474                 (*env)->ExceptionDescribe(env);
3475                 (*env)->FatalError(env, "A call to release_pending_monitor_events in LDKWatch from rust threw an exception.");
3476         }
3477         LDKCVec_MonitorEventZ ret_constr;
3478         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
3479         if (ret_constr.datalen > 0)
3480                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
3481         else
3482                 ret_constr.data = NULL;
3483         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
3484         for (size_t o = 0; o < ret_constr.datalen; o++) {
3485                 int64_t ret_conv_14 = ret_vals[o];
3486                 LDKMonitorEvent ret_conv_14_conv = *(LDKMonitorEvent*)(((uint64_t)ret_conv_14) & ~1);
3487                 ret_conv_14_conv = MonitorEvent_clone((LDKMonitorEvent*)(((uint64_t)ret_conv_14) & ~1));
3488                 ret_constr.data[o] = ret_conv_14_conv;
3489         }
3490         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
3491         if (get_jenv_res == JNI_EDETACHED) {
3492                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3493         }
3494         return ret_constr;
3495 }
3496 static void* LDKWatch_JCalls_clone(const void* this_arg) {
3497         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
3498         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3499         return (void*) this_arg;
3500 }
3501 static inline LDKWatch LDKWatch_init (JNIEnv *env, jclass clz, jobject o) {
3502         jclass c = (*env)->GetObjectClass(env, o);
3503         CHECK(c != NULL);
3504         LDKWatch_JCalls *calls = MALLOC(sizeof(LDKWatch_JCalls), "LDKWatch_JCalls");
3505         atomic_init(&calls->refcnt, 1);
3506         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
3507         calls->o = (*env)->NewWeakGlobalRef(env, o);
3508         calls->watch_channel_meth = (*env)->GetMethodID(env, c, "watch_channel", "(JJ)J");
3509         CHECK(calls->watch_channel_meth != NULL);
3510         calls->update_channel_meth = (*env)->GetMethodID(env, c, "update_channel", "(JJ)J");
3511         CHECK(calls->update_channel_meth != NULL);
3512         calls->release_pending_monitor_events_meth = (*env)->GetMethodID(env, c, "release_pending_monitor_events", "()[J");
3513         CHECK(calls->release_pending_monitor_events_meth != NULL);
3514
3515         LDKWatch ret = {
3516                 .this_arg = (void*) calls,
3517                 .watch_channel = watch_channel_LDKWatch_jcall,
3518                 .update_channel = update_channel_LDKWatch_jcall,
3519                 .release_pending_monitor_events = release_pending_monitor_events_LDKWatch_jcall,
3520                 .free = LDKWatch_JCalls_free,
3521         };
3522         return ret;
3523 }
3524 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKWatch_1new(JNIEnv *env, jclass clz, jobject o) {
3525         LDKWatch *res_ptr = MALLOC(sizeof(LDKWatch), "LDKWatch");
3526         *res_ptr = LDKWatch_init(env, clz, o);
3527         return (uint64_t)res_ptr;
3528 }
3529 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) {
3530         LDKWatch* this_arg_conv = (LDKWatch*)(((uint64_t)this_arg) & ~1);
3531         LDKOutPoint funding_txo_conv;
3532         funding_txo_conv.inner = (void*)(funding_txo & (~1));
3533         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
3534         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
3535         LDKChannelMonitor monitor_conv;
3536         monitor_conv.inner = (void*)(monitor & (~1));
3537         monitor_conv.is_owned = (monitor & 1) || (monitor == 0);
3538         monitor_conv = ChannelMonitor_clone(&monitor_conv);
3539         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
3540         *ret_conv = (this_arg_conv->watch_channel)(this_arg_conv->this_arg, funding_txo_conv, monitor_conv);
3541         return (uint64_t)ret_conv;
3542 }
3543
3544 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) {
3545         LDKWatch* this_arg_conv = (LDKWatch*)(((uint64_t)this_arg) & ~1);
3546         LDKOutPoint funding_txo_conv;
3547         funding_txo_conv.inner = (void*)(funding_txo & (~1));
3548         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
3549         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
3550         LDKChannelMonitorUpdate update_conv;
3551         update_conv.inner = (void*)(update & (~1));
3552         update_conv.is_owned = (update & 1) || (update == 0);
3553         update_conv = ChannelMonitorUpdate_clone(&update_conv);
3554         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
3555         *ret_conv = (this_arg_conv->update_channel)(this_arg_conv->this_arg, funding_txo_conv, update_conv);
3556         return (uint64_t)ret_conv;
3557 }
3558
3559 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Watch_1release_1pending_1monitor_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
3560         LDKWatch* this_arg_conv = (LDKWatch*)(((uint64_t)this_arg) & ~1);
3561         LDKCVec_MonitorEventZ ret_var = (this_arg_conv->release_pending_monitor_events)(this_arg_conv->this_arg);
3562         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
3563         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
3564         for (size_t o = 0; o < ret_var.datalen; o++) {
3565                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
3566                 *ret_conv_14_copy = MonitorEvent_clone(&ret_var.data[o]);
3567                 uint64_t ret_conv_14_ref = (uint64_t)ret_conv_14_copy;
3568                 ret_arr_ptr[o] = ret_conv_14_ref;
3569         }
3570         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
3571         FREE(ret_var.data);
3572         return ret_arr;
3573 }
3574
3575 typedef struct LDKBroadcasterInterface_JCalls {
3576         atomic_size_t refcnt;
3577         JavaVM *vm;
3578         jweak o;
3579         jmethodID broadcast_transaction_meth;
3580 } LDKBroadcasterInterface_JCalls;
3581 static void LDKBroadcasterInterface_JCalls_free(void* this_arg) {
3582         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
3583         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3584                 JNIEnv *env;
3585                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3586                 if (get_jenv_res == JNI_EDETACHED) {
3587                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3588                 } else {
3589                         DO_ASSERT(get_jenv_res == JNI_OK);
3590                 }
3591                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
3592                 if (get_jenv_res == JNI_EDETACHED) {
3593                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3594                 }
3595                 FREE(j_calls);
3596         }
3597 }
3598 void broadcast_transaction_LDKBroadcasterInterface_jcall(const void* this_arg, LDKTransaction tx) {
3599         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
3600         JNIEnv *env;
3601         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3602         if (get_jenv_res == JNI_EDETACHED) {
3603                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3604         } else {
3605                 DO_ASSERT(get_jenv_res == JNI_OK);
3606         }
3607         LDKTransaction tx_var = tx;
3608         int8_tArray tx_arr = (*env)->NewByteArray(env, tx_var.datalen);
3609         (*env)->SetByteArrayRegion(env, tx_arr, 0, tx_var.datalen, tx_var.data);
3610         Transaction_free(tx_var);
3611         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3612         CHECK(obj != NULL);
3613         (*env)->CallVoidMethod(env, obj, j_calls->broadcast_transaction_meth, tx_arr);
3614         if ((*env)->ExceptionCheck(env)) {
3615                 (*env)->ExceptionDescribe(env);
3616                 (*env)->FatalError(env, "A call to broadcast_transaction in LDKBroadcasterInterface from rust threw an exception.");
3617         }
3618         if (get_jenv_res == JNI_EDETACHED) {
3619                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3620         }
3621 }
3622 static void* LDKBroadcasterInterface_JCalls_clone(const void* this_arg) {
3623         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
3624         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3625         return (void*) this_arg;
3626 }
3627 static inline LDKBroadcasterInterface LDKBroadcasterInterface_init (JNIEnv *env, jclass clz, jobject o) {
3628         jclass c = (*env)->GetObjectClass(env, o);
3629         CHECK(c != NULL);
3630         LDKBroadcasterInterface_JCalls *calls = MALLOC(sizeof(LDKBroadcasterInterface_JCalls), "LDKBroadcasterInterface_JCalls");
3631         atomic_init(&calls->refcnt, 1);
3632         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
3633         calls->o = (*env)->NewWeakGlobalRef(env, o);
3634         calls->broadcast_transaction_meth = (*env)->GetMethodID(env, c, "broadcast_transaction", "([B)V");
3635         CHECK(calls->broadcast_transaction_meth != NULL);
3636
3637         LDKBroadcasterInterface ret = {
3638                 .this_arg = (void*) calls,
3639                 .broadcast_transaction = broadcast_transaction_LDKBroadcasterInterface_jcall,
3640                 .free = LDKBroadcasterInterface_JCalls_free,
3641         };
3642         return ret;
3643 }
3644 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKBroadcasterInterface_1new(JNIEnv *env, jclass clz, jobject o) {
3645         LDKBroadcasterInterface *res_ptr = MALLOC(sizeof(LDKBroadcasterInterface), "LDKBroadcasterInterface");
3646         *res_ptr = LDKBroadcasterInterface_init(env, clz, o);
3647         return (uint64_t)res_ptr;
3648 }
3649 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BroadcasterInterface_1broadcast_1transaction(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray tx) {
3650         LDKBroadcasterInterface* this_arg_conv = (LDKBroadcasterInterface*)(((uint64_t)this_arg) & ~1);
3651         LDKTransaction tx_ref;
3652         tx_ref.datalen = (*env)->GetArrayLength(env, tx);
3653         tx_ref.data = MALLOC(tx_ref.datalen, "LDKTransaction Bytes");
3654         (*env)->GetByteArrayRegion(env, tx, 0, tx_ref.datalen, tx_ref.data);
3655         tx_ref.data_is_owned = true;
3656         (this_arg_conv->broadcast_transaction)(this_arg_conv->this_arg, tx_ref);
3657 }
3658
3659 typedef struct LDKKeysInterface_JCalls {
3660         atomic_size_t refcnt;
3661         JavaVM *vm;
3662         jweak o;
3663         jmethodID get_node_secret_meth;
3664         jmethodID get_destination_script_meth;
3665         jmethodID get_shutdown_pubkey_meth;
3666         jmethodID get_channel_signer_meth;
3667         jmethodID get_secure_random_bytes_meth;
3668         jmethodID read_chan_signer_meth;
3669         jmethodID sign_invoice_meth;
3670 } LDKKeysInterface_JCalls;
3671 static void LDKKeysInterface_JCalls_free(void* this_arg) {
3672         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3673         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3674                 JNIEnv *env;
3675                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3676                 if (get_jenv_res == JNI_EDETACHED) {
3677                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3678                 } else {
3679                         DO_ASSERT(get_jenv_res == JNI_OK);
3680                 }
3681                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
3682                 if (get_jenv_res == JNI_EDETACHED) {
3683                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3684                 }
3685                 FREE(j_calls);
3686         }
3687 }
3688 LDKSecretKey get_node_secret_LDKKeysInterface_jcall(const void* this_arg) {
3689         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3690         JNIEnv *env;
3691         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3692         if (get_jenv_res == JNI_EDETACHED) {
3693                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3694         } else {
3695                 DO_ASSERT(get_jenv_res == JNI_OK);
3696         }
3697         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3698         CHECK(obj != NULL);
3699         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_node_secret_meth);
3700         if ((*env)->ExceptionCheck(env)) {
3701                 (*env)->ExceptionDescribe(env);
3702                 (*env)->FatalError(env, "A call to get_node_secret in LDKKeysInterface from rust threw an exception.");
3703         }
3704         LDKSecretKey ret_ref;
3705         CHECK((*env)->GetArrayLength(env, ret) == 32);
3706         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.bytes);
3707         if (get_jenv_res == JNI_EDETACHED) {
3708                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3709         }
3710         return ret_ref;
3711 }
3712 LDKCVec_u8Z get_destination_script_LDKKeysInterface_jcall(const void* this_arg) {
3713         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3714         JNIEnv *env;
3715         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3716         if (get_jenv_res == JNI_EDETACHED) {
3717                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3718         } else {
3719                 DO_ASSERT(get_jenv_res == JNI_OK);
3720         }
3721         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3722         CHECK(obj != NULL);
3723         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_destination_script_meth);
3724         if ((*env)->ExceptionCheck(env)) {
3725                 (*env)->ExceptionDescribe(env);
3726                 (*env)->FatalError(env, "A call to get_destination_script in LDKKeysInterface from rust threw an exception.");
3727         }
3728         LDKCVec_u8Z ret_ref;
3729         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
3730         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
3731         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
3732         if (get_jenv_res == JNI_EDETACHED) {
3733                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3734         }
3735         return ret_ref;
3736 }
3737 LDKPublicKey get_shutdown_pubkey_LDKKeysInterface_jcall(const void* this_arg) {
3738         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3739         JNIEnv *env;
3740         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3741         if (get_jenv_res == JNI_EDETACHED) {
3742                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3743         } else {
3744                 DO_ASSERT(get_jenv_res == JNI_OK);
3745         }
3746         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3747         CHECK(obj != NULL);
3748         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_shutdown_pubkey_meth);
3749         if ((*env)->ExceptionCheck(env)) {
3750                 (*env)->ExceptionDescribe(env);
3751                 (*env)->FatalError(env, "A call to get_shutdown_pubkey in LDKKeysInterface from rust threw an exception.");
3752         }
3753         LDKPublicKey ret_ref;
3754         CHECK((*env)->GetArrayLength(env, ret) == 33);
3755         (*env)->GetByteArrayRegion(env, ret, 0, 33, ret_ref.compressed_form);
3756         if (get_jenv_res == JNI_EDETACHED) {
3757                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3758         }
3759         return ret_ref;
3760 }
3761 LDKSign get_channel_signer_LDKKeysInterface_jcall(const void* this_arg, bool inbound, uint64_t channel_value_satoshis) {
3762         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3763         JNIEnv *env;
3764         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3765         if (get_jenv_res == JNI_EDETACHED) {
3766                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3767         } else {
3768                 DO_ASSERT(get_jenv_res == JNI_OK);
3769         }
3770         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3771         CHECK(obj != NULL);
3772         LDKSign* ret = (LDKSign*)(*env)->CallLongMethod(env, obj, j_calls->get_channel_signer_meth, inbound, channel_value_satoshis);
3773         if ((*env)->ExceptionCheck(env)) {
3774                 (*env)->ExceptionDescribe(env);
3775                 (*env)->FatalError(env, "A call to get_channel_signer in LDKKeysInterface from rust threw an exception.");
3776         }
3777         LDKSign ret_conv = *(LDKSign*)(((uint64_t)ret) & ~1);
3778         ret_conv = Sign_clone(ret);
3779         if (get_jenv_res == JNI_EDETACHED) {
3780                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3781         }
3782         return ret_conv;
3783 }
3784 LDKThirtyTwoBytes get_secure_random_bytes_LDKKeysInterface_jcall(const void* this_arg) {
3785         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3786         JNIEnv *env;
3787         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3788         if (get_jenv_res == JNI_EDETACHED) {
3789                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3790         } else {
3791                 DO_ASSERT(get_jenv_res == JNI_OK);
3792         }
3793         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3794         CHECK(obj != NULL);
3795         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_secure_random_bytes_meth);
3796         if ((*env)->ExceptionCheck(env)) {
3797                 (*env)->ExceptionDescribe(env);
3798                 (*env)->FatalError(env, "A call to get_secure_random_bytes in LDKKeysInterface from rust threw an exception.");
3799         }
3800         LDKThirtyTwoBytes ret_ref;
3801         CHECK((*env)->GetArrayLength(env, ret) == 32);
3802         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
3803         if (get_jenv_res == JNI_EDETACHED) {
3804                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3805         }
3806         return ret_ref;
3807 }
3808 LDKCResult_SignDecodeErrorZ read_chan_signer_LDKKeysInterface_jcall(const void* this_arg, LDKu8slice reader) {
3809         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3810         JNIEnv *env;
3811         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3812         if (get_jenv_res == JNI_EDETACHED) {
3813                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3814         } else {
3815                 DO_ASSERT(get_jenv_res == JNI_OK);
3816         }
3817         LDKu8slice reader_var = reader;
3818         int8_tArray reader_arr = (*env)->NewByteArray(env, reader_var.datalen);
3819         (*env)->SetByteArrayRegion(env, reader_arr, 0, reader_var.datalen, reader_var.data);
3820         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3821         CHECK(obj != NULL);
3822         LDKCResult_SignDecodeErrorZ* ret = (LDKCResult_SignDecodeErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->read_chan_signer_meth, reader_arr);
3823         if ((*env)->ExceptionCheck(env)) {
3824                 (*env)->ExceptionDescribe(env);
3825                 (*env)->FatalError(env, "A call to read_chan_signer in LDKKeysInterface from rust threw an exception.");
3826         }
3827         LDKCResult_SignDecodeErrorZ ret_conv = *(LDKCResult_SignDecodeErrorZ*)(((uint64_t)ret) & ~1);
3828         ret_conv = CResult_SignDecodeErrorZ_clone((LDKCResult_SignDecodeErrorZ*)(((uint64_t)ret) & ~1));
3829         if (get_jenv_res == JNI_EDETACHED) {
3830                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3831         }
3832         return ret_conv;
3833 }
3834 LDKCResult_RecoverableSignatureNoneZ sign_invoice_LDKKeysInterface_jcall(const void* this_arg, LDKCVec_u8Z invoice_preimage) {
3835         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3836         JNIEnv *env;
3837         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3838         if (get_jenv_res == JNI_EDETACHED) {
3839                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3840         } else {
3841                 DO_ASSERT(get_jenv_res == JNI_OK);
3842         }
3843         LDKCVec_u8Z invoice_preimage_var = invoice_preimage;
3844         int8_tArray invoice_preimage_arr = (*env)->NewByteArray(env, invoice_preimage_var.datalen);
3845         (*env)->SetByteArrayRegion(env, invoice_preimage_arr, 0, invoice_preimage_var.datalen, invoice_preimage_var.data);
3846         CVec_u8Z_free(invoice_preimage_var);
3847         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3848         CHECK(obj != NULL);
3849         LDKCResult_RecoverableSignatureNoneZ* ret = (LDKCResult_RecoverableSignatureNoneZ*)(*env)->CallLongMethod(env, obj, j_calls->sign_invoice_meth, invoice_preimage_arr);
3850         if ((*env)->ExceptionCheck(env)) {
3851                 (*env)->ExceptionDescribe(env);
3852                 (*env)->FatalError(env, "A call to sign_invoice in LDKKeysInterface from rust threw an exception.");
3853         }
3854         LDKCResult_RecoverableSignatureNoneZ ret_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(((uint64_t)ret) & ~1);
3855         ret_conv = CResult_RecoverableSignatureNoneZ_clone((LDKCResult_RecoverableSignatureNoneZ*)(((uint64_t)ret) & ~1));
3856         if (get_jenv_res == JNI_EDETACHED) {
3857                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3858         }
3859         return ret_conv;
3860 }
3861 static void* LDKKeysInterface_JCalls_clone(const void* this_arg) {
3862         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3863         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3864         return (void*) this_arg;
3865 }
3866 static inline LDKKeysInterface LDKKeysInterface_init (JNIEnv *env, jclass clz, jobject o) {
3867         jclass c = (*env)->GetObjectClass(env, o);
3868         CHECK(c != NULL);
3869         LDKKeysInterface_JCalls *calls = MALLOC(sizeof(LDKKeysInterface_JCalls), "LDKKeysInterface_JCalls");
3870         atomic_init(&calls->refcnt, 1);
3871         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
3872         calls->o = (*env)->NewWeakGlobalRef(env, o);
3873         calls->get_node_secret_meth = (*env)->GetMethodID(env, c, "get_node_secret", "()[B");
3874         CHECK(calls->get_node_secret_meth != NULL);
3875         calls->get_destination_script_meth = (*env)->GetMethodID(env, c, "get_destination_script", "()[B");
3876         CHECK(calls->get_destination_script_meth != NULL);
3877         calls->get_shutdown_pubkey_meth = (*env)->GetMethodID(env, c, "get_shutdown_pubkey", "()[B");
3878         CHECK(calls->get_shutdown_pubkey_meth != NULL);
3879         calls->get_channel_signer_meth = (*env)->GetMethodID(env, c, "get_channel_signer", "(ZJ)J");
3880         CHECK(calls->get_channel_signer_meth != NULL);
3881         calls->get_secure_random_bytes_meth = (*env)->GetMethodID(env, c, "get_secure_random_bytes", "()[B");
3882         CHECK(calls->get_secure_random_bytes_meth != NULL);
3883         calls->read_chan_signer_meth = (*env)->GetMethodID(env, c, "read_chan_signer", "([B)J");
3884         CHECK(calls->read_chan_signer_meth != NULL);
3885         calls->sign_invoice_meth = (*env)->GetMethodID(env, c, "sign_invoice", "([B)J");
3886         CHECK(calls->sign_invoice_meth != NULL);
3887
3888         LDKKeysInterface ret = {
3889                 .this_arg = (void*) calls,
3890                 .get_node_secret = get_node_secret_LDKKeysInterface_jcall,
3891                 .get_destination_script = get_destination_script_LDKKeysInterface_jcall,
3892                 .get_shutdown_pubkey = get_shutdown_pubkey_LDKKeysInterface_jcall,
3893                 .get_channel_signer = get_channel_signer_LDKKeysInterface_jcall,
3894                 .get_secure_random_bytes = get_secure_random_bytes_LDKKeysInterface_jcall,
3895                 .read_chan_signer = read_chan_signer_LDKKeysInterface_jcall,
3896                 .sign_invoice = sign_invoice_LDKKeysInterface_jcall,
3897                 .free = LDKKeysInterface_JCalls_free,
3898         };
3899         return ret;
3900 }
3901 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKKeysInterface_1new(JNIEnv *env, jclass clz, jobject o) {
3902         LDKKeysInterface *res_ptr = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
3903         *res_ptr = LDKKeysInterface_init(env, clz, o);
3904         return (uint64_t)res_ptr;
3905 }
3906 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1node_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
3907         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
3908         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
3909         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->get_node_secret)(this_arg_conv->this_arg).bytes);
3910         return ret_arr;
3911 }
3912
3913 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1destination_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
3914         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
3915         LDKCVec_u8Z ret_var = (this_arg_conv->get_destination_script)(this_arg_conv->this_arg);
3916         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
3917         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
3918         CVec_u8Z_free(ret_var);
3919         return ret_arr;
3920 }
3921
3922 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1shutdown_1pubkey(JNIEnv *env, jclass clz, int64_t this_arg) {
3923         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
3924         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
3925         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, (this_arg_conv->get_shutdown_pubkey)(this_arg_conv->this_arg).compressed_form);
3926         return ret_arr;
3927 }
3928
3929 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) {
3930         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
3931         LDKSign* ret = MALLOC(sizeof(LDKSign), "LDKSign");
3932         *ret = (this_arg_conv->get_channel_signer)(this_arg_conv->this_arg, inbound, channel_value_satoshis);
3933         return (uint64_t)ret;
3934 }
3935
3936 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1secure_1random_1bytes(JNIEnv *env, jclass clz, int64_t this_arg) {
3937         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
3938         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
3939         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->get_secure_random_bytes)(this_arg_conv->this_arg).data);
3940         return ret_arr;
3941 }
3942
3943 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1read_1chan_1signer(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray reader) {
3944         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
3945         LDKu8slice reader_ref;
3946         reader_ref.datalen = (*env)->GetArrayLength(env, reader);
3947         reader_ref.data = (*env)->GetByteArrayElements (env, reader, NULL);
3948         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
3949         *ret_conv = (this_arg_conv->read_chan_signer)(this_arg_conv->this_arg, reader_ref);
3950         (*env)->ReleaseByteArrayElements(env, reader, (int8_t*)reader_ref.data, 0);
3951         return (uint64_t)ret_conv;
3952 }
3953
3954 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1sign_1invoice(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray invoice_preimage) {
3955         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
3956         LDKCVec_u8Z invoice_preimage_ref;
3957         invoice_preimage_ref.datalen = (*env)->GetArrayLength(env, invoice_preimage);
3958         invoice_preimage_ref.data = MALLOC(invoice_preimage_ref.datalen, "LDKCVec_u8Z Bytes");
3959         (*env)->GetByteArrayRegion(env, invoice_preimage, 0, invoice_preimage_ref.datalen, invoice_preimage_ref.data);
3960         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
3961         *ret_conv = (this_arg_conv->sign_invoice)(this_arg_conv->this_arg, invoice_preimage_ref);
3962         return (uint64_t)ret_conv;
3963 }
3964
3965 typedef struct LDKFeeEstimator_JCalls {
3966         atomic_size_t refcnt;
3967         JavaVM *vm;
3968         jweak o;
3969         jmethodID get_est_sat_per_1000_weight_meth;
3970 } LDKFeeEstimator_JCalls;
3971 static void LDKFeeEstimator_JCalls_free(void* this_arg) {
3972         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
3973         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3974                 JNIEnv *env;
3975                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3976                 if (get_jenv_res == JNI_EDETACHED) {
3977                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3978                 } else {
3979                         DO_ASSERT(get_jenv_res == JNI_OK);
3980                 }
3981                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
3982                 if (get_jenv_res == JNI_EDETACHED) {
3983                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3984                 }
3985                 FREE(j_calls);
3986         }
3987 }
3988 uint32_t get_est_sat_per_1000_weight_LDKFeeEstimator_jcall(const void* this_arg, LDKConfirmationTarget confirmation_target) {
3989         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
3990         JNIEnv *env;
3991         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3992         if (get_jenv_res == JNI_EDETACHED) {
3993                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3994         } else {
3995                 DO_ASSERT(get_jenv_res == JNI_OK);
3996         }
3997         jclass confirmation_target_conv = LDKConfirmationTarget_to_java(env, confirmation_target);
3998         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3999         CHECK(obj != NULL);
4000         int32_t ret = (*env)->CallIntMethod(env, obj, j_calls->get_est_sat_per_1000_weight_meth, confirmation_target_conv);
4001         if ((*env)->ExceptionCheck(env)) {
4002                 (*env)->ExceptionDescribe(env);
4003                 (*env)->FatalError(env, "A call to get_est_sat_per_1000_weight in LDKFeeEstimator from rust threw an exception.");
4004         }
4005         if (get_jenv_res == JNI_EDETACHED) {
4006                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4007         }
4008         return ret;
4009 }
4010 static void* LDKFeeEstimator_JCalls_clone(const void* this_arg) {
4011         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
4012         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4013         return (void*) this_arg;
4014 }
4015 static inline LDKFeeEstimator LDKFeeEstimator_init (JNIEnv *env, jclass clz, jobject o) {
4016         jclass c = (*env)->GetObjectClass(env, o);
4017         CHECK(c != NULL);
4018         LDKFeeEstimator_JCalls *calls = MALLOC(sizeof(LDKFeeEstimator_JCalls), "LDKFeeEstimator_JCalls");
4019         atomic_init(&calls->refcnt, 1);
4020         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
4021         calls->o = (*env)->NewWeakGlobalRef(env, o);
4022         calls->get_est_sat_per_1000_weight_meth = (*env)->GetMethodID(env, c, "get_est_sat_per_1000_weight", "(Lorg/ldk/enums/ConfirmationTarget;)I");
4023         CHECK(calls->get_est_sat_per_1000_weight_meth != NULL);
4024
4025         LDKFeeEstimator ret = {
4026                 .this_arg = (void*) calls,
4027                 .get_est_sat_per_1000_weight = get_est_sat_per_1000_weight_LDKFeeEstimator_jcall,
4028                 .free = LDKFeeEstimator_JCalls_free,
4029         };
4030         return ret;
4031 }
4032 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKFeeEstimator_1new(JNIEnv *env, jclass clz, jobject o) {
4033         LDKFeeEstimator *res_ptr = MALLOC(sizeof(LDKFeeEstimator), "LDKFeeEstimator");
4034         *res_ptr = LDKFeeEstimator_init(env, clz, o);
4035         return (uint64_t)res_ptr;
4036 }
4037 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) {
4038         LDKFeeEstimator* this_arg_conv = (LDKFeeEstimator*)(((uint64_t)this_arg) & ~1);
4039         LDKConfirmationTarget confirmation_target_conv = LDKConfirmationTarget_from_java(env, confirmation_target);
4040         int32_t ret_val = (this_arg_conv->get_est_sat_per_1000_weight)(this_arg_conv->this_arg, confirmation_target_conv);
4041         return ret_val;
4042 }
4043
4044 typedef struct LDKLogger_JCalls {
4045         atomic_size_t refcnt;
4046         JavaVM *vm;
4047         jweak o;
4048         jmethodID log_meth;
4049 } LDKLogger_JCalls;
4050 static void LDKLogger_JCalls_free(void* this_arg) {
4051         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
4052         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4053                 JNIEnv *env;
4054                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4055                 if (get_jenv_res == JNI_EDETACHED) {
4056                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4057                 } else {
4058                         DO_ASSERT(get_jenv_res == JNI_OK);
4059                 }
4060                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
4061                 if (get_jenv_res == JNI_EDETACHED) {
4062                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4063                 }
4064                 FREE(j_calls);
4065         }
4066 }
4067 void log_LDKLogger_jcall(const void* this_arg, const char* record) {
4068         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
4069         JNIEnv *env;
4070         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4071         if (get_jenv_res == JNI_EDETACHED) {
4072                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4073         } else {
4074                 DO_ASSERT(get_jenv_res == JNI_OK);
4075         }
4076         const char* record_str = record;
4077         jstring record_conv = str_ref_to_java(env, record_str, strlen(record_str));
4078         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4079         CHECK(obj != NULL);
4080         (*env)->CallVoidMethod(env, obj, j_calls->log_meth, record_conv);
4081         if ((*env)->ExceptionCheck(env)) {
4082                 (*env)->ExceptionDescribe(env);
4083                 (*env)->FatalError(env, "A call to log in LDKLogger from rust threw an exception.");
4084         }
4085         if (get_jenv_res == JNI_EDETACHED) {
4086                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4087         }
4088 }
4089 static void* LDKLogger_JCalls_clone(const void* this_arg) {
4090         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
4091         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4092         return (void*) this_arg;
4093 }
4094 static inline LDKLogger LDKLogger_init (JNIEnv *env, jclass clz, jobject o) {
4095         jclass c = (*env)->GetObjectClass(env, o);
4096         CHECK(c != NULL);
4097         LDKLogger_JCalls *calls = MALLOC(sizeof(LDKLogger_JCalls), "LDKLogger_JCalls");
4098         atomic_init(&calls->refcnt, 1);
4099         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
4100         calls->o = (*env)->NewWeakGlobalRef(env, o);
4101         calls->log_meth = (*env)->GetMethodID(env, c, "log", "(Ljava/lang/String;)V");
4102         CHECK(calls->log_meth != NULL);
4103
4104         LDKLogger ret = {
4105                 .this_arg = (void*) calls,
4106                 .log = log_LDKLogger_jcall,
4107                 .free = LDKLogger_JCalls_free,
4108         };
4109         return ret;
4110 }
4111 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKLogger_1new(JNIEnv *env, jclass clz, jobject o) {
4112         LDKLogger *res_ptr = MALLOC(sizeof(LDKLogger), "LDKLogger");
4113         *res_ptr = LDKLogger_init(env, clz, o);
4114         return (uint64_t)res_ptr;
4115 }
4116 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1BlockHashChannelManagerZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
4117         LDKC2Tuple_BlockHashChannelManagerZ* ret = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
4118         LDKThirtyTwoBytes a_ref;
4119         CHECK((*env)->GetArrayLength(env, a) == 32);
4120         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
4121         ret->a = a_ref;
4122         LDKChannelManager b_conv;
4123         b_conv.inner = (void*)(b & (~1));
4124         b_conv.is_owned = (b & 1) || (b == 0);
4125         // Warning: we need a move here but no clone is available for LDKChannelManager
4126         ret->b = b_conv;
4127         return (uint64_t)ret;
4128 }
4129 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1BlockHashChannelManagerZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
4130         LDKC2Tuple_BlockHashChannelManagerZ *tuple = (LDKC2Tuple_BlockHashChannelManagerZ*)(ptr & ~1);
4131         int8_tArray a_arr = (*env)->NewByteArray(env, 32);
4132         (*env)->SetByteArrayRegion(env, a_arr, 0, 32, tuple->a.data);
4133         return a_arr;
4134 }
4135 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1BlockHashChannelManagerZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
4136         LDKC2Tuple_BlockHashChannelManagerZ *tuple = (LDKC2Tuple_BlockHashChannelManagerZ*)(ptr & ~1);
4137         LDKChannelManager b_var = tuple->b;
4138         CHECK((((uint64_t)b_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4139         CHECK((((uint64_t)&b_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4140         uint64_t b_ref = (uint64_t)b_var.inner & ~1;
4141         return b_ref;
4142 }
4143 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4144         return ((LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)arg)->result_ok;
4145 }
4146 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4147         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(arg & ~1);
4148         CHECK(val->result_ok);
4149         uint64_t res_ref = (uint64_t)(&(*val->contents.result)) | 1;
4150         return res_ref;
4151 }
4152 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4153         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(arg & ~1);
4154         CHECK(!val->result_ok);
4155         LDKDecodeError err_var = (*val->contents.err);
4156         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4157         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4158         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4159         return err_ref;
4160 }
4161 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelConfigDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4162         return ((LDKCResult_ChannelConfigDecodeErrorZ*)arg)->result_ok;
4163 }
4164 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelConfigDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4165         LDKCResult_ChannelConfigDecodeErrorZ *val = (LDKCResult_ChannelConfigDecodeErrorZ*)(arg & ~1);
4166         CHECK(val->result_ok);
4167         LDKChannelConfig res_var = (*val->contents.result);
4168         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4169         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4170         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4171         return res_ref;
4172 }
4173 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelConfigDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4174         LDKCResult_ChannelConfigDecodeErrorZ *val = (LDKCResult_ChannelConfigDecodeErrorZ*)(arg & ~1);
4175         CHECK(!val->result_ok);
4176         LDKDecodeError err_var = (*val->contents.err);
4177         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4178         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4179         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4180         return err_ref;
4181 }
4182 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OutPointDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4183         return ((LDKCResult_OutPointDecodeErrorZ*)arg)->result_ok;
4184 }
4185 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OutPointDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4186         LDKCResult_OutPointDecodeErrorZ *val = (LDKCResult_OutPointDecodeErrorZ*)(arg & ~1);
4187         CHECK(val->result_ok);
4188         LDKOutPoint res_var = (*val->contents.result);
4189         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4190         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4191         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4192         return res_ref;
4193 }
4194 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OutPointDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4195         LDKCResult_OutPointDecodeErrorZ *val = (LDKCResult_OutPointDecodeErrorZ*)(arg & ~1);
4196         CHECK(!val->result_ok);
4197         LDKDecodeError err_var = (*val->contents.err);
4198         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4199         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4200         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4201         return err_ref;
4202 }
4203 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SiPrefixNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4204         return ((LDKCResult_SiPrefixNoneZ*)arg)->result_ok;
4205 }
4206 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SiPrefixNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4207         LDKCResult_SiPrefixNoneZ *val = (LDKCResult_SiPrefixNoneZ*)(arg & ~1);
4208         CHECK(val->result_ok);
4209         jclass res_conv = LDKSiPrefix_to_java(env, (*val->contents.result));
4210         return res_conv;
4211 }
4212 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SiPrefixNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4213         LDKCResult_SiPrefixNoneZ *val = (LDKCResult_SiPrefixNoneZ*)(arg & ~1);
4214         CHECK(!val->result_ok);
4215         return *val->contents.err;
4216 }
4217 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4218         return ((LDKCResult_InvoiceNoneZ*)arg)->result_ok;
4219 }
4220 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4221         LDKCResult_InvoiceNoneZ *val = (LDKCResult_InvoiceNoneZ*)(arg & ~1);
4222         CHECK(val->result_ok);
4223         LDKInvoice res_var = (*val->contents.result);
4224         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4225         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4226         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4227         return res_ref;
4228 }
4229 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4230         LDKCResult_InvoiceNoneZ *val = (LDKCResult_InvoiceNoneZ*)(arg & ~1);
4231         CHECK(!val->result_ok);
4232         return *val->contents.err;
4233 }
4234 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignedRawInvoiceNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4235         return ((LDKCResult_SignedRawInvoiceNoneZ*)arg)->result_ok;
4236 }
4237 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignedRawInvoiceNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4238         LDKCResult_SignedRawInvoiceNoneZ *val = (LDKCResult_SignedRawInvoiceNoneZ*)(arg & ~1);
4239         CHECK(val->result_ok);
4240         LDKSignedRawInvoice res_var = (*val->contents.result);
4241         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4242         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4243         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4244         return res_ref;
4245 }
4246 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignedRawInvoiceNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4247         LDKCResult_SignedRawInvoiceNoneZ *val = (LDKCResult_SignedRawInvoiceNoneZ*)(arg & ~1);
4248         CHECK(!val->result_ok);
4249         return *val->contents.err;
4250 }
4251 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b, int64_t c) {
4252         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
4253         LDKRawInvoice a_conv;
4254         a_conv.inner = (void*)(a & (~1));
4255         a_conv.is_owned = (a & 1) || (a == 0);
4256         a_conv = RawInvoice_clone(&a_conv);
4257         ret->a = a_conv;
4258         LDKThirtyTwoBytes b_ref;
4259         CHECK((*env)->GetArrayLength(env, b) == 32);
4260         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
4261         ret->b = b_ref;
4262         LDKInvoiceSignature c_conv;
4263         c_conv.inner = (void*)(c & (~1));
4264         c_conv.is_owned = (c & 1) || (c == 0);
4265         c_conv = InvoiceSignature_clone(&c_conv);
4266         ret->c = c_conv;
4267         return (uint64_t)ret;
4268 }
4269 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
4270         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *tuple = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(ptr & ~1);
4271         LDKRawInvoice a_var = tuple->a;
4272         CHECK((((uint64_t)a_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4273         CHECK((((uint64_t)&a_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4274         uint64_t a_ref = (uint64_t)a_var.inner & ~1;
4275         return a_ref;
4276 }
4277 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
4278         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *tuple = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(ptr & ~1);
4279         int8_tArray b_arr = (*env)->NewByteArray(env, 32);
4280         (*env)->SetByteArrayRegion(env, b_arr, 0, 32, tuple->b.data);
4281         return b_arr;
4282 }
4283 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1c(JNIEnv *env, jclass clz, int64_t ptr) {
4284         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *tuple = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(ptr & ~1);
4285         LDKInvoiceSignature c_var = tuple->c;
4286         CHECK((((uint64_t)c_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4287         CHECK((((uint64_t)&c_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4288         uint64_t c_ref = (uint64_t)c_var.inner & ~1;
4289         return c_ref;
4290 }
4291 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PayeePubKeyErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4292         return ((LDKCResult_PayeePubKeyErrorZ*)arg)->result_ok;
4293 }
4294 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PayeePubKeyErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4295         LDKCResult_PayeePubKeyErrorZ *val = (LDKCResult_PayeePubKeyErrorZ*)(arg & ~1);
4296         CHECK(val->result_ok);
4297         LDKPayeePubKey res_var = (*val->contents.result);
4298         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4299         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4300         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4301         return res_ref;
4302 }
4303 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PayeePubKeyErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4304         LDKCResult_PayeePubKeyErrorZ *val = (LDKCResult_PayeePubKeyErrorZ*)(arg & ~1);
4305         CHECK(!val->result_ok);
4306         jclass err_conv = LDKSecp256k1Error_to_java(env, (*val->contents.err));
4307         return err_conv;
4308 }
4309 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1PrivateRouteZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
4310         LDKCVec_PrivateRouteZ *ret = MALLOC(sizeof(LDKCVec_PrivateRouteZ), "LDKCVec_PrivateRouteZ");
4311         ret->datalen = (*env)->GetArrayLength(env, elems);
4312         if (ret->datalen == 0) {
4313                 ret->data = NULL;
4314         } else {
4315                 ret->data = MALLOC(sizeof(LDKPrivateRoute) * ret->datalen, "LDKCVec_PrivateRouteZ Data");
4316                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
4317                 for (size_t i = 0; i < ret->datalen; i++) {
4318                         int64_t arr_elem = java_elems[i];
4319                         LDKPrivateRoute arr_elem_conv;
4320                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
4321                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
4322                         arr_elem_conv = PrivateRoute_clone(&arr_elem_conv);
4323                         ret->data[i] = arr_elem_conv;
4324                 }
4325                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
4326         }
4327         return (uint64_t)ret;
4328 }
4329 static inline LDKCVec_PrivateRouteZ CVec_PrivateRouteZ_clone(const LDKCVec_PrivateRouteZ *orig) {
4330         LDKCVec_PrivateRouteZ ret = { .data = MALLOC(sizeof(LDKPrivateRoute) * orig->datalen, "LDKCVec_PrivateRouteZ clone bytes"), .datalen = orig->datalen };
4331         for (size_t i = 0; i < ret.datalen; i++) {
4332                 ret.data[i] = PrivateRoute_clone(&orig->data[i]);
4333         }
4334         return ret;
4335 }
4336 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PositiveTimestampCreationErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4337         return ((LDKCResult_PositiveTimestampCreationErrorZ*)arg)->result_ok;
4338 }
4339 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PositiveTimestampCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4340         LDKCResult_PositiveTimestampCreationErrorZ *val = (LDKCResult_PositiveTimestampCreationErrorZ*)(arg & ~1);
4341         CHECK(val->result_ok);
4342         LDKPositiveTimestamp res_var = (*val->contents.result);
4343         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4344         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4345         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4346         return res_ref;
4347 }
4348 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PositiveTimestampCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4349         LDKCResult_PositiveTimestampCreationErrorZ *val = (LDKCResult_PositiveTimestampCreationErrorZ*)(arg & ~1);
4350         CHECK(!val->result_ok);
4351         jclass err_conv = LDKCreationError_to_java(env, (*val->contents.err));
4352         return err_conv;
4353 }
4354 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneSemanticErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4355         return ((LDKCResult_NoneSemanticErrorZ*)arg)->result_ok;
4356 }
4357 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneSemanticErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4358         LDKCResult_NoneSemanticErrorZ *val = (LDKCResult_NoneSemanticErrorZ*)(arg & ~1);
4359         CHECK(val->result_ok);
4360         return *val->contents.result;
4361 }
4362 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneSemanticErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4363         LDKCResult_NoneSemanticErrorZ *val = (LDKCResult_NoneSemanticErrorZ*)(arg & ~1);
4364         CHECK(!val->result_ok);
4365         jclass err_conv = LDKSemanticError_to_java(env, (*val->contents.err));
4366         return err_conv;
4367 }
4368 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceSemanticErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4369         return ((LDKCResult_InvoiceSemanticErrorZ*)arg)->result_ok;
4370 }
4371 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceSemanticErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4372         LDKCResult_InvoiceSemanticErrorZ *val = (LDKCResult_InvoiceSemanticErrorZ*)(arg & ~1);
4373         CHECK(val->result_ok);
4374         LDKInvoice res_var = (*val->contents.result);
4375         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4376         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4377         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4378         return res_ref;
4379 }
4380 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceSemanticErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4381         LDKCResult_InvoiceSemanticErrorZ *val = (LDKCResult_InvoiceSemanticErrorZ*)(arg & ~1);
4382         CHECK(!val->result_ok);
4383         jclass err_conv = LDKSemanticError_to_java(env, (*val->contents.err));
4384         return err_conv;
4385 }
4386 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DescriptionCreationErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4387         return ((LDKCResult_DescriptionCreationErrorZ*)arg)->result_ok;
4388 }
4389 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DescriptionCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4390         LDKCResult_DescriptionCreationErrorZ *val = (LDKCResult_DescriptionCreationErrorZ*)(arg & ~1);
4391         CHECK(val->result_ok);
4392         LDKDescription res_var = (*val->contents.result);
4393         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4394         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4395         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4396         return res_ref;
4397 }
4398 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DescriptionCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4399         LDKCResult_DescriptionCreationErrorZ *val = (LDKCResult_DescriptionCreationErrorZ*)(arg & ~1);
4400         CHECK(!val->result_ok);
4401         jclass err_conv = LDKCreationError_to_java(env, (*val->contents.err));
4402         return err_conv;
4403 }
4404 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ExpiryTimeCreationErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4405         return ((LDKCResult_ExpiryTimeCreationErrorZ*)arg)->result_ok;
4406 }
4407 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ExpiryTimeCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4408         LDKCResult_ExpiryTimeCreationErrorZ *val = (LDKCResult_ExpiryTimeCreationErrorZ*)(arg & ~1);
4409         CHECK(val->result_ok);
4410         LDKExpiryTime res_var = (*val->contents.result);
4411         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4412         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4413         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4414         return res_ref;
4415 }
4416 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ExpiryTimeCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4417         LDKCResult_ExpiryTimeCreationErrorZ *val = (LDKCResult_ExpiryTimeCreationErrorZ*)(arg & ~1);
4418         CHECK(!val->result_ok);
4419         jclass err_conv = LDKCreationError_to_java(env, (*val->contents.err));
4420         return err_conv;
4421 }
4422 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PrivateRouteCreationErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4423         return ((LDKCResult_PrivateRouteCreationErrorZ*)arg)->result_ok;
4424 }
4425 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PrivateRouteCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4426         LDKCResult_PrivateRouteCreationErrorZ *val = (LDKCResult_PrivateRouteCreationErrorZ*)(arg & ~1);
4427         CHECK(val->result_ok);
4428         LDKPrivateRoute res_var = (*val->contents.result);
4429         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4430         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4431         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4432         return res_ref;
4433 }
4434 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PrivateRouteCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4435         LDKCResult_PrivateRouteCreationErrorZ *val = (LDKCResult_PrivateRouteCreationErrorZ*)(arg & ~1);
4436         CHECK(!val->result_ok);
4437         jclass err_conv = LDKCreationError_to_java(env, (*val->contents.err));
4438         return err_conv;
4439 }
4440 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1StringErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4441         return ((LDKCResult_StringErrorZ*)arg)->result_ok;
4442 }
4443 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_LDKCResult_1StringErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4444         LDKCResult_StringErrorZ *val = (LDKCResult_StringErrorZ*)(arg & ~1);
4445         CHECK(val->result_ok);
4446         LDKStr res_str = (*val->contents.result);
4447         jstring res_conv = str_ref_to_java(env, res_str.chars, res_str.len);
4448         return res_conv;
4449 }
4450 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1StringErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4451         LDKCResult_StringErrorZ *val = (LDKCResult_StringErrorZ*)(arg & ~1);
4452         CHECK(!val->result_ok);
4453         jclass err_conv = LDKSecp256k1Error_to_java(env, (*val->contents.err));
4454         return err_conv;
4455 }
4456 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelMonitorUpdateDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4457         return ((LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)arg)->result_ok;
4458 }
4459 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelMonitorUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4460         LDKCResult_ChannelMonitorUpdateDecodeErrorZ *val = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(arg & ~1);
4461         CHECK(val->result_ok);
4462         LDKChannelMonitorUpdate res_var = (*val->contents.result);
4463         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4464         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4465         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4466         return res_ref;
4467 }
4468 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelMonitorUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4469         LDKCResult_ChannelMonitorUpdateDecodeErrorZ *val = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(arg & ~1);
4470         CHECK(!val->result_ok);
4471         LDKDecodeError err_var = (*val->contents.err);
4472         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4473         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4474         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4475         return err_ref;
4476 }
4477 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCUpdateDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4478         return ((LDKCResult_HTLCUpdateDecodeErrorZ*)arg)->result_ok;
4479 }
4480 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4481         LDKCResult_HTLCUpdateDecodeErrorZ *val = (LDKCResult_HTLCUpdateDecodeErrorZ*)(arg & ~1);
4482         CHECK(val->result_ok);
4483         LDKHTLCUpdate res_var = (*val->contents.result);
4484         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4485         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4486         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4487         return res_ref;
4488 }
4489 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4490         LDKCResult_HTLCUpdateDecodeErrorZ *val = (LDKCResult_HTLCUpdateDecodeErrorZ*)(arg & ~1);
4491         CHECK(!val->result_ok);
4492         LDKDecodeError err_var = (*val->contents.err);
4493         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4494         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4495         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4496         return err_ref;
4497 }
4498 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneMonitorUpdateErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4499         return ((LDKCResult_NoneMonitorUpdateErrorZ*)arg)->result_ok;
4500 }
4501 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneMonitorUpdateErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4502         LDKCResult_NoneMonitorUpdateErrorZ *val = (LDKCResult_NoneMonitorUpdateErrorZ*)(arg & ~1);
4503         CHECK(val->result_ok);
4504         return *val->contents.result;
4505 }
4506 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneMonitorUpdateErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4507         LDKCResult_NoneMonitorUpdateErrorZ *val = (LDKCResult_NoneMonitorUpdateErrorZ*)(arg & ~1);
4508         CHECK(!val->result_ok);
4509         LDKMonitorUpdateError err_var = (*val->contents.err);
4510         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4511         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4512         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4513         return err_ref;
4514 }
4515 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1OutPointScriptZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
4516         LDKC2Tuple_OutPointScriptZ* ret = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
4517         LDKOutPoint a_conv;
4518         a_conv.inner = (void*)(a & (~1));
4519         a_conv.is_owned = (a & 1) || (a == 0);
4520         a_conv = OutPoint_clone(&a_conv);
4521         ret->a = a_conv;
4522         LDKCVec_u8Z b_ref;
4523         b_ref.datalen = (*env)->GetArrayLength(env, b);
4524         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
4525         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
4526         ret->b = b_ref;
4527         return (uint64_t)ret;
4528 }
4529 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1OutPointScriptZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
4530         LDKC2Tuple_OutPointScriptZ *tuple = (LDKC2Tuple_OutPointScriptZ*)(ptr & ~1);
4531         LDKOutPoint a_var = tuple->a;
4532         CHECK((((uint64_t)a_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4533         CHECK((((uint64_t)&a_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4534         uint64_t a_ref = (uint64_t)a_var.inner & ~1;
4535         return a_ref;
4536 }
4537 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1OutPointScriptZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
4538         LDKC2Tuple_OutPointScriptZ *tuple = (LDKC2Tuple_OutPointScriptZ*)(ptr & ~1);
4539         LDKCVec_u8Z b_var = tuple->b;
4540         int8_tArray b_arr = (*env)->NewByteArray(env, b_var.datalen);
4541         (*env)->SetByteArrayRegion(env, b_arr, 0, b_var.datalen, b_var.data);
4542         return b_arr;
4543 }
4544 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1u32ScriptZ_1new(JNIEnv *env, jclass clz, int32_t a, int8_tArray b) {
4545         LDKC2Tuple_u32ScriptZ* ret = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
4546         ret->a = a;
4547         LDKCVec_u8Z b_ref;
4548         b_ref.datalen = (*env)->GetArrayLength(env, b);
4549         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
4550         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
4551         ret->b = b_ref;
4552         return (uint64_t)ret;
4553 }
4554 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1u32ScriptZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
4555         LDKC2Tuple_u32ScriptZ *tuple = (LDKC2Tuple_u32ScriptZ*)(ptr & ~1);
4556         return tuple->a;
4557 }
4558 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1u32ScriptZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
4559         LDKC2Tuple_u32ScriptZ *tuple = (LDKC2Tuple_u32ScriptZ*)(ptr & ~1);
4560         LDKCVec_u8Z b_var = tuple->b;
4561         int8_tArray b_arr = (*env)->NewByteArray(env, b_var.datalen);
4562         (*env)->SetByteArrayRegion(env, b_arr, 0, b_var.datalen, b_var.data);
4563         return b_arr;
4564 }
4565 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1u32ScriptZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
4566         LDKCVec_C2Tuple_u32ScriptZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_u32ScriptZZ), "LDKCVec_C2Tuple_u32ScriptZZ");
4567         ret->datalen = (*env)->GetArrayLength(env, elems);
4568         if (ret->datalen == 0) {
4569                 ret->data = NULL;
4570         } else {
4571                 ret->data = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ) * ret->datalen, "LDKCVec_C2Tuple_u32ScriptZZ Data");
4572                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
4573                 for (size_t i = 0; i < ret->datalen; i++) {
4574                         int64_t arr_elem = java_elems[i];
4575                         LDKC2Tuple_u32ScriptZ arr_elem_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)arr_elem) & ~1);
4576                         arr_elem_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)(((uint64_t)arr_elem) & ~1));
4577                         ret->data[i] = arr_elem_conv;
4578                 }
4579                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
4580         }
4581         return (uint64_t)ret;
4582 }
4583 static inline LDKCVec_C2Tuple_u32ScriptZZ CVec_C2Tuple_u32ScriptZZ_clone(const LDKCVec_C2Tuple_u32ScriptZZ *orig) {
4584         LDKCVec_C2Tuple_u32ScriptZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ) * orig->datalen, "LDKCVec_C2Tuple_u32ScriptZZ clone bytes"), .datalen = orig->datalen };
4585         for (size_t i = 0; i < ret.datalen; i++) {
4586                 ret.data[i] = C2Tuple_u32ScriptZ_clone(&orig->data[i]);
4587         }
4588         return ret;
4589 }
4590 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
4591         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
4592         LDKThirtyTwoBytes a_ref;
4593         CHECK((*env)->GetArrayLength(env, a) == 32);
4594         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
4595         ret->a = a_ref;
4596         LDKCVec_C2Tuple_u32ScriptZZ b_constr;
4597         b_constr.datalen = (*env)->GetArrayLength(env, b);
4598         if (b_constr.datalen > 0)
4599                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
4600         else
4601                 b_constr.data = NULL;
4602         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
4603         for (size_t b = 0; b < b_constr.datalen; b++) {
4604                 int64_t b_conv_27 = b_vals[b];
4605                 LDKC2Tuple_u32ScriptZ b_conv_27_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_27) & ~1);
4606                 b_conv_27_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_27) & ~1));
4607                 b_constr.data[b] = b_conv_27_conv;
4608         }
4609         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
4610         ret->b = b_constr;
4611         return (uint64_t)ret;
4612 }
4613 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
4614         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *tuple = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(ptr & ~1);
4615         int8_tArray a_arr = (*env)->NewByteArray(env, 32);
4616         (*env)->SetByteArrayRegion(env, a_arr, 0, 32, tuple->a.data);
4617         return a_arr;
4618 }
4619 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
4620         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *tuple = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(ptr & ~1);
4621         LDKCVec_C2Tuple_u32ScriptZZ b_var = tuple->b;
4622         int64_tArray b_arr = (*env)->NewLongArray(env, b_var.datalen);
4623         int64_t *b_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, b_arr, NULL);
4624         for (size_t b = 0; b < b_var.datalen; b++) {
4625                 uint64_t b_conv_27_ref = (uint64_t)(&b_var.data[b]) | 1;
4626                 b_arr_ptr[b] = b_conv_27_ref;
4627         }
4628         (*env)->ReleasePrimitiveArrayCritical(env, b_arr, b_arr_ptr, 0);
4629         return b_arr;
4630 }
4631 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
4632         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ");
4633         ret->datalen = (*env)->GetArrayLength(env, elems);
4634         if (ret->datalen == 0) {
4635                 ret->data = NULL;
4636         } else {
4637                 ret->data = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ) * ret->datalen, "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ Data");
4638                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
4639                 for (size_t i = 0; i < ret->datalen; i++) {
4640                         int64_t arr_elem = java_elems[i];
4641                         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ arr_elem_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)arr_elem) & ~1);
4642                         arr_elem_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone((LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)arr_elem) & ~1));
4643                         ret->data[i] = arr_elem_conv;
4644                 }
4645                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
4646         }
4647         return (uint64_t)ret;
4648 }
4649 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ *orig) {
4650         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 };
4651         for (size_t i = 0; i < ret.datalen; i++) {
4652                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(&orig->data[i]);
4653         }
4654         return ret;
4655 }
4656 static jclass LDKEvent_FundingGenerationReady_class = NULL;
4657 static jmethodID LDKEvent_FundingGenerationReady_meth = NULL;
4658 static jclass LDKEvent_PaymentReceived_class = NULL;
4659 static jmethodID LDKEvent_PaymentReceived_meth = NULL;
4660 static jclass LDKEvent_PaymentSent_class = NULL;
4661 static jmethodID LDKEvent_PaymentSent_meth = NULL;
4662 static jclass LDKEvent_PaymentFailed_class = NULL;
4663 static jmethodID LDKEvent_PaymentFailed_meth = NULL;
4664 static jclass LDKEvent_PendingHTLCsForwardable_class = NULL;
4665 static jmethodID LDKEvent_PendingHTLCsForwardable_meth = NULL;
4666 static jclass LDKEvent_SpendableOutputs_class = NULL;
4667 static jmethodID LDKEvent_SpendableOutputs_meth = NULL;
4668 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKEvent_init (JNIEnv *env, jclass clz) {
4669         LDKEvent_FundingGenerationReady_class =
4670                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$FundingGenerationReady;"));
4671         CHECK(LDKEvent_FundingGenerationReady_class != NULL);
4672         LDKEvent_FundingGenerationReady_meth = (*env)->GetMethodID(env, LDKEvent_FundingGenerationReady_class, "<init>", "([BJ[BJ)V");
4673         CHECK(LDKEvent_FundingGenerationReady_meth != NULL);
4674         LDKEvent_PaymentReceived_class =
4675                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PaymentReceived;"));
4676         CHECK(LDKEvent_PaymentReceived_class != NULL);
4677         LDKEvent_PaymentReceived_meth = (*env)->GetMethodID(env, LDKEvent_PaymentReceived_class, "<init>", "([B[B[BJJ)V");
4678         CHECK(LDKEvent_PaymentReceived_meth != NULL);
4679         LDKEvent_PaymentSent_class =
4680                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PaymentSent;"));
4681         CHECK(LDKEvent_PaymentSent_class != NULL);
4682         LDKEvent_PaymentSent_meth = (*env)->GetMethodID(env, LDKEvent_PaymentSent_class, "<init>", "([B)V");
4683         CHECK(LDKEvent_PaymentSent_meth != NULL);
4684         LDKEvent_PaymentFailed_class =
4685                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PaymentFailed;"));
4686         CHECK(LDKEvent_PaymentFailed_class != NULL);
4687         LDKEvent_PaymentFailed_meth = (*env)->GetMethodID(env, LDKEvent_PaymentFailed_class, "<init>", "([BZ)V");
4688         CHECK(LDKEvent_PaymentFailed_meth != NULL);
4689         LDKEvent_PendingHTLCsForwardable_class =
4690                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PendingHTLCsForwardable;"));
4691         CHECK(LDKEvent_PendingHTLCsForwardable_class != NULL);
4692         LDKEvent_PendingHTLCsForwardable_meth = (*env)->GetMethodID(env, LDKEvent_PendingHTLCsForwardable_class, "<init>", "(J)V");
4693         CHECK(LDKEvent_PendingHTLCsForwardable_meth != NULL);
4694         LDKEvent_SpendableOutputs_class =
4695                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$SpendableOutputs;"));
4696         CHECK(LDKEvent_SpendableOutputs_class != NULL);
4697         LDKEvent_SpendableOutputs_meth = (*env)->GetMethodID(env, LDKEvent_SpendableOutputs_class, "<init>", "([J)V");
4698         CHECK(LDKEvent_SpendableOutputs_meth != NULL);
4699 }
4700 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
4701         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
4702         switch(obj->tag) {
4703                 case LDKEvent_FundingGenerationReady: {
4704                         int8_tArray temporary_channel_id_arr = (*env)->NewByteArray(env, 32);
4705                         (*env)->SetByteArrayRegion(env, temporary_channel_id_arr, 0, 32, obj->funding_generation_ready.temporary_channel_id.data);
4706                         LDKCVec_u8Z output_script_var = obj->funding_generation_ready.output_script;
4707                         int8_tArray output_script_arr = (*env)->NewByteArray(env, output_script_var.datalen);
4708                         (*env)->SetByteArrayRegion(env, output_script_arr, 0, output_script_var.datalen, output_script_var.data);
4709                         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);
4710                 }
4711                 case LDKEvent_PaymentReceived: {
4712                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
4713                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_received.payment_hash.data);
4714                         int8_tArray payment_preimage_arr = (*env)->NewByteArray(env, 32);
4715                         (*env)->SetByteArrayRegion(env, payment_preimage_arr, 0, 32, obj->payment_received.payment_preimage.data);
4716                         int8_tArray payment_secret_arr = (*env)->NewByteArray(env, 32);
4717                         (*env)->SetByteArrayRegion(env, payment_secret_arr, 0, 32, obj->payment_received.payment_secret.data);
4718                         return (*env)->NewObject(env, LDKEvent_PaymentReceived_class, LDKEvent_PaymentReceived_meth, payment_hash_arr, payment_preimage_arr, payment_secret_arr, obj->payment_received.amt, obj->payment_received.user_payment_id);
4719                 }
4720                 case LDKEvent_PaymentSent: {
4721                         int8_tArray payment_preimage_arr = (*env)->NewByteArray(env, 32);
4722                         (*env)->SetByteArrayRegion(env, payment_preimage_arr, 0, 32, obj->payment_sent.payment_preimage.data);
4723                         return (*env)->NewObject(env, LDKEvent_PaymentSent_class, LDKEvent_PaymentSent_meth, payment_preimage_arr);
4724                 }
4725                 case LDKEvent_PaymentFailed: {
4726                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
4727                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_failed.payment_hash.data);
4728                         return (*env)->NewObject(env, LDKEvent_PaymentFailed_class, LDKEvent_PaymentFailed_meth, payment_hash_arr, obj->payment_failed.rejected_by_dest);
4729                 }
4730                 case LDKEvent_PendingHTLCsForwardable: {
4731                         return (*env)->NewObject(env, LDKEvent_PendingHTLCsForwardable_class, LDKEvent_PendingHTLCsForwardable_meth, obj->pending_htl_cs_forwardable.time_forwardable);
4732                 }
4733                 case LDKEvent_SpendableOutputs: {
4734                         LDKCVec_SpendableOutputDescriptorZ outputs_var = obj->spendable_outputs.outputs;
4735                         int64_tArray outputs_arr = (*env)->NewLongArray(env, outputs_var.datalen);
4736                         int64_t *outputs_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, outputs_arr, NULL);
4737                         for (size_t b = 0; b < outputs_var.datalen; b++) {
4738                                 uint64_t outputs_conv_27_ref = ((uint64_t)&outputs_var.data[b]) | 1;
4739                                 outputs_arr_ptr[b] = outputs_conv_27_ref;
4740                         }
4741                         (*env)->ReleasePrimitiveArrayCritical(env, outputs_arr, outputs_arr_ptr, 0);
4742                         return (*env)->NewObject(env, LDKEvent_SpendableOutputs_class, LDKEvent_SpendableOutputs_meth, outputs_arr);
4743                 }
4744                 default: abort();
4745         }
4746 }
4747 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1EventZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
4748         LDKCVec_EventZ *ret = MALLOC(sizeof(LDKCVec_EventZ), "LDKCVec_EventZ");
4749         ret->datalen = (*env)->GetArrayLength(env, elems);
4750         if (ret->datalen == 0) {
4751                 ret->data = NULL;
4752         } else {
4753                 ret->data = MALLOC(sizeof(LDKEvent) * ret->datalen, "LDKCVec_EventZ Data");
4754                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
4755                 for (size_t i = 0; i < ret->datalen; i++) {
4756                         int64_t arr_elem = java_elems[i];
4757                         LDKEvent arr_elem_conv = *(LDKEvent*)(((uint64_t)arr_elem) & ~1);
4758                         arr_elem_conv = Event_clone((LDKEvent*)(((uint64_t)arr_elem) & ~1));
4759                         ret->data[i] = arr_elem_conv;
4760                 }
4761                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
4762         }
4763         return (uint64_t)ret;
4764 }
4765 static inline LDKCVec_EventZ CVec_EventZ_clone(const LDKCVec_EventZ *orig) {
4766         LDKCVec_EventZ ret = { .data = MALLOC(sizeof(LDKEvent) * orig->datalen, "LDKCVec_EventZ clone bytes"), .datalen = orig->datalen };
4767         for (size_t i = 0; i < ret.datalen; i++) {
4768                 ret.data[i] = Event_clone(&orig->data[i]);
4769         }
4770         return ret;
4771 }
4772 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1u32TxOutZ_1new(JNIEnv *env, jclass clz, int32_t a, int64_t b) {
4773         LDKC2Tuple_u32TxOutZ* ret = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
4774         ret->a = a;
4775         LDKTxOut b_conv = *(LDKTxOut*)(((uint64_t)b) & ~1);
4776         b_conv = TxOut_clone((LDKTxOut*)(((uint64_t)b) & ~1));
4777         ret->b = b_conv;
4778         return (uint64_t)ret;
4779 }
4780 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1u32TxOutZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
4781         LDKC2Tuple_u32TxOutZ *tuple = (LDKC2Tuple_u32TxOutZ*)(ptr & ~1);
4782         return tuple->a;
4783 }
4784 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1u32TxOutZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
4785         LDKC2Tuple_u32TxOutZ *tuple = (LDKC2Tuple_u32TxOutZ*)(ptr & ~1);
4786         uint64_t b_ref = ((uint64_t)&tuple->b) | 1;
4787         return (uint64_t)b_ref;
4788 }
4789 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1u32TxOutZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
4790         LDKCVec_C2Tuple_u32TxOutZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_u32TxOutZZ), "LDKCVec_C2Tuple_u32TxOutZZ");
4791         ret->datalen = (*env)->GetArrayLength(env, elems);
4792         if (ret->datalen == 0) {
4793                 ret->data = NULL;
4794         } else {
4795                 ret->data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * ret->datalen, "LDKCVec_C2Tuple_u32TxOutZZ Data");
4796                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
4797                 for (size_t i = 0; i < ret->datalen; i++) {
4798                         int64_t arr_elem = java_elems[i];
4799                         LDKC2Tuple_u32TxOutZ arr_elem_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)arr_elem) & ~1);
4800                         arr_elem_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uint64_t)arr_elem) & ~1));
4801                         ret->data[i] = arr_elem_conv;
4802                 }
4803                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
4804         }
4805         return (uint64_t)ret;
4806 }
4807 static inline LDKCVec_C2Tuple_u32TxOutZZ CVec_C2Tuple_u32TxOutZZ_clone(const LDKCVec_C2Tuple_u32TxOutZZ *orig) {
4808         LDKCVec_C2Tuple_u32TxOutZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * orig->datalen, "LDKCVec_C2Tuple_u32TxOutZZ clone bytes"), .datalen = orig->datalen };
4809         for (size_t i = 0; i < ret.datalen; i++) {
4810                 ret.data[i] = C2Tuple_u32TxOutZ_clone(&orig->data[i]);
4811         }
4812         return ret;
4813 }
4814 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
4815         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
4816         LDKThirtyTwoBytes a_ref;
4817         CHECK((*env)->GetArrayLength(env, a) == 32);
4818         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
4819         ret->a = a_ref;
4820         LDKCVec_C2Tuple_u32TxOutZZ b_constr;
4821         b_constr.datalen = (*env)->GetArrayLength(env, b);
4822         if (b_constr.datalen > 0)
4823                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
4824         else
4825                 b_constr.data = NULL;
4826         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
4827         for (size_t a = 0; a < b_constr.datalen; a++) {
4828                 int64_t b_conv_26 = b_vals[a];
4829                 LDKC2Tuple_u32TxOutZ b_conv_26_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_26) & ~1);
4830                 b_conv_26_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_26) & ~1));
4831                 b_constr.data[a] = b_conv_26_conv;
4832         }
4833         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
4834         ret->b = b_constr;
4835         return (uint64_t)ret;
4836 }
4837 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
4838         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *tuple = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(ptr & ~1);
4839         int8_tArray a_arr = (*env)->NewByteArray(env, 32);
4840         (*env)->SetByteArrayRegion(env, a_arr, 0, 32, tuple->a.data);
4841         return a_arr;
4842 }
4843 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
4844         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *tuple = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(ptr & ~1);
4845         LDKCVec_C2Tuple_u32TxOutZZ b_var = tuple->b;
4846         int64_tArray b_arr = (*env)->NewLongArray(env, b_var.datalen);
4847         int64_t *b_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, b_arr, NULL);
4848         for (size_t a = 0; a < b_var.datalen; a++) {
4849                 uint64_t b_conv_26_ref = (uint64_t)(&b_var.data[a]) | 1;
4850                 b_arr_ptr[a] = b_conv_26_ref;
4851         }
4852         (*env)->ReleasePrimitiveArrayCritical(env, b_arr, b_arr_ptr, 0);
4853         return b_arr;
4854 }
4855 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
4856         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ");
4857         ret->datalen = (*env)->GetArrayLength(env, elems);
4858         if (ret->datalen == 0) {
4859                 ret->data = NULL;
4860         } else {
4861                 ret->data = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ) * ret->datalen, "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Data");
4862                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
4863                 for (size_t i = 0; i < ret->datalen; i++) {
4864                         int64_t arr_elem = java_elems[i];
4865                         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ arr_elem_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)arr_elem) & ~1);
4866                         arr_elem_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone((LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)arr_elem) & ~1));
4867                         ret->data[i] = arr_elem_conv;
4868                 }
4869                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
4870         }
4871         return (uint64_t)ret;
4872 }
4873 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ *orig) {
4874         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 };
4875         for (size_t i = 0; i < ret.datalen; i++) {
4876                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(&orig->data[i]);
4877         }
4878         return ret;
4879 }
4880 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4881         return ((LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)arg)->result_ok;
4882 }
4883 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4884         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1);
4885         CHECK(val->result_ok);
4886         uint64_t res_ref = (uint64_t)(&(*val->contents.result)) | 1;
4887         return res_ref;
4888 }
4889 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4890         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1);
4891         CHECK(!val->result_ok);
4892         LDKDecodeError err_var = (*val->contents.err);
4893         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4894         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4895         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4896         return err_ref;
4897 }
4898 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolLightningErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4899         return ((LDKCResult_boolLightningErrorZ*)arg)->result_ok;
4900 }
4901 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4902         LDKCResult_boolLightningErrorZ *val = (LDKCResult_boolLightningErrorZ*)(arg & ~1);
4903         CHECK(val->result_ok);
4904         return *val->contents.result;
4905 }
4906 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4907         LDKCResult_boolLightningErrorZ *val = (LDKCResult_boolLightningErrorZ*)(arg & ~1);
4908         CHECK(!val->result_ok);
4909         LDKLightningError err_var = (*val->contents.err);
4910         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4911         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4912         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4913         return err_ref;
4914 }
4915 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1new(JNIEnv *env, jclass clz, int64_t a, int64_t b, int64_t c) {
4916         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
4917         LDKChannelAnnouncement a_conv;
4918         a_conv.inner = (void*)(a & (~1));
4919         a_conv.is_owned = (a & 1) || (a == 0);
4920         a_conv = ChannelAnnouncement_clone(&a_conv);
4921         ret->a = a_conv;
4922         LDKChannelUpdate b_conv;
4923         b_conv.inner = (void*)(b & (~1));
4924         b_conv.is_owned = (b & 1) || (b == 0);
4925         b_conv = ChannelUpdate_clone(&b_conv);
4926         ret->b = b_conv;
4927         LDKChannelUpdate c_conv;
4928         c_conv.inner = (void*)(c & (~1));
4929         c_conv.is_owned = (c & 1) || (c == 0);
4930         c_conv = ChannelUpdate_clone(&c_conv);
4931         ret->c = c_conv;
4932         return (uint64_t)ret;
4933 }
4934 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
4935         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *tuple = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ptr & ~1);
4936         LDKChannelAnnouncement a_var = tuple->a;
4937         CHECK((((uint64_t)a_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4938         CHECK((((uint64_t)&a_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4939         uint64_t a_ref = (uint64_t)a_var.inner & ~1;
4940         return a_ref;
4941 }
4942 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
4943         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *tuple = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ptr & ~1);
4944         LDKChannelUpdate b_var = tuple->b;
4945         CHECK((((uint64_t)b_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4946         CHECK((((uint64_t)&b_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4947         uint64_t b_ref = (uint64_t)b_var.inner & ~1;
4948         return b_ref;
4949 }
4950 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1c(JNIEnv *env, jclass clz, int64_t ptr) {
4951         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *tuple = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ptr & ~1);
4952         LDKChannelUpdate c_var = tuple->c;
4953         CHECK((((uint64_t)c_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4954         CHECK((((uint64_t)&c_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4955         uint64_t c_ref = (uint64_t)c_var.inner & ~1;
4956         return c_ref;
4957 }
4958 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
4959         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *ret = MALLOC(sizeof(LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ");
4960         ret->datalen = (*env)->GetArrayLength(env, elems);
4961         if (ret->datalen == 0) {
4962                 ret->data = NULL;
4963         } else {
4964                 ret->data = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) * ret->datalen, "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Data");
4965                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
4966                 for (size_t i = 0; i < ret->datalen; i++) {
4967                         int64_t arr_elem = java_elems[i];
4968                         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ arr_elem_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)arr_elem) & ~1);
4969                         arr_elem_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone((LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)arr_elem) & ~1));
4970                         ret->data[i] = arr_elem_conv;
4971                 }
4972                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
4973         }
4974         return (uint64_t)ret;
4975 }
4976 static inline LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone(const LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *orig) {
4977         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret = { .data = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) * orig->datalen, "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ clone bytes"), .datalen = orig->datalen };
4978         for (size_t i = 0; i < ret.datalen; i++) {
4979                 ret.data[i] = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(&orig->data[i]);
4980         }
4981         return ret;
4982 }
4983 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1NodeAnnouncementZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
4984         LDKCVec_NodeAnnouncementZ *ret = MALLOC(sizeof(LDKCVec_NodeAnnouncementZ), "LDKCVec_NodeAnnouncementZ");
4985         ret->datalen = (*env)->GetArrayLength(env, elems);
4986         if (ret->datalen == 0) {
4987                 ret->data = NULL;
4988         } else {
4989                 ret->data = MALLOC(sizeof(LDKNodeAnnouncement) * ret->datalen, "LDKCVec_NodeAnnouncementZ Data");
4990                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
4991                 for (size_t i = 0; i < ret->datalen; i++) {
4992                         int64_t arr_elem = java_elems[i];
4993                         LDKNodeAnnouncement arr_elem_conv;
4994                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
4995                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
4996                         arr_elem_conv = NodeAnnouncement_clone(&arr_elem_conv);
4997                         ret->data[i] = arr_elem_conv;
4998                 }
4999                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
5000         }
5001         return (uint64_t)ret;
5002 }
5003 static inline LDKCVec_NodeAnnouncementZ CVec_NodeAnnouncementZ_clone(const LDKCVec_NodeAnnouncementZ *orig) {
5004         LDKCVec_NodeAnnouncementZ ret = { .data = MALLOC(sizeof(LDKNodeAnnouncement) * orig->datalen, "LDKCVec_NodeAnnouncementZ clone bytes"), .datalen = orig->datalen };
5005         for (size_t i = 0; i < ret.datalen; i++) {
5006                 ret.data[i] = NodeAnnouncement_clone(&orig->data[i]);
5007         }
5008         return ret;
5009 }
5010 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneLightningErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5011         return ((LDKCResult_NoneLightningErrorZ*)arg)->result_ok;
5012 }
5013 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5014         LDKCResult_NoneLightningErrorZ *val = (LDKCResult_NoneLightningErrorZ*)(arg & ~1);
5015         CHECK(val->result_ok);
5016         return *val->contents.result;
5017 }
5018 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5019         LDKCResult_NoneLightningErrorZ *val = (LDKCResult_NoneLightningErrorZ*)(arg & ~1);
5020         CHECK(!val->result_ok);
5021         LDKLightningError err_var = (*val->contents.err);
5022         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5023         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5024         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5025         return err_ref;
5026 }
5027 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1u8ZPeerHandleErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5028         return ((LDKCResult_CVec_u8ZPeerHandleErrorZ*)arg)->result_ok;
5029 }
5030 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1u8ZPeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5031         LDKCResult_CVec_u8ZPeerHandleErrorZ *val = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(arg & ~1);
5032         CHECK(val->result_ok);
5033         LDKCVec_u8Z res_var = (*val->contents.result);
5034         int8_tArray res_arr = (*env)->NewByteArray(env, res_var.datalen);
5035         (*env)->SetByteArrayRegion(env, res_arr, 0, res_var.datalen, res_var.data);
5036         return res_arr;
5037 }
5038 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1u8ZPeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5039         LDKCResult_CVec_u8ZPeerHandleErrorZ *val = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(arg & ~1);
5040         CHECK(!val->result_ok);
5041         LDKPeerHandleError err_var = (*val->contents.err);
5042         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5043         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5044         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5045         return err_ref;
5046 }
5047 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePeerHandleErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5048         return ((LDKCResult_NonePeerHandleErrorZ*)arg)->result_ok;
5049 }
5050 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5051         LDKCResult_NonePeerHandleErrorZ *val = (LDKCResult_NonePeerHandleErrorZ*)(arg & ~1);
5052         CHECK(val->result_ok);
5053         return *val->contents.result;
5054 }
5055 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5056         LDKCResult_NonePeerHandleErrorZ *val = (LDKCResult_NonePeerHandleErrorZ*)(arg & ~1);
5057         CHECK(!val->result_ok);
5058         LDKPeerHandleError err_var = (*val->contents.err);
5059         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5060         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5061         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5062         return err_ref;
5063 }
5064 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolPeerHandleErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5065         return ((LDKCResult_boolPeerHandleErrorZ*)arg)->result_ok;
5066 }
5067 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolPeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5068         LDKCResult_boolPeerHandleErrorZ *val = (LDKCResult_boolPeerHandleErrorZ*)(arg & ~1);
5069         CHECK(val->result_ok);
5070         return *val->contents.result;
5071 }
5072 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolPeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5073         LDKCResult_boolPeerHandleErrorZ *val = (LDKCResult_boolPeerHandleErrorZ*)(arg & ~1);
5074         CHECK(!val->result_ok);
5075         LDKPeerHandleError err_var = (*val->contents.err);
5076         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5077         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5078         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5079         return err_ref;
5080 }
5081 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DirectionalChannelInfoDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5082         return ((LDKCResult_DirectionalChannelInfoDecodeErrorZ*)arg)->result_ok;
5083 }
5084 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DirectionalChannelInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5085         LDKCResult_DirectionalChannelInfoDecodeErrorZ *val = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(arg & ~1);
5086         CHECK(val->result_ok);
5087         LDKDirectionalChannelInfo res_var = (*val->contents.result);
5088         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5089         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5090         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5091         return res_ref;
5092 }
5093 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DirectionalChannelInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5094         LDKCResult_DirectionalChannelInfoDecodeErrorZ *val = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(arg & ~1);
5095         CHECK(!val->result_ok);
5096         LDKDecodeError err_var = (*val->contents.err);
5097         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5098         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5099         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5100         return err_ref;
5101 }
5102 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelInfoDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5103         return ((LDKCResult_ChannelInfoDecodeErrorZ*)arg)->result_ok;
5104 }
5105 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5106         LDKCResult_ChannelInfoDecodeErrorZ *val = (LDKCResult_ChannelInfoDecodeErrorZ*)(arg & ~1);
5107         CHECK(val->result_ok);
5108         LDKChannelInfo res_var = (*val->contents.result);
5109         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5110         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5111         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5112         return res_ref;
5113 }
5114 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5115         LDKCResult_ChannelInfoDecodeErrorZ *val = (LDKCResult_ChannelInfoDecodeErrorZ*)(arg & ~1);
5116         CHECK(!val->result_ok);
5117         LDKDecodeError err_var = (*val->contents.err);
5118         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5119         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5120         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5121         return err_ref;
5122 }
5123 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RoutingFeesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5124         return ((LDKCResult_RoutingFeesDecodeErrorZ*)arg)->result_ok;
5125 }
5126 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RoutingFeesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5127         LDKCResult_RoutingFeesDecodeErrorZ *val = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
5128         CHECK(val->result_ok);
5129         LDKRoutingFees res_var = (*val->contents.result);
5130         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5131         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5132         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5133         return res_ref;
5134 }
5135 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RoutingFeesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5136         LDKCResult_RoutingFeesDecodeErrorZ *val = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
5137         CHECK(!val->result_ok);
5138         LDKDecodeError err_var = (*val->contents.err);
5139         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5140         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5141         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5142         return err_ref;
5143 }
5144 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementInfoDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5145         return ((LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)arg)->result_ok;
5146 }
5147 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5148         LDKCResult_NodeAnnouncementInfoDecodeErrorZ *val = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
5149         CHECK(val->result_ok);
5150         LDKNodeAnnouncementInfo res_var = (*val->contents.result);
5151         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5152         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5153         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5154         return res_ref;
5155 }
5156 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5157         LDKCResult_NodeAnnouncementInfoDecodeErrorZ *val = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
5158         CHECK(!val->result_ok);
5159         LDKDecodeError err_var = (*val->contents.err);
5160         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5161         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5162         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5163         return err_ref;
5164 }
5165 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1u64Z_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
5166         LDKCVec_u64Z *ret = MALLOC(sizeof(LDKCVec_u64Z), "LDKCVec_u64Z");
5167         ret->datalen = (*env)->GetArrayLength(env, elems);
5168         if (ret->datalen == 0) {
5169                 ret->data = NULL;
5170         } else {
5171                 ret->data = MALLOC(sizeof(uint64_t) * ret->datalen, "LDKCVec_u64Z Data");
5172                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
5173                 for (size_t i = 0; i < ret->datalen; i++) {
5174                         ret->data[i] = java_elems[i];
5175                 }
5176                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
5177         }
5178         return (uint64_t)ret;
5179 }
5180 static inline LDKCVec_u64Z CVec_u64Z_clone(const LDKCVec_u64Z *orig) {
5181         LDKCVec_u64Z ret = { .data = MALLOC(sizeof(int64_t) * orig->datalen, "LDKCVec_u64Z clone bytes"), .datalen = orig->datalen };
5182         memcpy(ret.data, orig->data, sizeof(int64_t) * ret.datalen);
5183         return ret;
5184 }
5185 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeInfoDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5186         return ((LDKCResult_NodeInfoDecodeErrorZ*)arg)->result_ok;
5187 }
5188 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5189         LDKCResult_NodeInfoDecodeErrorZ *val = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
5190         CHECK(val->result_ok);
5191         LDKNodeInfo res_var = (*val->contents.result);
5192         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5193         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5194         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5195         return res_ref;
5196 }
5197 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5198         LDKCResult_NodeInfoDecodeErrorZ *val = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
5199         CHECK(!val->result_ok);
5200         LDKDecodeError err_var = (*val->contents.err);
5201         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5202         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5203         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5204         return err_ref;
5205 }
5206 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetworkGraphDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5207         return ((LDKCResult_NetworkGraphDecodeErrorZ*)arg)->result_ok;
5208 }
5209 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetworkGraphDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5210         LDKCResult_NetworkGraphDecodeErrorZ *val = (LDKCResult_NetworkGraphDecodeErrorZ*)(arg & ~1);
5211         CHECK(val->result_ok);
5212         LDKNetworkGraph res_var = (*val->contents.result);
5213         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5214         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5215         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5216         return res_ref;
5217 }
5218 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetworkGraphDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5219         LDKCResult_NetworkGraphDecodeErrorZ *val = (LDKCResult_NetworkGraphDecodeErrorZ*)(arg & ~1);
5220         CHECK(!val->result_ok);
5221         LDKDecodeError err_var = (*val->contents.err);
5222         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5223         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5224         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5225         return err_ref;
5226 }
5227 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressu8Z_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5228         return ((LDKCResult_NetAddressu8Z*)arg)->result_ok;
5229 }
5230 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressu8Z_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5231         LDKCResult_NetAddressu8Z *val = (LDKCResult_NetAddressu8Z*)(arg & ~1);
5232         CHECK(val->result_ok);
5233         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
5234         return res_ref;
5235 }
5236 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressu8Z_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5237         LDKCResult_NetAddressu8Z *val = (LDKCResult_NetAddressu8Z*)(arg & ~1);
5238         CHECK(!val->result_ok);
5239         return *val->contents.err;
5240 }
5241 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CResult_1NetAddressu8ZDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5242         return ((LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)arg)->result_ok;
5243 }
5244 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CResult_1NetAddressu8ZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5245         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ *val = (LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(arg & ~1);
5246         CHECK(val->result_ok);
5247         LDKCResult_NetAddressu8Z* res_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
5248         *res_conv = (*val->contents.result);
5249         *res_conv = CResult_NetAddressu8Z_clone(res_conv);
5250         return (uint64_t)res_conv;
5251 }
5252 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CResult_1NetAddressu8ZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5253         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ *val = (LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(arg & ~1);
5254         CHECK(!val->result_ok);
5255         LDKDecodeError err_var = (*val->contents.err);
5256         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5257         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5258         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5259         return err_ref;
5260 }
5261 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5262         return ((LDKCResult_NetAddressDecodeErrorZ*)arg)->result_ok;
5263 }
5264 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5265         LDKCResult_NetAddressDecodeErrorZ *val = (LDKCResult_NetAddressDecodeErrorZ*)(arg & ~1);
5266         CHECK(val->result_ok);
5267         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
5268         return res_ref;
5269 }
5270 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5271         LDKCResult_NetAddressDecodeErrorZ *val = (LDKCResult_NetAddressDecodeErrorZ*)(arg & ~1);
5272         CHECK(!val->result_ok);
5273         LDKDecodeError err_var = (*val->contents.err);
5274         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5275         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5276         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5277         return err_ref;
5278 }
5279 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1UpdateAddHTLCZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
5280         LDKCVec_UpdateAddHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateAddHTLCZ), "LDKCVec_UpdateAddHTLCZ");
5281         ret->datalen = (*env)->GetArrayLength(env, elems);
5282         if (ret->datalen == 0) {
5283                 ret->data = NULL;
5284         } else {
5285                 ret->data = MALLOC(sizeof(LDKUpdateAddHTLC) * ret->datalen, "LDKCVec_UpdateAddHTLCZ Data");
5286                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
5287                 for (size_t i = 0; i < ret->datalen; i++) {
5288                         int64_t arr_elem = java_elems[i];
5289                         LDKUpdateAddHTLC arr_elem_conv;
5290                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
5291                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
5292                         arr_elem_conv = UpdateAddHTLC_clone(&arr_elem_conv);
5293                         ret->data[i] = arr_elem_conv;
5294                 }
5295                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
5296         }
5297         return (uint64_t)ret;
5298 }
5299 static inline LDKCVec_UpdateAddHTLCZ CVec_UpdateAddHTLCZ_clone(const LDKCVec_UpdateAddHTLCZ *orig) {
5300         LDKCVec_UpdateAddHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateAddHTLC) * orig->datalen, "LDKCVec_UpdateAddHTLCZ clone bytes"), .datalen = orig->datalen };
5301         for (size_t i = 0; i < ret.datalen; i++) {
5302                 ret.data[i] = UpdateAddHTLC_clone(&orig->data[i]);
5303         }
5304         return ret;
5305 }
5306 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1UpdateFulfillHTLCZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
5307         LDKCVec_UpdateFulfillHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateFulfillHTLCZ), "LDKCVec_UpdateFulfillHTLCZ");
5308         ret->datalen = (*env)->GetArrayLength(env, elems);
5309         if (ret->datalen == 0) {
5310                 ret->data = NULL;
5311         } else {
5312                 ret->data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * ret->datalen, "LDKCVec_UpdateFulfillHTLCZ Data");
5313                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
5314                 for (size_t i = 0; i < ret->datalen; i++) {
5315                         int64_t arr_elem = java_elems[i];
5316                         LDKUpdateFulfillHTLC arr_elem_conv;
5317                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
5318                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
5319                         arr_elem_conv = UpdateFulfillHTLC_clone(&arr_elem_conv);
5320                         ret->data[i] = arr_elem_conv;
5321                 }
5322                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
5323         }
5324         return (uint64_t)ret;
5325 }
5326 static inline LDKCVec_UpdateFulfillHTLCZ CVec_UpdateFulfillHTLCZ_clone(const LDKCVec_UpdateFulfillHTLCZ *orig) {
5327         LDKCVec_UpdateFulfillHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * orig->datalen, "LDKCVec_UpdateFulfillHTLCZ clone bytes"), .datalen = orig->datalen };
5328         for (size_t i = 0; i < ret.datalen; i++) {
5329                 ret.data[i] = UpdateFulfillHTLC_clone(&orig->data[i]);
5330         }
5331         return ret;
5332 }
5333 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1UpdateFailHTLCZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
5334         LDKCVec_UpdateFailHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateFailHTLCZ), "LDKCVec_UpdateFailHTLCZ");
5335         ret->datalen = (*env)->GetArrayLength(env, elems);
5336         if (ret->datalen == 0) {
5337                 ret->data = NULL;
5338         } else {
5339                 ret->data = MALLOC(sizeof(LDKUpdateFailHTLC) * ret->datalen, "LDKCVec_UpdateFailHTLCZ Data");
5340                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
5341                 for (size_t i = 0; i < ret->datalen; i++) {
5342                         int64_t arr_elem = java_elems[i];
5343                         LDKUpdateFailHTLC arr_elem_conv;
5344                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
5345                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
5346                         arr_elem_conv = UpdateFailHTLC_clone(&arr_elem_conv);
5347                         ret->data[i] = arr_elem_conv;
5348                 }
5349                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
5350         }
5351         return (uint64_t)ret;
5352 }
5353 static inline LDKCVec_UpdateFailHTLCZ CVec_UpdateFailHTLCZ_clone(const LDKCVec_UpdateFailHTLCZ *orig) {
5354         LDKCVec_UpdateFailHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailHTLC) * orig->datalen, "LDKCVec_UpdateFailHTLCZ clone bytes"), .datalen = orig->datalen };
5355         for (size_t i = 0; i < ret.datalen; i++) {
5356                 ret.data[i] = UpdateFailHTLC_clone(&orig->data[i]);
5357         }
5358         return ret;
5359 }
5360 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1UpdateFailMalformedHTLCZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
5361         LDKCVec_UpdateFailMalformedHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateFailMalformedHTLCZ), "LDKCVec_UpdateFailMalformedHTLCZ");
5362         ret->datalen = (*env)->GetArrayLength(env, elems);
5363         if (ret->datalen == 0) {
5364                 ret->data = NULL;
5365         } else {
5366                 ret->data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * ret->datalen, "LDKCVec_UpdateFailMalformedHTLCZ Data");
5367                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
5368                 for (size_t i = 0; i < ret->datalen; i++) {
5369                         int64_t arr_elem = java_elems[i];
5370                         LDKUpdateFailMalformedHTLC arr_elem_conv;
5371                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
5372                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
5373                         arr_elem_conv = UpdateFailMalformedHTLC_clone(&arr_elem_conv);
5374                         ret->data[i] = arr_elem_conv;
5375                 }
5376                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
5377         }
5378         return (uint64_t)ret;
5379 }
5380 static inline LDKCVec_UpdateFailMalformedHTLCZ CVec_UpdateFailMalformedHTLCZ_clone(const LDKCVec_UpdateFailMalformedHTLCZ *orig) {
5381         LDKCVec_UpdateFailMalformedHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * orig->datalen, "LDKCVec_UpdateFailMalformedHTLCZ clone bytes"), .datalen = orig->datalen };
5382         for (size_t i = 0; i < ret.datalen; i++) {
5383                 ret.data[i] = UpdateFailMalformedHTLC_clone(&orig->data[i]);
5384         }
5385         return ret;
5386 }
5387 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AcceptChannelDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5388         return ((LDKCResult_AcceptChannelDecodeErrorZ*)arg)->result_ok;
5389 }
5390 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AcceptChannelDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5391         LDKCResult_AcceptChannelDecodeErrorZ *val = (LDKCResult_AcceptChannelDecodeErrorZ*)(arg & ~1);
5392         CHECK(val->result_ok);
5393         LDKAcceptChannel res_var = (*val->contents.result);
5394         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5395         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5396         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5397         return res_ref;
5398 }
5399 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AcceptChannelDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5400         LDKCResult_AcceptChannelDecodeErrorZ *val = (LDKCResult_AcceptChannelDecodeErrorZ*)(arg & ~1);
5401         CHECK(!val->result_ok);
5402         LDKDecodeError err_var = (*val->contents.err);
5403         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5404         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5405         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5406         return err_ref;
5407 }
5408 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AnnouncementSignaturesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5409         return ((LDKCResult_AnnouncementSignaturesDecodeErrorZ*)arg)->result_ok;
5410 }
5411 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AnnouncementSignaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5412         LDKCResult_AnnouncementSignaturesDecodeErrorZ *val = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(arg & ~1);
5413         CHECK(val->result_ok);
5414         LDKAnnouncementSignatures res_var = (*val->contents.result);
5415         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5416         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5417         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5418         return res_ref;
5419 }
5420 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AnnouncementSignaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5421         LDKCResult_AnnouncementSignaturesDecodeErrorZ *val = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(arg & ~1);
5422         CHECK(!val->result_ok);
5423         LDKDecodeError err_var = (*val->contents.err);
5424         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5425         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5426         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5427         return err_ref;
5428 }
5429 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelReestablishDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5430         return ((LDKCResult_ChannelReestablishDecodeErrorZ*)arg)->result_ok;
5431 }
5432 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelReestablishDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5433         LDKCResult_ChannelReestablishDecodeErrorZ *val = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
5434         CHECK(val->result_ok);
5435         LDKChannelReestablish res_var = (*val->contents.result);
5436         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5437         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5438         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5439         return res_ref;
5440 }
5441 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelReestablishDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5442         LDKCResult_ChannelReestablishDecodeErrorZ *val = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
5443         CHECK(!val->result_ok);
5444         LDKDecodeError err_var = (*val->contents.err);
5445         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5446         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5447         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5448         return err_ref;
5449 }
5450 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ClosingSignedDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5451         return ((LDKCResult_ClosingSignedDecodeErrorZ*)arg)->result_ok;
5452 }
5453 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ClosingSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5454         LDKCResult_ClosingSignedDecodeErrorZ *val = (LDKCResult_ClosingSignedDecodeErrorZ*)(arg & ~1);
5455         CHECK(val->result_ok);
5456         LDKClosingSigned res_var = (*val->contents.result);
5457         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5458         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5459         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5460         return res_ref;
5461 }
5462 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ClosingSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5463         LDKCResult_ClosingSignedDecodeErrorZ *val = (LDKCResult_ClosingSignedDecodeErrorZ*)(arg & ~1);
5464         CHECK(!val->result_ok);
5465         LDKDecodeError err_var = (*val->contents.err);
5466         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5467         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5468         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5469         return err_ref;
5470 }
5471 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentSignedDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5472         return ((LDKCResult_CommitmentSignedDecodeErrorZ*)arg)->result_ok;
5473 }
5474 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5475         LDKCResult_CommitmentSignedDecodeErrorZ *val = (LDKCResult_CommitmentSignedDecodeErrorZ*)(arg & ~1);
5476         CHECK(val->result_ok);
5477         LDKCommitmentSigned res_var = (*val->contents.result);
5478         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5479         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5480         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5481         return res_ref;
5482 }
5483 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5484         LDKCResult_CommitmentSignedDecodeErrorZ *val = (LDKCResult_CommitmentSignedDecodeErrorZ*)(arg & ~1);
5485         CHECK(!val->result_ok);
5486         LDKDecodeError err_var = (*val->contents.err);
5487         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5488         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5489         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5490         return err_ref;
5491 }
5492 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingCreatedDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5493         return ((LDKCResult_FundingCreatedDecodeErrorZ*)arg)->result_ok;
5494 }
5495 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingCreatedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5496         LDKCResult_FundingCreatedDecodeErrorZ *val = (LDKCResult_FundingCreatedDecodeErrorZ*)(arg & ~1);
5497         CHECK(val->result_ok);
5498         LDKFundingCreated res_var = (*val->contents.result);
5499         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5500         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5501         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5502         return res_ref;
5503 }
5504 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingCreatedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5505         LDKCResult_FundingCreatedDecodeErrorZ *val = (LDKCResult_FundingCreatedDecodeErrorZ*)(arg & ~1);
5506         CHECK(!val->result_ok);
5507         LDKDecodeError err_var = (*val->contents.err);
5508         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5509         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5510         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5511         return err_ref;
5512 }
5513 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingSignedDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5514         return ((LDKCResult_FundingSignedDecodeErrorZ*)arg)->result_ok;
5515 }
5516 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5517         LDKCResult_FundingSignedDecodeErrorZ *val = (LDKCResult_FundingSignedDecodeErrorZ*)(arg & ~1);
5518         CHECK(val->result_ok);
5519         LDKFundingSigned res_var = (*val->contents.result);
5520         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5521         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5522         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5523         return res_ref;
5524 }
5525 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5526         LDKCResult_FundingSignedDecodeErrorZ *val = (LDKCResult_FundingSignedDecodeErrorZ*)(arg & ~1);
5527         CHECK(!val->result_ok);
5528         LDKDecodeError err_var = (*val->contents.err);
5529         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5530         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5531         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5532         return err_ref;
5533 }
5534 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingLockedDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5535         return ((LDKCResult_FundingLockedDecodeErrorZ*)arg)->result_ok;
5536 }
5537 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingLockedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5538         LDKCResult_FundingLockedDecodeErrorZ *val = (LDKCResult_FundingLockedDecodeErrorZ*)(arg & ~1);
5539         CHECK(val->result_ok);
5540         LDKFundingLocked res_var = (*val->contents.result);
5541         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5542         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5543         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5544         return res_ref;
5545 }
5546 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingLockedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5547         LDKCResult_FundingLockedDecodeErrorZ *val = (LDKCResult_FundingLockedDecodeErrorZ*)(arg & ~1);
5548         CHECK(!val->result_ok);
5549         LDKDecodeError err_var = (*val->contents.err);
5550         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5551         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5552         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5553         return err_ref;
5554 }
5555 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5556         return ((LDKCResult_InitDecodeErrorZ*)arg)->result_ok;
5557 }
5558 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5559         LDKCResult_InitDecodeErrorZ *val = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
5560         CHECK(val->result_ok);
5561         LDKInit res_var = (*val->contents.result);
5562         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5563         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5564         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5565         return res_ref;
5566 }
5567 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5568         LDKCResult_InitDecodeErrorZ *val = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
5569         CHECK(!val->result_ok);
5570         LDKDecodeError err_var = (*val->contents.err);
5571         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5572         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5573         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5574         return err_ref;
5575 }
5576 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OpenChannelDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5577         return ((LDKCResult_OpenChannelDecodeErrorZ*)arg)->result_ok;
5578 }
5579 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OpenChannelDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5580         LDKCResult_OpenChannelDecodeErrorZ *val = (LDKCResult_OpenChannelDecodeErrorZ*)(arg & ~1);
5581         CHECK(val->result_ok);
5582         LDKOpenChannel res_var = (*val->contents.result);
5583         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5584         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5585         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5586         return res_ref;
5587 }
5588 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OpenChannelDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5589         LDKCResult_OpenChannelDecodeErrorZ *val = (LDKCResult_OpenChannelDecodeErrorZ*)(arg & ~1);
5590         CHECK(!val->result_ok);
5591         LDKDecodeError err_var = (*val->contents.err);
5592         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5593         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5594         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5595         return err_ref;
5596 }
5597 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RevokeAndACKDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5598         return ((LDKCResult_RevokeAndACKDecodeErrorZ*)arg)->result_ok;
5599 }
5600 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RevokeAndACKDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5601         LDKCResult_RevokeAndACKDecodeErrorZ *val = (LDKCResult_RevokeAndACKDecodeErrorZ*)(arg & ~1);
5602         CHECK(val->result_ok);
5603         LDKRevokeAndACK res_var = (*val->contents.result);
5604         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5605         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5606         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5607         return res_ref;
5608 }
5609 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RevokeAndACKDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5610         LDKCResult_RevokeAndACKDecodeErrorZ *val = (LDKCResult_RevokeAndACKDecodeErrorZ*)(arg & ~1);
5611         CHECK(!val->result_ok);
5612         LDKDecodeError err_var = (*val->contents.err);
5613         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5614         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5615         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5616         return err_ref;
5617 }
5618 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5619         return ((LDKCResult_ShutdownDecodeErrorZ*)arg)->result_ok;
5620 }
5621 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5622         LDKCResult_ShutdownDecodeErrorZ *val = (LDKCResult_ShutdownDecodeErrorZ*)(arg & ~1);
5623         CHECK(val->result_ok);
5624         LDKShutdown res_var = (*val->contents.result);
5625         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5626         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5627         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5628         return res_ref;
5629 }
5630 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5631         LDKCResult_ShutdownDecodeErrorZ *val = (LDKCResult_ShutdownDecodeErrorZ*)(arg & ~1);
5632         CHECK(!val->result_ok);
5633         LDKDecodeError err_var = (*val->contents.err);
5634         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5635         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5636         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5637         return err_ref;
5638 }
5639 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailHTLCDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5640         return ((LDKCResult_UpdateFailHTLCDecodeErrorZ*)arg)->result_ok;
5641 }
5642 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5643         LDKCResult_UpdateFailHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(arg & ~1);
5644         CHECK(val->result_ok);
5645         LDKUpdateFailHTLC res_var = (*val->contents.result);
5646         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5647         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5648         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5649         return res_ref;
5650 }
5651 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5652         LDKCResult_UpdateFailHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(arg & ~1);
5653         CHECK(!val->result_ok);
5654         LDKDecodeError err_var = (*val->contents.err);
5655         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5656         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5657         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5658         return err_ref;
5659 }
5660 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailMalformedHTLCDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5661         return ((LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)arg)->result_ok;
5662 }
5663 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailMalformedHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5664         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(arg & ~1);
5665         CHECK(val->result_ok);
5666         LDKUpdateFailMalformedHTLC res_var = (*val->contents.result);
5667         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5668         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5669         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5670         return res_ref;
5671 }
5672 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailMalformedHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5673         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(arg & ~1);
5674         CHECK(!val->result_ok);
5675         LDKDecodeError err_var = (*val->contents.err);
5676         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5677         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5678         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5679         return err_ref;
5680 }
5681 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFeeDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5682         return ((LDKCResult_UpdateFeeDecodeErrorZ*)arg)->result_ok;
5683 }
5684 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFeeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5685         LDKCResult_UpdateFeeDecodeErrorZ *val = (LDKCResult_UpdateFeeDecodeErrorZ*)(arg & ~1);
5686         CHECK(val->result_ok);
5687         LDKUpdateFee res_var = (*val->contents.result);
5688         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5689         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5690         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5691         return res_ref;
5692 }
5693 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFeeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5694         LDKCResult_UpdateFeeDecodeErrorZ *val = (LDKCResult_UpdateFeeDecodeErrorZ*)(arg & ~1);
5695         CHECK(!val->result_ok);
5696         LDKDecodeError err_var = (*val->contents.err);
5697         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5698         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5699         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5700         return err_ref;
5701 }
5702 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFulfillHTLCDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5703         return ((LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)arg)->result_ok;
5704 }
5705 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFulfillHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5706         LDKCResult_UpdateFulfillHTLCDecodeErrorZ *val = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(arg & ~1);
5707         CHECK(val->result_ok);
5708         LDKUpdateFulfillHTLC res_var = (*val->contents.result);
5709         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5710         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5711         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5712         return res_ref;
5713 }
5714 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFulfillHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5715         LDKCResult_UpdateFulfillHTLCDecodeErrorZ *val = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(arg & ~1);
5716         CHECK(!val->result_ok);
5717         LDKDecodeError err_var = (*val->contents.err);
5718         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5719         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5720         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5721         return err_ref;
5722 }
5723 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateAddHTLCDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5724         return ((LDKCResult_UpdateAddHTLCDecodeErrorZ*)arg)->result_ok;
5725 }
5726 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateAddHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5727         LDKCResult_UpdateAddHTLCDecodeErrorZ *val = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(arg & ~1);
5728         CHECK(val->result_ok);
5729         LDKUpdateAddHTLC res_var = (*val->contents.result);
5730         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5731         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5732         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5733         return res_ref;
5734 }
5735 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateAddHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5736         LDKCResult_UpdateAddHTLCDecodeErrorZ *val = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(arg & ~1);
5737         CHECK(!val->result_ok);
5738         LDKDecodeError err_var = (*val->contents.err);
5739         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5740         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5741         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5742         return err_ref;
5743 }
5744 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PingDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5745         return ((LDKCResult_PingDecodeErrorZ*)arg)->result_ok;
5746 }
5747 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PingDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5748         LDKCResult_PingDecodeErrorZ *val = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
5749         CHECK(val->result_ok);
5750         LDKPing res_var = (*val->contents.result);
5751         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5752         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5753         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5754         return res_ref;
5755 }
5756 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PingDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5757         LDKCResult_PingDecodeErrorZ *val = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
5758         CHECK(!val->result_ok);
5759         LDKDecodeError err_var = (*val->contents.err);
5760         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5761         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5762         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5763         return err_ref;
5764 }
5765 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PongDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5766         return ((LDKCResult_PongDecodeErrorZ*)arg)->result_ok;
5767 }
5768 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PongDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5769         LDKCResult_PongDecodeErrorZ *val = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
5770         CHECK(val->result_ok);
5771         LDKPong res_var = (*val->contents.result);
5772         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5773         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5774         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5775         return res_ref;
5776 }
5777 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PongDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5778         LDKCResult_PongDecodeErrorZ *val = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
5779         CHECK(!val->result_ok);
5780         LDKDecodeError err_var = (*val->contents.err);
5781         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5782         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5783         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5784         return err_ref;
5785 }
5786 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelAnnouncementDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5787         return ((LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)arg)->result_ok;
5788 }
5789 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5790         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
5791         CHECK(val->result_ok);
5792         LDKUnsignedChannelAnnouncement res_var = (*val->contents.result);
5793         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5794         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5795         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5796         return res_ref;
5797 }
5798 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5799         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
5800         CHECK(!val->result_ok);
5801         LDKDecodeError err_var = (*val->contents.err);
5802         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5803         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5804         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5805         return err_ref;
5806 }
5807 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelAnnouncementDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5808         return ((LDKCResult_ChannelAnnouncementDecodeErrorZ*)arg)->result_ok;
5809 }
5810 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5811         LDKCResult_ChannelAnnouncementDecodeErrorZ *val = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(arg & ~1);
5812         CHECK(val->result_ok);
5813         LDKChannelAnnouncement res_var = (*val->contents.result);
5814         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5815         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5816         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5817         return res_ref;
5818 }
5819 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5820         LDKCResult_ChannelAnnouncementDecodeErrorZ *val = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(arg & ~1);
5821         CHECK(!val->result_ok);
5822         LDKDecodeError err_var = (*val->contents.err);
5823         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5824         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5825         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5826         return err_ref;
5827 }
5828 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelUpdateDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5829         return ((LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)arg)->result_ok;
5830 }
5831 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5832         LDKCResult_UnsignedChannelUpdateDecodeErrorZ *val = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
5833         CHECK(val->result_ok);
5834         LDKUnsignedChannelUpdate res_var = (*val->contents.result);
5835         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5836         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5837         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5838         return res_ref;
5839 }
5840 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5841         LDKCResult_UnsignedChannelUpdateDecodeErrorZ *val = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
5842         CHECK(!val->result_ok);
5843         LDKDecodeError err_var = (*val->contents.err);
5844         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5845         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5846         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5847         return err_ref;
5848 }
5849 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelUpdateDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5850         return ((LDKCResult_ChannelUpdateDecodeErrorZ*)arg)->result_ok;
5851 }
5852 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5853         LDKCResult_ChannelUpdateDecodeErrorZ *val = (LDKCResult_ChannelUpdateDecodeErrorZ*)(arg & ~1);
5854         CHECK(val->result_ok);
5855         LDKChannelUpdate res_var = (*val->contents.result);
5856         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5857         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5858         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5859         return res_ref;
5860 }
5861 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5862         LDKCResult_ChannelUpdateDecodeErrorZ *val = (LDKCResult_ChannelUpdateDecodeErrorZ*)(arg & ~1);
5863         CHECK(!val->result_ok);
5864         LDKDecodeError err_var = (*val->contents.err);
5865         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5866         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5867         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5868         return err_ref;
5869 }
5870 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ErrorMessageDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5871         return ((LDKCResult_ErrorMessageDecodeErrorZ*)arg)->result_ok;
5872 }
5873 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ErrorMessageDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5874         LDKCResult_ErrorMessageDecodeErrorZ *val = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
5875         CHECK(val->result_ok);
5876         LDKErrorMessage res_var = (*val->contents.result);
5877         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5878         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5879         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5880         return res_ref;
5881 }
5882 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ErrorMessageDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5883         LDKCResult_ErrorMessageDecodeErrorZ *val = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
5884         CHECK(!val->result_ok);
5885         LDKDecodeError err_var = (*val->contents.err);
5886         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5887         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5888         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5889         return err_ref;
5890 }
5891 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedNodeAnnouncementDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5892         return ((LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)arg)->result_ok;
5893 }
5894 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedNodeAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5895         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
5896         CHECK(val->result_ok);
5897         LDKUnsignedNodeAnnouncement res_var = (*val->contents.result);
5898         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5899         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5900         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5901         return res_ref;
5902 }
5903 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedNodeAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5904         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
5905         CHECK(!val->result_ok);
5906         LDKDecodeError err_var = (*val->contents.err);
5907         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5908         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5909         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5910         return err_ref;
5911 }
5912 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5913         return ((LDKCResult_NodeAnnouncementDecodeErrorZ*)arg)->result_ok;
5914 }
5915 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5916         LDKCResult_NodeAnnouncementDecodeErrorZ *val = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(arg & ~1);
5917         CHECK(val->result_ok);
5918         LDKNodeAnnouncement res_var = (*val->contents.result);
5919         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5920         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5921         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5922         return res_ref;
5923 }
5924 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5925         LDKCResult_NodeAnnouncementDecodeErrorZ *val = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(arg & ~1);
5926         CHECK(!val->result_ok);
5927         LDKDecodeError err_var = (*val->contents.err);
5928         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5929         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5930         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5931         return err_ref;
5932 }
5933 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryShortChannelIdsDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5934         return ((LDKCResult_QueryShortChannelIdsDecodeErrorZ*)arg)->result_ok;
5935 }
5936 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryShortChannelIdsDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5937         LDKCResult_QueryShortChannelIdsDecodeErrorZ *val = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
5938         CHECK(val->result_ok);
5939         LDKQueryShortChannelIds res_var = (*val->contents.result);
5940         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5941         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5942         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5943         return res_ref;
5944 }
5945 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryShortChannelIdsDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5946         LDKCResult_QueryShortChannelIdsDecodeErrorZ *val = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
5947         CHECK(!val->result_ok);
5948         LDKDecodeError err_var = (*val->contents.err);
5949         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5950         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5951         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5952         return err_ref;
5953 }
5954 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyShortChannelIdsEndDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5955         return ((LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)arg)->result_ok;
5956 }
5957 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyShortChannelIdsEndDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5958         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *val = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
5959         CHECK(val->result_ok);
5960         LDKReplyShortChannelIdsEnd res_var = (*val->contents.result);
5961         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5962         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5963         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5964         return res_ref;
5965 }
5966 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyShortChannelIdsEndDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5967         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *val = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
5968         CHECK(!val->result_ok);
5969         LDKDecodeError err_var = (*val->contents.err);
5970         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5971         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5972         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5973         return err_ref;
5974 }
5975 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryChannelRangeDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5976         return ((LDKCResult_QueryChannelRangeDecodeErrorZ*)arg)->result_ok;
5977 }
5978 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryChannelRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5979         LDKCResult_QueryChannelRangeDecodeErrorZ *val = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
5980         CHECK(val->result_ok);
5981         LDKQueryChannelRange res_var = (*val->contents.result);
5982         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5983         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5984         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5985         return res_ref;
5986 }
5987 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryChannelRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5988         LDKCResult_QueryChannelRangeDecodeErrorZ *val = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
5989         CHECK(!val->result_ok);
5990         LDKDecodeError err_var = (*val->contents.err);
5991         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5992         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5993         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5994         return err_ref;
5995 }
5996 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyChannelRangeDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5997         return ((LDKCResult_ReplyChannelRangeDecodeErrorZ*)arg)->result_ok;
5998 }
5999 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyChannelRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6000         LDKCResult_ReplyChannelRangeDecodeErrorZ *val = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
6001         CHECK(val->result_ok);
6002         LDKReplyChannelRange res_var = (*val->contents.result);
6003         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6004         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6005         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6006         return res_ref;
6007 }
6008 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyChannelRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6009         LDKCResult_ReplyChannelRangeDecodeErrorZ *val = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
6010         CHECK(!val->result_ok);
6011         LDKDecodeError err_var = (*val->contents.err);
6012         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6013         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6014         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6015         return err_ref;
6016 }
6017 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1GossipTimestampFilterDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6018         return ((LDKCResult_GossipTimestampFilterDecodeErrorZ*)arg)->result_ok;
6019 }
6020 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1GossipTimestampFilterDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6021         LDKCResult_GossipTimestampFilterDecodeErrorZ *val = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
6022         CHECK(val->result_ok);
6023         LDKGossipTimestampFilter res_var = (*val->contents.result);
6024         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6025         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6026         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6027         return res_ref;
6028 }
6029 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1GossipTimestampFilterDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6030         LDKCResult_GossipTimestampFilterDecodeErrorZ *val = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
6031         CHECK(!val->result_ok);
6032         LDKDecodeError err_var = (*val->contents.err);
6033         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6034         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6035         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6036         return err_ref;
6037 }
6038 static jclass LDKSignOrCreationError_SignError_class = NULL;
6039 static jmethodID LDKSignOrCreationError_SignError_meth = NULL;
6040 static jclass LDKSignOrCreationError_CreationError_class = NULL;
6041 static jmethodID LDKSignOrCreationError_CreationError_meth = NULL;
6042 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKSignOrCreationError_init (JNIEnv *env, jclass clz) {
6043         LDKSignOrCreationError_SignError_class =
6044                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKSignOrCreationError$SignError;"));
6045         CHECK(LDKSignOrCreationError_SignError_class != NULL);
6046         LDKSignOrCreationError_SignError_meth = (*env)->GetMethodID(env, LDKSignOrCreationError_SignError_class, "<init>", "()V");
6047         CHECK(LDKSignOrCreationError_SignError_meth != NULL);
6048         LDKSignOrCreationError_CreationError_class =
6049                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKSignOrCreationError$CreationError;"));
6050         CHECK(LDKSignOrCreationError_CreationError_class != NULL);
6051         LDKSignOrCreationError_CreationError_meth = (*env)->GetMethodID(env, LDKSignOrCreationError_CreationError_class, "<init>", "(Lorg/ldk/enums/CreationError;)V");
6052         CHECK(LDKSignOrCreationError_CreationError_meth != NULL);
6053 }
6054 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKSignOrCreationError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
6055         LDKSignOrCreationError *obj = (LDKSignOrCreationError*)(ptr & ~1);
6056         switch(obj->tag) {
6057                 case LDKSignOrCreationError_SignError: {
6058                         return (*env)->NewObject(env, LDKSignOrCreationError_SignError_class, LDKSignOrCreationError_SignError_meth);
6059                 }
6060                 case LDKSignOrCreationError_CreationError: {
6061                         jclass creation_error_conv = LDKCreationError_to_java(env, obj->creation_error);
6062                         return (*env)->NewObject(env, LDKSignOrCreationError_CreationError_class, LDKSignOrCreationError_CreationError_meth, creation_error_conv);
6063                 }
6064                 default: abort();
6065         }
6066 }
6067 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceSignOrCreationErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6068         return ((LDKCResult_InvoiceSignOrCreationErrorZ*)arg)->result_ok;
6069 }
6070 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceSignOrCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6071         LDKCResult_InvoiceSignOrCreationErrorZ *val = (LDKCResult_InvoiceSignOrCreationErrorZ*)(arg & ~1);
6072         CHECK(val->result_ok);
6073         LDKInvoice res_var = (*val->contents.result);
6074         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6075         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6076         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6077         return res_ref;
6078 }
6079 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceSignOrCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6080         LDKCResult_InvoiceSignOrCreationErrorZ *val = (LDKCResult_InvoiceSignOrCreationErrorZ*)(arg & ~1);
6081         CHECK(!val->result_ok);
6082         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
6083         return err_ref;
6084 }
6085 typedef struct LDKMessageSendEventsProvider_JCalls {
6086         atomic_size_t refcnt;
6087         JavaVM *vm;
6088         jweak o;
6089         jmethodID get_and_clear_pending_msg_events_meth;
6090 } LDKMessageSendEventsProvider_JCalls;
6091 static void LDKMessageSendEventsProvider_JCalls_free(void* this_arg) {
6092         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
6093         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6094                 JNIEnv *env;
6095                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6096                 if (get_jenv_res == JNI_EDETACHED) {
6097                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6098                 } else {
6099                         DO_ASSERT(get_jenv_res == JNI_OK);
6100                 }
6101                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6102                 if (get_jenv_res == JNI_EDETACHED) {
6103                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6104                 }
6105                 FREE(j_calls);
6106         }
6107 }
6108 LDKCVec_MessageSendEventZ get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall(const void* this_arg) {
6109         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
6110         JNIEnv *env;
6111         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6112         if (get_jenv_res == JNI_EDETACHED) {
6113                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6114         } else {
6115                 DO_ASSERT(get_jenv_res == JNI_OK);
6116         }
6117         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6118         CHECK(obj != NULL);
6119         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_and_clear_pending_msg_events_meth);
6120         if ((*env)->ExceptionCheck(env)) {
6121                 (*env)->ExceptionDescribe(env);
6122                 (*env)->FatalError(env, "A call to get_and_clear_pending_msg_events in LDKMessageSendEventsProvider from rust threw an exception.");
6123         }
6124         LDKCVec_MessageSendEventZ ret_constr;
6125         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
6126         if (ret_constr.datalen > 0)
6127                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
6128         else
6129                 ret_constr.data = NULL;
6130         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
6131         for (size_t s = 0; s < ret_constr.datalen; s++) {
6132                 int64_t ret_conv_18 = ret_vals[s];
6133                 LDKMessageSendEvent ret_conv_18_conv = *(LDKMessageSendEvent*)(((uint64_t)ret_conv_18) & ~1);
6134                 ret_conv_18_conv = MessageSendEvent_clone((LDKMessageSendEvent*)(((uint64_t)ret_conv_18) & ~1));
6135                 ret_constr.data[s] = ret_conv_18_conv;
6136         }
6137         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
6138         if (get_jenv_res == JNI_EDETACHED) {
6139                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6140         }
6141         return ret_constr;
6142 }
6143 static void* LDKMessageSendEventsProvider_JCalls_clone(const void* this_arg) {
6144         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
6145         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6146         return (void*) this_arg;
6147 }
6148 static inline LDKMessageSendEventsProvider LDKMessageSendEventsProvider_init (JNIEnv *env, jclass clz, jobject o) {
6149         jclass c = (*env)->GetObjectClass(env, o);
6150         CHECK(c != NULL);
6151         LDKMessageSendEventsProvider_JCalls *calls = MALLOC(sizeof(LDKMessageSendEventsProvider_JCalls), "LDKMessageSendEventsProvider_JCalls");
6152         atomic_init(&calls->refcnt, 1);
6153         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6154         calls->o = (*env)->NewWeakGlobalRef(env, o);
6155         calls->get_and_clear_pending_msg_events_meth = (*env)->GetMethodID(env, c, "get_and_clear_pending_msg_events", "()[J");
6156         CHECK(calls->get_and_clear_pending_msg_events_meth != NULL);
6157
6158         LDKMessageSendEventsProvider ret = {
6159                 .this_arg = (void*) calls,
6160                 .get_and_clear_pending_msg_events = get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall,
6161                 .free = LDKMessageSendEventsProvider_JCalls_free,
6162         };
6163         return ret;
6164 }
6165 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEventsProvider_1new(JNIEnv *env, jclass clz, jobject o) {
6166         LDKMessageSendEventsProvider *res_ptr = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
6167         *res_ptr = LDKMessageSendEventsProvider_init(env, clz, o);
6168         return (uint64_t)res_ptr;
6169 }
6170 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_MessageSendEventsProvider_1get_1and_1clear_1pending_1msg_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
6171         LDKMessageSendEventsProvider* this_arg_conv = (LDKMessageSendEventsProvider*)(((uint64_t)this_arg) & ~1);
6172         LDKCVec_MessageSendEventZ ret_var = (this_arg_conv->get_and_clear_pending_msg_events)(this_arg_conv->this_arg);
6173         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
6174         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
6175         for (size_t s = 0; s < ret_var.datalen; s++) {
6176                 LDKMessageSendEvent *ret_conv_18_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
6177                 *ret_conv_18_copy = MessageSendEvent_clone(&ret_var.data[s]);
6178                 uint64_t ret_conv_18_ref = (uint64_t)ret_conv_18_copy;
6179                 ret_arr_ptr[s] = ret_conv_18_ref;
6180         }
6181         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
6182         FREE(ret_var.data);
6183         return ret_arr;
6184 }
6185
6186 typedef struct LDKEventHandler_JCalls {
6187         atomic_size_t refcnt;
6188         JavaVM *vm;
6189         jweak o;
6190         jmethodID handle_event_meth;
6191 } LDKEventHandler_JCalls;
6192 static void LDKEventHandler_JCalls_free(void* this_arg) {
6193         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
6194         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6195                 JNIEnv *env;
6196                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6197                 if (get_jenv_res == JNI_EDETACHED) {
6198                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6199                 } else {
6200                         DO_ASSERT(get_jenv_res == JNI_OK);
6201                 }
6202                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6203                 if (get_jenv_res == JNI_EDETACHED) {
6204                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6205                 }
6206                 FREE(j_calls);
6207         }
6208 }
6209 void handle_event_LDKEventHandler_jcall(const void* this_arg, LDKEvent event) {
6210         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
6211         JNIEnv *env;
6212         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6213         if (get_jenv_res == JNI_EDETACHED) {
6214                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6215         } else {
6216                 DO_ASSERT(get_jenv_res == JNI_OK);
6217         }
6218         LDKEvent *event_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
6219         *event_copy = event;
6220         uint64_t event_ref = (uint64_t)event_copy;
6221         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6222         CHECK(obj != NULL);
6223         (*env)->CallVoidMethod(env, obj, j_calls->handle_event_meth, event_ref);
6224         if ((*env)->ExceptionCheck(env)) {
6225                 (*env)->ExceptionDescribe(env);
6226                 (*env)->FatalError(env, "A call to handle_event in LDKEventHandler from rust threw an exception.");
6227         }
6228         if (get_jenv_res == JNI_EDETACHED) {
6229                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6230         }
6231 }
6232 static void* LDKEventHandler_JCalls_clone(const void* this_arg) {
6233         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
6234         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6235         return (void*) this_arg;
6236 }
6237 static inline LDKEventHandler LDKEventHandler_init (JNIEnv *env, jclass clz, jobject o) {
6238         jclass c = (*env)->GetObjectClass(env, o);
6239         CHECK(c != NULL);
6240         LDKEventHandler_JCalls *calls = MALLOC(sizeof(LDKEventHandler_JCalls), "LDKEventHandler_JCalls");
6241         atomic_init(&calls->refcnt, 1);
6242         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6243         calls->o = (*env)->NewWeakGlobalRef(env, o);
6244         calls->handle_event_meth = (*env)->GetMethodID(env, c, "handle_event", "(J)V");
6245         CHECK(calls->handle_event_meth != NULL);
6246
6247         LDKEventHandler ret = {
6248                 .this_arg = (void*) calls,
6249                 .handle_event = handle_event_LDKEventHandler_jcall,
6250                 .free = LDKEventHandler_JCalls_free,
6251         };
6252         return ret;
6253 }
6254 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKEventHandler_1new(JNIEnv *env, jclass clz, jobject o) {
6255         LDKEventHandler *res_ptr = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
6256         *res_ptr = LDKEventHandler_init(env, clz, o);
6257         return (uint64_t)res_ptr;
6258 }
6259 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventHandler_1handle_1event(JNIEnv *env, jclass clz, int64_t this_arg, int64_t event) {
6260         LDKEventHandler* this_arg_conv = (LDKEventHandler*)(((uint64_t)this_arg) & ~1);
6261         LDKEvent event_conv = *(LDKEvent*)(((uint64_t)event) & ~1);
6262         (this_arg_conv->handle_event)(this_arg_conv->this_arg, event_conv);
6263 }
6264
6265 typedef struct LDKEventsProvider_JCalls {
6266         atomic_size_t refcnt;
6267         JavaVM *vm;
6268         jweak o;
6269         jmethodID process_pending_events_meth;
6270 } LDKEventsProvider_JCalls;
6271 static void LDKEventsProvider_JCalls_free(void* this_arg) {
6272         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
6273         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6274                 JNIEnv *env;
6275                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6276                 if (get_jenv_res == JNI_EDETACHED) {
6277                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6278                 } else {
6279                         DO_ASSERT(get_jenv_res == JNI_OK);
6280                 }
6281                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6282                 if (get_jenv_res == JNI_EDETACHED) {
6283                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6284                 }
6285                 FREE(j_calls);
6286         }
6287 }
6288 void process_pending_events_LDKEventsProvider_jcall(const void* this_arg, LDKEventHandler handler) {
6289         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
6290         JNIEnv *env;
6291         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6292         if (get_jenv_res == JNI_EDETACHED) {
6293                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6294         } else {
6295                 DO_ASSERT(get_jenv_res == JNI_OK);
6296         }
6297         LDKEventHandler* ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
6298         *ret = handler;
6299         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6300         CHECK(obj != NULL);
6301         (*env)->CallVoidMethod(env, obj, j_calls->process_pending_events_meth, (uint64_t)ret);
6302         if ((*env)->ExceptionCheck(env)) {
6303                 (*env)->ExceptionDescribe(env);
6304                 (*env)->FatalError(env, "A call to process_pending_events in LDKEventsProvider from rust threw an exception.");
6305         }
6306         if (get_jenv_res == JNI_EDETACHED) {
6307                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6308         }
6309 }
6310 static void* LDKEventsProvider_JCalls_clone(const void* this_arg) {
6311         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
6312         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6313         return (void*) this_arg;
6314 }
6315 static inline LDKEventsProvider LDKEventsProvider_init (JNIEnv *env, jclass clz, jobject o) {
6316         jclass c = (*env)->GetObjectClass(env, o);
6317         CHECK(c != NULL);
6318         LDKEventsProvider_JCalls *calls = MALLOC(sizeof(LDKEventsProvider_JCalls), "LDKEventsProvider_JCalls");
6319         atomic_init(&calls->refcnt, 1);
6320         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6321         calls->o = (*env)->NewWeakGlobalRef(env, o);
6322         calls->process_pending_events_meth = (*env)->GetMethodID(env, c, "process_pending_events", "(J)V");
6323         CHECK(calls->process_pending_events_meth != NULL);
6324
6325         LDKEventsProvider ret = {
6326                 .this_arg = (void*) calls,
6327                 .process_pending_events = process_pending_events_LDKEventsProvider_jcall,
6328                 .free = LDKEventsProvider_JCalls_free,
6329         };
6330         return ret;
6331 }
6332 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKEventsProvider_1new(JNIEnv *env, jclass clz, jobject o) {
6333         LDKEventsProvider *res_ptr = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
6334         *res_ptr = LDKEventsProvider_init(env, clz, o);
6335         return (uint64_t)res_ptr;
6336 }
6337 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventsProvider_1process_1pending_1events(JNIEnv *env, jclass clz, int64_t this_arg, int64_t handler) {
6338         LDKEventsProvider* this_arg_conv = (LDKEventsProvider*)(((uint64_t)this_arg) & ~1);
6339         LDKEventHandler handler_conv = *(LDKEventHandler*)(((uint64_t)handler) & ~1);
6340         if (handler_conv.free == LDKEventHandler_JCalls_free) {
6341                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
6342                 LDKEventHandler_JCalls_clone(handler_conv.this_arg);
6343         }
6344         (this_arg_conv->process_pending_events)(this_arg_conv->this_arg, handler_conv);
6345 }
6346
6347 typedef struct LDKAccess_JCalls {
6348         atomic_size_t refcnt;
6349         JavaVM *vm;
6350         jweak o;
6351         jmethodID get_utxo_meth;
6352 } LDKAccess_JCalls;
6353 static void LDKAccess_JCalls_free(void* this_arg) {
6354         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
6355         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6356                 JNIEnv *env;
6357                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6358                 if (get_jenv_res == JNI_EDETACHED) {
6359                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6360                 } else {
6361                         DO_ASSERT(get_jenv_res == JNI_OK);
6362                 }
6363                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6364                 if (get_jenv_res == JNI_EDETACHED) {
6365                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6366                 }
6367                 FREE(j_calls);
6368         }
6369 }
6370 LDKCResult_TxOutAccessErrorZ get_utxo_LDKAccess_jcall(const void* this_arg, const uint8_t (* genesis_hash)[32], uint64_t short_channel_id) {
6371         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
6372         JNIEnv *env;
6373         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6374         if (get_jenv_res == JNI_EDETACHED) {
6375                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6376         } else {
6377                 DO_ASSERT(get_jenv_res == JNI_OK);
6378         }
6379         int8_tArray genesis_hash_arr = (*env)->NewByteArray(env, 32);
6380         (*env)->SetByteArrayRegion(env, genesis_hash_arr, 0, 32, *genesis_hash);
6381         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6382         CHECK(obj != NULL);
6383         LDKCResult_TxOutAccessErrorZ* ret = (LDKCResult_TxOutAccessErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->get_utxo_meth, genesis_hash_arr, short_channel_id);
6384         if ((*env)->ExceptionCheck(env)) {
6385                 (*env)->ExceptionDescribe(env);
6386                 (*env)->FatalError(env, "A call to get_utxo in LDKAccess from rust threw an exception.");
6387         }
6388         LDKCResult_TxOutAccessErrorZ ret_conv = *(LDKCResult_TxOutAccessErrorZ*)(((uint64_t)ret) & ~1);
6389         ret_conv = CResult_TxOutAccessErrorZ_clone((LDKCResult_TxOutAccessErrorZ*)(((uint64_t)ret) & ~1));
6390         if (get_jenv_res == JNI_EDETACHED) {
6391                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6392         }
6393         return ret_conv;
6394 }
6395 static void* LDKAccess_JCalls_clone(const void* this_arg) {
6396         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
6397         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6398         return (void*) this_arg;
6399 }
6400 static inline LDKAccess LDKAccess_init (JNIEnv *env, jclass clz, jobject o) {
6401         jclass c = (*env)->GetObjectClass(env, o);
6402         CHECK(c != NULL);
6403         LDKAccess_JCalls *calls = MALLOC(sizeof(LDKAccess_JCalls), "LDKAccess_JCalls");
6404         atomic_init(&calls->refcnt, 1);
6405         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6406         calls->o = (*env)->NewWeakGlobalRef(env, o);
6407         calls->get_utxo_meth = (*env)->GetMethodID(env, c, "get_utxo", "([BJ)J");
6408         CHECK(calls->get_utxo_meth != NULL);
6409
6410         LDKAccess ret = {
6411                 .this_arg = (void*) calls,
6412                 .get_utxo = get_utxo_LDKAccess_jcall,
6413                 .free = LDKAccess_JCalls_free,
6414         };
6415         return ret;
6416 }
6417 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKAccess_1new(JNIEnv *env, jclass clz, jobject o) {
6418         LDKAccess *res_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
6419         *res_ptr = LDKAccess_init(env, clz, o);
6420         return (uint64_t)res_ptr;
6421 }
6422 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) {
6423         LDKAccess* this_arg_conv = (LDKAccess*)(((uint64_t)this_arg) & ~1);
6424         unsigned char genesis_hash_arr[32];
6425         CHECK((*env)->GetArrayLength(env, genesis_hash) == 32);
6426         (*env)->GetByteArrayRegion(env, genesis_hash, 0, 32, genesis_hash_arr);
6427         unsigned char (*genesis_hash_ref)[32] = &genesis_hash_arr;
6428         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
6429         *ret_conv = (this_arg_conv->get_utxo)(this_arg_conv->this_arg, genesis_hash_ref, short_channel_id);
6430         return (uint64_t)ret_conv;
6431 }
6432
6433 typedef struct LDKListen_JCalls {
6434         atomic_size_t refcnt;
6435         JavaVM *vm;
6436         jweak o;
6437         jmethodID block_connected_meth;
6438         jmethodID block_disconnected_meth;
6439 } LDKListen_JCalls;
6440 static void LDKListen_JCalls_free(void* this_arg) {
6441         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
6442         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6443                 JNIEnv *env;
6444                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6445                 if (get_jenv_res == JNI_EDETACHED) {
6446                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6447                 } else {
6448                         DO_ASSERT(get_jenv_res == JNI_OK);
6449                 }
6450                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6451                 if (get_jenv_res == JNI_EDETACHED) {
6452                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6453                 }
6454                 FREE(j_calls);
6455         }
6456 }
6457 void block_connected_LDKListen_jcall(const void* this_arg, LDKu8slice block, uint32_t height) {
6458         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
6459         JNIEnv *env;
6460         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6461         if (get_jenv_res == JNI_EDETACHED) {
6462                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6463         } else {
6464                 DO_ASSERT(get_jenv_res == JNI_OK);
6465         }
6466         LDKu8slice block_var = block;
6467         int8_tArray block_arr = (*env)->NewByteArray(env, block_var.datalen);
6468         (*env)->SetByteArrayRegion(env, block_arr, 0, block_var.datalen, block_var.data);
6469         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6470         CHECK(obj != NULL);
6471         (*env)->CallVoidMethod(env, obj, j_calls->block_connected_meth, block_arr, height);
6472         if ((*env)->ExceptionCheck(env)) {
6473                 (*env)->ExceptionDescribe(env);
6474                 (*env)->FatalError(env, "A call to block_connected in LDKListen from rust threw an exception.");
6475         }
6476         if (get_jenv_res == JNI_EDETACHED) {
6477                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6478         }
6479 }
6480 void block_disconnected_LDKListen_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
6481         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
6482         JNIEnv *env;
6483         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6484         if (get_jenv_res == JNI_EDETACHED) {
6485                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6486         } else {
6487                 DO_ASSERT(get_jenv_res == JNI_OK);
6488         }
6489         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
6490         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
6491         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6492         CHECK(obj != NULL);
6493         (*env)->CallVoidMethod(env, obj, j_calls->block_disconnected_meth, header_arr, height);
6494         if ((*env)->ExceptionCheck(env)) {
6495                 (*env)->ExceptionDescribe(env);
6496                 (*env)->FatalError(env, "A call to block_disconnected in LDKListen from rust threw an exception.");
6497         }
6498         if (get_jenv_res == JNI_EDETACHED) {
6499                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6500         }
6501 }
6502 static void* LDKListen_JCalls_clone(const void* this_arg) {
6503         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
6504         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6505         return (void*) this_arg;
6506 }
6507 static inline LDKListen LDKListen_init (JNIEnv *env, jclass clz, jobject o) {
6508         jclass c = (*env)->GetObjectClass(env, o);
6509         CHECK(c != NULL);
6510         LDKListen_JCalls *calls = MALLOC(sizeof(LDKListen_JCalls), "LDKListen_JCalls");
6511         atomic_init(&calls->refcnt, 1);
6512         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6513         calls->o = (*env)->NewWeakGlobalRef(env, o);
6514         calls->block_connected_meth = (*env)->GetMethodID(env, c, "block_connected", "([BI)V");
6515         CHECK(calls->block_connected_meth != NULL);
6516         calls->block_disconnected_meth = (*env)->GetMethodID(env, c, "block_disconnected", "([BI)V");
6517         CHECK(calls->block_disconnected_meth != NULL);
6518
6519         LDKListen ret = {
6520                 .this_arg = (void*) calls,
6521                 .block_connected = block_connected_LDKListen_jcall,
6522                 .block_disconnected = block_disconnected_LDKListen_jcall,
6523                 .free = LDKListen_JCalls_free,
6524         };
6525         return ret;
6526 }
6527 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKListen_1new(JNIEnv *env, jclass clz, jobject o) {
6528         LDKListen *res_ptr = MALLOC(sizeof(LDKListen), "LDKListen");
6529         *res_ptr = LDKListen_init(env, clz, o);
6530         return (uint64_t)res_ptr;
6531 }
6532 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) {
6533         LDKListen* this_arg_conv = (LDKListen*)(((uint64_t)this_arg) & ~1);
6534         LDKu8slice block_ref;
6535         block_ref.datalen = (*env)->GetArrayLength(env, block);
6536         block_ref.data = (*env)->GetByteArrayElements (env, block, NULL);
6537         (this_arg_conv->block_connected)(this_arg_conv->this_arg, block_ref, height);
6538         (*env)->ReleaseByteArrayElements(env, block, (int8_t*)block_ref.data, 0);
6539 }
6540
6541 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) {
6542         LDKListen* this_arg_conv = (LDKListen*)(((uint64_t)this_arg) & ~1);
6543         unsigned char header_arr[80];
6544         CHECK((*env)->GetArrayLength(env, header) == 80);
6545         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
6546         unsigned char (*header_ref)[80] = &header_arr;
6547         (this_arg_conv->block_disconnected)(this_arg_conv->this_arg, header_ref, height);
6548 }
6549
6550 typedef struct LDKConfirm_JCalls {
6551         atomic_size_t refcnt;
6552         JavaVM *vm;
6553         jweak o;
6554         jmethodID transactions_confirmed_meth;
6555         jmethodID transaction_unconfirmed_meth;
6556         jmethodID best_block_updated_meth;
6557         jmethodID get_relevant_txids_meth;
6558 } LDKConfirm_JCalls;
6559 static void LDKConfirm_JCalls_free(void* this_arg) {
6560         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
6561         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6562                 JNIEnv *env;
6563                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6564                 if (get_jenv_res == JNI_EDETACHED) {
6565                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6566                 } else {
6567                         DO_ASSERT(get_jenv_res == JNI_OK);
6568                 }
6569                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6570                 if (get_jenv_res == JNI_EDETACHED) {
6571                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6572                 }
6573                 FREE(j_calls);
6574         }
6575 }
6576 void transactions_confirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height) {
6577         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
6578         JNIEnv *env;
6579         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6580         if (get_jenv_res == JNI_EDETACHED) {
6581                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6582         } else {
6583                 DO_ASSERT(get_jenv_res == JNI_OK);
6584         }
6585         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
6586         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
6587         LDKCVec_C2Tuple_usizeTransactionZZ txdata_var = txdata;
6588         int64_tArray txdata_arr = (*env)->NewLongArray(env, txdata_var.datalen);
6589         int64_t *txdata_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, txdata_arr, NULL);
6590         for (size_t y = 0; y < txdata_var.datalen; y++) {
6591                 LDKC2Tuple_usizeTransactionZ* txdata_conv_24_ref = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
6592                 *txdata_conv_24_ref = txdata_var.data[y];
6593                 txdata_arr_ptr[y] = (uint64_t)txdata_conv_24_ref;
6594         }
6595         (*env)->ReleasePrimitiveArrayCritical(env, txdata_arr, txdata_arr_ptr, 0);
6596         FREE(txdata_var.data);
6597         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6598         CHECK(obj != NULL);
6599         (*env)->CallVoidMethod(env, obj, j_calls->transactions_confirmed_meth, header_arr, txdata_arr, height);
6600         if ((*env)->ExceptionCheck(env)) {
6601                 (*env)->ExceptionDescribe(env);
6602                 (*env)->FatalError(env, "A call to transactions_confirmed in LDKConfirm from rust threw an exception.");
6603         }
6604         if (get_jenv_res == JNI_EDETACHED) {
6605                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6606         }
6607 }
6608 void transaction_unconfirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* txid)[32]) {
6609         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
6610         JNIEnv *env;
6611         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6612         if (get_jenv_res == JNI_EDETACHED) {
6613                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6614         } else {
6615                 DO_ASSERT(get_jenv_res == JNI_OK);
6616         }
6617         int8_tArray txid_arr = (*env)->NewByteArray(env, 32);
6618         (*env)->SetByteArrayRegion(env, txid_arr, 0, 32, *txid);
6619         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6620         CHECK(obj != NULL);
6621         (*env)->CallVoidMethod(env, obj, j_calls->transaction_unconfirmed_meth, txid_arr);
6622         if ((*env)->ExceptionCheck(env)) {
6623                 (*env)->ExceptionDescribe(env);
6624                 (*env)->FatalError(env, "A call to transaction_unconfirmed in LDKConfirm from rust threw an exception.");
6625         }
6626         if (get_jenv_res == JNI_EDETACHED) {
6627                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6628         }
6629 }
6630 void best_block_updated_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
6631         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
6632         JNIEnv *env;
6633         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6634         if (get_jenv_res == JNI_EDETACHED) {
6635                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6636         } else {
6637                 DO_ASSERT(get_jenv_res == JNI_OK);
6638         }
6639         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
6640         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
6641         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6642         CHECK(obj != NULL);
6643         (*env)->CallVoidMethod(env, obj, j_calls->best_block_updated_meth, header_arr, height);
6644         if ((*env)->ExceptionCheck(env)) {
6645                 (*env)->ExceptionDescribe(env);
6646                 (*env)->FatalError(env, "A call to best_block_updated in LDKConfirm from rust threw an exception.");
6647         }
6648         if (get_jenv_res == JNI_EDETACHED) {
6649                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6650         }
6651 }
6652 LDKCVec_TxidZ get_relevant_txids_LDKConfirm_jcall(const void* this_arg) {
6653         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
6654         JNIEnv *env;
6655         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6656         if (get_jenv_res == JNI_EDETACHED) {
6657                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6658         } else {
6659                 DO_ASSERT(get_jenv_res == JNI_OK);
6660         }
6661         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6662         CHECK(obj != NULL);
6663         jobjectArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_relevant_txids_meth);
6664         if ((*env)->ExceptionCheck(env)) {
6665                 (*env)->ExceptionDescribe(env);
6666                 (*env)->FatalError(env, "A call to get_relevant_txids in LDKConfirm from rust threw an exception.");
6667         }
6668         LDKCVec_TxidZ ret_constr;
6669         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
6670         if (ret_constr.datalen > 0)
6671                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
6672         else
6673                 ret_constr.data = NULL;
6674         for (size_t i = 0; i < ret_constr.datalen; i++) {
6675                 int8_tArray ret_conv_8 = (*env)->GetObjectArrayElement(env, ret, i);
6676                 LDKThirtyTwoBytes ret_conv_8_ref;
6677                 CHECK((*env)->GetArrayLength(env, ret_conv_8) == 32);
6678                 (*env)->GetByteArrayRegion(env, ret_conv_8, 0, 32, ret_conv_8_ref.data);
6679                 ret_constr.data[i] = ret_conv_8_ref;
6680         }
6681         if (get_jenv_res == JNI_EDETACHED) {
6682                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6683         }
6684         return ret_constr;
6685 }
6686 static void* LDKConfirm_JCalls_clone(const void* this_arg) {
6687         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
6688         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6689         return (void*) this_arg;
6690 }
6691 static inline LDKConfirm LDKConfirm_init (JNIEnv *env, jclass clz, jobject o) {
6692         jclass c = (*env)->GetObjectClass(env, o);
6693         CHECK(c != NULL);
6694         LDKConfirm_JCalls *calls = MALLOC(sizeof(LDKConfirm_JCalls), "LDKConfirm_JCalls");
6695         atomic_init(&calls->refcnt, 1);
6696         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6697         calls->o = (*env)->NewWeakGlobalRef(env, o);
6698         calls->transactions_confirmed_meth = (*env)->GetMethodID(env, c, "transactions_confirmed", "([B[JI)V");
6699         CHECK(calls->transactions_confirmed_meth != NULL);
6700         calls->transaction_unconfirmed_meth = (*env)->GetMethodID(env, c, "transaction_unconfirmed", "([B)V");
6701         CHECK(calls->transaction_unconfirmed_meth != NULL);
6702         calls->best_block_updated_meth = (*env)->GetMethodID(env, c, "best_block_updated", "([BI)V");
6703         CHECK(calls->best_block_updated_meth != NULL);
6704         calls->get_relevant_txids_meth = (*env)->GetMethodID(env, c, "get_relevant_txids", "()[[B");
6705         CHECK(calls->get_relevant_txids_meth != NULL);
6706
6707         LDKConfirm ret = {
6708                 .this_arg = (void*) calls,
6709                 .transactions_confirmed = transactions_confirmed_LDKConfirm_jcall,
6710                 .transaction_unconfirmed = transaction_unconfirmed_LDKConfirm_jcall,
6711                 .best_block_updated = best_block_updated_LDKConfirm_jcall,
6712                 .get_relevant_txids = get_relevant_txids_LDKConfirm_jcall,
6713                 .free = LDKConfirm_JCalls_free,
6714         };
6715         return ret;
6716 }
6717 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKConfirm_1new(JNIEnv *env, jclass clz, jobject o) {
6718         LDKConfirm *res_ptr = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
6719         *res_ptr = LDKConfirm_init(env, clz, o);
6720         return (uint64_t)res_ptr;
6721 }
6722 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) {
6723         LDKConfirm* this_arg_conv = (LDKConfirm*)(((uint64_t)this_arg) & ~1);
6724         unsigned char header_arr[80];
6725         CHECK((*env)->GetArrayLength(env, header) == 80);
6726         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
6727         unsigned char (*header_ref)[80] = &header_arr;
6728         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
6729         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
6730         if (txdata_constr.datalen > 0)
6731                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
6732         else
6733                 txdata_constr.data = NULL;
6734         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
6735         for (size_t y = 0; y < txdata_constr.datalen; y++) {
6736                 int64_t txdata_conv_24 = txdata_vals[y];
6737                 LDKC2Tuple_usizeTransactionZ txdata_conv_24_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_24) & ~1);
6738                 txdata_conv_24_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_24) & ~1));
6739                 txdata_constr.data[y] = txdata_conv_24_conv;
6740         }
6741         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
6742         (this_arg_conv->transactions_confirmed)(this_arg_conv->this_arg, header_ref, txdata_constr, height);
6743 }
6744
6745 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Confirm_1transaction_1unconfirmed(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray txid) {
6746         LDKConfirm* this_arg_conv = (LDKConfirm*)(((uint64_t)this_arg) & ~1);
6747         unsigned char txid_arr[32];
6748         CHECK((*env)->GetArrayLength(env, txid) == 32);
6749         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
6750         unsigned char (*txid_ref)[32] = &txid_arr;
6751         (this_arg_conv->transaction_unconfirmed)(this_arg_conv->this_arg, txid_ref);
6752 }
6753
6754 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) {
6755         LDKConfirm* this_arg_conv = (LDKConfirm*)(((uint64_t)this_arg) & ~1);
6756         unsigned char header_arr[80];
6757         CHECK((*env)->GetArrayLength(env, header) == 80);
6758         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
6759         unsigned char (*header_ref)[80] = &header_arr;
6760         (this_arg_conv->best_block_updated)(this_arg_conv->this_arg, header_ref, height);
6761 }
6762
6763 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_Confirm_1get_1relevant_1txids(JNIEnv *env, jclass clz, int64_t this_arg) {
6764         LDKConfirm* this_arg_conv = (LDKConfirm*)(((uint64_t)this_arg) & ~1);
6765         LDKCVec_TxidZ ret_var = (this_arg_conv->get_relevant_txids)(this_arg_conv->this_arg);
6766         jobjectArray ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
6767         ;
6768         for (size_t i = 0; i < ret_var.datalen; i++) {
6769                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 32);
6770                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 32, ret_var.data[i].data);
6771                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
6772         }
6773         FREE(ret_var.data);
6774         return ret_arr;
6775 }
6776
6777 typedef struct LDKFilter_JCalls {
6778         atomic_size_t refcnt;
6779         JavaVM *vm;
6780         jweak o;
6781         jmethodID register_tx_meth;
6782         jmethodID register_output_meth;
6783 } LDKFilter_JCalls;
6784 static void LDKFilter_JCalls_free(void* this_arg) {
6785         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
6786         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6787                 JNIEnv *env;
6788                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6789                 if (get_jenv_res == JNI_EDETACHED) {
6790                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6791                 } else {
6792                         DO_ASSERT(get_jenv_res == JNI_OK);
6793                 }
6794                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6795                 if (get_jenv_res == JNI_EDETACHED) {
6796                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6797                 }
6798                 FREE(j_calls);
6799         }
6800 }
6801 void register_tx_LDKFilter_jcall(const void* this_arg, const uint8_t (* txid)[32], LDKu8slice script_pubkey) {
6802         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
6803         JNIEnv *env;
6804         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6805         if (get_jenv_res == JNI_EDETACHED) {
6806                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6807         } else {
6808                 DO_ASSERT(get_jenv_res == JNI_OK);
6809         }
6810         int8_tArray txid_arr = (*env)->NewByteArray(env, 32);
6811         (*env)->SetByteArrayRegion(env, txid_arr, 0, 32, *txid);
6812         LDKu8slice script_pubkey_var = script_pubkey;
6813         int8_tArray script_pubkey_arr = (*env)->NewByteArray(env, script_pubkey_var.datalen);
6814         (*env)->SetByteArrayRegion(env, script_pubkey_arr, 0, script_pubkey_var.datalen, script_pubkey_var.data);
6815         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6816         CHECK(obj != NULL);
6817         (*env)->CallVoidMethod(env, obj, j_calls->register_tx_meth, txid_arr, script_pubkey_arr);
6818         if ((*env)->ExceptionCheck(env)) {
6819                 (*env)->ExceptionDescribe(env);
6820                 (*env)->FatalError(env, "A call to register_tx in LDKFilter from rust threw an exception.");
6821         }
6822         if (get_jenv_res == JNI_EDETACHED) {
6823                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6824         }
6825 }
6826 LDKCOption_C2Tuple_usizeTransactionZZ register_output_LDKFilter_jcall(const void* this_arg, LDKWatchedOutput output) {
6827         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
6828         JNIEnv *env;
6829         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6830         if (get_jenv_res == JNI_EDETACHED) {
6831                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6832         } else {
6833                 DO_ASSERT(get_jenv_res == JNI_OK);
6834         }
6835         LDKWatchedOutput output_var = output;
6836         CHECK((((uint64_t)output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6837         CHECK((((uint64_t)&output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6838         uint64_t output_ref = (uint64_t)output_var.inner;
6839         if (output_var.is_owned) {
6840                 output_ref |= 1;
6841         }
6842         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6843         CHECK(obj != NULL);
6844         LDKCOption_C2Tuple_usizeTransactionZZ* ret = (LDKCOption_C2Tuple_usizeTransactionZZ*)(*env)->CallLongMethod(env, obj, j_calls->register_output_meth, output_ref);
6845         if ((*env)->ExceptionCheck(env)) {
6846                 (*env)->ExceptionDescribe(env);
6847                 (*env)->FatalError(env, "A call to register_output in LDKFilter from rust threw an exception.");
6848         }
6849         LDKCOption_C2Tuple_usizeTransactionZZ ret_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(((uint64_t)ret) & ~1);
6850         ret_conv = COption_C2Tuple_usizeTransactionZZ_clone((LDKCOption_C2Tuple_usizeTransactionZZ*)(((uint64_t)ret) & ~1));
6851         if (get_jenv_res == JNI_EDETACHED) {
6852                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6853         }
6854         return ret_conv;
6855 }
6856 static void* LDKFilter_JCalls_clone(const void* this_arg) {
6857         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
6858         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6859         return (void*) this_arg;
6860 }
6861 static inline LDKFilter LDKFilter_init (JNIEnv *env, jclass clz, jobject o) {
6862         jclass c = (*env)->GetObjectClass(env, o);
6863         CHECK(c != NULL);
6864         LDKFilter_JCalls *calls = MALLOC(sizeof(LDKFilter_JCalls), "LDKFilter_JCalls");
6865         atomic_init(&calls->refcnt, 1);
6866         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6867         calls->o = (*env)->NewWeakGlobalRef(env, o);
6868         calls->register_tx_meth = (*env)->GetMethodID(env, c, "register_tx", "([B[B)V");
6869         CHECK(calls->register_tx_meth != NULL);
6870         calls->register_output_meth = (*env)->GetMethodID(env, c, "register_output", "(J)J");
6871         CHECK(calls->register_output_meth != NULL);
6872
6873         LDKFilter ret = {
6874                 .this_arg = (void*) calls,
6875                 .register_tx = register_tx_LDKFilter_jcall,
6876                 .register_output = register_output_LDKFilter_jcall,
6877                 .free = LDKFilter_JCalls_free,
6878         };
6879         return ret;
6880 }
6881 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKFilter_1new(JNIEnv *env, jclass clz, jobject o) {
6882         LDKFilter *res_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter");
6883         *res_ptr = LDKFilter_init(env, clz, o);
6884         return (uint64_t)res_ptr;
6885 }
6886 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) {
6887         LDKFilter* this_arg_conv = (LDKFilter*)(((uint64_t)this_arg) & ~1);
6888         unsigned char txid_arr[32];
6889         CHECK((*env)->GetArrayLength(env, txid) == 32);
6890         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
6891         unsigned char (*txid_ref)[32] = &txid_arr;
6892         LDKu8slice script_pubkey_ref;
6893         script_pubkey_ref.datalen = (*env)->GetArrayLength(env, script_pubkey);
6894         script_pubkey_ref.data = (*env)->GetByteArrayElements (env, script_pubkey, NULL);
6895         (this_arg_conv->register_tx)(this_arg_conv->this_arg, txid_ref, script_pubkey_ref);
6896         (*env)->ReleaseByteArrayElements(env, script_pubkey, (int8_t*)script_pubkey_ref.data, 0);
6897 }
6898
6899 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Filter_1register_1output(JNIEnv *env, jclass clz, int64_t this_arg, int64_t output) {
6900         LDKFilter* this_arg_conv = (LDKFilter*)(((uint64_t)this_arg) & ~1);
6901         LDKWatchedOutput output_conv;
6902         output_conv.inner = (void*)(output & (~1));
6903         output_conv.is_owned = (output & 1) || (output == 0);
6904         output_conv = WatchedOutput_clone(&output_conv);
6905         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
6906         *ret_copy = (this_arg_conv->register_output)(this_arg_conv->this_arg, output_conv);
6907         uint64_t ret_ref = (uint64_t)ret_copy;
6908         return ret_ref;
6909 }
6910
6911 typedef struct LDKPersist_JCalls {
6912         atomic_size_t refcnt;
6913         JavaVM *vm;
6914         jweak o;
6915         jmethodID persist_new_channel_meth;
6916         jmethodID update_persisted_channel_meth;
6917 } LDKPersist_JCalls;
6918 static void LDKPersist_JCalls_free(void* this_arg) {
6919         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
6920         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6921                 JNIEnv *env;
6922                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6923                 if (get_jenv_res == JNI_EDETACHED) {
6924                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6925                 } else {
6926                         DO_ASSERT(get_jenv_res == JNI_OK);
6927                 }
6928                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6929                 if (get_jenv_res == JNI_EDETACHED) {
6930                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6931                 }
6932                 FREE(j_calls);
6933         }
6934 }
6935 LDKCResult_NoneChannelMonitorUpdateErrZ persist_new_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint id, const LDKChannelMonitor * data) {
6936         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
6937         JNIEnv *env;
6938         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6939         if (get_jenv_res == JNI_EDETACHED) {
6940                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6941         } else {
6942                 DO_ASSERT(get_jenv_res == JNI_OK);
6943         }
6944         LDKOutPoint id_var = id;
6945         CHECK((((uint64_t)id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6946         CHECK((((uint64_t)&id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6947         uint64_t id_ref = (uint64_t)id_var.inner;
6948         if (id_var.is_owned) {
6949                 id_ref |= 1;
6950         }
6951         LDKChannelMonitor data_var = *data;
6952         data_var = ChannelMonitor_clone(data);
6953         CHECK((((uint64_t)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6954         CHECK((((uint64_t)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6955         uint64_t data_ref = (uint64_t)data_var.inner;
6956         if (data_var.is_owned) {
6957                 data_ref |= 1;
6958         }
6959         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6960         CHECK(obj != NULL);
6961         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(*env)->CallLongMethod(env, obj, j_calls->persist_new_channel_meth, id_ref, data_ref);
6962         if ((*env)->ExceptionCheck(env)) {
6963                 (*env)->ExceptionDescribe(env);
6964                 (*env)->FatalError(env, "A call to persist_new_channel in LDKPersist from rust threw an exception.");
6965         }
6966         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
6967         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
6968         if (get_jenv_res == JNI_EDETACHED) {
6969                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6970         }
6971         return ret_conv;
6972 }
6973 LDKCResult_NoneChannelMonitorUpdateErrZ update_persisted_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint id, const LDKChannelMonitorUpdate * update, const LDKChannelMonitor * data) {
6974         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
6975         JNIEnv *env;
6976         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6977         if (get_jenv_res == JNI_EDETACHED) {
6978                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6979         } else {
6980                 DO_ASSERT(get_jenv_res == JNI_OK);
6981         }
6982         LDKOutPoint id_var = id;
6983         CHECK((((uint64_t)id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6984         CHECK((((uint64_t)&id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6985         uint64_t id_ref = (uint64_t)id_var.inner;
6986         if (id_var.is_owned) {
6987                 id_ref |= 1;
6988         }
6989         LDKChannelMonitorUpdate update_var = *update;
6990         update_var = ChannelMonitorUpdate_clone(update);
6991         CHECK((((uint64_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6992         CHECK((((uint64_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6993         uint64_t update_ref = (uint64_t)update_var.inner;
6994         if (update_var.is_owned) {
6995                 update_ref |= 1;
6996         }
6997         LDKChannelMonitor data_var = *data;
6998         data_var = ChannelMonitor_clone(data);
6999         CHECK((((uint64_t)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7000         CHECK((((uint64_t)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7001         uint64_t data_ref = (uint64_t)data_var.inner;
7002         if (data_var.is_owned) {
7003                 data_ref |= 1;
7004         }
7005         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7006         CHECK(obj != NULL);
7007         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(*env)->CallLongMethod(env, obj, j_calls->update_persisted_channel_meth, id_ref, update_ref, data_ref);
7008         if ((*env)->ExceptionCheck(env)) {
7009                 (*env)->ExceptionDescribe(env);
7010                 (*env)->FatalError(env, "A call to update_persisted_channel in LDKPersist from rust threw an exception.");
7011         }
7012         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
7013         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
7014         if (get_jenv_res == JNI_EDETACHED) {
7015                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7016         }
7017         return ret_conv;
7018 }
7019 static void* LDKPersist_JCalls_clone(const void* this_arg) {
7020         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
7021         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7022         return (void*) this_arg;
7023 }
7024 static inline LDKPersist LDKPersist_init (JNIEnv *env, jclass clz, jobject o) {
7025         jclass c = (*env)->GetObjectClass(env, o);
7026         CHECK(c != NULL);
7027         LDKPersist_JCalls *calls = MALLOC(sizeof(LDKPersist_JCalls), "LDKPersist_JCalls");
7028         atomic_init(&calls->refcnt, 1);
7029         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
7030         calls->o = (*env)->NewWeakGlobalRef(env, o);
7031         calls->persist_new_channel_meth = (*env)->GetMethodID(env, c, "persist_new_channel", "(JJ)J");
7032         CHECK(calls->persist_new_channel_meth != NULL);
7033         calls->update_persisted_channel_meth = (*env)->GetMethodID(env, c, "update_persisted_channel", "(JJJ)J");
7034         CHECK(calls->update_persisted_channel_meth != NULL);
7035
7036         LDKPersist ret = {
7037                 .this_arg = (void*) calls,
7038                 .persist_new_channel = persist_new_channel_LDKPersist_jcall,
7039                 .update_persisted_channel = update_persisted_channel_LDKPersist_jcall,
7040                 .free = LDKPersist_JCalls_free,
7041         };
7042         return ret;
7043 }
7044 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKPersist_1new(JNIEnv *env, jclass clz, jobject o) {
7045         LDKPersist *res_ptr = MALLOC(sizeof(LDKPersist), "LDKPersist");
7046         *res_ptr = LDKPersist_init(env, clz, o);
7047         return (uint64_t)res_ptr;
7048 }
7049 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) {
7050         LDKPersist* this_arg_conv = (LDKPersist*)(((uint64_t)this_arg) & ~1);
7051         LDKOutPoint id_conv;
7052         id_conv.inner = (void*)(id & (~1));
7053         id_conv.is_owned = (id & 1) || (id == 0);
7054         id_conv = OutPoint_clone(&id_conv);
7055         LDKChannelMonitor data_conv;
7056         data_conv.inner = (void*)(data & (~1));
7057         data_conv.is_owned = false;
7058         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
7059         *ret_conv = (this_arg_conv->persist_new_channel)(this_arg_conv->this_arg, id_conv, &data_conv);
7060         return (uint64_t)ret_conv;
7061 }
7062
7063 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) {
7064         LDKPersist* this_arg_conv = (LDKPersist*)(((uint64_t)this_arg) & ~1);
7065         LDKOutPoint id_conv;
7066         id_conv.inner = (void*)(id & (~1));
7067         id_conv.is_owned = (id & 1) || (id == 0);
7068         id_conv = OutPoint_clone(&id_conv);
7069         LDKChannelMonitorUpdate update_conv;
7070         update_conv.inner = (void*)(update & (~1));
7071         update_conv.is_owned = false;
7072         LDKChannelMonitor data_conv;
7073         data_conv.inner = (void*)(data & (~1));
7074         data_conv.is_owned = false;
7075         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
7076         *ret_conv = (this_arg_conv->update_persisted_channel)(this_arg_conv->this_arg, id_conv, &update_conv, &data_conv);
7077         return (uint64_t)ret_conv;
7078 }
7079
7080 typedef struct LDKChannelMessageHandler_JCalls {
7081         atomic_size_t refcnt;
7082         JavaVM *vm;
7083         jweak o;
7084         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
7085         jmethodID handle_open_channel_meth;
7086         jmethodID handle_accept_channel_meth;
7087         jmethodID handle_funding_created_meth;
7088         jmethodID handle_funding_signed_meth;
7089         jmethodID handle_funding_locked_meth;
7090         jmethodID handle_shutdown_meth;
7091         jmethodID handle_closing_signed_meth;
7092         jmethodID handle_update_add_htlc_meth;
7093         jmethodID handle_update_fulfill_htlc_meth;
7094         jmethodID handle_update_fail_htlc_meth;
7095         jmethodID handle_update_fail_malformed_htlc_meth;
7096         jmethodID handle_commitment_signed_meth;
7097         jmethodID handle_revoke_and_ack_meth;
7098         jmethodID handle_update_fee_meth;
7099         jmethodID handle_announcement_signatures_meth;
7100         jmethodID peer_disconnected_meth;
7101         jmethodID peer_connected_meth;
7102         jmethodID handle_channel_reestablish_meth;
7103         jmethodID handle_channel_update_meth;
7104         jmethodID handle_error_meth;
7105 } LDKChannelMessageHandler_JCalls;
7106 static void LDKChannelMessageHandler_JCalls_free(void* this_arg) {
7107         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7108         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7109                 JNIEnv *env;
7110                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7111                 if (get_jenv_res == JNI_EDETACHED) {
7112                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7113                 } else {
7114                         DO_ASSERT(get_jenv_res == JNI_OK);
7115                 }
7116                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
7117                 if (get_jenv_res == JNI_EDETACHED) {
7118                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7119                 }
7120                 FREE(j_calls);
7121         }
7122 }
7123 void handle_open_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKOpenChannel * msg) {
7124         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7125         JNIEnv *env;
7126         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7127         if (get_jenv_res == JNI_EDETACHED) {
7128                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7129         } else {
7130                 DO_ASSERT(get_jenv_res == JNI_OK);
7131         }
7132         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7133         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7134         LDKInitFeatures their_features_var = their_features;
7135         CHECK((((uint64_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7136         CHECK((((uint64_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7137         uint64_t their_features_ref = (uint64_t)their_features_var.inner;
7138         if (their_features_var.is_owned) {
7139                 their_features_ref |= 1;
7140         }
7141         LDKOpenChannel msg_var = *msg;
7142         msg_var = OpenChannel_clone(msg);
7143         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7144         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7145         uint64_t msg_ref = (uint64_t)msg_var.inner;
7146         if (msg_var.is_owned) {
7147                 msg_ref |= 1;
7148         }
7149         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7150         CHECK(obj != NULL);
7151         (*env)->CallVoidMethod(env, obj, j_calls->handle_open_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
7152         if ((*env)->ExceptionCheck(env)) {
7153                 (*env)->ExceptionDescribe(env);
7154                 (*env)->FatalError(env, "A call to handle_open_channel in LDKChannelMessageHandler from rust threw an exception.");
7155         }
7156         if (get_jenv_res == JNI_EDETACHED) {
7157                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7158         }
7159 }
7160 void handle_accept_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKAcceptChannel * msg) {
7161         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7162         JNIEnv *env;
7163         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7164         if (get_jenv_res == JNI_EDETACHED) {
7165                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7166         } else {
7167                 DO_ASSERT(get_jenv_res == JNI_OK);
7168         }
7169         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7170         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7171         LDKInitFeatures their_features_var = their_features;
7172         CHECK((((uint64_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7173         CHECK((((uint64_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7174         uint64_t their_features_ref = (uint64_t)their_features_var.inner;
7175         if (their_features_var.is_owned) {
7176                 their_features_ref |= 1;
7177         }
7178         LDKAcceptChannel msg_var = *msg;
7179         msg_var = AcceptChannel_clone(msg);
7180         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7181         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7182         uint64_t msg_ref = (uint64_t)msg_var.inner;
7183         if (msg_var.is_owned) {
7184                 msg_ref |= 1;
7185         }
7186         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7187         CHECK(obj != NULL);
7188         (*env)->CallVoidMethod(env, obj, j_calls->handle_accept_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
7189         if ((*env)->ExceptionCheck(env)) {
7190                 (*env)->ExceptionDescribe(env);
7191                 (*env)->FatalError(env, "A call to handle_accept_channel in LDKChannelMessageHandler from rust threw an exception.");
7192         }
7193         if (get_jenv_res == JNI_EDETACHED) {
7194                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7195         }
7196 }
7197 void handle_funding_created_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingCreated * msg) {
7198         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7199         JNIEnv *env;
7200         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7201         if (get_jenv_res == JNI_EDETACHED) {
7202                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7203         } else {
7204                 DO_ASSERT(get_jenv_res == JNI_OK);
7205         }
7206         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7207         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7208         LDKFundingCreated msg_var = *msg;
7209         msg_var = FundingCreated_clone(msg);
7210         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7211         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7212         uint64_t msg_ref = (uint64_t)msg_var.inner;
7213         if (msg_var.is_owned) {
7214                 msg_ref |= 1;
7215         }
7216         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7217         CHECK(obj != NULL);
7218         (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_created_meth, their_node_id_arr, msg_ref);
7219         if ((*env)->ExceptionCheck(env)) {
7220                 (*env)->ExceptionDescribe(env);
7221                 (*env)->FatalError(env, "A call to handle_funding_created in LDKChannelMessageHandler from rust threw an exception.");
7222         }
7223         if (get_jenv_res == JNI_EDETACHED) {
7224                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7225         }
7226 }
7227 void handle_funding_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingSigned * msg) {
7228         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7229         JNIEnv *env;
7230         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7231         if (get_jenv_res == JNI_EDETACHED) {
7232                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7233         } else {
7234                 DO_ASSERT(get_jenv_res == JNI_OK);
7235         }
7236         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7237         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7238         LDKFundingSigned msg_var = *msg;
7239         msg_var = FundingSigned_clone(msg);
7240         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7241         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7242         uint64_t msg_ref = (uint64_t)msg_var.inner;
7243         if (msg_var.is_owned) {
7244                 msg_ref |= 1;
7245         }
7246         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7247         CHECK(obj != NULL);
7248         (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_signed_meth, their_node_id_arr, msg_ref);
7249         if ((*env)->ExceptionCheck(env)) {
7250                 (*env)->ExceptionDescribe(env);
7251                 (*env)->FatalError(env, "A call to handle_funding_signed in LDKChannelMessageHandler from rust threw an exception.");
7252         }
7253         if (get_jenv_res == JNI_EDETACHED) {
7254                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7255         }
7256 }
7257 void handle_funding_locked_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingLocked * msg) {
7258         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7259         JNIEnv *env;
7260         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7261         if (get_jenv_res == JNI_EDETACHED) {
7262                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7263         } else {
7264                 DO_ASSERT(get_jenv_res == JNI_OK);
7265         }
7266         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7267         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7268         LDKFundingLocked msg_var = *msg;
7269         msg_var = FundingLocked_clone(msg);
7270         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7271         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7272         uint64_t msg_ref = (uint64_t)msg_var.inner;
7273         if (msg_var.is_owned) {
7274                 msg_ref |= 1;
7275         }
7276         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7277         CHECK(obj != NULL);
7278         (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_locked_meth, their_node_id_arr, msg_ref);
7279         if ((*env)->ExceptionCheck(env)) {
7280                 (*env)->ExceptionDescribe(env);
7281                 (*env)->FatalError(env, "A call to handle_funding_locked in LDKChannelMessageHandler from rust threw an exception.");
7282         }
7283         if (get_jenv_res == JNI_EDETACHED) {
7284                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7285         }
7286 }
7287 void handle_shutdown_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInitFeatures * their_features, const LDKShutdown * msg) {
7288         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7289         JNIEnv *env;
7290         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7291         if (get_jenv_res == JNI_EDETACHED) {
7292                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7293         } else {
7294                 DO_ASSERT(get_jenv_res == JNI_OK);
7295         }
7296         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7297         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7298         LDKInitFeatures their_features_var = *their_features;
7299         their_features_var = InitFeatures_clone(their_features);
7300         CHECK((((uint64_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7301         CHECK((((uint64_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7302         uint64_t their_features_ref = (uint64_t)their_features_var.inner;
7303         if (their_features_var.is_owned) {
7304                 their_features_ref |= 1;
7305         }
7306         LDKShutdown msg_var = *msg;
7307         msg_var = Shutdown_clone(msg);
7308         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7309         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7310         uint64_t msg_ref = (uint64_t)msg_var.inner;
7311         if (msg_var.is_owned) {
7312                 msg_ref |= 1;
7313         }
7314         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7315         CHECK(obj != NULL);
7316         (*env)->CallVoidMethod(env, obj, j_calls->handle_shutdown_meth, their_node_id_arr, their_features_ref, msg_ref);
7317         if ((*env)->ExceptionCheck(env)) {
7318                 (*env)->ExceptionDescribe(env);
7319                 (*env)->FatalError(env, "A call to handle_shutdown in LDKChannelMessageHandler from rust threw an exception.");
7320         }
7321         if (get_jenv_res == JNI_EDETACHED) {
7322                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7323         }
7324 }
7325 void handle_closing_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKClosingSigned * msg) {
7326         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7327         JNIEnv *env;
7328         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7329         if (get_jenv_res == JNI_EDETACHED) {
7330                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7331         } else {
7332                 DO_ASSERT(get_jenv_res == JNI_OK);
7333         }
7334         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7335         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7336         LDKClosingSigned msg_var = *msg;
7337         msg_var = ClosingSigned_clone(msg);
7338         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7339         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7340         uint64_t msg_ref = (uint64_t)msg_var.inner;
7341         if (msg_var.is_owned) {
7342                 msg_ref |= 1;
7343         }
7344         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7345         CHECK(obj != NULL);
7346         (*env)->CallVoidMethod(env, obj, j_calls->handle_closing_signed_meth, their_node_id_arr, msg_ref);
7347         if ((*env)->ExceptionCheck(env)) {
7348                 (*env)->ExceptionDescribe(env);
7349                 (*env)->FatalError(env, "A call to handle_closing_signed in LDKChannelMessageHandler from rust threw an exception.");
7350         }
7351         if (get_jenv_res == JNI_EDETACHED) {
7352                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7353         }
7354 }
7355 void handle_update_add_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateAddHTLC * msg) {
7356         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7357         JNIEnv *env;
7358         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7359         if (get_jenv_res == JNI_EDETACHED) {
7360                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7361         } else {
7362                 DO_ASSERT(get_jenv_res == JNI_OK);
7363         }
7364         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7365         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7366         LDKUpdateAddHTLC msg_var = *msg;
7367         msg_var = UpdateAddHTLC_clone(msg);
7368         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7369         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7370         uint64_t msg_ref = (uint64_t)msg_var.inner;
7371         if (msg_var.is_owned) {
7372                 msg_ref |= 1;
7373         }
7374         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7375         CHECK(obj != NULL);
7376         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_add_htlc_meth, their_node_id_arr, msg_ref);
7377         if ((*env)->ExceptionCheck(env)) {
7378                 (*env)->ExceptionDescribe(env);
7379                 (*env)->FatalError(env, "A call to handle_update_add_htlc in LDKChannelMessageHandler from rust threw an exception.");
7380         }
7381         if (get_jenv_res == JNI_EDETACHED) {
7382                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7383         }
7384 }
7385 void handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFulfillHTLC * msg) {
7386         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7387         JNIEnv *env;
7388         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7389         if (get_jenv_res == JNI_EDETACHED) {
7390                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7391         } else {
7392                 DO_ASSERT(get_jenv_res == JNI_OK);
7393         }
7394         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7395         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7396         LDKUpdateFulfillHTLC msg_var = *msg;
7397         msg_var = UpdateFulfillHTLC_clone(msg);
7398         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7399         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7400         uint64_t msg_ref = (uint64_t)msg_var.inner;
7401         if (msg_var.is_owned) {
7402                 msg_ref |= 1;
7403         }
7404         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7405         CHECK(obj != NULL);
7406         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fulfill_htlc_meth, their_node_id_arr, msg_ref);
7407         if ((*env)->ExceptionCheck(env)) {
7408                 (*env)->ExceptionDescribe(env);
7409                 (*env)->FatalError(env, "A call to handle_update_fulfill_htlc in LDKChannelMessageHandler from rust threw an exception.");
7410         }
7411         if (get_jenv_res == JNI_EDETACHED) {
7412                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7413         }
7414 }
7415 void handle_update_fail_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailHTLC * msg) {
7416         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7417         JNIEnv *env;
7418         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7419         if (get_jenv_res == JNI_EDETACHED) {
7420                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7421         } else {
7422                 DO_ASSERT(get_jenv_res == JNI_OK);
7423         }
7424         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7425         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7426         LDKUpdateFailHTLC msg_var = *msg;
7427         msg_var = UpdateFailHTLC_clone(msg);
7428         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7429         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7430         uint64_t msg_ref = (uint64_t)msg_var.inner;
7431         if (msg_var.is_owned) {
7432                 msg_ref |= 1;
7433         }
7434         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7435         CHECK(obj != NULL);
7436         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fail_htlc_meth, their_node_id_arr, msg_ref);
7437         if ((*env)->ExceptionCheck(env)) {
7438                 (*env)->ExceptionDescribe(env);
7439                 (*env)->FatalError(env, "A call to handle_update_fail_htlc in LDKChannelMessageHandler from rust threw an exception.");
7440         }
7441         if (get_jenv_res == JNI_EDETACHED) {
7442                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7443         }
7444 }
7445 void handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailMalformedHTLC * msg) {
7446         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7447         JNIEnv *env;
7448         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7449         if (get_jenv_res == JNI_EDETACHED) {
7450                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7451         } else {
7452                 DO_ASSERT(get_jenv_res == JNI_OK);
7453         }
7454         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7455         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7456         LDKUpdateFailMalformedHTLC msg_var = *msg;
7457         msg_var = UpdateFailMalformedHTLC_clone(msg);
7458         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7459         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7460         uint64_t msg_ref = (uint64_t)msg_var.inner;
7461         if (msg_var.is_owned) {
7462                 msg_ref |= 1;
7463         }
7464         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7465         CHECK(obj != NULL);
7466         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fail_malformed_htlc_meth, their_node_id_arr, msg_ref);
7467         if ((*env)->ExceptionCheck(env)) {
7468                 (*env)->ExceptionDescribe(env);
7469                 (*env)->FatalError(env, "A call to handle_update_fail_malformed_htlc in LDKChannelMessageHandler from rust threw an exception.");
7470         }
7471         if (get_jenv_res == JNI_EDETACHED) {
7472                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7473         }
7474 }
7475 void handle_commitment_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKCommitmentSigned * msg) {
7476         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7477         JNIEnv *env;
7478         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7479         if (get_jenv_res == JNI_EDETACHED) {
7480                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7481         } else {
7482                 DO_ASSERT(get_jenv_res == JNI_OK);
7483         }
7484         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7485         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7486         LDKCommitmentSigned msg_var = *msg;
7487         msg_var = CommitmentSigned_clone(msg);
7488         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7489         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7490         uint64_t msg_ref = (uint64_t)msg_var.inner;
7491         if (msg_var.is_owned) {
7492                 msg_ref |= 1;
7493         }
7494         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7495         CHECK(obj != NULL);
7496         (*env)->CallVoidMethod(env, obj, j_calls->handle_commitment_signed_meth, their_node_id_arr, msg_ref);
7497         if ((*env)->ExceptionCheck(env)) {
7498                 (*env)->ExceptionDescribe(env);
7499                 (*env)->FatalError(env, "A call to handle_commitment_signed in LDKChannelMessageHandler from rust threw an exception.");
7500         }
7501         if (get_jenv_res == JNI_EDETACHED) {
7502                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7503         }
7504 }
7505 void handle_revoke_and_ack_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKRevokeAndACK * msg) {
7506         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7507         JNIEnv *env;
7508         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7509         if (get_jenv_res == JNI_EDETACHED) {
7510                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7511         } else {
7512                 DO_ASSERT(get_jenv_res == JNI_OK);
7513         }
7514         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7515         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7516         LDKRevokeAndACK msg_var = *msg;
7517         msg_var = RevokeAndACK_clone(msg);
7518         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7519         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7520         uint64_t msg_ref = (uint64_t)msg_var.inner;
7521         if (msg_var.is_owned) {
7522                 msg_ref |= 1;
7523         }
7524         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7525         CHECK(obj != NULL);
7526         (*env)->CallVoidMethod(env, obj, j_calls->handle_revoke_and_ack_meth, their_node_id_arr, msg_ref);
7527         if ((*env)->ExceptionCheck(env)) {
7528                 (*env)->ExceptionDescribe(env);
7529                 (*env)->FatalError(env, "A call to handle_revoke_and_ack in LDKChannelMessageHandler from rust threw an exception.");
7530         }
7531         if (get_jenv_res == JNI_EDETACHED) {
7532                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7533         }
7534 }
7535 void handle_update_fee_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFee * msg) {
7536         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7537         JNIEnv *env;
7538         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7539         if (get_jenv_res == JNI_EDETACHED) {
7540                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7541         } else {
7542                 DO_ASSERT(get_jenv_res == JNI_OK);
7543         }
7544         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7545         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7546         LDKUpdateFee msg_var = *msg;
7547         msg_var = UpdateFee_clone(msg);
7548         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7549         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7550         uint64_t msg_ref = (uint64_t)msg_var.inner;
7551         if (msg_var.is_owned) {
7552                 msg_ref |= 1;
7553         }
7554         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7555         CHECK(obj != NULL);
7556         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fee_meth, their_node_id_arr, msg_ref);
7557         if ((*env)->ExceptionCheck(env)) {
7558                 (*env)->ExceptionDescribe(env);
7559                 (*env)->FatalError(env, "A call to handle_update_fee in LDKChannelMessageHandler from rust threw an exception.");
7560         }
7561         if (get_jenv_res == JNI_EDETACHED) {
7562                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7563         }
7564 }
7565 void handle_announcement_signatures_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKAnnouncementSignatures * msg) {
7566         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7567         JNIEnv *env;
7568         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7569         if (get_jenv_res == JNI_EDETACHED) {
7570                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7571         } else {
7572                 DO_ASSERT(get_jenv_res == JNI_OK);
7573         }
7574         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7575         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7576         LDKAnnouncementSignatures msg_var = *msg;
7577         msg_var = AnnouncementSignatures_clone(msg);
7578         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7579         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7580         uint64_t msg_ref = (uint64_t)msg_var.inner;
7581         if (msg_var.is_owned) {
7582                 msg_ref |= 1;
7583         }
7584         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7585         CHECK(obj != NULL);
7586         (*env)->CallVoidMethod(env, obj, j_calls->handle_announcement_signatures_meth, their_node_id_arr, msg_ref);
7587         if ((*env)->ExceptionCheck(env)) {
7588                 (*env)->ExceptionDescribe(env);
7589                 (*env)->FatalError(env, "A call to handle_announcement_signatures in LDKChannelMessageHandler from rust threw an exception.");
7590         }
7591         if (get_jenv_res == JNI_EDETACHED) {
7592                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7593         }
7594 }
7595 void peer_disconnected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, bool no_connection_possible) {
7596         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7597         JNIEnv *env;
7598         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7599         if (get_jenv_res == JNI_EDETACHED) {
7600                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7601         } else {
7602                 DO_ASSERT(get_jenv_res == JNI_OK);
7603         }
7604         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7605         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7606         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7607         CHECK(obj != NULL);
7608         (*env)->CallVoidMethod(env, obj, j_calls->peer_disconnected_meth, their_node_id_arr, no_connection_possible);
7609         if ((*env)->ExceptionCheck(env)) {
7610                 (*env)->ExceptionDescribe(env);
7611                 (*env)->FatalError(env, "A call to peer_disconnected in LDKChannelMessageHandler from rust threw an exception.");
7612         }
7613         if (get_jenv_res == JNI_EDETACHED) {
7614                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7615         }
7616 }
7617 void peer_connected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * msg) {
7618         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7619         JNIEnv *env;
7620         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7621         if (get_jenv_res == JNI_EDETACHED) {
7622                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7623         } else {
7624                 DO_ASSERT(get_jenv_res == JNI_OK);
7625         }
7626         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7627         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7628         LDKInit msg_var = *msg;
7629         msg_var = Init_clone(msg);
7630         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7631         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7632         uint64_t msg_ref = (uint64_t)msg_var.inner;
7633         if (msg_var.is_owned) {
7634                 msg_ref |= 1;
7635         }
7636         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7637         CHECK(obj != NULL);
7638         (*env)->CallVoidMethod(env, obj, j_calls->peer_connected_meth, their_node_id_arr, msg_ref);
7639         if ((*env)->ExceptionCheck(env)) {
7640                 (*env)->ExceptionDescribe(env);
7641                 (*env)->FatalError(env, "A call to peer_connected in LDKChannelMessageHandler from rust threw an exception.");
7642         }
7643         if (get_jenv_res == JNI_EDETACHED) {
7644                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7645         }
7646 }
7647 void handle_channel_reestablish_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelReestablish * msg) {
7648         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7649         JNIEnv *env;
7650         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7651         if (get_jenv_res == JNI_EDETACHED) {
7652                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7653         } else {
7654                 DO_ASSERT(get_jenv_res == JNI_OK);
7655         }
7656         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7657         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7658         LDKChannelReestablish msg_var = *msg;
7659         msg_var = ChannelReestablish_clone(msg);
7660         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7661         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7662         uint64_t msg_ref = (uint64_t)msg_var.inner;
7663         if (msg_var.is_owned) {
7664                 msg_ref |= 1;
7665         }
7666         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7667         CHECK(obj != NULL);
7668         (*env)->CallVoidMethod(env, obj, j_calls->handle_channel_reestablish_meth, their_node_id_arr, msg_ref);
7669         if ((*env)->ExceptionCheck(env)) {
7670                 (*env)->ExceptionDescribe(env);
7671                 (*env)->FatalError(env, "A call to handle_channel_reestablish in LDKChannelMessageHandler from rust threw an exception.");
7672         }
7673         if (get_jenv_res == JNI_EDETACHED) {
7674                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7675         }
7676 }
7677 void handle_channel_update_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelUpdate * msg) {
7678         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7679         JNIEnv *env;
7680         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7681         if (get_jenv_res == JNI_EDETACHED) {
7682                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7683         } else {
7684                 DO_ASSERT(get_jenv_res == JNI_OK);
7685         }
7686         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7687         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7688         LDKChannelUpdate msg_var = *msg;
7689         msg_var = ChannelUpdate_clone(msg);
7690         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7691         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7692         uint64_t msg_ref = (uint64_t)msg_var.inner;
7693         if (msg_var.is_owned) {
7694                 msg_ref |= 1;
7695         }
7696         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7697         CHECK(obj != NULL);
7698         (*env)->CallVoidMethod(env, obj, j_calls->handle_channel_update_meth, their_node_id_arr, msg_ref);
7699         if ((*env)->ExceptionCheck(env)) {
7700                 (*env)->ExceptionDescribe(env);
7701                 (*env)->FatalError(env, "A call to handle_channel_update in LDKChannelMessageHandler from rust threw an exception.");
7702         }
7703         if (get_jenv_res == JNI_EDETACHED) {
7704                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7705         }
7706 }
7707 void handle_error_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKErrorMessage * msg) {
7708         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7709         JNIEnv *env;
7710         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7711         if (get_jenv_res == JNI_EDETACHED) {
7712                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7713         } else {
7714                 DO_ASSERT(get_jenv_res == JNI_OK);
7715         }
7716         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7717         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7718         LDKErrorMessage msg_var = *msg;
7719         msg_var = ErrorMessage_clone(msg);
7720         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7721         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7722         uint64_t msg_ref = (uint64_t)msg_var.inner;
7723         if (msg_var.is_owned) {
7724                 msg_ref |= 1;
7725         }
7726         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7727         CHECK(obj != NULL);
7728         (*env)->CallVoidMethod(env, obj, j_calls->handle_error_meth, their_node_id_arr, msg_ref);
7729         if ((*env)->ExceptionCheck(env)) {
7730                 (*env)->ExceptionDescribe(env);
7731                 (*env)->FatalError(env, "A call to handle_error in LDKChannelMessageHandler from rust threw an exception.");
7732         }
7733         if (get_jenv_res == JNI_EDETACHED) {
7734                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7735         }
7736 }
7737 static void* LDKChannelMessageHandler_JCalls_clone(const void* this_arg) {
7738         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7739         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7740         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
7741         return (void*) this_arg;
7742 }
7743 static inline LDKChannelMessageHandler LDKChannelMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
7744         jclass c = (*env)->GetObjectClass(env, o);
7745         CHECK(c != NULL);
7746         LDKChannelMessageHandler_JCalls *calls = MALLOC(sizeof(LDKChannelMessageHandler_JCalls), "LDKChannelMessageHandler_JCalls");
7747         atomic_init(&calls->refcnt, 1);
7748         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
7749         calls->o = (*env)->NewWeakGlobalRef(env, o);
7750         calls->handle_open_channel_meth = (*env)->GetMethodID(env, c, "handle_open_channel", "([BJJ)V");
7751         CHECK(calls->handle_open_channel_meth != NULL);
7752         calls->handle_accept_channel_meth = (*env)->GetMethodID(env, c, "handle_accept_channel", "([BJJ)V");
7753         CHECK(calls->handle_accept_channel_meth != NULL);
7754         calls->handle_funding_created_meth = (*env)->GetMethodID(env, c, "handle_funding_created", "([BJ)V");
7755         CHECK(calls->handle_funding_created_meth != NULL);
7756         calls->handle_funding_signed_meth = (*env)->GetMethodID(env, c, "handle_funding_signed", "([BJ)V");
7757         CHECK(calls->handle_funding_signed_meth != NULL);
7758         calls->handle_funding_locked_meth = (*env)->GetMethodID(env, c, "handle_funding_locked", "([BJ)V");
7759         CHECK(calls->handle_funding_locked_meth != NULL);
7760         calls->handle_shutdown_meth = (*env)->GetMethodID(env, c, "handle_shutdown", "([BJJ)V");
7761         CHECK(calls->handle_shutdown_meth != NULL);
7762         calls->handle_closing_signed_meth = (*env)->GetMethodID(env, c, "handle_closing_signed", "([BJ)V");
7763         CHECK(calls->handle_closing_signed_meth != NULL);
7764         calls->handle_update_add_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_add_htlc", "([BJ)V");
7765         CHECK(calls->handle_update_add_htlc_meth != NULL);
7766         calls->handle_update_fulfill_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fulfill_htlc", "([BJ)V");
7767         CHECK(calls->handle_update_fulfill_htlc_meth != NULL);
7768         calls->handle_update_fail_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fail_htlc", "([BJ)V");
7769         CHECK(calls->handle_update_fail_htlc_meth != NULL);
7770         calls->handle_update_fail_malformed_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fail_malformed_htlc", "([BJ)V");
7771         CHECK(calls->handle_update_fail_malformed_htlc_meth != NULL);
7772         calls->handle_commitment_signed_meth = (*env)->GetMethodID(env, c, "handle_commitment_signed", "([BJ)V");
7773         CHECK(calls->handle_commitment_signed_meth != NULL);
7774         calls->handle_revoke_and_ack_meth = (*env)->GetMethodID(env, c, "handle_revoke_and_ack", "([BJ)V");
7775         CHECK(calls->handle_revoke_and_ack_meth != NULL);
7776         calls->handle_update_fee_meth = (*env)->GetMethodID(env, c, "handle_update_fee", "([BJ)V");
7777         CHECK(calls->handle_update_fee_meth != NULL);
7778         calls->handle_announcement_signatures_meth = (*env)->GetMethodID(env, c, "handle_announcement_signatures", "([BJ)V");
7779         CHECK(calls->handle_announcement_signatures_meth != NULL);
7780         calls->peer_disconnected_meth = (*env)->GetMethodID(env, c, "peer_disconnected", "([BZ)V");
7781         CHECK(calls->peer_disconnected_meth != NULL);
7782         calls->peer_connected_meth = (*env)->GetMethodID(env, c, "peer_connected", "([BJ)V");
7783         CHECK(calls->peer_connected_meth != NULL);
7784         calls->handle_channel_reestablish_meth = (*env)->GetMethodID(env, c, "handle_channel_reestablish", "([BJ)V");
7785         CHECK(calls->handle_channel_reestablish_meth != NULL);
7786         calls->handle_channel_update_meth = (*env)->GetMethodID(env, c, "handle_channel_update", "([BJ)V");
7787         CHECK(calls->handle_channel_update_meth != NULL);
7788         calls->handle_error_meth = (*env)->GetMethodID(env, c, "handle_error", "([BJ)V");
7789         CHECK(calls->handle_error_meth != NULL);
7790
7791         LDKChannelMessageHandler ret = {
7792                 .this_arg = (void*) calls,
7793                 .handle_open_channel = handle_open_channel_LDKChannelMessageHandler_jcall,
7794                 .handle_accept_channel = handle_accept_channel_LDKChannelMessageHandler_jcall,
7795                 .handle_funding_created = handle_funding_created_LDKChannelMessageHandler_jcall,
7796                 .handle_funding_signed = handle_funding_signed_LDKChannelMessageHandler_jcall,
7797                 .handle_funding_locked = handle_funding_locked_LDKChannelMessageHandler_jcall,
7798                 .handle_shutdown = handle_shutdown_LDKChannelMessageHandler_jcall,
7799                 .handle_closing_signed = handle_closing_signed_LDKChannelMessageHandler_jcall,
7800                 .handle_update_add_htlc = handle_update_add_htlc_LDKChannelMessageHandler_jcall,
7801                 .handle_update_fulfill_htlc = handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall,
7802                 .handle_update_fail_htlc = handle_update_fail_htlc_LDKChannelMessageHandler_jcall,
7803                 .handle_update_fail_malformed_htlc = handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall,
7804                 .handle_commitment_signed = handle_commitment_signed_LDKChannelMessageHandler_jcall,
7805                 .handle_revoke_and_ack = handle_revoke_and_ack_LDKChannelMessageHandler_jcall,
7806                 .handle_update_fee = handle_update_fee_LDKChannelMessageHandler_jcall,
7807                 .handle_announcement_signatures = handle_announcement_signatures_LDKChannelMessageHandler_jcall,
7808                 .peer_disconnected = peer_disconnected_LDKChannelMessageHandler_jcall,
7809                 .peer_connected = peer_connected_LDKChannelMessageHandler_jcall,
7810                 .handle_channel_reestablish = handle_channel_reestablish_LDKChannelMessageHandler_jcall,
7811                 .handle_channel_update = handle_channel_update_LDKChannelMessageHandler_jcall,
7812                 .handle_error = handle_error_LDKChannelMessageHandler_jcall,
7813                 .free = LDKChannelMessageHandler_JCalls_free,
7814                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(env, clz, MessageSendEventsProvider),
7815         };
7816         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
7817         return ret;
7818 }
7819 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
7820         LDKChannelMessageHandler *res_ptr = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
7821         *res_ptr = LDKChannelMessageHandler_init(env, clz, o, MessageSendEventsProvider);
7822         return (uint64_t)res_ptr;
7823 }
7824 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) {
7825         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7826         LDKPublicKey their_node_id_ref;
7827         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7828         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7829         LDKInitFeatures their_features_conv;
7830         their_features_conv.inner = (void*)(their_features & (~1));
7831         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
7832         their_features_conv = InitFeatures_clone(&their_features_conv);
7833         LDKOpenChannel msg_conv;
7834         msg_conv.inner = (void*)(msg & (~1));
7835         msg_conv.is_owned = false;
7836         (this_arg_conv->handle_open_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
7837 }
7838
7839 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) {
7840         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7841         LDKPublicKey their_node_id_ref;
7842         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7843         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7844         LDKInitFeatures their_features_conv;
7845         their_features_conv.inner = (void*)(their_features & (~1));
7846         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
7847         their_features_conv = InitFeatures_clone(&their_features_conv);
7848         LDKAcceptChannel msg_conv;
7849         msg_conv.inner = (void*)(msg & (~1));
7850         msg_conv.is_owned = false;
7851         (this_arg_conv->handle_accept_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
7852 }
7853
7854 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) {
7855         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7856         LDKPublicKey their_node_id_ref;
7857         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7858         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7859         LDKFundingCreated msg_conv;
7860         msg_conv.inner = (void*)(msg & (~1));
7861         msg_conv.is_owned = false;
7862         (this_arg_conv->handle_funding_created)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7863 }
7864
7865 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) {
7866         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7867         LDKPublicKey their_node_id_ref;
7868         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7869         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7870         LDKFundingSigned msg_conv;
7871         msg_conv.inner = (void*)(msg & (~1));
7872         msg_conv.is_owned = false;
7873         (this_arg_conv->handle_funding_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7874 }
7875
7876 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) {
7877         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7878         LDKPublicKey their_node_id_ref;
7879         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7880         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7881         LDKFundingLocked msg_conv;
7882         msg_conv.inner = (void*)(msg & (~1));
7883         msg_conv.is_owned = false;
7884         (this_arg_conv->handle_funding_locked)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7885 }
7886
7887 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) {
7888         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7889         LDKPublicKey their_node_id_ref;
7890         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7891         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7892         LDKInitFeatures their_features_conv;
7893         their_features_conv.inner = (void*)(their_features & (~1));
7894         their_features_conv.is_owned = false;
7895         LDKShutdown msg_conv;
7896         msg_conv.inner = (void*)(msg & (~1));
7897         msg_conv.is_owned = false;
7898         (this_arg_conv->handle_shutdown)(this_arg_conv->this_arg, their_node_id_ref, &their_features_conv, &msg_conv);
7899 }
7900
7901 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) {
7902         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7903         LDKPublicKey their_node_id_ref;
7904         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7905         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7906         LDKClosingSigned msg_conv;
7907         msg_conv.inner = (void*)(msg & (~1));
7908         msg_conv.is_owned = false;
7909         (this_arg_conv->handle_closing_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7910 }
7911
7912 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) {
7913         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7914         LDKPublicKey their_node_id_ref;
7915         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7916         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7917         LDKUpdateAddHTLC msg_conv;
7918         msg_conv.inner = (void*)(msg & (~1));
7919         msg_conv.is_owned = false;
7920         (this_arg_conv->handle_update_add_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7921 }
7922
7923 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) {
7924         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7925         LDKPublicKey their_node_id_ref;
7926         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7927         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7928         LDKUpdateFulfillHTLC msg_conv;
7929         msg_conv.inner = (void*)(msg & (~1));
7930         msg_conv.is_owned = false;
7931         (this_arg_conv->handle_update_fulfill_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7932 }
7933
7934 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) {
7935         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7936         LDKPublicKey their_node_id_ref;
7937         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7938         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7939         LDKUpdateFailHTLC msg_conv;
7940         msg_conv.inner = (void*)(msg & (~1));
7941         msg_conv.is_owned = false;
7942         (this_arg_conv->handle_update_fail_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7943 }
7944
7945 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) {
7946         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7947         LDKPublicKey their_node_id_ref;
7948         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7949         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7950         LDKUpdateFailMalformedHTLC msg_conv;
7951         msg_conv.inner = (void*)(msg & (~1));
7952         msg_conv.is_owned = false;
7953         (this_arg_conv->handle_update_fail_malformed_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7954 }
7955
7956 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) {
7957         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7958         LDKPublicKey their_node_id_ref;
7959         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7960         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7961         LDKCommitmentSigned msg_conv;
7962         msg_conv.inner = (void*)(msg & (~1));
7963         msg_conv.is_owned = false;
7964         (this_arg_conv->handle_commitment_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7965 }
7966
7967 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) {
7968         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7969         LDKPublicKey their_node_id_ref;
7970         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7971         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7972         LDKRevokeAndACK msg_conv;
7973         msg_conv.inner = (void*)(msg & (~1));
7974         msg_conv.is_owned = false;
7975         (this_arg_conv->handle_revoke_and_ack)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7976 }
7977
7978 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) {
7979         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7980         LDKPublicKey their_node_id_ref;
7981         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7982         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7983         LDKUpdateFee msg_conv;
7984         msg_conv.inner = (void*)(msg & (~1));
7985         msg_conv.is_owned = false;
7986         (this_arg_conv->handle_update_fee)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7987 }
7988
7989 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) {
7990         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7991         LDKPublicKey their_node_id_ref;
7992         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7993         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7994         LDKAnnouncementSignatures msg_conv;
7995         msg_conv.inner = (void*)(msg & (~1));
7996         msg_conv.is_owned = false;
7997         (this_arg_conv->handle_announcement_signatures)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7998 }
7999
8000 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) {
8001         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
8002         LDKPublicKey their_node_id_ref;
8003         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8004         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8005         (this_arg_conv->peer_disconnected)(this_arg_conv->this_arg, their_node_id_ref, no_connection_possible);
8006 }
8007
8008 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) {
8009         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
8010         LDKPublicKey their_node_id_ref;
8011         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8012         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8013         LDKInit msg_conv;
8014         msg_conv.inner = (void*)(msg & (~1));
8015         msg_conv.is_owned = false;
8016         (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8017 }
8018
8019 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) {
8020         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
8021         LDKPublicKey their_node_id_ref;
8022         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8023         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8024         LDKChannelReestablish msg_conv;
8025         msg_conv.inner = (void*)(msg & (~1));
8026         msg_conv.is_owned = false;
8027         (this_arg_conv->handle_channel_reestablish)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8028 }
8029
8030 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) {
8031         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
8032         LDKPublicKey their_node_id_ref;
8033         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8034         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8035         LDKChannelUpdate msg_conv;
8036         msg_conv.inner = (void*)(msg & (~1));
8037         msg_conv.is_owned = false;
8038         (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8039 }
8040
8041 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) {
8042         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
8043         LDKPublicKey their_node_id_ref;
8044         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8045         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8046         LDKErrorMessage msg_conv;
8047         msg_conv.inner = (void*)(msg & (~1));
8048         msg_conv.is_owned = false;
8049         (this_arg_conv->handle_error)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8050 }
8051
8052 typedef struct LDKRoutingMessageHandler_JCalls {
8053         atomic_size_t refcnt;
8054         JavaVM *vm;
8055         jweak o;
8056         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
8057         jmethodID handle_node_announcement_meth;
8058         jmethodID handle_channel_announcement_meth;
8059         jmethodID handle_channel_update_meth;
8060         jmethodID handle_htlc_fail_channel_update_meth;
8061         jmethodID get_next_channel_announcements_meth;
8062         jmethodID get_next_node_announcements_meth;
8063         jmethodID sync_routing_table_meth;
8064         jmethodID handle_reply_channel_range_meth;
8065         jmethodID handle_reply_short_channel_ids_end_meth;
8066         jmethodID handle_query_channel_range_meth;
8067         jmethodID handle_query_short_channel_ids_meth;
8068 } LDKRoutingMessageHandler_JCalls;
8069 static void LDKRoutingMessageHandler_JCalls_free(void* this_arg) {
8070         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8071         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8072                 JNIEnv *env;
8073                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8074                 if (get_jenv_res == JNI_EDETACHED) {
8075                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8076                 } else {
8077                         DO_ASSERT(get_jenv_res == JNI_OK);
8078                 }
8079                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
8080                 if (get_jenv_res == JNI_EDETACHED) {
8081                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8082                 }
8083                 FREE(j_calls);
8084         }
8085 }
8086 LDKCResult_boolLightningErrorZ handle_node_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKNodeAnnouncement * msg) {
8087         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8088         JNIEnv *env;
8089         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8090         if (get_jenv_res == JNI_EDETACHED) {
8091                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8092         } else {
8093                 DO_ASSERT(get_jenv_res == JNI_OK);
8094         }
8095         LDKNodeAnnouncement msg_var = *msg;
8096         msg_var = NodeAnnouncement_clone(msg);
8097         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8098         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8099         uint64_t msg_ref = (uint64_t)msg_var.inner;
8100         if (msg_var.is_owned) {
8101                 msg_ref |= 1;
8102         }
8103         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8104         CHECK(obj != NULL);
8105         LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_node_announcement_meth, msg_ref);
8106         if ((*env)->ExceptionCheck(env)) {
8107                 (*env)->ExceptionDescribe(env);
8108                 (*env)->FatalError(env, "A call to handle_node_announcement in LDKRoutingMessageHandler from rust threw an exception.");
8109         }
8110         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1);
8111         ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1));
8112         if (get_jenv_res == JNI_EDETACHED) {
8113                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8114         }
8115         return ret_conv;
8116 }
8117 LDKCResult_boolLightningErrorZ handle_channel_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelAnnouncement * msg) {
8118         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8119         JNIEnv *env;
8120         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8121         if (get_jenv_res == JNI_EDETACHED) {
8122                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8123         } else {
8124                 DO_ASSERT(get_jenv_res == JNI_OK);
8125         }
8126         LDKChannelAnnouncement msg_var = *msg;
8127         msg_var = ChannelAnnouncement_clone(msg);
8128         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8129         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8130         uint64_t msg_ref = (uint64_t)msg_var.inner;
8131         if (msg_var.is_owned) {
8132                 msg_ref |= 1;
8133         }
8134         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8135         CHECK(obj != NULL);
8136         LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_channel_announcement_meth, msg_ref);
8137         if ((*env)->ExceptionCheck(env)) {
8138                 (*env)->ExceptionDescribe(env);
8139                 (*env)->FatalError(env, "A call to handle_channel_announcement in LDKRoutingMessageHandler from rust threw an exception.");
8140         }
8141         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1);
8142         ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1));
8143         if (get_jenv_res == JNI_EDETACHED) {
8144                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8145         }
8146         return ret_conv;
8147 }
8148 LDKCResult_boolLightningErrorZ handle_channel_update_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelUpdate * msg) {
8149         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8150         JNIEnv *env;
8151         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8152         if (get_jenv_res == JNI_EDETACHED) {
8153                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8154         } else {
8155                 DO_ASSERT(get_jenv_res == JNI_OK);
8156         }
8157         LDKChannelUpdate msg_var = *msg;
8158         msg_var = ChannelUpdate_clone(msg);
8159         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8160         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8161         uint64_t msg_ref = (uint64_t)msg_var.inner;
8162         if (msg_var.is_owned) {
8163                 msg_ref |= 1;
8164         }
8165         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8166         CHECK(obj != NULL);
8167         LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_channel_update_meth, msg_ref);
8168         if ((*env)->ExceptionCheck(env)) {
8169                 (*env)->ExceptionDescribe(env);
8170                 (*env)->FatalError(env, "A call to handle_channel_update in LDKRoutingMessageHandler from rust threw an exception.");
8171         }
8172         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1);
8173         ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1));
8174         if (get_jenv_res == JNI_EDETACHED) {
8175                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8176         }
8177         return ret_conv;
8178 }
8179 void handle_htlc_fail_channel_update_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKHTLCFailChannelUpdate * update) {
8180         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8181         JNIEnv *env;
8182         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8183         if (get_jenv_res == JNI_EDETACHED) {
8184                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8185         } else {
8186                 DO_ASSERT(get_jenv_res == JNI_OK);
8187         }
8188         uint64_t ret_update = (uint64_t)update;
8189         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8190         CHECK(obj != NULL);
8191         (*env)->CallVoidMethod(env, obj, j_calls->handle_htlc_fail_channel_update_meth, ret_update);
8192         if ((*env)->ExceptionCheck(env)) {
8193                 (*env)->ExceptionDescribe(env);
8194                 (*env)->FatalError(env, "A call to handle_htlc_fail_channel_update in LDKRoutingMessageHandler from rust threw an exception.");
8195         }
8196         if (get_jenv_res == JNI_EDETACHED) {
8197                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8198         }
8199 }
8200 LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ get_next_channel_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, uint64_t starting_point, uint8_t batch_amount) {
8201         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8202         JNIEnv *env;
8203         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8204         if (get_jenv_res == JNI_EDETACHED) {
8205                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8206         } else {
8207                 DO_ASSERT(get_jenv_res == JNI_OK);
8208         }
8209         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8210         CHECK(obj != NULL);
8211         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_next_channel_announcements_meth, starting_point, batch_amount);
8212         if ((*env)->ExceptionCheck(env)) {
8213                 (*env)->ExceptionDescribe(env);
8214                 (*env)->FatalError(env, "A call to get_next_channel_announcements in LDKRoutingMessageHandler from rust threw an exception.");
8215         }
8216         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_constr;
8217         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
8218         if (ret_constr.datalen > 0)
8219                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
8220         else
8221                 ret_constr.data = NULL;
8222         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
8223         for (size_t l = 0; l < ret_constr.datalen; l++) {
8224                 int64_t ret_conv_63 = ret_vals[l];
8225                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ ret_conv_63_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)ret_conv_63) & ~1);
8226                 ret_conv_63_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone((LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)ret_conv_63) & ~1));
8227                 ret_constr.data[l] = ret_conv_63_conv;
8228         }
8229         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
8230         if (get_jenv_res == JNI_EDETACHED) {
8231                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8232         }
8233         return ret_constr;
8234 }
8235 LDKCVec_NodeAnnouncementZ get_next_node_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey starting_point, uint8_t batch_amount) {
8236         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8237         JNIEnv *env;
8238         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8239         if (get_jenv_res == JNI_EDETACHED) {
8240                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8241         } else {
8242                 DO_ASSERT(get_jenv_res == JNI_OK);
8243         }
8244         int8_tArray starting_point_arr = (*env)->NewByteArray(env, 33);
8245         (*env)->SetByteArrayRegion(env, starting_point_arr, 0, 33, starting_point.compressed_form);
8246         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8247         CHECK(obj != NULL);
8248         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_next_node_announcements_meth, starting_point_arr, batch_amount);
8249         if ((*env)->ExceptionCheck(env)) {
8250                 (*env)->ExceptionDescribe(env);
8251                 (*env)->FatalError(env, "A call to get_next_node_announcements in LDKRoutingMessageHandler from rust threw an exception.");
8252         }
8253         LDKCVec_NodeAnnouncementZ ret_constr;
8254         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
8255         if (ret_constr.datalen > 0)
8256                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
8257         else
8258                 ret_constr.data = NULL;
8259         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
8260         for (size_t s = 0; s < ret_constr.datalen; s++) {
8261                 int64_t ret_conv_18 = ret_vals[s];
8262                 LDKNodeAnnouncement ret_conv_18_conv;
8263                 ret_conv_18_conv.inner = (void*)(ret_conv_18 & (~1));
8264                 ret_conv_18_conv.is_owned = (ret_conv_18 & 1) || (ret_conv_18 == 0);
8265                 ret_conv_18_conv = NodeAnnouncement_clone(&ret_conv_18_conv);
8266                 ret_constr.data[s] = ret_conv_18_conv;
8267         }
8268         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
8269         if (get_jenv_res == JNI_EDETACHED) {
8270                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8271         }
8272         return ret_constr;
8273 }
8274 void sync_routing_table_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * init) {
8275         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8276         JNIEnv *env;
8277         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8278         if (get_jenv_res == JNI_EDETACHED) {
8279                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8280         } else {
8281                 DO_ASSERT(get_jenv_res == JNI_OK);
8282         }
8283         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8284         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8285         LDKInit init_var = *init;
8286         init_var = Init_clone(init);
8287         CHECK((((uint64_t)init_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8288         CHECK((((uint64_t)&init_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8289         uint64_t init_ref = (uint64_t)init_var.inner;
8290         if (init_var.is_owned) {
8291                 init_ref |= 1;
8292         }
8293         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8294         CHECK(obj != NULL);
8295         (*env)->CallVoidMethod(env, obj, j_calls->sync_routing_table_meth, their_node_id_arr, init_ref);
8296         if ((*env)->ExceptionCheck(env)) {
8297                 (*env)->ExceptionDescribe(env);
8298                 (*env)->FatalError(env, "A call to sync_routing_table in LDKRoutingMessageHandler from rust threw an exception.");
8299         }
8300         if (get_jenv_res == JNI_EDETACHED) {
8301                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8302         }
8303 }
8304 LDKCResult_NoneLightningErrorZ handle_reply_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyChannelRange msg) {
8305         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8306         JNIEnv *env;
8307         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8308         if (get_jenv_res == JNI_EDETACHED) {
8309                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8310         } else {
8311                 DO_ASSERT(get_jenv_res == JNI_OK);
8312         }
8313         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8314         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8315         LDKReplyChannelRange msg_var = msg;
8316         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8317         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8318         uint64_t msg_ref = (uint64_t)msg_var.inner;
8319         if (msg_var.is_owned) {
8320                 msg_ref |= 1;
8321         }
8322         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8323         CHECK(obj != NULL);
8324         LDKCResult_NoneLightningErrorZ* ret = (LDKCResult_NoneLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_reply_channel_range_meth, their_node_id_arr, msg_ref);
8325         if ((*env)->ExceptionCheck(env)) {
8326                 (*env)->ExceptionDescribe(env);
8327                 (*env)->FatalError(env, "A call to handle_reply_channel_range in LDKRoutingMessageHandler from rust threw an exception.");
8328         }
8329         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
8330         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
8331         if (get_jenv_res == JNI_EDETACHED) {
8332                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8333         }
8334         return ret_conv;
8335 }
8336 LDKCResult_NoneLightningErrorZ handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyShortChannelIdsEnd msg) {
8337         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8338         JNIEnv *env;
8339         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8340         if (get_jenv_res == JNI_EDETACHED) {
8341                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8342         } else {
8343                 DO_ASSERT(get_jenv_res == JNI_OK);
8344         }
8345         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8346         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8347         LDKReplyShortChannelIdsEnd msg_var = msg;
8348         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8349         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8350         uint64_t msg_ref = (uint64_t)msg_var.inner;
8351         if (msg_var.is_owned) {
8352                 msg_ref |= 1;
8353         }
8354         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8355         CHECK(obj != NULL);
8356         LDKCResult_NoneLightningErrorZ* ret = (LDKCResult_NoneLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_reply_short_channel_ids_end_meth, their_node_id_arr, msg_ref);
8357         if ((*env)->ExceptionCheck(env)) {
8358                 (*env)->ExceptionDescribe(env);
8359                 (*env)->FatalError(env, "A call to handle_reply_short_channel_ids_end in LDKRoutingMessageHandler from rust threw an exception.");
8360         }
8361         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
8362         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
8363         if (get_jenv_res == JNI_EDETACHED) {
8364                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8365         }
8366         return ret_conv;
8367 }
8368 LDKCResult_NoneLightningErrorZ handle_query_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryChannelRange msg) {
8369         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8370         JNIEnv *env;
8371         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8372         if (get_jenv_res == JNI_EDETACHED) {
8373                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8374         } else {
8375                 DO_ASSERT(get_jenv_res == JNI_OK);
8376         }
8377         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8378         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8379         LDKQueryChannelRange msg_var = msg;
8380         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8381         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8382         uint64_t msg_ref = (uint64_t)msg_var.inner;
8383         if (msg_var.is_owned) {
8384                 msg_ref |= 1;
8385         }
8386         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8387         CHECK(obj != NULL);
8388         LDKCResult_NoneLightningErrorZ* ret = (LDKCResult_NoneLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_query_channel_range_meth, their_node_id_arr, msg_ref);
8389         if ((*env)->ExceptionCheck(env)) {
8390                 (*env)->ExceptionDescribe(env);
8391                 (*env)->FatalError(env, "A call to handle_query_channel_range in LDKRoutingMessageHandler from rust threw an exception.");
8392         }
8393         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
8394         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
8395         if (get_jenv_res == JNI_EDETACHED) {
8396                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8397         }
8398         return ret_conv;
8399 }
8400 LDKCResult_NoneLightningErrorZ handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryShortChannelIds msg) {
8401         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_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         LDKQueryShortChannelIds msg_var = msg;
8412         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8413         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8414         uint64_t msg_ref = (uint64_t)msg_var.inner;
8415         if (msg_var.is_owned) {
8416                 msg_ref |= 1;
8417         }
8418         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8419         CHECK(obj != NULL);
8420         LDKCResult_NoneLightningErrorZ* ret = (LDKCResult_NoneLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_query_short_channel_ids_meth, their_node_id_arr, msg_ref);
8421         if ((*env)->ExceptionCheck(env)) {
8422                 (*env)->ExceptionDescribe(env);
8423                 (*env)->FatalError(env, "A call to handle_query_short_channel_ids in LDKRoutingMessageHandler from rust threw an exception.");
8424         }
8425         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
8426         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
8427         if (get_jenv_res == JNI_EDETACHED) {
8428                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8429         }
8430         return ret_conv;
8431 }
8432 static void* LDKRoutingMessageHandler_JCalls_clone(const void* this_arg) {
8433         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8434         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8435         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
8436         return (void*) this_arg;
8437 }
8438 static inline LDKRoutingMessageHandler LDKRoutingMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
8439         jclass c = (*env)->GetObjectClass(env, o);
8440         CHECK(c != NULL);
8441         LDKRoutingMessageHandler_JCalls *calls = MALLOC(sizeof(LDKRoutingMessageHandler_JCalls), "LDKRoutingMessageHandler_JCalls");
8442         atomic_init(&calls->refcnt, 1);
8443         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
8444         calls->o = (*env)->NewWeakGlobalRef(env, o);
8445         calls->handle_node_announcement_meth = (*env)->GetMethodID(env, c, "handle_node_announcement", "(J)J");
8446         CHECK(calls->handle_node_announcement_meth != NULL);
8447         calls->handle_channel_announcement_meth = (*env)->GetMethodID(env, c, "handle_channel_announcement", "(J)J");
8448         CHECK(calls->handle_channel_announcement_meth != NULL);
8449         calls->handle_channel_update_meth = (*env)->GetMethodID(env, c, "handle_channel_update", "(J)J");
8450         CHECK(calls->handle_channel_update_meth != NULL);
8451         calls->handle_htlc_fail_channel_update_meth = (*env)->GetMethodID(env, c, "handle_htlc_fail_channel_update", "(J)V");
8452         CHECK(calls->handle_htlc_fail_channel_update_meth != NULL);
8453         calls->get_next_channel_announcements_meth = (*env)->GetMethodID(env, c, "get_next_channel_announcements", "(JB)[J");
8454         CHECK(calls->get_next_channel_announcements_meth != NULL);
8455         calls->get_next_node_announcements_meth = (*env)->GetMethodID(env, c, "get_next_node_announcements", "([BB)[J");
8456         CHECK(calls->get_next_node_announcements_meth != NULL);
8457         calls->sync_routing_table_meth = (*env)->GetMethodID(env, c, "sync_routing_table", "([BJ)V");
8458         CHECK(calls->sync_routing_table_meth != NULL);
8459         calls->handle_reply_channel_range_meth = (*env)->GetMethodID(env, c, "handle_reply_channel_range", "([BJ)J");
8460         CHECK(calls->handle_reply_channel_range_meth != NULL);
8461         calls->handle_reply_short_channel_ids_end_meth = (*env)->GetMethodID(env, c, "handle_reply_short_channel_ids_end", "([BJ)J");
8462         CHECK(calls->handle_reply_short_channel_ids_end_meth != NULL);
8463         calls->handle_query_channel_range_meth = (*env)->GetMethodID(env, c, "handle_query_channel_range", "([BJ)J");
8464         CHECK(calls->handle_query_channel_range_meth != NULL);
8465         calls->handle_query_short_channel_ids_meth = (*env)->GetMethodID(env, c, "handle_query_short_channel_ids", "([BJ)J");
8466         CHECK(calls->handle_query_short_channel_ids_meth != NULL);
8467
8468         LDKRoutingMessageHandler ret = {
8469                 .this_arg = (void*) calls,
8470                 .handle_node_announcement = handle_node_announcement_LDKRoutingMessageHandler_jcall,
8471                 .handle_channel_announcement = handle_channel_announcement_LDKRoutingMessageHandler_jcall,
8472                 .handle_channel_update = handle_channel_update_LDKRoutingMessageHandler_jcall,
8473                 .handle_htlc_fail_channel_update = handle_htlc_fail_channel_update_LDKRoutingMessageHandler_jcall,
8474                 .get_next_channel_announcements = get_next_channel_announcements_LDKRoutingMessageHandler_jcall,
8475                 .get_next_node_announcements = get_next_node_announcements_LDKRoutingMessageHandler_jcall,
8476                 .sync_routing_table = sync_routing_table_LDKRoutingMessageHandler_jcall,
8477                 .handle_reply_channel_range = handle_reply_channel_range_LDKRoutingMessageHandler_jcall,
8478                 .handle_reply_short_channel_ids_end = handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall,
8479                 .handle_query_channel_range = handle_query_channel_range_LDKRoutingMessageHandler_jcall,
8480                 .handle_query_short_channel_ids = handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall,
8481                 .free = LDKRoutingMessageHandler_JCalls_free,
8482                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(env, clz, MessageSendEventsProvider),
8483         };
8484         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
8485         return ret;
8486 }
8487 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
8488         LDKRoutingMessageHandler *res_ptr = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
8489         *res_ptr = LDKRoutingMessageHandler_init(env, clz, o, MessageSendEventsProvider);
8490         return (uint64_t)res_ptr;
8491 }
8492 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1node_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
8493         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
8494         LDKNodeAnnouncement msg_conv;
8495         msg_conv.inner = (void*)(msg & (~1));
8496         msg_conv.is_owned = false;
8497         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
8498         *ret_conv = (this_arg_conv->handle_node_announcement)(this_arg_conv->this_arg, &msg_conv);
8499         return (uint64_t)ret_conv;
8500 }
8501
8502 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1channel_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
8503         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
8504         LDKChannelAnnouncement msg_conv;
8505         msg_conv.inner = (void*)(msg & (~1));
8506         msg_conv.is_owned = false;
8507         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
8508         *ret_conv = (this_arg_conv->handle_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
8509         return (uint64_t)ret_conv;
8510 }
8511
8512 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1channel_1update(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
8513         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
8514         LDKChannelUpdate msg_conv;
8515         msg_conv.inner = (void*)(msg & (~1));
8516         msg_conv.is_owned = false;
8517         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
8518         *ret_conv = (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, &msg_conv);
8519         return (uint64_t)ret_conv;
8520 }
8521
8522 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1htlc_1fail_1channel_1update(JNIEnv *env, jclass clz, int64_t this_arg, int64_t update) {
8523         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
8524         LDKHTLCFailChannelUpdate* update_conv = (LDKHTLCFailChannelUpdate*)update;
8525         (this_arg_conv->handle_htlc_fail_channel_update)(this_arg_conv->this_arg, update_conv);
8526 }
8527
8528 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) {
8529         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
8530         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_var = (this_arg_conv->get_next_channel_announcements)(this_arg_conv->this_arg, starting_point, batch_amount);
8531         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
8532         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
8533         for (size_t l = 0; l < ret_var.datalen; l++) {
8534                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv_63_ref = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
8535                 *ret_conv_63_ref = ret_var.data[l];
8536                 ret_arr_ptr[l] = (uint64_t)ret_conv_63_ref;
8537         }
8538         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
8539         FREE(ret_var.data);
8540         return ret_arr;
8541 }
8542
8543 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) {
8544         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
8545         LDKPublicKey starting_point_ref;
8546         CHECK((*env)->GetArrayLength(env, starting_point) == 33);
8547         (*env)->GetByteArrayRegion(env, starting_point, 0, 33, starting_point_ref.compressed_form);
8548         LDKCVec_NodeAnnouncementZ ret_var = (this_arg_conv->get_next_node_announcements)(this_arg_conv->this_arg, starting_point_ref, batch_amount);
8549         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
8550         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
8551         for (size_t s = 0; s < ret_var.datalen; s++) {
8552                 LDKNodeAnnouncement ret_conv_18_var = ret_var.data[s];
8553                 CHECK((((uint64_t)ret_conv_18_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8554                 CHECK((((uint64_t)&ret_conv_18_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8555                 uint64_t ret_conv_18_ref = (uint64_t)ret_conv_18_var.inner;
8556                 if (ret_conv_18_var.is_owned) {
8557                         ret_conv_18_ref |= 1;
8558                 }
8559                 ret_arr_ptr[s] = ret_conv_18_ref;
8560         }
8561         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
8562         FREE(ret_var.data);
8563         return ret_arr;
8564 }
8565
8566 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) {
8567         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
8568         LDKPublicKey their_node_id_ref;
8569         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8570         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8571         LDKInit init_conv;
8572         init_conv.inner = (void*)(init & (~1));
8573         init_conv.is_owned = false;
8574         (this_arg_conv->sync_routing_table)(this_arg_conv->this_arg, their_node_id_ref, &init_conv);
8575 }
8576
8577 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) {
8578         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
8579         LDKPublicKey their_node_id_ref;
8580         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8581         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8582         LDKReplyChannelRange msg_conv;
8583         msg_conv.inner = (void*)(msg & (~1));
8584         msg_conv.is_owned = (msg & 1) || (msg == 0);
8585         msg_conv = ReplyChannelRange_clone(&msg_conv);
8586         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
8587         *ret_conv = (this_arg_conv->handle_reply_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
8588         return (uint64_t)ret_conv;
8589 }
8590
8591 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) {
8592         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
8593         LDKPublicKey their_node_id_ref;
8594         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8595         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8596         LDKReplyShortChannelIdsEnd msg_conv;
8597         msg_conv.inner = (void*)(msg & (~1));
8598         msg_conv.is_owned = (msg & 1) || (msg == 0);
8599         msg_conv = ReplyShortChannelIdsEnd_clone(&msg_conv);
8600         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
8601         *ret_conv = (this_arg_conv->handle_reply_short_channel_ids_end)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
8602         return (uint64_t)ret_conv;
8603 }
8604
8605 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) {
8606         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
8607         LDKPublicKey their_node_id_ref;
8608         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8609         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8610         LDKQueryChannelRange msg_conv;
8611         msg_conv.inner = (void*)(msg & (~1));
8612         msg_conv.is_owned = (msg & 1) || (msg == 0);
8613         msg_conv = QueryChannelRange_clone(&msg_conv);
8614         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
8615         *ret_conv = (this_arg_conv->handle_query_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
8616         return (uint64_t)ret_conv;
8617 }
8618
8619 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) {
8620         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
8621         LDKPublicKey their_node_id_ref;
8622         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8623         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8624         LDKQueryShortChannelIds msg_conv;
8625         msg_conv.inner = (void*)(msg & (~1));
8626         msg_conv.is_owned = (msg & 1) || (msg == 0);
8627         msg_conv = QueryShortChannelIds_clone(&msg_conv);
8628         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
8629         *ret_conv = (this_arg_conv->handle_query_short_channel_ids)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
8630         return (uint64_t)ret_conv;
8631 }
8632
8633 typedef struct LDKSocketDescriptor_JCalls {
8634         atomic_size_t refcnt;
8635         JavaVM *vm;
8636         jweak o;
8637         jmethodID send_data_meth;
8638         jmethodID disconnect_socket_meth;
8639         jmethodID eq_meth;
8640         jmethodID hash_meth;
8641 } LDKSocketDescriptor_JCalls;
8642 static void LDKSocketDescriptor_JCalls_free(void* this_arg) {
8643         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
8644         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8645                 JNIEnv *env;
8646                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8647                 if (get_jenv_res == JNI_EDETACHED) {
8648                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8649                 } else {
8650                         DO_ASSERT(get_jenv_res == JNI_OK);
8651                 }
8652                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
8653                 if (get_jenv_res == JNI_EDETACHED) {
8654                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8655                 }
8656                 FREE(j_calls);
8657         }
8658 }
8659 uintptr_t send_data_LDKSocketDescriptor_jcall(void* this_arg, LDKu8slice data, bool resume_read) {
8660         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
8661         JNIEnv *env;
8662         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8663         if (get_jenv_res == JNI_EDETACHED) {
8664                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8665         } else {
8666                 DO_ASSERT(get_jenv_res == JNI_OK);
8667         }
8668         LDKu8slice data_var = data;
8669         int8_tArray data_arr = (*env)->NewByteArray(env, data_var.datalen);
8670         (*env)->SetByteArrayRegion(env, data_arr, 0, data_var.datalen, data_var.data);
8671         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8672         CHECK(obj != NULL);
8673         int64_t ret = (*env)->CallLongMethod(env, obj, j_calls->send_data_meth, data_arr, resume_read);
8674         if ((*env)->ExceptionCheck(env)) {
8675                 (*env)->ExceptionDescribe(env);
8676                 (*env)->FatalError(env, "A call to send_data in LDKSocketDescriptor from rust threw an exception.");
8677         }
8678         if (get_jenv_res == JNI_EDETACHED) {
8679                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8680         }
8681         return ret;
8682 }
8683 void disconnect_socket_LDKSocketDescriptor_jcall(void* this_arg) {
8684         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
8685         JNIEnv *env;
8686         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8687         if (get_jenv_res == JNI_EDETACHED) {
8688                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8689         } else {
8690                 DO_ASSERT(get_jenv_res == JNI_OK);
8691         }
8692         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8693         CHECK(obj != NULL);
8694         (*env)->CallVoidMethod(env, obj, j_calls->disconnect_socket_meth);
8695         if ((*env)->ExceptionCheck(env)) {
8696                 (*env)->ExceptionDescribe(env);
8697                 (*env)->FatalError(env, "A call to disconnect_socket in LDKSocketDescriptor from rust threw an exception.");
8698         }
8699         if (get_jenv_res == JNI_EDETACHED) {
8700                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8701         }
8702 }
8703 bool eq_LDKSocketDescriptor_jcall(const void* this_arg, const LDKSocketDescriptor * other_arg) {
8704         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
8705         JNIEnv *env;
8706         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8707         if (get_jenv_res == JNI_EDETACHED) {
8708                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8709         } else {
8710                 DO_ASSERT(get_jenv_res == JNI_OK);
8711         }
8712         LDKSocketDescriptor *other_arg_clone = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
8713         *other_arg_clone = SocketDescriptor_clone(other_arg);
8714         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8715         CHECK(obj != NULL);
8716         jboolean ret = (*env)->CallBooleanMethod(env, obj, j_calls->eq_meth, (uint64_t)other_arg_clone);
8717         if ((*env)->ExceptionCheck(env)) {
8718                 (*env)->ExceptionDescribe(env);
8719                 (*env)->FatalError(env, "A call to eq in LDKSocketDescriptor from rust threw an exception.");
8720         }
8721         if (get_jenv_res == JNI_EDETACHED) {
8722                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8723         }
8724         return ret;
8725 }
8726 uint64_t hash_LDKSocketDescriptor_jcall(const void* this_arg) {
8727         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
8728         JNIEnv *env;
8729         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8730         if (get_jenv_res == JNI_EDETACHED) {
8731                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8732         } else {
8733                 DO_ASSERT(get_jenv_res == JNI_OK);
8734         }
8735         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8736         CHECK(obj != NULL);
8737         int64_t ret = (*env)->CallLongMethod(env, obj, j_calls->hash_meth);
8738         if ((*env)->ExceptionCheck(env)) {
8739                 (*env)->ExceptionDescribe(env);
8740                 (*env)->FatalError(env, "A call to hash in LDKSocketDescriptor from rust threw an exception.");
8741         }
8742         if (get_jenv_res == JNI_EDETACHED) {
8743                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8744         }
8745         return ret;
8746 }
8747 static void* LDKSocketDescriptor_JCalls_clone(const void* this_arg) {
8748         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
8749         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8750         return (void*) this_arg;
8751 }
8752 static inline LDKSocketDescriptor LDKSocketDescriptor_init (JNIEnv *env, jclass clz, jobject o) {
8753         jclass c = (*env)->GetObjectClass(env, o);
8754         CHECK(c != NULL);
8755         LDKSocketDescriptor_JCalls *calls = MALLOC(sizeof(LDKSocketDescriptor_JCalls), "LDKSocketDescriptor_JCalls");
8756         atomic_init(&calls->refcnt, 1);
8757         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
8758         calls->o = (*env)->NewWeakGlobalRef(env, o);
8759         calls->send_data_meth = (*env)->GetMethodID(env, c, "send_data", "([BZ)J");
8760         CHECK(calls->send_data_meth != NULL);
8761         calls->disconnect_socket_meth = (*env)->GetMethodID(env, c, "disconnect_socket", "()V");
8762         CHECK(calls->disconnect_socket_meth != NULL);
8763         calls->eq_meth = (*env)->GetMethodID(env, c, "eq", "(J)Z");
8764         CHECK(calls->eq_meth != NULL);
8765         calls->hash_meth = (*env)->GetMethodID(env, c, "hash", "()J");
8766         CHECK(calls->hash_meth != NULL);
8767
8768         LDKSocketDescriptor ret = {
8769                 .this_arg = (void*) calls,
8770                 .send_data = send_data_LDKSocketDescriptor_jcall,
8771                 .disconnect_socket = disconnect_socket_LDKSocketDescriptor_jcall,
8772                 .eq = eq_LDKSocketDescriptor_jcall,
8773                 .hash = hash_LDKSocketDescriptor_jcall,
8774                 .clone = LDKSocketDescriptor_JCalls_clone,
8775                 .free = LDKSocketDescriptor_JCalls_free,
8776         };
8777         return ret;
8778 }
8779 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSocketDescriptor_1new(JNIEnv *env, jclass clz, jobject o) {
8780         LDKSocketDescriptor *res_ptr = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
8781         *res_ptr = LDKSocketDescriptor_init(env, clz, o);
8782         return (uint64_t)res_ptr;
8783 }
8784 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) {
8785         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)(((uint64_t)this_arg) & ~1);
8786         LDKu8slice data_ref;
8787         data_ref.datalen = (*env)->GetArrayLength(env, data);
8788         data_ref.data = (*env)->GetByteArrayElements (env, data, NULL);
8789         int64_t ret_val = (this_arg_conv->send_data)(this_arg_conv->this_arg, data_ref, resume_read);
8790         (*env)->ReleaseByteArrayElements(env, data, (int8_t*)data_ref.data, 0);
8791         return ret_val;
8792 }
8793
8794 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1disconnect_1socket(JNIEnv *env, jclass clz, int64_t this_arg) {
8795         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)(((uint64_t)this_arg) & ~1);
8796         (this_arg_conv->disconnect_socket)(this_arg_conv->this_arg);
8797 }
8798
8799 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
8800         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)(((uint64_t)this_arg) & ~1);
8801         int64_t ret_val = (this_arg_conv->hash)(this_arg_conv->this_arg);
8802         return ret_val;
8803 }
8804
8805 typedef struct LDKChannelManagerPersister_JCalls {
8806         atomic_size_t refcnt;
8807         JavaVM *vm;
8808         jweak o;
8809         jmethodID persist_manager_meth;
8810 } LDKChannelManagerPersister_JCalls;
8811 static void LDKChannelManagerPersister_JCalls_free(void* this_arg) {
8812         LDKChannelManagerPersister_JCalls *j_calls = (LDKChannelManagerPersister_JCalls*) this_arg;
8813         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8814                 JNIEnv *env;
8815                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8816                 if (get_jenv_res == JNI_EDETACHED) {
8817                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8818                 } else {
8819                         DO_ASSERT(get_jenv_res == JNI_OK);
8820                 }
8821                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
8822                 if (get_jenv_res == JNI_EDETACHED) {
8823                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8824                 }
8825                 FREE(j_calls);
8826         }
8827 }
8828 LDKCResult_NoneErrorZ persist_manager_LDKChannelManagerPersister_jcall(const void* this_arg, const LDKChannelManager * channel_manager) {
8829         LDKChannelManagerPersister_JCalls *j_calls = (LDKChannelManagerPersister_JCalls*) this_arg;
8830         JNIEnv *env;
8831         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8832         if (get_jenv_res == JNI_EDETACHED) {
8833                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8834         } else {
8835                 DO_ASSERT(get_jenv_res == JNI_OK);
8836         }
8837         LDKChannelManager channel_manager_var = *channel_manager;
8838         // Warning: we may need a move here but no clone is available for LDKChannelManager
8839         CHECK((((uint64_t)channel_manager_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8840         CHECK((((uint64_t)&channel_manager_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8841         uint64_t channel_manager_ref = (uint64_t)channel_manager_var.inner;
8842         if (channel_manager_var.is_owned) {
8843                 channel_manager_ref |= 1;
8844         }
8845         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8846         CHECK(obj != NULL);
8847         LDKCResult_NoneErrorZ* ret = (LDKCResult_NoneErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->persist_manager_meth, channel_manager_ref);
8848         if ((*env)->ExceptionCheck(env)) {
8849                 (*env)->ExceptionDescribe(env);
8850                 (*env)->FatalError(env, "A call to persist_manager in LDKChannelManagerPersister from rust threw an exception.");
8851         }
8852         LDKCResult_NoneErrorZ ret_conv = *(LDKCResult_NoneErrorZ*)(((uint64_t)ret) & ~1);
8853         ret_conv = CResult_NoneErrorZ_clone((LDKCResult_NoneErrorZ*)(((uint64_t)ret) & ~1));
8854         if (get_jenv_res == JNI_EDETACHED) {
8855                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8856         }
8857         return ret_conv;
8858 }
8859 static void* LDKChannelManagerPersister_JCalls_clone(const void* this_arg) {
8860         LDKChannelManagerPersister_JCalls *j_calls = (LDKChannelManagerPersister_JCalls*) this_arg;
8861         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8862         return (void*) this_arg;
8863 }
8864 static inline LDKChannelManagerPersister LDKChannelManagerPersister_init (JNIEnv *env, jclass clz, jobject o) {
8865         jclass c = (*env)->GetObjectClass(env, o);
8866         CHECK(c != NULL);
8867         LDKChannelManagerPersister_JCalls *calls = MALLOC(sizeof(LDKChannelManagerPersister_JCalls), "LDKChannelManagerPersister_JCalls");
8868         atomic_init(&calls->refcnt, 1);
8869         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
8870         calls->o = (*env)->NewWeakGlobalRef(env, o);
8871         calls->persist_manager_meth = (*env)->GetMethodID(env, c, "persist_manager", "(J)J");
8872         CHECK(calls->persist_manager_meth != NULL);
8873
8874         LDKChannelManagerPersister ret = {
8875                 .this_arg = (void*) calls,
8876                 .persist_manager = persist_manager_LDKChannelManagerPersister_jcall,
8877                 .free = LDKChannelManagerPersister_JCalls_free,
8878         };
8879         return ret;
8880 }
8881 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKChannelManagerPersister_1new(JNIEnv *env, jclass clz, jobject o) {
8882         LDKChannelManagerPersister *res_ptr = MALLOC(sizeof(LDKChannelManagerPersister), "LDKChannelManagerPersister");
8883         *res_ptr = LDKChannelManagerPersister_init(env, clz, o);
8884         return (uint64_t)res_ptr;
8885 }
8886 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerPersister_1persist_1manager(JNIEnv *env, jclass clz, int64_t this_arg, int64_t channel_manager) {
8887         LDKChannelManagerPersister* this_arg_conv = (LDKChannelManagerPersister*)(((uint64_t)this_arg) & ~1);
8888         LDKChannelManager channel_manager_conv;
8889         channel_manager_conv.inner = (void*)(channel_manager & (~1));
8890         channel_manager_conv.is_owned = false;
8891         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
8892         *ret_conv = (this_arg_conv->persist_manager)(this_arg_conv->this_arg, &channel_manager_conv);
8893         return (uint64_t)ret_conv;
8894 }
8895
8896 static jclass LDKFallback_SegWitProgram_class = NULL;
8897 static jmethodID LDKFallback_SegWitProgram_meth = NULL;
8898 static jclass LDKFallback_PubKeyHash_class = NULL;
8899 static jmethodID LDKFallback_PubKeyHash_meth = NULL;
8900 static jclass LDKFallback_ScriptHash_class = NULL;
8901 static jmethodID LDKFallback_ScriptHash_meth = NULL;
8902 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKFallback_init (JNIEnv *env, jclass clz) {
8903         LDKFallback_SegWitProgram_class =
8904                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKFallback$SegWitProgram;"));
8905         CHECK(LDKFallback_SegWitProgram_class != NULL);
8906         LDKFallback_SegWitProgram_meth = (*env)->GetMethodID(env, LDKFallback_SegWitProgram_class, "<init>", "(B[B)V");
8907         CHECK(LDKFallback_SegWitProgram_meth != NULL);
8908         LDKFallback_PubKeyHash_class =
8909                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKFallback$PubKeyHash;"));
8910         CHECK(LDKFallback_PubKeyHash_class != NULL);
8911         LDKFallback_PubKeyHash_meth = (*env)->GetMethodID(env, LDKFallback_PubKeyHash_class, "<init>", "([B)V");
8912         CHECK(LDKFallback_PubKeyHash_meth != NULL);
8913         LDKFallback_ScriptHash_class =
8914                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKFallback$ScriptHash;"));
8915         CHECK(LDKFallback_ScriptHash_class != NULL);
8916         LDKFallback_ScriptHash_meth = (*env)->GetMethodID(env, LDKFallback_ScriptHash_class, "<init>", "([B)V");
8917         CHECK(LDKFallback_ScriptHash_meth != NULL);
8918 }
8919 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKFallback_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
8920         LDKFallback *obj = (LDKFallback*)(ptr & ~1);
8921         switch(obj->tag) {
8922                 case LDKFallback_SegWitProgram: {
8923                         uint8_t version_val = obj->seg_wit_program.version._0;
8924                         LDKCVec_u8Z program_var = obj->seg_wit_program.program;
8925                         int8_tArray program_arr = (*env)->NewByteArray(env, program_var.datalen);
8926                         (*env)->SetByteArrayRegion(env, program_arr, 0, program_var.datalen, program_var.data);
8927                         return (*env)->NewObject(env, LDKFallback_SegWitProgram_class, LDKFallback_SegWitProgram_meth, version_val, program_arr);
8928                 }
8929                 case LDKFallback_PubKeyHash: {
8930                         int8_tArray pub_key_hash_arr = (*env)->NewByteArray(env, 20);
8931                         (*env)->SetByteArrayRegion(env, pub_key_hash_arr, 0, 20, obj->pub_key_hash.data);
8932                         return (*env)->NewObject(env, LDKFallback_PubKeyHash_class, LDKFallback_PubKeyHash_meth, pub_key_hash_arr);
8933                 }
8934                 case LDKFallback_ScriptHash: {
8935                         int8_tArray script_hash_arr = (*env)->NewByteArray(env, 20);
8936                         (*env)->SetByteArrayRegion(env, script_hash_arr, 0, 20, obj->script_hash.data);
8937                         return (*env)->NewObject(env, LDKFallback_ScriptHash_class, LDKFallback_ScriptHash_meth, script_hash_arr);
8938                 }
8939                 default: abort();
8940         }
8941 }
8942 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings__1ldk_1get_1compiled_1version(JNIEnv *env, jclass clz) {
8943         LDKStr ret_str = _ldk_get_compiled_version();
8944         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
8945         return ret_conv;
8946 }
8947
8948 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings__1ldk_1c_1bindings_1get_1compiled_1version(JNIEnv *env, jclass clz) {
8949         LDKStr ret_str = _ldk_c_bindings_get_compiled_version();
8950         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
8951         return ret_conv;
8952 }
8953
8954 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Transaction_1free(JNIEnv *env, jclass clz, int8_tArray _res) {
8955         LDKTransaction _res_ref;
8956         _res_ref.datalen = (*env)->GetArrayLength(env, _res);
8957         _res_ref.data = MALLOC(_res_ref.datalen, "LDKTransaction Bytes");
8958         (*env)->GetByteArrayRegion(env, _res, 0, _res_ref.datalen, _res_ref.data);
8959         _res_ref.data_is_owned = true;
8960         Transaction_free(_res_ref);
8961 }
8962
8963 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxOut_1free(JNIEnv *env, jclass clz, int64_t _res) {
8964         if ((_res & 1) != 0) return;
8965         LDKTxOut _res_conv = *(LDKTxOut*)(((uint64_t)_res) & ~1);
8966         FREE((void*)_res);
8967         TxOut_free(_res_conv);
8968 }
8969
8970 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxOut_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8971         LDKTxOut* orig_conv = (LDKTxOut*)(orig & ~1);
8972         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
8973         *ret_ref = TxOut_clone(orig_conv);
8974         return (uint64_t)ret_ref;
8975 }
8976
8977 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Str_1free(JNIEnv *env, jclass clz, jstring _res) {
8978         LDKStr dummy = { .chars = NULL, .len = 0, .chars_is_owned = false };
8979         Str_free(dummy);
8980 }
8981
8982 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
8983         LDKSecretKey o_ref;
8984         CHECK((*env)->GetArrayLength(env, o) == 32);
8985         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.bytes);
8986         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
8987         *ret_conv = CResult_SecretKeyErrorZ_ok(o_ref);
8988         return (uint64_t)ret_conv;
8989 }
8990
8991 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
8992         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
8993         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
8994         *ret_conv = CResult_SecretKeyErrorZ_err(e_conv);
8995         return (uint64_t)ret_conv;
8996 }
8997
8998 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8999         if ((_res & 1) != 0) return;
9000         LDKCResult_SecretKeyErrorZ _res_conv = *(LDKCResult_SecretKeyErrorZ*)(((uint64_t)_res) & ~1);
9001         FREE((void*)_res);
9002         CResult_SecretKeyErrorZ_free(_res_conv);
9003 }
9004
9005 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
9006         LDKPublicKey o_ref;
9007         CHECK((*env)->GetArrayLength(env, o) == 33);
9008         (*env)->GetByteArrayRegion(env, o, 0, 33, o_ref.compressed_form);
9009         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
9010         *ret_conv = CResult_PublicKeyErrorZ_ok(o_ref);
9011         return (uint64_t)ret_conv;
9012 }
9013
9014 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
9015         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
9016         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
9017         *ret_conv = CResult_PublicKeyErrorZ_err(e_conv);
9018         return (uint64_t)ret_conv;
9019 }
9020
9021 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9022         if ((_res & 1) != 0) return;
9023         LDKCResult_PublicKeyErrorZ _res_conv = *(LDKCResult_PublicKeyErrorZ*)(((uint64_t)_res) & ~1);
9024         FREE((void*)_res);
9025         CResult_PublicKeyErrorZ_free(_res_conv);
9026 }
9027
9028 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9029         LDKCResult_PublicKeyErrorZ* orig_conv = (LDKCResult_PublicKeyErrorZ*)(orig & ~1);
9030         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
9031         *ret_conv = CResult_PublicKeyErrorZ_clone(orig_conv);
9032         return (uint64_t)ret_conv;
9033 }
9034
9035 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9036         LDKTxCreationKeys o_conv;
9037         o_conv.inner = (void*)(o & (~1));
9038         o_conv.is_owned = (o & 1) || (o == 0);
9039         o_conv = TxCreationKeys_clone(&o_conv);
9040         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
9041         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_ok(o_conv);
9042         return (uint64_t)ret_conv;
9043 }
9044
9045 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9046         LDKDecodeError e_conv;
9047         e_conv.inner = (void*)(e & (~1));
9048         e_conv.is_owned = (e & 1) || (e == 0);
9049         e_conv = DecodeError_clone(&e_conv);
9050         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
9051         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_err(e_conv);
9052         return (uint64_t)ret_conv;
9053 }
9054
9055 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9056         if ((_res & 1) != 0) return;
9057         LDKCResult_TxCreationKeysDecodeErrorZ _res_conv = *(LDKCResult_TxCreationKeysDecodeErrorZ*)(((uint64_t)_res) & ~1);
9058         FREE((void*)_res);
9059         CResult_TxCreationKeysDecodeErrorZ_free(_res_conv);
9060 }
9061
9062 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9063         LDKCResult_TxCreationKeysDecodeErrorZ* orig_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(orig & ~1);
9064         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
9065         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(orig_conv);
9066         return (uint64_t)ret_conv;
9067 }
9068
9069 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9070         LDKChannelPublicKeys o_conv;
9071         o_conv.inner = (void*)(o & (~1));
9072         o_conv.is_owned = (o & 1) || (o == 0);
9073         o_conv = ChannelPublicKeys_clone(&o_conv);
9074         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
9075         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_ok(o_conv);
9076         return (uint64_t)ret_conv;
9077 }
9078
9079 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9080         LDKDecodeError e_conv;
9081         e_conv.inner = (void*)(e & (~1));
9082         e_conv.is_owned = (e & 1) || (e == 0);
9083         e_conv = DecodeError_clone(&e_conv);
9084         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
9085         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_err(e_conv);
9086         return (uint64_t)ret_conv;
9087 }
9088
9089 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9090         if ((_res & 1) != 0) return;
9091         LDKCResult_ChannelPublicKeysDecodeErrorZ _res_conv = *(LDKCResult_ChannelPublicKeysDecodeErrorZ*)(((uint64_t)_res) & ~1);
9092         FREE((void*)_res);
9093         CResult_ChannelPublicKeysDecodeErrorZ_free(_res_conv);
9094 }
9095
9096 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9097         LDKCResult_ChannelPublicKeysDecodeErrorZ* orig_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(orig & ~1);
9098         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
9099         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(orig_conv);
9100         return (uint64_t)ret_conv;
9101 }
9102
9103 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9104         LDKTxCreationKeys o_conv;
9105         o_conv.inner = (void*)(o & (~1));
9106         o_conv.is_owned = (o & 1) || (o == 0);
9107         o_conv = TxCreationKeys_clone(&o_conv);
9108         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
9109         *ret_conv = CResult_TxCreationKeysErrorZ_ok(o_conv);
9110         return (uint64_t)ret_conv;
9111 }
9112
9113 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
9114         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
9115         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
9116         *ret_conv = CResult_TxCreationKeysErrorZ_err(e_conv);
9117         return (uint64_t)ret_conv;
9118 }
9119
9120 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9121         if ((_res & 1) != 0) return;
9122         LDKCResult_TxCreationKeysErrorZ _res_conv = *(LDKCResult_TxCreationKeysErrorZ*)(((uint64_t)_res) & ~1);
9123         FREE((void*)_res);
9124         CResult_TxCreationKeysErrorZ_free(_res_conv);
9125 }
9126
9127 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9128         LDKCResult_TxCreationKeysErrorZ* orig_conv = (LDKCResult_TxCreationKeysErrorZ*)(orig & ~1);
9129         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
9130         *ret_conv = CResult_TxCreationKeysErrorZ_clone(orig_conv);
9131         return (uint64_t)ret_conv;
9132 }
9133
9134 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1some(JNIEnv *env, jclass clz, int32_t o) {
9135         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
9136         *ret_copy = COption_u32Z_some(o);
9137         uint64_t ret_ref = (uint64_t)ret_copy;
9138         return ret_ref;
9139 }
9140
9141 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1none(JNIEnv *env, jclass clz) {
9142         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
9143         *ret_copy = COption_u32Z_none();
9144         uint64_t ret_ref = (uint64_t)ret_copy;
9145         return ret_ref;
9146 }
9147
9148 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
9149         if ((_res & 1) != 0) return;
9150         LDKCOption_u32Z _res_conv = *(LDKCOption_u32Z*)(((uint64_t)_res) & ~1);
9151         FREE((void*)_res);
9152         COption_u32Z_free(_res_conv);
9153 }
9154
9155 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9156         LDKCOption_u32Z* orig_conv = (LDKCOption_u32Z*)orig;
9157         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
9158         *ret_copy = COption_u32Z_clone(orig_conv);
9159         uint64_t ret_ref = (uint64_t)ret_copy;
9160         return ret_ref;
9161 }
9162
9163 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9164         LDKHTLCOutputInCommitment o_conv;
9165         o_conv.inner = (void*)(o & (~1));
9166         o_conv.is_owned = (o & 1) || (o == 0);
9167         o_conv = HTLCOutputInCommitment_clone(&o_conv);
9168         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
9169         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(o_conv);
9170         return (uint64_t)ret_conv;
9171 }
9172
9173 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9174         LDKDecodeError e_conv;
9175         e_conv.inner = (void*)(e & (~1));
9176         e_conv.is_owned = (e & 1) || (e == 0);
9177         e_conv = DecodeError_clone(&e_conv);
9178         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
9179         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_err(e_conv);
9180         return (uint64_t)ret_conv;
9181 }
9182
9183 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9184         if ((_res & 1) != 0) return;
9185         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ _res_conv = *(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(((uint64_t)_res) & ~1);
9186         FREE((void*)_res);
9187         CResult_HTLCOutputInCommitmentDecodeErrorZ_free(_res_conv);
9188 }
9189
9190 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9191         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* orig_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(orig & ~1);
9192         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
9193         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(orig_conv);
9194         return (uint64_t)ret_conv;
9195 }
9196
9197 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9198         LDKCounterpartyChannelTransactionParameters o_conv;
9199         o_conv.inner = (void*)(o & (~1));
9200         o_conv.is_owned = (o & 1) || (o == 0);
9201         o_conv = CounterpartyChannelTransactionParameters_clone(&o_conv);
9202         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
9203         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(o_conv);
9204         return (uint64_t)ret_conv;
9205 }
9206
9207 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9208         LDKDecodeError e_conv;
9209         e_conv.inner = (void*)(e & (~1));
9210         e_conv.is_owned = (e & 1) || (e == 0);
9211         e_conv = DecodeError_clone(&e_conv);
9212         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
9213         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(e_conv);
9214         return (uint64_t)ret_conv;
9215 }
9216
9217 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9218         if ((_res & 1) != 0) return;
9219         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(((uint64_t)_res) & ~1);
9220         FREE((void*)_res);
9221         CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(_res_conv);
9222 }
9223
9224 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9225         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
9226         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
9227         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
9228         return (uint64_t)ret_conv;
9229 }
9230
9231 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9232         LDKChannelTransactionParameters o_conv;
9233         o_conv.inner = (void*)(o & (~1));
9234         o_conv.is_owned = (o & 1) || (o == 0);
9235         o_conv = ChannelTransactionParameters_clone(&o_conv);
9236         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
9237         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_ok(o_conv);
9238         return (uint64_t)ret_conv;
9239 }
9240
9241 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9242         LDKDecodeError e_conv;
9243         e_conv.inner = (void*)(e & (~1));
9244         e_conv.is_owned = (e & 1) || (e == 0);
9245         e_conv = DecodeError_clone(&e_conv);
9246         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
9247         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_err(e_conv);
9248         return (uint64_t)ret_conv;
9249 }
9250
9251 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9252         if ((_res & 1) != 0) return;
9253         LDKCResult_ChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(((uint64_t)_res) & ~1);
9254         FREE((void*)_res);
9255         CResult_ChannelTransactionParametersDecodeErrorZ_free(_res_conv);
9256 }
9257
9258 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9259         LDKCResult_ChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
9260         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
9261         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
9262         return (uint64_t)ret_conv;
9263 }
9264
9265 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1SignatureZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
9266         LDKCVec_SignatureZ _res_constr;
9267         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
9268         if (_res_constr.datalen > 0)
9269                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
9270         else
9271                 _res_constr.data = NULL;
9272         for (size_t i = 0; i < _res_constr.datalen; i++) {
9273                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
9274                 LDKSignature _res_conv_8_ref;
9275                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 64);
9276                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 64, _res_conv_8_ref.compact_form);
9277                 _res_constr.data[i] = _res_conv_8_ref;
9278         }
9279         CVec_SignatureZ_free(_res_constr);
9280 }
9281
9282 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9283         LDKHolderCommitmentTransaction o_conv;
9284         o_conv.inner = (void*)(o & (~1));
9285         o_conv.is_owned = (o & 1) || (o == 0);
9286         o_conv = HolderCommitmentTransaction_clone(&o_conv);
9287         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
9288         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_ok(o_conv);
9289         return (uint64_t)ret_conv;
9290 }
9291
9292 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9293         LDKDecodeError e_conv;
9294         e_conv.inner = (void*)(e & (~1));
9295         e_conv.is_owned = (e & 1) || (e == 0);
9296         e_conv = DecodeError_clone(&e_conv);
9297         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
9298         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_err(e_conv);
9299         return (uint64_t)ret_conv;
9300 }
9301
9302 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9303         if ((_res & 1) != 0) return;
9304         LDKCResult_HolderCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(((uint64_t)_res) & ~1);
9305         FREE((void*)_res);
9306         CResult_HolderCommitmentTransactionDecodeErrorZ_free(_res_conv);
9307 }
9308
9309 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9310         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(orig & ~1);
9311         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
9312         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(orig_conv);
9313         return (uint64_t)ret_conv;
9314 }
9315
9316 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9317         LDKBuiltCommitmentTransaction o_conv;
9318         o_conv.inner = (void*)(o & (~1));
9319         o_conv.is_owned = (o & 1) || (o == 0);
9320         o_conv = BuiltCommitmentTransaction_clone(&o_conv);
9321         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
9322         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(o_conv);
9323         return (uint64_t)ret_conv;
9324 }
9325
9326 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9327         LDKDecodeError e_conv;
9328         e_conv.inner = (void*)(e & (~1));
9329         e_conv.is_owned = (e & 1) || (e == 0);
9330         e_conv = DecodeError_clone(&e_conv);
9331         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
9332         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_err(e_conv);
9333         return (uint64_t)ret_conv;
9334 }
9335
9336 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9337         if ((_res & 1) != 0) return;
9338         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(((uint64_t)_res) & ~1);
9339         FREE((void*)_res);
9340         CResult_BuiltCommitmentTransactionDecodeErrorZ_free(_res_conv);
9341 }
9342
9343 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9344         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(orig & ~1);
9345         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
9346         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(orig_conv);
9347         return (uint64_t)ret_conv;
9348 }
9349
9350 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9351         LDKCommitmentTransaction o_conv;
9352         o_conv.inner = (void*)(o & (~1));
9353         o_conv.is_owned = (o & 1) || (o == 0);
9354         o_conv = CommitmentTransaction_clone(&o_conv);
9355         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
9356         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_ok(o_conv);
9357         return (uint64_t)ret_conv;
9358 }
9359
9360 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9361         LDKDecodeError e_conv;
9362         e_conv.inner = (void*)(e & (~1));
9363         e_conv.is_owned = (e & 1) || (e == 0);
9364         e_conv = DecodeError_clone(&e_conv);
9365         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
9366         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_err(e_conv);
9367         return (uint64_t)ret_conv;
9368 }
9369
9370 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9371         if ((_res & 1) != 0) return;
9372         LDKCResult_CommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_CommitmentTransactionDecodeErrorZ*)(((uint64_t)_res) & ~1);
9373         FREE((void*)_res);
9374         CResult_CommitmentTransactionDecodeErrorZ_free(_res_conv);
9375 }
9376
9377 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9378         LDKCResult_CommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(orig & ~1);
9379         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
9380         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(orig_conv);
9381         return (uint64_t)ret_conv;
9382 }
9383
9384 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9385         LDKTrustedCommitmentTransaction o_conv;
9386         o_conv.inner = (void*)(o & (~1));
9387         o_conv.is_owned = (o & 1) || (o == 0);
9388         // Warning: we need a move here but no clone is available for LDKTrustedCommitmentTransaction
9389         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
9390         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_ok(o_conv);
9391         return (uint64_t)ret_conv;
9392 }
9393
9394 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1err(JNIEnv *env, jclass clz) {
9395         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
9396         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_err();
9397         return (uint64_t)ret_conv;
9398 }
9399
9400 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9401         if ((_res & 1) != 0) return;
9402         LDKCResult_TrustedCommitmentTransactionNoneZ _res_conv = *(LDKCResult_TrustedCommitmentTransactionNoneZ*)(((uint64_t)_res) & ~1);
9403         FREE((void*)_res);
9404         CResult_TrustedCommitmentTransactionNoneZ_free(_res_conv);
9405 }
9406
9407 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1ok(JNIEnv *env, jclass clz, jobjectArray o) {
9408         LDKCVec_SignatureZ o_constr;
9409         o_constr.datalen = (*env)->GetArrayLength(env, o);
9410         if (o_constr.datalen > 0)
9411                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
9412         else
9413                 o_constr.data = NULL;
9414         for (size_t i = 0; i < o_constr.datalen; i++) {
9415                 int8_tArray o_conv_8 = (*env)->GetObjectArrayElement(env, o, i);
9416                 LDKSignature o_conv_8_ref;
9417                 CHECK((*env)->GetArrayLength(env, o_conv_8) == 64);
9418                 (*env)->GetByteArrayRegion(env, o_conv_8, 0, 64, o_conv_8_ref.compact_form);
9419                 o_constr.data[i] = o_conv_8_ref;
9420         }
9421         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
9422         *ret_conv = CResult_CVec_SignatureZNoneZ_ok(o_constr);
9423         return (uint64_t)ret_conv;
9424 }
9425
9426 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1err(JNIEnv *env, jclass clz) {
9427         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
9428         *ret_conv = CResult_CVec_SignatureZNoneZ_err();
9429         return (uint64_t)ret_conv;
9430 }
9431
9432 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9433         if ((_res & 1) != 0) return;
9434         LDKCResult_CVec_SignatureZNoneZ _res_conv = *(LDKCResult_CVec_SignatureZNoneZ*)(((uint64_t)_res) & ~1);
9435         FREE((void*)_res);
9436         CResult_CVec_SignatureZNoneZ_free(_res_conv);
9437 }
9438
9439 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9440         LDKCResult_CVec_SignatureZNoneZ* orig_conv = (LDKCResult_CVec_SignatureZNoneZ*)(orig & ~1);
9441         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
9442         *ret_conv = CResult_CVec_SignatureZNoneZ_clone(orig_conv);
9443         return (uint64_t)ret_conv;
9444 }
9445
9446 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1ok(JNIEnv *env, jclass clz) {
9447         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
9448         *ret_conv = CResult_NoneErrorZ_ok();
9449         return (uint64_t)ret_conv;
9450 }
9451
9452 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
9453         LDKIOError e_conv = LDKIOError_from_java(env, e);
9454         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
9455         *ret_conv = CResult_NoneErrorZ_err(e_conv);
9456         return (uint64_t)ret_conv;
9457 }
9458
9459 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9460         if ((_res & 1) != 0) return;
9461         LDKCResult_NoneErrorZ _res_conv = *(LDKCResult_NoneErrorZ*)(((uint64_t)_res) & ~1);
9462         FREE((void*)_res);
9463         CResult_NoneErrorZ_free(_res_conv);
9464 }
9465
9466 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9467         LDKCResult_NoneErrorZ* orig_conv = (LDKCResult_NoneErrorZ*)(orig & ~1);
9468         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
9469         *ret_conv = CResult_NoneErrorZ_clone(orig_conv);
9470         return (uint64_t)ret_conv;
9471 }
9472
9473 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9474         LDKRouteHop o_conv;
9475         o_conv.inner = (void*)(o & (~1));
9476         o_conv.is_owned = (o & 1) || (o == 0);
9477         o_conv = RouteHop_clone(&o_conv);
9478         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
9479         *ret_conv = CResult_RouteHopDecodeErrorZ_ok(o_conv);
9480         return (uint64_t)ret_conv;
9481 }
9482
9483 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9484         LDKDecodeError e_conv;
9485         e_conv.inner = (void*)(e & (~1));
9486         e_conv.is_owned = (e & 1) || (e == 0);
9487         e_conv = DecodeError_clone(&e_conv);
9488         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
9489         *ret_conv = CResult_RouteHopDecodeErrorZ_err(e_conv);
9490         return (uint64_t)ret_conv;
9491 }
9492
9493 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9494         if ((_res & 1) != 0) return;
9495         LDKCResult_RouteHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHopDecodeErrorZ*)(((uint64_t)_res) & ~1);
9496         FREE((void*)_res);
9497         CResult_RouteHopDecodeErrorZ_free(_res_conv);
9498 }
9499
9500 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9501         LDKCResult_RouteHopDecodeErrorZ* orig_conv = (LDKCResult_RouteHopDecodeErrorZ*)(orig & ~1);
9502         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
9503         *ret_conv = CResult_RouteHopDecodeErrorZ_clone(orig_conv);
9504         return (uint64_t)ret_conv;
9505 }
9506
9507 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHopZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
9508         LDKCVec_RouteHopZ _res_constr;
9509         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
9510         if (_res_constr.datalen > 0)
9511                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
9512         else
9513                 _res_constr.data = NULL;
9514         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
9515         for (size_t k = 0; k < _res_constr.datalen; k++) {
9516                 int64_t _res_conv_10 = _res_vals[k];
9517                 LDKRouteHop _res_conv_10_conv;
9518                 _res_conv_10_conv.inner = (void*)(_res_conv_10 & (~1));
9519                 _res_conv_10_conv.is_owned = (_res_conv_10 & 1) || (_res_conv_10 == 0);
9520                 _res_constr.data[k] = _res_conv_10_conv;
9521         }
9522         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
9523         CVec_RouteHopZ_free(_res_constr);
9524 }
9525
9526 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CVec_1RouteHopZZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
9527         LDKCVec_CVec_RouteHopZZ _res_constr;
9528         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
9529         if (_res_constr.datalen > 0)
9530                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
9531         else
9532                 _res_constr.data = NULL;
9533         for (size_t m = 0; m < _res_constr.datalen; m++) {
9534                 int64_tArray _res_conv_12 = (*env)->GetObjectArrayElement(env, _res, m);
9535                 LDKCVec_RouteHopZ _res_conv_12_constr;
9536                 _res_conv_12_constr.datalen = (*env)->GetArrayLength(env, _res_conv_12);
9537                 if (_res_conv_12_constr.datalen > 0)
9538                         _res_conv_12_constr.data = MALLOC(_res_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
9539                 else
9540                         _res_conv_12_constr.data = NULL;
9541                 int64_t* _res_conv_12_vals = (*env)->GetLongArrayElements (env, _res_conv_12, NULL);
9542                 for (size_t k = 0; k < _res_conv_12_constr.datalen; k++) {
9543                         int64_t _res_conv_12_conv_10 = _res_conv_12_vals[k];
9544                         LDKRouteHop _res_conv_12_conv_10_conv;
9545                         _res_conv_12_conv_10_conv.inner = (void*)(_res_conv_12_conv_10 & (~1));
9546                         _res_conv_12_conv_10_conv.is_owned = (_res_conv_12_conv_10 & 1) || (_res_conv_12_conv_10 == 0);
9547                         _res_conv_12_constr.data[k] = _res_conv_12_conv_10_conv;
9548                 }
9549                 (*env)->ReleaseLongArrayElements(env, _res_conv_12, _res_conv_12_vals, 0);
9550                 _res_constr.data[m] = _res_conv_12_constr;
9551         }
9552         CVec_CVec_RouteHopZZ_free(_res_constr);
9553 }
9554
9555 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9556         LDKRoute o_conv;
9557         o_conv.inner = (void*)(o & (~1));
9558         o_conv.is_owned = (o & 1) || (o == 0);
9559         o_conv = Route_clone(&o_conv);
9560         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
9561         *ret_conv = CResult_RouteDecodeErrorZ_ok(o_conv);
9562         return (uint64_t)ret_conv;
9563 }
9564
9565 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9566         LDKDecodeError e_conv;
9567         e_conv.inner = (void*)(e & (~1));
9568         e_conv.is_owned = (e & 1) || (e == 0);
9569         e_conv = DecodeError_clone(&e_conv);
9570         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
9571         *ret_conv = CResult_RouteDecodeErrorZ_err(e_conv);
9572         return (uint64_t)ret_conv;
9573 }
9574
9575 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9576         if ((_res & 1) != 0) return;
9577         LDKCResult_RouteDecodeErrorZ _res_conv = *(LDKCResult_RouteDecodeErrorZ*)(((uint64_t)_res) & ~1);
9578         FREE((void*)_res);
9579         CResult_RouteDecodeErrorZ_free(_res_conv);
9580 }
9581
9582 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9583         LDKCResult_RouteDecodeErrorZ* orig_conv = (LDKCResult_RouteDecodeErrorZ*)(orig & ~1);
9584         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
9585         *ret_conv = CResult_RouteDecodeErrorZ_clone(orig_conv);
9586         return (uint64_t)ret_conv;
9587 }
9588
9589 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1some(JNIEnv *env, jclass clz, int64_t o) {
9590         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
9591         *ret_copy = COption_u64Z_some(o);
9592         uint64_t ret_ref = (uint64_t)ret_copy;
9593         return ret_ref;
9594 }
9595
9596 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1none(JNIEnv *env, jclass clz) {
9597         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
9598         *ret_copy = COption_u64Z_none();
9599         uint64_t ret_ref = (uint64_t)ret_copy;
9600         return ret_ref;
9601 }
9602
9603 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
9604         if ((_res & 1) != 0) return;
9605         LDKCOption_u64Z _res_conv = *(LDKCOption_u64Z*)(((uint64_t)_res) & ~1);
9606         FREE((void*)_res);
9607         COption_u64Z_free(_res_conv);
9608 }
9609
9610 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9611         LDKCOption_u64Z* orig_conv = (LDKCOption_u64Z*)orig;
9612         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
9613         *ret_copy = COption_u64Z_clone(orig_conv);
9614         uint64_t ret_ref = (uint64_t)ret_copy;
9615         return ret_ref;
9616 }
9617
9618 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ChannelDetailsZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
9619         LDKCVec_ChannelDetailsZ _res_constr;
9620         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
9621         if (_res_constr.datalen > 0)
9622                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
9623         else
9624                 _res_constr.data = NULL;
9625         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
9626         for (size_t q = 0; q < _res_constr.datalen; q++) {
9627                 int64_t _res_conv_16 = _res_vals[q];
9628                 LDKChannelDetails _res_conv_16_conv;
9629                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
9630                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
9631                 _res_constr.data[q] = _res_conv_16_conv;
9632         }
9633         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
9634         CVec_ChannelDetailsZ_free(_res_constr);
9635 }
9636
9637 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHintZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
9638         LDKCVec_RouteHintZ _res_constr;
9639         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
9640         if (_res_constr.datalen > 0)
9641                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
9642         else
9643                 _res_constr.data = NULL;
9644         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
9645         for (size_t l = 0; l < _res_constr.datalen; l++) {
9646                 int64_t _res_conv_11 = _res_vals[l];
9647                 LDKRouteHint _res_conv_11_conv;
9648                 _res_conv_11_conv.inner = (void*)(_res_conv_11 & (~1));
9649                 _res_conv_11_conv.is_owned = (_res_conv_11 & 1) || (_res_conv_11 == 0);
9650                 _res_constr.data[l] = _res_conv_11_conv;
9651         }
9652         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
9653         CVec_RouteHintZ_free(_res_constr);
9654 }
9655
9656 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9657         LDKRoute o_conv;
9658         o_conv.inner = (void*)(o & (~1));
9659         o_conv.is_owned = (o & 1) || (o == 0);
9660         o_conv = Route_clone(&o_conv);
9661         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
9662         *ret_conv = CResult_RouteLightningErrorZ_ok(o_conv);
9663         return (uint64_t)ret_conv;
9664 }
9665
9666 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9667         LDKLightningError e_conv;
9668         e_conv.inner = (void*)(e & (~1));
9669         e_conv.is_owned = (e & 1) || (e == 0);
9670         e_conv = LightningError_clone(&e_conv);
9671         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
9672         *ret_conv = CResult_RouteLightningErrorZ_err(e_conv);
9673         return (uint64_t)ret_conv;
9674 }
9675
9676 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9677         if ((_res & 1) != 0) return;
9678         LDKCResult_RouteLightningErrorZ _res_conv = *(LDKCResult_RouteLightningErrorZ*)(((uint64_t)_res) & ~1);
9679         FREE((void*)_res);
9680         CResult_RouteLightningErrorZ_free(_res_conv);
9681 }
9682
9683 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9684         LDKCResult_RouteLightningErrorZ* orig_conv = (LDKCResult_RouteLightningErrorZ*)(orig & ~1);
9685         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
9686         *ret_conv = CResult_RouteLightningErrorZ_clone(orig_conv);
9687         return (uint64_t)ret_conv;
9688 }
9689
9690 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9691         LDKTxOut o_conv = *(LDKTxOut*)(((uint64_t)o) & ~1);
9692         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
9693         *ret_conv = CResult_TxOutAccessErrorZ_ok(o_conv);
9694         return (uint64_t)ret_conv;
9695 }
9696
9697 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
9698         LDKAccessError e_conv = LDKAccessError_from_java(env, e);
9699         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
9700         *ret_conv = CResult_TxOutAccessErrorZ_err(e_conv);
9701         return (uint64_t)ret_conv;
9702 }
9703
9704 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9705         if ((_res & 1) != 0) return;
9706         LDKCResult_TxOutAccessErrorZ _res_conv = *(LDKCResult_TxOutAccessErrorZ*)(((uint64_t)_res) & ~1);
9707         FREE((void*)_res);
9708         CResult_TxOutAccessErrorZ_free(_res_conv);
9709 }
9710
9711 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9712         LDKCResult_TxOutAccessErrorZ* orig_conv = (LDKCResult_TxOutAccessErrorZ*)(orig & ~1);
9713         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
9714         *ret_conv = CResult_TxOutAccessErrorZ_clone(orig_conv);
9715         return (uint64_t)ret_conv;
9716 }
9717
9718 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9719         LDKC2Tuple_usizeTransactionZ* orig_conv = (LDKC2Tuple_usizeTransactionZ*)(orig & ~1);
9720         LDKC2Tuple_usizeTransactionZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
9721         *ret_ref = C2Tuple_usizeTransactionZ_clone(orig_conv);
9722         return (uint64_t)ret_ref;
9723 }
9724
9725 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
9726         LDKTransaction b_ref;
9727         b_ref.datalen = (*env)->GetArrayLength(env, b);
9728         b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
9729         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
9730         b_ref.data_is_owned = true;
9731         LDKC2Tuple_usizeTransactionZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
9732         *ret_ref = C2Tuple_usizeTransactionZ_new(a, b_ref);
9733         return (uint64_t)ret_ref;
9734 }
9735
9736 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9737         if ((_res & 1) != 0) return;
9738         LDKC2Tuple_usizeTransactionZ _res_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)_res) & ~1);
9739         FREE((void*)_res);
9740         C2Tuple_usizeTransactionZ_free(_res_conv);
9741 }
9742
9743 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1usizeTransactionZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
9744         LDKCVec_C2Tuple_usizeTransactionZZ _res_constr;
9745         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
9746         if (_res_constr.datalen > 0)
9747                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
9748         else
9749                 _res_constr.data = NULL;
9750         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
9751         for (size_t y = 0; y < _res_constr.datalen; y++) {
9752                 int64_t _res_conv_24 = _res_vals[y];
9753                 LDKC2Tuple_usizeTransactionZ _res_conv_24_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)_res_conv_24) & ~1);
9754                 FREE((void*)_res_conv_24);
9755                 _res_constr.data[y] = _res_conv_24_conv;
9756         }
9757         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
9758         CVec_C2Tuple_usizeTransactionZZ_free(_res_constr);
9759 }
9760
9761 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TxidZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
9762         LDKCVec_TxidZ _res_constr;
9763         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
9764         if (_res_constr.datalen > 0)
9765                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
9766         else
9767                 _res_constr.data = NULL;
9768         for (size_t i = 0; i < _res_constr.datalen; i++) {
9769                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
9770                 LDKThirtyTwoBytes _res_conv_8_ref;
9771                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 32);
9772                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 32, _res_conv_8_ref.data);
9773                 _res_constr.data[i] = _res_conv_8_ref;
9774         }
9775         CVec_TxidZ_free(_res_constr);
9776 }
9777
9778 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1ok(JNIEnv *env, jclass clz) {
9779         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
9780         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_ok();
9781         return (uint64_t)ret_conv;
9782 }
9783
9784 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1err(JNIEnv *env, jclass clz, jclass e) {
9785         LDKChannelMonitorUpdateErr e_conv = LDKChannelMonitorUpdateErr_from_java(env, e);
9786         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
9787         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_err(e_conv);
9788         return (uint64_t)ret_conv;
9789 }
9790
9791 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9792         if ((_res & 1) != 0) return;
9793         LDKCResult_NoneChannelMonitorUpdateErrZ _res_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)_res) & ~1);
9794         FREE((void*)_res);
9795         CResult_NoneChannelMonitorUpdateErrZ_free(_res_conv);
9796 }
9797
9798 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9799         LDKCResult_NoneChannelMonitorUpdateErrZ* orig_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(orig & ~1);
9800         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
9801         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone(orig_conv);
9802         return (uint64_t)ret_conv;
9803 }
9804
9805 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1MonitorEventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
9806         LDKCVec_MonitorEventZ _res_constr;
9807         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
9808         if (_res_constr.datalen > 0)
9809                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
9810         else
9811                 _res_constr.data = NULL;
9812         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
9813         for (size_t o = 0; o < _res_constr.datalen; o++) {
9814                 int64_t _res_conv_14 = _res_vals[o];
9815                 LDKMonitorEvent _res_conv_14_conv = *(LDKMonitorEvent*)(((uint64_t)_res_conv_14) & ~1);
9816                 FREE((void*)_res_conv_14);
9817                 _res_constr.data[o] = _res_conv_14_conv;
9818         }
9819         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
9820         CVec_MonitorEventZ_free(_res_constr);
9821 }
9822
9823 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1some(JNIEnv *env, jclass clz, int64_t o) {
9824         LDKC2Tuple_usizeTransactionZ o_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)o) & ~1);
9825         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
9826         *ret_copy = COption_C2Tuple_usizeTransactionZZ_some(o_conv);
9827         uint64_t ret_ref = (uint64_t)ret_copy;
9828         return ret_ref;
9829 }
9830
9831 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1none(JNIEnv *env, jclass clz) {
9832         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
9833         *ret_copy = COption_C2Tuple_usizeTransactionZZ_none();
9834         uint64_t ret_ref = (uint64_t)ret_copy;
9835         return ret_ref;
9836 }
9837
9838 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9839         if ((_res & 1) != 0) return;
9840         LDKCOption_C2Tuple_usizeTransactionZZ _res_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(((uint64_t)_res) & ~1);
9841         FREE((void*)_res);
9842         COption_C2Tuple_usizeTransactionZZ_free(_res_conv);
9843 }
9844
9845 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9846         LDKCOption_C2Tuple_usizeTransactionZZ* orig_conv = (LDKCOption_C2Tuple_usizeTransactionZZ*)orig;
9847         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
9848         *ret_copy = COption_C2Tuple_usizeTransactionZZ_clone(orig_conv);
9849         uint64_t ret_ref = (uint64_t)ret_copy;
9850         return ret_ref;
9851 }
9852
9853 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1SpendableOutputDescriptorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
9854         LDKCVec_SpendableOutputDescriptorZ _res_constr;
9855         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
9856         if (_res_constr.datalen > 0)
9857                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
9858         else
9859                 _res_constr.data = NULL;
9860         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
9861         for (size_t b = 0; b < _res_constr.datalen; b++) {
9862                 int64_t _res_conv_27 = _res_vals[b];
9863                 LDKSpendableOutputDescriptor _res_conv_27_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)_res_conv_27) & ~1);
9864                 FREE((void*)_res_conv_27);
9865                 _res_constr.data[b] = _res_conv_27_conv;
9866         }
9867         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
9868         CVec_SpendableOutputDescriptorZ_free(_res_constr);
9869 }
9870
9871 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1MessageSendEventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
9872         LDKCVec_MessageSendEventZ _res_constr;
9873         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
9874         if (_res_constr.datalen > 0)
9875                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
9876         else
9877                 _res_constr.data = NULL;
9878         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
9879         for (size_t s = 0; s < _res_constr.datalen; s++) {
9880                 int64_t _res_conv_18 = _res_vals[s];
9881                 LDKMessageSendEvent _res_conv_18_conv = *(LDKMessageSendEvent*)(((uint64_t)_res_conv_18) & ~1);
9882                 FREE((void*)_res_conv_18);
9883                 _res_constr.data[s] = _res_conv_18_conv;
9884         }
9885         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
9886         CVec_MessageSendEventZ_free(_res_constr);
9887 }
9888
9889 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9890         LDKInitFeatures o_conv;
9891         o_conv.inner = (void*)(o & (~1));
9892         o_conv.is_owned = (o & 1) || (o == 0);
9893         o_conv = InitFeatures_clone(&o_conv);
9894         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
9895         *ret_conv = CResult_InitFeaturesDecodeErrorZ_ok(o_conv);
9896         return (uint64_t)ret_conv;
9897 }
9898
9899 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9900         LDKDecodeError e_conv;
9901         e_conv.inner = (void*)(e & (~1));
9902         e_conv.is_owned = (e & 1) || (e == 0);
9903         e_conv = DecodeError_clone(&e_conv);
9904         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
9905         *ret_conv = CResult_InitFeaturesDecodeErrorZ_err(e_conv);
9906         return (uint64_t)ret_conv;
9907 }
9908
9909 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9910         if ((_res & 1) != 0) return;
9911         LDKCResult_InitFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InitFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
9912         FREE((void*)_res);
9913         CResult_InitFeaturesDecodeErrorZ_free(_res_conv);
9914 }
9915
9916 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9917         LDKNodeFeatures o_conv;
9918         o_conv.inner = (void*)(o & (~1));
9919         o_conv.is_owned = (o & 1) || (o == 0);
9920         o_conv = NodeFeatures_clone(&o_conv);
9921         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
9922         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_ok(o_conv);
9923         return (uint64_t)ret_conv;
9924 }
9925
9926 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9927         LDKDecodeError e_conv;
9928         e_conv.inner = (void*)(e & (~1));
9929         e_conv.is_owned = (e & 1) || (e == 0);
9930         e_conv = DecodeError_clone(&e_conv);
9931         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
9932         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_err(e_conv);
9933         return (uint64_t)ret_conv;
9934 }
9935
9936 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9937         if ((_res & 1) != 0) return;
9938         LDKCResult_NodeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_NodeFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
9939         FREE((void*)_res);
9940         CResult_NodeFeaturesDecodeErrorZ_free(_res_conv);
9941 }
9942
9943 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9944         LDKChannelFeatures o_conv;
9945         o_conv.inner = (void*)(o & (~1));
9946         o_conv.is_owned = (o & 1) || (o == 0);
9947         o_conv = ChannelFeatures_clone(&o_conv);
9948         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
9949         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_ok(o_conv);
9950         return (uint64_t)ret_conv;
9951 }
9952
9953 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9954         LDKDecodeError e_conv;
9955         e_conv.inner = (void*)(e & (~1));
9956         e_conv.is_owned = (e & 1) || (e == 0);
9957         e_conv = DecodeError_clone(&e_conv);
9958         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
9959         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_err(e_conv);
9960         return (uint64_t)ret_conv;
9961 }
9962
9963 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9964         if ((_res & 1) != 0) return;
9965         LDKCResult_ChannelFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
9966         FREE((void*)_res);
9967         CResult_ChannelFeaturesDecodeErrorZ_free(_res_conv);
9968 }
9969
9970 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9971         LDKInvoiceFeatures o_conv;
9972         o_conv.inner = (void*)(o & (~1));
9973         o_conv.is_owned = (o & 1) || (o == 0);
9974         o_conv = InvoiceFeatures_clone(&o_conv);
9975         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
9976         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_ok(o_conv);
9977         return (uint64_t)ret_conv;
9978 }
9979
9980 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9981         LDKDecodeError e_conv;
9982         e_conv.inner = (void*)(e & (~1));
9983         e_conv.is_owned = (e & 1) || (e == 0);
9984         e_conv = DecodeError_clone(&e_conv);
9985         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
9986         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_err(e_conv);
9987         return (uint64_t)ret_conv;
9988 }
9989
9990 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9991         if ((_res & 1) != 0) return;
9992         LDKCResult_InvoiceFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InvoiceFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
9993         FREE((void*)_res);
9994         CResult_InvoiceFeaturesDecodeErrorZ_free(_res_conv);
9995 }
9996
9997 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9998         LDKDelayedPaymentOutputDescriptor o_conv;
9999         o_conv.inner = (void*)(o & (~1));
10000         o_conv.is_owned = (o & 1) || (o == 0);
10001         o_conv = DelayedPaymentOutputDescriptor_clone(&o_conv);
10002         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
10003         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
10004         return (uint64_t)ret_conv;
10005 }
10006
10007 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10008         LDKDecodeError e_conv;
10009         e_conv.inner = (void*)(e & (~1));
10010         e_conv.is_owned = (e & 1) || (e == 0);
10011         e_conv = DecodeError_clone(&e_conv);
10012         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
10013         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
10014         return (uint64_t)ret_conv;
10015 }
10016
10017 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10018         if ((_res & 1) != 0) return;
10019         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(((uint64_t)_res) & ~1);
10020         FREE((void*)_res);
10021         CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
10022 }
10023
10024 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10025         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(orig & ~1);
10026         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
10027         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
10028         return (uint64_t)ret_conv;
10029 }
10030
10031 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10032         LDKStaticPaymentOutputDescriptor o_conv;
10033         o_conv.inner = (void*)(o & (~1));
10034         o_conv.is_owned = (o & 1) || (o == 0);
10035         o_conv = StaticPaymentOutputDescriptor_clone(&o_conv);
10036         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
10037         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
10038         return (uint64_t)ret_conv;
10039 }
10040
10041 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10042         LDKDecodeError e_conv;
10043         e_conv.inner = (void*)(e & (~1));
10044         e_conv.is_owned = (e & 1) || (e == 0);
10045         e_conv = DecodeError_clone(&e_conv);
10046         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
10047         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
10048         return (uint64_t)ret_conv;
10049 }
10050
10051 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10052         if ((_res & 1) != 0) return;
10053         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(((uint64_t)_res) & ~1);
10054         FREE((void*)_res);
10055         CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
10056 }
10057
10058 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10059         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(orig & ~1);
10060         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
10061         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
10062         return (uint64_t)ret_conv;
10063 }
10064
10065 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10066         LDKSpendableOutputDescriptor o_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)o) & ~1);
10067         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
10068         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_ok(o_conv);
10069         return (uint64_t)ret_conv;
10070 }
10071
10072 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10073         LDKDecodeError e_conv;
10074         e_conv.inner = (void*)(e & (~1));
10075         e_conv.is_owned = (e & 1) || (e == 0);
10076         e_conv = DecodeError_clone(&e_conv);
10077         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
10078         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_err(e_conv);
10079         return (uint64_t)ret_conv;
10080 }
10081
10082 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10083         if ((_res & 1) != 0) return;
10084         LDKCResult_SpendableOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(((uint64_t)_res) & ~1);
10085         FREE((void*)_res);
10086         CResult_SpendableOutputDescriptorDecodeErrorZ_free(_res_conv);
10087 }
10088
10089 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10090         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(orig & ~1);
10091         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
10092         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(orig_conv);
10093         return (uint64_t)ret_conv;
10094 }
10095
10096 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10097         LDKC2Tuple_SignatureCVec_SignatureZZ* orig_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(orig & ~1);
10098         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
10099         *ret_ref = C2Tuple_SignatureCVec_SignatureZZ_clone(orig_conv);
10100         return (uint64_t)ret_ref;
10101 }
10102
10103 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, jobjectArray b) {
10104         LDKSignature a_ref;
10105         CHECK((*env)->GetArrayLength(env, a) == 64);
10106         (*env)->GetByteArrayRegion(env, a, 0, 64, a_ref.compact_form);
10107         LDKCVec_SignatureZ b_constr;
10108         b_constr.datalen = (*env)->GetArrayLength(env, b);
10109         if (b_constr.datalen > 0)
10110                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
10111         else
10112                 b_constr.data = NULL;
10113         for (size_t i = 0; i < b_constr.datalen; i++) {
10114                 int8_tArray b_conv_8 = (*env)->GetObjectArrayElement(env, b, i);
10115                 LDKSignature b_conv_8_ref;
10116                 CHECK((*env)->GetArrayLength(env, b_conv_8) == 64);
10117                 (*env)->GetByteArrayRegion(env, b_conv_8, 0, 64, b_conv_8_ref.compact_form);
10118                 b_constr.data[i] = b_conv_8_ref;
10119         }
10120         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
10121         *ret_ref = C2Tuple_SignatureCVec_SignatureZZ_new(a_ref, b_constr);
10122         return (uint64_t)ret_ref;
10123 }
10124
10125 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10126         if ((_res & 1) != 0) return;
10127         LDKC2Tuple_SignatureCVec_SignatureZZ _res_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(((uint64_t)_res) & ~1);
10128         FREE((void*)_res);
10129         C2Tuple_SignatureCVec_SignatureZZ_free(_res_conv);
10130 }
10131
10132 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10133         LDKC2Tuple_SignatureCVec_SignatureZZ o_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(((uint64_t)o) & ~1);
10134         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
10135         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(o_conv);
10136         return (uint64_t)ret_conv;
10137 }
10138
10139 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1err(JNIEnv *env, jclass clz) {
10140         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
10141         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err();
10142         return (uint64_t)ret_conv;
10143 }
10144
10145 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10146         if ((_res & 1) != 0) return;
10147         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ _res_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)_res) & ~1);
10148         FREE((void*)_res);
10149         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(_res_conv);
10150 }
10151
10152 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10153         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* orig_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(orig & ~1);
10154         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
10155         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(orig_conv);
10156         return (uint64_t)ret_conv;
10157 }
10158
10159 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
10160         LDKSignature o_ref;
10161         CHECK((*env)->GetArrayLength(env, o) == 64);
10162         (*env)->GetByteArrayRegion(env, o, 0, 64, o_ref.compact_form);
10163         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
10164         *ret_conv = CResult_SignatureNoneZ_ok(o_ref);
10165         return (uint64_t)ret_conv;
10166 }
10167
10168 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1err(JNIEnv *env, jclass clz) {
10169         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
10170         *ret_conv = CResult_SignatureNoneZ_err();
10171         return (uint64_t)ret_conv;
10172 }
10173
10174 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10175         if ((_res & 1) != 0) return;
10176         LDKCResult_SignatureNoneZ _res_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)_res) & ~1);
10177         FREE((void*)_res);
10178         CResult_SignatureNoneZ_free(_res_conv);
10179 }
10180
10181 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10182         LDKCResult_SignatureNoneZ* orig_conv = (LDKCResult_SignatureNoneZ*)(orig & ~1);
10183         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
10184         *ret_conv = CResult_SignatureNoneZ_clone(orig_conv);
10185         return (uint64_t)ret_conv;
10186 }
10187
10188 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10189         LDKSign o_conv = *(LDKSign*)(((uint64_t)o) & ~1);
10190         if (o_conv.free == LDKSign_JCalls_free) {
10191                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
10192                 LDKSign_JCalls_clone(o_conv.this_arg);
10193         }
10194         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
10195         *ret_conv = CResult_SignDecodeErrorZ_ok(o_conv);
10196         return (uint64_t)ret_conv;
10197 }
10198
10199 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10200         LDKDecodeError e_conv;
10201         e_conv.inner = (void*)(e & (~1));
10202         e_conv.is_owned = (e & 1) || (e == 0);
10203         e_conv = DecodeError_clone(&e_conv);
10204         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
10205         *ret_conv = CResult_SignDecodeErrorZ_err(e_conv);
10206         return (uint64_t)ret_conv;
10207 }
10208
10209 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10210         if ((_res & 1) != 0) return;
10211         LDKCResult_SignDecodeErrorZ _res_conv = *(LDKCResult_SignDecodeErrorZ*)(((uint64_t)_res) & ~1);
10212         FREE((void*)_res);
10213         CResult_SignDecodeErrorZ_free(_res_conv);
10214 }
10215
10216 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10217         LDKCResult_SignDecodeErrorZ* orig_conv = (LDKCResult_SignDecodeErrorZ*)(orig & ~1);
10218         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
10219         *ret_conv = CResult_SignDecodeErrorZ_clone(orig_conv);
10220         return (uint64_t)ret_conv;
10221 }
10222
10223 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u8Z_1free(JNIEnv *env, jclass clz, int8_tArray _res) {
10224         LDKCVec_u8Z _res_ref;
10225         _res_ref.datalen = (*env)->GetArrayLength(env, _res);
10226         _res_ref.data = MALLOC(_res_ref.datalen, "LDKCVec_u8Z Bytes");
10227         (*env)->GetByteArrayRegion(env, _res, 0, _res_ref.datalen, _res_ref.data);
10228         CVec_u8Z_free(_res_ref);
10229 }
10230
10231 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray arg) {
10232         LDKRecoverableSignature arg_ref;
10233         CHECK((*env)->GetArrayLength(env, arg) == 68);
10234         (*env)->GetByteArrayRegion(env, arg, 0, 68, arg_ref.serialized_form);
10235         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
10236         *ret_conv = CResult_RecoverableSignatureNoneZ_ok(arg_ref);
10237         return (uint64_t)ret_conv;
10238 }
10239
10240 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1err(JNIEnv *env, jclass clz) {
10241         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
10242         *ret_conv = CResult_RecoverableSignatureNoneZ_err();
10243         return (uint64_t)ret_conv;
10244 }
10245
10246 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10247         if ((_res & 1) != 0) return;
10248         LDKCResult_RecoverableSignatureNoneZ _res_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(((uint64_t)_res) & ~1);
10249         FREE((void*)_res);
10250         CResult_RecoverableSignatureNoneZ_free(_res_conv);
10251 }
10252
10253 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10254         LDKCResult_RecoverableSignatureNoneZ* orig_conv = (LDKCResult_RecoverableSignatureNoneZ*)(orig & ~1);
10255         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
10256         *ret_conv = CResult_RecoverableSignatureNoneZ_clone(orig_conv);
10257         return (uint64_t)ret_conv;
10258 }
10259
10260 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CVec_1u8ZZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
10261         LDKCVec_CVec_u8ZZ _res_constr;
10262         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
10263         if (_res_constr.datalen > 0)
10264                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
10265         else
10266                 _res_constr.data = NULL;
10267         for (size_t i = 0; i < _res_constr.datalen; i++) {
10268                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
10269                 LDKCVec_u8Z _res_conv_8_ref;
10270                 _res_conv_8_ref.datalen = (*env)->GetArrayLength(env, _res_conv_8);
10271                 _res_conv_8_ref.data = MALLOC(_res_conv_8_ref.datalen, "LDKCVec_u8Z Bytes");
10272                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, _res_conv_8_ref.datalen, _res_conv_8_ref.data);
10273                 _res_constr.data[i] = _res_conv_8_ref;
10274         }
10275         CVec_CVec_u8ZZ_free(_res_constr);
10276 }
10277
10278 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1ok(JNIEnv *env, jclass clz, jobjectArray o) {
10279         LDKCVec_CVec_u8ZZ o_constr;
10280         o_constr.datalen = (*env)->GetArrayLength(env, o);
10281         if (o_constr.datalen > 0)
10282                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
10283         else
10284                 o_constr.data = NULL;
10285         for (size_t i = 0; i < o_constr.datalen; i++) {
10286                 int8_tArray o_conv_8 = (*env)->GetObjectArrayElement(env, o, i);
10287                 LDKCVec_u8Z o_conv_8_ref;
10288                 o_conv_8_ref.datalen = (*env)->GetArrayLength(env, o_conv_8);
10289                 o_conv_8_ref.data = MALLOC(o_conv_8_ref.datalen, "LDKCVec_u8Z Bytes");
10290                 (*env)->GetByteArrayRegion(env, o_conv_8, 0, o_conv_8_ref.datalen, o_conv_8_ref.data);
10291                 o_constr.data[i] = o_conv_8_ref;
10292         }
10293         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
10294         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_ok(o_constr);
10295         return (uint64_t)ret_conv;
10296 }
10297
10298 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1err(JNIEnv *env, jclass clz) {
10299         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
10300         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_err();
10301         return (uint64_t)ret_conv;
10302 }
10303
10304 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10305         if ((_res & 1) != 0) return;
10306         LDKCResult_CVec_CVec_u8ZZNoneZ _res_conv = *(LDKCResult_CVec_CVec_u8ZZNoneZ*)(((uint64_t)_res) & ~1);
10307         FREE((void*)_res);
10308         CResult_CVec_CVec_u8ZZNoneZ_free(_res_conv);
10309 }
10310
10311 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10312         LDKCResult_CVec_CVec_u8ZZNoneZ* orig_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(orig & ~1);
10313         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
10314         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(orig_conv);
10315         return (uint64_t)ret_conv;
10316 }
10317
10318 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10319         LDKInMemorySigner o_conv;
10320         o_conv.inner = (void*)(o & (~1));
10321         o_conv.is_owned = (o & 1) || (o == 0);
10322         o_conv = InMemorySigner_clone(&o_conv);
10323         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
10324         *ret_conv = CResult_InMemorySignerDecodeErrorZ_ok(o_conv);
10325         return (uint64_t)ret_conv;
10326 }
10327
10328 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10329         LDKDecodeError e_conv;
10330         e_conv.inner = (void*)(e & (~1));
10331         e_conv.is_owned = (e & 1) || (e == 0);
10332         e_conv = DecodeError_clone(&e_conv);
10333         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
10334         *ret_conv = CResult_InMemorySignerDecodeErrorZ_err(e_conv);
10335         return (uint64_t)ret_conv;
10336 }
10337
10338 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10339         if ((_res & 1) != 0) return;
10340         LDKCResult_InMemorySignerDecodeErrorZ _res_conv = *(LDKCResult_InMemorySignerDecodeErrorZ*)(((uint64_t)_res) & ~1);
10341         FREE((void*)_res);
10342         CResult_InMemorySignerDecodeErrorZ_free(_res_conv);
10343 }
10344
10345 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10346         LDKCResult_InMemorySignerDecodeErrorZ* orig_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(orig & ~1);
10347         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
10348         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(orig_conv);
10349         return (uint64_t)ret_conv;
10350 }
10351
10352 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TxOutZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
10353         LDKCVec_TxOutZ _res_constr;
10354         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
10355         if (_res_constr.datalen > 0)
10356                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
10357         else
10358                 _res_constr.data = NULL;
10359         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
10360         for (size_t h = 0; h < _res_constr.datalen; h++) {
10361                 int64_t _res_conv_7 = _res_vals[h];
10362                 LDKTxOut _res_conv_7_conv = *(LDKTxOut*)(((uint64_t)_res_conv_7) & ~1);
10363                 FREE((void*)_res_conv_7);
10364                 _res_constr.data[h] = _res_conv_7_conv;
10365         }
10366         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
10367         CVec_TxOutZ_free(_res_constr);
10368 }
10369
10370 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
10371         LDKTransaction o_ref;
10372         o_ref.datalen = (*env)->GetArrayLength(env, o);
10373         o_ref.data = MALLOC(o_ref.datalen, "LDKTransaction Bytes");
10374         (*env)->GetByteArrayRegion(env, o, 0, o_ref.datalen, o_ref.data);
10375         o_ref.data_is_owned = true;
10376         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
10377         *ret_conv = CResult_TransactionNoneZ_ok(o_ref);
10378         return (uint64_t)ret_conv;
10379 }
10380
10381 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1err(JNIEnv *env, jclass clz) {
10382         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
10383         *ret_conv = CResult_TransactionNoneZ_err();
10384         return (uint64_t)ret_conv;
10385 }
10386
10387 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10388         if ((_res & 1) != 0) return;
10389         LDKCResult_TransactionNoneZ _res_conv = *(LDKCResult_TransactionNoneZ*)(((uint64_t)_res) & ~1);
10390         FREE((void*)_res);
10391         CResult_TransactionNoneZ_free(_res_conv);
10392 }
10393
10394 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10395         LDKCResult_TransactionNoneZ* orig_conv = (LDKCResult_TransactionNoneZ*)(orig & ~1);
10396         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
10397         *ret_conv = CResult_TransactionNoneZ_clone(orig_conv);
10398         return (uint64_t)ret_conv;
10399 }
10400
10401 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
10402         LDKThirtyTwoBytes a_ref;
10403         CHECK((*env)->GetArrayLength(env, a) == 32);
10404         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
10405         LDKChannelMonitor b_conv;
10406         b_conv.inner = (void*)(b & (~1));
10407         b_conv.is_owned = (b & 1) || (b == 0);
10408         b_conv = ChannelMonitor_clone(&b_conv);
10409         LDKC2Tuple_BlockHashChannelMonitorZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
10410         *ret_ref = C2Tuple_BlockHashChannelMonitorZ_new(a_ref, b_conv);
10411         return (uint64_t)ret_ref;
10412 }
10413
10414 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10415         if ((_res & 1) != 0) return;
10416         LDKC2Tuple_BlockHashChannelMonitorZ _res_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)_res) & ~1);
10417         FREE((void*)_res);
10418         C2Tuple_BlockHashChannelMonitorZ_free(_res_conv);
10419 }
10420
10421 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1BlockHashChannelMonitorZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
10422         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ _res_constr;
10423         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
10424         if (_res_constr.datalen > 0)
10425                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Elements");
10426         else
10427                 _res_constr.data = NULL;
10428         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
10429         for (size_t i = 0; i < _res_constr.datalen; i++) {
10430                 int64_t _res_conv_34 = _res_vals[i];
10431                 LDKC2Tuple_BlockHashChannelMonitorZ _res_conv_34_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)_res_conv_34) & ~1);
10432                 FREE((void*)_res_conv_34);
10433                 _res_constr.data[i] = _res_conv_34_conv;
10434         }
10435         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
10436         CVec_C2Tuple_BlockHashChannelMonitorZZ_free(_res_constr);
10437 }
10438
10439 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1ok(JNIEnv *env, jclass clz, int64_tArray o) {
10440         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ o_constr;
10441         o_constr.datalen = (*env)->GetArrayLength(env, o);
10442         if (o_constr.datalen > 0)
10443                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Elements");
10444         else
10445                 o_constr.data = NULL;
10446         int64_t* o_vals = (*env)->GetLongArrayElements (env, o, NULL);
10447         for (size_t i = 0; i < o_constr.datalen; i++) {
10448                 int64_t o_conv_34 = o_vals[i];
10449                 LDKC2Tuple_BlockHashChannelMonitorZ o_conv_34_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)o_conv_34) & ~1);
10450                 // Warning: we may need a move here but no clone is available for LDKC2Tuple_BlockHashChannelMonitorZ
10451                 o_constr.data[i] = o_conv_34_conv;
10452         }
10453         (*env)->ReleaseLongArrayElements(env, o, o_vals, 0);
10454         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
10455         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_ok(o_constr);
10456         return (uint64_t)ret_conv;
10457 }
10458
10459 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
10460         LDKIOError e_conv = LDKIOError_from_java(env, e);
10461         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
10462         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_err(e_conv);
10463         return (uint64_t)ret_conv;
10464 }
10465
10466 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10467         if ((_res & 1) != 0) return;
10468         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ _res_conv = *(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(((uint64_t)_res) & ~1);
10469         FREE((void*)_res);
10470         CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_free(_res_conv);
10471 }
10472
10473 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1some(JNIEnv *env, jclass clz, int16_t o) {
10474         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
10475         *ret_copy = COption_u16Z_some(o);
10476         uint64_t ret_ref = (uint64_t)ret_copy;
10477         return ret_ref;
10478 }
10479
10480 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1none(JNIEnv *env, jclass clz) {
10481         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
10482         *ret_copy = COption_u16Z_none();
10483         uint64_t ret_ref = (uint64_t)ret_copy;
10484         return ret_ref;
10485 }
10486
10487 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
10488         if ((_res & 1) != 0) return;
10489         LDKCOption_u16Z _res_conv = *(LDKCOption_u16Z*)(((uint64_t)_res) & ~1);
10490         FREE((void*)_res);
10491         COption_u16Z_free(_res_conv);
10492 }
10493
10494 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10495         LDKCOption_u16Z* orig_conv = (LDKCOption_u16Z*)orig;
10496         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
10497         *ret_copy = COption_u16Z_clone(orig_conv);
10498         uint64_t ret_ref = (uint64_t)ret_copy;
10499         return ret_ref;
10500 }
10501
10502 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1ok(JNIEnv *env, jclass clz) {
10503         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
10504         *ret_conv = CResult_NoneAPIErrorZ_ok();
10505         return (uint64_t)ret_conv;
10506 }
10507
10508 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10509         LDKAPIError e_conv = *(LDKAPIError*)(((uint64_t)e) & ~1);
10510         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
10511         *ret_conv = CResult_NoneAPIErrorZ_err(e_conv);
10512         return (uint64_t)ret_conv;
10513 }
10514
10515 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10516         if ((_res & 1) != 0) return;
10517         LDKCResult_NoneAPIErrorZ _res_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)_res) & ~1);
10518         FREE((void*)_res);
10519         CResult_NoneAPIErrorZ_free(_res_conv);
10520 }
10521
10522 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10523         LDKCResult_NoneAPIErrorZ* orig_conv = (LDKCResult_NoneAPIErrorZ*)(orig & ~1);
10524         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
10525         *ret_conv = CResult_NoneAPIErrorZ_clone(orig_conv);
10526         return (uint64_t)ret_conv;
10527 }
10528
10529 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CResult_1NoneAPIErrorZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
10530         LDKCVec_CResult_NoneAPIErrorZZ _res_constr;
10531         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
10532         if (_res_constr.datalen > 0)
10533                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
10534         else
10535                 _res_constr.data = NULL;
10536         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
10537         for (size_t w = 0; w < _res_constr.datalen; w++) {
10538                 int64_t _res_conv_22 = _res_vals[w];
10539                 LDKCResult_NoneAPIErrorZ _res_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)_res_conv_22) & ~1);
10540                 FREE((void*)_res_conv_22);
10541                 _res_constr.data[w] = _res_conv_22_conv;
10542         }
10543         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
10544         CVec_CResult_NoneAPIErrorZZ_free(_res_constr);
10545 }
10546
10547 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1APIErrorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
10548         LDKCVec_APIErrorZ _res_constr;
10549         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
10550         if (_res_constr.datalen > 0)
10551                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
10552         else
10553                 _res_constr.data = NULL;
10554         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
10555         for (size_t k = 0; k < _res_constr.datalen; k++) {
10556                 int64_t _res_conv_10 = _res_vals[k];
10557                 LDKAPIError _res_conv_10_conv = *(LDKAPIError*)(((uint64_t)_res_conv_10) & ~1);
10558                 FREE((void*)_res_conv_10);
10559                 _res_constr.data[k] = _res_conv_10_conv;
10560         }
10561         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
10562         CVec_APIErrorZ_free(_res_constr);
10563 }
10564
10565 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1ok(JNIEnv *env, jclass clz) {
10566         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
10567         *ret_conv = CResult_NonePaymentSendFailureZ_ok();
10568         return (uint64_t)ret_conv;
10569 }
10570
10571 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10572         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(((uint64_t)e) & ~1);
10573         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
10574         *ret_conv = CResult_NonePaymentSendFailureZ_err(e_conv);
10575         return (uint64_t)ret_conv;
10576 }
10577
10578 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10579         if ((_res & 1) != 0) return;
10580         LDKCResult_NonePaymentSendFailureZ _res_conv = *(LDKCResult_NonePaymentSendFailureZ*)(((uint64_t)_res) & ~1);
10581         FREE((void*)_res);
10582         CResult_NonePaymentSendFailureZ_free(_res_conv);
10583 }
10584
10585 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10586         LDKCResult_NonePaymentSendFailureZ* orig_conv = (LDKCResult_NonePaymentSendFailureZ*)(orig & ~1);
10587         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
10588         *ret_conv = CResult_NonePaymentSendFailureZ_clone(orig_conv);
10589         return (uint64_t)ret_conv;
10590 }
10591
10592 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1NetAddressZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
10593         LDKCVec_NetAddressZ _res_constr;
10594         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
10595         if (_res_constr.datalen > 0)
10596                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
10597         else
10598                 _res_constr.data = NULL;
10599         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
10600         for (size_t m = 0; m < _res_constr.datalen; m++) {
10601                 int64_t _res_conv_12 = _res_vals[m];
10602                 LDKNetAddress _res_conv_12_conv = *(LDKNetAddress*)(((uint64_t)_res_conv_12) & ~1);
10603                 FREE((void*)_res_conv_12);
10604                 _res_constr.data[m] = _res_conv_12_conv;
10605         }
10606         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
10607         CVec_NetAddressZ_free(_res_constr);
10608 }
10609
10610 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10611         LDKC2Tuple_PaymentHashPaymentSecretZ* orig_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(orig & ~1);
10612         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
10613         *ret_ref = C2Tuple_PaymentHashPaymentSecretZ_clone(orig_conv);
10614         return (uint64_t)ret_ref;
10615 }
10616
10617 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int8_tArray b) {
10618         LDKThirtyTwoBytes a_ref;
10619         CHECK((*env)->GetArrayLength(env, a) == 32);
10620         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
10621         LDKThirtyTwoBytes b_ref;
10622         CHECK((*env)->GetArrayLength(env, b) == 32);
10623         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
10624         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
10625         *ret_ref = C2Tuple_PaymentHashPaymentSecretZ_new(a_ref, b_ref);
10626         return (uint64_t)ret_ref;
10627 }
10628
10629 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10630         if ((_res & 1) != 0) return;
10631         LDKC2Tuple_PaymentHashPaymentSecretZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(((uint64_t)_res) & ~1);
10632         FREE((void*)_res);
10633         C2Tuple_PaymentHashPaymentSecretZ_free(_res_conv);
10634 }
10635
10636 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
10637         LDKThirtyTwoBytes o_ref;
10638         CHECK((*env)->GetArrayLength(env, o) == 32);
10639         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
10640         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
10641         *ret_conv = CResult_PaymentSecretAPIErrorZ_ok(o_ref);
10642         return (uint64_t)ret_conv;
10643 }
10644
10645 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10646         LDKAPIError e_conv = *(LDKAPIError*)(((uint64_t)e) & ~1);
10647         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
10648         *ret_conv = CResult_PaymentSecretAPIErrorZ_err(e_conv);
10649         return (uint64_t)ret_conv;
10650 }
10651
10652 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10653         if ((_res & 1) != 0) return;
10654         LDKCResult_PaymentSecretAPIErrorZ _res_conv = *(LDKCResult_PaymentSecretAPIErrorZ*)(((uint64_t)_res) & ~1);
10655         FREE((void*)_res);
10656         CResult_PaymentSecretAPIErrorZ_free(_res_conv);
10657 }
10658
10659 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10660         LDKCResult_PaymentSecretAPIErrorZ* orig_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(orig & ~1);
10661         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
10662         *ret_conv = CResult_PaymentSecretAPIErrorZ_clone(orig_conv);
10663         return (uint64_t)ret_conv;
10664 }
10665
10666 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ChannelMonitorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
10667         LDKCVec_ChannelMonitorZ _res_constr;
10668         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
10669         if (_res_constr.datalen > 0)
10670                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
10671         else
10672                 _res_constr.data = NULL;
10673         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
10674         for (size_t q = 0; q < _res_constr.datalen; q++) {
10675                 int64_t _res_conv_16 = _res_vals[q];
10676                 LDKChannelMonitor _res_conv_16_conv;
10677                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
10678                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
10679                 _res_constr.data[q] = _res_conv_16_conv;
10680         }
10681         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
10682         CVec_ChannelMonitorZ_free(_res_constr);
10683 }
10684
10685 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
10686         LDKThirtyTwoBytes a_ref;
10687         CHECK((*env)->GetArrayLength(env, a) == 32);
10688         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
10689         LDKChannelManager b_conv;
10690         b_conv.inner = (void*)(b & (~1));
10691         b_conv.is_owned = (b & 1) || (b == 0);
10692         // Warning: we need a move here but no clone is available for LDKChannelManager
10693         LDKC2Tuple_BlockHashChannelManagerZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
10694         *ret_ref = C2Tuple_BlockHashChannelManagerZ_new(a_ref, b_conv);
10695         return (uint64_t)ret_ref;
10696 }
10697
10698 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10699         if ((_res & 1) != 0) return;
10700         LDKC2Tuple_BlockHashChannelManagerZ _res_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(((uint64_t)_res) & ~1);
10701         FREE((void*)_res);
10702         C2Tuple_BlockHashChannelManagerZ_free(_res_conv);
10703 }
10704
10705 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10706         LDKC2Tuple_BlockHashChannelManagerZ o_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(((uint64_t)o) & ~1);
10707         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
10708         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(o_conv);
10709         return (uint64_t)ret_conv;
10710 }
10711
10712 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10713         LDKDecodeError e_conv;
10714         e_conv.inner = (void*)(e & (~1));
10715         e_conv.is_owned = (e & 1) || (e == 0);
10716         e_conv = DecodeError_clone(&e_conv);
10717         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
10718         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(e_conv);
10719         return (uint64_t)ret_conv;
10720 }
10721
10722 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10723         if ((_res & 1) != 0) return;
10724         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(((uint64_t)_res) & ~1);
10725         FREE((void*)_res);
10726         CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(_res_conv);
10727 }
10728
10729 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10730         LDKChannelConfig o_conv;
10731         o_conv.inner = (void*)(o & (~1));
10732         o_conv.is_owned = (o & 1) || (o == 0);
10733         o_conv = ChannelConfig_clone(&o_conv);
10734         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
10735         *ret_conv = CResult_ChannelConfigDecodeErrorZ_ok(o_conv);
10736         return (uint64_t)ret_conv;
10737 }
10738
10739 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10740         LDKDecodeError e_conv;
10741         e_conv.inner = (void*)(e & (~1));
10742         e_conv.is_owned = (e & 1) || (e == 0);
10743         e_conv = DecodeError_clone(&e_conv);
10744         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
10745         *ret_conv = CResult_ChannelConfigDecodeErrorZ_err(e_conv);
10746         return (uint64_t)ret_conv;
10747 }
10748
10749 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10750         if ((_res & 1) != 0) return;
10751         LDKCResult_ChannelConfigDecodeErrorZ _res_conv = *(LDKCResult_ChannelConfigDecodeErrorZ*)(((uint64_t)_res) & ~1);
10752         FREE((void*)_res);
10753         CResult_ChannelConfigDecodeErrorZ_free(_res_conv);
10754 }
10755
10756 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10757         LDKCResult_ChannelConfigDecodeErrorZ* orig_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(orig & ~1);
10758         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
10759         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(orig_conv);
10760         return (uint64_t)ret_conv;
10761 }
10762
10763 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10764         LDKOutPoint o_conv;
10765         o_conv.inner = (void*)(o & (~1));
10766         o_conv.is_owned = (o & 1) || (o == 0);
10767         o_conv = OutPoint_clone(&o_conv);
10768         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
10769         *ret_conv = CResult_OutPointDecodeErrorZ_ok(o_conv);
10770         return (uint64_t)ret_conv;
10771 }
10772
10773 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10774         LDKDecodeError e_conv;
10775         e_conv.inner = (void*)(e & (~1));
10776         e_conv.is_owned = (e & 1) || (e == 0);
10777         e_conv = DecodeError_clone(&e_conv);
10778         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
10779         *ret_conv = CResult_OutPointDecodeErrorZ_err(e_conv);
10780         return (uint64_t)ret_conv;
10781 }
10782
10783 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10784         if ((_res & 1) != 0) return;
10785         LDKCResult_OutPointDecodeErrorZ _res_conv = *(LDKCResult_OutPointDecodeErrorZ*)(((uint64_t)_res) & ~1);
10786         FREE((void*)_res);
10787         CResult_OutPointDecodeErrorZ_free(_res_conv);
10788 }
10789
10790 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10791         LDKCResult_OutPointDecodeErrorZ* orig_conv = (LDKCResult_OutPointDecodeErrorZ*)(orig & ~1);
10792         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
10793         *ret_conv = CResult_OutPointDecodeErrorZ_clone(orig_conv);
10794         return (uint64_t)ret_conv;
10795 }
10796
10797 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixNoneZ_1ok(JNIEnv *env, jclass clz, jclass o) {
10798         LDKSiPrefix o_conv = LDKSiPrefix_from_java(env, o);
10799         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
10800         *ret_conv = CResult_SiPrefixNoneZ_ok(o_conv);
10801         return (uint64_t)ret_conv;
10802 }
10803
10804 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixNoneZ_1err(JNIEnv *env, jclass clz) {
10805         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
10806         *ret_conv = CResult_SiPrefixNoneZ_err();
10807         return (uint64_t)ret_conv;
10808 }
10809
10810 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10811         if ((_res & 1) != 0) return;
10812         LDKCResult_SiPrefixNoneZ _res_conv = *(LDKCResult_SiPrefixNoneZ*)(((uint64_t)_res) & ~1);
10813         FREE((void*)_res);
10814         CResult_SiPrefixNoneZ_free(_res_conv);
10815 }
10816
10817 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10818         LDKCResult_SiPrefixNoneZ* orig_conv = (LDKCResult_SiPrefixNoneZ*)(orig & ~1);
10819         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
10820         *ret_conv = CResult_SiPrefixNoneZ_clone(orig_conv);
10821         return (uint64_t)ret_conv;
10822 }
10823
10824 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10825         LDKInvoice o_conv;
10826         o_conv.inner = (void*)(o & (~1));
10827         o_conv.is_owned = (o & 1) || (o == 0);
10828         o_conv = Invoice_clone(&o_conv);
10829         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
10830         *ret_conv = CResult_InvoiceNoneZ_ok(o_conv);
10831         return (uint64_t)ret_conv;
10832 }
10833
10834 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceNoneZ_1err(JNIEnv *env, jclass clz) {
10835         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
10836         *ret_conv = CResult_InvoiceNoneZ_err();
10837         return (uint64_t)ret_conv;
10838 }
10839
10840 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10841         if ((_res & 1) != 0) return;
10842         LDKCResult_InvoiceNoneZ _res_conv = *(LDKCResult_InvoiceNoneZ*)(((uint64_t)_res) & ~1);
10843         FREE((void*)_res);
10844         CResult_InvoiceNoneZ_free(_res_conv);
10845 }
10846
10847 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10848         LDKCResult_InvoiceNoneZ* orig_conv = (LDKCResult_InvoiceNoneZ*)(orig & ~1);
10849         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
10850         *ret_conv = CResult_InvoiceNoneZ_clone(orig_conv);
10851         return (uint64_t)ret_conv;
10852 }
10853
10854 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10855         LDKSignedRawInvoice o_conv;
10856         o_conv.inner = (void*)(o & (~1));
10857         o_conv.is_owned = (o & 1) || (o == 0);
10858         o_conv = SignedRawInvoice_clone(&o_conv);
10859         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
10860         *ret_conv = CResult_SignedRawInvoiceNoneZ_ok(o_conv);
10861         return (uint64_t)ret_conv;
10862 }
10863
10864 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceNoneZ_1err(JNIEnv *env, jclass clz) {
10865         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
10866         *ret_conv = CResult_SignedRawInvoiceNoneZ_err();
10867         return (uint64_t)ret_conv;
10868 }
10869
10870 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10871         if ((_res & 1) != 0) return;
10872         LDKCResult_SignedRawInvoiceNoneZ _res_conv = *(LDKCResult_SignedRawInvoiceNoneZ*)(((uint64_t)_res) & ~1);
10873         FREE((void*)_res);
10874         CResult_SignedRawInvoiceNoneZ_free(_res_conv);
10875 }
10876
10877 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10878         LDKCResult_SignedRawInvoiceNoneZ* orig_conv = (LDKCResult_SignedRawInvoiceNoneZ*)(orig & ~1);
10879         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
10880         *ret_conv = CResult_SignedRawInvoiceNoneZ_clone(orig_conv);
10881         return (uint64_t)ret_conv;
10882 }
10883
10884 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10885         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* orig_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(orig & ~1);
10886         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_ref = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
10887         *ret_ref = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(orig_conv);
10888         return (uint64_t)ret_ref;
10889 }
10890
10891 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) {
10892         LDKRawInvoice a_conv;
10893         a_conv.inner = (void*)(a & (~1));
10894         a_conv.is_owned = (a & 1) || (a == 0);
10895         a_conv = RawInvoice_clone(&a_conv);
10896         LDKThirtyTwoBytes b_ref;
10897         CHECK((*env)->GetArrayLength(env, b) == 32);
10898         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
10899         LDKInvoiceSignature c_conv;
10900         c_conv.inner = (void*)(c & (~1));
10901         c_conv.is_owned = (c & 1) || (c == 0);
10902         c_conv = InvoiceSignature_clone(&c_conv);
10903         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_ref = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
10904         *ret_ref = C3Tuple_RawInvoice_u832InvoiceSignatureZ_new(a_conv, b_ref, c_conv);
10905         return (uint64_t)ret_ref;
10906 }
10907
10908 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10909         if ((_res & 1) != 0) return;
10910         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ _res_conv = *(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(((uint64_t)_res) & ~1);
10911         FREE((void*)_res);
10912         C3Tuple_RawInvoice_u832InvoiceSignatureZ_free(_res_conv);
10913 }
10914
10915 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10916         LDKPayeePubKey o_conv;
10917         o_conv.inner = (void*)(o & (~1));
10918         o_conv.is_owned = (o & 1) || (o == 0);
10919         o_conv = PayeePubKey_clone(&o_conv);
10920         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
10921         *ret_conv = CResult_PayeePubKeyErrorZ_ok(o_conv);
10922         return (uint64_t)ret_conv;
10923 }
10924
10925 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
10926         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
10927         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
10928         *ret_conv = CResult_PayeePubKeyErrorZ_err(e_conv);
10929         return (uint64_t)ret_conv;
10930 }
10931
10932 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10933         if ((_res & 1) != 0) return;
10934         LDKCResult_PayeePubKeyErrorZ _res_conv = *(LDKCResult_PayeePubKeyErrorZ*)(((uint64_t)_res) & ~1);
10935         FREE((void*)_res);
10936         CResult_PayeePubKeyErrorZ_free(_res_conv);
10937 }
10938
10939 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10940         LDKCResult_PayeePubKeyErrorZ* orig_conv = (LDKCResult_PayeePubKeyErrorZ*)(orig & ~1);
10941         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
10942         *ret_conv = CResult_PayeePubKeyErrorZ_clone(orig_conv);
10943         return (uint64_t)ret_conv;
10944 }
10945
10946 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PrivateRouteZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
10947         LDKCVec_PrivateRouteZ _res_constr;
10948         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
10949         if (_res_constr.datalen > 0)
10950                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPrivateRoute), "LDKCVec_PrivateRouteZ Elements");
10951         else
10952                 _res_constr.data = NULL;
10953         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
10954         for (size_t o = 0; o < _res_constr.datalen; o++) {
10955                 int64_t _res_conv_14 = _res_vals[o];
10956                 LDKPrivateRoute _res_conv_14_conv;
10957                 _res_conv_14_conv.inner = (void*)(_res_conv_14 & (~1));
10958                 _res_conv_14_conv.is_owned = (_res_conv_14 & 1) || (_res_conv_14 == 0);
10959                 _res_constr.data[o] = _res_conv_14_conv;
10960         }
10961         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
10962         CVec_PrivateRouteZ_free(_res_constr);
10963 }
10964
10965 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10966         LDKPositiveTimestamp o_conv;
10967         o_conv.inner = (void*)(o & (~1));
10968         o_conv.is_owned = (o & 1) || (o == 0);
10969         o_conv = PositiveTimestamp_clone(&o_conv);
10970         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
10971         *ret_conv = CResult_PositiveTimestampCreationErrorZ_ok(o_conv);
10972         return (uint64_t)ret_conv;
10973 }
10974
10975 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
10976         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
10977         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
10978         *ret_conv = CResult_PositiveTimestampCreationErrorZ_err(e_conv);
10979         return (uint64_t)ret_conv;
10980 }
10981
10982 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10983         if ((_res & 1) != 0) return;
10984         LDKCResult_PositiveTimestampCreationErrorZ _res_conv = *(LDKCResult_PositiveTimestampCreationErrorZ*)(((uint64_t)_res) & ~1);
10985         FREE((void*)_res);
10986         CResult_PositiveTimestampCreationErrorZ_free(_res_conv);
10987 }
10988
10989 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10990         LDKCResult_PositiveTimestampCreationErrorZ* orig_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(orig & ~1);
10991         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
10992         *ret_conv = CResult_PositiveTimestampCreationErrorZ_clone(orig_conv);
10993         return (uint64_t)ret_conv;
10994 }
10995
10996 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1ok(JNIEnv *env, jclass clz) {
10997         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
10998         *ret_conv = CResult_NoneSemanticErrorZ_ok();
10999         return (uint64_t)ret_conv;
11000 }
11001
11002 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
11003         LDKSemanticError e_conv = LDKSemanticError_from_java(env, e);
11004         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
11005         *ret_conv = CResult_NoneSemanticErrorZ_err(e_conv);
11006         return (uint64_t)ret_conv;
11007 }
11008
11009 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11010         if ((_res & 1) != 0) return;
11011         LDKCResult_NoneSemanticErrorZ _res_conv = *(LDKCResult_NoneSemanticErrorZ*)(((uint64_t)_res) & ~1);
11012         FREE((void*)_res);
11013         CResult_NoneSemanticErrorZ_free(_res_conv);
11014 }
11015
11016 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11017         LDKCResult_NoneSemanticErrorZ* orig_conv = (LDKCResult_NoneSemanticErrorZ*)(orig & ~1);
11018         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
11019         *ret_conv = CResult_NoneSemanticErrorZ_clone(orig_conv);
11020         return (uint64_t)ret_conv;
11021 }
11022
11023 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11024         LDKInvoice o_conv;
11025         o_conv.inner = (void*)(o & (~1));
11026         o_conv.is_owned = (o & 1) || (o == 0);
11027         o_conv = Invoice_clone(&o_conv);
11028         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
11029         *ret_conv = CResult_InvoiceSemanticErrorZ_ok(o_conv);
11030         return (uint64_t)ret_conv;
11031 }
11032
11033 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
11034         LDKSemanticError e_conv = LDKSemanticError_from_java(env, e);
11035         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
11036         *ret_conv = CResult_InvoiceSemanticErrorZ_err(e_conv);
11037         return (uint64_t)ret_conv;
11038 }
11039
11040 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11041         if ((_res & 1) != 0) return;
11042         LDKCResult_InvoiceSemanticErrorZ _res_conv = *(LDKCResult_InvoiceSemanticErrorZ*)(((uint64_t)_res) & ~1);
11043         FREE((void*)_res);
11044         CResult_InvoiceSemanticErrorZ_free(_res_conv);
11045 }
11046
11047 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11048         LDKCResult_InvoiceSemanticErrorZ* orig_conv = (LDKCResult_InvoiceSemanticErrorZ*)(orig & ~1);
11049         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
11050         *ret_conv = CResult_InvoiceSemanticErrorZ_clone(orig_conv);
11051         return (uint64_t)ret_conv;
11052 }
11053
11054 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11055         LDKDescription o_conv;
11056         o_conv.inner = (void*)(o & (~1));
11057         o_conv.is_owned = (o & 1) || (o == 0);
11058         o_conv = Description_clone(&o_conv);
11059         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
11060         *ret_conv = CResult_DescriptionCreationErrorZ_ok(o_conv);
11061         return (uint64_t)ret_conv;
11062 }
11063
11064 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
11065         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
11066         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
11067         *ret_conv = CResult_DescriptionCreationErrorZ_err(e_conv);
11068         return (uint64_t)ret_conv;
11069 }
11070
11071 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11072         if ((_res & 1) != 0) return;
11073         LDKCResult_DescriptionCreationErrorZ _res_conv = *(LDKCResult_DescriptionCreationErrorZ*)(((uint64_t)_res) & ~1);
11074         FREE((void*)_res);
11075         CResult_DescriptionCreationErrorZ_free(_res_conv);
11076 }
11077
11078 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11079         LDKCResult_DescriptionCreationErrorZ* orig_conv = (LDKCResult_DescriptionCreationErrorZ*)(orig & ~1);
11080         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
11081         *ret_conv = CResult_DescriptionCreationErrorZ_clone(orig_conv);
11082         return (uint64_t)ret_conv;
11083 }
11084
11085 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ExpiryTimeCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11086         LDKExpiryTime o_conv;
11087         o_conv.inner = (void*)(o & (~1));
11088         o_conv.is_owned = (o & 1) || (o == 0);
11089         o_conv = ExpiryTime_clone(&o_conv);
11090         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
11091         *ret_conv = CResult_ExpiryTimeCreationErrorZ_ok(o_conv);
11092         return (uint64_t)ret_conv;
11093 }
11094
11095 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ExpiryTimeCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
11096         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
11097         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
11098         *ret_conv = CResult_ExpiryTimeCreationErrorZ_err(e_conv);
11099         return (uint64_t)ret_conv;
11100 }
11101
11102 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ExpiryTimeCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11103         if ((_res & 1) != 0) return;
11104         LDKCResult_ExpiryTimeCreationErrorZ _res_conv = *(LDKCResult_ExpiryTimeCreationErrorZ*)(((uint64_t)_res) & ~1);
11105         FREE((void*)_res);
11106         CResult_ExpiryTimeCreationErrorZ_free(_res_conv);
11107 }
11108
11109 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ExpiryTimeCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11110         LDKCResult_ExpiryTimeCreationErrorZ* orig_conv = (LDKCResult_ExpiryTimeCreationErrorZ*)(orig & ~1);
11111         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
11112         *ret_conv = CResult_ExpiryTimeCreationErrorZ_clone(orig_conv);
11113         return (uint64_t)ret_conv;
11114 }
11115
11116 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11117         LDKPrivateRoute o_conv;
11118         o_conv.inner = (void*)(o & (~1));
11119         o_conv.is_owned = (o & 1) || (o == 0);
11120         o_conv = PrivateRoute_clone(&o_conv);
11121         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
11122         *ret_conv = CResult_PrivateRouteCreationErrorZ_ok(o_conv);
11123         return (uint64_t)ret_conv;
11124 }
11125
11126 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
11127         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
11128         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
11129         *ret_conv = CResult_PrivateRouteCreationErrorZ_err(e_conv);
11130         return (uint64_t)ret_conv;
11131 }
11132
11133 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11134         if ((_res & 1) != 0) return;
11135         LDKCResult_PrivateRouteCreationErrorZ _res_conv = *(LDKCResult_PrivateRouteCreationErrorZ*)(((uint64_t)_res) & ~1);
11136         FREE((void*)_res);
11137         CResult_PrivateRouteCreationErrorZ_free(_res_conv);
11138 }
11139
11140 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11141         LDKCResult_PrivateRouteCreationErrorZ* orig_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(orig & ~1);
11142         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
11143         *ret_conv = CResult_PrivateRouteCreationErrorZ_clone(orig_conv);
11144         return (uint64_t)ret_conv;
11145 }
11146
11147 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1ok(JNIEnv *env, jclass clz, jstring o) {
11148         LDKStr o_conv = java_to_owned_str(env, o);
11149         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
11150         *ret_conv = CResult_StringErrorZ_ok(o_conv);
11151         return (uint64_t)ret_conv;
11152 }
11153
11154 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
11155         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
11156         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
11157         *ret_conv = CResult_StringErrorZ_err(e_conv);
11158         return (uint64_t)ret_conv;
11159 }
11160
11161 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11162         if ((_res & 1) != 0) return;
11163         LDKCResult_StringErrorZ _res_conv = *(LDKCResult_StringErrorZ*)(((uint64_t)_res) & ~1);
11164         FREE((void*)_res);
11165         CResult_StringErrorZ_free(_res_conv);
11166 }
11167
11168 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11169         LDKChannelMonitorUpdate o_conv;
11170         o_conv.inner = (void*)(o & (~1));
11171         o_conv.is_owned = (o & 1) || (o == 0);
11172         o_conv = ChannelMonitorUpdate_clone(&o_conv);
11173         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
11174         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_ok(o_conv);
11175         return (uint64_t)ret_conv;
11176 }
11177
11178 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11179         LDKDecodeError e_conv;
11180         e_conv.inner = (void*)(e & (~1));
11181         e_conv.is_owned = (e & 1) || (e == 0);
11182         e_conv = DecodeError_clone(&e_conv);
11183         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
11184         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_err(e_conv);
11185         return (uint64_t)ret_conv;
11186 }
11187
11188 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11189         if ((_res & 1) != 0) return;
11190         LDKCResult_ChannelMonitorUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
11191         FREE((void*)_res);
11192         CResult_ChannelMonitorUpdateDecodeErrorZ_free(_res_conv);
11193 }
11194
11195 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11196         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(orig & ~1);
11197         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
11198         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(orig_conv);
11199         return (uint64_t)ret_conv;
11200 }
11201
11202 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11203         LDKHTLCUpdate o_conv;
11204         o_conv.inner = (void*)(o & (~1));
11205         o_conv.is_owned = (o & 1) || (o == 0);
11206         o_conv = HTLCUpdate_clone(&o_conv);
11207         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
11208         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_ok(o_conv);
11209         return (uint64_t)ret_conv;
11210 }
11211
11212 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11213         LDKDecodeError e_conv;
11214         e_conv.inner = (void*)(e & (~1));
11215         e_conv.is_owned = (e & 1) || (e == 0);
11216         e_conv = DecodeError_clone(&e_conv);
11217         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
11218         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_err(e_conv);
11219         return (uint64_t)ret_conv;
11220 }
11221
11222 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11223         if ((_res & 1) != 0) return;
11224         LDKCResult_HTLCUpdateDecodeErrorZ _res_conv = *(LDKCResult_HTLCUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
11225         FREE((void*)_res);
11226         CResult_HTLCUpdateDecodeErrorZ_free(_res_conv);
11227 }
11228
11229 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11230         LDKCResult_HTLCUpdateDecodeErrorZ* orig_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(orig & ~1);
11231         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
11232         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(orig_conv);
11233         return (uint64_t)ret_conv;
11234 }
11235
11236 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneMonitorUpdateErrorZ_1ok(JNIEnv *env, jclass clz) {
11237         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
11238         *ret_conv = CResult_NoneMonitorUpdateErrorZ_ok();
11239         return (uint64_t)ret_conv;
11240 }
11241
11242 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneMonitorUpdateErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11243         LDKMonitorUpdateError e_conv;
11244         e_conv.inner = (void*)(e & (~1));
11245         e_conv.is_owned = (e & 1) || (e == 0);
11246         e_conv = MonitorUpdateError_clone(&e_conv);
11247         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
11248         *ret_conv = CResult_NoneMonitorUpdateErrorZ_err(e_conv);
11249         return (uint64_t)ret_conv;
11250 }
11251
11252 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneMonitorUpdateErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11253         if ((_res & 1) != 0) return;
11254         LDKCResult_NoneMonitorUpdateErrorZ _res_conv = *(LDKCResult_NoneMonitorUpdateErrorZ*)(((uint64_t)_res) & ~1);
11255         FREE((void*)_res);
11256         CResult_NoneMonitorUpdateErrorZ_free(_res_conv);
11257 }
11258
11259 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneMonitorUpdateErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11260         LDKCResult_NoneMonitorUpdateErrorZ* orig_conv = (LDKCResult_NoneMonitorUpdateErrorZ*)(orig & ~1);
11261         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
11262         *ret_conv = CResult_NoneMonitorUpdateErrorZ_clone(orig_conv);
11263         return (uint64_t)ret_conv;
11264 }
11265
11266 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11267         LDKC2Tuple_OutPointScriptZ* orig_conv = (LDKC2Tuple_OutPointScriptZ*)(orig & ~1);
11268         LDKC2Tuple_OutPointScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
11269         *ret_ref = C2Tuple_OutPointScriptZ_clone(orig_conv);
11270         return (uint64_t)ret_ref;
11271 }
11272
11273 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
11274         LDKOutPoint a_conv;
11275         a_conv.inner = (void*)(a & (~1));
11276         a_conv.is_owned = (a & 1) || (a == 0);
11277         a_conv = OutPoint_clone(&a_conv);
11278         LDKCVec_u8Z b_ref;
11279         b_ref.datalen = (*env)->GetArrayLength(env, b);
11280         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
11281         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
11282         LDKC2Tuple_OutPointScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
11283         *ret_ref = C2Tuple_OutPointScriptZ_new(a_conv, b_ref);
11284         return (uint64_t)ret_ref;
11285 }
11286
11287 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11288         if ((_res & 1) != 0) return;
11289         LDKC2Tuple_OutPointScriptZ _res_conv = *(LDKC2Tuple_OutPointScriptZ*)(((uint64_t)_res) & ~1);
11290         FREE((void*)_res);
11291         C2Tuple_OutPointScriptZ_free(_res_conv);
11292 }
11293
11294 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11295         LDKC2Tuple_u32ScriptZ* orig_conv = (LDKC2Tuple_u32ScriptZ*)(orig & ~1);
11296         LDKC2Tuple_u32ScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
11297         *ret_ref = C2Tuple_u32ScriptZ_clone(orig_conv);
11298         return (uint64_t)ret_ref;
11299 }
11300
11301 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1new(JNIEnv *env, jclass clz, int32_t a, int8_tArray b) {
11302         LDKCVec_u8Z b_ref;
11303         b_ref.datalen = (*env)->GetArrayLength(env, b);
11304         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
11305         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
11306         LDKC2Tuple_u32ScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
11307         *ret_ref = C2Tuple_u32ScriptZ_new(a, b_ref);
11308         return (uint64_t)ret_ref;
11309 }
11310
11311 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11312         if ((_res & 1) != 0) return;
11313         LDKC2Tuple_u32ScriptZ _res_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)_res) & ~1);
11314         FREE((void*)_res);
11315         C2Tuple_u32ScriptZ_free(_res_conv);
11316 }
11317
11318 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1u32ScriptZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
11319         LDKCVec_C2Tuple_u32ScriptZZ _res_constr;
11320         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11321         if (_res_constr.datalen > 0)
11322                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
11323         else
11324                 _res_constr.data = NULL;
11325         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
11326         for (size_t b = 0; b < _res_constr.datalen; b++) {
11327                 int64_t _res_conv_27 = _res_vals[b];
11328                 LDKC2Tuple_u32ScriptZ _res_conv_27_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)_res_conv_27) & ~1);
11329                 FREE((void*)_res_conv_27);
11330                 _res_constr.data[b] = _res_conv_27_conv;
11331         }
11332         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
11333         CVec_C2Tuple_u32ScriptZZ_free(_res_constr);
11334 }
11335
11336 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11337         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(orig & ~1);
11338         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
11339         *ret_ref = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(orig_conv);
11340         return (uint64_t)ret_ref;
11341 }
11342
11343 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
11344         LDKThirtyTwoBytes a_ref;
11345         CHECK((*env)->GetArrayLength(env, a) == 32);
11346         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
11347         LDKCVec_C2Tuple_u32ScriptZZ b_constr;
11348         b_constr.datalen = (*env)->GetArrayLength(env, b);
11349         if (b_constr.datalen > 0)
11350                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
11351         else
11352                 b_constr.data = NULL;
11353         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
11354         for (size_t b = 0; b < b_constr.datalen; b++) {
11355                 int64_t b_conv_27 = b_vals[b];
11356                 LDKC2Tuple_u32ScriptZ b_conv_27_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_27) & ~1);
11357                 b_conv_27_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_27) & ~1));
11358                 b_constr.data[b] = b_conv_27_conv;
11359         }
11360         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
11361         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
11362         *ret_ref = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(a_ref, b_constr);
11363         return (uint64_t)ret_ref;
11364 }
11365
11366 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11367         if ((_res & 1) != 0) return;
11368         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)_res) & ~1);
11369         FREE((void*)_res);
11370         C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(_res_conv);
11371 }
11372
11373 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
11374         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ _res_constr;
11375         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11376         if (_res_constr.datalen > 0)
11377                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ Elements");
11378         else
11379                 _res_constr.data = NULL;
11380         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
11381         for (size_t v = 0; v < _res_constr.datalen; v++) {
11382                 int64_t _res_conv_47 = _res_vals[v];
11383                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv_47_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)_res_conv_47) & ~1);
11384                 FREE((void*)_res_conv_47);
11385                 _res_constr.data[v] = _res_conv_47_conv;
11386         }
11387         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
11388         CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(_res_constr);
11389 }
11390
11391 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1EventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
11392         LDKCVec_EventZ _res_constr;
11393         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11394         if (_res_constr.datalen > 0)
11395                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKEvent), "LDKCVec_EventZ Elements");
11396         else
11397                 _res_constr.data = NULL;
11398         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
11399         for (size_t h = 0; h < _res_constr.datalen; h++) {
11400                 int64_t _res_conv_7 = _res_vals[h];
11401                 LDKEvent _res_conv_7_conv = *(LDKEvent*)(((uint64_t)_res_conv_7) & ~1);
11402                 FREE((void*)_res_conv_7);
11403                 _res_constr.data[h] = _res_conv_7_conv;
11404         }
11405         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
11406         CVec_EventZ_free(_res_constr);
11407 }
11408
11409 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TransactionZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
11410         LDKCVec_TransactionZ _res_constr;
11411         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11412         if (_res_constr.datalen > 0)
11413                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTransaction), "LDKCVec_TransactionZ Elements");
11414         else
11415                 _res_constr.data = NULL;
11416         for (size_t i = 0; i < _res_constr.datalen; i++) {
11417                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
11418                 LDKTransaction _res_conv_8_ref;
11419                 _res_conv_8_ref.datalen = (*env)->GetArrayLength(env, _res_conv_8);
11420                 _res_conv_8_ref.data = MALLOC(_res_conv_8_ref.datalen, "LDKTransaction Bytes");
11421                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, _res_conv_8_ref.datalen, _res_conv_8_ref.data);
11422                 _res_conv_8_ref.data_is_owned = true;
11423                 _res_constr.data[i] = _res_conv_8_ref;
11424         }
11425         CVec_TransactionZ_free(_res_constr);
11426 }
11427
11428 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11429         LDKC2Tuple_u32TxOutZ* orig_conv = (LDKC2Tuple_u32TxOutZ*)(orig & ~1);
11430         LDKC2Tuple_u32TxOutZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
11431         *ret_ref = C2Tuple_u32TxOutZ_clone(orig_conv);
11432         return (uint64_t)ret_ref;
11433 }
11434
11435 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1new(JNIEnv *env, jclass clz, int32_t a, int64_t b) {
11436         LDKTxOut b_conv = *(LDKTxOut*)(((uint64_t)b) & ~1);
11437         LDKC2Tuple_u32TxOutZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
11438         *ret_ref = C2Tuple_u32TxOutZ_new(a, b_conv);
11439         return (uint64_t)ret_ref;
11440 }
11441
11442 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11443         if ((_res & 1) != 0) return;
11444         LDKC2Tuple_u32TxOutZ _res_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)_res) & ~1);
11445         FREE((void*)_res);
11446         C2Tuple_u32TxOutZ_free(_res_conv);
11447 }
11448
11449 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1u32TxOutZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
11450         LDKCVec_C2Tuple_u32TxOutZZ _res_constr;
11451         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11452         if (_res_constr.datalen > 0)
11453                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
11454         else
11455                 _res_constr.data = NULL;
11456         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
11457         for (size_t a = 0; a < _res_constr.datalen; a++) {
11458                 int64_t _res_conv_26 = _res_vals[a];
11459                 LDKC2Tuple_u32TxOutZ _res_conv_26_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)_res_conv_26) & ~1);
11460                 FREE((void*)_res_conv_26);
11461                 _res_constr.data[a] = _res_conv_26_conv;
11462         }
11463         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
11464         CVec_C2Tuple_u32TxOutZZ_free(_res_constr);
11465 }
11466
11467 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11468         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(orig & ~1);
11469         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
11470         *ret_ref = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(orig_conv);
11471         return (uint64_t)ret_ref;
11472 }
11473
11474 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
11475         LDKThirtyTwoBytes a_ref;
11476         CHECK((*env)->GetArrayLength(env, a) == 32);
11477         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
11478         LDKCVec_C2Tuple_u32TxOutZZ b_constr;
11479         b_constr.datalen = (*env)->GetArrayLength(env, b);
11480         if (b_constr.datalen > 0)
11481                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
11482         else
11483                 b_constr.data = NULL;
11484         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
11485         for (size_t a = 0; a < b_constr.datalen; a++) {
11486                 int64_t b_conv_26 = b_vals[a];
11487                 LDKC2Tuple_u32TxOutZ b_conv_26_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_26) & ~1);
11488                 b_conv_26_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_26) & ~1));
11489                 b_constr.data[a] = b_conv_26_conv;
11490         }
11491         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
11492         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
11493         *ret_ref = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(a_ref, b_constr);
11494         return (uint64_t)ret_ref;
11495 }
11496
11497 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11498         if ((_res & 1) != 0) return;
11499         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)_res) & ~1);
11500         FREE((void*)_res);
11501         C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(_res_conv);
11502 }
11503
11504 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
11505         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ _res_constr;
11506         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11507         if (_res_constr.datalen > 0)
11508                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Elements");
11509         else
11510                 _res_constr.data = NULL;
11511         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
11512         for (size_t u = 0; u < _res_constr.datalen; u++) {
11513                 int64_t _res_conv_46 = _res_vals[u];
11514                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv_46_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)_res_conv_46) & ~1);
11515                 FREE((void*)_res_conv_46);
11516                 _res_constr.data[u] = _res_conv_46_conv;
11517         }
11518         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
11519         CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(_res_constr);
11520 }
11521
11522 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11523         LDKC2Tuple_BlockHashChannelMonitorZ o_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)o) & ~1);
11524         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
11525         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(o_conv);
11526         return (uint64_t)ret_conv;
11527 }
11528
11529 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11530         LDKDecodeError e_conv;
11531         e_conv.inner = (void*)(e & (~1));
11532         e_conv.is_owned = (e & 1) || (e == 0);
11533         e_conv = DecodeError_clone(&e_conv);
11534         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
11535         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(e_conv);
11536         return (uint64_t)ret_conv;
11537 }
11538
11539 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11540         if ((_res & 1) != 0) return;
11541         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(((uint64_t)_res) & ~1);
11542         FREE((void*)_res);
11543         CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(_res_conv);
11544 }
11545
11546 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1ok(JNIEnv *env, jclass clz, jboolean o) {
11547         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
11548         *ret_conv = CResult_boolLightningErrorZ_ok(o);
11549         return (uint64_t)ret_conv;
11550 }
11551
11552 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11553         LDKLightningError e_conv;
11554         e_conv.inner = (void*)(e & (~1));
11555         e_conv.is_owned = (e & 1) || (e == 0);
11556         e_conv = LightningError_clone(&e_conv);
11557         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
11558         *ret_conv = CResult_boolLightningErrorZ_err(e_conv);
11559         return (uint64_t)ret_conv;
11560 }
11561
11562 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11563         if ((_res & 1) != 0) return;
11564         LDKCResult_boolLightningErrorZ _res_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)_res) & ~1);
11565         FREE((void*)_res);
11566         CResult_boolLightningErrorZ_free(_res_conv);
11567 }
11568
11569 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11570         LDKCResult_boolLightningErrorZ* orig_conv = (LDKCResult_boolLightningErrorZ*)(orig & ~1);
11571         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
11572         *ret_conv = CResult_boolLightningErrorZ_clone(orig_conv);
11573         return (uint64_t)ret_conv;
11574 }
11575
11576 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11577         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* orig_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(orig & ~1);
11578         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_ref = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
11579         *ret_ref = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(orig_conv);
11580         return (uint64_t)ret_ref;
11581 }
11582
11583 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) {
11584         LDKChannelAnnouncement a_conv;
11585         a_conv.inner = (void*)(a & (~1));
11586         a_conv.is_owned = (a & 1) || (a == 0);
11587         a_conv = ChannelAnnouncement_clone(&a_conv);
11588         LDKChannelUpdate b_conv;
11589         b_conv.inner = (void*)(b & (~1));
11590         b_conv.is_owned = (b & 1) || (b == 0);
11591         b_conv = ChannelUpdate_clone(&b_conv);
11592         LDKChannelUpdate c_conv;
11593         c_conv.inner = (void*)(c & (~1));
11594         c_conv.is_owned = (c & 1) || (c == 0);
11595         c_conv = ChannelUpdate_clone(&c_conv);
11596         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_ref = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
11597         *ret_ref = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(a_conv, b_conv, c_conv);
11598         return (uint64_t)ret_ref;
11599 }
11600
11601 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11602         if ((_res & 1) != 0) return;
11603         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)_res) & ~1);
11604         FREE((void*)_res);
11605         C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(_res_conv);
11606 }
11607
11608 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
11609         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ _res_constr;
11610         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11611         if (_res_constr.datalen > 0)
11612                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
11613         else
11614                 _res_constr.data = NULL;
11615         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
11616         for (size_t l = 0; l < _res_constr.datalen; l++) {
11617                 int64_t _res_conv_63 = _res_vals[l];
11618                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv_63_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)_res_conv_63) & ~1);
11619                 FREE((void*)_res_conv_63);
11620                 _res_constr.data[l] = _res_conv_63_conv;
11621         }
11622         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
11623         CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(_res_constr);
11624 }
11625
11626 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1NodeAnnouncementZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
11627         LDKCVec_NodeAnnouncementZ _res_constr;
11628         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11629         if (_res_constr.datalen > 0)
11630                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
11631         else
11632                 _res_constr.data = NULL;
11633         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
11634         for (size_t s = 0; s < _res_constr.datalen; s++) {
11635                 int64_t _res_conv_18 = _res_vals[s];
11636                 LDKNodeAnnouncement _res_conv_18_conv;
11637                 _res_conv_18_conv.inner = (void*)(_res_conv_18 & (~1));
11638                 _res_conv_18_conv.is_owned = (_res_conv_18 & 1) || (_res_conv_18 == 0);
11639                 _res_constr.data[s] = _res_conv_18_conv;
11640         }
11641         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
11642         CVec_NodeAnnouncementZ_free(_res_constr);
11643 }
11644
11645 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1ok(JNIEnv *env, jclass clz) {
11646         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
11647         *ret_conv = CResult_NoneLightningErrorZ_ok();
11648         return (uint64_t)ret_conv;
11649 }
11650
11651 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11652         LDKLightningError e_conv;
11653         e_conv.inner = (void*)(e & (~1));
11654         e_conv.is_owned = (e & 1) || (e == 0);
11655         e_conv = LightningError_clone(&e_conv);
11656         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
11657         *ret_conv = CResult_NoneLightningErrorZ_err(e_conv);
11658         return (uint64_t)ret_conv;
11659 }
11660
11661 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11662         if ((_res & 1) != 0) return;
11663         LDKCResult_NoneLightningErrorZ _res_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)_res) & ~1);
11664         FREE((void*)_res);
11665         CResult_NoneLightningErrorZ_free(_res_conv);
11666 }
11667
11668 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11669         LDKCResult_NoneLightningErrorZ* orig_conv = (LDKCResult_NoneLightningErrorZ*)(orig & ~1);
11670         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
11671         *ret_conv = CResult_NoneLightningErrorZ_clone(orig_conv);
11672         return (uint64_t)ret_conv;
11673 }
11674
11675 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PublicKeyZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
11676         LDKCVec_PublicKeyZ _res_constr;
11677         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11678         if (_res_constr.datalen > 0)
11679                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
11680         else
11681                 _res_constr.data = NULL;
11682         for (size_t i = 0; i < _res_constr.datalen; i++) {
11683                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
11684                 LDKPublicKey _res_conv_8_ref;
11685                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 33);
11686                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 33, _res_conv_8_ref.compressed_form);
11687                 _res_constr.data[i] = _res_conv_8_ref;
11688         }
11689         CVec_PublicKeyZ_free(_res_constr);
11690 }
11691
11692 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
11693         LDKCVec_u8Z o_ref;
11694         o_ref.datalen = (*env)->GetArrayLength(env, o);
11695         o_ref.data = MALLOC(o_ref.datalen, "LDKCVec_u8Z Bytes");
11696         (*env)->GetByteArrayRegion(env, o, 0, o_ref.datalen, o_ref.data);
11697         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
11698         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_ok(o_ref);
11699         return (uint64_t)ret_conv;
11700 }
11701
11702 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11703         LDKPeerHandleError e_conv;
11704         e_conv.inner = (void*)(e & (~1));
11705         e_conv.is_owned = (e & 1) || (e == 0);
11706         e_conv = PeerHandleError_clone(&e_conv);
11707         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
11708         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_err(e_conv);
11709         return (uint64_t)ret_conv;
11710 }
11711
11712 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11713         if ((_res & 1) != 0) return;
11714         LDKCResult_CVec_u8ZPeerHandleErrorZ _res_conv = *(LDKCResult_CVec_u8ZPeerHandleErrorZ*)(((uint64_t)_res) & ~1);
11715         FREE((void*)_res);
11716         CResult_CVec_u8ZPeerHandleErrorZ_free(_res_conv);
11717 }
11718
11719 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11720         LDKCResult_CVec_u8ZPeerHandleErrorZ* orig_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(orig & ~1);
11721         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
11722         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(orig_conv);
11723         return (uint64_t)ret_conv;
11724 }
11725
11726 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1ok(JNIEnv *env, jclass clz) {
11727         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
11728         *ret_conv = CResult_NonePeerHandleErrorZ_ok();
11729         return (uint64_t)ret_conv;
11730 }
11731
11732 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11733         LDKPeerHandleError e_conv;
11734         e_conv.inner = (void*)(e & (~1));
11735         e_conv.is_owned = (e & 1) || (e == 0);
11736         e_conv = PeerHandleError_clone(&e_conv);
11737         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
11738         *ret_conv = CResult_NonePeerHandleErrorZ_err(e_conv);
11739         return (uint64_t)ret_conv;
11740 }
11741
11742 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11743         if ((_res & 1) != 0) return;
11744         LDKCResult_NonePeerHandleErrorZ _res_conv = *(LDKCResult_NonePeerHandleErrorZ*)(((uint64_t)_res) & ~1);
11745         FREE((void*)_res);
11746         CResult_NonePeerHandleErrorZ_free(_res_conv);
11747 }
11748
11749 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11750         LDKCResult_NonePeerHandleErrorZ* orig_conv = (LDKCResult_NonePeerHandleErrorZ*)(orig & ~1);
11751         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
11752         *ret_conv = CResult_NonePeerHandleErrorZ_clone(orig_conv);
11753         return (uint64_t)ret_conv;
11754 }
11755
11756 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1ok(JNIEnv *env, jclass clz, jboolean o) {
11757         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
11758         *ret_conv = CResult_boolPeerHandleErrorZ_ok(o);
11759         return (uint64_t)ret_conv;
11760 }
11761
11762 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11763         LDKPeerHandleError e_conv;
11764         e_conv.inner = (void*)(e & (~1));
11765         e_conv.is_owned = (e & 1) || (e == 0);
11766         e_conv = PeerHandleError_clone(&e_conv);
11767         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
11768         *ret_conv = CResult_boolPeerHandleErrorZ_err(e_conv);
11769         return (uint64_t)ret_conv;
11770 }
11771
11772 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11773         if ((_res & 1) != 0) return;
11774         LDKCResult_boolPeerHandleErrorZ _res_conv = *(LDKCResult_boolPeerHandleErrorZ*)(((uint64_t)_res) & ~1);
11775         FREE((void*)_res);
11776         CResult_boolPeerHandleErrorZ_free(_res_conv);
11777 }
11778
11779 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11780         LDKCResult_boolPeerHandleErrorZ* orig_conv = (LDKCResult_boolPeerHandleErrorZ*)(orig & ~1);
11781         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
11782         *ret_conv = CResult_boolPeerHandleErrorZ_clone(orig_conv);
11783         return (uint64_t)ret_conv;
11784 }
11785
11786 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DirectionalChannelInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11787         LDKDirectionalChannelInfo o_conv;
11788         o_conv.inner = (void*)(o & (~1));
11789         o_conv.is_owned = (o & 1) || (o == 0);
11790         o_conv = DirectionalChannelInfo_clone(&o_conv);
11791         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
11792         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_ok(o_conv);
11793         return (uint64_t)ret_conv;
11794 }
11795
11796 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DirectionalChannelInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11797         LDKDecodeError e_conv;
11798         e_conv.inner = (void*)(e & (~1));
11799         e_conv.is_owned = (e & 1) || (e == 0);
11800         e_conv = DecodeError_clone(&e_conv);
11801         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
11802         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_err(e_conv);
11803         return (uint64_t)ret_conv;
11804 }
11805
11806 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1DirectionalChannelInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11807         if ((_res & 1) != 0) return;
11808         LDKCResult_DirectionalChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
11809         FREE((void*)_res);
11810         CResult_DirectionalChannelInfoDecodeErrorZ_free(_res_conv);
11811 }
11812
11813 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DirectionalChannelInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11814         LDKCResult_DirectionalChannelInfoDecodeErrorZ* orig_conv = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(orig & ~1);
11815         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
11816         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_clone(orig_conv);
11817         return (uint64_t)ret_conv;
11818 }
11819
11820 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11821         LDKChannelInfo o_conv;
11822         o_conv.inner = (void*)(o & (~1));
11823         o_conv.is_owned = (o & 1) || (o == 0);
11824         o_conv = ChannelInfo_clone(&o_conv);
11825         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
11826         *ret_conv = CResult_ChannelInfoDecodeErrorZ_ok(o_conv);
11827         return (uint64_t)ret_conv;
11828 }
11829
11830 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11831         LDKDecodeError e_conv;
11832         e_conv.inner = (void*)(e & (~1));
11833         e_conv.is_owned = (e & 1) || (e == 0);
11834         e_conv = DecodeError_clone(&e_conv);
11835         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
11836         *ret_conv = CResult_ChannelInfoDecodeErrorZ_err(e_conv);
11837         return (uint64_t)ret_conv;
11838 }
11839
11840 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11841         if ((_res & 1) != 0) return;
11842         LDKCResult_ChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
11843         FREE((void*)_res);
11844         CResult_ChannelInfoDecodeErrorZ_free(_res_conv);
11845 }
11846
11847 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11848         LDKCResult_ChannelInfoDecodeErrorZ* orig_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(orig & ~1);
11849         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
11850         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(orig_conv);
11851         return (uint64_t)ret_conv;
11852 }
11853
11854 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11855         LDKRoutingFees o_conv;
11856         o_conv.inner = (void*)(o & (~1));
11857         o_conv.is_owned = (o & 1) || (o == 0);
11858         o_conv = RoutingFees_clone(&o_conv);
11859         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
11860         *ret_conv = CResult_RoutingFeesDecodeErrorZ_ok(o_conv);
11861         return (uint64_t)ret_conv;
11862 }
11863
11864 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11865         LDKDecodeError e_conv;
11866         e_conv.inner = (void*)(e & (~1));
11867         e_conv.is_owned = (e & 1) || (e == 0);
11868         e_conv = DecodeError_clone(&e_conv);
11869         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
11870         *ret_conv = CResult_RoutingFeesDecodeErrorZ_err(e_conv);
11871         return (uint64_t)ret_conv;
11872 }
11873
11874 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11875         if ((_res & 1) != 0) return;
11876         LDKCResult_RoutingFeesDecodeErrorZ _res_conv = *(LDKCResult_RoutingFeesDecodeErrorZ*)(((uint64_t)_res) & ~1);
11877         FREE((void*)_res);
11878         CResult_RoutingFeesDecodeErrorZ_free(_res_conv);
11879 }
11880
11881 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11882         LDKCResult_RoutingFeesDecodeErrorZ* orig_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(orig & ~1);
11883         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
11884         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(orig_conv);
11885         return (uint64_t)ret_conv;
11886 }
11887
11888 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11889         LDKNodeAnnouncementInfo o_conv;
11890         o_conv.inner = (void*)(o & (~1));
11891         o_conv.is_owned = (o & 1) || (o == 0);
11892         o_conv = NodeAnnouncementInfo_clone(&o_conv);
11893         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
11894         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_ok(o_conv);
11895         return (uint64_t)ret_conv;
11896 }
11897
11898 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11899         LDKDecodeError e_conv;
11900         e_conv.inner = (void*)(e & (~1));
11901         e_conv.is_owned = (e & 1) || (e == 0);
11902         e_conv = DecodeError_clone(&e_conv);
11903         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
11904         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_err(e_conv);
11905         return (uint64_t)ret_conv;
11906 }
11907
11908 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11909         if ((_res & 1) != 0) return;
11910         LDKCResult_NodeAnnouncementInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
11911         FREE((void*)_res);
11912         CResult_NodeAnnouncementInfoDecodeErrorZ_free(_res_conv);
11913 }
11914
11915 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11916         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(orig & ~1);
11917         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
11918         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(orig_conv);
11919         return (uint64_t)ret_conv;
11920 }
11921
11922 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u64Z_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
11923         LDKCVec_u64Z _res_constr;
11924         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11925         if (_res_constr.datalen > 0)
11926                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
11927         else
11928                 _res_constr.data = NULL;
11929         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
11930         for (size_t g = 0; g < _res_constr.datalen; g++) {
11931                 int64_t _res_conv_6 = _res_vals[g];
11932                 _res_constr.data[g] = _res_conv_6;
11933         }
11934         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
11935         CVec_u64Z_free(_res_constr);
11936 }
11937
11938 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11939         LDKNodeInfo o_conv;
11940         o_conv.inner = (void*)(o & (~1));
11941         o_conv.is_owned = (o & 1) || (o == 0);
11942         o_conv = NodeInfo_clone(&o_conv);
11943         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
11944         *ret_conv = CResult_NodeInfoDecodeErrorZ_ok(o_conv);
11945         return (uint64_t)ret_conv;
11946 }
11947
11948 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11949         LDKDecodeError e_conv;
11950         e_conv.inner = (void*)(e & (~1));
11951         e_conv.is_owned = (e & 1) || (e == 0);
11952         e_conv = DecodeError_clone(&e_conv);
11953         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
11954         *ret_conv = CResult_NodeInfoDecodeErrorZ_err(e_conv);
11955         return (uint64_t)ret_conv;
11956 }
11957
11958 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11959         if ((_res & 1) != 0) return;
11960         LDKCResult_NodeInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
11961         FREE((void*)_res);
11962         CResult_NodeInfoDecodeErrorZ_free(_res_conv);
11963 }
11964
11965 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11966         LDKCResult_NodeInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(orig & ~1);
11967         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
11968         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(orig_conv);
11969         return (uint64_t)ret_conv;
11970 }
11971
11972 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11973         LDKNetworkGraph o_conv;
11974         o_conv.inner = (void*)(o & (~1));
11975         o_conv.is_owned = (o & 1) || (o == 0);
11976         o_conv = NetworkGraph_clone(&o_conv);
11977         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
11978         *ret_conv = CResult_NetworkGraphDecodeErrorZ_ok(o_conv);
11979         return (uint64_t)ret_conv;
11980 }
11981
11982 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11983         LDKDecodeError e_conv;
11984         e_conv.inner = (void*)(e & (~1));
11985         e_conv.is_owned = (e & 1) || (e == 0);
11986         e_conv = DecodeError_clone(&e_conv);
11987         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
11988         *ret_conv = CResult_NetworkGraphDecodeErrorZ_err(e_conv);
11989         return (uint64_t)ret_conv;
11990 }
11991
11992 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11993         if ((_res & 1) != 0) return;
11994         LDKCResult_NetworkGraphDecodeErrorZ _res_conv = *(LDKCResult_NetworkGraphDecodeErrorZ*)(((uint64_t)_res) & ~1);
11995         FREE((void*)_res);
11996         CResult_NetworkGraphDecodeErrorZ_free(_res_conv);
11997 }
11998
11999 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12000         LDKCResult_NetworkGraphDecodeErrorZ* orig_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(orig & ~1);
12001         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
12002         *ret_conv = CResult_NetworkGraphDecodeErrorZ_clone(orig_conv);
12003         return (uint64_t)ret_conv;
12004 }
12005
12006 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressu8Z_1ok(JNIEnv *env, jclass clz, int64_t o) {
12007         LDKNetAddress o_conv = *(LDKNetAddress*)(((uint64_t)o) & ~1);
12008         LDKCResult_NetAddressu8Z* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
12009         *ret_conv = CResult_NetAddressu8Z_ok(o_conv);
12010         return (uint64_t)ret_conv;
12011 }
12012
12013 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressu8Z_1err(JNIEnv *env, jclass clz, int8_t e) {
12014         LDKCResult_NetAddressu8Z* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
12015         *ret_conv = CResult_NetAddressu8Z_err(e);
12016         return (uint64_t)ret_conv;
12017 }
12018
12019 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressu8Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
12020         if ((_res & 1) != 0) return;
12021         LDKCResult_NetAddressu8Z _res_conv = *(LDKCResult_NetAddressu8Z*)(((uint64_t)_res) & ~1);
12022         FREE((void*)_res);
12023         CResult_NetAddressu8Z_free(_res_conv);
12024 }
12025
12026 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressu8Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12027         LDKCResult_NetAddressu8Z* orig_conv = (LDKCResult_NetAddressu8Z*)(orig & ~1);
12028         LDKCResult_NetAddressu8Z* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
12029         *ret_conv = CResult_NetAddressu8Z_clone(orig_conv);
12030         return (uint64_t)ret_conv;
12031 }
12032
12033 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CResult_1NetAddressu8ZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12034         LDKCResult_NetAddressu8Z o_conv = *(LDKCResult_NetAddressu8Z*)(((uint64_t)o) & ~1);
12035         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
12036         *ret_conv = CResult_CResult_NetAddressu8ZDecodeErrorZ_ok(o_conv);
12037         return (uint64_t)ret_conv;
12038 }
12039
12040 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CResult_1NetAddressu8ZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12041         LDKDecodeError e_conv;
12042         e_conv.inner = (void*)(e & (~1));
12043         e_conv.is_owned = (e & 1) || (e == 0);
12044         e_conv = DecodeError_clone(&e_conv);
12045         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
12046         *ret_conv = CResult_CResult_NetAddressu8ZDecodeErrorZ_err(e_conv);
12047         return (uint64_t)ret_conv;
12048 }
12049
12050 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CResult_1NetAddressu8ZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12051         if ((_res & 1) != 0) return;
12052         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ _res_conv = *(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(((uint64_t)_res) & ~1);
12053         FREE((void*)_res);
12054         CResult_CResult_NetAddressu8ZDecodeErrorZ_free(_res_conv);
12055 }
12056
12057 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CResult_1NetAddressu8ZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12058         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* orig_conv = (LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(orig & ~1);
12059         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
12060         *ret_conv = CResult_CResult_NetAddressu8ZDecodeErrorZ_clone(orig_conv);
12061         return (uint64_t)ret_conv;
12062 }
12063
12064 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12065         LDKNetAddress o_conv = *(LDKNetAddress*)(((uint64_t)o) & ~1);
12066         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
12067         *ret_conv = CResult_NetAddressDecodeErrorZ_ok(o_conv);
12068         return (uint64_t)ret_conv;
12069 }
12070
12071 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12072         LDKDecodeError e_conv;
12073         e_conv.inner = (void*)(e & (~1));
12074         e_conv.is_owned = (e & 1) || (e == 0);
12075         e_conv = DecodeError_clone(&e_conv);
12076         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
12077         *ret_conv = CResult_NetAddressDecodeErrorZ_err(e_conv);
12078         return (uint64_t)ret_conv;
12079 }
12080
12081 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12082         if ((_res & 1) != 0) return;
12083         LDKCResult_NetAddressDecodeErrorZ _res_conv = *(LDKCResult_NetAddressDecodeErrorZ*)(((uint64_t)_res) & ~1);
12084         FREE((void*)_res);
12085         CResult_NetAddressDecodeErrorZ_free(_res_conv);
12086 }
12087
12088 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12089         LDKCResult_NetAddressDecodeErrorZ* orig_conv = (LDKCResult_NetAddressDecodeErrorZ*)(orig & ~1);
12090         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
12091         *ret_conv = CResult_NetAddressDecodeErrorZ_clone(orig_conv);
12092         return (uint64_t)ret_conv;
12093 }
12094
12095 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateAddHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
12096         LDKCVec_UpdateAddHTLCZ _res_constr;
12097         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
12098         if (_res_constr.datalen > 0)
12099                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
12100         else
12101                 _res_constr.data = NULL;
12102         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
12103         for (size_t p = 0; p < _res_constr.datalen; p++) {
12104                 int64_t _res_conv_15 = _res_vals[p];
12105                 LDKUpdateAddHTLC _res_conv_15_conv;
12106                 _res_conv_15_conv.inner = (void*)(_res_conv_15 & (~1));
12107                 _res_conv_15_conv.is_owned = (_res_conv_15 & 1) || (_res_conv_15 == 0);
12108                 _res_constr.data[p] = _res_conv_15_conv;
12109         }
12110         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
12111         CVec_UpdateAddHTLCZ_free(_res_constr);
12112 }
12113
12114 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFulfillHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
12115         LDKCVec_UpdateFulfillHTLCZ _res_constr;
12116         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
12117         if (_res_constr.datalen > 0)
12118                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
12119         else
12120                 _res_constr.data = NULL;
12121         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
12122         for (size_t t = 0; t < _res_constr.datalen; t++) {
12123                 int64_t _res_conv_19 = _res_vals[t];
12124                 LDKUpdateFulfillHTLC _res_conv_19_conv;
12125                 _res_conv_19_conv.inner = (void*)(_res_conv_19 & (~1));
12126                 _res_conv_19_conv.is_owned = (_res_conv_19 & 1) || (_res_conv_19 == 0);
12127                 _res_constr.data[t] = _res_conv_19_conv;
12128         }
12129         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
12130         CVec_UpdateFulfillHTLCZ_free(_res_constr);
12131 }
12132
12133 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFailHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
12134         LDKCVec_UpdateFailHTLCZ _res_constr;
12135         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
12136         if (_res_constr.datalen > 0)
12137                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
12138         else
12139                 _res_constr.data = NULL;
12140         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
12141         for (size_t q = 0; q < _res_constr.datalen; q++) {
12142                 int64_t _res_conv_16 = _res_vals[q];
12143                 LDKUpdateFailHTLC _res_conv_16_conv;
12144                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
12145                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
12146                 _res_constr.data[q] = _res_conv_16_conv;
12147         }
12148         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
12149         CVec_UpdateFailHTLCZ_free(_res_constr);
12150 }
12151
12152 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFailMalformedHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
12153         LDKCVec_UpdateFailMalformedHTLCZ _res_constr;
12154         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
12155         if (_res_constr.datalen > 0)
12156                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
12157         else
12158                 _res_constr.data = NULL;
12159         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
12160         for (size_t z = 0; z < _res_constr.datalen; z++) {
12161                 int64_t _res_conv_25 = _res_vals[z];
12162                 LDKUpdateFailMalformedHTLC _res_conv_25_conv;
12163                 _res_conv_25_conv.inner = (void*)(_res_conv_25 & (~1));
12164                 _res_conv_25_conv.is_owned = (_res_conv_25 & 1) || (_res_conv_25 == 0);
12165                 _res_constr.data[z] = _res_conv_25_conv;
12166         }
12167         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
12168         CVec_UpdateFailMalformedHTLCZ_free(_res_constr);
12169 }
12170
12171 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12172         LDKAcceptChannel o_conv;
12173         o_conv.inner = (void*)(o & (~1));
12174         o_conv.is_owned = (o & 1) || (o == 0);
12175         o_conv = AcceptChannel_clone(&o_conv);
12176         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
12177         *ret_conv = CResult_AcceptChannelDecodeErrorZ_ok(o_conv);
12178         return (uint64_t)ret_conv;
12179 }
12180
12181 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12182         LDKDecodeError e_conv;
12183         e_conv.inner = (void*)(e & (~1));
12184         e_conv.is_owned = (e & 1) || (e == 0);
12185         e_conv = DecodeError_clone(&e_conv);
12186         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
12187         *ret_conv = CResult_AcceptChannelDecodeErrorZ_err(e_conv);
12188         return (uint64_t)ret_conv;
12189 }
12190
12191 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12192         if ((_res & 1) != 0) return;
12193         LDKCResult_AcceptChannelDecodeErrorZ _res_conv = *(LDKCResult_AcceptChannelDecodeErrorZ*)(((uint64_t)_res) & ~1);
12194         FREE((void*)_res);
12195         CResult_AcceptChannelDecodeErrorZ_free(_res_conv);
12196 }
12197
12198 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12199         LDKCResult_AcceptChannelDecodeErrorZ* orig_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(orig & ~1);
12200         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
12201         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(orig_conv);
12202         return (uint64_t)ret_conv;
12203 }
12204
12205 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12206         LDKAnnouncementSignatures o_conv;
12207         o_conv.inner = (void*)(o & (~1));
12208         o_conv.is_owned = (o & 1) || (o == 0);
12209         o_conv = AnnouncementSignatures_clone(&o_conv);
12210         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
12211         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_ok(o_conv);
12212         return (uint64_t)ret_conv;
12213 }
12214
12215 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12216         LDKDecodeError e_conv;
12217         e_conv.inner = (void*)(e & (~1));
12218         e_conv.is_owned = (e & 1) || (e == 0);
12219         e_conv = DecodeError_clone(&e_conv);
12220         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
12221         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_err(e_conv);
12222         return (uint64_t)ret_conv;
12223 }
12224
12225 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12226         if ((_res & 1) != 0) return;
12227         LDKCResult_AnnouncementSignaturesDecodeErrorZ _res_conv = *(LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
12228         FREE((void*)_res);
12229         CResult_AnnouncementSignaturesDecodeErrorZ_free(_res_conv);
12230 }
12231
12232 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12233         LDKCResult_AnnouncementSignaturesDecodeErrorZ* orig_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(orig & ~1);
12234         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
12235         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(orig_conv);
12236         return (uint64_t)ret_conv;
12237 }
12238
12239 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12240         LDKChannelReestablish o_conv;
12241         o_conv.inner = (void*)(o & (~1));
12242         o_conv.is_owned = (o & 1) || (o == 0);
12243         o_conv = ChannelReestablish_clone(&o_conv);
12244         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
12245         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_ok(o_conv);
12246         return (uint64_t)ret_conv;
12247 }
12248
12249 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12250         LDKDecodeError e_conv;
12251         e_conv.inner = (void*)(e & (~1));
12252         e_conv.is_owned = (e & 1) || (e == 0);
12253         e_conv = DecodeError_clone(&e_conv);
12254         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
12255         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_err(e_conv);
12256         return (uint64_t)ret_conv;
12257 }
12258
12259 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12260         if ((_res & 1) != 0) return;
12261         LDKCResult_ChannelReestablishDecodeErrorZ _res_conv = *(LDKCResult_ChannelReestablishDecodeErrorZ*)(((uint64_t)_res) & ~1);
12262         FREE((void*)_res);
12263         CResult_ChannelReestablishDecodeErrorZ_free(_res_conv);
12264 }
12265
12266 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12267         LDKCResult_ChannelReestablishDecodeErrorZ* orig_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(orig & ~1);
12268         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
12269         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(orig_conv);
12270         return (uint64_t)ret_conv;
12271 }
12272
12273 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12274         LDKClosingSigned o_conv;
12275         o_conv.inner = (void*)(o & (~1));
12276         o_conv.is_owned = (o & 1) || (o == 0);
12277         o_conv = ClosingSigned_clone(&o_conv);
12278         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
12279         *ret_conv = CResult_ClosingSignedDecodeErrorZ_ok(o_conv);
12280         return (uint64_t)ret_conv;
12281 }
12282
12283 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12284         LDKDecodeError e_conv;
12285         e_conv.inner = (void*)(e & (~1));
12286         e_conv.is_owned = (e & 1) || (e == 0);
12287         e_conv = DecodeError_clone(&e_conv);
12288         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
12289         *ret_conv = CResult_ClosingSignedDecodeErrorZ_err(e_conv);
12290         return (uint64_t)ret_conv;
12291 }
12292
12293 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12294         if ((_res & 1) != 0) return;
12295         LDKCResult_ClosingSignedDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedDecodeErrorZ*)(((uint64_t)_res) & ~1);
12296         FREE((void*)_res);
12297         CResult_ClosingSignedDecodeErrorZ_free(_res_conv);
12298 }
12299
12300 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12301         LDKCResult_ClosingSignedDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(orig & ~1);
12302         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
12303         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(orig_conv);
12304         return (uint64_t)ret_conv;
12305 }
12306
12307 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12308         LDKCommitmentSigned o_conv;
12309         o_conv.inner = (void*)(o & (~1));
12310         o_conv.is_owned = (o & 1) || (o == 0);
12311         o_conv = CommitmentSigned_clone(&o_conv);
12312         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
12313         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_ok(o_conv);
12314         return (uint64_t)ret_conv;
12315 }
12316
12317 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12318         LDKDecodeError e_conv;
12319         e_conv.inner = (void*)(e & (~1));
12320         e_conv.is_owned = (e & 1) || (e == 0);
12321         e_conv = DecodeError_clone(&e_conv);
12322         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
12323         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_err(e_conv);
12324         return (uint64_t)ret_conv;
12325 }
12326
12327 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12328         if ((_res & 1) != 0) return;
12329         LDKCResult_CommitmentSignedDecodeErrorZ _res_conv = *(LDKCResult_CommitmentSignedDecodeErrorZ*)(((uint64_t)_res) & ~1);
12330         FREE((void*)_res);
12331         CResult_CommitmentSignedDecodeErrorZ_free(_res_conv);
12332 }
12333
12334 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12335         LDKCResult_CommitmentSignedDecodeErrorZ* orig_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(orig & ~1);
12336         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
12337         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(orig_conv);
12338         return (uint64_t)ret_conv;
12339 }
12340
12341 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12342         LDKFundingCreated o_conv;
12343         o_conv.inner = (void*)(o & (~1));
12344         o_conv.is_owned = (o & 1) || (o == 0);
12345         o_conv = FundingCreated_clone(&o_conv);
12346         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
12347         *ret_conv = CResult_FundingCreatedDecodeErrorZ_ok(o_conv);
12348         return (uint64_t)ret_conv;
12349 }
12350
12351 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12352         LDKDecodeError e_conv;
12353         e_conv.inner = (void*)(e & (~1));
12354         e_conv.is_owned = (e & 1) || (e == 0);
12355         e_conv = DecodeError_clone(&e_conv);
12356         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
12357         *ret_conv = CResult_FundingCreatedDecodeErrorZ_err(e_conv);
12358         return (uint64_t)ret_conv;
12359 }
12360
12361 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12362         if ((_res & 1) != 0) return;
12363         LDKCResult_FundingCreatedDecodeErrorZ _res_conv = *(LDKCResult_FundingCreatedDecodeErrorZ*)(((uint64_t)_res) & ~1);
12364         FREE((void*)_res);
12365         CResult_FundingCreatedDecodeErrorZ_free(_res_conv);
12366 }
12367
12368 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12369         LDKCResult_FundingCreatedDecodeErrorZ* orig_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(orig & ~1);
12370         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
12371         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(orig_conv);
12372         return (uint64_t)ret_conv;
12373 }
12374
12375 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12376         LDKFundingSigned o_conv;
12377         o_conv.inner = (void*)(o & (~1));
12378         o_conv.is_owned = (o & 1) || (o == 0);
12379         o_conv = FundingSigned_clone(&o_conv);
12380         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
12381         *ret_conv = CResult_FundingSignedDecodeErrorZ_ok(o_conv);
12382         return (uint64_t)ret_conv;
12383 }
12384
12385 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12386         LDKDecodeError e_conv;
12387         e_conv.inner = (void*)(e & (~1));
12388         e_conv.is_owned = (e & 1) || (e == 0);
12389         e_conv = DecodeError_clone(&e_conv);
12390         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
12391         *ret_conv = CResult_FundingSignedDecodeErrorZ_err(e_conv);
12392         return (uint64_t)ret_conv;
12393 }
12394
12395 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12396         if ((_res & 1) != 0) return;
12397         LDKCResult_FundingSignedDecodeErrorZ _res_conv = *(LDKCResult_FundingSignedDecodeErrorZ*)(((uint64_t)_res) & ~1);
12398         FREE((void*)_res);
12399         CResult_FundingSignedDecodeErrorZ_free(_res_conv);
12400 }
12401
12402 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12403         LDKCResult_FundingSignedDecodeErrorZ* orig_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(orig & ~1);
12404         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
12405         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(orig_conv);
12406         return (uint64_t)ret_conv;
12407 }
12408
12409 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12410         LDKFundingLocked o_conv;
12411         o_conv.inner = (void*)(o & (~1));
12412         o_conv.is_owned = (o & 1) || (o == 0);
12413         o_conv = FundingLocked_clone(&o_conv);
12414         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
12415         *ret_conv = CResult_FundingLockedDecodeErrorZ_ok(o_conv);
12416         return (uint64_t)ret_conv;
12417 }
12418
12419 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12420         LDKDecodeError e_conv;
12421         e_conv.inner = (void*)(e & (~1));
12422         e_conv.is_owned = (e & 1) || (e == 0);
12423         e_conv = DecodeError_clone(&e_conv);
12424         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
12425         *ret_conv = CResult_FundingLockedDecodeErrorZ_err(e_conv);
12426         return (uint64_t)ret_conv;
12427 }
12428
12429 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12430         if ((_res & 1) != 0) return;
12431         LDKCResult_FundingLockedDecodeErrorZ _res_conv = *(LDKCResult_FundingLockedDecodeErrorZ*)(((uint64_t)_res) & ~1);
12432         FREE((void*)_res);
12433         CResult_FundingLockedDecodeErrorZ_free(_res_conv);
12434 }
12435
12436 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12437         LDKCResult_FundingLockedDecodeErrorZ* orig_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(orig & ~1);
12438         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
12439         *ret_conv = CResult_FundingLockedDecodeErrorZ_clone(orig_conv);
12440         return (uint64_t)ret_conv;
12441 }
12442
12443 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12444         LDKInit o_conv;
12445         o_conv.inner = (void*)(o & (~1));
12446         o_conv.is_owned = (o & 1) || (o == 0);
12447         o_conv = Init_clone(&o_conv);
12448         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
12449         *ret_conv = CResult_InitDecodeErrorZ_ok(o_conv);
12450         return (uint64_t)ret_conv;
12451 }
12452
12453 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12454         LDKDecodeError e_conv;
12455         e_conv.inner = (void*)(e & (~1));
12456         e_conv.is_owned = (e & 1) || (e == 0);
12457         e_conv = DecodeError_clone(&e_conv);
12458         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
12459         *ret_conv = CResult_InitDecodeErrorZ_err(e_conv);
12460         return (uint64_t)ret_conv;
12461 }
12462
12463 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12464         if ((_res & 1) != 0) return;
12465         LDKCResult_InitDecodeErrorZ _res_conv = *(LDKCResult_InitDecodeErrorZ*)(((uint64_t)_res) & ~1);
12466         FREE((void*)_res);
12467         CResult_InitDecodeErrorZ_free(_res_conv);
12468 }
12469
12470 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12471         LDKCResult_InitDecodeErrorZ* orig_conv = (LDKCResult_InitDecodeErrorZ*)(orig & ~1);
12472         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
12473         *ret_conv = CResult_InitDecodeErrorZ_clone(orig_conv);
12474         return (uint64_t)ret_conv;
12475 }
12476
12477 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12478         LDKOpenChannel o_conv;
12479         o_conv.inner = (void*)(o & (~1));
12480         o_conv.is_owned = (o & 1) || (o == 0);
12481         o_conv = OpenChannel_clone(&o_conv);
12482         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
12483         *ret_conv = CResult_OpenChannelDecodeErrorZ_ok(o_conv);
12484         return (uint64_t)ret_conv;
12485 }
12486
12487 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12488         LDKDecodeError e_conv;
12489         e_conv.inner = (void*)(e & (~1));
12490         e_conv.is_owned = (e & 1) || (e == 0);
12491         e_conv = DecodeError_clone(&e_conv);
12492         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
12493         *ret_conv = CResult_OpenChannelDecodeErrorZ_err(e_conv);
12494         return (uint64_t)ret_conv;
12495 }
12496
12497 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12498         if ((_res & 1) != 0) return;
12499         LDKCResult_OpenChannelDecodeErrorZ _res_conv = *(LDKCResult_OpenChannelDecodeErrorZ*)(((uint64_t)_res) & ~1);
12500         FREE((void*)_res);
12501         CResult_OpenChannelDecodeErrorZ_free(_res_conv);
12502 }
12503
12504 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12505         LDKCResult_OpenChannelDecodeErrorZ* orig_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(orig & ~1);
12506         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
12507         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(orig_conv);
12508         return (uint64_t)ret_conv;
12509 }
12510
12511 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12512         LDKRevokeAndACK o_conv;
12513         o_conv.inner = (void*)(o & (~1));
12514         o_conv.is_owned = (o & 1) || (o == 0);
12515         o_conv = RevokeAndACK_clone(&o_conv);
12516         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
12517         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_ok(o_conv);
12518         return (uint64_t)ret_conv;
12519 }
12520
12521 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12522         LDKDecodeError e_conv;
12523         e_conv.inner = (void*)(e & (~1));
12524         e_conv.is_owned = (e & 1) || (e == 0);
12525         e_conv = DecodeError_clone(&e_conv);
12526         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
12527         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_err(e_conv);
12528         return (uint64_t)ret_conv;
12529 }
12530
12531 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12532         if ((_res & 1) != 0) return;
12533         LDKCResult_RevokeAndACKDecodeErrorZ _res_conv = *(LDKCResult_RevokeAndACKDecodeErrorZ*)(((uint64_t)_res) & ~1);
12534         FREE((void*)_res);
12535         CResult_RevokeAndACKDecodeErrorZ_free(_res_conv);
12536 }
12537
12538 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12539         LDKCResult_RevokeAndACKDecodeErrorZ* orig_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(orig & ~1);
12540         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
12541         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(orig_conv);
12542         return (uint64_t)ret_conv;
12543 }
12544
12545 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12546         LDKShutdown o_conv;
12547         o_conv.inner = (void*)(o & (~1));
12548         o_conv.is_owned = (o & 1) || (o == 0);
12549         o_conv = Shutdown_clone(&o_conv);
12550         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
12551         *ret_conv = CResult_ShutdownDecodeErrorZ_ok(o_conv);
12552         return (uint64_t)ret_conv;
12553 }
12554
12555 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12556         LDKDecodeError e_conv;
12557         e_conv.inner = (void*)(e & (~1));
12558         e_conv.is_owned = (e & 1) || (e == 0);
12559         e_conv = DecodeError_clone(&e_conv);
12560         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
12561         *ret_conv = CResult_ShutdownDecodeErrorZ_err(e_conv);
12562         return (uint64_t)ret_conv;
12563 }
12564
12565 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12566         if ((_res & 1) != 0) return;
12567         LDKCResult_ShutdownDecodeErrorZ _res_conv = *(LDKCResult_ShutdownDecodeErrorZ*)(((uint64_t)_res) & ~1);
12568         FREE((void*)_res);
12569         CResult_ShutdownDecodeErrorZ_free(_res_conv);
12570 }
12571
12572 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12573         LDKCResult_ShutdownDecodeErrorZ* orig_conv = (LDKCResult_ShutdownDecodeErrorZ*)(orig & ~1);
12574         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
12575         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(orig_conv);
12576         return (uint64_t)ret_conv;
12577 }
12578
12579 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12580         LDKUpdateFailHTLC o_conv;
12581         o_conv.inner = (void*)(o & (~1));
12582         o_conv.is_owned = (o & 1) || (o == 0);
12583         o_conv = UpdateFailHTLC_clone(&o_conv);
12584         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
12585         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_ok(o_conv);
12586         return (uint64_t)ret_conv;
12587 }
12588
12589 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12590         LDKDecodeError e_conv;
12591         e_conv.inner = (void*)(e & (~1));
12592         e_conv.is_owned = (e & 1) || (e == 0);
12593         e_conv = DecodeError_clone(&e_conv);
12594         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
12595         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_err(e_conv);
12596         return (uint64_t)ret_conv;
12597 }
12598
12599 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12600         if ((_res & 1) != 0) return;
12601         LDKCResult_UpdateFailHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
12602         FREE((void*)_res);
12603         CResult_UpdateFailHTLCDecodeErrorZ_free(_res_conv);
12604 }
12605
12606 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12607         LDKCResult_UpdateFailHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(orig & ~1);
12608         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
12609         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(orig_conv);
12610         return (uint64_t)ret_conv;
12611 }
12612
12613 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12614         LDKUpdateFailMalformedHTLC o_conv;
12615         o_conv.inner = (void*)(o & (~1));
12616         o_conv.is_owned = (o & 1) || (o == 0);
12617         o_conv = UpdateFailMalformedHTLC_clone(&o_conv);
12618         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
12619         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(o_conv);
12620         return (uint64_t)ret_conv;
12621 }
12622
12623 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12624         LDKDecodeError e_conv;
12625         e_conv.inner = (void*)(e & (~1));
12626         e_conv.is_owned = (e & 1) || (e == 0);
12627         e_conv = DecodeError_clone(&e_conv);
12628         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
12629         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(e_conv);
12630         return (uint64_t)ret_conv;
12631 }
12632
12633 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12634         if ((_res & 1) != 0) return;
12635         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
12636         FREE((void*)_res);
12637         CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(_res_conv);
12638 }
12639
12640 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12641         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(orig & ~1);
12642         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
12643         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(orig_conv);
12644         return (uint64_t)ret_conv;
12645 }
12646
12647 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12648         LDKUpdateFee o_conv;
12649         o_conv.inner = (void*)(o & (~1));
12650         o_conv.is_owned = (o & 1) || (o == 0);
12651         o_conv = UpdateFee_clone(&o_conv);
12652         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
12653         *ret_conv = CResult_UpdateFeeDecodeErrorZ_ok(o_conv);
12654         return (uint64_t)ret_conv;
12655 }
12656
12657 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12658         LDKDecodeError e_conv;
12659         e_conv.inner = (void*)(e & (~1));
12660         e_conv.is_owned = (e & 1) || (e == 0);
12661         e_conv = DecodeError_clone(&e_conv);
12662         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
12663         *ret_conv = CResult_UpdateFeeDecodeErrorZ_err(e_conv);
12664         return (uint64_t)ret_conv;
12665 }
12666
12667 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12668         if ((_res & 1) != 0) return;
12669         LDKCResult_UpdateFeeDecodeErrorZ _res_conv = *(LDKCResult_UpdateFeeDecodeErrorZ*)(((uint64_t)_res) & ~1);
12670         FREE((void*)_res);
12671         CResult_UpdateFeeDecodeErrorZ_free(_res_conv);
12672 }
12673
12674 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12675         LDKCResult_UpdateFeeDecodeErrorZ* orig_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(orig & ~1);
12676         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
12677         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(orig_conv);
12678         return (uint64_t)ret_conv;
12679 }
12680
12681 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12682         LDKUpdateFulfillHTLC o_conv;
12683         o_conv.inner = (void*)(o & (~1));
12684         o_conv.is_owned = (o & 1) || (o == 0);
12685         o_conv = UpdateFulfillHTLC_clone(&o_conv);
12686         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
12687         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_ok(o_conv);
12688         return (uint64_t)ret_conv;
12689 }
12690
12691 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12692         LDKDecodeError e_conv;
12693         e_conv.inner = (void*)(e & (~1));
12694         e_conv.is_owned = (e & 1) || (e == 0);
12695         e_conv = DecodeError_clone(&e_conv);
12696         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
12697         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_err(e_conv);
12698         return (uint64_t)ret_conv;
12699 }
12700
12701 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12702         if ((_res & 1) != 0) return;
12703         LDKCResult_UpdateFulfillHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
12704         FREE((void*)_res);
12705         CResult_UpdateFulfillHTLCDecodeErrorZ_free(_res_conv);
12706 }
12707
12708 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12709         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(orig & ~1);
12710         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
12711         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(orig_conv);
12712         return (uint64_t)ret_conv;
12713 }
12714
12715 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12716         LDKUpdateAddHTLC o_conv;
12717         o_conv.inner = (void*)(o & (~1));
12718         o_conv.is_owned = (o & 1) || (o == 0);
12719         o_conv = UpdateAddHTLC_clone(&o_conv);
12720         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
12721         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_ok(o_conv);
12722         return (uint64_t)ret_conv;
12723 }
12724
12725 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12726         LDKDecodeError e_conv;
12727         e_conv.inner = (void*)(e & (~1));
12728         e_conv.is_owned = (e & 1) || (e == 0);
12729         e_conv = DecodeError_clone(&e_conv);
12730         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
12731         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_err(e_conv);
12732         return (uint64_t)ret_conv;
12733 }
12734
12735 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12736         if ((_res & 1) != 0) return;
12737         LDKCResult_UpdateAddHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateAddHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
12738         FREE((void*)_res);
12739         CResult_UpdateAddHTLCDecodeErrorZ_free(_res_conv);
12740 }
12741
12742 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12743         LDKCResult_UpdateAddHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(orig & ~1);
12744         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
12745         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(orig_conv);
12746         return (uint64_t)ret_conv;
12747 }
12748
12749 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12750         LDKPing o_conv;
12751         o_conv.inner = (void*)(o & (~1));
12752         o_conv.is_owned = (o & 1) || (o == 0);
12753         o_conv = Ping_clone(&o_conv);
12754         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
12755         *ret_conv = CResult_PingDecodeErrorZ_ok(o_conv);
12756         return (uint64_t)ret_conv;
12757 }
12758
12759 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12760         LDKDecodeError e_conv;
12761         e_conv.inner = (void*)(e & (~1));
12762         e_conv.is_owned = (e & 1) || (e == 0);
12763         e_conv = DecodeError_clone(&e_conv);
12764         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
12765         *ret_conv = CResult_PingDecodeErrorZ_err(e_conv);
12766         return (uint64_t)ret_conv;
12767 }
12768
12769 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12770         if ((_res & 1) != 0) return;
12771         LDKCResult_PingDecodeErrorZ _res_conv = *(LDKCResult_PingDecodeErrorZ*)(((uint64_t)_res) & ~1);
12772         FREE((void*)_res);
12773         CResult_PingDecodeErrorZ_free(_res_conv);
12774 }
12775
12776 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12777         LDKCResult_PingDecodeErrorZ* orig_conv = (LDKCResult_PingDecodeErrorZ*)(orig & ~1);
12778         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
12779         *ret_conv = CResult_PingDecodeErrorZ_clone(orig_conv);
12780         return (uint64_t)ret_conv;
12781 }
12782
12783 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12784         LDKPong o_conv;
12785         o_conv.inner = (void*)(o & (~1));
12786         o_conv.is_owned = (o & 1) || (o == 0);
12787         o_conv = Pong_clone(&o_conv);
12788         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
12789         *ret_conv = CResult_PongDecodeErrorZ_ok(o_conv);
12790         return (uint64_t)ret_conv;
12791 }
12792
12793 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12794         LDKDecodeError e_conv;
12795         e_conv.inner = (void*)(e & (~1));
12796         e_conv.is_owned = (e & 1) || (e == 0);
12797         e_conv = DecodeError_clone(&e_conv);
12798         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
12799         *ret_conv = CResult_PongDecodeErrorZ_err(e_conv);
12800         return (uint64_t)ret_conv;
12801 }
12802
12803 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12804         if ((_res & 1) != 0) return;
12805         LDKCResult_PongDecodeErrorZ _res_conv = *(LDKCResult_PongDecodeErrorZ*)(((uint64_t)_res) & ~1);
12806         FREE((void*)_res);
12807         CResult_PongDecodeErrorZ_free(_res_conv);
12808 }
12809
12810 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12811         LDKCResult_PongDecodeErrorZ* orig_conv = (LDKCResult_PongDecodeErrorZ*)(orig & ~1);
12812         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
12813         *ret_conv = CResult_PongDecodeErrorZ_clone(orig_conv);
12814         return (uint64_t)ret_conv;
12815 }
12816
12817 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12818         LDKUnsignedChannelAnnouncement o_conv;
12819         o_conv.inner = (void*)(o & (~1));
12820         o_conv.is_owned = (o & 1) || (o == 0);
12821         o_conv = UnsignedChannelAnnouncement_clone(&o_conv);
12822         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
12823         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(o_conv);
12824         return (uint64_t)ret_conv;
12825 }
12826
12827 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12828         LDKDecodeError e_conv;
12829         e_conv.inner = (void*)(e & (~1));
12830         e_conv.is_owned = (e & 1) || (e == 0);
12831         e_conv = DecodeError_clone(&e_conv);
12832         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
12833         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(e_conv);
12834         return (uint64_t)ret_conv;
12835 }
12836
12837 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12838         if ((_res & 1) != 0) return;
12839         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
12840         FREE((void*)_res);
12841         CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(_res_conv);
12842 }
12843
12844 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12845         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(orig & ~1);
12846         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
12847         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(orig_conv);
12848         return (uint64_t)ret_conv;
12849 }
12850
12851 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12852         LDKChannelAnnouncement o_conv;
12853         o_conv.inner = (void*)(o & (~1));
12854         o_conv.is_owned = (o & 1) || (o == 0);
12855         o_conv = ChannelAnnouncement_clone(&o_conv);
12856         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
12857         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_ok(o_conv);
12858         return (uint64_t)ret_conv;
12859 }
12860
12861 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12862         LDKDecodeError e_conv;
12863         e_conv.inner = (void*)(e & (~1));
12864         e_conv.is_owned = (e & 1) || (e == 0);
12865         e_conv = DecodeError_clone(&e_conv);
12866         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
12867         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_err(e_conv);
12868         return (uint64_t)ret_conv;
12869 }
12870
12871 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12872         if ((_res & 1) != 0) return;
12873         LDKCResult_ChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_ChannelAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
12874         FREE((void*)_res);
12875         CResult_ChannelAnnouncementDecodeErrorZ_free(_res_conv);
12876 }
12877
12878 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12879         LDKCResult_ChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(orig & ~1);
12880         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
12881         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(orig_conv);
12882         return (uint64_t)ret_conv;
12883 }
12884
12885 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12886         LDKUnsignedChannelUpdate o_conv;
12887         o_conv.inner = (void*)(o & (~1));
12888         o_conv.is_owned = (o & 1) || (o == 0);
12889         o_conv = UnsignedChannelUpdate_clone(&o_conv);
12890         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
12891         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_ok(o_conv);
12892         return (uint64_t)ret_conv;
12893 }
12894
12895 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12896         LDKDecodeError e_conv;
12897         e_conv.inner = (void*)(e & (~1));
12898         e_conv.is_owned = (e & 1) || (e == 0);
12899         e_conv = DecodeError_clone(&e_conv);
12900         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
12901         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_err(e_conv);
12902         return (uint64_t)ret_conv;
12903 }
12904
12905 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12906         if ((_res & 1) != 0) return;
12907         LDKCResult_UnsignedChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
12908         FREE((void*)_res);
12909         CResult_UnsignedChannelUpdateDecodeErrorZ_free(_res_conv);
12910 }
12911
12912 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12913         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(orig & ~1);
12914         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
12915         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(orig_conv);
12916         return (uint64_t)ret_conv;
12917 }
12918
12919 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12920         LDKChannelUpdate o_conv;
12921         o_conv.inner = (void*)(o & (~1));
12922         o_conv.is_owned = (o & 1) || (o == 0);
12923         o_conv = ChannelUpdate_clone(&o_conv);
12924         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
12925         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_ok(o_conv);
12926         return (uint64_t)ret_conv;
12927 }
12928
12929 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12930         LDKDecodeError e_conv;
12931         e_conv.inner = (void*)(e & (~1));
12932         e_conv.is_owned = (e & 1) || (e == 0);
12933         e_conv = DecodeError_clone(&e_conv);
12934         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
12935         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_err(e_conv);
12936         return (uint64_t)ret_conv;
12937 }
12938
12939 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12940         if ((_res & 1) != 0) return;
12941         LDKCResult_ChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
12942         FREE((void*)_res);
12943         CResult_ChannelUpdateDecodeErrorZ_free(_res_conv);
12944 }
12945
12946 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12947         LDKCResult_ChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(orig & ~1);
12948         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
12949         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(orig_conv);
12950         return (uint64_t)ret_conv;
12951 }
12952
12953 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12954         LDKErrorMessage o_conv;
12955         o_conv.inner = (void*)(o & (~1));
12956         o_conv.is_owned = (o & 1) || (o == 0);
12957         o_conv = ErrorMessage_clone(&o_conv);
12958         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
12959         *ret_conv = CResult_ErrorMessageDecodeErrorZ_ok(o_conv);
12960         return (uint64_t)ret_conv;
12961 }
12962
12963 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12964         LDKDecodeError e_conv;
12965         e_conv.inner = (void*)(e & (~1));
12966         e_conv.is_owned = (e & 1) || (e == 0);
12967         e_conv = DecodeError_clone(&e_conv);
12968         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
12969         *ret_conv = CResult_ErrorMessageDecodeErrorZ_err(e_conv);
12970         return (uint64_t)ret_conv;
12971 }
12972
12973 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12974         if ((_res & 1) != 0) return;
12975         LDKCResult_ErrorMessageDecodeErrorZ _res_conv = *(LDKCResult_ErrorMessageDecodeErrorZ*)(((uint64_t)_res) & ~1);
12976         FREE((void*)_res);
12977         CResult_ErrorMessageDecodeErrorZ_free(_res_conv);
12978 }
12979
12980 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12981         LDKCResult_ErrorMessageDecodeErrorZ* orig_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(orig & ~1);
12982         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
12983         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(orig_conv);
12984         return (uint64_t)ret_conv;
12985 }
12986
12987 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12988         LDKUnsignedNodeAnnouncement o_conv;
12989         o_conv.inner = (void*)(o & (~1));
12990         o_conv.is_owned = (o & 1) || (o == 0);
12991         o_conv = UnsignedNodeAnnouncement_clone(&o_conv);
12992         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
12993         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(o_conv);
12994         return (uint64_t)ret_conv;
12995 }
12996
12997 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12998         LDKDecodeError e_conv;
12999         e_conv.inner = (void*)(e & (~1));
13000         e_conv.is_owned = (e & 1) || (e == 0);
13001         e_conv = DecodeError_clone(&e_conv);
13002         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
13003         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(e_conv);
13004         return (uint64_t)ret_conv;
13005 }
13006
13007 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13008         if ((_res & 1) != 0) return;
13009         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
13010         FREE((void*)_res);
13011         CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(_res_conv);
13012 }
13013
13014 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13015         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(orig & ~1);
13016         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
13017         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(orig_conv);
13018         return (uint64_t)ret_conv;
13019 }
13020
13021 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13022         LDKNodeAnnouncement o_conv;
13023         o_conv.inner = (void*)(o & (~1));
13024         o_conv.is_owned = (o & 1) || (o == 0);
13025         o_conv = NodeAnnouncement_clone(&o_conv);
13026         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
13027         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_ok(o_conv);
13028         return (uint64_t)ret_conv;
13029 }
13030
13031 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13032         LDKDecodeError e_conv;
13033         e_conv.inner = (void*)(e & (~1));
13034         e_conv.is_owned = (e & 1) || (e == 0);
13035         e_conv = DecodeError_clone(&e_conv);
13036         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
13037         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_err(e_conv);
13038         return (uint64_t)ret_conv;
13039 }
13040
13041 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13042         if ((_res & 1) != 0) return;
13043         LDKCResult_NodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
13044         FREE((void*)_res);
13045         CResult_NodeAnnouncementDecodeErrorZ_free(_res_conv);
13046 }
13047
13048 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13049         LDKCResult_NodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(orig & ~1);
13050         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
13051         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(orig_conv);
13052         return (uint64_t)ret_conv;
13053 }
13054
13055 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13056         LDKQueryShortChannelIds o_conv;
13057         o_conv.inner = (void*)(o & (~1));
13058         o_conv.is_owned = (o & 1) || (o == 0);
13059         o_conv = QueryShortChannelIds_clone(&o_conv);
13060         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
13061         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_ok(o_conv);
13062         return (uint64_t)ret_conv;
13063 }
13064
13065 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13066         LDKDecodeError e_conv;
13067         e_conv.inner = (void*)(e & (~1));
13068         e_conv.is_owned = (e & 1) || (e == 0);
13069         e_conv = DecodeError_clone(&e_conv);
13070         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
13071         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_err(e_conv);
13072         return (uint64_t)ret_conv;
13073 }
13074
13075 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13076         if ((_res & 1) != 0) return;
13077         LDKCResult_QueryShortChannelIdsDecodeErrorZ _res_conv = *(LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(((uint64_t)_res) & ~1);
13078         FREE((void*)_res);
13079         CResult_QueryShortChannelIdsDecodeErrorZ_free(_res_conv);
13080 }
13081
13082 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13083         LDKCResult_QueryShortChannelIdsDecodeErrorZ* orig_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(orig & ~1);
13084         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
13085         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(orig_conv);
13086         return (uint64_t)ret_conv;
13087 }
13088
13089 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13090         LDKReplyShortChannelIdsEnd o_conv;
13091         o_conv.inner = (void*)(o & (~1));
13092         o_conv.is_owned = (o & 1) || (o == 0);
13093         o_conv = ReplyShortChannelIdsEnd_clone(&o_conv);
13094         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
13095         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(o_conv);
13096         return (uint64_t)ret_conv;
13097 }
13098
13099 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13100         LDKDecodeError e_conv;
13101         e_conv.inner = (void*)(e & (~1));
13102         e_conv.is_owned = (e & 1) || (e == 0);
13103         e_conv = DecodeError_clone(&e_conv);
13104         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
13105         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(e_conv);
13106         return (uint64_t)ret_conv;
13107 }
13108
13109 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13110         if ((_res & 1) != 0) return;
13111         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ _res_conv = *(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(((uint64_t)_res) & ~1);
13112         FREE((void*)_res);
13113         CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(_res_conv);
13114 }
13115
13116 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13117         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* orig_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(orig & ~1);
13118         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
13119         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(orig_conv);
13120         return (uint64_t)ret_conv;
13121 }
13122
13123 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13124         LDKQueryChannelRange o_conv;
13125         o_conv.inner = (void*)(o & (~1));
13126         o_conv.is_owned = (o & 1) || (o == 0);
13127         o_conv = QueryChannelRange_clone(&o_conv);
13128         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
13129         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_ok(o_conv);
13130         return (uint64_t)ret_conv;
13131 }
13132
13133 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13134         LDKDecodeError e_conv;
13135         e_conv.inner = (void*)(e & (~1));
13136         e_conv.is_owned = (e & 1) || (e == 0);
13137         e_conv = DecodeError_clone(&e_conv);
13138         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
13139         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_err(e_conv);
13140         return (uint64_t)ret_conv;
13141 }
13142
13143 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13144         if ((_res & 1) != 0) return;
13145         LDKCResult_QueryChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_QueryChannelRangeDecodeErrorZ*)(((uint64_t)_res) & ~1);
13146         FREE((void*)_res);
13147         CResult_QueryChannelRangeDecodeErrorZ_free(_res_conv);
13148 }
13149
13150 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13151         LDKCResult_QueryChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(orig & ~1);
13152         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
13153         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(orig_conv);
13154         return (uint64_t)ret_conv;
13155 }
13156
13157 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13158         LDKReplyChannelRange o_conv;
13159         o_conv.inner = (void*)(o & (~1));
13160         o_conv.is_owned = (o & 1) || (o == 0);
13161         o_conv = ReplyChannelRange_clone(&o_conv);
13162         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
13163         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_ok(o_conv);
13164         return (uint64_t)ret_conv;
13165 }
13166
13167 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13168         LDKDecodeError e_conv;
13169         e_conv.inner = (void*)(e & (~1));
13170         e_conv.is_owned = (e & 1) || (e == 0);
13171         e_conv = DecodeError_clone(&e_conv);
13172         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
13173         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_err(e_conv);
13174         return (uint64_t)ret_conv;
13175 }
13176
13177 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13178         if ((_res & 1) != 0) return;
13179         LDKCResult_ReplyChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_ReplyChannelRangeDecodeErrorZ*)(((uint64_t)_res) & ~1);
13180         FREE((void*)_res);
13181         CResult_ReplyChannelRangeDecodeErrorZ_free(_res_conv);
13182 }
13183
13184 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13185         LDKCResult_ReplyChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(orig & ~1);
13186         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
13187         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(orig_conv);
13188         return (uint64_t)ret_conv;
13189 }
13190
13191 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13192         LDKGossipTimestampFilter o_conv;
13193         o_conv.inner = (void*)(o & (~1));
13194         o_conv.is_owned = (o & 1) || (o == 0);
13195         o_conv = GossipTimestampFilter_clone(&o_conv);
13196         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
13197         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_ok(o_conv);
13198         return (uint64_t)ret_conv;
13199 }
13200
13201 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13202         LDKDecodeError e_conv;
13203         e_conv.inner = (void*)(e & (~1));
13204         e_conv.is_owned = (e & 1) || (e == 0);
13205         e_conv = DecodeError_clone(&e_conv);
13206         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
13207         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_err(e_conv);
13208         return (uint64_t)ret_conv;
13209 }
13210
13211 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13212         if ((_res & 1) != 0) return;
13213         LDKCResult_GossipTimestampFilterDecodeErrorZ _res_conv = *(LDKCResult_GossipTimestampFilterDecodeErrorZ*)(((uint64_t)_res) & ~1);
13214         FREE((void*)_res);
13215         CResult_GossipTimestampFilterDecodeErrorZ_free(_res_conv);
13216 }
13217
13218 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13219         LDKCResult_GossipTimestampFilterDecodeErrorZ* orig_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(orig & ~1);
13220         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
13221         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(orig_conv);
13222         return (uint64_t)ret_conv;
13223 }
13224
13225 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13226         LDKInvoice o_conv;
13227         o_conv.inner = (void*)(o & (~1));
13228         o_conv.is_owned = (o & 1) || (o == 0);
13229         o_conv = Invoice_clone(&o_conv);
13230         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
13231         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_ok(o_conv);
13232         return (uint64_t)ret_conv;
13233 }
13234
13235 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13236         LDKSignOrCreationError e_conv = *(LDKSignOrCreationError*)(((uint64_t)e) & ~1);
13237         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
13238         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_err(e_conv);
13239         return (uint64_t)ret_conv;
13240 }
13241
13242 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13243         if ((_res & 1) != 0) return;
13244         LDKCResult_InvoiceSignOrCreationErrorZ _res_conv = *(LDKCResult_InvoiceSignOrCreationErrorZ*)(((uint64_t)_res) & ~1);
13245         FREE((void*)_res);
13246         CResult_InvoiceSignOrCreationErrorZ_free(_res_conv);
13247 }
13248
13249 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13250         LDKCResult_InvoiceSignOrCreationErrorZ* orig_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(orig & ~1);
13251         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
13252         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone(orig_conv);
13253         return (uint64_t)ret_conv;
13254 }
13255
13256 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Event_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
13257         if ((this_ptr & 1) != 0) return;
13258         LDKEvent this_ptr_conv = *(LDKEvent*)(((uint64_t)this_ptr) & ~1);
13259         FREE((void*)this_ptr);
13260         Event_free(this_ptr_conv);
13261 }
13262
13263 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13264         LDKEvent* orig_conv = (LDKEvent*)orig;
13265         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
13266         *ret_copy = Event_clone(orig_conv);
13267         uint64_t ret_ref = (uint64_t)ret_copy;
13268         return ret_ref;
13269 }
13270
13271 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Event_1write(JNIEnv *env, jclass clz, int64_t obj) {
13272         LDKEvent* obj_conv = (LDKEvent*)obj;
13273         LDKCVec_u8Z ret_var = Event_write(obj_conv);
13274         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
13275         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
13276         CVec_u8Z_free(ret_var);
13277         return ret_arr;
13278 }
13279
13280 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
13281         if ((this_ptr & 1) != 0) return;
13282         LDKMessageSendEvent this_ptr_conv = *(LDKMessageSendEvent*)(((uint64_t)this_ptr) & ~1);
13283         FREE((void*)this_ptr);
13284         MessageSendEvent_free(this_ptr_conv);
13285 }
13286
13287 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13288         LDKMessageSendEvent* orig_conv = (LDKMessageSendEvent*)orig;
13289         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
13290         *ret_copy = MessageSendEvent_clone(orig_conv);
13291         uint64_t ret_ref = (uint64_t)ret_copy;
13292         return ret_ref;
13293 }
13294
13295 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageSendEventsProvider_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
13296         if ((this_ptr & 1) != 0) return;
13297         LDKMessageSendEventsProvider this_ptr_conv = *(LDKMessageSendEventsProvider*)(((uint64_t)this_ptr) & ~1);
13298         FREE((void*)this_ptr);
13299         MessageSendEventsProvider_free(this_ptr_conv);
13300 }
13301
13302 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventsProvider_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
13303         if ((this_ptr & 1) != 0) return;
13304         LDKEventsProvider this_ptr_conv = *(LDKEventsProvider*)(((uint64_t)this_ptr) & ~1);
13305         FREE((void*)this_ptr);
13306         EventsProvider_free(this_ptr_conv);
13307 }
13308
13309 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
13310         if ((this_ptr & 1) != 0) return;
13311         LDKEventHandler this_ptr_conv = *(LDKEventHandler*)(((uint64_t)this_ptr) & ~1);
13312         FREE((void*)this_ptr);
13313         EventHandler_free(this_ptr_conv);
13314 }
13315
13316 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_APIError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
13317         if ((this_ptr & 1) != 0) return;
13318         LDKAPIError this_ptr_conv = *(LDKAPIError*)(((uint64_t)this_ptr) & ~1);
13319         FREE((void*)this_ptr);
13320         APIError_free(this_ptr_conv);
13321 }
13322
13323 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13324         LDKAPIError* orig_conv = (LDKAPIError*)orig;
13325         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
13326         *ret_copy = APIError_clone(orig_conv);
13327         uint64_t ret_ref = (uint64_t)ret_copy;
13328         return ret_ref;
13329 }
13330
13331 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_sign(JNIEnv *env, jclass clz, int8_tArray msg, int8_tArray sk) {
13332         LDKu8slice msg_ref;
13333         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
13334         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
13335         unsigned char sk_arr[32];
13336         CHECK((*env)->GetArrayLength(env, sk) == 32);
13337         (*env)->GetByteArrayRegion(env, sk, 0, 32, sk_arr);
13338         unsigned char (*sk_ref)[32] = &sk_arr;
13339         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
13340         *ret_conv = sign(msg_ref, sk_ref);
13341         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
13342         return (uint64_t)ret_conv;
13343 }
13344
13345 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_recover_1pk(JNIEnv *env, jclass clz, int8_tArray msg, jstring sig) {
13346         LDKu8slice msg_ref;
13347         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
13348         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
13349         LDKStr sig_conv = java_to_owned_str(env, sig);
13350         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
13351         *ret_conv = recover_pk(msg_ref, sig_conv);
13352         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
13353         return (uint64_t)ret_conv;
13354 }
13355
13356 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_verify(JNIEnv *env, jclass clz, int8_tArray msg, jstring sig, int8_tArray pk) {
13357         LDKu8slice msg_ref;
13358         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
13359         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
13360         LDKStr sig_conv = java_to_owned_str(env, sig);
13361         LDKPublicKey pk_ref;
13362         CHECK((*env)->GetArrayLength(env, pk) == 33);
13363         (*env)->GetByteArrayRegion(env, pk, 0, 33, pk_ref.compressed_form);
13364         jboolean ret_val = verify(msg_ref, sig_conv, pk_ref);
13365         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
13366         return ret_val;
13367 }
13368
13369 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13370         LDKLevel* orig_conv = (LDKLevel*)(orig & ~1);
13371         jclass ret_conv = LDKLevel_to_java(env, Level_clone(orig_conv));
13372         return ret_conv;
13373 }
13374
13375 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Level_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
13376         LDKLevel* a_conv = (LDKLevel*)(a & ~1);
13377         LDKLevel* b_conv = (LDKLevel*)(b & ~1);
13378         jboolean ret_val = Level_eq(a_conv, b_conv);
13379         return ret_val;
13380 }
13381
13382 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Level_1hash(JNIEnv *env, jclass clz, int64_t o) {
13383         LDKLevel* o_conv = (LDKLevel*)(o & ~1);
13384         int64_t ret_val = Level_hash(o_conv);
13385         return ret_val;
13386 }
13387
13388 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1max(JNIEnv *env, jclass clz) {
13389         jclass ret_conv = LDKLevel_to_java(env, Level_max());
13390         return ret_conv;
13391 }
13392
13393 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Logger_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
13394         if ((this_ptr & 1) != 0) return;
13395         LDKLogger this_ptr_conv = *(LDKLogger*)(((uint64_t)this_ptr) & ~1);
13396         FREE((void*)this_ptr);
13397         Logger_free(this_ptr_conv);
13398 }
13399
13400 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
13401         LDKChannelHandshakeConfig this_obj_conv;
13402         this_obj_conv.inner = (void*)(this_obj & (~1));
13403         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13404         ChannelHandshakeConfig_free(this_obj_conv);
13405 }
13406
13407 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
13408         LDKChannelHandshakeConfig this_ptr_conv;
13409         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13410         this_ptr_conv.is_owned = false;
13411         int32_t ret_val = ChannelHandshakeConfig_get_minimum_depth(&this_ptr_conv);
13412         return ret_val;
13413 }
13414
13415 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
13416         LDKChannelHandshakeConfig this_ptr_conv;
13417         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13418         this_ptr_conv.is_owned = false;
13419         ChannelHandshakeConfig_set_minimum_depth(&this_ptr_conv, val);
13420 }
13421
13422 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1our_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
13423         LDKChannelHandshakeConfig this_ptr_conv;
13424         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13425         this_ptr_conv.is_owned = false;
13426         int16_t ret_val = ChannelHandshakeConfig_get_our_to_self_delay(&this_ptr_conv);
13427         return ret_val;
13428 }
13429
13430 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) {
13431         LDKChannelHandshakeConfig this_ptr_conv;
13432         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13433         this_ptr_conv.is_owned = false;
13434         ChannelHandshakeConfig_set_our_to_self_delay(&this_ptr_conv, val);
13435 }
13436
13437 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1our_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
13438         LDKChannelHandshakeConfig this_ptr_conv;
13439         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13440         this_ptr_conv.is_owned = false;
13441         int64_t ret_val = ChannelHandshakeConfig_get_our_htlc_minimum_msat(&this_ptr_conv);
13442         return ret_val;
13443 }
13444
13445 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) {
13446         LDKChannelHandshakeConfig this_ptr_conv;
13447         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13448         this_ptr_conv.is_owned = false;
13449         ChannelHandshakeConfig_set_our_htlc_minimum_msat(&this_ptr_conv, val);
13450 }
13451
13452 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) {
13453         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_new(minimum_depth_arg, our_to_self_delay_arg, our_htlc_minimum_msat_arg);
13454         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13455         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13456         uint64_t ret_ref = (uint64_t)ret_var.inner;
13457         if (ret_var.is_owned) {
13458                 ret_ref |= 1;
13459         }
13460         return ret_ref;
13461 }
13462
13463 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13464         LDKChannelHandshakeConfig orig_conv;
13465         orig_conv.inner = (void*)(orig & (~1));
13466         orig_conv.is_owned = false;
13467         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(&orig_conv);
13468         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13469         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13470         uint64_t ret_ref = (uint64_t)ret_var.inner;
13471         if (ret_var.is_owned) {
13472                 ret_ref |= 1;
13473         }
13474         return ret_ref;
13475 }
13476
13477 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1default(JNIEnv *env, jclass clz) {
13478         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_default();
13479         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13480         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13481         uint64_t ret_ref = (uint64_t)ret_var.inner;
13482         if (ret_var.is_owned) {
13483                 ret_ref |= 1;
13484         }
13485         return ret_ref;
13486 }
13487
13488 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
13489         LDKChannelHandshakeLimits this_obj_conv;
13490         this_obj_conv.inner = (void*)(this_obj & (~1));
13491         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13492         ChannelHandshakeLimits_free(this_obj_conv);
13493 }
13494
13495 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
13496         LDKChannelHandshakeLimits this_ptr_conv;
13497         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13498         this_ptr_conv.is_owned = false;
13499         int64_t ret_val = ChannelHandshakeLimits_get_min_funding_satoshis(&this_ptr_conv);
13500         return ret_val;
13501 }
13502
13503 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1min_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
13504         LDKChannelHandshakeLimits this_ptr_conv;
13505         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13506         this_ptr_conv.is_owned = false;
13507         ChannelHandshakeLimits_set_min_funding_satoshis(&this_ptr_conv, val);
13508 }
13509
13510 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
13511         LDKChannelHandshakeLimits this_ptr_conv;
13512         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13513         this_ptr_conv.is_owned = false;
13514         int64_t ret_val = ChannelHandshakeLimits_get_max_htlc_minimum_msat(&this_ptr_conv);
13515         return ret_val;
13516 }
13517
13518 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) {
13519         LDKChannelHandshakeLimits this_ptr_conv;
13520         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13521         this_ptr_conv.is_owned = false;
13522         ChannelHandshakeLimits_set_max_htlc_minimum_msat(&this_ptr_conv, val);
13523 }
13524
13525 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) {
13526         LDKChannelHandshakeLimits this_ptr_conv;
13527         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13528         this_ptr_conv.is_owned = false;
13529         int64_t ret_val = ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(&this_ptr_conv);
13530         return ret_val;
13531 }
13532
13533 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) {
13534         LDKChannelHandshakeLimits this_ptr_conv;
13535         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13536         this_ptr_conv.is_owned = false;
13537         ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
13538 }
13539
13540 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
13541         LDKChannelHandshakeLimits this_ptr_conv;
13542         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13543         this_ptr_conv.is_owned = false;
13544         int64_t ret_val = ChannelHandshakeLimits_get_max_channel_reserve_satoshis(&this_ptr_conv);
13545         return ret_val;
13546 }
13547
13548 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) {
13549         LDKChannelHandshakeLimits this_ptr_conv;
13550         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13551         this_ptr_conv.is_owned = false;
13552         ChannelHandshakeLimits_set_max_channel_reserve_satoshis(&this_ptr_conv, val);
13553 }
13554
13555 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
13556         LDKChannelHandshakeLimits this_ptr_conv;
13557         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13558         this_ptr_conv.is_owned = false;
13559         int16_t ret_val = ChannelHandshakeLimits_get_min_max_accepted_htlcs(&this_ptr_conv);
13560         return ret_val;
13561 }
13562
13563 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) {
13564         LDKChannelHandshakeLimits this_ptr_conv;
13565         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13566         this_ptr_conv.is_owned = false;
13567         ChannelHandshakeLimits_set_min_max_accepted_htlcs(&this_ptr_conv, val);
13568 }
13569
13570 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
13571         LDKChannelHandshakeLimits this_ptr_conv;
13572         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13573         this_ptr_conv.is_owned = false;
13574         int32_t ret_val = ChannelHandshakeLimits_get_max_minimum_depth(&this_ptr_conv);
13575         return ret_val;
13576 }
13577
13578 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1max_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
13579         LDKChannelHandshakeLimits this_ptr_conv;
13580         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13581         this_ptr_conv.is_owned = false;
13582         ChannelHandshakeLimits_set_max_minimum_depth(&this_ptr_conv, val);
13583 }
13584
13585 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1force_1announced_1channel_1preference(JNIEnv *env, jclass clz, int64_t this_ptr) {
13586         LDKChannelHandshakeLimits this_ptr_conv;
13587         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13588         this_ptr_conv.is_owned = false;
13589         jboolean ret_val = ChannelHandshakeLimits_get_force_announced_channel_preference(&this_ptr_conv);
13590         return ret_val;
13591 }
13592
13593 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1force_1announced_1channel_1preference(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
13594         LDKChannelHandshakeLimits this_ptr_conv;
13595         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13596         this_ptr_conv.is_owned = false;
13597         ChannelHandshakeLimits_set_force_announced_channel_preference(&this_ptr_conv, val);
13598 }
13599
13600 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1their_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
13601         LDKChannelHandshakeLimits this_ptr_conv;
13602         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13603         this_ptr_conv.is_owned = false;
13604         int16_t ret_val = ChannelHandshakeLimits_get_their_to_self_delay(&this_ptr_conv);
13605         return ret_val;
13606 }
13607
13608 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) {
13609         LDKChannelHandshakeLimits this_ptr_conv;
13610         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13611         this_ptr_conv.is_owned = false;
13612         ChannelHandshakeLimits_set_their_to_self_delay(&this_ptr_conv, val);
13613 }
13614
13615 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) {
13616         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);
13617         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13618         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13619         uint64_t ret_ref = (uint64_t)ret_var.inner;
13620         if (ret_var.is_owned) {
13621                 ret_ref |= 1;
13622         }
13623         return ret_ref;
13624 }
13625
13626 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13627         LDKChannelHandshakeLimits orig_conv;
13628         orig_conv.inner = (void*)(orig & (~1));
13629         orig_conv.is_owned = false;
13630         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(&orig_conv);
13631         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13632         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13633         uint64_t ret_ref = (uint64_t)ret_var.inner;
13634         if (ret_var.is_owned) {
13635                 ret_ref |= 1;
13636         }
13637         return ret_ref;
13638 }
13639
13640 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1default(JNIEnv *env, jclass clz) {
13641         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_default();
13642         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13643         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13644         uint64_t ret_ref = (uint64_t)ret_var.inner;
13645         if (ret_var.is_owned) {
13646                 ret_ref |= 1;
13647         }
13648         return ret_ref;
13649 }
13650
13651 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
13652         LDKChannelConfig this_obj_conv;
13653         this_obj_conv.inner = (void*)(this_obj & (~1));
13654         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13655         ChannelConfig_free(this_obj_conv);
13656 }
13657
13658 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1forwarding_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
13659         LDKChannelConfig this_ptr_conv;
13660         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13661         this_ptr_conv.is_owned = false;
13662         int32_t ret_val = ChannelConfig_get_forwarding_fee_proportional_millionths(&this_ptr_conv);
13663         return ret_val;
13664 }
13665
13666 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) {
13667         LDKChannelConfig this_ptr_conv;
13668         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13669         this_ptr_conv.is_owned = false;
13670         ChannelConfig_set_forwarding_fee_proportional_millionths(&this_ptr_conv, val);
13671 }
13672
13673 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1forwarding_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
13674         LDKChannelConfig this_ptr_conv;
13675         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13676         this_ptr_conv.is_owned = false;
13677         int32_t ret_val = ChannelConfig_get_forwarding_fee_base_msat(&this_ptr_conv);
13678         return ret_val;
13679 }
13680
13681 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) {
13682         LDKChannelConfig this_ptr_conv;
13683         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13684         this_ptr_conv.is_owned = false;
13685         ChannelConfig_set_forwarding_fee_base_msat(&this_ptr_conv, val);
13686 }
13687
13688 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
13689         LDKChannelConfig this_ptr_conv;
13690         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13691         this_ptr_conv.is_owned = false;
13692         int16_t ret_val = ChannelConfig_get_cltv_expiry_delta(&this_ptr_conv);
13693         return ret_val;
13694 }
13695
13696 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
13697         LDKChannelConfig this_ptr_conv;
13698         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13699         this_ptr_conv.is_owned = false;
13700         ChannelConfig_set_cltv_expiry_delta(&this_ptr_conv, val);
13701 }
13702
13703 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1announced_1channel(JNIEnv *env, jclass clz, int64_t this_ptr) {
13704         LDKChannelConfig this_ptr_conv;
13705         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13706         this_ptr_conv.is_owned = false;
13707         jboolean ret_val = ChannelConfig_get_announced_channel(&this_ptr_conv);
13708         return ret_val;
13709 }
13710
13711 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1announced_1channel(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
13712         LDKChannelConfig this_ptr_conv;
13713         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13714         this_ptr_conv.is_owned = false;
13715         ChannelConfig_set_announced_channel(&this_ptr_conv, val);
13716 }
13717
13718 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1commit_1upfront_1shutdown_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
13719         LDKChannelConfig this_ptr_conv;
13720         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13721         this_ptr_conv.is_owned = false;
13722         jboolean ret_val = ChannelConfig_get_commit_upfront_shutdown_pubkey(&this_ptr_conv);
13723         return ret_val;
13724 }
13725
13726 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1commit_1upfront_1shutdown_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
13727         LDKChannelConfig this_ptr_conv;
13728         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13729         this_ptr_conv.is_owned = false;
13730         ChannelConfig_set_commit_upfront_shutdown_pubkey(&this_ptr_conv, val);
13731 }
13732
13733 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) {
13734         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);
13735         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13736         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13737         uint64_t ret_ref = (uint64_t)ret_var.inner;
13738         if (ret_var.is_owned) {
13739                 ret_ref |= 1;
13740         }
13741         return ret_ref;
13742 }
13743
13744 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13745         LDKChannelConfig orig_conv;
13746         orig_conv.inner = (void*)(orig & (~1));
13747         orig_conv.is_owned = false;
13748         LDKChannelConfig ret_var = ChannelConfig_clone(&orig_conv);
13749         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13750         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13751         uint64_t ret_ref = (uint64_t)ret_var.inner;
13752         if (ret_var.is_owned) {
13753                 ret_ref |= 1;
13754         }
13755         return ret_ref;
13756 }
13757
13758 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1default(JNIEnv *env, jclass clz) {
13759         LDKChannelConfig ret_var = ChannelConfig_default();
13760         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13761         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13762         uint64_t ret_ref = (uint64_t)ret_var.inner;
13763         if (ret_var.is_owned) {
13764                 ret_ref |= 1;
13765         }
13766         return ret_ref;
13767 }
13768
13769 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1write(JNIEnv *env, jclass clz, int64_t obj) {
13770         LDKChannelConfig obj_conv;
13771         obj_conv.inner = (void*)(obj & (~1));
13772         obj_conv.is_owned = false;
13773         LDKCVec_u8Z ret_var = ChannelConfig_write(&obj_conv);
13774         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
13775         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
13776         CVec_u8Z_free(ret_var);
13777         return ret_arr;
13778 }
13779
13780 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
13781         LDKu8slice ser_ref;
13782         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
13783         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
13784         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
13785         *ret_conv = ChannelConfig_read(ser_ref);
13786         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
13787         return (uint64_t)ret_conv;
13788 }
13789
13790 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
13791         LDKUserConfig this_obj_conv;
13792         this_obj_conv.inner = (void*)(this_obj & (~1));
13793         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13794         UserConfig_free(this_obj_conv);
13795 }
13796
13797 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1own_1channel_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
13798         LDKUserConfig this_ptr_conv;
13799         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13800         this_ptr_conv.is_owned = false;
13801         LDKChannelHandshakeConfig ret_var = UserConfig_get_own_channel_config(&this_ptr_conv);
13802         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13803         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13804         uint64_t ret_ref = (uint64_t)ret_var.inner;
13805         if (ret_var.is_owned) {
13806                 ret_ref |= 1;
13807         }
13808         return ret_ref;
13809 }
13810
13811 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1own_1channel_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
13812         LDKUserConfig this_ptr_conv;
13813         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13814         this_ptr_conv.is_owned = false;
13815         LDKChannelHandshakeConfig val_conv;
13816         val_conv.inner = (void*)(val & (~1));
13817         val_conv.is_owned = (val & 1) || (val == 0);
13818         val_conv = ChannelHandshakeConfig_clone(&val_conv);
13819         UserConfig_set_own_channel_config(&this_ptr_conv, val_conv);
13820 }
13821
13822 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1peer_1channel_1config_1limits(JNIEnv *env, jclass clz, int64_t this_ptr) {
13823         LDKUserConfig this_ptr_conv;
13824         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13825         this_ptr_conv.is_owned = false;
13826         LDKChannelHandshakeLimits ret_var = UserConfig_get_peer_channel_config_limits(&this_ptr_conv);
13827         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13828         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13829         uint64_t ret_ref = (uint64_t)ret_var.inner;
13830         if (ret_var.is_owned) {
13831                 ret_ref |= 1;
13832         }
13833         return ret_ref;
13834 }
13835
13836 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) {
13837         LDKUserConfig this_ptr_conv;
13838         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13839         this_ptr_conv.is_owned = false;
13840         LDKChannelHandshakeLimits val_conv;
13841         val_conv.inner = (void*)(val & (~1));
13842         val_conv.is_owned = (val & 1) || (val == 0);
13843         val_conv = ChannelHandshakeLimits_clone(&val_conv);
13844         UserConfig_set_peer_channel_config_limits(&this_ptr_conv, val_conv);
13845 }
13846
13847 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1channel_1options(JNIEnv *env, jclass clz, int64_t this_ptr) {
13848         LDKUserConfig this_ptr_conv;
13849         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13850         this_ptr_conv.is_owned = false;
13851         LDKChannelConfig ret_var = UserConfig_get_channel_options(&this_ptr_conv);
13852         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13853         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13854         uint64_t ret_ref = (uint64_t)ret_var.inner;
13855         if (ret_var.is_owned) {
13856                 ret_ref |= 1;
13857         }
13858         return ret_ref;
13859 }
13860
13861 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1channel_1options(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
13862         LDKUserConfig this_ptr_conv;
13863         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13864         this_ptr_conv.is_owned = false;
13865         LDKChannelConfig val_conv;
13866         val_conv.inner = (void*)(val & (~1));
13867         val_conv.is_owned = (val & 1) || (val == 0);
13868         val_conv = ChannelConfig_clone(&val_conv);
13869         UserConfig_set_channel_options(&this_ptr_conv, val_conv);
13870 }
13871
13872 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1accept_1forwards_1to_1priv_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
13873         LDKUserConfig this_ptr_conv;
13874         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13875         this_ptr_conv.is_owned = false;
13876         jboolean ret_val = UserConfig_get_accept_forwards_to_priv_channels(&this_ptr_conv);
13877         return ret_val;
13878 }
13879
13880 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) {
13881         LDKUserConfig this_ptr_conv;
13882         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13883         this_ptr_conv.is_owned = false;
13884         UserConfig_set_accept_forwards_to_priv_channels(&this_ptr_conv, val);
13885 }
13886
13887 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) {
13888         LDKChannelHandshakeConfig own_channel_config_arg_conv;
13889         own_channel_config_arg_conv.inner = (void*)(own_channel_config_arg & (~1));
13890         own_channel_config_arg_conv.is_owned = (own_channel_config_arg & 1) || (own_channel_config_arg == 0);
13891         own_channel_config_arg_conv = ChannelHandshakeConfig_clone(&own_channel_config_arg_conv);
13892         LDKChannelHandshakeLimits peer_channel_config_limits_arg_conv;
13893         peer_channel_config_limits_arg_conv.inner = (void*)(peer_channel_config_limits_arg & (~1));
13894         peer_channel_config_limits_arg_conv.is_owned = (peer_channel_config_limits_arg & 1) || (peer_channel_config_limits_arg == 0);
13895         peer_channel_config_limits_arg_conv = ChannelHandshakeLimits_clone(&peer_channel_config_limits_arg_conv);
13896         LDKChannelConfig channel_options_arg_conv;
13897         channel_options_arg_conv.inner = (void*)(channel_options_arg & (~1));
13898         channel_options_arg_conv.is_owned = (channel_options_arg & 1) || (channel_options_arg == 0);
13899         channel_options_arg_conv = ChannelConfig_clone(&channel_options_arg_conv);
13900         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);
13901         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13902         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13903         uint64_t ret_ref = (uint64_t)ret_var.inner;
13904         if (ret_var.is_owned) {
13905                 ret_ref |= 1;
13906         }
13907         return ret_ref;
13908 }
13909
13910 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13911         LDKUserConfig orig_conv;
13912         orig_conv.inner = (void*)(orig & (~1));
13913         orig_conv.is_owned = false;
13914         LDKUserConfig ret_var = UserConfig_clone(&orig_conv);
13915         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13916         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13917         uint64_t ret_ref = (uint64_t)ret_var.inner;
13918         if (ret_var.is_owned) {
13919                 ret_ref |= 1;
13920         }
13921         return ret_ref;
13922 }
13923
13924 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1default(JNIEnv *env, jclass clz) {
13925         LDKUserConfig ret_var = UserConfig_default();
13926         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13927         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13928         uint64_t ret_ref = (uint64_t)ret_var.inner;
13929         if (ret_var.is_owned) {
13930                 ret_ref |= 1;
13931         }
13932         return ret_ref;
13933 }
13934
13935 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BestBlock_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
13936         LDKBestBlock this_obj_conv;
13937         this_obj_conv.inner = (void*)(this_obj & (~1));
13938         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13939         BestBlock_free(this_obj_conv);
13940 }
13941
13942 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13943         LDKBestBlock orig_conv;
13944         orig_conv.inner = (void*)(orig & (~1));
13945         orig_conv.is_owned = false;
13946         LDKBestBlock ret_var = BestBlock_clone(&orig_conv);
13947         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13948         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13949         uint64_t ret_ref = (uint64_t)ret_var.inner;
13950         if (ret_var.is_owned) {
13951                 ret_ref |= 1;
13952         }
13953         return ret_ref;
13954 }
13955
13956 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1from_1genesis(JNIEnv *env, jclass clz, jclass network) {
13957         LDKNetwork network_conv = LDKNetwork_from_java(env, network);
13958         LDKBestBlock ret_var = BestBlock_from_genesis(network_conv);
13959         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13960         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13961         uint64_t ret_ref = (uint64_t)ret_var.inner;
13962         if (ret_var.is_owned) {
13963                 ret_ref |= 1;
13964         }
13965         return ret_ref;
13966 }
13967
13968 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1new(JNIEnv *env, jclass clz, int8_tArray block_hash, int32_t height) {
13969         LDKThirtyTwoBytes block_hash_ref;
13970         CHECK((*env)->GetArrayLength(env, block_hash) == 32);
13971         (*env)->GetByteArrayRegion(env, block_hash, 0, 32, block_hash_ref.data);
13972         LDKBestBlock ret_var = BestBlock_new(block_hash_ref, height);
13973         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13974         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13975         uint64_t ret_ref = (uint64_t)ret_var.inner;
13976         if (ret_var.is_owned) {
13977                 ret_ref |= 1;
13978         }
13979         return ret_ref;
13980 }
13981
13982 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BestBlock_1block_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
13983         LDKBestBlock this_arg_conv;
13984         this_arg_conv.inner = (void*)(this_arg & (~1));
13985         this_arg_conv.is_owned = false;
13986         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
13987         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, BestBlock_block_hash(&this_arg_conv).data);
13988         return ret_arr;
13989 }
13990
13991 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1height(JNIEnv *env, jclass clz, int64_t this_arg) {
13992         LDKBestBlock this_arg_conv;
13993         this_arg_conv.inner = (void*)(this_arg & (~1));
13994         this_arg_conv.is_owned = false;
13995         int32_t ret_val = BestBlock_height(&this_arg_conv);
13996         return ret_val;
13997 }
13998
13999 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_AccessError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14000         LDKAccessError* orig_conv = (LDKAccessError*)(orig & ~1);
14001         jclass ret_conv = LDKAccessError_to_java(env, AccessError_clone(orig_conv));
14002         return ret_conv;
14003 }
14004
14005 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Access_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
14006         if ((this_ptr & 1) != 0) return;
14007         LDKAccess this_ptr_conv = *(LDKAccess*)(((uint64_t)this_ptr) & ~1);
14008         FREE((void*)this_ptr);
14009         Access_free(this_ptr_conv);
14010 }
14011
14012 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Listen_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
14013         if ((this_ptr & 1) != 0) return;
14014         LDKListen this_ptr_conv = *(LDKListen*)(((uint64_t)this_ptr) & ~1);
14015         FREE((void*)this_ptr);
14016         Listen_free(this_ptr_conv);
14017 }
14018
14019 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Confirm_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
14020         if ((this_ptr & 1) != 0) return;
14021         LDKConfirm this_ptr_conv = *(LDKConfirm*)(((uint64_t)this_ptr) & ~1);
14022         FREE((void*)this_ptr);
14023         Confirm_free(this_ptr_conv);
14024 }
14025
14026 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Watch_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
14027         if ((this_ptr & 1) != 0) return;
14028         LDKWatch this_ptr_conv = *(LDKWatch*)(((uint64_t)this_ptr) & ~1);
14029         FREE((void*)this_ptr);
14030         Watch_free(this_ptr_conv);
14031 }
14032
14033 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Filter_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
14034         if ((this_ptr & 1) != 0) return;
14035         LDKFilter this_ptr_conv = *(LDKFilter*)(((uint64_t)this_ptr) & ~1);
14036         FREE((void*)this_ptr);
14037         Filter_free(this_ptr_conv);
14038 }
14039
14040 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14041         LDKWatchedOutput this_obj_conv;
14042         this_obj_conv.inner = (void*)(this_obj & (~1));
14043         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14044         WatchedOutput_free(this_obj_conv);
14045 }
14046
14047 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1block_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
14048         LDKWatchedOutput this_ptr_conv;
14049         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14050         this_ptr_conv.is_owned = false;
14051         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14052         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, WatchedOutput_get_block_hash(&this_ptr_conv).data);
14053         return ret_arr;
14054 }
14055
14056 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1block_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14057         LDKWatchedOutput this_ptr_conv;
14058         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14059         this_ptr_conv.is_owned = false;
14060         LDKThirtyTwoBytes val_ref;
14061         CHECK((*env)->GetArrayLength(env, val) == 32);
14062         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
14063         WatchedOutput_set_block_hash(&this_ptr_conv, val_ref);
14064 }
14065
14066 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
14067         LDKWatchedOutput this_ptr_conv;
14068         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14069         this_ptr_conv.is_owned = false;
14070         LDKOutPoint ret_var = WatchedOutput_get_outpoint(&this_ptr_conv);
14071         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14072         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14073         uint64_t ret_ref = (uint64_t)ret_var.inner;
14074         if (ret_var.is_owned) {
14075                 ret_ref |= 1;
14076         }
14077         return ret_ref;
14078 }
14079
14080 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
14081         LDKWatchedOutput this_ptr_conv;
14082         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14083         this_ptr_conv.is_owned = false;
14084         LDKOutPoint val_conv;
14085         val_conv.inner = (void*)(val & (~1));
14086         val_conv.is_owned = (val & 1) || (val == 0);
14087         val_conv = OutPoint_clone(&val_conv);
14088         WatchedOutput_set_outpoint(&this_ptr_conv, val_conv);
14089 }
14090
14091 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1script_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
14092         LDKWatchedOutput this_ptr_conv;
14093         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14094         this_ptr_conv.is_owned = false;
14095         LDKu8slice ret_var = WatchedOutput_get_script_pubkey(&this_ptr_conv);
14096         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
14097         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
14098         return ret_arr;
14099 }
14100
14101 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1script_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14102         LDKWatchedOutput this_ptr_conv;
14103         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14104         this_ptr_conv.is_owned = false;
14105         LDKCVec_u8Z val_ref;
14106         val_ref.datalen = (*env)->GetArrayLength(env, val);
14107         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
14108         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
14109         WatchedOutput_set_script_pubkey(&this_ptr_conv, val_ref);
14110 }
14111
14112 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) {
14113         LDKThirtyTwoBytes block_hash_arg_ref;
14114         CHECK((*env)->GetArrayLength(env, block_hash_arg) == 32);
14115         (*env)->GetByteArrayRegion(env, block_hash_arg, 0, 32, block_hash_arg_ref.data);
14116         LDKOutPoint outpoint_arg_conv;
14117         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
14118         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
14119         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
14120         LDKCVec_u8Z script_pubkey_arg_ref;
14121         script_pubkey_arg_ref.datalen = (*env)->GetArrayLength(env, script_pubkey_arg);
14122         script_pubkey_arg_ref.data = MALLOC(script_pubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
14123         (*env)->GetByteArrayRegion(env, script_pubkey_arg, 0, script_pubkey_arg_ref.datalen, script_pubkey_arg_ref.data);
14124         LDKWatchedOutput ret_var = WatchedOutput_new(block_hash_arg_ref, outpoint_arg_conv, script_pubkey_arg_ref);
14125         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14126         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14127         uint64_t ret_ref = (uint64_t)ret_var.inner;
14128         if (ret_var.is_owned) {
14129                 ret_ref |= 1;
14130         }
14131         return ret_ref;
14132 }
14133
14134 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14135         LDKWatchedOutput orig_conv;
14136         orig_conv.inner = (void*)(orig & (~1));
14137         orig_conv.is_owned = false;
14138         LDKWatchedOutput ret_var = WatchedOutput_clone(&orig_conv);
14139         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14140         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14141         uint64_t ret_ref = (uint64_t)ret_var.inner;
14142         if (ret_var.is_owned) {
14143                 ret_ref |= 1;
14144         }
14145         return ret_ref;
14146 }
14147
14148 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1hash(JNIEnv *env, jclass clz, int64_t o) {
14149         LDKWatchedOutput o_conv;
14150         o_conv.inner = (void*)(o & (~1));
14151         o_conv.is_owned = false;
14152         int64_t ret_val = WatchedOutput_hash(&o_conv);
14153         return ret_val;
14154 }
14155
14156 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BroadcasterInterface_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
14157         if ((this_ptr & 1) != 0) return;
14158         LDKBroadcasterInterface this_ptr_conv = *(LDKBroadcasterInterface*)(((uint64_t)this_ptr) & ~1);
14159         FREE((void*)this_ptr);
14160         BroadcasterInterface_free(this_ptr_conv);
14161 }
14162
14163 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14164         LDKConfirmationTarget* orig_conv = (LDKConfirmationTarget*)(orig & ~1);
14165         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_clone(orig_conv));
14166         return ret_conv;
14167 }
14168
14169 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FeeEstimator_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
14170         if ((this_ptr & 1) != 0) return;
14171         LDKFeeEstimator this_ptr_conv = *(LDKFeeEstimator*)(((uint64_t)this_ptr) & ~1);
14172         FREE((void*)this_ptr);
14173         FeeEstimator_free(this_ptr_conv);
14174 }
14175
14176 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14177         LDKChainMonitor this_obj_conv;
14178         this_obj_conv.inner = (void*)(this_obj & (~1));
14179         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14180         ChainMonitor_free(this_obj_conv);
14181 }
14182
14183 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) {
14184         LDKFilter *chain_source_conv_ptr = NULL;
14185         if (chain_source != 0) {
14186                 LDKFilter chain_source_conv;
14187                 chain_source_conv = *(LDKFilter*)(((uint64_t)chain_source) & ~1);
14188                 if (chain_source_conv.free == LDKFilter_JCalls_free) {
14189                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14190                         LDKFilter_JCalls_clone(chain_source_conv.this_arg);
14191                 }
14192                 chain_source_conv_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter");
14193                 *chain_source_conv_ptr = chain_source_conv;
14194         }
14195         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
14196         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
14197                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14198                 LDKBroadcasterInterface_JCalls_clone(broadcaster_conv.this_arg);
14199         }
14200         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
14201         if (logger_conv.free == LDKLogger_JCalls_free) {
14202                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14203                 LDKLogger_JCalls_clone(logger_conv.this_arg);
14204         }
14205         LDKFeeEstimator feeest_conv = *(LDKFeeEstimator*)(((uint64_t)feeest) & ~1);
14206         if (feeest_conv.free == LDKFeeEstimator_JCalls_free) {
14207                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14208                 LDKFeeEstimator_JCalls_clone(feeest_conv.this_arg);
14209         }
14210         LDKPersist persister_conv = *(LDKPersist*)(((uint64_t)persister) & ~1);
14211         if (persister_conv.free == LDKPersist_JCalls_free) {
14212                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14213                 LDKPersist_JCalls_clone(persister_conv.this_arg);
14214         }
14215         LDKChainMonitor ret_var = ChainMonitor_new(chain_source_conv_ptr, broadcaster_conv, logger_conv, feeest_conv, persister_conv);
14216         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14217         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14218         uint64_t ret_ref = (uint64_t)ret_var.inner;
14219         if (ret_var.is_owned) {
14220                 ret_ref |= 1;
14221         }
14222         return ret_ref;
14223 }
14224
14225 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Listen(JNIEnv *env, jclass clz, int64_t this_arg) {
14226         LDKChainMonitor this_arg_conv;
14227         this_arg_conv.inner = (void*)(this_arg & (~1));
14228         this_arg_conv.is_owned = false;
14229         LDKListen* ret = MALLOC(sizeof(LDKListen), "LDKListen");
14230         *ret = ChainMonitor_as_Listen(&this_arg_conv);
14231         return (uint64_t)ret;
14232 }
14233
14234 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Confirm(JNIEnv *env, jclass clz, int64_t this_arg) {
14235         LDKChainMonitor this_arg_conv;
14236         this_arg_conv.inner = (void*)(this_arg & (~1));
14237         this_arg_conv.is_owned = false;
14238         LDKConfirm* ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
14239         *ret = ChainMonitor_as_Confirm(&this_arg_conv);
14240         return (uint64_t)ret;
14241 }
14242
14243 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Watch(JNIEnv *env, jclass clz, int64_t this_arg) {
14244         LDKChainMonitor this_arg_conv;
14245         this_arg_conv.inner = (void*)(this_arg & (~1));
14246         this_arg_conv.is_owned = false;
14247         LDKWatch* ret = MALLOC(sizeof(LDKWatch), "LDKWatch");
14248         *ret = ChainMonitor_as_Watch(&this_arg_conv);
14249         return (uint64_t)ret;
14250 }
14251
14252 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1EventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
14253         LDKChainMonitor this_arg_conv;
14254         this_arg_conv.inner = (void*)(this_arg & (~1));
14255         this_arg_conv.is_owned = false;
14256         LDKEventsProvider* ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
14257         *ret = ChainMonitor_as_EventsProvider(&this_arg_conv);
14258         return (uint64_t)ret;
14259 }
14260
14261 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14262         LDKChannelMonitorUpdate this_obj_conv;
14263         this_obj_conv.inner = (void*)(this_obj & (~1));
14264         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14265         ChannelMonitorUpdate_free(this_obj_conv);
14266 }
14267
14268 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1get_1update_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
14269         LDKChannelMonitorUpdate this_ptr_conv;
14270         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14271         this_ptr_conv.is_owned = false;
14272         int64_t ret_val = ChannelMonitorUpdate_get_update_id(&this_ptr_conv);
14273         return ret_val;
14274 }
14275
14276 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1set_1update_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
14277         LDKChannelMonitorUpdate this_ptr_conv;
14278         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14279         this_ptr_conv.is_owned = false;
14280         ChannelMonitorUpdate_set_update_id(&this_ptr_conv, val);
14281 }
14282
14283 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14284         LDKChannelMonitorUpdate orig_conv;
14285         orig_conv.inner = (void*)(orig & (~1));
14286         orig_conv.is_owned = false;
14287         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(&orig_conv);
14288         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14289         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14290         uint64_t ret_ref = (uint64_t)ret_var.inner;
14291         if (ret_var.is_owned) {
14292                 ret_ref |= 1;
14293         }
14294         return ret_ref;
14295 }
14296
14297 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
14298         LDKChannelMonitorUpdate obj_conv;
14299         obj_conv.inner = (void*)(obj & (~1));
14300         obj_conv.is_owned = false;
14301         LDKCVec_u8Z ret_var = ChannelMonitorUpdate_write(&obj_conv);
14302         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
14303         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
14304         CVec_u8Z_free(ret_var);
14305         return ret_arr;
14306 }
14307
14308 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
14309         LDKu8slice ser_ref;
14310         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
14311         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
14312         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
14313         *ret_conv = ChannelMonitorUpdate_read(ser_ref);
14314         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
14315         return (uint64_t)ret_conv;
14316 }
14317
14318 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateErr_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14319         LDKChannelMonitorUpdateErr* orig_conv = (LDKChannelMonitorUpdateErr*)(orig & ~1);
14320         jclass ret_conv = LDKChannelMonitorUpdateErr_to_java(env, ChannelMonitorUpdateErr_clone(orig_conv));
14321         return ret_conv;
14322 }
14323
14324 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorUpdateError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14325         LDKMonitorUpdateError this_obj_conv;
14326         this_obj_conv.inner = (void*)(this_obj & (~1));
14327         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14328         MonitorUpdateError_free(this_obj_conv);
14329 }
14330
14331 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorUpdateError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14332         LDKMonitorUpdateError orig_conv;
14333         orig_conv.inner = (void*)(orig & (~1));
14334         orig_conv.is_owned = false;
14335         LDKMonitorUpdateError ret_var = MonitorUpdateError_clone(&orig_conv);
14336         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14337         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14338         uint64_t ret_ref = (uint64_t)ret_var.inner;
14339         if (ret_var.is_owned) {
14340                 ret_ref |= 1;
14341         }
14342         return ret_ref;
14343 }
14344
14345 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
14346         if ((this_ptr & 1) != 0) return;
14347         LDKMonitorEvent this_ptr_conv = *(LDKMonitorEvent*)(((uint64_t)this_ptr) & ~1);
14348         FREE((void*)this_ptr);
14349         MonitorEvent_free(this_ptr_conv);
14350 }
14351
14352 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14353         LDKMonitorEvent* orig_conv = (LDKMonitorEvent*)orig;
14354         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
14355         *ret_copy = MonitorEvent_clone(orig_conv);
14356         uint64_t ret_ref = (uint64_t)ret_copy;
14357         return ret_ref;
14358 }
14359
14360 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14361         LDKHTLCUpdate this_obj_conv;
14362         this_obj_conv.inner = (void*)(this_obj & (~1));
14363         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14364         HTLCUpdate_free(this_obj_conv);
14365 }
14366
14367 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14368         LDKHTLCUpdate orig_conv;
14369         orig_conv.inner = (void*)(orig & (~1));
14370         orig_conv.is_owned = false;
14371         LDKHTLCUpdate ret_var = HTLCUpdate_clone(&orig_conv);
14372         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14373         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14374         uint64_t ret_ref = (uint64_t)ret_var.inner;
14375         if (ret_var.is_owned) {
14376                 ret_ref |= 1;
14377         }
14378         return ret_ref;
14379 }
14380
14381 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
14382         LDKHTLCUpdate obj_conv;
14383         obj_conv.inner = (void*)(obj & (~1));
14384         obj_conv.is_owned = false;
14385         LDKCVec_u8Z ret_var = HTLCUpdate_write(&obj_conv);
14386         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
14387         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
14388         CVec_u8Z_free(ret_var);
14389         return ret_arr;
14390 }
14391
14392 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
14393         LDKu8slice ser_ref;
14394         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
14395         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
14396         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
14397         *ret_conv = HTLCUpdate_read(ser_ref);
14398         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
14399         return (uint64_t)ret_conv;
14400 }
14401
14402 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14403         LDKChannelMonitor this_obj_conv;
14404         this_obj_conv.inner = (void*)(this_obj & (~1));
14405         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14406         ChannelMonitor_free(this_obj_conv);
14407 }
14408
14409 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14410         LDKChannelMonitor orig_conv;
14411         orig_conv.inner = (void*)(orig & (~1));
14412         orig_conv.is_owned = false;
14413         LDKChannelMonitor ret_var = ChannelMonitor_clone(&orig_conv);
14414         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14415         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14416         uint64_t ret_ref = (uint64_t)ret_var.inner;
14417         if (ret_var.is_owned) {
14418                 ret_ref |= 1;
14419         }
14420         return ret_ref;
14421 }
14422
14423 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1write(JNIEnv *env, jclass clz, int64_t obj) {
14424         LDKChannelMonitor obj_conv;
14425         obj_conv.inner = (void*)(obj & (~1));
14426         obj_conv.is_owned = false;
14427         LDKCVec_u8Z ret_var = ChannelMonitor_write(&obj_conv);
14428         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
14429         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
14430         CVec_u8Z_free(ret_var);
14431         return ret_arr;
14432 }
14433
14434 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) {
14435         LDKChannelMonitor this_arg_conv;
14436         this_arg_conv.inner = (void*)(this_arg & (~1));
14437         this_arg_conv.is_owned = false;
14438         LDKChannelMonitorUpdate updates_conv;
14439         updates_conv.inner = (void*)(updates & (~1));
14440         updates_conv.is_owned = false;
14441         LDKBroadcasterInterface* broadcaster_conv = (LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
14442         LDKFeeEstimator* fee_estimator_conv = (LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
14443         LDKLogger* logger_conv = (LDKLogger*)(((uint64_t)logger) & ~1);
14444         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
14445         *ret_conv = ChannelMonitor_update_monitor(&this_arg_conv, &updates_conv, broadcaster_conv, fee_estimator_conv, logger_conv);
14446         return (uint64_t)ret_conv;
14447 }
14448
14449 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1latest_1update_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
14450         LDKChannelMonitor this_arg_conv;
14451         this_arg_conv.inner = (void*)(this_arg & (~1));
14452         this_arg_conv.is_owned = false;
14453         int64_t ret_val = ChannelMonitor_get_latest_update_id(&this_arg_conv);
14454         return ret_val;
14455 }
14456
14457 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_arg) {
14458         LDKChannelMonitor this_arg_conv;
14459         this_arg_conv.inner = (void*)(this_arg & (~1));
14460         this_arg_conv.is_owned = false;
14461         LDKC2Tuple_OutPointScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
14462         *ret_ref = ChannelMonitor_get_funding_txo(&this_arg_conv);
14463         return (uint64_t)ret_ref;
14464 }
14465
14466 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1outputs_1to_1watch(JNIEnv *env, jclass clz, int64_t this_arg) {
14467         LDKChannelMonitor this_arg_conv;
14468         this_arg_conv.inner = (void*)(this_arg & (~1));
14469         this_arg_conv.is_owned = false;
14470         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ ret_var = ChannelMonitor_get_outputs_to_watch(&this_arg_conv);
14471         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
14472         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
14473         for (size_t v = 0; v < ret_var.datalen; v++) {
14474                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv_47_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
14475                 *ret_conv_47_ref = ret_var.data[v];
14476                 ret_arr_ptr[v] = (uint64_t)ret_conv_47_ref;
14477         }
14478         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
14479         FREE(ret_var.data);
14480         return ret_arr;
14481 }
14482
14483 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1load_1outputs_1to_1watch(JNIEnv *env, jclass clz, int64_t this_arg, int64_t filter) {
14484         LDKChannelMonitor this_arg_conv;
14485         this_arg_conv.inner = (void*)(this_arg & (~1));
14486         this_arg_conv.is_owned = false;
14487         LDKFilter* filter_conv = (LDKFilter*)(((uint64_t)filter) & ~1);
14488         ChannelMonitor_load_outputs_to_watch(&this_arg_conv, filter_conv);
14489 }
14490
14491 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1and_1clear_1pending_1monitor_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
14492         LDKChannelMonitor this_arg_conv;
14493         this_arg_conv.inner = (void*)(this_arg & (~1));
14494         this_arg_conv.is_owned = false;
14495         LDKCVec_MonitorEventZ ret_var = ChannelMonitor_get_and_clear_pending_monitor_events(&this_arg_conv);
14496         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
14497         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
14498         for (size_t o = 0; o < ret_var.datalen; o++) {
14499                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
14500                 *ret_conv_14_copy = MonitorEvent_clone(&ret_var.data[o]);
14501                 uint64_t ret_conv_14_ref = (uint64_t)ret_conv_14_copy;
14502                 ret_arr_ptr[o] = ret_conv_14_ref;
14503         }
14504         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
14505         FREE(ret_var.data);
14506         return ret_arr;
14507 }
14508
14509 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1and_1clear_1pending_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
14510         LDKChannelMonitor this_arg_conv;
14511         this_arg_conv.inner = (void*)(this_arg & (~1));
14512         this_arg_conv.is_owned = false;
14513         LDKCVec_EventZ ret_var = ChannelMonitor_get_and_clear_pending_events(&this_arg_conv);
14514         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
14515         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
14516         for (size_t h = 0; h < ret_var.datalen; h++) {
14517                 LDKEvent *ret_conv_7_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
14518                 *ret_conv_7_copy = Event_clone(&ret_var.data[h]);
14519                 uint64_t ret_conv_7_ref = (uint64_t)ret_conv_7_copy;
14520                 ret_arr_ptr[h] = ret_conv_7_ref;
14521         }
14522         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
14523         FREE(ret_var.data);
14524         return ret_arr;
14525 }
14526
14527 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) {
14528         LDKChannelMonitor this_arg_conv;
14529         this_arg_conv.inner = (void*)(this_arg & (~1));
14530         this_arg_conv.is_owned = false;
14531         LDKLogger* logger_conv = (LDKLogger*)(((uint64_t)logger) & ~1);
14532         LDKCVec_TransactionZ ret_var = ChannelMonitor_get_latest_holder_commitment_txn(&this_arg_conv, logger_conv);
14533         jobjectArray ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
14534         ;
14535         for (size_t i = 0; i < ret_var.datalen; i++) {
14536                 LDKTransaction ret_conv_8_var = ret_var.data[i];
14537                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, ret_conv_8_var.datalen);
14538                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, ret_conv_8_var.datalen, ret_conv_8_var.data);
14539                 Transaction_free(ret_conv_8_var);
14540                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
14541         }
14542         FREE(ret_var.data);
14543         return ret_arr;
14544 }
14545
14546 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) {
14547         LDKChannelMonitor this_arg_conv;
14548         this_arg_conv.inner = (void*)(this_arg & (~1));
14549         this_arg_conv.is_owned = false;
14550         unsigned char header_arr[80];
14551         CHECK((*env)->GetArrayLength(env, header) == 80);
14552         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
14553         unsigned char (*header_ref)[80] = &header_arr;
14554         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
14555         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
14556         if (txdata_constr.datalen > 0)
14557                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
14558         else
14559                 txdata_constr.data = NULL;
14560         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
14561         for (size_t y = 0; y < txdata_constr.datalen; y++) {
14562                 int64_t txdata_conv_24 = txdata_vals[y];
14563                 LDKC2Tuple_usizeTransactionZ txdata_conv_24_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_24) & ~1);
14564                 txdata_conv_24_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_24) & ~1));
14565                 txdata_constr.data[y] = txdata_conv_24_conv;
14566         }
14567         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
14568         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
14569         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
14570                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14571                 LDKBroadcasterInterface_JCalls_clone(broadcaster_conv.this_arg);
14572         }
14573         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
14574         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
14575                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14576                 LDKFeeEstimator_JCalls_clone(fee_estimator_conv.this_arg);
14577         }
14578         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
14579         if (logger_conv.free == LDKLogger_JCalls_free) {
14580                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14581                 LDKLogger_JCalls_clone(logger_conv.this_arg);
14582         }
14583         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);
14584         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
14585         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
14586         for (size_t u = 0; u < ret_var.datalen; u++) {
14587                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_46_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
14588                 *ret_conv_46_ref = ret_var.data[u];
14589                 ret_arr_ptr[u] = (uint64_t)ret_conv_46_ref;
14590         }
14591         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
14592         FREE(ret_var.data);
14593         return ret_arr;
14594 }
14595
14596 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) {
14597         LDKChannelMonitor this_arg_conv;
14598         this_arg_conv.inner = (void*)(this_arg & (~1));
14599         this_arg_conv.is_owned = false;
14600         unsigned char header_arr[80];
14601         CHECK((*env)->GetArrayLength(env, header) == 80);
14602         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
14603         unsigned char (*header_ref)[80] = &header_arr;
14604         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
14605         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
14606                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14607                 LDKBroadcasterInterface_JCalls_clone(broadcaster_conv.this_arg);
14608         }
14609         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
14610         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
14611                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14612                 LDKFeeEstimator_JCalls_clone(fee_estimator_conv.this_arg);
14613         }
14614         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
14615         if (logger_conv.free == LDKLogger_JCalls_free) {
14616                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14617                 LDKLogger_JCalls_clone(logger_conv.this_arg);
14618         }
14619         ChannelMonitor_block_disconnected(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
14620 }
14621
14622 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) {
14623         LDKChannelMonitor this_arg_conv;
14624         this_arg_conv.inner = (void*)(this_arg & (~1));
14625         this_arg_conv.is_owned = false;
14626         unsigned char header_arr[80];
14627         CHECK((*env)->GetArrayLength(env, header) == 80);
14628         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
14629         unsigned char (*header_ref)[80] = &header_arr;
14630         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
14631         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
14632         if (txdata_constr.datalen > 0)
14633                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
14634         else
14635                 txdata_constr.data = NULL;
14636         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
14637         for (size_t y = 0; y < txdata_constr.datalen; y++) {
14638                 int64_t txdata_conv_24 = txdata_vals[y];
14639                 LDKC2Tuple_usizeTransactionZ txdata_conv_24_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_24) & ~1);
14640                 txdata_conv_24_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_24) & ~1));
14641                 txdata_constr.data[y] = txdata_conv_24_conv;
14642         }
14643         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
14644         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
14645         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
14646                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14647                 LDKBroadcasterInterface_JCalls_clone(broadcaster_conv.this_arg);
14648         }
14649         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
14650         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
14651                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14652                 LDKFeeEstimator_JCalls_clone(fee_estimator_conv.this_arg);
14653         }
14654         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
14655         if (logger_conv.free == LDKLogger_JCalls_free) {
14656                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14657                 LDKLogger_JCalls_clone(logger_conv.this_arg);
14658         }
14659         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);
14660         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
14661         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
14662         for (size_t u = 0; u < ret_var.datalen; u++) {
14663                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_46_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
14664                 *ret_conv_46_ref = ret_var.data[u];
14665                 ret_arr_ptr[u] = (uint64_t)ret_conv_46_ref;
14666         }
14667         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
14668         FREE(ret_var.data);
14669         return ret_arr;
14670 }
14671
14672 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) {
14673         LDKChannelMonitor this_arg_conv;
14674         this_arg_conv.inner = (void*)(this_arg & (~1));
14675         this_arg_conv.is_owned = false;
14676         unsigned char txid_arr[32];
14677         CHECK((*env)->GetArrayLength(env, txid) == 32);
14678         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
14679         unsigned char (*txid_ref)[32] = &txid_arr;
14680         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
14681         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
14682                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14683                 LDKBroadcasterInterface_JCalls_clone(broadcaster_conv.this_arg);
14684         }
14685         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
14686         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
14687                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14688                 LDKFeeEstimator_JCalls_clone(fee_estimator_conv.this_arg);
14689         }
14690         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
14691         if (logger_conv.free == LDKLogger_JCalls_free) {
14692                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14693                 LDKLogger_JCalls_clone(logger_conv.this_arg);
14694         }
14695         ChannelMonitor_transaction_unconfirmed(&this_arg_conv, txid_ref, broadcaster_conv, fee_estimator_conv, logger_conv);
14696 }
14697
14698 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) {
14699         LDKChannelMonitor this_arg_conv;
14700         this_arg_conv.inner = (void*)(this_arg & (~1));
14701         this_arg_conv.is_owned = false;
14702         unsigned char header_arr[80];
14703         CHECK((*env)->GetArrayLength(env, header) == 80);
14704         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
14705         unsigned char (*header_ref)[80] = &header_arr;
14706         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
14707         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
14708                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14709                 LDKBroadcasterInterface_JCalls_clone(broadcaster_conv.this_arg);
14710         }
14711         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
14712         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
14713                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14714                 LDKFeeEstimator_JCalls_clone(fee_estimator_conv.this_arg);
14715         }
14716         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
14717         if (logger_conv.free == LDKLogger_JCalls_free) {
14718                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14719                 LDKLogger_JCalls_clone(logger_conv.this_arg);
14720         }
14721         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ ret_var = ChannelMonitor_best_block_updated(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
14722         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
14723         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
14724         for (size_t u = 0; u < ret_var.datalen; u++) {
14725                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_46_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
14726                 *ret_conv_46_ref = ret_var.data[u];
14727                 ret_arr_ptr[u] = (uint64_t)ret_conv_46_ref;
14728         }
14729         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
14730         FREE(ret_var.data);
14731         return ret_arr;
14732 }
14733
14734 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1relevant_1txids(JNIEnv *env, jclass clz, int64_t this_arg) {
14735         LDKChannelMonitor this_arg_conv;
14736         this_arg_conv.inner = (void*)(this_arg & (~1));
14737         this_arg_conv.is_owned = false;
14738         LDKCVec_TxidZ ret_var = ChannelMonitor_get_relevant_txids(&this_arg_conv);
14739         jobjectArray ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
14740         ;
14741         for (size_t i = 0; i < ret_var.datalen; i++) {
14742                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 32);
14743                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 32, ret_var.data[i].data);
14744                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
14745         }
14746         FREE(ret_var.data);
14747         return ret_arr;
14748 }
14749
14750 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1current_1best_1block(JNIEnv *env, jclass clz, int64_t this_arg) {
14751         LDKChannelMonitor this_arg_conv;
14752         this_arg_conv.inner = (void*)(this_arg & (~1));
14753         this_arg_conv.is_owned = false;
14754         LDKBestBlock ret_var = ChannelMonitor_current_best_block(&this_arg_conv);
14755         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14756         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14757         uint64_t ret_ref = (uint64_t)ret_var.inner;
14758         if (ret_var.is_owned) {
14759                 ret_ref |= 1;
14760         }
14761         return ret_ref;
14762 }
14763
14764 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Persist_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
14765         if ((this_ptr & 1) != 0) return;
14766         LDKPersist this_ptr_conv = *(LDKPersist*)(((uint64_t)this_ptr) & ~1);
14767         FREE((void*)this_ptr);
14768         Persist_free(this_ptr_conv);
14769 }
14770
14771 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
14772         LDKu8slice ser_ref;
14773         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
14774         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
14775         LDKKeysInterface* arg_conv = (LDKKeysInterface*)(((uint64_t)arg) & ~1);
14776         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
14777         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_read(ser_ref, arg_conv);
14778         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
14779         return (uint64_t)ret_conv;
14780 }
14781
14782 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14783         LDKOutPoint this_obj_conv;
14784         this_obj_conv.inner = (void*)(this_obj & (~1));
14785         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14786         OutPoint_free(this_obj_conv);
14787 }
14788
14789 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1get_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
14790         LDKOutPoint this_ptr_conv;
14791         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14792         this_ptr_conv.is_owned = false;
14793         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14794         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OutPoint_get_txid(&this_ptr_conv));
14795         return ret_arr;
14796 }
14797
14798 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1set_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14799         LDKOutPoint this_ptr_conv;
14800         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14801         this_ptr_conv.is_owned = false;
14802         LDKThirtyTwoBytes val_ref;
14803         CHECK((*env)->GetArrayLength(env, val) == 32);
14804         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
14805         OutPoint_set_txid(&this_ptr_conv, val_ref);
14806 }
14807
14808 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1get_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
14809         LDKOutPoint this_ptr_conv;
14810         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14811         this_ptr_conv.is_owned = false;
14812         int16_t ret_val = OutPoint_get_index(&this_ptr_conv);
14813         return ret_val;
14814 }
14815
14816 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1set_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
14817         LDKOutPoint this_ptr_conv;
14818         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14819         this_ptr_conv.is_owned = false;
14820         OutPoint_set_index(&this_ptr_conv, val);
14821 }
14822
14823 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1new(JNIEnv *env, jclass clz, int8_tArray txid_arg, int16_t index_arg) {
14824         LDKThirtyTwoBytes txid_arg_ref;
14825         CHECK((*env)->GetArrayLength(env, txid_arg) == 32);
14826         (*env)->GetByteArrayRegion(env, txid_arg, 0, 32, txid_arg_ref.data);
14827         LDKOutPoint ret_var = OutPoint_new(txid_arg_ref, index_arg);
14828         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14829         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14830         uint64_t ret_ref = (uint64_t)ret_var.inner;
14831         if (ret_var.is_owned) {
14832                 ret_ref |= 1;
14833         }
14834         return ret_ref;
14835 }
14836
14837 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14838         LDKOutPoint orig_conv;
14839         orig_conv.inner = (void*)(orig & (~1));
14840         orig_conv.is_owned = false;
14841         LDKOutPoint ret_var = OutPoint_clone(&orig_conv);
14842         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14843         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14844         uint64_t ret_ref = (uint64_t)ret_var.inner;
14845         if (ret_var.is_owned) {
14846                 ret_ref |= 1;
14847         }
14848         return ret_ref;
14849 }
14850
14851 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_OutPoint_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
14852         LDKOutPoint a_conv;
14853         a_conv.inner = (void*)(a & (~1));
14854         a_conv.is_owned = false;
14855         LDKOutPoint b_conv;
14856         b_conv.inner = (void*)(b & (~1));
14857         b_conv.is_owned = false;
14858         jboolean ret_val = OutPoint_eq(&a_conv, &b_conv);
14859         return ret_val;
14860 }
14861
14862 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1hash(JNIEnv *env, jclass clz, int64_t o) {
14863         LDKOutPoint o_conv;
14864         o_conv.inner = (void*)(o & (~1));
14865         o_conv.is_owned = false;
14866         int64_t ret_val = OutPoint_hash(&o_conv);
14867         return ret_val;
14868 }
14869
14870 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1to_1channel_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
14871         LDKOutPoint this_arg_conv;
14872         this_arg_conv.inner = (void*)(this_arg & (~1));
14873         this_arg_conv.is_owned = false;
14874         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14875         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, OutPoint_to_channel_id(&this_arg_conv).data);
14876         return ret_arr;
14877 }
14878
14879 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1write(JNIEnv *env, jclass clz, int64_t obj) {
14880         LDKOutPoint obj_conv;
14881         obj_conv.inner = (void*)(obj & (~1));
14882         obj_conv.is_owned = false;
14883         LDKCVec_u8Z ret_var = OutPoint_write(&obj_conv);
14884         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
14885         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
14886         CVec_u8Z_free(ret_var);
14887         return ret_arr;
14888 }
14889
14890 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
14891         LDKu8slice ser_ref;
14892         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
14893         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
14894         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
14895         *ret_conv = OutPoint_read(ser_ref);
14896         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
14897         return (uint64_t)ret_conv;
14898 }
14899
14900 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14901         LDKDelayedPaymentOutputDescriptor this_obj_conv;
14902         this_obj_conv.inner = (void*)(this_obj & (~1));
14903         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14904         DelayedPaymentOutputDescriptor_free(this_obj_conv);
14905 }
14906
14907 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
14908         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
14909         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14910         this_ptr_conv.is_owned = false;
14911         LDKOutPoint ret_var = DelayedPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
14912         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14913         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14914         uint64_t ret_ref = (uint64_t)ret_var.inner;
14915         if (ret_var.is_owned) {
14916                 ret_ref |= 1;
14917         }
14918         return ret_ref;
14919 }
14920
14921 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
14922         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
14923         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14924         this_ptr_conv.is_owned = false;
14925         LDKOutPoint val_conv;
14926         val_conv.inner = (void*)(val & (~1));
14927         val_conv.is_owned = (val & 1) || (val == 0);
14928         val_conv = OutPoint_clone(&val_conv);
14929         DelayedPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
14930 }
14931
14932 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
14933         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
14934         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14935         this_ptr_conv.is_owned = false;
14936         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
14937         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DelayedPaymentOutputDescriptor_get_per_commitment_point(&this_ptr_conv).compressed_form);
14938         return ret_arr;
14939 }
14940
14941 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14942         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
14943         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14944         this_ptr_conv.is_owned = false;
14945         LDKPublicKey val_ref;
14946         CHECK((*env)->GetArrayLength(env, val) == 33);
14947         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
14948         DelayedPaymentOutputDescriptor_set_per_commitment_point(&this_ptr_conv, val_ref);
14949 }
14950
14951 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
14952         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
14953         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14954         this_ptr_conv.is_owned = false;
14955         int16_t ret_val = DelayedPaymentOutputDescriptor_get_to_self_delay(&this_ptr_conv);
14956         return ret_val;
14957 }
14958
14959 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
14960         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
14961         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14962         this_ptr_conv.is_owned = false;
14963         DelayedPaymentOutputDescriptor_set_to_self_delay(&this_ptr_conv, val);
14964 }
14965
14966 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1output(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
14967         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
14968         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14969         this_ptr_conv.is_owned = false;
14970         LDKTxOut val_conv = *(LDKTxOut*)(((uint64_t)val) & ~1);
14971         DelayedPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
14972 }
14973
14974 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1revocation_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
14975         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
14976         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14977         this_ptr_conv.is_owned = false;
14978         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
14979         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DelayedPaymentOutputDescriptor_get_revocation_pubkey(&this_ptr_conv).compressed_form);
14980         return ret_arr;
14981 }
14982
14983 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1revocation_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14984         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
14985         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14986         this_ptr_conv.is_owned = false;
14987         LDKPublicKey val_ref;
14988         CHECK((*env)->GetArrayLength(env, val) == 33);
14989         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
14990         DelayedPaymentOutputDescriptor_set_revocation_pubkey(&this_ptr_conv, val_ref);
14991 }
14992
14993 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
14994         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
14995         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14996         this_ptr_conv.is_owned = false;
14997         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14998         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *DelayedPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv));
14999         return ret_arr;
15000 }
15001
15002 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15003         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
15004         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15005         this_ptr_conv.is_owned = false;
15006         LDKThirtyTwoBytes val_ref;
15007         CHECK((*env)->GetArrayLength(env, val) == 32);
15008         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
15009         DelayedPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
15010 }
15011
15012 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
15013         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
15014         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15015         this_ptr_conv.is_owned = false;
15016         int64_t ret_val = DelayedPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
15017         return ret_val;
15018 }
15019
15020 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15021         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
15022         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15023         this_ptr_conv.is_owned = false;
15024         DelayedPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
15025 }
15026
15027 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) {
15028         LDKOutPoint outpoint_arg_conv;
15029         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
15030         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
15031         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
15032         LDKPublicKey per_commitment_point_arg_ref;
15033         CHECK((*env)->GetArrayLength(env, per_commitment_point_arg) == 33);
15034         (*env)->GetByteArrayRegion(env, per_commitment_point_arg, 0, 33, per_commitment_point_arg_ref.compressed_form);
15035         LDKTxOut output_arg_conv = *(LDKTxOut*)(((uint64_t)output_arg) & ~1);
15036         LDKPublicKey revocation_pubkey_arg_ref;
15037         CHECK((*env)->GetArrayLength(env, revocation_pubkey_arg) == 33);
15038         (*env)->GetByteArrayRegion(env, revocation_pubkey_arg, 0, 33, revocation_pubkey_arg_ref.compressed_form);
15039         LDKThirtyTwoBytes channel_keys_id_arg_ref;
15040         CHECK((*env)->GetArrayLength(env, channel_keys_id_arg) == 32);
15041         (*env)->GetByteArrayRegion(env, channel_keys_id_arg, 0, 32, channel_keys_id_arg_ref.data);
15042         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);
15043         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15044         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15045         uint64_t ret_ref = (uint64_t)ret_var.inner;
15046         if (ret_var.is_owned) {
15047                 ret_ref |= 1;
15048         }
15049         return ret_ref;
15050 }
15051
15052 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15053         LDKDelayedPaymentOutputDescriptor orig_conv;
15054         orig_conv.inner = (void*)(orig & (~1));
15055         orig_conv.is_owned = false;
15056         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(&orig_conv);
15057         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15058         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15059         uint64_t ret_ref = (uint64_t)ret_var.inner;
15060         if (ret_var.is_owned) {
15061                 ret_ref |= 1;
15062         }
15063         return ret_ref;
15064 }
15065
15066 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
15067         LDKDelayedPaymentOutputDescriptor obj_conv;
15068         obj_conv.inner = (void*)(obj & (~1));
15069         obj_conv.is_owned = false;
15070         LDKCVec_u8Z ret_var = DelayedPaymentOutputDescriptor_write(&obj_conv);
15071         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
15072         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
15073         CVec_u8Z_free(ret_var);
15074         return ret_arr;
15075 }
15076
15077 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
15078         LDKu8slice ser_ref;
15079         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
15080         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
15081         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
15082         *ret_conv = DelayedPaymentOutputDescriptor_read(ser_ref);
15083         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
15084         return (uint64_t)ret_conv;
15085 }
15086
15087 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
15088         LDKStaticPaymentOutputDescriptor this_obj_conv;
15089         this_obj_conv.inner = (void*)(this_obj & (~1));
15090         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15091         StaticPaymentOutputDescriptor_free(this_obj_conv);
15092 }
15093
15094 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
15095         LDKStaticPaymentOutputDescriptor this_ptr_conv;
15096         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15097         this_ptr_conv.is_owned = false;
15098         LDKOutPoint ret_var = StaticPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
15099         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15100         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15101         uint64_t ret_ref = (uint64_t)ret_var.inner;
15102         if (ret_var.is_owned) {
15103                 ret_ref |= 1;
15104         }
15105         return ret_ref;
15106 }
15107
15108 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15109         LDKStaticPaymentOutputDescriptor this_ptr_conv;
15110         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15111         this_ptr_conv.is_owned = false;
15112         LDKOutPoint val_conv;
15113         val_conv.inner = (void*)(val & (~1));
15114         val_conv.is_owned = (val & 1) || (val == 0);
15115         val_conv = OutPoint_clone(&val_conv);
15116         StaticPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
15117 }
15118
15119 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1output(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15120         LDKStaticPaymentOutputDescriptor this_ptr_conv;
15121         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15122         this_ptr_conv.is_owned = false;
15123         LDKTxOut val_conv = *(LDKTxOut*)(((uint64_t)val) & ~1);
15124         StaticPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
15125 }
15126
15127 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
15128         LDKStaticPaymentOutputDescriptor this_ptr_conv;
15129         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15130         this_ptr_conv.is_owned = false;
15131         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
15132         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *StaticPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv));
15133         return ret_arr;
15134 }
15135
15136 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15137         LDKStaticPaymentOutputDescriptor this_ptr_conv;
15138         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15139         this_ptr_conv.is_owned = false;
15140         LDKThirtyTwoBytes val_ref;
15141         CHECK((*env)->GetArrayLength(env, val) == 32);
15142         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
15143         StaticPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
15144 }
15145
15146 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
15147         LDKStaticPaymentOutputDescriptor this_ptr_conv;
15148         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15149         this_ptr_conv.is_owned = false;
15150         int64_t ret_val = StaticPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
15151         return ret_val;
15152 }
15153
15154 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15155         LDKStaticPaymentOutputDescriptor this_ptr_conv;
15156         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15157         this_ptr_conv.is_owned = false;
15158         StaticPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
15159 }
15160
15161 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) {
15162         LDKOutPoint outpoint_arg_conv;
15163         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
15164         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
15165         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
15166         LDKTxOut output_arg_conv = *(LDKTxOut*)(((uint64_t)output_arg) & ~1);
15167         LDKThirtyTwoBytes channel_keys_id_arg_ref;
15168         CHECK((*env)->GetArrayLength(env, channel_keys_id_arg) == 32);
15169         (*env)->GetByteArrayRegion(env, channel_keys_id_arg, 0, 32, channel_keys_id_arg_ref.data);
15170         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_new(outpoint_arg_conv, output_arg_conv, channel_keys_id_arg_ref, channel_value_satoshis_arg);
15171         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15172         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15173         uint64_t ret_ref = (uint64_t)ret_var.inner;
15174         if (ret_var.is_owned) {
15175                 ret_ref |= 1;
15176         }
15177         return ret_ref;
15178 }
15179
15180 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15181         LDKStaticPaymentOutputDescriptor orig_conv;
15182         orig_conv.inner = (void*)(orig & (~1));
15183         orig_conv.is_owned = false;
15184         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(&orig_conv);
15185         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15186         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15187         uint64_t ret_ref = (uint64_t)ret_var.inner;
15188         if (ret_var.is_owned) {
15189                 ret_ref |= 1;
15190         }
15191         return ret_ref;
15192 }
15193
15194 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
15195         LDKStaticPaymentOutputDescriptor obj_conv;
15196         obj_conv.inner = (void*)(obj & (~1));
15197         obj_conv.is_owned = false;
15198         LDKCVec_u8Z ret_var = StaticPaymentOutputDescriptor_write(&obj_conv);
15199         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
15200         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
15201         CVec_u8Z_free(ret_var);
15202         return ret_arr;
15203 }
15204
15205 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
15206         LDKu8slice ser_ref;
15207         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
15208         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
15209         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
15210         *ret_conv = StaticPaymentOutputDescriptor_read(ser_ref);
15211         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
15212         return (uint64_t)ret_conv;
15213 }
15214
15215 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
15216         if ((this_ptr & 1) != 0) return;
15217         LDKSpendableOutputDescriptor this_ptr_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)this_ptr) & ~1);
15218         FREE((void*)this_ptr);
15219         SpendableOutputDescriptor_free(this_ptr_conv);
15220 }
15221
15222 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15223         LDKSpendableOutputDescriptor* orig_conv = (LDKSpendableOutputDescriptor*)orig;
15224         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
15225         *ret_copy = SpendableOutputDescriptor_clone(orig_conv);
15226         uint64_t ret_ref = (uint64_t)ret_copy;
15227         return ret_ref;
15228 }
15229
15230 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
15231         LDKSpendableOutputDescriptor* obj_conv = (LDKSpendableOutputDescriptor*)obj;
15232         LDKCVec_u8Z ret_var = SpendableOutputDescriptor_write(obj_conv);
15233         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
15234         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
15235         CVec_u8Z_free(ret_var);
15236         return ret_arr;
15237 }
15238
15239 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
15240         LDKu8slice ser_ref;
15241         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
15242         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
15243         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
15244         *ret_conv = SpendableOutputDescriptor_read(ser_ref);
15245         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
15246         return (uint64_t)ret_conv;
15247 }
15248
15249 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BaseSign_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
15250         if ((this_ptr & 1) != 0) return;
15251         LDKBaseSign this_ptr_conv = *(LDKBaseSign*)(((uint64_t)this_ptr) & ~1);
15252         FREE((void*)this_ptr);
15253         BaseSign_free(this_ptr_conv);
15254 }
15255
15256 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sign_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15257         LDKSign* orig_conv = (LDKSign*)(((uint64_t)orig) & ~1);
15258         LDKSign* ret = MALLOC(sizeof(LDKSign), "LDKSign");
15259         *ret = Sign_clone(orig_conv);
15260         return (uint64_t)ret;
15261 }
15262
15263 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Sign_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
15264         if ((this_ptr & 1) != 0) return;
15265         LDKSign this_ptr_conv = *(LDKSign*)(((uint64_t)this_ptr) & ~1);
15266         FREE((void*)this_ptr);
15267         Sign_free(this_ptr_conv);
15268 }
15269
15270 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_KeysInterface_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
15271         if ((this_ptr & 1) != 0) return;
15272         LDKKeysInterface this_ptr_conv = *(LDKKeysInterface*)(((uint64_t)this_ptr) & ~1);
15273         FREE((void*)this_ptr);
15274         KeysInterface_free(this_ptr_conv);
15275 }
15276
15277 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
15278         LDKInMemorySigner this_obj_conv;
15279         this_obj_conv.inner = (void*)(this_obj & (~1));
15280         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15281         InMemorySigner_free(this_obj_conv);
15282 }
15283
15284 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1funding_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
15285         LDKInMemorySigner this_ptr_conv;
15286         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15287         this_ptr_conv.is_owned = false;
15288         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
15289         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_funding_key(&this_ptr_conv));
15290         return ret_arr;
15291 }
15292
15293 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1funding_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15294         LDKInMemorySigner this_ptr_conv;
15295         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15296         this_ptr_conv.is_owned = false;
15297         LDKSecretKey val_ref;
15298         CHECK((*env)->GetArrayLength(env, val) == 32);
15299         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
15300         InMemorySigner_set_funding_key(&this_ptr_conv, val_ref);
15301 }
15302
15303 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1revocation_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
15304         LDKInMemorySigner this_ptr_conv;
15305         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15306         this_ptr_conv.is_owned = false;
15307         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
15308         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_revocation_base_key(&this_ptr_conv));
15309         return ret_arr;
15310 }
15311
15312 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1revocation_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15313         LDKInMemorySigner this_ptr_conv;
15314         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15315         this_ptr_conv.is_owned = false;
15316         LDKSecretKey val_ref;
15317         CHECK((*env)->GetArrayLength(env, val) == 32);
15318         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
15319         InMemorySigner_set_revocation_base_key(&this_ptr_conv, val_ref);
15320 }
15321
15322 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
15323         LDKInMemorySigner this_ptr_conv;
15324         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15325         this_ptr_conv.is_owned = false;
15326         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
15327         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_payment_key(&this_ptr_conv));
15328         return ret_arr;
15329 }
15330
15331 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15332         LDKInMemorySigner this_ptr_conv;
15333         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15334         this_ptr_conv.is_owned = false;
15335         LDKSecretKey val_ref;
15336         CHECK((*env)->GetArrayLength(env, val) == 32);
15337         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
15338         InMemorySigner_set_payment_key(&this_ptr_conv, val_ref);
15339 }
15340
15341 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1delayed_1payment_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
15342         LDKInMemorySigner this_ptr_conv;
15343         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15344         this_ptr_conv.is_owned = false;
15345         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
15346         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_delayed_payment_base_key(&this_ptr_conv));
15347         return ret_arr;
15348 }
15349
15350 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) {
15351         LDKInMemorySigner this_ptr_conv;
15352         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15353         this_ptr_conv.is_owned = false;
15354         LDKSecretKey val_ref;
15355         CHECK((*env)->GetArrayLength(env, val) == 32);
15356         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
15357         InMemorySigner_set_delayed_payment_base_key(&this_ptr_conv, val_ref);
15358 }
15359
15360 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1htlc_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
15361         LDKInMemorySigner this_ptr_conv;
15362         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15363         this_ptr_conv.is_owned = false;
15364         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
15365         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_htlc_base_key(&this_ptr_conv));
15366         return ret_arr;
15367 }
15368
15369 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1htlc_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15370         LDKInMemorySigner this_ptr_conv;
15371         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15372         this_ptr_conv.is_owned = false;
15373         LDKSecretKey val_ref;
15374         CHECK((*env)->GetArrayLength(env, val) == 32);
15375         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
15376         InMemorySigner_set_htlc_base_key(&this_ptr_conv, val_ref);
15377 }
15378
15379 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1commitment_1seed(JNIEnv *env, jclass clz, int64_t this_ptr) {
15380         LDKInMemorySigner this_ptr_conv;
15381         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15382         this_ptr_conv.is_owned = false;
15383         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
15384         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_commitment_seed(&this_ptr_conv));
15385         return ret_arr;
15386 }
15387
15388 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1commitment_1seed(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15389         LDKInMemorySigner this_ptr_conv;
15390         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15391         this_ptr_conv.is_owned = false;
15392         LDKThirtyTwoBytes val_ref;
15393         CHECK((*env)->GetArrayLength(env, val) == 32);
15394         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
15395         InMemorySigner_set_commitment_seed(&this_ptr_conv, val_ref);
15396 }
15397
15398 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15399         LDKInMemorySigner orig_conv;
15400         orig_conv.inner = (void*)(orig & (~1));
15401         orig_conv.is_owned = false;
15402         LDKInMemorySigner ret_var = InMemorySigner_clone(&orig_conv);
15403         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15404         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15405         uint64_t ret_ref = (uint64_t)ret_var.inner;
15406         if (ret_var.is_owned) {
15407                 ret_ref |= 1;
15408         }
15409         return ret_ref;
15410 }
15411
15412 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) {
15413         LDKSecretKey funding_key_ref;
15414         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
15415         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_ref.bytes);
15416         LDKSecretKey revocation_base_key_ref;
15417         CHECK((*env)->GetArrayLength(env, revocation_base_key) == 32);
15418         (*env)->GetByteArrayRegion(env, revocation_base_key, 0, 32, revocation_base_key_ref.bytes);
15419         LDKSecretKey payment_key_ref;
15420         CHECK((*env)->GetArrayLength(env, payment_key) == 32);
15421         (*env)->GetByteArrayRegion(env, payment_key, 0, 32, payment_key_ref.bytes);
15422         LDKSecretKey delayed_payment_base_key_ref;
15423         CHECK((*env)->GetArrayLength(env, delayed_payment_base_key) == 32);
15424         (*env)->GetByteArrayRegion(env, delayed_payment_base_key, 0, 32, delayed_payment_base_key_ref.bytes);
15425         LDKSecretKey htlc_base_key_ref;
15426         CHECK((*env)->GetArrayLength(env, htlc_base_key) == 32);
15427         (*env)->GetByteArrayRegion(env, htlc_base_key, 0, 32, htlc_base_key_ref.bytes);
15428         LDKThirtyTwoBytes commitment_seed_ref;
15429         CHECK((*env)->GetArrayLength(env, commitment_seed) == 32);
15430         (*env)->GetByteArrayRegion(env, commitment_seed, 0, 32, commitment_seed_ref.data);
15431         LDKThirtyTwoBytes channel_keys_id_ref;
15432         CHECK((*env)->GetArrayLength(env, channel_keys_id) == 32);
15433         (*env)->GetByteArrayRegion(env, channel_keys_id, 0, 32, channel_keys_id_ref.data);
15434         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);
15435         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15436         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15437         uint64_t ret_ref = (uint64_t)ret_var.inner;
15438         if (ret_var.is_owned) {
15439                 ret_ref |= 1;
15440         }
15441         return ret_ref;
15442 }
15443
15444 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1counterparty_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
15445         LDKInMemorySigner this_arg_conv;
15446         this_arg_conv.inner = (void*)(this_arg & (~1));
15447         this_arg_conv.is_owned = false;
15448         LDKChannelPublicKeys ret_var = InMemorySigner_counterparty_pubkeys(&this_arg_conv);
15449         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15450         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15451         uint64_t ret_ref = (uint64_t)ret_var.inner;
15452         if (ret_var.is_owned) {
15453                 ret_ref |= 1;
15454         }
15455         return ret_ref;
15456 }
15457
15458 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1counterparty_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
15459         LDKInMemorySigner this_arg_conv;
15460         this_arg_conv.inner = (void*)(this_arg & (~1));
15461         this_arg_conv.is_owned = false;
15462         int16_t ret_val = InMemorySigner_counterparty_selected_contest_delay(&this_arg_conv);
15463         return ret_val;
15464 }
15465
15466 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1holder_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
15467         LDKInMemorySigner this_arg_conv;
15468         this_arg_conv.inner = (void*)(this_arg & (~1));
15469         this_arg_conv.is_owned = false;
15470         int16_t ret_val = InMemorySigner_holder_selected_contest_delay(&this_arg_conv);
15471         return ret_val;
15472 }
15473
15474 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_arg) {
15475         LDKInMemorySigner this_arg_conv;
15476         this_arg_conv.inner = (void*)(this_arg & (~1));
15477         this_arg_conv.is_owned = false;
15478         jboolean ret_val = InMemorySigner_is_outbound(&this_arg_conv);
15479         return ret_val;
15480 }
15481
15482 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_arg) {
15483         LDKInMemorySigner this_arg_conv;
15484         this_arg_conv.inner = (void*)(this_arg & (~1));
15485         this_arg_conv.is_owned = false;
15486         LDKOutPoint ret_var = InMemorySigner_funding_outpoint(&this_arg_conv);
15487         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15488         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15489         uint64_t ret_ref = (uint64_t)ret_var.inner;
15490         if (ret_var.is_owned) {
15491                 ret_ref |= 1;
15492         }
15493         return ret_ref;
15494 }
15495
15496 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1channel_1parameters(JNIEnv *env, jclass clz, int64_t this_arg) {
15497         LDKInMemorySigner this_arg_conv;
15498         this_arg_conv.inner = (void*)(this_arg & (~1));
15499         this_arg_conv.is_owned = false;
15500         LDKChannelTransactionParameters ret_var = InMemorySigner_get_channel_parameters(&this_arg_conv);
15501         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15502         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15503         uint64_t ret_ref = (uint64_t)ret_var.inner;
15504         if (ret_var.is_owned) {
15505                 ret_ref |= 1;
15506         }
15507         return ret_ref;
15508 }
15509
15510 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) {
15511         LDKInMemorySigner this_arg_conv;
15512         this_arg_conv.inner = (void*)(this_arg & (~1));
15513         this_arg_conv.is_owned = false;
15514         LDKTransaction spend_tx_ref;
15515         spend_tx_ref.datalen = (*env)->GetArrayLength(env, spend_tx);
15516         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
15517         (*env)->GetByteArrayRegion(env, spend_tx, 0, spend_tx_ref.datalen, spend_tx_ref.data);
15518         spend_tx_ref.data_is_owned = true;
15519         LDKStaticPaymentOutputDescriptor descriptor_conv;
15520         descriptor_conv.inner = (void*)(descriptor & (~1));
15521         descriptor_conv.is_owned = false;
15522         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
15523         *ret_conv = InMemorySigner_sign_counterparty_payment_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
15524         return (uint64_t)ret_conv;
15525 }
15526
15527 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) {
15528         LDKInMemorySigner this_arg_conv;
15529         this_arg_conv.inner = (void*)(this_arg & (~1));
15530         this_arg_conv.is_owned = false;
15531         LDKTransaction spend_tx_ref;
15532         spend_tx_ref.datalen = (*env)->GetArrayLength(env, spend_tx);
15533         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
15534         (*env)->GetByteArrayRegion(env, spend_tx, 0, spend_tx_ref.datalen, spend_tx_ref.data);
15535         spend_tx_ref.data_is_owned = true;
15536         LDKDelayedPaymentOutputDescriptor descriptor_conv;
15537         descriptor_conv.inner = (void*)(descriptor & (~1));
15538         descriptor_conv.is_owned = false;
15539         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
15540         *ret_conv = InMemorySigner_sign_dynamic_p2wsh_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
15541         return (uint64_t)ret_conv;
15542 }
15543
15544 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1as_1BaseSign(JNIEnv *env, jclass clz, int64_t this_arg) {
15545         LDKInMemorySigner this_arg_conv;
15546         this_arg_conv.inner = (void*)(this_arg & (~1));
15547         this_arg_conv.is_owned = false;
15548         LDKBaseSign* ret = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
15549         *ret = InMemorySigner_as_BaseSign(&this_arg_conv);
15550         return (uint64_t)ret;
15551 }
15552
15553 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1as_1Sign(JNIEnv *env, jclass clz, int64_t this_arg) {
15554         LDKInMemorySigner this_arg_conv;
15555         this_arg_conv.inner = (void*)(this_arg & (~1));
15556         this_arg_conv.is_owned = false;
15557         LDKSign* ret = MALLOC(sizeof(LDKSign), "LDKSign");
15558         *ret = InMemorySigner_as_Sign(&this_arg_conv);
15559         return (uint64_t)ret;
15560 }
15561
15562 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1write(JNIEnv *env, jclass clz, int64_t obj) {
15563         LDKInMemorySigner obj_conv;
15564         obj_conv.inner = (void*)(obj & (~1));
15565         obj_conv.is_owned = false;
15566         LDKCVec_u8Z ret_var = InMemorySigner_write(&obj_conv);
15567         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
15568         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
15569         CVec_u8Z_free(ret_var);
15570         return ret_arr;
15571 }
15572
15573 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
15574         LDKu8slice ser_ref;
15575         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
15576         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
15577         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
15578         *ret_conv = InMemorySigner_read(ser_ref);
15579         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
15580         return (uint64_t)ret_conv;
15581 }
15582
15583 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_KeysManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
15584         LDKKeysManager this_obj_conv;
15585         this_obj_conv.inner = (void*)(this_obj & (~1));
15586         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15587         KeysManager_free(this_obj_conv);
15588 }
15589
15590 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) {
15591         unsigned char seed_arr[32];
15592         CHECK((*env)->GetArrayLength(env, seed) == 32);
15593         (*env)->GetByteArrayRegion(env, seed, 0, 32, seed_arr);
15594         unsigned char (*seed_ref)[32] = &seed_arr;
15595         LDKKeysManager ret_var = KeysManager_new(seed_ref, starting_time_secs, starting_time_nanos);
15596         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15597         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15598         uint64_t ret_ref = (uint64_t)ret_var.inner;
15599         if (ret_var.is_owned) {
15600                 ret_ref |= 1;
15601         }
15602         return ret_ref;
15603 }
15604
15605 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) {
15606         LDKKeysManager this_arg_conv;
15607         this_arg_conv.inner = (void*)(this_arg & (~1));
15608         this_arg_conv.is_owned = false;
15609         unsigned char params_arr[32];
15610         CHECK((*env)->GetArrayLength(env, params) == 32);
15611         (*env)->GetByteArrayRegion(env, params, 0, 32, params_arr);
15612         unsigned char (*params_ref)[32] = &params_arr;
15613         LDKInMemorySigner ret_var = KeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
15614         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15615         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15616         uint64_t ret_ref = (uint64_t)ret_var.inner;
15617         if (ret_var.is_owned) {
15618                 ret_ref |= 1;
15619         }
15620         return ret_ref;
15621 }
15622
15623 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) {
15624         LDKKeysManager this_arg_conv;
15625         this_arg_conv.inner = (void*)(this_arg & (~1));
15626         this_arg_conv.is_owned = false;
15627         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
15628         descriptors_constr.datalen = (*env)->GetArrayLength(env, descriptors);
15629         if (descriptors_constr.datalen > 0)
15630                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
15631         else
15632                 descriptors_constr.data = NULL;
15633         int64_t* descriptors_vals = (*env)->GetLongArrayElements (env, descriptors, NULL);
15634         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
15635                 int64_t descriptors_conv_27 = descriptors_vals[b];
15636                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)descriptors_conv_27) & ~1);
15637                 descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uint64_t)descriptors_conv_27) & ~1));
15638                 descriptors_constr.data[b] = descriptors_conv_27_conv;
15639         }
15640         (*env)->ReleaseLongArrayElements(env, descriptors, descriptors_vals, 0);
15641         LDKCVec_TxOutZ outputs_constr;
15642         outputs_constr.datalen = (*env)->GetArrayLength(env, outputs);
15643         if (outputs_constr.datalen > 0)
15644                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
15645         else
15646                 outputs_constr.data = NULL;
15647         int64_t* outputs_vals = (*env)->GetLongArrayElements (env, outputs, NULL);
15648         for (size_t h = 0; h < outputs_constr.datalen; h++) {
15649                 int64_t outputs_conv_7 = outputs_vals[h];
15650                 LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(((uint64_t)outputs_conv_7) & ~1);
15651                 outputs_conv_7_conv = TxOut_clone((LDKTxOut*)(((uint64_t)outputs_conv_7) & ~1));
15652                 outputs_constr.data[h] = outputs_conv_7_conv;
15653         }
15654         (*env)->ReleaseLongArrayElements(env, outputs, outputs_vals, 0);
15655         LDKCVec_u8Z change_destination_script_ref;
15656         change_destination_script_ref.datalen = (*env)->GetArrayLength(env, change_destination_script);
15657         change_destination_script_ref.data = MALLOC(change_destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
15658         (*env)->GetByteArrayRegion(env, change_destination_script, 0, change_destination_script_ref.datalen, change_destination_script_ref.data);
15659         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
15660         *ret_conv = KeysManager_spend_spendable_outputs(&this_arg_conv, descriptors_constr, outputs_constr, change_destination_script_ref, feerate_sat_per_1000_weight);
15661         return (uint64_t)ret_conv;
15662 }
15663
15664 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysManager_1as_1KeysInterface(JNIEnv *env, jclass clz, int64_t this_arg) {
15665         LDKKeysManager this_arg_conv;
15666         this_arg_conv.inner = (void*)(this_arg & (~1));
15667         this_arg_conv.is_owned = false;
15668         LDKKeysInterface* ret = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
15669         *ret = KeysManager_as_KeysInterface(&this_arg_conv);
15670         return (uint64_t)ret;
15671 }
15672
15673 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
15674         LDKChannelManager this_obj_conv;
15675         this_obj_conv.inner = (void*)(this_obj & (~1));
15676         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15677         ChannelManager_free(this_obj_conv);
15678 }
15679
15680 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
15681         LDKChainParameters this_obj_conv;
15682         this_obj_conv.inner = (void*)(this_obj & (~1));
15683         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15684         ChainParameters_free(this_obj_conv);
15685 }
15686
15687 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChainParameters_1get_1network(JNIEnv *env, jclass clz, int64_t this_ptr) {
15688         LDKChainParameters this_ptr_conv;
15689         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15690         this_ptr_conv.is_owned = false;
15691         jclass ret_conv = LDKNetwork_to_java(env, ChainParameters_get_network(&this_ptr_conv));
15692         return ret_conv;
15693 }
15694
15695 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1set_1network(JNIEnv *env, jclass clz, int64_t this_ptr, jclass val) {
15696         LDKChainParameters this_ptr_conv;
15697         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15698         this_ptr_conv.is_owned = false;
15699         LDKNetwork val_conv = LDKNetwork_from_java(env, val);
15700         ChainParameters_set_network(&this_ptr_conv, val_conv);
15701 }
15702
15703 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1get_1best_1block(JNIEnv *env, jclass clz, int64_t this_ptr) {
15704         LDKChainParameters this_ptr_conv;
15705         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15706         this_ptr_conv.is_owned = false;
15707         LDKBestBlock ret_var = ChainParameters_get_best_block(&this_ptr_conv);
15708         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15709         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15710         uint64_t ret_ref = (uint64_t)ret_var.inner;
15711         if (ret_var.is_owned) {
15712                 ret_ref |= 1;
15713         }
15714         return ret_ref;
15715 }
15716
15717 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1set_1best_1block(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15718         LDKChainParameters this_ptr_conv;
15719         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15720         this_ptr_conv.is_owned = false;
15721         LDKBestBlock val_conv;
15722         val_conv.inner = (void*)(val & (~1));
15723         val_conv.is_owned = (val & 1) || (val == 0);
15724         val_conv = BestBlock_clone(&val_conv);
15725         ChainParameters_set_best_block(&this_ptr_conv, val_conv);
15726 }
15727
15728 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1new(JNIEnv *env, jclass clz, jclass network_arg, int64_t best_block_arg) {
15729         LDKNetwork network_arg_conv = LDKNetwork_from_java(env, network_arg);
15730         LDKBestBlock best_block_arg_conv;
15731         best_block_arg_conv.inner = (void*)(best_block_arg & (~1));
15732         best_block_arg_conv.is_owned = (best_block_arg & 1) || (best_block_arg == 0);
15733         best_block_arg_conv = BestBlock_clone(&best_block_arg_conv);
15734         LDKChainParameters ret_var = ChainParameters_new(network_arg_conv, best_block_arg_conv);
15735         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15736         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15737         uint64_t ret_ref = (uint64_t)ret_var.inner;
15738         if (ret_var.is_owned) {
15739                 ret_ref |= 1;
15740         }
15741         return ret_ref;
15742 }
15743
15744 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15745         LDKChainParameters orig_conv;
15746         orig_conv.inner = (void*)(orig & (~1));
15747         orig_conv.is_owned = false;
15748         LDKChainParameters ret_var = ChainParameters_clone(&orig_conv);
15749         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15750         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15751         uint64_t ret_ref = (uint64_t)ret_var.inner;
15752         if (ret_var.is_owned) {
15753                 ret_ref |= 1;
15754         }
15755         return ret_ref;
15756 }
15757
15758 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
15759         LDKChannelCounterparty this_obj_conv;
15760         this_obj_conv.inner = (void*)(this_obj & (~1));
15761         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15762         ChannelCounterparty_free(this_obj_conv);
15763 }
15764
15765 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
15766         LDKChannelCounterparty this_ptr_conv;
15767         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15768         this_ptr_conv.is_owned = false;
15769         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
15770         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelCounterparty_get_node_id(&this_ptr_conv).compressed_form);
15771         return ret_arr;
15772 }
15773
15774 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15775         LDKChannelCounterparty this_ptr_conv;
15776         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15777         this_ptr_conv.is_owned = false;
15778         LDKPublicKey val_ref;
15779         CHECK((*env)->GetArrayLength(env, val) == 33);
15780         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
15781         ChannelCounterparty_set_node_id(&this_ptr_conv, val_ref);
15782 }
15783
15784 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
15785         LDKChannelCounterparty this_ptr_conv;
15786         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15787         this_ptr_conv.is_owned = false;
15788         LDKInitFeatures ret_var = ChannelCounterparty_get_features(&this_ptr_conv);
15789         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15790         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15791         uint64_t ret_ref = (uint64_t)ret_var.inner;
15792         if (ret_var.is_owned) {
15793                 ret_ref |= 1;
15794         }
15795         return ret_ref;
15796 }
15797
15798 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15799         LDKChannelCounterparty this_ptr_conv;
15800         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15801         this_ptr_conv.is_owned = false;
15802         LDKInitFeatures val_conv;
15803         val_conv.inner = (void*)(val & (~1));
15804         val_conv.is_owned = (val & 1) || (val == 0);
15805         val_conv = InitFeatures_clone(&val_conv);
15806         ChannelCounterparty_set_features(&this_ptr_conv, val_conv);
15807 }
15808
15809 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr) {
15810         LDKChannelCounterparty this_ptr_conv;
15811         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15812         this_ptr_conv.is_owned = false;
15813         int64_t ret_val = ChannelCounterparty_get_unspendable_punishment_reserve(&this_ptr_conv);
15814         return ret_val;
15815 }
15816
15817 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15818         LDKChannelCounterparty this_ptr_conv;
15819         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15820         this_ptr_conv.is_owned = false;
15821         ChannelCounterparty_set_unspendable_punishment_reserve(&this_ptr_conv, val);
15822 }
15823
15824 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15825         LDKChannelCounterparty orig_conv;
15826         orig_conv.inner = (void*)(orig & (~1));
15827         orig_conv.is_owned = false;
15828         LDKChannelCounterparty ret_var = ChannelCounterparty_clone(&orig_conv);
15829         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15830         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15831         uint64_t ret_ref = (uint64_t)ret_var.inner;
15832         if (ret_var.is_owned) {
15833                 ret_ref |= 1;
15834         }
15835         return ret_ref;
15836 }
15837
15838 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
15839         LDKChannelDetails this_obj_conv;
15840         this_obj_conv.inner = (void*)(this_obj & (~1));
15841         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15842         ChannelDetails_free(this_obj_conv);
15843 }
15844
15845 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
15846         LDKChannelDetails this_ptr_conv;
15847         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15848         this_ptr_conv.is_owned = false;
15849         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
15850         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ChannelDetails_get_channel_id(&this_ptr_conv));
15851         return ret_arr;
15852 }
15853
15854 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15855         LDKChannelDetails this_ptr_conv;
15856         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15857         this_ptr_conv.is_owned = false;
15858         LDKThirtyTwoBytes val_ref;
15859         CHECK((*env)->GetArrayLength(env, val) == 32);
15860         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
15861         ChannelDetails_set_channel_id(&this_ptr_conv, val_ref);
15862 }
15863
15864 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1counterparty(JNIEnv *env, jclass clz, int64_t this_ptr) {
15865         LDKChannelDetails this_ptr_conv;
15866         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15867         this_ptr_conv.is_owned = false;
15868         LDKChannelCounterparty ret_var = ChannelDetails_get_counterparty(&this_ptr_conv);
15869         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15870         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15871         uint64_t ret_ref = (uint64_t)ret_var.inner;
15872         if (ret_var.is_owned) {
15873                 ret_ref |= 1;
15874         }
15875         return ret_ref;
15876 }
15877
15878 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1counterparty(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15879         LDKChannelDetails this_ptr_conv;
15880         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15881         this_ptr_conv.is_owned = false;
15882         LDKChannelCounterparty val_conv;
15883         val_conv.inner = (void*)(val & (~1));
15884         val_conv.is_owned = (val & 1) || (val == 0);
15885         val_conv = ChannelCounterparty_clone(&val_conv);
15886         ChannelDetails_set_counterparty(&this_ptr_conv, val_conv);
15887 }
15888
15889 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_ptr) {
15890         LDKChannelDetails this_ptr_conv;
15891         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15892         this_ptr_conv.is_owned = false;
15893         LDKOutPoint ret_var = ChannelDetails_get_funding_txo(&this_ptr_conv);
15894         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15895         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15896         uint64_t ret_ref = (uint64_t)ret_var.inner;
15897         if (ret_var.is_owned) {
15898                 ret_ref |= 1;
15899         }
15900         return ret_ref;
15901 }
15902
15903 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15904         LDKChannelDetails this_ptr_conv;
15905         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15906         this_ptr_conv.is_owned = false;
15907         LDKOutPoint val_conv;
15908         val_conv.inner = (void*)(val & (~1));
15909         val_conv.is_owned = (val & 1) || (val == 0);
15910         val_conv = OutPoint_clone(&val_conv);
15911         ChannelDetails_set_funding_txo(&this_ptr_conv, val_conv);
15912 }
15913
15914 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
15915         LDKChannelDetails this_ptr_conv;
15916         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15917         this_ptr_conv.is_owned = false;
15918         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
15919         *ret_copy = ChannelDetails_get_short_channel_id(&this_ptr_conv);
15920         uint64_t ret_ref = (uint64_t)ret_copy;
15921         return ret_ref;
15922 }
15923
15924 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15925         LDKChannelDetails this_ptr_conv;
15926         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15927         this_ptr_conv.is_owned = false;
15928         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
15929         ChannelDetails_set_short_channel_id(&this_ptr_conv, val_conv);
15930 }
15931
15932 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
15933         LDKChannelDetails this_ptr_conv;
15934         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15935         this_ptr_conv.is_owned = false;
15936         int64_t ret_val = ChannelDetails_get_channel_value_satoshis(&this_ptr_conv);
15937         return ret_val;
15938 }
15939
15940 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15941         LDKChannelDetails this_ptr_conv;
15942         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15943         this_ptr_conv.is_owned = false;
15944         ChannelDetails_set_channel_value_satoshis(&this_ptr_conv, val);
15945 }
15946
15947 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr) {
15948         LDKChannelDetails this_ptr_conv;
15949         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15950         this_ptr_conv.is_owned = false;
15951         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
15952         *ret_copy = ChannelDetails_get_unspendable_punishment_reserve(&this_ptr_conv);
15953         uint64_t ret_ref = (uint64_t)ret_copy;
15954         return ret_ref;
15955 }
15956
15957 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15958         LDKChannelDetails this_ptr_conv;
15959         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15960         this_ptr_conv.is_owned = false;
15961         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
15962         ChannelDetails_set_unspendable_punishment_reserve(&this_ptr_conv, val_conv);
15963 }
15964
15965 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1user_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
15966         LDKChannelDetails this_ptr_conv;
15967         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15968         this_ptr_conv.is_owned = false;
15969         int64_t ret_val = ChannelDetails_get_user_id(&this_ptr_conv);
15970         return ret_val;
15971 }
15972
15973 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1user_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15974         LDKChannelDetails this_ptr_conv;
15975         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15976         this_ptr_conv.is_owned = false;
15977         ChannelDetails_set_user_id(&this_ptr_conv, val);
15978 }
15979
15980 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1outbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
15981         LDKChannelDetails this_ptr_conv;
15982         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15983         this_ptr_conv.is_owned = false;
15984         int64_t ret_val = ChannelDetails_get_outbound_capacity_msat(&this_ptr_conv);
15985         return ret_val;
15986 }
15987
15988 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1outbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15989         LDKChannelDetails this_ptr_conv;
15990         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15991         this_ptr_conv.is_owned = false;
15992         ChannelDetails_set_outbound_capacity_msat(&this_ptr_conv, val);
15993 }
15994
15995 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
15996         LDKChannelDetails this_ptr_conv;
15997         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15998         this_ptr_conv.is_owned = false;
15999         int64_t ret_val = ChannelDetails_get_inbound_capacity_msat(&this_ptr_conv);
16000         return ret_val;
16001 }
16002
16003 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1inbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16004         LDKChannelDetails this_ptr_conv;
16005         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16006         this_ptr_conv.is_owned = false;
16007         ChannelDetails_set_inbound_capacity_msat(&this_ptr_conv, val);
16008 }
16009
16010 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1confirmations_1required(JNIEnv *env, jclass clz, int64_t this_ptr) {
16011         LDKChannelDetails this_ptr_conv;
16012         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16013         this_ptr_conv.is_owned = false;
16014         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
16015         *ret_copy = ChannelDetails_get_confirmations_required(&this_ptr_conv);
16016         uint64_t ret_ref = (uint64_t)ret_copy;
16017         return ret_ref;
16018 }
16019
16020 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1confirmations_1required(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16021         LDKChannelDetails this_ptr_conv;
16022         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16023         this_ptr_conv.is_owned = false;
16024         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(((uint64_t)val) & ~1);
16025         ChannelDetails_set_confirmations_required(&this_ptr_conv, val_conv);
16026 }
16027
16028 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1force_1close_1spend_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
16029         LDKChannelDetails this_ptr_conv;
16030         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16031         this_ptr_conv.is_owned = false;
16032         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
16033         *ret_copy = ChannelDetails_get_force_close_spend_delay(&this_ptr_conv);
16034         uint64_t ret_ref = (uint64_t)ret_copy;
16035         return ret_ref;
16036 }
16037
16038 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) {
16039         LDKChannelDetails this_ptr_conv;
16040         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16041         this_ptr_conv.is_owned = false;
16042         LDKCOption_u16Z val_conv = *(LDKCOption_u16Z*)(((uint64_t)val) & ~1);
16043         ChannelDetails_set_force_close_spend_delay(&this_ptr_conv, val_conv);
16044 }
16045
16046 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_ptr) {
16047         LDKChannelDetails this_ptr_conv;
16048         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16049         this_ptr_conv.is_owned = false;
16050         jboolean ret_val = ChannelDetails_get_is_outbound(&this_ptr_conv);
16051         return ret_val;
16052 }
16053
16054 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
16055         LDKChannelDetails this_ptr_conv;
16056         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16057         this_ptr_conv.is_owned = false;
16058         ChannelDetails_set_is_outbound(&this_ptr_conv, val);
16059 }
16060
16061 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1funding_1locked(JNIEnv *env, jclass clz, int64_t this_ptr) {
16062         LDKChannelDetails this_ptr_conv;
16063         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16064         this_ptr_conv.is_owned = false;
16065         jboolean ret_val = ChannelDetails_get_is_funding_locked(&this_ptr_conv);
16066         return ret_val;
16067 }
16068
16069 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1funding_1locked(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
16070         LDKChannelDetails this_ptr_conv;
16071         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16072         this_ptr_conv.is_owned = false;
16073         ChannelDetails_set_is_funding_locked(&this_ptr_conv, val);
16074 }
16075
16076 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1usable(JNIEnv *env, jclass clz, int64_t this_ptr) {
16077         LDKChannelDetails this_ptr_conv;
16078         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16079         this_ptr_conv.is_owned = false;
16080         jboolean ret_val = ChannelDetails_get_is_usable(&this_ptr_conv);
16081         return ret_val;
16082 }
16083
16084 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1usable(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
16085         LDKChannelDetails this_ptr_conv;
16086         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16087         this_ptr_conv.is_owned = false;
16088         ChannelDetails_set_is_usable(&this_ptr_conv, val);
16089 }
16090
16091 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1public(JNIEnv *env, jclass clz, int64_t this_ptr) {
16092         LDKChannelDetails this_ptr_conv;
16093         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16094         this_ptr_conv.is_owned = false;
16095         jboolean ret_val = ChannelDetails_get_is_public(&this_ptr_conv);
16096         return ret_val;
16097 }
16098
16099 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1public(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
16100         LDKChannelDetails this_ptr_conv;
16101         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16102         this_ptr_conv.is_owned = false;
16103         ChannelDetails_set_is_public(&this_ptr_conv, val);
16104 }
16105
16106 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int64_t counterparty_arg, int64_t funding_txo_arg, int64_t short_channel_id_arg, int64_t channel_value_satoshis_arg, int64_t unspendable_punishment_reserve_arg, int64_t user_id_arg, int64_t outbound_capacity_msat_arg, int64_t inbound_capacity_msat_arg, int64_t confirmations_required_arg, int64_t force_close_spend_delay_arg, jboolean is_outbound_arg, jboolean is_funding_locked_arg, jboolean is_usable_arg, jboolean is_public_arg) {
16107         LDKThirtyTwoBytes channel_id_arg_ref;
16108         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
16109         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
16110         LDKChannelCounterparty counterparty_arg_conv;
16111         counterparty_arg_conv.inner = (void*)(counterparty_arg & (~1));
16112         counterparty_arg_conv.is_owned = (counterparty_arg & 1) || (counterparty_arg == 0);
16113         counterparty_arg_conv = ChannelCounterparty_clone(&counterparty_arg_conv);
16114         LDKOutPoint funding_txo_arg_conv;
16115         funding_txo_arg_conv.inner = (void*)(funding_txo_arg & (~1));
16116         funding_txo_arg_conv.is_owned = (funding_txo_arg & 1) || (funding_txo_arg == 0);
16117         funding_txo_arg_conv = OutPoint_clone(&funding_txo_arg_conv);
16118         LDKCOption_u64Z short_channel_id_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)short_channel_id_arg) & ~1);
16119         LDKCOption_u64Z unspendable_punishment_reserve_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)unspendable_punishment_reserve_arg) & ~1);
16120         LDKCOption_u32Z confirmations_required_arg_conv = *(LDKCOption_u32Z*)(((uint64_t)confirmations_required_arg) & ~1);
16121         LDKCOption_u16Z force_close_spend_delay_arg_conv = *(LDKCOption_u16Z*)(((uint64_t)force_close_spend_delay_arg) & ~1);
16122         LDKChannelDetails ret_var = ChannelDetails_new(channel_id_arg_ref, counterparty_arg_conv, funding_txo_arg_conv, short_channel_id_arg_conv, channel_value_satoshis_arg, unspendable_punishment_reserve_arg_conv, user_id_arg, outbound_capacity_msat_arg, inbound_capacity_msat_arg, confirmations_required_arg_conv, force_close_spend_delay_arg_conv, is_outbound_arg, is_funding_locked_arg, is_usable_arg, is_public_arg);
16123         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16124         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16125         uint64_t ret_ref = (uint64_t)ret_var.inner;
16126         if (ret_var.is_owned) {
16127                 ret_ref |= 1;
16128         }
16129         return ret_ref;
16130 }
16131
16132 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16133         LDKChannelDetails orig_conv;
16134         orig_conv.inner = (void*)(orig & (~1));
16135         orig_conv.is_owned = false;
16136         LDKChannelDetails ret_var = ChannelDetails_clone(&orig_conv);
16137         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16138         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16139         uint64_t ret_ref = (uint64_t)ret_var.inner;
16140         if (ret_var.is_owned) {
16141                 ret_ref |= 1;
16142         }
16143         return ret_ref;
16144 }
16145
16146 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
16147         if ((this_ptr & 1) != 0) return;
16148         LDKPaymentSendFailure this_ptr_conv = *(LDKPaymentSendFailure*)(((uint64_t)this_ptr) & ~1);
16149         FREE((void*)this_ptr);
16150         PaymentSendFailure_free(this_ptr_conv);
16151 }
16152
16153 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16154         LDKPaymentSendFailure* orig_conv = (LDKPaymentSendFailure*)orig;
16155         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
16156         *ret_copy = PaymentSendFailure_clone(orig_conv);
16157         uint64_t ret_ref = (uint64_t)ret_copy;
16158         return ret_ref;
16159 }
16160
16161 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) {
16162         LDKFeeEstimator fee_est_conv = *(LDKFeeEstimator*)(((uint64_t)fee_est) & ~1);
16163         if (fee_est_conv.free == LDKFeeEstimator_JCalls_free) {
16164                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16165                 LDKFeeEstimator_JCalls_clone(fee_est_conv.this_arg);
16166         }
16167         LDKWatch chain_monitor_conv = *(LDKWatch*)(((uint64_t)chain_monitor) & ~1);
16168         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
16169                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16170                 LDKWatch_JCalls_clone(chain_monitor_conv.this_arg);
16171         }
16172         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)tx_broadcaster) & ~1);
16173         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
16174                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16175                 LDKBroadcasterInterface_JCalls_clone(tx_broadcaster_conv.this_arg);
16176         }
16177         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
16178         if (logger_conv.free == LDKLogger_JCalls_free) {
16179                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16180                 LDKLogger_JCalls_clone(logger_conv.this_arg);
16181         }
16182         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
16183         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
16184                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16185                 LDKKeysInterface_JCalls_clone(keys_manager_conv.this_arg);
16186         }
16187         LDKUserConfig config_conv;
16188         config_conv.inner = (void*)(config & (~1));
16189         config_conv.is_owned = (config & 1) || (config == 0);
16190         config_conv = UserConfig_clone(&config_conv);
16191         LDKChainParameters params_conv;
16192         params_conv.inner = (void*)(params & (~1));
16193         params_conv.is_owned = (params & 1) || (params == 0);
16194         params_conv = ChainParameters_clone(&params_conv);
16195         LDKChannelManager ret_var = ChannelManager_new(fee_est_conv, chain_monitor_conv, tx_broadcaster_conv, logger_conv, keys_manager_conv, config_conv, params_conv);
16196         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16197         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16198         uint64_t ret_ref = (uint64_t)ret_var.inner;
16199         if (ret_var.is_owned) {
16200                 ret_ref |= 1;
16201         }
16202         return ret_ref;
16203 }
16204
16205 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1current_1default_1configuration(JNIEnv *env, jclass clz, int64_t this_arg) {
16206         LDKChannelManager this_arg_conv;
16207         this_arg_conv.inner = (void*)(this_arg & (~1));
16208         this_arg_conv.is_owned = false;
16209         LDKUserConfig ret_var = ChannelManager_get_current_default_configuration(&this_arg_conv);
16210         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16211         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16212         uint64_t ret_ref = (uint64_t)ret_var.inner;
16213         if (ret_var.is_owned) {
16214                 ret_ref |= 1;
16215         }
16216         return ret_ref;
16217 }
16218
16219 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1create_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_network_key, int64_t channel_value_satoshis, int64_t push_msat, int64_t user_id, int64_t override_config) {
16220         LDKChannelManager this_arg_conv;
16221         this_arg_conv.inner = (void*)(this_arg & (~1));
16222         this_arg_conv.is_owned = false;
16223         LDKPublicKey their_network_key_ref;
16224         CHECK((*env)->GetArrayLength(env, their_network_key) == 33);
16225         (*env)->GetByteArrayRegion(env, their_network_key, 0, 33, their_network_key_ref.compressed_form);
16226         LDKUserConfig override_config_conv;
16227         override_config_conv.inner = (void*)(override_config & (~1));
16228         override_config_conv.is_owned = (override_config & 1) || (override_config == 0);
16229         override_config_conv = UserConfig_clone(&override_config_conv);
16230         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
16231         *ret_conv = ChannelManager_create_channel(&this_arg_conv, their_network_key_ref, channel_value_satoshis, push_msat, user_id, override_config_conv);
16232         return (uint64_t)ret_conv;
16233 }
16234
16235 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
16236         LDKChannelManager this_arg_conv;
16237         this_arg_conv.inner = (void*)(this_arg & (~1));
16238         this_arg_conv.is_owned = false;
16239         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_channels(&this_arg_conv);
16240         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
16241         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
16242         for (size_t q = 0; q < ret_var.datalen; q++) {
16243                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
16244                 CHECK((((uint64_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16245                 CHECK((((uint64_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16246                 uint64_t ret_conv_16_ref = (uint64_t)ret_conv_16_var.inner;
16247                 if (ret_conv_16_var.is_owned) {
16248                         ret_conv_16_ref |= 1;
16249                 }
16250                 ret_arr_ptr[q] = ret_conv_16_ref;
16251         }
16252         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
16253         FREE(ret_var.data);
16254         return ret_arr;
16255 }
16256
16257 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1usable_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
16258         LDKChannelManager this_arg_conv;
16259         this_arg_conv.inner = (void*)(this_arg & (~1));
16260         this_arg_conv.is_owned = false;
16261         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_usable_channels(&this_arg_conv);
16262         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
16263         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
16264         for (size_t q = 0; q < ret_var.datalen; q++) {
16265                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
16266                 CHECK((((uint64_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16267                 CHECK((((uint64_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16268                 uint64_t ret_conv_16_ref = (uint64_t)ret_conv_16_var.inner;
16269                 if (ret_conv_16_var.is_owned) {
16270                         ret_conv_16_ref |= 1;
16271                 }
16272                 ret_arr_ptr[q] = ret_conv_16_ref;
16273         }
16274         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
16275         FREE(ret_var.data);
16276         return ret_arr;
16277 }
16278
16279 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1close_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray channel_id) {
16280         LDKChannelManager this_arg_conv;
16281         this_arg_conv.inner = (void*)(this_arg & (~1));
16282         this_arg_conv.is_owned = false;
16283         unsigned char channel_id_arr[32];
16284         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
16285         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
16286         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
16287         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
16288         *ret_conv = ChannelManager_close_channel(&this_arg_conv, channel_id_ref);
16289         return (uint64_t)ret_conv;
16290 }
16291
16292 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) {
16293         LDKChannelManager this_arg_conv;
16294         this_arg_conv.inner = (void*)(this_arg & (~1));
16295         this_arg_conv.is_owned = false;
16296         unsigned char channel_id_arr[32];
16297         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
16298         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
16299         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
16300         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
16301         *ret_conv = ChannelManager_force_close_channel(&this_arg_conv, channel_id_ref);
16302         return (uint64_t)ret_conv;
16303 }
16304
16305 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1force_1close_1all_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
16306         LDKChannelManager this_arg_conv;
16307         this_arg_conv.inner = (void*)(this_arg & (~1));
16308         this_arg_conv.is_owned = false;
16309         ChannelManager_force_close_all_channels(&this_arg_conv);
16310 }
16311
16312 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) {
16313         LDKChannelManager this_arg_conv;
16314         this_arg_conv.inner = (void*)(this_arg & (~1));
16315         this_arg_conv.is_owned = false;
16316         LDKRoute route_conv;
16317         route_conv.inner = (void*)(route & (~1));
16318         route_conv.is_owned = false;
16319         LDKThirtyTwoBytes payment_hash_ref;
16320         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
16321         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
16322         LDKThirtyTwoBytes payment_secret_ref;
16323         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
16324         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
16325         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
16326         *ret_conv = ChannelManager_send_payment(&this_arg_conv, &route_conv, payment_hash_ref, payment_secret_ref);
16327         return (uint64_t)ret_conv;
16328 }
16329
16330 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) {
16331         LDKChannelManager this_arg_conv;
16332         this_arg_conv.inner = (void*)(this_arg & (~1));
16333         this_arg_conv.is_owned = false;
16334         unsigned char temporary_channel_id_arr[32];
16335         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
16336         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_arr);
16337         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
16338         LDKTransaction funding_transaction_ref;
16339         funding_transaction_ref.datalen = (*env)->GetArrayLength(env, funding_transaction);
16340         funding_transaction_ref.data = MALLOC(funding_transaction_ref.datalen, "LDKTransaction Bytes");
16341         (*env)->GetByteArrayRegion(env, funding_transaction, 0, funding_transaction_ref.datalen, funding_transaction_ref.data);
16342         funding_transaction_ref.data_is_owned = true;
16343         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
16344         *ret_conv = ChannelManager_funding_transaction_generated(&this_arg_conv, temporary_channel_id_ref, funding_transaction_ref);
16345         return (uint64_t)ret_conv;
16346 }
16347
16348 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) {
16349         LDKChannelManager this_arg_conv;
16350         this_arg_conv.inner = (void*)(this_arg & (~1));
16351         this_arg_conv.is_owned = false;
16352         LDKThreeBytes rgb_ref;
16353         CHECK((*env)->GetArrayLength(env, rgb) == 3);
16354         (*env)->GetByteArrayRegion(env, rgb, 0, 3, rgb_ref.data);
16355         LDKThirtyTwoBytes alias_ref;
16356         CHECK((*env)->GetArrayLength(env, alias) == 32);
16357         (*env)->GetByteArrayRegion(env, alias, 0, 32, alias_ref.data);
16358         LDKCVec_NetAddressZ addresses_constr;
16359         addresses_constr.datalen = (*env)->GetArrayLength(env, addresses);
16360         if (addresses_constr.datalen > 0)
16361                 addresses_constr.data = MALLOC(addresses_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
16362         else
16363                 addresses_constr.data = NULL;
16364         int64_t* addresses_vals = (*env)->GetLongArrayElements (env, addresses, NULL);
16365         for (size_t m = 0; m < addresses_constr.datalen; m++) {
16366                 int64_t addresses_conv_12 = addresses_vals[m];
16367                 LDKNetAddress addresses_conv_12_conv = *(LDKNetAddress*)(((uint64_t)addresses_conv_12) & ~1);
16368                 addresses_constr.data[m] = addresses_conv_12_conv;
16369         }
16370         (*env)->ReleaseLongArrayElements(env, addresses, addresses_vals, 0);
16371         ChannelManager_broadcast_node_announcement(&this_arg_conv, rgb_ref, alias_ref, addresses_constr);
16372 }
16373
16374 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1process_1pending_1htlc_1forwards(JNIEnv *env, jclass clz, int64_t this_arg) {
16375         LDKChannelManager this_arg_conv;
16376         this_arg_conv.inner = (void*)(this_arg & (~1));
16377         this_arg_conv.is_owned = false;
16378         ChannelManager_process_pending_htlc_forwards(&this_arg_conv);
16379 }
16380
16381 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1timer_1tick_1occurred(JNIEnv *env, jclass clz, int64_t this_arg) {
16382         LDKChannelManager this_arg_conv;
16383         this_arg_conv.inner = (void*)(this_arg & (~1));
16384         this_arg_conv.is_owned = false;
16385         ChannelManager_timer_tick_occurred(&this_arg_conv);
16386 }
16387
16388 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelManager_1fail_1htlc_1backwards(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_hash) {
16389         LDKChannelManager this_arg_conv;
16390         this_arg_conv.inner = (void*)(this_arg & (~1));
16391         this_arg_conv.is_owned = false;
16392         unsigned char payment_hash_arr[32];
16393         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
16394         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_arr);
16395         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
16396         jboolean ret_val = ChannelManager_fail_htlc_backwards(&this_arg_conv, payment_hash_ref);
16397         return ret_val;
16398 }
16399
16400 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelManager_1claim_1funds(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_preimage) {
16401         LDKChannelManager this_arg_conv;
16402         this_arg_conv.inner = (void*)(this_arg & (~1));
16403         this_arg_conv.is_owned = false;
16404         LDKThirtyTwoBytes payment_preimage_ref;
16405         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
16406         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
16407         jboolean ret_val = ChannelManager_claim_funds(&this_arg_conv, payment_preimage_ref);
16408         return ret_val;
16409 }
16410
16411 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1our_1node_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
16412         LDKChannelManager this_arg_conv;
16413         this_arg_conv.inner = (void*)(this_arg & (~1));
16414         this_arg_conv.is_owned = false;
16415         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
16416         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelManager_get_our_node_id(&this_arg_conv).compressed_form);
16417         return ret_arr;
16418 }
16419
16420 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) {
16421         LDKChannelManager this_arg_conv;
16422         this_arg_conv.inner = (void*)(this_arg & (~1));
16423         this_arg_conv.is_owned = false;
16424         LDKOutPoint funding_txo_conv;
16425         funding_txo_conv.inner = (void*)(funding_txo & (~1));
16426         funding_txo_conv.is_owned = false;
16427         ChannelManager_channel_monitor_updated(&this_arg_conv, &funding_txo_conv, highest_applied_update_id);
16428 }
16429
16430 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) {
16431         LDKChannelManager this_arg_conv;
16432         this_arg_conv.inner = (void*)(this_arg & (~1));
16433         this_arg_conv.is_owned = false;
16434         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(((uint64_t)min_value_msat) & ~1);
16435         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
16436         *ret_ref = ChannelManager_create_inbound_payment(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs, user_payment_id);
16437         return (uint64_t)ret_ref;
16438 }
16439
16440 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) {
16441         LDKChannelManager this_arg_conv;
16442         this_arg_conv.inner = (void*)(this_arg & (~1));
16443         this_arg_conv.is_owned = false;
16444         LDKThirtyTwoBytes payment_hash_ref;
16445         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
16446         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
16447         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(((uint64_t)min_value_msat) & ~1);
16448         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
16449         *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);
16450         return (uint64_t)ret_conv;
16451 }
16452
16453 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
16454         LDKChannelManager this_arg_conv;
16455         this_arg_conv.inner = (void*)(this_arg & (~1));
16456         this_arg_conv.is_owned = false;
16457         LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
16458         *ret = ChannelManager_as_MessageSendEventsProvider(&this_arg_conv);
16459         return (uint64_t)ret;
16460 }
16461
16462 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1EventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
16463         LDKChannelManager this_arg_conv;
16464         this_arg_conv.inner = (void*)(this_arg & (~1));
16465         this_arg_conv.is_owned = false;
16466         LDKEventsProvider* ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
16467         *ret = ChannelManager_as_EventsProvider(&this_arg_conv);
16468         return (uint64_t)ret;
16469 }
16470
16471 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Listen(JNIEnv *env, jclass clz, int64_t this_arg) {
16472         LDKChannelManager this_arg_conv;
16473         this_arg_conv.inner = (void*)(this_arg & (~1));
16474         this_arg_conv.is_owned = false;
16475         LDKListen* ret = MALLOC(sizeof(LDKListen), "LDKListen");
16476         *ret = ChannelManager_as_Listen(&this_arg_conv);
16477         return (uint64_t)ret;
16478 }
16479
16480 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Confirm(JNIEnv *env, jclass clz, int64_t this_arg) {
16481         LDKChannelManager this_arg_conv;
16482         this_arg_conv.inner = (void*)(this_arg & (~1));
16483         this_arg_conv.is_owned = false;
16484         LDKConfirm* ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
16485         *ret = ChannelManager_as_Confirm(&this_arg_conv);
16486         return (uint64_t)ret;
16487 }
16488
16489 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) {
16490         LDKChannelManager this_arg_conv;
16491         this_arg_conv.inner = (void*)(this_arg & (~1));
16492         this_arg_conv.is_owned = false;
16493         jboolean ret_val = ChannelManager_await_persistable_update_timeout(&this_arg_conv, max_wait);
16494         return ret_val;
16495 }
16496
16497 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1await_1persistable_1update(JNIEnv *env, jclass clz, int64_t this_arg) {
16498         LDKChannelManager this_arg_conv;
16499         this_arg_conv.inner = (void*)(this_arg & (~1));
16500         this_arg_conv.is_owned = false;
16501         ChannelManager_await_persistable_update(&this_arg_conv);
16502 }
16503
16504 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1current_1best_1block(JNIEnv *env, jclass clz, int64_t this_arg) {
16505         LDKChannelManager this_arg_conv;
16506         this_arg_conv.inner = (void*)(this_arg & (~1));
16507         this_arg_conv.is_owned = false;
16508         LDKBestBlock ret_var = ChannelManager_current_best_block(&this_arg_conv);
16509         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16510         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16511         uint64_t ret_ref = (uint64_t)ret_var.inner;
16512         if (ret_var.is_owned) {
16513                 ret_ref |= 1;
16514         }
16515         return ret_ref;
16516 }
16517
16518 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1ChannelMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
16519         LDKChannelManager this_arg_conv;
16520         this_arg_conv.inner = (void*)(this_arg & (~1));
16521         this_arg_conv.is_owned = false;
16522         LDKChannelMessageHandler* ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
16523         *ret = ChannelManager_as_ChannelMessageHandler(&this_arg_conv);
16524         return (uint64_t)ret;
16525 }
16526
16527 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1write(JNIEnv *env, jclass clz, int64_t obj) {
16528         LDKChannelManager obj_conv;
16529         obj_conv.inner = (void*)(obj & (~1));
16530         obj_conv.is_owned = false;
16531         LDKCVec_u8Z ret_var = ChannelManager_write(&obj_conv);
16532         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
16533         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
16534         CVec_u8Z_free(ret_var);
16535         return ret_arr;
16536 }
16537
16538 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
16539         LDKChannelManagerReadArgs this_obj_conv;
16540         this_obj_conv.inner = (void*)(this_obj & (~1));
16541         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16542         ChannelManagerReadArgs_free(this_obj_conv);
16543 }
16544
16545 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1keys_1manager(JNIEnv *env, jclass clz, int64_t this_ptr) {
16546         LDKChannelManagerReadArgs this_ptr_conv;
16547         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16548         this_ptr_conv.is_owned = false;
16549         uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_keys_manager(&this_ptr_conv);
16550         return ret_ret;
16551 }
16552
16553 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1keys_1manager(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16554         LDKChannelManagerReadArgs this_ptr_conv;
16555         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16556         this_ptr_conv.is_owned = false;
16557         LDKKeysInterface val_conv = *(LDKKeysInterface*)(((uint64_t)val) & ~1);
16558         if (val_conv.free == LDKKeysInterface_JCalls_free) {
16559                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16560                 LDKKeysInterface_JCalls_clone(val_conv.this_arg);
16561         }
16562         ChannelManagerReadArgs_set_keys_manager(&this_ptr_conv, val_conv);
16563 }
16564
16565 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1fee_1estimator(JNIEnv *env, jclass clz, int64_t this_ptr) {
16566         LDKChannelManagerReadArgs this_ptr_conv;
16567         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16568         this_ptr_conv.is_owned = false;
16569         uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_fee_estimator(&this_ptr_conv);
16570         return ret_ret;
16571 }
16572
16573 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1fee_1estimator(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16574         LDKChannelManagerReadArgs this_ptr_conv;
16575         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16576         this_ptr_conv.is_owned = false;
16577         LDKFeeEstimator val_conv = *(LDKFeeEstimator*)(((uint64_t)val) & ~1);
16578         if (val_conv.free == LDKFeeEstimator_JCalls_free) {
16579                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16580                 LDKFeeEstimator_JCalls_clone(val_conv.this_arg);
16581         }
16582         ChannelManagerReadArgs_set_fee_estimator(&this_ptr_conv, val_conv);
16583 }
16584
16585 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1chain_1monitor(JNIEnv *env, jclass clz, int64_t this_ptr) {
16586         LDKChannelManagerReadArgs this_ptr_conv;
16587         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16588         this_ptr_conv.is_owned = false;
16589         uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_chain_monitor(&this_ptr_conv);
16590         return ret_ret;
16591 }
16592
16593 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1chain_1monitor(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16594         LDKChannelManagerReadArgs this_ptr_conv;
16595         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16596         this_ptr_conv.is_owned = false;
16597         LDKWatch val_conv = *(LDKWatch*)(((uint64_t)val) & ~1);
16598         if (val_conv.free == LDKWatch_JCalls_free) {
16599                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16600                 LDKWatch_JCalls_clone(val_conv.this_arg);
16601         }
16602         ChannelManagerReadArgs_set_chain_monitor(&this_ptr_conv, val_conv);
16603 }
16604
16605 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1tx_1broadcaster(JNIEnv *env, jclass clz, int64_t this_ptr) {
16606         LDKChannelManagerReadArgs this_ptr_conv;
16607         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16608         this_ptr_conv.is_owned = false;
16609         uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_tx_broadcaster(&this_ptr_conv);
16610         return ret_ret;
16611 }
16612
16613 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1tx_1broadcaster(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16614         LDKChannelManagerReadArgs this_ptr_conv;
16615         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16616         this_ptr_conv.is_owned = false;
16617         LDKBroadcasterInterface val_conv = *(LDKBroadcasterInterface*)(((uint64_t)val) & ~1);
16618         if (val_conv.free == LDKBroadcasterInterface_JCalls_free) {
16619                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16620                 LDKBroadcasterInterface_JCalls_clone(val_conv.this_arg);
16621         }
16622         ChannelManagerReadArgs_set_tx_broadcaster(&this_ptr_conv, val_conv);
16623 }
16624
16625 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1logger(JNIEnv *env, jclass clz, int64_t this_ptr) {
16626         LDKChannelManagerReadArgs this_ptr_conv;
16627         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16628         this_ptr_conv.is_owned = false;
16629         uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_logger(&this_ptr_conv);
16630         return ret_ret;
16631 }
16632
16633 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1logger(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16634         LDKChannelManagerReadArgs this_ptr_conv;
16635         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16636         this_ptr_conv.is_owned = false;
16637         LDKLogger val_conv = *(LDKLogger*)(((uint64_t)val) & ~1);
16638         if (val_conv.free == LDKLogger_JCalls_free) {
16639                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16640                 LDKLogger_JCalls_clone(val_conv.this_arg);
16641         }
16642         ChannelManagerReadArgs_set_logger(&this_ptr_conv, val_conv);
16643 }
16644
16645 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1default_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
16646         LDKChannelManagerReadArgs this_ptr_conv;
16647         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16648         this_ptr_conv.is_owned = false;
16649         LDKUserConfig ret_var = ChannelManagerReadArgs_get_default_config(&this_ptr_conv);
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_ChannelManagerReadArgs_1set_1default_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16660         LDKChannelManagerReadArgs this_ptr_conv;
16661         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16662         this_ptr_conv.is_owned = false;
16663         LDKUserConfig val_conv;
16664         val_conv.inner = (void*)(val & (~1));
16665         val_conv.is_owned = (val & 1) || (val == 0);
16666         val_conv = UserConfig_clone(&val_conv);
16667         ChannelManagerReadArgs_set_default_config(&this_ptr_conv, val_conv);
16668 }
16669
16670 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) {
16671         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
16672         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
16673                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16674                 LDKKeysInterface_JCalls_clone(keys_manager_conv.this_arg);
16675         }
16676         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
16677         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
16678                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16679                 LDKFeeEstimator_JCalls_clone(fee_estimator_conv.this_arg);
16680         }
16681         LDKWatch chain_monitor_conv = *(LDKWatch*)(((uint64_t)chain_monitor) & ~1);
16682         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
16683                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16684                 LDKWatch_JCalls_clone(chain_monitor_conv.this_arg);
16685         }
16686         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)tx_broadcaster) & ~1);
16687         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
16688                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16689                 LDKBroadcasterInterface_JCalls_clone(tx_broadcaster_conv.this_arg);
16690         }
16691         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
16692         if (logger_conv.free == LDKLogger_JCalls_free) {
16693                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16694                 LDKLogger_JCalls_clone(logger_conv.this_arg);
16695         }
16696         LDKUserConfig default_config_conv;
16697         default_config_conv.inner = (void*)(default_config & (~1));
16698         default_config_conv.is_owned = (default_config & 1) || (default_config == 0);
16699         default_config_conv = UserConfig_clone(&default_config_conv);
16700         LDKCVec_ChannelMonitorZ channel_monitors_constr;
16701         channel_monitors_constr.datalen = (*env)->GetArrayLength(env, channel_monitors);
16702         if (channel_monitors_constr.datalen > 0)
16703                 channel_monitors_constr.data = MALLOC(channel_monitors_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
16704         else
16705                 channel_monitors_constr.data = NULL;
16706         int64_t* channel_monitors_vals = (*env)->GetLongArrayElements (env, channel_monitors, NULL);
16707         for (size_t q = 0; q < channel_monitors_constr.datalen; q++) {
16708                 int64_t channel_monitors_conv_16 = channel_monitors_vals[q];
16709                 LDKChannelMonitor channel_monitors_conv_16_conv;
16710                 channel_monitors_conv_16_conv.inner = (void*)(channel_monitors_conv_16 & (~1));
16711                 channel_monitors_conv_16_conv.is_owned = (channel_monitors_conv_16 & 1) || (channel_monitors_conv_16 == 0);
16712                 channel_monitors_constr.data[q] = channel_monitors_conv_16_conv;
16713         }
16714         (*env)->ReleaseLongArrayElements(env, channel_monitors, channel_monitors_vals, 0);
16715         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);
16716         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16717         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16718         uint64_t ret_ref = (uint64_t)ret_var.inner;
16719         if (ret_var.is_owned) {
16720                 ret_ref |= 1;
16721         }
16722         return ret_ref;
16723 }
16724
16725 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
16726         LDKu8slice ser_ref;
16727         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
16728         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
16729         LDKChannelManagerReadArgs arg_conv;
16730         arg_conv.inner = (void*)(arg & (~1));
16731         arg_conv.is_owned = (arg & 1) || (arg == 0);
16732         // Warning: we need a move here but no clone is available for LDKChannelManagerReadArgs
16733         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
16734         *ret_conv = C2Tuple_BlockHashChannelManagerZ_read(ser_ref, arg_conv);
16735         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
16736         return (uint64_t)ret_conv;
16737 }
16738
16739 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DecodeError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
16740         LDKDecodeError this_obj_conv;
16741         this_obj_conv.inner = (void*)(this_obj & (~1));
16742         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16743         DecodeError_free(this_obj_conv);
16744 }
16745
16746 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16747         LDKDecodeError orig_conv;
16748         orig_conv.inner = (void*)(orig & (~1));
16749         orig_conv.is_owned = false;
16750         LDKDecodeError ret_var = DecodeError_clone(&orig_conv);
16751         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16752         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16753         uint64_t ret_ref = (uint64_t)ret_var.inner;
16754         if (ret_var.is_owned) {
16755                 ret_ref |= 1;
16756         }
16757         return ret_ref;
16758 }
16759
16760 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
16761         LDKInit this_obj_conv;
16762         this_obj_conv.inner = (void*)(this_obj & (~1));
16763         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16764         Init_free(this_obj_conv);
16765 }
16766
16767 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
16768         LDKInit this_ptr_conv;
16769         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16770         this_ptr_conv.is_owned = false;
16771         LDKInitFeatures ret_var = Init_get_features(&this_ptr_conv);
16772         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16773         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16774         uint64_t ret_ref = (uint64_t)ret_var.inner;
16775         if (ret_var.is_owned) {
16776                 ret_ref |= 1;
16777         }
16778         return ret_ref;
16779 }
16780
16781 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16782         LDKInit this_ptr_conv;
16783         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16784         this_ptr_conv.is_owned = false;
16785         LDKInitFeatures val_conv;
16786         val_conv.inner = (void*)(val & (~1));
16787         val_conv.is_owned = (val & 1) || (val == 0);
16788         val_conv = InitFeatures_clone(&val_conv);
16789         Init_set_features(&this_ptr_conv, val_conv);
16790 }
16791
16792 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1new(JNIEnv *env, jclass clz, int64_t features_arg) {
16793         LDKInitFeatures features_arg_conv;
16794         features_arg_conv.inner = (void*)(features_arg & (~1));
16795         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
16796         features_arg_conv = InitFeatures_clone(&features_arg_conv);
16797         LDKInit ret_var = Init_new(features_arg_conv);
16798         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16799         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16800         uint64_t ret_ref = (uint64_t)ret_var.inner;
16801         if (ret_var.is_owned) {
16802                 ret_ref |= 1;
16803         }
16804         return ret_ref;
16805 }
16806
16807 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16808         LDKInit orig_conv;
16809         orig_conv.inner = (void*)(orig & (~1));
16810         orig_conv.is_owned = false;
16811         LDKInit ret_var = Init_clone(&orig_conv);
16812         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16813         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16814         uint64_t ret_ref = (uint64_t)ret_var.inner;
16815         if (ret_var.is_owned) {
16816                 ret_ref |= 1;
16817         }
16818         return ret_ref;
16819 }
16820
16821 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
16822         LDKErrorMessage this_obj_conv;
16823         this_obj_conv.inner = (void*)(this_obj & (~1));
16824         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16825         ErrorMessage_free(this_obj_conv);
16826 }
16827
16828 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
16829         LDKErrorMessage this_ptr_conv;
16830         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16831         this_ptr_conv.is_owned = false;
16832         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
16833         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ErrorMessage_get_channel_id(&this_ptr_conv));
16834         return ret_arr;
16835 }
16836
16837 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
16838         LDKErrorMessage this_ptr_conv;
16839         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16840         this_ptr_conv.is_owned = false;
16841         LDKThirtyTwoBytes val_ref;
16842         CHECK((*env)->GetArrayLength(env, val) == 32);
16843         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
16844         ErrorMessage_set_channel_id(&this_ptr_conv, val_ref);
16845 }
16846
16847 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1get_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
16848         LDKErrorMessage this_ptr_conv;
16849         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16850         this_ptr_conv.is_owned = false;
16851         LDKStr ret_str = ErrorMessage_get_data(&this_ptr_conv);
16852         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
16853         return ret_conv;
16854 }
16855
16856 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1set_1data(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
16857         LDKErrorMessage this_ptr_conv;
16858         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16859         this_ptr_conv.is_owned = false;
16860         LDKStr val_conv = java_to_owned_str(env, val);
16861         ErrorMessage_set_data(&this_ptr_conv, val_conv);
16862 }
16863
16864 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, jstring data_arg) {
16865         LDKThirtyTwoBytes channel_id_arg_ref;
16866         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
16867         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
16868         LDKStr data_arg_conv = java_to_owned_str(env, data_arg);
16869         LDKErrorMessage ret_var = ErrorMessage_new(channel_id_arg_ref, data_arg_conv);
16870         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16871         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16872         uint64_t ret_ref = (uint64_t)ret_var.inner;
16873         if (ret_var.is_owned) {
16874                 ret_ref |= 1;
16875         }
16876         return ret_ref;
16877 }
16878
16879 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16880         LDKErrorMessage orig_conv;
16881         orig_conv.inner = (void*)(orig & (~1));
16882         orig_conv.is_owned = false;
16883         LDKErrorMessage ret_var = ErrorMessage_clone(&orig_conv);
16884         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16885         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16886         uint64_t ret_ref = (uint64_t)ret_var.inner;
16887         if (ret_var.is_owned) {
16888                 ret_ref |= 1;
16889         }
16890         return ret_ref;
16891 }
16892
16893 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
16894         LDKPing this_obj_conv;
16895         this_obj_conv.inner = (void*)(this_obj & (~1));
16896         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16897         Ping_free(this_obj_conv);
16898 }
16899
16900 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Ping_1get_1ponglen(JNIEnv *env, jclass clz, int64_t this_ptr) {
16901         LDKPing this_ptr_conv;
16902         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16903         this_ptr_conv.is_owned = false;
16904         int16_t ret_val = Ping_get_ponglen(&this_ptr_conv);
16905         return ret_val;
16906 }
16907
16908 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1set_1ponglen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
16909         LDKPing this_ptr_conv;
16910         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16911         this_ptr_conv.is_owned = false;
16912         Ping_set_ponglen(&this_ptr_conv, val);
16913 }
16914
16915 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Ping_1get_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr) {
16916         LDKPing this_ptr_conv;
16917         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16918         this_ptr_conv.is_owned = false;
16919         int16_t ret_val = Ping_get_byteslen(&this_ptr_conv);
16920         return ret_val;
16921 }
16922
16923 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1set_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
16924         LDKPing this_ptr_conv;
16925         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16926         this_ptr_conv.is_owned = false;
16927         Ping_set_byteslen(&this_ptr_conv, val);
16928 }
16929
16930 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1new(JNIEnv *env, jclass clz, int16_t ponglen_arg, int16_t byteslen_arg) {
16931         LDKPing ret_var = Ping_new(ponglen_arg, byteslen_arg);
16932         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16933         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16934         uint64_t ret_ref = (uint64_t)ret_var.inner;
16935         if (ret_var.is_owned) {
16936                 ret_ref |= 1;
16937         }
16938         return ret_ref;
16939 }
16940
16941 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16942         LDKPing orig_conv;
16943         orig_conv.inner = (void*)(orig & (~1));
16944         orig_conv.is_owned = false;
16945         LDKPing ret_var = Ping_clone(&orig_conv);
16946         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16947         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16948         uint64_t ret_ref = (uint64_t)ret_var.inner;
16949         if (ret_var.is_owned) {
16950                 ret_ref |= 1;
16951         }
16952         return ret_ref;
16953 }
16954
16955 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Pong_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
16956         LDKPong this_obj_conv;
16957         this_obj_conv.inner = (void*)(this_obj & (~1));
16958         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16959         Pong_free(this_obj_conv);
16960 }
16961
16962 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Pong_1get_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr) {
16963         LDKPong this_ptr_conv;
16964         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16965         this_ptr_conv.is_owned = false;
16966         int16_t ret_val = Pong_get_byteslen(&this_ptr_conv);
16967         return ret_val;
16968 }
16969
16970 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Pong_1set_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
16971         LDKPong this_ptr_conv;
16972         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16973         this_ptr_conv.is_owned = false;
16974         Pong_set_byteslen(&this_ptr_conv, val);
16975 }
16976
16977 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1new(JNIEnv *env, jclass clz, int16_t byteslen_arg) {
16978         LDKPong ret_var = Pong_new(byteslen_arg);
16979         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16980         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16981         uint64_t ret_ref = (uint64_t)ret_var.inner;
16982         if (ret_var.is_owned) {
16983                 ret_ref |= 1;
16984         }
16985         return ret_ref;
16986 }
16987
16988 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16989         LDKPong orig_conv;
16990         orig_conv.inner = (void*)(orig & (~1));
16991         orig_conv.is_owned = false;
16992         LDKPong ret_var = Pong_clone(&orig_conv);
16993         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16994         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16995         uint64_t ret_ref = (uint64_t)ret_var.inner;
16996         if (ret_var.is_owned) {
16997                 ret_ref |= 1;
16998         }
16999         return ret_ref;
17000 }
17001
17002 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17003         LDKOpenChannel this_obj_conv;
17004         this_obj_conv.inner = (void*)(this_obj & (~1));
17005         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17006         OpenChannel_free(this_obj_conv);
17007 }
17008
17009 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
17010         LDKOpenChannel this_ptr_conv;
17011         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17012         this_ptr_conv.is_owned = false;
17013         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
17014         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OpenChannel_get_chain_hash(&this_ptr_conv));
17015         return ret_arr;
17016 }
17017
17018 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17019         LDKOpenChannel this_ptr_conv;
17020         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17021         this_ptr_conv.is_owned = false;
17022         LDKThirtyTwoBytes val_ref;
17023         CHECK((*env)->GetArrayLength(env, val) == 32);
17024         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
17025         OpenChannel_set_chain_hash(&this_ptr_conv, val_ref);
17026 }
17027
17028 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
17029         LDKOpenChannel this_ptr_conv;
17030         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17031         this_ptr_conv.is_owned = false;
17032         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
17033         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OpenChannel_get_temporary_channel_id(&this_ptr_conv));
17034         return ret_arr;
17035 }
17036
17037 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17038         LDKOpenChannel this_ptr_conv;
17039         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17040         this_ptr_conv.is_owned = false;
17041         LDKThirtyTwoBytes val_ref;
17042         CHECK((*env)->GetArrayLength(env, val) == 32);
17043         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
17044         OpenChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
17045 }
17046
17047 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
17048         LDKOpenChannel this_ptr_conv;
17049         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17050         this_ptr_conv.is_owned = false;
17051         int64_t ret_val = OpenChannel_get_funding_satoshis(&this_ptr_conv);
17052         return ret_val;
17053 }
17054
17055 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17056         LDKOpenChannel this_ptr_conv;
17057         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17058         this_ptr_conv.is_owned = false;
17059         OpenChannel_set_funding_satoshis(&this_ptr_conv, val);
17060 }
17061
17062 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1push_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
17063         LDKOpenChannel this_ptr_conv;
17064         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17065         this_ptr_conv.is_owned = false;
17066         int64_t ret_val = OpenChannel_get_push_msat(&this_ptr_conv);
17067         return ret_val;
17068 }
17069
17070 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1push_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17071         LDKOpenChannel this_ptr_conv;
17072         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17073         this_ptr_conv.is_owned = false;
17074         OpenChannel_set_push_msat(&this_ptr_conv, val);
17075 }
17076
17077 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
17078         LDKOpenChannel this_ptr_conv;
17079         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17080         this_ptr_conv.is_owned = false;
17081         int64_t ret_val = OpenChannel_get_dust_limit_satoshis(&this_ptr_conv);
17082         return ret_val;
17083 }
17084
17085 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17086         LDKOpenChannel this_ptr_conv;
17087         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17088         this_ptr_conv.is_owned = false;
17089         OpenChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
17090 }
17091
17092 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) {
17093         LDKOpenChannel this_ptr_conv;
17094         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17095         this_ptr_conv.is_owned = false;
17096         int64_t ret_val = OpenChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
17097         return ret_val;
17098 }
17099
17100 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) {
17101         LDKOpenChannel this_ptr_conv;
17102         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17103         this_ptr_conv.is_owned = false;
17104         OpenChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
17105 }
17106
17107 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
17108         LDKOpenChannel this_ptr_conv;
17109         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17110         this_ptr_conv.is_owned = false;
17111         int64_t ret_val = OpenChannel_get_channel_reserve_satoshis(&this_ptr_conv);
17112         return ret_val;
17113 }
17114
17115 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17116         LDKOpenChannel this_ptr_conv;
17117         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17118         this_ptr_conv.is_owned = false;
17119         OpenChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
17120 }
17121
17122 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
17123         LDKOpenChannel this_ptr_conv;
17124         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17125         this_ptr_conv.is_owned = false;
17126         int64_t ret_val = OpenChannel_get_htlc_minimum_msat(&this_ptr_conv);
17127         return ret_val;
17128 }
17129
17130 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17131         LDKOpenChannel this_ptr_conv;
17132         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17133         this_ptr_conv.is_owned = false;
17134         OpenChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
17135 }
17136
17137 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr) {
17138         LDKOpenChannel this_ptr_conv;
17139         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17140         this_ptr_conv.is_owned = false;
17141         int32_t ret_val = OpenChannel_get_feerate_per_kw(&this_ptr_conv);
17142         return ret_val;
17143 }
17144
17145 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
17146         LDKOpenChannel this_ptr_conv;
17147         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17148         this_ptr_conv.is_owned = false;
17149         OpenChannel_set_feerate_per_kw(&this_ptr_conv, val);
17150 }
17151
17152 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
17153         LDKOpenChannel this_ptr_conv;
17154         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17155         this_ptr_conv.is_owned = false;
17156         int16_t ret_val = OpenChannel_get_to_self_delay(&this_ptr_conv);
17157         return ret_val;
17158 }
17159
17160 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
17161         LDKOpenChannel this_ptr_conv;
17162         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17163         this_ptr_conv.is_owned = false;
17164         OpenChannel_set_to_self_delay(&this_ptr_conv, val);
17165 }
17166
17167 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
17168         LDKOpenChannel this_ptr_conv;
17169         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17170         this_ptr_conv.is_owned = false;
17171         int16_t ret_val = OpenChannel_get_max_accepted_htlcs(&this_ptr_conv);
17172         return ret_val;
17173 }
17174
17175 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
17176         LDKOpenChannel this_ptr_conv;
17177         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17178         this_ptr_conv.is_owned = false;
17179         OpenChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
17180 }
17181
17182 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
17183         LDKOpenChannel this_ptr_conv;
17184         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17185         this_ptr_conv.is_owned = false;
17186         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
17187         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_funding_pubkey(&this_ptr_conv).compressed_form);
17188         return ret_arr;
17189 }
17190
17191 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17192         LDKOpenChannel this_ptr_conv;
17193         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17194         this_ptr_conv.is_owned = false;
17195         LDKPublicKey val_ref;
17196         CHECK((*env)->GetArrayLength(env, val) == 33);
17197         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
17198         OpenChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
17199 }
17200
17201 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
17202         LDKOpenChannel this_ptr_conv;
17203         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17204         this_ptr_conv.is_owned = false;
17205         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
17206         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form);
17207         return ret_arr;
17208 }
17209
17210 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17211         LDKOpenChannel this_ptr_conv;
17212         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17213         this_ptr_conv.is_owned = false;
17214         LDKPublicKey val_ref;
17215         CHECK((*env)->GetArrayLength(env, val) == 33);
17216         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
17217         OpenChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
17218 }
17219
17220 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
17221         LDKOpenChannel this_ptr_conv;
17222         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17223         this_ptr_conv.is_owned = false;
17224         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
17225         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_payment_point(&this_ptr_conv).compressed_form);
17226         return ret_arr;
17227 }
17228
17229 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17230         LDKOpenChannel this_ptr_conv;
17231         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17232         this_ptr_conv.is_owned = false;
17233         LDKPublicKey val_ref;
17234         CHECK((*env)->GetArrayLength(env, val) == 33);
17235         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
17236         OpenChannel_set_payment_point(&this_ptr_conv, val_ref);
17237 }
17238
17239 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
17240         LDKOpenChannel this_ptr_conv;
17241         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17242         this_ptr_conv.is_owned = false;
17243         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
17244         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
17245         return ret_arr;
17246 }
17247
17248 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17249         LDKOpenChannel this_ptr_conv;
17250         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17251         this_ptr_conv.is_owned = false;
17252         LDKPublicKey val_ref;
17253         CHECK((*env)->GetArrayLength(env, val) == 33);
17254         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
17255         OpenChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
17256 }
17257
17258 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
17259         LDKOpenChannel this_ptr_conv;
17260         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17261         this_ptr_conv.is_owned = false;
17262         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
17263         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form);
17264         return ret_arr;
17265 }
17266
17267 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17268         LDKOpenChannel this_ptr_conv;
17269         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17270         this_ptr_conv.is_owned = false;
17271         LDKPublicKey val_ref;
17272         CHECK((*env)->GetArrayLength(env, val) == 33);
17273         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
17274         OpenChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
17275 }
17276
17277 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1first_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
17278         LDKOpenChannel this_ptr_conv;
17279         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17280         this_ptr_conv.is_owned = false;
17281         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
17282         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form);
17283         return ret_arr;
17284 }
17285
17286 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) {
17287         LDKOpenChannel this_ptr_conv;
17288         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17289         this_ptr_conv.is_owned = false;
17290         LDKPublicKey val_ref;
17291         CHECK((*env)->GetArrayLength(env, val) == 33);
17292         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
17293         OpenChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
17294 }
17295
17296 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1flags(JNIEnv *env, jclass clz, int64_t this_ptr) {
17297         LDKOpenChannel this_ptr_conv;
17298         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17299         this_ptr_conv.is_owned = false;
17300         int8_t ret_val = OpenChannel_get_channel_flags(&this_ptr_conv);
17301         return ret_val;
17302 }
17303
17304 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1flags(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
17305         LDKOpenChannel this_ptr_conv;
17306         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17307         this_ptr_conv.is_owned = false;
17308         OpenChannel_set_channel_flags(&this_ptr_conv, val);
17309 }
17310
17311 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17312         LDKOpenChannel orig_conv;
17313         orig_conv.inner = (void*)(orig & (~1));
17314         orig_conv.is_owned = false;
17315         LDKOpenChannel ret_var = OpenChannel_clone(&orig_conv);
17316         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17317         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17318         uint64_t ret_ref = (uint64_t)ret_var.inner;
17319         if (ret_var.is_owned) {
17320                 ret_ref |= 1;
17321         }
17322         return ret_ref;
17323 }
17324
17325 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17326         LDKAcceptChannel this_obj_conv;
17327         this_obj_conv.inner = (void*)(this_obj & (~1));
17328         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17329         AcceptChannel_free(this_obj_conv);
17330 }
17331
17332 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
17333         LDKAcceptChannel this_ptr_conv;
17334         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17335         this_ptr_conv.is_owned = false;
17336         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
17337         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *AcceptChannel_get_temporary_channel_id(&this_ptr_conv));
17338         return ret_arr;
17339 }
17340
17341 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17342         LDKAcceptChannel this_ptr_conv;
17343         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17344         this_ptr_conv.is_owned = false;
17345         LDKThirtyTwoBytes val_ref;
17346         CHECK((*env)->GetArrayLength(env, val) == 32);
17347         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
17348         AcceptChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
17349 }
17350
17351 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
17352         LDKAcceptChannel this_ptr_conv;
17353         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17354         this_ptr_conv.is_owned = false;
17355         int64_t ret_val = AcceptChannel_get_dust_limit_satoshis(&this_ptr_conv);
17356         return ret_val;
17357 }
17358
17359 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17360         LDKAcceptChannel this_ptr_conv;
17361         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17362         this_ptr_conv.is_owned = false;
17363         AcceptChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
17364 }
17365
17366 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) {
17367         LDKAcceptChannel this_ptr_conv;
17368         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17369         this_ptr_conv.is_owned = false;
17370         int64_t ret_val = AcceptChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
17371         return ret_val;
17372 }
17373
17374 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) {
17375         LDKAcceptChannel this_ptr_conv;
17376         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17377         this_ptr_conv.is_owned = false;
17378         AcceptChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
17379 }
17380
17381 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
17382         LDKAcceptChannel this_ptr_conv;
17383         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17384         this_ptr_conv.is_owned = false;
17385         int64_t ret_val = AcceptChannel_get_channel_reserve_satoshis(&this_ptr_conv);
17386         return ret_val;
17387 }
17388
17389 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17390         LDKAcceptChannel this_ptr_conv;
17391         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17392         this_ptr_conv.is_owned = false;
17393         AcceptChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
17394 }
17395
17396 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
17397         LDKAcceptChannel this_ptr_conv;
17398         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17399         this_ptr_conv.is_owned = false;
17400         int64_t ret_val = AcceptChannel_get_htlc_minimum_msat(&this_ptr_conv);
17401         return ret_val;
17402 }
17403
17404 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17405         LDKAcceptChannel this_ptr_conv;
17406         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17407         this_ptr_conv.is_owned = false;
17408         AcceptChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
17409 }
17410
17411 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
17412         LDKAcceptChannel this_ptr_conv;
17413         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17414         this_ptr_conv.is_owned = false;
17415         int32_t ret_val = AcceptChannel_get_minimum_depth(&this_ptr_conv);
17416         return ret_val;
17417 }
17418
17419 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
17420         LDKAcceptChannel this_ptr_conv;
17421         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17422         this_ptr_conv.is_owned = false;
17423         AcceptChannel_set_minimum_depth(&this_ptr_conv, val);
17424 }
17425
17426 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
17427         LDKAcceptChannel this_ptr_conv;
17428         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17429         this_ptr_conv.is_owned = false;
17430         int16_t ret_val = AcceptChannel_get_to_self_delay(&this_ptr_conv);
17431         return ret_val;
17432 }
17433
17434 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
17435         LDKAcceptChannel this_ptr_conv;
17436         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17437         this_ptr_conv.is_owned = false;
17438         AcceptChannel_set_to_self_delay(&this_ptr_conv, val);
17439 }
17440
17441 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
17442         LDKAcceptChannel this_ptr_conv;
17443         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17444         this_ptr_conv.is_owned = false;
17445         int16_t ret_val = AcceptChannel_get_max_accepted_htlcs(&this_ptr_conv);
17446         return ret_val;
17447 }
17448
17449 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
17450         LDKAcceptChannel this_ptr_conv;
17451         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17452         this_ptr_conv.is_owned = false;
17453         AcceptChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
17454 }
17455
17456 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
17457         LDKAcceptChannel this_ptr_conv;
17458         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17459         this_ptr_conv.is_owned = false;
17460         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
17461         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_funding_pubkey(&this_ptr_conv).compressed_form);
17462         return ret_arr;
17463 }
17464
17465 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17466         LDKAcceptChannel this_ptr_conv;
17467         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17468         this_ptr_conv.is_owned = false;
17469         LDKPublicKey val_ref;
17470         CHECK((*env)->GetArrayLength(env, val) == 33);
17471         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
17472         AcceptChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
17473 }
17474
17475 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
17476         LDKAcceptChannel this_ptr_conv;
17477         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17478         this_ptr_conv.is_owned = false;
17479         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
17480         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form);
17481         return ret_arr;
17482 }
17483
17484 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17485         LDKAcceptChannel this_ptr_conv;
17486         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17487         this_ptr_conv.is_owned = false;
17488         LDKPublicKey val_ref;
17489         CHECK((*env)->GetArrayLength(env, val) == 33);
17490         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
17491         AcceptChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
17492 }
17493
17494 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
17495         LDKAcceptChannel this_ptr_conv;
17496         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17497         this_ptr_conv.is_owned = false;
17498         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
17499         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_payment_point(&this_ptr_conv).compressed_form);
17500         return ret_arr;
17501 }
17502
17503 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17504         LDKAcceptChannel this_ptr_conv;
17505         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17506         this_ptr_conv.is_owned = false;
17507         LDKPublicKey val_ref;
17508         CHECK((*env)->GetArrayLength(env, val) == 33);
17509         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
17510         AcceptChannel_set_payment_point(&this_ptr_conv, val_ref);
17511 }
17512
17513 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
17514         LDKAcceptChannel this_ptr_conv;
17515         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17516         this_ptr_conv.is_owned = false;
17517         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
17518         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
17519         return ret_arr;
17520 }
17521
17522 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17523         LDKAcceptChannel this_ptr_conv;
17524         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17525         this_ptr_conv.is_owned = false;
17526         LDKPublicKey val_ref;
17527         CHECK((*env)->GetArrayLength(env, val) == 33);
17528         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
17529         AcceptChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
17530 }
17531
17532 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
17533         LDKAcceptChannel this_ptr_conv;
17534         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17535         this_ptr_conv.is_owned = false;
17536         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
17537         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form);
17538         return ret_arr;
17539 }
17540
17541 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17542         LDKAcceptChannel this_ptr_conv;
17543         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17544         this_ptr_conv.is_owned = false;
17545         LDKPublicKey val_ref;
17546         CHECK((*env)->GetArrayLength(env, val) == 33);
17547         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
17548         AcceptChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
17549 }
17550
17551 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1first_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
17552         LDKAcceptChannel this_ptr_conv;
17553         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17554         this_ptr_conv.is_owned = false;
17555         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
17556         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form);
17557         return ret_arr;
17558 }
17559
17560 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) {
17561         LDKAcceptChannel this_ptr_conv;
17562         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17563         this_ptr_conv.is_owned = false;
17564         LDKPublicKey val_ref;
17565         CHECK((*env)->GetArrayLength(env, val) == 33);
17566         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
17567         AcceptChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
17568 }
17569
17570 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17571         LDKAcceptChannel orig_conv;
17572         orig_conv.inner = (void*)(orig & (~1));
17573         orig_conv.is_owned = false;
17574         LDKAcceptChannel ret_var = AcceptChannel_clone(&orig_conv);
17575         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17576         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17577         uint64_t ret_ref = (uint64_t)ret_var.inner;
17578         if (ret_var.is_owned) {
17579                 ret_ref |= 1;
17580         }
17581         return ret_ref;
17582 }
17583
17584 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17585         LDKFundingCreated this_obj_conv;
17586         this_obj_conv.inner = (void*)(this_obj & (~1));
17587         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17588         FundingCreated_free(this_obj_conv);
17589 }
17590
17591 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
17592         LDKFundingCreated this_ptr_conv;
17593         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17594         this_ptr_conv.is_owned = false;
17595         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
17596         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingCreated_get_temporary_channel_id(&this_ptr_conv));
17597         return ret_arr;
17598 }
17599
17600 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17601         LDKFundingCreated this_ptr_conv;
17602         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17603         this_ptr_conv.is_owned = false;
17604         LDKThirtyTwoBytes val_ref;
17605         CHECK((*env)->GetArrayLength(env, val) == 32);
17606         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
17607         FundingCreated_set_temporary_channel_id(&this_ptr_conv, val_ref);
17608 }
17609
17610 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1funding_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
17611         LDKFundingCreated this_ptr_conv;
17612         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17613         this_ptr_conv.is_owned = false;
17614         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
17615         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingCreated_get_funding_txid(&this_ptr_conv));
17616         return ret_arr;
17617 }
17618
17619 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1funding_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17620         LDKFundingCreated this_ptr_conv;
17621         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17622         this_ptr_conv.is_owned = false;
17623         LDKThirtyTwoBytes val_ref;
17624         CHECK((*env)->GetArrayLength(env, val) == 32);
17625         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
17626         FundingCreated_set_funding_txid(&this_ptr_conv, val_ref);
17627 }
17628
17629 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1funding_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
17630         LDKFundingCreated this_ptr_conv;
17631         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17632         this_ptr_conv.is_owned = false;
17633         int16_t ret_val = FundingCreated_get_funding_output_index(&this_ptr_conv);
17634         return ret_val;
17635 }
17636
17637 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1funding_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
17638         LDKFundingCreated this_ptr_conv;
17639         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17640         this_ptr_conv.is_owned = false;
17641         FundingCreated_set_funding_output_index(&this_ptr_conv, val);
17642 }
17643
17644 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
17645         LDKFundingCreated this_ptr_conv;
17646         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17647         this_ptr_conv.is_owned = false;
17648         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
17649         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, FundingCreated_get_signature(&this_ptr_conv).compact_form);
17650         return ret_arr;
17651 }
17652
17653 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17654         LDKFundingCreated this_ptr_conv;
17655         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17656         this_ptr_conv.is_owned = false;
17657         LDKSignature val_ref;
17658         CHECK((*env)->GetArrayLength(env, val) == 64);
17659         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
17660         FundingCreated_set_signature(&this_ptr_conv, val_ref);
17661 }
17662
17663 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) {
17664         LDKThirtyTwoBytes temporary_channel_id_arg_ref;
17665         CHECK((*env)->GetArrayLength(env, temporary_channel_id_arg) == 32);
17666         (*env)->GetByteArrayRegion(env, temporary_channel_id_arg, 0, 32, temporary_channel_id_arg_ref.data);
17667         LDKThirtyTwoBytes funding_txid_arg_ref;
17668         CHECK((*env)->GetArrayLength(env, funding_txid_arg) == 32);
17669         (*env)->GetByteArrayRegion(env, funding_txid_arg, 0, 32, funding_txid_arg_ref.data);
17670         LDKSignature signature_arg_ref;
17671         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
17672         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
17673         LDKFundingCreated ret_var = FundingCreated_new(temporary_channel_id_arg_ref, funding_txid_arg_ref, funding_output_index_arg, signature_arg_ref);
17674         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17675         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17676         uint64_t ret_ref = (uint64_t)ret_var.inner;
17677         if (ret_var.is_owned) {
17678                 ret_ref |= 1;
17679         }
17680         return ret_ref;
17681 }
17682
17683 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17684         LDKFundingCreated orig_conv;
17685         orig_conv.inner = (void*)(orig & (~1));
17686         orig_conv.is_owned = false;
17687         LDKFundingCreated ret_var = FundingCreated_clone(&orig_conv);
17688         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17689         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17690         uint64_t ret_ref = (uint64_t)ret_var.inner;
17691         if (ret_var.is_owned) {
17692                 ret_ref |= 1;
17693         }
17694         return ret_ref;
17695 }
17696
17697 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17698         LDKFundingSigned this_obj_conv;
17699         this_obj_conv.inner = (void*)(this_obj & (~1));
17700         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17701         FundingSigned_free(this_obj_conv);
17702 }
17703
17704 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
17705         LDKFundingSigned this_ptr_conv;
17706         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17707         this_ptr_conv.is_owned = false;
17708         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
17709         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingSigned_get_channel_id(&this_ptr_conv));
17710         return ret_arr;
17711 }
17712
17713 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17714         LDKFundingSigned this_ptr_conv;
17715         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17716         this_ptr_conv.is_owned = false;
17717         LDKThirtyTwoBytes val_ref;
17718         CHECK((*env)->GetArrayLength(env, val) == 32);
17719         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
17720         FundingSigned_set_channel_id(&this_ptr_conv, val_ref);
17721 }
17722
17723 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
17724         LDKFundingSigned this_ptr_conv;
17725         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17726         this_ptr_conv.is_owned = false;
17727         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
17728         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, FundingSigned_get_signature(&this_ptr_conv).compact_form);
17729         return ret_arr;
17730 }
17731
17732 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17733         LDKFundingSigned this_ptr_conv;
17734         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17735         this_ptr_conv.is_owned = false;
17736         LDKSignature val_ref;
17737         CHECK((*env)->GetArrayLength(env, val) == 64);
17738         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
17739         FundingSigned_set_signature(&this_ptr_conv, val_ref);
17740 }
17741
17742 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray signature_arg) {
17743         LDKThirtyTwoBytes channel_id_arg_ref;
17744         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
17745         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
17746         LDKSignature signature_arg_ref;
17747         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
17748         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
17749         LDKFundingSigned ret_var = FundingSigned_new(channel_id_arg_ref, signature_arg_ref);
17750         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17751         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17752         uint64_t ret_ref = (uint64_t)ret_var.inner;
17753         if (ret_var.is_owned) {
17754                 ret_ref |= 1;
17755         }
17756         return ret_ref;
17757 }
17758
17759 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17760         LDKFundingSigned orig_conv;
17761         orig_conv.inner = (void*)(orig & (~1));
17762         orig_conv.is_owned = false;
17763         LDKFundingSigned ret_var = FundingSigned_clone(&orig_conv);
17764         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17765         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17766         uint64_t ret_ref = (uint64_t)ret_var.inner;
17767         if (ret_var.is_owned) {
17768                 ret_ref |= 1;
17769         }
17770         return ret_ref;
17771 }
17772
17773 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingLocked_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17774         LDKFundingLocked this_obj_conv;
17775         this_obj_conv.inner = (void*)(this_obj & (~1));
17776         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17777         FundingLocked_free(this_obj_conv);
17778 }
17779
17780 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingLocked_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
17781         LDKFundingLocked this_ptr_conv;
17782         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17783         this_ptr_conv.is_owned = false;
17784         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
17785         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingLocked_get_channel_id(&this_ptr_conv));
17786         return ret_arr;
17787 }
17788
17789 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingLocked_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17790         LDKFundingLocked this_ptr_conv;
17791         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17792         this_ptr_conv.is_owned = false;
17793         LDKThirtyTwoBytes val_ref;
17794         CHECK((*env)->GetArrayLength(env, val) == 32);
17795         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
17796         FundingLocked_set_channel_id(&this_ptr_conv, val_ref);
17797 }
17798
17799 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingLocked_1get_1next_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
17800         LDKFundingLocked this_ptr_conv;
17801         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17802         this_ptr_conv.is_owned = false;
17803         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
17804         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, FundingLocked_get_next_per_commitment_point(&this_ptr_conv).compressed_form);
17805         return ret_arr;
17806 }
17807
17808 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) {
17809         LDKFundingLocked this_ptr_conv;
17810         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17811         this_ptr_conv.is_owned = false;
17812         LDKPublicKey val_ref;
17813         CHECK((*env)->GetArrayLength(env, val) == 33);
17814         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
17815         FundingLocked_set_next_per_commitment_point(&this_ptr_conv, val_ref);
17816 }
17817
17818 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) {
17819         LDKThirtyTwoBytes channel_id_arg_ref;
17820         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
17821         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
17822         LDKPublicKey next_per_commitment_point_arg_ref;
17823         CHECK((*env)->GetArrayLength(env, next_per_commitment_point_arg) == 33);
17824         (*env)->GetByteArrayRegion(env, next_per_commitment_point_arg, 0, 33, next_per_commitment_point_arg_ref.compressed_form);
17825         LDKFundingLocked ret_var = FundingLocked_new(channel_id_arg_ref, next_per_commitment_point_arg_ref);
17826         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17827         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17828         uint64_t ret_ref = (uint64_t)ret_var.inner;
17829         if (ret_var.is_owned) {
17830                 ret_ref |= 1;
17831         }
17832         return ret_ref;
17833 }
17834
17835 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingLocked_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17836         LDKFundingLocked orig_conv;
17837         orig_conv.inner = (void*)(orig & (~1));
17838         orig_conv.is_owned = false;
17839         LDKFundingLocked ret_var = FundingLocked_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 void JNICALL Java_org_ldk_impl_bindings_Shutdown_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17850         LDKShutdown this_obj_conv;
17851         this_obj_conv.inner = (void*)(this_obj & (~1));
17852         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17853         Shutdown_free(this_obj_conv);
17854 }
17855
17856 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
17857         LDKShutdown this_ptr_conv;
17858         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17859         this_ptr_conv.is_owned = false;
17860         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
17861         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *Shutdown_get_channel_id(&this_ptr_conv));
17862         return ret_arr;
17863 }
17864
17865 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17866         LDKShutdown this_ptr_conv;
17867         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17868         this_ptr_conv.is_owned = false;
17869         LDKThirtyTwoBytes val_ref;
17870         CHECK((*env)->GetArrayLength(env, val) == 32);
17871         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
17872         Shutdown_set_channel_id(&this_ptr_conv, val_ref);
17873 }
17874
17875 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1get_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
17876         LDKShutdown this_ptr_conv;
17877         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17878         this_ptr_conv.is_owned = false;
17879         LDKu8slice ret_var = Shutdown_get_scriptpubkey(&this_ptr_conv);
17880         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17881         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17882         return ret_arr;
17883 }
17884
17885 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1set_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17886         LDKShutdown this_ptr_conv;
17887         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17888         this_ptr_conv.is_owned = false;
17889         LDKCVec_u8Z val_ref;
17890         val_ref.datalen = (*env)->GetArrayLength(env, val);
17891         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
17892         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
17893         Shutdown_set_scriptpubkey(&this_ptr_conv, val_ref);
17894 }
17895
17896 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray scriptpubkey_arg) {
17897         LDKThirtyTwoBytes channel_id_arg_ref;
17898         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
17899         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
17900         LDKCVec_u8Z scriptpubkey_arg_ref;
17901         scriptpubkey_arg_ref.datalen = (*env)->GetArrayLength(env, scriptpubkey_arg);
17902         scriptpubkey_arg_ref.data = MALLOC(scriptpubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
17903         (*env)->GetByteArrayRegion(env, scriptpubkey_arg, 0, scriptpubkey_arg_ref.datalen, scriptpubkey_arg_ref.data);
17904         LDKShutdown ret_var = Shutdown_new(channel_id_arg_ref, scriptpubkey_arg_ref);
17905         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17906         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17907         uint64_t ret_ref = (uint64_t)ret_var.inner;
17908         if (ret_var.is_owned) {
17909                 ret_ref |= 1;
17910         }
17911         return ret_ref;
17912 }
17913
17914 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17915         LDKShutdown orig_conv;
17916         orig_conv.inner = (void*)(orig & (~1));
17917         orig_conv.is_owned = false;
17918         LDKShutdown ret_var = Shutdown_clone(&orig_conv);
17919         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17920         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17921         uint64_t ret_ref = (uint64_t)ret_var.inner;
17922         if (ret_var.is_owned) {
17923                 ret_ref |= 1;
17924         }
17925         return ret_ref;
17926 }
17927
17928 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17929         LDKClosingSigned this_obj_conv;
17930         this_obj_conv.inner = (void*)(this_obj & (~1));
17931         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17932         ClosingSigned_free(this_obj_conv);
17933 }
17934
17935 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
17936         LDKClosingSigned this_ptr_conv;
17937         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17938         this_ptr_conv.is_owned = false;
17939         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
17940         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ClosingSigned_get_channel_id(&this_ptr_conv));
17941         return ret_arr;
17942 }
17943
17944 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17945         LDKClosingSigned this_ptr_conv;
17946         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17947         this_ptr_conv.is_owned = false;
17948         LDKThirtyTwoBytes val_ref;
17949         CHECK((*env)->GetArrayLength(env, val) == 32);
17950         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
17951         ClosingSigned_set_channel_id(&this_ptr_conv, val_ref);
17952 }
17953
17954 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
17955         LDKClosingSigned this_ptr_conv;
17956         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17957         this_ptr_conv.is_owned = false;
17958         int64_t ret_val = ClosingSigned_get_fee_satoshis(&this_ptr_conv);
17959         return ret_val;
17960 }
17961
17962 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17963         LDKClosingSigned this_ptr_conv;
17964         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17965         this_ptr_conv.is_owned = false;
17966         ClosingSigned_set_fee_satoshis(&this_ptr_conv, val);
17967 }
17968
17969 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
17970         LDKClosingSigned this_ptr_conv;
17971         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17972         this_ptr_conv.is_owned = false;
17973         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
17974         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ClosingSigned_get_signature(&this_ptr_conv).compact_form);
17975         return ret_arr;
17976 }
17977
17978 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17979         LDKClosingSigned this_ptr_conv;
17980         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17981         this_ptr_conv.is_owned = false;
17982         LDKSignature val_ref;
17983         CHECK((*env)->GetArrayLength(env, val) == 64);
17984         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
17985         ClosingSigned_set_signature(&this_ptr_conv, val_ref);
17986 }
17987
17988 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) {
17989         LDKThirtyTwoBytes channel_id_arg_ref;
17990         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
17991         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
17992         LDKSignature signature_arg_ref;
17993         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
17994         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
17995         LDKClosingSigned ret_var = ClosingSigned_new(channel_id_arg_ref, fee_satoshis_arg, signature_arg_ref);
17996         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17997         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17998         uint64_t ret_ref = (uint64_t)ret_var.inner;
17999         if (ret_var.is_owned) {
18000                 ret_ref |= 1;
18001         }
18002         return ret_ref;
18003 }
18004
18005 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18006         LDKClosingSigned orig_conv;
18007         orig_conv.inner = (void*)(orig & (~1));
18008         orig_conv.is_owned = false;
18009         LDKClosingSigned ret_var = ClosingSigned_clone(&orig_conv);
18010         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18011         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18012         uint64_t ret_ref = (uint64_t)ret_var.inner;
18013         if (ret_var.is_owned) {
18014                 ret_ref |= 1;
18015         }
18016         return ret_ref;
18017 }
18018
18019 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18020         LDKUpdateAddHTLC this_obj_conv;
18021         this_obj_conv.inner = (void*)(this_obj & (~1));
18022         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18023         UpdateAddHTLC_free(this_obj_conv);
18024 }
18025
18026 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18027         LDKUpdateAddHTLC this_ptr_conv;
18028         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18029         this_ptr_conv.is_owned = false;
18030         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18031         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateAddHTLC_get_channel_id(&this_ptr_conv));
18032         return ret_arr;
18033 }
18034
18035 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18036         LDKUpdateAddHTLC this_ptr_conv;
18037         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18038         this_ptr_conv.is_owned = false;
18039         LDKThirtyTwoBytes val_ref;
18040         CHECK((*env)->GetArrayLength(env, val) == 32);
18041         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18042         UpdateAddHTLC_set_channel_id(&this_ptr_conv, val_ref);
18043 }
18044
18045 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18046         LDKUpdateAddHTLC this_ptr_conv;
18047         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18048         this_ptr_conv.is_owned = false;
18049         int64_t ret_val = UpdateAddHTLC_get_htlc_id(&this_ptr_conv);
18050         return ret_val;
18051 }
18052
18053 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18054         LDKUpdateAddHTLC this_ptr_conv;
18055         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18056         this_ptr_conv.is_owned = false;
18057         UpdateAddHTLC_set_htlc_id(&this_ptr_conv, val);
18058 }
18059
18060 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
18061         LDKUpdateAddHTLC this_ptr_conv;
18062         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18063         this_ptr_conv.is_owned = false;
18064         int64_t ret_val = UpdateAddHTLC_get_amount_msat(&this_ptr_conv);
18065         return ret_val;
18066 }
18067
18068 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18069         LDKUpdateAddHTLC this_ptr_conv;
18070         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18071         this_ptr_conv.is_owned = false;
18072         UpdateAddHTLC_set_amount_msat(&this_ptr_conv, val);
18073 }
18074
18075 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
18076         LDKUpdateAddHTLC this_ptr_conv;
18077         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18078         this_ptr_conv.is_owned = false;
18079         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18080         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateAddHTLC_get_payment_hash(&this_ptr_conv));
18081         return ret_arr;
18082 }
18083
18084 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18085         LDKUpdateAddHTLC this_ptr_conv;
18086         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18087         this_ptr_conv.is_owned = false;
18088         LDKThirtyTwoBytes val_ref;
18089         CHECK((*env)->GetArrayLength(env, val) == 32);
18090         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18091         UpdateAddHTLC_set_payment_hash(&this_ptr_conv, val_ref);
18092 }
18093
18094 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr) {
18095         LDKUpdateAddHTLC this_ptr_conv;
18096         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18097         this_ptr_conv.is_owned = false;
18098         int32_t ret_val = UpdateAddHTLC_get_cltv_expiry(&this_ptr_conv);
18099         return ret_val;
18100 }
18101
18102 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
18103         LDKUpdateAddHTLC this_ptr_conv;
18104         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18105         this_ptr_conv.is_owned = false;
18106         UpdateAddHTLC_set_cltv_expiry(&this_ptr_conv, val);
18107 }
18108
18109 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18110         LDKUpdateAddHTLC orig_conv;
18111         orig_conv.inner = (void*)(orig & (~1));
18112         orig_conv.is_owned = false;
18113         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(&orig_conv);
18114         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18115         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18116         uint64_t ret_ref = (uint64_t)ret_var.inner;
18117         if (ret_var.is_owned) {
18118                 ret_ref |= 1;
18119         }
18120         return ret_ref;
18121 }
18122
18123 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18124         LDKUpdateFulfillHTLC this_obj_conv;
18125         this_obj_conv.inner = (void*)(this_obj & (~1));
18126         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18127         UpdateFulfillHTLC_free(this_obj_conv);
18128 }
18129
18130 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18131         LDKUpdateFulfillHTLC this_ptr_conv;
18132         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18133         this_ptr_conv.is_owned = false;
18134         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18135         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFulfillHTLC_get_channel_id(&this_ptr_conv));
18136         return ret_arr;
18137 }
18138
18139 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18140         LDKUpdateFulfillHTLC this_ptr_conv;
18141         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18142         this_ptr_conv.is_owned = false;
18143         LDKThirtyTwoBytes val_ref;
18144         CHECK((*env)->GetArrayLength(env, val) == 32);
18145         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18146         UpdateFulfillHTLC_set_channel_id(&this_ptr_conv, val_ref);
18147 }
18148
18149 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18150         LDKUpdateFulfillHTLC this_ptr_conv;
18151         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18152         this_ptr_conv.is_owned = false;
18153         int64_t ret_val = UpdateFulfillHTLC_get_htlc_id(&this_ptr_conv);
18154         return ret_val;
18155 }
18156
18157 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18158         LDKUpdateFulfillHTLC this_ptr_conv;
18159         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18160         this_ptr_conv.is_owned = false;
18161         UpdateFulfillHTLC_set_htlc_id(&this_ptr_conv, val);
18162 }
18163
18164 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1payment_1preimage(JNIEnv *env, jclass clz, int64_t this_ptr) {
18165         LDKUpdateFulfillHTLC this_ptr_conv;
18166         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18167         this_ptr_conv.is_owned = false;
18168         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18169         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFulfillHTLC_get_payment_preimage(&this_ptr_conv));
18170         return ret_arr;
18171 }
18172
18173 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1payment_1preimage(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18174         LDKUpdateFulfillHTLC this_ptr_conv;
18175         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18176         this_ptr_conv.is_owned = false;
18177         LDKThirtyTwoBytes val_ref;
18178         CHECK((*env)->GetArrayLength(env, val) == 32);
18179         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18180         UpdateFulfillHTLC_set_payment_preimage(&this_ptr_conv, val_ref);
18181 }
18182
18183 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) {
18184         LDKThirtyTwoBytes channel_id_arg_ref;
18185         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
18186         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
18187         LDKThirtyTwoBytes payment_preimage_arg_ref;
18188         CHECK((*env)->GetArrayLength(env, payment_preimage_arg) == 32);
18189         (*env)->GetByteArrayRegion(env, payment_preimage_arg, 0, 32, payment_preimage_arg_ref.data);
18190         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_new(channel_id_arg_ref, htlc_id_arg, payment_preimage_arg_ref);
18191         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18192         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18193         uint64_t ret_ref = (uint64_t)ret_var.inner;
18194         if (ret_var.is_owned) {
18195                 ret_ref |= 1;
18196         }
18197         return ret_ref;
18198 }
18199
18200 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18201         LDKUpdateFulfillHTLC orig_conv;
18202         orig_conv.inner = (void*)(orig & (~1));
18203         orig_conv.is_owned = false;
18204         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(&orig_conv);
18205         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18206         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18207         uint64_t ret_ref = (uint64_t)ret_var.inner;
18208         if (ret_var.is_owned) {
18209                 ret_ref |= 1;
18210         }
18211         return ret_ref;
18212 }
18213
18214 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18215         LDKUpdateFailHTLC this_obj_conv;
18216         this_obj_conv.inner = (void*)(this_obj & (~1));
18217         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18218         UpdateFailHTLC_free(this_obj_conv);
18219 }
18220
18221 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18222         LDKUpdateFailHTLC this_ptr_conv;
18223         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18224         this_ptr_conv.is_owned = false;
18225         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18226         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFailHTLC_get_channel_id(&this_ptr_conv));
18227         return ret_arr;
18228 }
18229
18230 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18231         LDKUpdateFailHTLC this_ptr_conv;
18232         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18233         this_ptr_conv.is_owned = false;
18234         LDKThirtyTwoBytes val_ref;
18235         CHECK((*env)->GetArrayLength(env, val) == 32);
18236         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18237         UpdateFailHTLC_set_channel_id(&this_ptr_conv, val_ref);
18238 }
18239
18240 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18241         LDKUpdateFailHTLC this_ptr_conv;
18242         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18243         this_ptr_conv.is_owned = false;
18244         int64_t ret_val = UpdateFailHTLC_get_htlc_id(&this_ptr_conv);
18245         return ret_val;
18246 }
18247
18248 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18249         LDKUpdateFailHTLC this_ptr_conv;
18250         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18251         this_ptr_conv.is_owned = false;
18252         UpdateFailHTLC_set_htlc_id(&this_ptr_conv, val);
18253 }
18254
18255 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18256         LDKUpdateFailHTLC orig_conv;
18257         orig_conv.inner = (void*)(orig & (~1));
18258         orig_conv.is_owned = false;
18259         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(&orig_conv);
18260         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18261         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18262         uint64_t ret_ref = (uint64_t)ret_var.inner;
18263         if (ret_var.is_owned) {
18264                 ret_ref |= 1;
18265         }
18266         return ret_ref;
18267 }
18268
18269 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18270         LDKUpdateFailMalformedHTLC this_obj_conv;
18271         this_obj_conv.inner = (void*)(this_obj & (~1));
18272         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18273         UpdateFailMalformedHTLC_free(this_obj_conv);
18274 }
18275
18276 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18277         LDKUpdateFailMalformedHTLC this_ptr_conv;
18278         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18279         this_ptr_conv.is_owned = false;
18280         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18281         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFailMalformedHTLC_get_channel_id(&this_ptr_conv));
18282         return ret_arr;
18283 }
18284
18285 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18286         LDKUpdateFailMalformedHTLC this_ptr_conv;
18287         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18288         this_ptr_conv.is_owned = false;
18289         LDKThirtyTwoBytes val_ref;
18290         CHECK((*env)->GetArrayLength(env, val) == 32);
18291         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18292         UpdateFailMalformedHTLC_set_channel_id(&this_ptr_conv, val_ref);
18293 }
18294
18295 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18296         LDKUpdateFailMalformedHTLC this_ptr_conv;
18297         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18298         this_ptr_conv.is_owned = false;
18299         int64_t ret_val = UpdateFailMalformedHTLC_get_htlc_id(&this_ptr_conv);
18300         return ret_val;
18301 }
18302
18303 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18304         LDKUpdateFailMalformedHTLC this_ptr_conv;
18305         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18306         this_ptr_conv.is_owned = false;
18307         UpdateFailMalformedHTLC_set_htlc_id(&this_ptr_conv, val);
18308 }
18309
18310 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1failure_1code(JNIEnv *env, jclass clz, int64_t this_ptr) {
18311         LDKUpdateFailMalformedHTLC this_ptr_conv;
18312         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18313         this_ptr_conv.is_owned = false;
18314         int16_t ret_val = UpdateFailMalformedHTLC_get_failure_code(&this_ptr_conv);
18315         return ret_val;
18316 }
18317
18318 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1failure_1code(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
18319         LDKUpdateFailMalformedHTLC this_ptr_conv;
18320         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18321         this_ptr_conv.is_owned = false;
18322         UpdateFailMalformedHTLC_set_failure_code(&this_ptr_conv, val);
18323 }
18324
18325 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18326         LDKUpdateFailMalformedHTLC orig_conv;
18327         orig_conv.inner = (void*)(orig & (~1));
18328         orig_conv.is_owned = false;
18329         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(&orig_conv);
18330         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18331         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18332         uint64_t ret_ref = (uint64_t)ret_var.inner;
18333         if (ret_var.is_owned) {
18334                 ret_ref |= 1;
18335         }
18336         return ret_ref;
18337 }
18338
18339 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18340         LDKCommitmentSigned this_obj_conv;
18341         this_obj_conv.inner = (void*)(this_obj & (~1));
18342         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18343         CommitmentSigned_free(this_obj_conv);
18344 }
18345
18346 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18347         LDKCommitmentSigned this_ptr_conv;
18348         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18349         this_ptr_conv.is_owned = false;
18350         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18351         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *CommitmentSigned_get_channel_id(&this_ptr_conv));
18352         return ret_arr;
18353 }
18354
18355 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18356         LDKCommitmentSigned this_ptr_conv;
18357         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18358         this_ptr_conv.is_owned = false;
18359         LDKThirtyTwoBytes val_ref;
18360         CHECK((*env)->GetArrayLength(env, val) == 32);
18361         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18362         CommitmentSigned_set_channel_id(&this_ptr_conv, val_ref);
18363 }
18364
18365 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
18366         LDKCommitmentSigned this_ptr_conv;
18367         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18368         this_ptr_conv.is_owned = false;
18369         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
18370         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, CommitmentSigned_get_signature(&this_ptr_conv).compact_form);
18371         return ret_arr;
18372 }
18373
18374 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18375         LDKCommitmentSigned this_ptr_conv;
18376         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18377         this_ptr_conv.is_owned = false;
18378         LDKSignature val_ref;
18379         CHECK((*env)->GetArrayLength(env, val) == 64);
18380         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
18381         CommitmentSigned_set_signature(&this_ptr_conv, val_ref);
18382 }
18383
18384 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1htlc_1signatures(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
18385         LDKCommitmentSigned this_ptr_conv;
18386         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18387         this_ptr_conv.is_owned = false;
18388         LDKCVec_SignatureZ val_constr;
18389         val_constr.datalen = (*env)->GetArrayLength(env, val);
18390         if (val_constr.datalen > 0)
18391                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
18392         else
18393                 val_constr.data = NULL;
18394         for (size_t i = 0; i < val_constr.datalen; i++) {
18395                 int8_tArray val_conv_8 = (*env)->GetObjectArrayElement(env, val, i);
18396                 LDKSignature val_conv_8_ref;
18397                 CHECK((*env)->GetArrayLength(env, val_conv_8) == 64);
18398                 (*env)->GetByteArrayRegion(env, val_conv_8, 0, 64, val_conv_8_ref.compact_form);
18399                 val_constr.data[i] = val_conv_8_ref;
18400         }
18401         CommitmentSigned_set_htlc_signatures(&this_ptr_conv, val_constr);
18402 }
18403
18404 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) {
18405         LDKThirtyTwoBytes channel_id_arg_ref;
18406         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
18407         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
18408         LDKSignature signature_arg_ref;
18409         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
18410         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
18411         LDKCVec_SignatureZ htlc_signatures_arg_constr;
18412         htlc_signatures_arg_constr.datalen = (*env)->GetArrayLength(env, htlc_signatures_arg);
18413         if (htlc_signatures_arg_constr.datalen > 0)
18414                 htlc_signatures_arg_constr.data = MALLOC(htlc_signatures_arg_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
18415         else
18416                 htlc_signatures_arg_constr.data = NULL;
18417         for (size_t i = 0; i < htlc_signatures_arg_constr.datalen; i++) {
18418                 int8_tArray htlc_signatures_arg_conv_8 = (*env)->GetObjectArrayElement(env, htlc_signatures_arg, i);
18419                 LDKSignature htlc_signatures_arg_conv_8_ref;
18420                 CHECK((*env)->GetArrayLength(env, htlc_signatures_arg_conv_8) == 64);
18421                 (*env)->GetByteArrayRegion(env, htlc_signatures_arg_conv_8, 0, 64, htlc_signatures_arg_conv_8_ref.compact_form);
18422                 htlc_signatures_arg_constr.data[i] = htlc_signatures_arg_conv_8_ref;
18423         }
18424         LDKCommitmentSigned ret_var = CommitmentSigned_new(channel_id_arg_ref, signature_arg_ref, htlc_signatures_arg_constr);
18425         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18426         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18427         uint64_t ret_ref = (uint64_t)ret_var.inner;
18428         if (ret_var.is_owned) {
18429                 ret_ref |= 1;
18430         }
18431         return ret_ref;
18432 }
18433
18434 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18435         LDKCommitmentSigned orig_conv;
18436         orig_conv.inner = (void*)(orig & (~1));
18437         orig_conv.is_owned = false;
18438         LDKCommitmentSigned ret_var = CommitmentSigned_clone(&orig_conv);
18439         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18440         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18441         uint64_t ret_ref = (uint64_t)ret_var.inner;
18442         if (ret_var.is_owned) {
18443                 ret_ref |= 1;
18444         }
18445         return ret_ref;
18446 }
18447
18448 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18449         LDKRevokeAndACK this_obj_conv;
18450         this_obj_conv.inner = (void*)(this_obj & (~1));
18451         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18452         RevokeAndACK_free(this_obj_conv);
18453 }
18454
18455 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18456         LDKRevokeAndACK this_ptr_conv;
18457         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18458         this_ptr_conv.is_owned = false;
18459         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18460         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *RevokeAndACK_get_channel_id(&this_ptr_conv));
18461         return ret_arr;
18462 }
18463
18464 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18465         LDKRevokeAndACK this_ptr_conv;
18466         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18467         this_ptr_conv.is_owned = false;
18468         LDKThirtyTwoBytes val_ref;
18469         CHECK((*env)->GetArrayLength(env, val) == 32);
18470         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18471         RevokeAndACK_set_channel_id(&this_ptr_conv, val_ref);
18472 }
18473
18474 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr) {
18475         LDKRevokeAndACK this_ptr_conv;
18476         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18477         this_ptr_conv.is_owned = false;
18478         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18479         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *RevokeAndACK_get_per_commitment_secret(&this_ptr_conv));
18480         return ret_arr;
18481 }
18482
18483 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1set_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18484         LDKRevokeAndACK this_ptr_conv;
18485         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18486         this_ptr_conv.is_owned = false;
18487         LDKThirtyTwoBytes val_ref;
18488         CHECK((*env)->GetArrayLength(env, val) == 32);
18489         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18490         RevokeAndACK_set_per_commitment_secret(&this_ptr_conv, val_ref);
18491 }
18492
18493 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1next_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
18494         LDKRevokeAndACK this_ptr_conv;
18495         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18496         this_ptr_conv.is_owned = false;
18497         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
18498         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RevokeAndACK_get_next_per_commitment_point(&this_ptr_conv).compressed_form);
18499         return ret_arr;
18500 }
18501
18502 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) {
18503         LDKRevokeAndACK this_ptr_conv;
18504         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18505         this_ptr_conv.is_owned = false;
18506         LDKPublicKey val_ref;
18507         CHECK((*env)->GetArrayLength(env, val) == 33);
18508         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
18509         RevokeAndACK_set_next_per_commitment_point(&this_ptr_conv, val_ref);
18510 }
18511
18512 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) {
18513         LDKThirtyTwoBytes channel_id_arg_ref;
18514         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
18515         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
18516         LDKThirtyTwoBytes per_commitment_secret_arg_ref;
18517         CHECK((*env)->GetArrayLength(env, per_commitment_secret_arg) == 32);
18518         (*env)->GetByteArrayRegion(env, per_commitment_secret_arg, 0, 32, per_commitment_secret_arg_ref.data);
18519         LDKPublicKey next_per_commitment_point_arg_ref;
18520         CHECK((*env)->GetArrayLength(env, next_per_commitment_point_arg) == 33);
18521         (*env)->GetByteArrayRegion(env, next_per_commitment_point_arg, 0, 33, next_per_commitment_point_arg_ref.compressed_form);
18522         LDKRevokeAndACK ret_var = RevokeAndACK_new(channel_id_arg_ref, per_commitment_secret_arg_ref, next_per_commitment_point_arg_ref);
18523         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18524         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18525         uint64_t ret_ref = (uint64_t)ret_var.inner;
18526         if (ret_var.is_owned) {
18527                 ret_ref |= 1;
18528         }
18529         return ret_ref;
18530 }
18531
18532 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18533         LDKRevokeAndACK orig_conv;
18534         orig_conv.inner = (void*)(orig & (~1));
18535         orig_conv.is_owned = false;
18536         LDKRevokeAndACK ret_var = RevokeAndACK_clone(&orig_conv);
18537         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18538         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18539         uint64_t ret_ref = (uint64_t)ret_var.inner;
18540         if (ret_var.is_owned) {
18541                 ret_ref |= 1;
18542         }
18543         return ret_ref;
18544 }
18545
18546 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18547         LDKUpdateFee this_obj_conv;
18548         this_obj_conv.inner = (void*)(this_obj & (~1));
18549         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18550         UpdateFee_free(this_obj_conv);
18551 }
18552
18553 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFee_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18554         LDKUpdateFee this_ptr_conv;
18555         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18556         this_ptr_conv.is_owned = false;
18557         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18558         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFee_get_channel_id(&this_ptr_conv));
18559         return ret_arr;
18560 }
18561
18562 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18563         LDKUpdateFee this_ptr_conv;
18564         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18565         this_ptr_conv.is_owned = false;
18566         LDKThirtyTwoBytes val_ref;
18567         CHECK((*env)->GetArrayLength(env, val) == 32);
18568         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18569         UpdateFee_set_channel_id(&this_ptr_conv, val_ref);
18570 }
18571
18572 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1get_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr) {
18573         LDKUpdateFee this_ptr_conv;
18574         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18575         this_ptr_conv.is_owned = false;
18576         int32_t ret_val = UpdateFee_get_feerate_per_kw(&this_ptr_conv);
18577         return ret_val;
18578 }
18579
18580 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1set_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
18581         LDKUpdateFee this_ptr_conv;
18582         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18583         this_ptr_conv.is_owned = false;
18584         UpdateFee_set_feerate_per_kw(&this_ptr_conv, val);
18585 }
18586
18587 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) {
18588         LDKThirtyTwoBytes channel_id_arg_ref;
18589         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
18590         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
18591         LDKUpdateFee ret_var = UpdateFee_new(channel_id_arg_ref, feerate_per_kw_arg);
18592         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18593         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18594         uint64_t ret_ref = (uint64_t)ret_var.inner;
18595         if (ret_var.is_owned) {
18596                 ret_ref |= 1;
18597         }
18598         return ret_ref;
18599 }
18600
18601 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18602         LDKUpdateFee orig_conv;
18603         orig_conv.inner = (void*)(orig & (~1));
18604         orig_conv.is_owned = false;
18605         LDKUpdateFee ret_var = UpdateFee_clone(&orig_conv);
18606         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18607         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18608         uint64_t ret_ref = (uint64_t)ret_var.inner;
18609         if (ret_var.is_owned) {
18610                 ret_ref |= 1;
18611         }
18612         return ret_ref;
18613 }
18614
18615 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18616         LDKDataLossProtect this_obj_conv;
18617         this_obj_conv.inner = (void*)(this_obj & (~1));
18618         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18619         DataLossProtect_free(this_obj_conv);
18620 }
18621
18622 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1get_1your_1last_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr) {
18623         LDKDataLossProtect this_ptr_conv;
18624         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18625         this_ptr_conv.is_owned = false;
18626         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18627         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *DataLossProtect_get_your_last_per_commitment_secret(&this_ptr_conv));
18628         return ret_arr;
18629 }
18630
18631 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) {
18632         LDKDataLossProtect this_ptr_conv;
18633         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18634         this_ptr_conv.is_owned = false;
18635         LDKThirtyTwoBytes val_ref;
18636         CHECK((*env)->GetArrayLength(env, val) == 32);
18637         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18638         DataLossProtect_set_your_last_per_commitment_secret(&this_ptr_conv, val_ref);
18639 }
18640
18641 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1get_1my_1current_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
18642         LDKDataLossProtect this_ptr_conv;
18643         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18644         this_ptr_conv.is_owned = false;
18645         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
18646         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DataLossProtect_get_my_current_per_commitment_point(&this_ptr_conv).compressed_form);
18647         return ret_arr;
18648 }
18649
18650 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) {
18651         LDKDataLossProtect this_ptr_conv;
18652         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18653         this_ptr_conv.is_owned = false;
18654         LDKPublicKey val_ref;
18655         CHECK((*env)->GetArrayLength(env, val) == 33);
18656         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
18657         DataLossProtect_set_my_current_per_commitment_point(&this_ptr_conv, val_ref);
18658 }
18659
18660 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) {
18661         LDKThirtyTwoBytes your_last_per_commitment_secret_arg_ref;
18662         CHECK((*env)->GetArrayLength(env, your_last_per_commitment_secret_arg) == 32);
18663         (*env)->GetByteArrayRegion(env, your_last_per_commitment_secret_arg, 0, 32, your_last_per_commitment_secret_arg_ref.data);
18664         LDKPublicKey my_current_per_commitment_point_arg_ref;
18665         CHECK((*env)->GetArrayLength(env, my_current_per_commitment_point_arg) == 33);
18666         (*env)->GetByteArrayRegion(env, my_current_per_commitment_point_arg, 0, 33, my_current_per_commitment_point_arg_ref.compressed_form);
18667         LDKDataLossProtect ret_var = DataLossProtect_new(your_last_per_commitment_secret_arg_ref, my_current_per_commitment_point_arg_ref);
18668         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18669         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18670         uint64_t ret_ref = (uint64_t)ret_var.inner;
18671         if (ret_var.is_owned) {
18672                 ret_ref |= 1;
18673         }
18674         return ret_ref;
18675 }
18676
18677 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18678         LDKDataLossProtect orig_conv;
18679         orig_conv.inner = (void*)(orig & (~1));
18680         orig_conv.is_owned = false;
18681         LDKDataLossProtect ret_var = DataLossProtect_clone(&orig_conv);
18682         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18683         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18684         uint64_t ret_ref = (uint64_t)ret_var.inner;
18685         if (ret_var.is_owned) {
18686                 ret_ref |= 1;
18687         }
18688         return ret_ref;
18689 }
18690
18691 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18692         LDKChannelReestablish this_obj_conv;
18693         this_obj_conv.inner = (void*)(this_obj & (~1));
18694         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18695         ChannelReestablish_free(this_obj_conv);
18696 }
18697
18698 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18699         LDKChannelReestablish this_ptr_conv;
18700         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18701         this_ptr_conv.is_owned = false;
18702         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18703         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ChannelReestablish_get_channel_id(&this_ptr_conv));
18704         return ret_arr;
18705 }
18706
18707 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18708         LDKChannelReestablish this_ptr_conv;
18709         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18710         this_ptr_conv.is_owned = false;
18711         LDKThirtyTwoBytes val_ref;
18712         CHECK((*env)->GetArrayLength(env, val) == 32);
18713         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18714         ChannelReestablish_set_channel_id(&this_ptr_conv, val_ref);
18715 }
18716
18717 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1next_1local_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_ptr) {
18718         LDKChannelReestablish this_ptr_conv;
18719         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18720         this_ptr_conv.is_owned = false;
18721         int64_t ret_val = ChannelReestablish_get_next_local_commitment_number(&this_ptr_conv);
18722         return ret_val;
18723 }
18724
18725 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) {
18726         LDKChannelReestablish this_ptr_conv;
18727         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18728         this_ptr_conv.is_owned = false;
18729         ChannelReestablish_set_next_local_commitment_number(&this_ptr_conv, val);
18730 }
18731
18732 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1next_1remote_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_ptr) {
18733         LDKChannelReestablish this_ptr_conv;
18734         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18735         this_ptr_conv.is_owned = false;
18736         int64_t ret_val = ChannelReestablish_get_next_remote_commitment_number(&this_ptr_conv);
18737         return ret_val;
18738 }
18739
18740 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) {
18741         LDKChannelReestablish this_ptr_conv;
18742         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18743         this_ptr_conv.is_owned = false;
18744         ChannelReestablish_set_next_remote_commitment_number(&this_ptr_conv, val);
18745 }
18746
18747 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18748         LDKChannelReestablish orig_conv;
18749         orig_conv.inner = (void*)(orig & (~1));
18750         orig_conv.is_owned = false;
18751         LDKChannelReestablish ret_var = ChannelReestablish_clone(&orig_conv);
18752         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18753         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18754         uint64_t ret_ref = (uint64_t)ret_var.inner;
18755         if (ret_var.is_owned) {
18756                 ret_ref |= 1;
18757         }
18758         return ret_ref;
18759 }
18760
18761 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18762         LDKAnnouncementSignatures this_obj_conv;
18763         this_obj_conv.inner = (void*)(this_obj & (~1));
18764         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18765         AnnouncementSignatures_free(this_obj_conv);
18766 }
18767
18768 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18769         LDKAnnouncementSignatures this_ptr_conv;
18770         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18771         this_ptr_conv.is_owned = false;
18772         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18773         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *AnnouncementSignatures_get_channel_id(&this_ptr_conv));
18774         return ret_arr;
18775 }
18776
18777 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18778         LDKAnnouncementSignatures this_ptr_conv;
18779         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18780         this_ptr_conv.is_owned = false;
18781         LDKThirtyTwoBytes val_ref;
18782         CHECK((*env)->GetArrayLength(env, val) == 32);
18783         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18784         AnnouncementSignatures_set_channel_id(&this_ptr_conv, val_ref);
18785 }
18786
18787 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18788         LDKAnnouncementSignatures this_ptr_conv;
18789         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18790         this_ptr_conv.is_owned = false;
18791         int64_t ret_val = AnnouncementSignatures_get_short_channel_id(&this_ptr_conv);
18792         return ret_val;
18793 }
18794
18795 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18796         LDKAnnouncementSignatures this_ptr_conv;
18797         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18798         this_ptr_conv.is_owned = false;
18799         AnnouncementSignatures_set_short_channel_id(&this_ptr_conv, val);
18800 }
18801
18802 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1node_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
18803         LDKAnnouncementSignatures this_ptr_conv;
18804         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18805         this_ptr_conv.is_owned = false;
18806         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
18807         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, AnnouncementSignatures_get_node_signature(&this_ptr_conv).compact_form);
18808         return ret_arr;
18809 }
18810
18811 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1node_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18812         LDKAnnouncementSignatures this_ptr_conv;
18813         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18814         this_ptr_conv.is_owned = false;
18815         LDKSignature val_ref;
18816         CHECK((*env)->GetArrayLength(env, val) == 64);
18817         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
18818         AnnouncementSignatures_set_node_signature(&this_ptr_conv, val_ref);
18819 }
18820
18821 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1bitcoin_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
18822         LDKAnnouncementSignatures this_ptr_conv;
18823         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18824         this_ptr_conv.is_owned = false;
18825         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
18826         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, AnnouncementSignatures_get_bitcoin_signature(&this_ptr_conv).compact_form);
18827         return ret_arr;
18828 }
18829
18830 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1bitcoin_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18831         LDKAnnouncementSignatures this_ptr_conv;
18832         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18833         this_ptr_conv.is_owned = false;
18834         LDKSignature val_ref;
18835         CHECK((*env)->GetArrayLength(env, val) == 64);
18836         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
18837         AnnouncementSignatures_set_bitcoin_signature(&this_ptr_conv, val_ref);
18838 }
18839
18840 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) {
18841         LDKThirtyTwoBytes channel_id_arg_ref;
18842         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
18843         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
18844         LDKSignature node_signature_arg_ref;
18845         CHECK((*env)->GetArrayLength(env, node_signature_arg) == 64);
18846         (*env)->GetByteArrayRegion(env, node_signature_arg, 0, 64, node_signature_arg_ref.compact_form);
18847         LDKSignature bitcoin_signature_arg_ref;
18848         CHECK((*env)->GetArrayLength(env, bitcoin_signature_arg) == 64);
18849         (*env)->GetByteArrayRegion(env, bitcoin_signature_arg, 0, 64, bitcoin_signature_arg_ref.compact_form);
18850         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_new(channel_id_arg_ref, short_channel_id_arg, node_signature_arg_ref, bitcoin_signature_arg_ref);
18851         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18852         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18853         uint64_t ret_ref = (uint64_t)ret_var.inner;
18854         if (ret_var.is_owned) {
18855                 ret_ref |= 1;
18856         }
18857         return ret_ref;
18858 }
18859
18860 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18861         LDKAnnouncementSignatures orig_conv;
18862         orig_conv.inner = (void*)(orig & (~1));
18863         orig_conv.is_owned = false;
18864         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(&orig_conv);
18865         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18866         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18867         uint64_t ret_ref = (uint64_t)ret_var.inner;
18868         if (ret_var.is_owned) {
18869                 ret_ref |= 1;
18870         }
18871         return ret_ref;
18872 }
18873
18874 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetAddress_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
18875         if ((this_ptr & 1) != 0) return;
18876         LDKNetAddress this_ptr_conv = *(LDKNetAddress*)(((uint64_t)this_ptr) & ~1);
18877         FREE((void*)this_ptr);
18878         NetAddress_free(this_ptr_conv);
18879 }
18880
18881 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18882         LDKNetAddress* orig_conv = (LDKNetAddress*)orig;
18883         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
18884         *ret_copy = NetAddress_clone(orig_conv);
18885         uint64_t ret_ref = (uint64_t)ret_copy;
18886         return ret_ref;
18887 }
18888
18889 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetAddress_1write(JNIEnv *env, jclass clz, int64_t obj) {
18890         LDKNetAddress* obj_conv = (LDKNetAddress*)obj;
18891         LDKCVec_u8Z ret_var = NetAddress_write(obj_conv);
18892         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
18893         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
18894         CVec_u8Z_free(ret_var);
18895         return ret_arr;
18896 }
18897
18898 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Result_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
18899         LDKu8slice ser_ref;
18900         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
18901         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
18902         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
18903         *ret_conv = Result_read(ser_ref);
18904         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
18905         return (uint64_t)ret_conv;
18906 }
18907
18908 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
18909         LDKu8slice ser_ref;
18910         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
18911         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
18912         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
18913         *ret_conv = NetAddress_read(ser_ref);
18914         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
18915         return (uint64_t)ret_conv;
18916 }
18917
18918 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18919         LDKUnsignedNodeAnnouncement this_obj_conv;
18920         this_obj_conv.inner = (void*)(this_obj & (~1));
18921         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18922         UnsignedNodeAnnouncement_free(this_obj_conv);
18923 }
18924
18925 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
18926         LDKUnsignedNodeAnnouncement this_ptr_conv;
18927         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18928         this_ptr_conv.is_owned = false;
18929         LDKNodeFeatures ret_var = UnsignedNodeAnnouncement_get_features(&this_ptr_conv);
18930         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18931         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18932         uint64_t ret_ref = (uint64_t)ret_var.inner;
18933         if (ret_var.is_owned) {
18934                 ret_ref |= 1;
18935         }
18936         return ret_ref;
18937 }
18938
18939 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18940         LDKUnsignedNodeAnnouncement this_ptr_conv;
18941         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18942         this_ptr_conv.is_owned = false;
18943         LDKNodeFeatures val_conv;
18944         val_conv.inner = (void*)(val & (~1));
18945         val_conv.is_owned = (val & 1) || (val == 0);
18946         val_conv = NodeFeatures_clone(&val_conv);
18947         UnsignedNodeAnnouncement_set_features(&this_ptr_conv, val_conv);
18948 }
18949
18950 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
18951         LDKUnsignedNodeAnnouncement this_ptr_conv;
18952         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18953         this_ptr_conv.is_owned = false;
18954         int32_t ret_val = UnsignedNodeAnnouncement_get_timestamp(&this_ptr_conv);
18955         return ret_val;
18956 }
18957
18958 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
18959         LDKUnsignedNodeAnnouncement this_ptr_conv;
18960         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18961         this_ptr_conv.is_owned = false;
18962         UnsignedNodeAnnouncement_set_timestamp(&this_ptr_conv, val);
18963 }
18964
18965 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18966         LDKUnsignedNodeAnnouncement this_ptr_conv;
18967         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18968         this_ptr_conv.is_owned = false;
18969         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
18970         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedNodeAnnouncement_get_node_id(&this_ptr_conv).compressed_form);
18971         return ret_arr;
18972 }
18973
18974 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18975         LDKUnsignedNodeAnnouncement this_ptr_conv;
18976         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18977         this_ptr_conv.is_owned = false;
18978         LDKPublicKey val_ref;
18979         CHECK((*env)->GetArrayLength(env, val) == 33);
18980         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
18981         UnsignedNodeAnnouncement_set_node_id(&this_ptr_conv, val_ref);
18982 }
18983
18984 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr) {
18985         LDKUnsignedNodeAnnouncement this_ptr_conv;
18986         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18987         this_ptr_conv.is_owned = false;
18988         int8_tArray ret_arr = (*env)->NewByteArray(env, 3);
18989         (*env)->SetByteArrayRegion(env, ret_arr, 0, 3, *UnsignedNodeAnnouncement_get_rgb(&this_ptr_conv));
18990         return ret_arr;
18991 }
18992
18993 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18994         LDKUnsignedNodeAnnouncement this_ptr_conv;
18995         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18996         this_ptr_conv.is_owned = false;
18997         LDKThreeBytes val_ref;
18998         CHECK((*env)->GetArrayLength(env, val) == 3);
18999         (*env)->GetByteArrayRegion(env, val, 0, 3, val_ref.data);
19000         UnsignedNodeAnnouncement_set_rgb(&this_ptr_conv, val_ref);
19001 }
19002
19003 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
19004         LDKUnsignedNodeAnnouncement this_ptr_conv;
19005         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19006         this_ptr_conv.is_owned = false;
19007         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
19008         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedNodeAnnouncement_get_alias(&this_ptr_conv));
19009         return ret_arr;
19010 }
19011
19012 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19013         LDKUnsignedNodeAnnouncement this_ptr_conv;
19014         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19015         this_ptr_conv.is_owned = false;
19016         LDKThirtyTwoBytes val_ref;
19017         CHECK((*env)->GetArrayLength(env, val) == 32);
19018         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
19019         UnsignedNodeAnnouncement_set_alias(&this_ptr_conv, val_ref);
19020 }
19021
19022 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1addresses(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
19023         LDKUnsignedNodeAnnouncement this_ptr_conv;
19024         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19025         this_ptr_conv.is_owned = false;
19026         LDKCVec_NetAddressZ val_constr;
19027         val_constr.datalen = (*env)->GetArrayLength(env, val);
19028         if (val_constr.datalen > 0)
19029                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
19030         else
19031                 val_constr.data = NULL;
19032         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
19033         for (size_t m = 0; m < val_constr.datalen; m++) {
19034                 int64_t val_conv_12 = val_vals[m];
19035                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(((uint64_t)val_conv_12) & ~1);
19036                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)val_conv_12) & ~1));
19037                 val_constr.data[m] = val_conv_12_conv;
19038         }
19039         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
19040         UnsignedNodeAnnouncement_set_addresses(&this_ptr_conv, val_constr);
19041 }
19042
19043 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19044         LDKUnsignedNodeAnnouncement orig_conv;
19045         orig_conv.inner = (void*)(orig & (~1));
19046         orig_conv.is_owned = false;
19047         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(&orig_conv);
19048         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19049         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19050         uint64_t ret_ref = (uint64_t)ret_var.inner;
19051         if (ret_var.is_owned) {
19052                 ret_ref |= 1;
19053         }
19054         return ret_ref;
19055 }
19056
19057 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19058         LDKNodeAnnouncement this_obj_conv;
19059         this_obj_conv.inner = (void*)(this_obj & (~1));
19060         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19061         NodeAnnouncement_free(this_obj_conv);
19062 }
19063
19064 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
19065         LDKNodeAnnouncement this_ptr_conv;
19066         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19067         this_ptr_conv.is_owned = false;
19068         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
19069         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, NodeAnnouncement_get_signature(&this_ptr_conv).compact_form);
19070         return ret_arr;
19071 }
19072
19073 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19074         LDKNodeAnnouncement this_ptr_conv;
19075         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19076         this_ptr_conv.is_owned = false;
19077         LDKSignature val_ref;
19078         CHECK((*env)->GetArrayLength(env, val) == 64);
19079         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
19080         NodeAnnouncement_set_signature(&this_ptr_conv, val_ref);
19081 }
19082
19083 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
19084         LDKNodeAnnouncement this_ptr_conv;
19085         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19086         this_ptr_conv.is_owned = false;
19087         LDKUnsignedNodeAnnouncement ret_var = NodeAnnouncement_get_contents(&this_ptr_conv);
19088         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19089         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19090         uint64_t ret_ref = (uint64_t)ret_var.inner;
19091         if (ret_var.is_owned) {
19092                 ret_ref |= 1;
19093         }
19094         return ret_ref;
19095 }
19096
19097 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19098         LDKNodeAnnouncement this_ptr_conv;
19099         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19100         this_ptr_conv.is_owned = false;
19101         LDKUnsignedNodeAnnouncement val_conv;
19102         val_conv.inner = (void*)(val & (~1));
19103         val_conv.is_owned = (val & 1) || (val == 0);
19104         val_conv = UnsignedNodeAnnouncement_clone(&val_conv);
19105         NodeAnnouncement_set_contents(&this_ptr_conv, val_conv);
19106 }
19107
19108 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1new(JNIEnv *env, jclass clz, int8_tArray signature_arg, int64_t contents_arg) {
19109         LDKSignature signature_arg_ref;
19110         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
19111         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
19112         LDKUnsignedNodeAnnouncement contents_arg_conv;
19113         contents_arg_conv.inner = (void*)(contents_arg & (~1));
19114         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
19115         contents_arg_conv = UnsignedNodeAnnouncement_clone(&contents_arg_conv);
19116         LDKNodeAnnouncement ret_var = NodeAnnouncement_new(signature_arg_ref, contents_arg_conv);
19117         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19118         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19119         uint64_t ret_ref = (uint64_t)ret_var.inner;
19120         if (ret_var.is_owned) {
19121                 ret_ref |= 1;
19122         }
19123         return ret_ref;
19124 }
19125
19126 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19127         LDKNodeAnnouncement orig_conv;
19128         orig_conv.inner = (void*)(orig & (~1));
19129         orig_conv.is_owned = false;
19130         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(&orig_conv);
19131         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19132         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19133         uint64_t ret_ref = (uint64_t)ret_var.inner;
19134         if (ret_var.is_owned) {
19135                 ret_ref |= 1;
19136         }
19137         return ret_ref;
19138 }
19139
19140 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19141         LDKUnsignedChannelAnnouncement this_obj_conv;
19142         this_obj_conv.inner = (void*)(this_obj & (~1));
19143         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19144         UnsignedChannelAnnouncement_free(this_obj_conv);
19145 }
19146
19147 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
19148         LDKUnsignedChannelAnnouncement this_ptr_conv;
19149         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19150         this_ptr_conv.is_owned = false;
19151         LDKChannelFeatures ret_var = UnsignedChannelAnnouncement_get_features(&this_ptr_conv);
19152         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19153         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19154         uint64_t ret_ref = (uint64_t)ret_var.inner;
19155         if (ret_var.is_owned) {
19156                 ret_ref |= 1;
19157         }
19158         return ret_ref;
19159 }
19160
19161 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19162         LDKUnsignedChannelAnnouncement this_ptr_conv;
19163         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19164         this_ptr_conv.is_owned = false;
19165         LDKChannelFeatures val_conv;
19166         val_conv.inner = (void*)(val & (~1));
19167         val_conv.is_owned = (val & 1) || (val == 0);
19168         val_conv = ChannelFeatures_clone(&val_conv);
19169         UnsignedChannelAnnouncement_set_features(&this_ptr_conv, val_conv);
19170 }
19171
19172 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
19173         LDKUnsignedChannelAnnouncement this_ptr_conv;
19174         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19175         this_ptr_conv.is_owned = false;
19176         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
19177         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedChannelAnnouncement_get_chain_hash(&this_ptr_conv));
19178         return ret_arr;
19179 }
19180
19181 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19182         LDKUnsignedChannelAnnouncement this_ptr_conv;
19183         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19184         this_ptr_conv.is_owned = false;
19185         LDKThirtyTwoBytes val_ref;
19186         CHECK((*env)->GetArrayLength(env, val) == 32);
19187         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
19188         UnsignedChannelAnnouncement_set_chain_hash(&this_ptr_conv, val_ref);
19189 }
19190
19191 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
19192         LDKUnsignedChannelAnnouncement this_ptr_conv;
19193         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19194         this_ptr_conv.is_owned = false;
19195         int64_t ret_val = UnsignedChannelAnnouncement_get_short_channel_id(&this_ptr_conv);
19196         return ret_val;
19197 }
19198
19199 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19200         LDKUnsignedChannelAnnouncement this_ptr_conv;
19201         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19202         this_ptr_conv.is_owned = false;
19203         UnsignedChannelAnnouncement_set_short_channel_id(&this_ptr_conv, val);
19204 }
19205
19206 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1node_1id_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
19207         LDKUnsignedChannelAnnouncement this_ptr_conv;
19208         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19209         this_ptr_conv.is_owned = false;
19210         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
19211         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_node_id_1(&this_ptr_conv).compressed_form);
19212         return ret_arr;
19213 }
19214
19215 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1node_1id_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19216         LDKUnsignedChannelAnnouncement this_ptr_conv;
19217         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19218         this_ptr_conv.is_owned = false;
19219         LDKPublicKey val_ref;
19220         CHECK((*env)->GetArrayLength(env, val) == 33);
19221         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
19222         UnsignedChannelAnnouncement_set_node_id_1(&this_ptr_conv, val_ref);
19223 }
19224
19225 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1node_1id_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
19226         LDKUnsignedChannelAnnouncement this_ptr_conv;
19227         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19228         this_ptr_conv.is_owned = false;
19229         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
19230         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_node_id_2(&this_ptr_conv).compressed_form);
19231         return ret_arr;
19232 }
19233
19234 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1node_1id_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19235         LDKUnsignedChannelAnnouncement this_ptr_conv;
19236         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19237         this_ptr_conv.is_owned = false;
19238         LDKPublicKey val_ref;
19239         CHECK((*env)->GetArrayLength(env, val) == 33);
19240         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
19241         UnsignedChannelAnnouncement_set_node_id_2(&this_ptr_conv, val_ref);
19242 }
19243
19244 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1bitcoin_1key_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
19245         LDKUnsignedChannelAnnouncement this_ptr_conv;
19246         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19247         this_ptr_conv.is_owned = false;
19248         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
19249         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_bitcoin_key_1(&this_ptr_conv).compressed_form);
19250         return ret_arr;
19251 }
19252
19253 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1bitcoin_1key_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19254         LDKUnsignedChannelAnnouncement this_ptr_conv;
19255         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19256         this_ptr_conv.is_owned = false;
19257         LDKPublicKey val_ref;
19258         CHECK((*env)->GetArrayLength(env, val) == 33);
19259         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
19260         UnsignedChannelAnnouncement_set_bitcoin_key_1(&this_ptr_conv, val_ref);
19261 }
19262
19263 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1bitcoin_1key_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
19264         LDKUnsignedChannelAnnouncement this_ptr_conv;
19265         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19266         this_ptr_conv.is_owned = false;
19267         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
19268         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_bitcoin_key_2(&this_ptr_conv).compressed_form);
19269         return ret_arr;
19270 }
19271
19272 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1bitcoin_1key_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19273         LDKUnsignedChannelAnnouncement this_ptr_conv;
19274         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19275         this_ptr_conv.is_owned = false;
19276         LDKPublicKey val_ref;
19277         CHECK((*env)->GetArrayLength(env, val) == 33);
19278         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
19279         UnsignedChannelAnnouncement_set_bitcoin_key_2(&this_ptr_conv, val_ref);
19280 }
19281
19282 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19283         LDKUnsignedChannelAnnouncement orig_conv;
19284         orig_conv.inner = (void*)(orig & (~1));
19285         orig_conv.is_owned = false;
19286         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(&orig_conv);
19287         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19288         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19289         uint64_t ret_ref = (uint64_t)ret_var.inner;
19290         if (ret_var.is_owned) {
19291                 ret_ref |= 1;
19292         }
19293         return ret_ref;
19294 }
19295
19296 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19297         LDKChannelAnnouncement this_obj_conv;
19298         this_obj_conv.inner = (void*)(this_obj & (~1));
19299         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19300         ChannelAnnouncement_free(this_obj_conv);
19301 }
19302
19303 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1node_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
19304         LDKChannelAnnouncement this_ptr_conv;
19305         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19306         this_ptr_conv.is_owned = false;
19307         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
19308         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_node_signature_1(&this_ptr_conv).compact_form);
19309         return ret_arr;
19310 }
19311
19312 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1node_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19313         LDKChannelAnnouncement this_ptr_conv;
19314         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19315         this_ptr_conv.is_owned = false;
19316         LDKSignature val_ref;
19317         CHECK((*env)->GetArrayLength(env, val) == 64);
19318         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
19319         ChannelAnnouncement_set_node_signature_1(&this_ptr_conv, val_ref);
19320 }
19321
19322 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1node_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
19323         LDKChannelAnnouncement this_ptr_conv;
19324         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19325         this_ptr_conv.is_owned = false;
19326         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
19327         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_node_signature_2(&this_ptr_conv).compact_form);
19328         return ret_arr;
19329 }
19330
19331 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1node_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19332         LDKChannelAnnouncement this_ptr_conv;
19333         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19334         this_ptr_conv.is_owned = false;
19335         LDKSignature val_ref;
19336         CHECK((*env)->GetArrayLength(env, val) == 64);
19337         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
19338         ChannelAnnouncement_set_node_signature_2(&this_ptr_conv, val_ref);
19339 }
19340
19341 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1bitcoin_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
19342         LDKChannelAnnouncement this_ptr_conv;
19343         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19344         this_ptr_conv.is_owned = false;
19345         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
19346         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_bitcoin_signature_1(&this_ptr_conv).compact_form);
19347         return ret_arr;
19348 }
19349
19350 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1bitcoin_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19351         LDKChannelAnnouncement this_ptr_conv;
19352         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19353         this_ptr_conv.is_owned = false;
19354         LDKSignature val_ref;
19355         CHECK((*env)->GetArrayLength(env, val) == 64);
19356         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
19357         ChannelAnnouncement_set_bitcoin_signature_1(&this_ptr_conv, val_ref);
19358 }
19359
19360 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1bitcoin_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
19361         LDKChannelAnnouncement this_ptr_conv;
19362         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19363         this_ptr_conv.is_owned = false;
19364         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
19365         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_bitcoin_signature_2(&this_ptr_conv).compact_form);
19366         return ret_arr;
19367 }
19368
19369 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1bitcoin_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19370         LDKChannelAnnouncement this_ptr_conv;
19371         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19372         this_ptr_conv.is_owned = false;
19373         LDKSignature val_ref;
19374         CHECK((*env)->GetArrayLength(env, val) == 64);
19375         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
19376         ChannelAnnouncement_set_bitcoin_signature_2(&this_ptr_conv, val_ref);
19377 }
19378
19379 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
19380         LDKChannelAnnouncement this_ptr_conv;
19381         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19382         this_ptr_conv.is_owned = false;
19383         LDKUnsignedChannelAnnouncement ret_var = ChannelAnnouncement_get_contents(&this_ptr_conv);
19384         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19385         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19386         uint64_t ret_ref = (uint64_t)ret_var.inner;
19387         if (ret_var.is_owned) {
19388                 ret_ref |= 1;
19389         }
19390         return ret_ref;
19391 }
19392
19393 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19394         LDKChannelAnnouncement this_ptr_conv;
19395         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19396         this_ptr_conv.is_owned = false;
19397         LDKUnsignedChannelAnnouncement val_conv;
19398         val_conv.inner = (void*)(val & (~1));
19399         val_conv.is_owned = (val & 1) || (val == 0);
19400         val_conv = UnsignedChannelAnnouncement_clone(&val_conv);
19401         ChannelAnnouncement_set_contents(&this_ptr_conv, val_conv);
19402 }
19403
19404 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) {
19405         LDKSignature node_signature_1_arg_ref;
19406         CHECK((*env)->GetArrayLength(env, node_signature_1_arg) == 64);
19407         (*env)->GetByteArrayRegion(env, node_signature_1_arg, 0, 64, node_signature_1_arg_ref.compact_form);
19408         LDKSignature node_signature_2_arg_ref;
19409         CHECK((*env)->GetArrayLength(env, node_signature_2_arg) == 64);
19410         (*env)->GetByteArrayRegion(env, node_signature_2_arg, 0, 64, node_signature_2_arg_ref.compact_form);
19411         LDKSignature bitcoin_signature_1_arg_ref;
19412         CHECK((*env)->GetArrayLength(env, bitcoin_signature_1_arg) == 64);
19413         (*env)->GetByteArrayRegion(env, bitcoin_signature_1_arg, 0, 64, bitcoin_signature_1_arg_ref.compact_form);
19414         LDKSignature bitcoin_signature_2_arg_ref;
19415         CHECK((*env)->GetArrayLength(env, bitcoin_signature_2_arg) == 64);
19416         (*env)->GetByteArrayRegion(env, bitcoin_signature_2_arg, 0, 64, bitcoin_signature_2_arg_ref.compact_form);
19417         LDKUnsignedChannelAnnouncement contents_arg_conv;
19418         contents_arg_conv.inner = (void*)(contents_arg & (~1));
19419         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
19420         contents_arg_conv = UnsignedChannelAnnouncement_clone(&contents_arg_conv);
19421         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);
19422         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19423         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19424         uint64_t ret_ref = (uint64_t)ret_var.inner;
19425         if (ret_var.is_owned) {
19426                 ret_ref |= 1;
19427         }
19428         return ret_ref;
19429 }
19430
19431 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19432         LDKChannelAnnouncement orig_conv;
19433         orig_conv.inner = (void*)(orig & (~1));
19434         orig_conv.is_owned = false;
19435         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(&orig_conv);
19436         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19437         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19438         uint64_t ret_ref = (uint64_t)ret_var.inner;
19439         if (ret_var.is_owned) {
19440                 ret_ref |= 1;
19441         }
19442         return ret_ref;
19443 }
19444
19445 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19446         LDKUnsignedChannelUpdate this_obj_conv;
19447         this_obj_conv.inner = (void*)(this_obj & (~1));
19448         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19449         UnsignedChannelUpdate_free(this_obj_conv);
19450 }
19451
19452 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
19453         LDKUnsignedChannelUpdate this_ptr_conv;
19454         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19455         this_ptr_conv.is_owned = false;
19456         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
19457         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedChannelUpdate_get_chain_hash(&this_ptr_conv));
19458         return ret_arr;
19459 }
19460
19461 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19462         LDKUnsignedChannelUpdate this_ptr_conv;
19463         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19464         this_ptr_conv.is_owned = false;
19465         LDKThirtyTwoBytes val_ref;
19466         CHECK((*env)->GetArrayLength(env, val) == 32);
19467         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
19468         UnsignedChannelUpdate_set_chain_hash(&this_ptr_conv, val_ref);
19469 }
19470
19471 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
19472         LDKUnsignedChannelUpdate this_ptr_conv;
19473         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19474         this_ptr_conv.is_owned = false;
19475         int64_t ret_val = UnsignedChannelUpdate_get_short_channel_id(&this_ptr_conv);
19476         return ret_val;
19477 }
19478
19479 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19480         LDKUnsignedChannelUpdate this_ptr_conv;
19481         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19482         this_ptr_conv.is_owned = false;
19483         UnsignedChannelUpdate_set_short_channel_id(&this_ptr_conv, val);
19484 }
19485
19486 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
19487         LDKUnsignedChannelUpdate this_ptr_conv;
19488         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19489         this_ptr_conv.is_owned = false;
19490         int32_t ret_val = UnsignedChannelUpdate_get_timestamp(&this_ptr_conv);
19491         return ret_val;
19492 }
19493
19494 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
19495         LDKUnsignedChannelUpdate this_ptr_conv;
19496         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19497         this_ptr_conv.is_owned = false;
19498         UnsignedChannelUpdate_set_timestamp(&this_ptr_conv, val);
19499 }
19500
19501 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1flags(JNIEnv *env, jclass clz, int64_t this_ptr) {
19502         LDKUnsignedChannelUpdate this_ptr_conv;
19503         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19504         this_ptr_conv.is_owned = false;
19505         int8_t ret_val = UnsignedChannelUpdate_get_flags(&this_ptr_conv);
19506         return ret_val;
19507 }
19508
19509 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1flags(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
19510         LDKUnsignedChannelUpdate this_ptr_conv;
19511         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19512         this_ptr_conv.is_owned = false;
19513         UnsignedChannelUpdate_set_flags(&this_ptr_conv, val);
19514 }
19515
19516 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
19517         LDKUnsignedChannelUpdate this_ptr_conv;
19518         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19519         this_ptr_conv.is_owned = false;
19520         int16_t ret_val = UnsignedChannelUpdate_get_cltv_expiry_delta(&this_ptr_conv);
19521         return ret_val;
19522 }
19523
19524 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
19525         LDKUnsignedChannelUpdate this_ptr_conv;
19526         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19527         this_ptr_conv.is_owned = false;
19528         UnsignedChannelUpdate_set_cltv_expiry_delta(&this_ptr_conv, val);
19529 }
19530
19531 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
19532         LDKUnsignedChannelUpdate this_ptr_conv;
19533         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19534         this_ptr_conv.is_owned = false;
19535         int64_t ret_val = UnsignedChannelUpdate_get_htlc_minimum_msat(&this_ptr_conv);
19536         return ret_val;
19537 }
19538
19539 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19540         LDKUnsignedChannelUpdate this_ptr_conv;
19541         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19542         this_ptr_conv.is_owned = false;
19543         UnsignedChannelUpdate_set_htlc_minimum_msat(&this_ptr_conv, val);
19544 }
19545
19546 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
19547         LDKUnsignedChannelUpdate this_ptr_conv;
19548         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19549         this_ptr_conv.is_owned = false;
19550         int32_t ret_val = UnsignedChannelUpdate_get_fee_base_msat(&this_ptr_conv);
19551         return ret_val;
19552 }
19553
19554 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
19555         LDKUnsignedChannelUpdate this_ptr_conv;
19556         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19557         this_ptr_conv.is_owned = false;
19558         UnsignedChannelUpdate_set_fee_base_msat(&this_ptr_conv, val);
19559 }
19560
19561 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
19562         LDKUnsignedChannelUpdate this_ptr_conv;
19563         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19564         this_ptr_conv.is_owned = false;
19565         int32_t ret_val = UnsignedChannelUpdate_get_fee_proportional_millionths(&this_ptr_conv);
19566         return ret_val;
19567 }
19568
19569 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
19570         LDKUnsignedChannelUpdate this_ptr_conv;
19571         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19572         this_ptr_conv.is_owned = false;
19573         UnsignedChannelUpdate_set_fee_proportional_millionths(&this_ptr_conv, val);
19574 }
19575
19576 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19577         LDKUnsignedChannelUpdate orig_conv;
19578         orig_conv.inner = (void*)(orig & (~1));
19579         orig_conv.is_owned = false;
19580         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(&orig_conv);
19581         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19582         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19583         uint64_t ret_ref = (uint64_t)ret_var.inner;
19584         if (ret_var.is_owned) {
19585                 ret_ref |= 1;
19586         }
19587         return ret_ref;
19588 }
19589
19590 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19591         LDKChannelUpdate this_obj_conv;
19592         this_obj_conv.inner = (void*)(this_obj & (~1));
19593         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19594         ChannelUpdate_free(this_obj_conv);
19595 }
19596
19597 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
19598         LDKChannelUpdate this_ptr_conv;
19599         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19600         this_ptr_conv.is_owned = false;
19601         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
19602         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelUpdate_get_signature(&this_ptr_conv).compact_form);
19603         return ret_arr;
19604 }
19605
19606 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19607         LDKChannelUpdate this_ptr_conv;
19608         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19609         this_ptr_conv.is_owned = false;
19610         LDKSignature val_ref;
19611         CHECK((*env)->GetArrayLength(env, val) == 64);
19612         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
19613         ChannelUpdate_set_signature(&this_ptr_conv, val_ref);
19614 }
19615
19616 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
19617         LDKChannelUpdate this_ptr_conv;
19618         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19619         this_ptr_conv.is_owned = false;
19620         LDKUnsignedChannelUpdate ret_var = ChannelUpdate_get_contents(&this_ptr_conv);
19621         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19622         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19623         uint64_t ret_ref = (uint64_t)ret_var.inner;
19624         if (ret_var.is_owned) {
19625                 ret_ref |= 1;
19626         }
19627         return ret_ref;
19628 }
19629
19630 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19631         LDKChannelUpdate this_ptr_conv;
19632         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19633         this_ptr_conv.is_owned = false;
19634         LDKUnsignedChannelUpdate val_conv;
19635         val_conv.inner = (void*)(val & (~1));
19636         val_conv.is_owned = (val & 1) || (val == 0);
19637         val_conv = UnsignedChannelUpdate_clone(&val_conv);
19638         ChannelUpdate_set_contents(&this_ptr_conv, val_conv);
19639 }
19640
19641 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1new(JNIEnv *env, jclass clz, int8_tArray signature_arg, int64_t contents_arg) {
19642         LDKSignature signature_arg_ref;
19643         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
19644         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
19645         LDKUnsignedChannelUpdate contents_arg_conv;
19646         contents_arg_conv.inner = (void*)(contents_arg & (~1));
19647         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
19648         contents_arg_conv = UnsignedChannelUpdate_clone(&contents_arg_conv);
19649         LDKChannelUpdate ret_var = ChannelUpdate_new(signature_arg_ref, contents_arg_conv);
19650         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19651         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19652         uint64_t ret_ref = (uint64_t)ret_var.inner;
19653         if (ret_var.is_owned) {
19654                 ret_ref |= 1;
19655         }
19656         return ret_ref;
19657 }
19658
19659 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19660         LDKChannelUpdate orig_conv;
19661         orig_conv.inner = (void*)(orig & (~1));
19662         orig_conv.is_owned = false;
19663         LDKChannelUpdate ret_var = ChannelUpdate_clone(&orig_conv);
19664         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19665         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19666         uint64_t ret_ref = (uint64_t)ret_var.inner;
19667         if (ret_var.is_owned) {
19668                 ret_ref |= 1;
19669         }
19670         return ret_ref;
19671 }
19672
19673 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19674         LDKQueryChannelRange this_obj_conv;
19675         this_obj_conv.inner = (void*)(this_obj & (~1));
19676         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19677         QueryChannelRange_free(this_obj_conv);
19678 }
19679
19680 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
19681         LDKQueryChannelRange this_ptr_conv;
19682         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19683         this_ptr_conv.is_owned = false;
19684         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
19685         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *QueryChannelRange_get_chain_hash(&this_ptr_conv));
19686         return ret_arr;
19687 }
19688
19689 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19690         LDKQueryChannelRange this_ptr_conv;
19691         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19692         this_ptr_conv.is_owned = false;
19693         LDKThirtyTwoBytes val_ref;
19694         CHECK((*env)->GetArrayLength(env, val) == 32);
19695         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
19696         QueryChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
19697 }
19698
19699 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr) {
19700         LDKQueryChannelRange this_ptr_conv;
19701         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19702         this_ptr_conv.is_owned = false;
19703         int32_t ret_val = QueryChannelRange_get_first_blocknum(&this_ptr_conv);
19704         return ret_val;
19705 }
19706
19707 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
19708         LDKQueryChannelRange this_ptr_conv;
19709         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19710         this_ptr_conv.is_owned = false;
19711         QueryChannelRange_set_first_blocknum(&this_ptr_conv, val);
19712 }
19713
19714 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr) {
19715         LDKQueryChannelRange this_ptr_conv;
19716         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19717         this_ptr_conv.is_owned = false;
19718         int32_t ret_val = QueryChannelRange_get_number_of_blocks(&this_ptr_conv);
19719         return ret_val;
19720 }
19721
19722 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
19723         LDKQueryChannelRange this_ptr_conv;
19724         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19725         this_ptr_conv.is_owned = false;
19726         QueryChannelRange_set_number_of_blocks(&this_ptr_conv, val);
19727 }
19728
19729 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) {
19730         LDKThirtyTwoBytes chain_hash_arg_ref;
19731         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
19732         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
19733         LDKQueryChannelRange ret_var = QueryChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg);
19734         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19735         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19736         uint64_t ret_ref = (uint64_t)ret_var.inner;
19737         if (ret_var.is_owned) {
19738                 ret_ref |= 1;
19739         }
19740         return ret_ref;
19741 }
19742
19743 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19744         LDKQueryChannelRange orig_conv;
19745         orig_conv.inner = (void*)(orig & (~1));
19746         orig_conv.is_owned = false;
19747         LDKQueryChannelRange ret_var = QueryChannelRange_clone(&orig_conv);
19748         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19749         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19750         uint64_t ret_ref = (uint64_t)ret_var.inner;
19751         if (ret_var.is_owned) {
19752                 ret_ref |= 1;
19753         }
19754         return ret_ref;
19755 }
19756
19757 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19758         LDKReplyChannelRange this_obj_conv;
19759         this_obj_conv.inner = (void*)(this_obj & (~1));
19760         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19761         ReplyChannelRange_free(this_obj_conv);
19762 }
19763
19764 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
19765         LDKReplyChannelRange this_ptr_conv;
19766         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19767         this_ptr_conv.is_owned = false;
19768         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
19769         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ReplyChannelRange_get_chain_hash(&this_ptr_conv));
19770         return ret_arr;
19771 }
19772
19773 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19774         LDKReplyChannelRange this_ptr_conv;
19775         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19776         this_ptr_conv.is_owned = false;
19777         LDKThirtyTwoBytes val_ref;
19778         CHECK((*env)->GetArrayLength(env, val) == 32);
19779         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
19780         ReplyChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
19781 }
19782
19783 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr) {
19784         LDKReplyChannelRange this_ptr_conv;
19785         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19786         this_ptr_conv.is_owned = false;
19787         int32_t ret_val = ReplyChannelRange_get_first_blocknum(&this_ptr_conv);
19788         return ret_val;
19789 }
19790
19791 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
19792         LDKReplyChannelRange this_ptr_conv;
19793         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19794         this_ptr_conv.is_owned = false;
19795         ReplyChannelRange_set_first_blocknum(&this_ptr_conv, val);
19796 }
19797
19798 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr) {
19799         LDKReplyChannelRange this_ptr_conv;
19800         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19801         this_ptr_conv.is_owned = false;
19802         int32_t ret_val = ReplyChannelRange_get_number_of_blocks(&this_ptr_conv);
19803         return ret_val;
19804 }
19805
19806 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
19807         LDKReplyChannelRange this_ptr_conv;
19808         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19809         this_ptr_conv.is_owned = false;
19810         ReplyChannelRange_set_number_of_blocks(&this_ptr_conv, val);
19811 }
19812
19813 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1sync_1complete(JNIEnv *env, jclass clz, int64_t this_ptr) {
19814         LDKReplyChannelRange this_ptr_conv;
19815         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19816         this_ptr_conv.is_owned = false;
19817         jboolean ret_val = ReplyChannelRange_get_sync_complete(&this_ptr_conv);
19818         return ret_val;
19819 }
19820
19821 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1sync_1complete(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
19822         LDKReplyChannelRange this_ptr_conv;
19823         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19824         this_ptr_conv.is_owned = false;
19825         ReplyChannelRange_set_sync_complete(&this_ptr_conv, val);
19826 }
19827
19828 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
19829         LDKReplyChannelRange this_ptr_conv;
19830         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19831         this_ptr_conv.is_owned = false;
19832         LDKCVec_u64Z val_constr;
19833         val_constr.datalen = (*env)->GetArrayLength(env, val);
19834         if (val_constr.datalen > 0)
19835                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
19836         else
19837                 val_constr.data = NULL;
19838         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
19839         for (size_t g = 0; g < val_constr.datalen; g++) {
19840                 int64_t val_conv_6 = val_vals[g];
19841                 val_constr.data[g] = val_conv_6;
19842         }
19843         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
19844         ReplyChannelRange_set_short_channel_ids(&this_ptr_conv, val_constr);
19845 }
19846
19847 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) {
19848         LDKThirtyTwoBytes chain_hash_arg_ref;
19849         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
19850         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
19851         LDKCVec_u64Z short_channel_ids_arg_constr;
19852         short_channel_ids_arg_constr.datalen = (*env)->GetArrayLength(env, short_channel_ids_arg);
19853         if (short_channel_ids_arg_constr.datalen > 0)
19854                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
19855         else
19856                 short_channel_ids_arg_constr.data = NULL;
19857         int64_t* short_channel_ids_arg_vals = (*env)->GetLongArrayElements (env, short_channel_ids_arg, NULL);
19858         for (size_t g = 0; g < short_channel_ids_arg_constr.datalen; g++) {
19859                 int64_t short_channel_ids_arg_conv_6 = short_channel_ids_arg_vals[g];
19860                 short_channel_ids_arg_constr.data[g] = short_channel_ids_arg_conv_6;
19861         }
19862         (*env)->ReleaseLongArrayElements(env, short_channel_ids_arg, short_channel_ids_arg_vals, 0);
19863         LDKReplyChannelRange ret_var = ReplyChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg, sync_complete_arg, short_channel_ids_arg_constr);
19864         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19865         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19866         uint64_t ret_ref = (uint64_t)ret_var.inner;
19867         if (ret_var.is_owned) {
19868                 ret_ref |= 1;
19869         }
19870         return ret_ref;
19871 }
19872
19873 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19874         LDKReplyChannelRange orig_conv;
19875         orig_conv.inner = (void*)(orig & (~1));
19876         orig_conv.is_owned = false;
19877         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(&orig_conv);
19878         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19879         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19880         uint64_t ret_ref = (uint64_t)ret_var.inner;
19881         if (ret_var.is_owned) {
19882                 ret_ref |= 1;
19883         }
19884         return ret_ref;
19885 }
19886
19887 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19888         LDKQueryShortChannelIds this_obj_conv;
19889         this_obj_conv.inner = (void*)(this_obj & (~1));
19890         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19891         QueryShortChannelIds_free(this_obj_conv);
19892 }
19893
19894 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
19895         LDKQueryShortChannelIds this_ptr_conv;
19896         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19897         this_ptr_conv.is_owned = false;
19898         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
19899         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *QueryShortChannelIds_get_chain_hash(&this_ptr_conv));
19900         return ret_arr;
19901 }
19902
19903 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19904         LDKQueryShortChannelIds this_ptr_conv;
19905         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19906         this_ptr_conv.is_owned = false;
19907         LDKThirtyTwoBytes val_ref;
19908         CHECK((*env)->GetArrayLength(env, val) == 32);
19909         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
19910         QueryShortChannelIds_set_chain_hash(&this_ptr_conv, val_ref);
19911 }
19912
19913 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1set_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
19914         LDKQueryShortChannelIds this_ptr_conv;
19915         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19916         this_ptr_conv.is_owned = false;
19917         LDKCVec_u64Z val_constr;
19918         val_constr.datalen = (*env)->GetArrayLength(env, val);
19919         if (val_constr.datalen > 0)
19920                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
19921         else
19922                 val_constr.data = NULL;
19923         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
19924         for (size_t g = 0; g < val_constr.datalen; g++) {
19925                 int64_t val_conv_6 = val_vals[g];
19926                 val_constr.data[g] = val_conv_6;
19927         }
19928         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
19929         QueryShortChannelIds_set_short_channel_ids(&this_ptr_conv, val_constr);
19930 }
19931
19932 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) {
19933         LDKThirtyTwoBytes chain_hash_arg_ref;
19934         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
19935         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
19936         LDKCVec_u64Z short_channel_ids_arg_constr;
19937         short_channel_ids_arg_constr.datalen = (*env)->GetArrayLength(env, short_channel_ids_arg);
19938         if (short_channel_ids_arg_constr.datalen > 0)
19939                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
19940         else
19941                 short_channel_ids_arg_constr.data = NULL;
19942         int64_t* short_channel_ids_arg_vals = (*env)->GetLongArrayElements (env, short_channel_ids_arg, NULL);
19943         for (size_t g = 0; g < short_channel_ids_arg_constr.datalen; g++) {
19944                 int64_t short_channel_ids_arg_conv_6 = short_channel_ids_arg_vals[g];
19945                 short_channel_ids_arg_constr.data[g] = short_channel_ids_arg_conv_6;
19946         }
19947         (*env)->ReleaseLongArrayElements(env, short_channel_ids_arg, short_channel_ids_arg_vals, 0);
19948         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_new(chain_hash_arg_ref, short_channel_ids_arg_constr);
19949         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19950         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19951         uint64_t ret_ref = (uint64_t)ret_var.inner;
19952         if (ret_var.is_owned) {
19953                 ret_ref |= 1;
19954         }
19955         return ret_ref;
19956 }
19957
19958 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19959         LDKQueryShortChannelIds orig_conv;
19960         orig_conv.inner = (void*)(orig & (~1));
19961         orig_conv.is_owned = false;
19962         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(&orig_conv);
19963         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19964         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19965         uint64_t ret_ref = (uint64_t)ret_var.inner;
19966         if (ret_var.is_owned) {
19967                 ret_ref |= 1;
19968         }
19969         return ret_ref;
19970 }
19971
19972 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19973         LDKReplyShortChannelIdsEnd this_obj_conv;
19974         this_obj_conv.inner = (void*)(this_obj & (~1));
19975         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19976         ReplyShortChannelIdsEnd_free(this_obj_conv);
19977 }
19978
19979 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
19980         LDKReplyShortChannelIdsEnd this_ptr_conv;
19981         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19982         this_ptr_conv.is_owned = false;
19983         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
19984         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ReplyShortChannelIdsEnd_get_chain_hash(&this_ptr_conv));
19985         return ret_arr;
19986 }
19987
19988 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19989         LDKReplyShortChannelIdsEnd this_ptr_conv;
19990         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19991         this_ptr_conv.is_owned = false;
19992         LDKThirtyTwoBytes val_ref;
19993         CHECK((*env)->GetArrayLength(env, val) == 32);
19994         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
19995         ReplyShortChannelIdsEnd_set_chain_hash(&this_ptr_conv, val_ref);
19996 }
19997
19998 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1get_1full_1information(JNIEnv *env, jclass clz, int64_t this_ptr) {
19999         LDKReplyShortChannelIdsEnd this_ptr_conv;
20000         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20001         this_ptr_conv.is_owned = false;
20002         jboolean ret_val = ReplyShortChannelIdsEnd_get_full_information(&this_ptr_conv);
20003         return ret_val;
20004 }
20005
20006 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1set_1full_1information(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
20007         LDKReplyShortChannelIdsEnd this_ptr_conv;
20008         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20009         this_ptr_conv.is_owned = false;
20010         ReplyShortChannelIdsEnd_set_full_information(&this_ptr_conv, val);
20011 }
20012
20013 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1new(JNIEnv *env, jclass clz, int8_tArray chain_hash_arg, jboolean full_information_arg) {
20014         LDKThirtyTwoBytes chain_hash_arg_ref;
20015         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
20016         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
20017         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_new(chain_hash_arg_ref, full_information_arg);
20018         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20019         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20020         uint64_t ret_ref = (uint64_t)ret_var.inner;
20021         if (ret_var.is_owned) {
20022                 ret_ref |= 1;
20023         }
20024         return ret_ref;
20025 }
20026
20027 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20028         LDKReplyShortChannelIdsEnd orig_conv;
20029         orig_conv.inner = (void*)(orig & (~1));
20030         orig_conv.is_owned = false;
20031         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(&orig_conv);
20032         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20033         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20034         uint64_t ret_ref = (uint64_t)ret_var.inner;
20035         if (ret_var.is_owned) {
20036                 ret_ref |= 1;
20037         }
20038         return ret_ref;
20039 }
20040
20041 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20042         LDKGossipTimestampFilter this_obj_conv;
20043         this_obj_conv.inner = (void*)(this_obj & (~1));
20044         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20045         GossipTimestampFilter_free(this_obj_conv);
20046 }
20047
20048 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
20049         LDKGossipTimestampFilter this_ptr_conv;
20050         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20051         this_ptr_conv.is_owned = false;
20052         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
20053         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *GossipTimestampFilter_get_chain_hash(&this_ptr_conv));
20054         return ret_arr;
20055 }
20056
20057 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20058         LDKGossipTimestampFilter this_ptr_conv;
20059         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20060         this_ptr_conv.is_owned = false;
20061         LDKThirtyTwoBytes val_ref;
20062         CHECK((*env)->GetArrayLength(env, val) == 32);
20063         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
20064         GossipTimestampFilter_set_chain_hash(&this_ptr_conv, val_ref);
20065 }
20066
20067 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1first_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
20068         LDKGossipTimestampFilter this_ptr_conv;
20069         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20070         this_ptr_conv.is_owned = false;
20071         int32_t ret_val = GossipTimestampFilter_get_first_timestamp(&this_ptr_conv);
20072         return ret_val;
20073 }
20074
20075 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1first_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
20076         LDKGossipTimestampFilter this_ptr_conv;
20077         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20078         this_ptr_conv.is_owned = false;
20079         GossipTimestampFilter_set_first_timestamp(&this_ptr_conv, val);
20080 }
20081
20082 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1timestamp_1range(JNIEnv *env, jclass clz, int64_t this_ptr) {
20083         LDKGossipTimestampFilter this_ptr_conv;
20084         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20085         this_ptr_conv.is_owned = false;
20086         int32_t ret_val = GossipTimestampFilter_get_timestamp_range(&this_ptr_conv);
20087         return ret_val;
20088 }
20089
20090 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1timestamp_1range(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
20091         LDKGossipTimestampFilter this_ptr_conv;
20092         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20093         this_ptr_conv.is_owned = false;
20094         GossipTimestampFilter_set_timestamp_range(&this_ptr_conv, val);
20095 }
20096
20097 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) {
20098         LDKThirtyTwoBytes chain_hash_arg_ref;
20099         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
20100         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
20101         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_new(chain_hash_arg_ref, first_timestamp_arg, timestamp_range_arg);
20102         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20103         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20104         uint64_t ret_ref = (uint64_t)ret_var.inner;
20105         if (ret_var.is_owned) {
20106                 ret_ref |= 1;
20107         }
20108         return ret_ref;
20109 }
20110
20111 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20112         LDKGossipTimestampFilter orig_conv;
20113         orig_conv.inner = (void*)(orig & (~1));
20114         orig_conv.is_owned = false;
20115         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(&orig_conv);
20116         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20117         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20118         uint64_t ret_ref = (uint64_t)ret_var.inner;
20119         if (ret_var.is_owned) {
20120                 ret_ref |= 1;
20121         }
20122         return ret_ref;
20123 }
20124
20125 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorAction_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
20126         if ((this_ptr & 1) != 0) return;
20127         LDKErrorAction this_ptr_conv = *(LDKErrorAction*)(((uint64_t)this_ptr) & ~1);
20128         FREE((void*)this_ptr);
20129         ErrorAction_free(this_ptr_conv);
20130 }
20131
20132 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20133         LDKErrorAction* orig_conv = (LDKErrorAction*)orig;
20134         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
20135         *ret_copy = ErrorAction_clone(orig_conv);
20136         uint64_t ret_ref = (uint64_t)ret_copy;
20137         return ret_ref;
20138 }
20139
20140 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20141         LDKLightningError this_obj_conv;
20142         this_obj_conv.inner = (void*)(this_obj & (~1));
20143         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20144         LightningError_free(this_obj_conv);
20145 }
20146
20147 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_LightningError_1get_1err(JNIEnv *env, jclass clz, int64_t this_ptr) {
20148         LDKLightningError this_ptr_conv;
20149         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20150         this_ptr_conv.is_owned = false;
20151         LDKStr ret_str = LightningError_get_err(&this_ptr_conv);
20152         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
20153         return ret_conv;
20154 }
20155
20156 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1set_1err(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
20157         LDKLightningError this_ptr_conv;
20158         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20159         this_ptr_conv.is_owned = false;
20160         LDKStr val_conv = java_to_owned_str(env, val);
20161         LightningError_set_err(&this_ptr_conv, val_conv);
20162 }
20163
20164 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1get_1action(JNIEnv *env, jclass clz, int64_t this_ptr) {
20165         LDKLightningError this_ptr_conv;
20166         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20167         this_ptr_conv.is_owned = false;
20168         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
20169         *ret_copy = LightningError_get_action(&this_ptr_conv);
20170         uint64_t ret_ref = (uint64_t)ret_copy;
20171         return ret_ref;
20172 }
20173
20174 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1set_1action(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20175         LDKLightningError this_ptr_conv;
20176         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20177         this_ptr_conv.is_owned = false;
20178         LDKErrorAction val_conv = *(LDKErrorAction*)(((uint64_t)val) & ~1);
20179         LightningError_set_action(&this_ptr_conv, val_conv);
20180 }
20181
20182 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1new(JNIEnv *env, jclass clz, jstring err_arg, int64_t action_arg) {
20183         LDKStr err_arg_conv = java_to_owned_str(env, err_arg);
20184         LDKErrorAction action_arg_conv = *(LDKErrorAction*)(((uint64_t)action_arg) & ~1);
20185         LDKLightningError ret_var = LightningError_new(err_arg_conv, action_arg_conv);
20186         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20187         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20188         uint64_t ret_ref = (uint64_t)ret_var.inner;
20189         if (ret_var.is_owned) {
20190                 ret_ref |= 1;
20191         }
20192         return ret_ref;
20193 }
20194
20195 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20196         LDKLightningError orig_conv;
20197         orig_conv.inner = (void*)(orig & (~1));
20198         orig_conv.is_owned = false;
20199         LDKLightningError ret_var = LightningError_clone(&orig_conv);
20200         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20201         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20202         uint64_t ret_ref = (uint64_t)ret_var.inner;
20203         if (ret_var.is_owned) {
20204                 ret_ref |= 1;
20205         }
20206         return ret_ref;
20207 }
20208
20209 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20210         LDKCommitmentUpdate this_obj_conv;
20211         this_obj_conv.inner = (void*)(this_obj & (~1));
20212         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20213         CommitmentUpdate_free(this_obj_conv);
20214 }
20215
20216 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1add_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
20217         LDKCommitmentUpdate this_ptr_conv;
20218         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20219         this_ptr_conv.is_owned = false;
20220         LDKCVec_UpdateAddHTLCZ val_constr;
20221         val_constr.datalen = (*env)->GetArrayLength(env, val);
20222         if (val_constr.datalen > 0)
20223                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
20224         else
20225                 val_constr.data = NULL;
20226         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
20227         for (size_t p = 0; p < val_constr.datalen; p++) {
20228                 int64_t val_conv_15 = val_vals[p];
20229                 LDKUpdateAddHTLC val_conv_15_conv;
20230                 val_conv_15_conv.inner = (void*)(val_conv_15 & (~1));
20231                 val_conv_15_conv.is_owned = (val_conv_15 & 1) || (val_conv_15 == 0);
20232                 val_conv_15_conv = UpdateAddHTLC_clone(&val_conv_15_conv);
20233                 val_constr.data[p] = val_conv_15_conv;
20234         }
20235         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
20236         CommitmentUpdate_set_update_add_htlcs(&this_ptr_conv, val_constr);
20237 }
20238
20239 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fulfill_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
20240         LDKCommitmentUpdate this_ptr_conv;
20241         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20242         this_ptr_conv.is_owned = false;
20243         LDKCVec_UpdateFulfillHTLCZ val_constr;
20244         val_constr.datalen = (*env)->GetArrayLength(env, val);
20245         if (val_constr.datalen > 0)
20246                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
20247         else
20248                 val_constr.data = NULL;
20249         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
20250         for (size_t t = 0; t < val_constr.datalen; t++) {
20251                 int64_t val_conv_19 = val_vals[t];
20252                 LDKUpdateFulfillHTLC val_conv_19_conv;
20253                 val_conv_19_conv.inner = (void*)(val_conv_19 & (~1));
20254                 val_conv_19_conv.is_owned = (val_conv_19 & 1) || (val_conv_19 == 0);
20255                 val_conv_19_conv = UpdateFulfillHTLC_clone(&val_conv_19_conv);
20256                 val_constr.data[t] = val_conv_19_conv;
20257         }
20258         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
20259         CommitmentUpdate_set_update_fulfill_htlcs(&this_ptr_conv, val_constr);
20260 }
20261
20262 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fail_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
20263         LDKCommitmentUpdate this_ptr_conv;
20264         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20265         this_ptr_conv.is_owned = false;
20266         LDKCVec_UpdateFailHTLCZ val_constr;
20267         val_constr.datalen = (*env)->GetArrayLength(env, val);
20268         if (val_constr.datalen > 0)
20269                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
20270         else
20271                 val_constr.data = NULL;
20272         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
20273         for (size_t q = 0; q < val_constr.datalen; q++) {
20274                 int64_t val_conv_16 = val_vals[q];
20275                 LDKUpdateFailHTLC val_conv_16_conv;
20276                 val_conv_16_conv.inner = (void*)(val_conv_16 & (~1));
20277                 val_conv_16_conv.is_owned = (val_conv_16 & 1) || (val_conv_16 == 0);
20278                 val_conv_16_conv = UpdateFailHTLC_clone(&val_conv_16_conv);
20279                 val_constr.data[q] = val_conv_16_conv;
20280         }
20281         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
20282         CommitmentUpdate_set_update_fail_htlcs(&this_ptr_conv, val_constr);
20283 }
20284
20285 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) {
20286         LDKCommitmentUpdate this_ptr_conv;
20287         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20288         this_ptr_conv.is_owned = false;
20289         LDKCVec_UpdateFailMalformedHTLCZ val_constr;
20290         val_constr.datalen = (*env)->GetArrayLength(env, val);
20291         if (val_constr.datalen > 0)
20292                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
20293         else
20294                 val_constr.data = NULL;
20295         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
20296         for (size_t z = 0; z < val_constr.datalen; z++) {
20297                 int64_t val_conv_25 = val_vals[z];
20298                 LDKUpdateFailMalformedHTLC val_conv_25_conv;
20299                 val_conv_25_conv.inner = (void*)(val_conv_25 & (~1));
20300                 val_conv_25_conv.is_owned = (val_conv_25 & 1) || (val_conv_25 == 0);
20301                 val_conv_25_conv = UpdateFailMalformedHTLC_clone(&val_conv_25_conv);
20302                 val_constr.data[z] = val_conv_25_conv;
20303         }
20304         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
20305         CommitmentUpdate_set_update_fail_malformed_htlcs(&this_ptr_conv, val_constr);
20306 }
20307
20308 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fee(JNIEnv *env, jclass clz, int64_t this_ptr) {
20309         LDKCommitmentUpdate this_ptr_conv;
20310         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20311         this_ptr_conv.is_owned = false;
20312         LDKUpdateFee ret_var = CommitmentUpdate_get_update_fee(&this_ptr_conv);
20313         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20314         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20315         uint64_t ret_ref = (uint64_t)ret_var.inner;
20316         if (ret_var.is_owned) {
20317                 ret_ref |= 1;
20318         }
20319         return ret_ref;
20320 }
20321
20322 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fee(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20323         LDKCommitmentUpdate this_ptr_conv;
20324         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20325         this_ptr_conv.is_owned = false;
20326         LDKUpdateFee val_conv;
20327         val_conv.inner = (void*)(val & (~1));
20328         val_conv.is_owned = (val & 1) || (val == 0);
20329         val_conv = UpdateFee_clone(&val_conv);
20330         CommitmentUpdate_set_update_fee(&this_ptr_conv, val_conv);
20331 }
20332
20333 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1commitment_1signed(JNIEnv *env, jclass clz, int64_t this_ptr) {
20334         LDKCommitmentUpdate this_ptr_conv;
20335         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20336         this_ptr_conv.is_owned = false;
20337         LDKCommitmentSigned ret_var = CommitmentUpdate_get_commitment_signed(&this_ptr_conv);
20338         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20339         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20340         uint64_t ret_ref = (uint64_t)ret_var.inner;
20341         if (ret_var.is_owned) {
20342                 ret_ref |= 1;
20343         }
20344         return ret_ref;
20345 }
20346
20347 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1commitment_1signed(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20348         LDKCommitmentUpdate this_ptr_conv;
20349         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20350         this_ptr_conv.is_owned = false;
20351         LDKCommitmentSigned val_conv;
20352         val_conv.inner = (void*)(val & (~1));
20353         val_conv.is_owned = (val & 1) || (val == 0);
20354         val_conv = CommitmentSigned_clone(&val_conv);
20355         CommitmentUpdate_set_commitment_signed(&this_ptr_conv, val_conv);
20356 }
20357
20358 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) {
20359         LDKCVec_UpdateAddHTLCZ update_add_htlcs_arg_constr;
20360         update_add_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_add_htlcs_arg);
20361         if (update_add_htlcs_arg_constr.datalen > 0)
20362                 update_add_htlcs_arg_constr.data = MALLOC(update_add_htlcs_arg_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
20363         else
20364                 update_add_htlcs_arg_constr.data = NULL;
20365         int64_t* update_add_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_add_htlcs_arg, NULL);
20366         for (size_t p = 0; p < update_add_htlcs_arg_constr.datalen; p++) {
20367                 int64_t update_add_htlcs_arg_conv_15 = update_add_htlcs_arg_vals[p];
20368                 LDKUpdateAddHTLC update_add_htlcs_arg_conv_15_conv;
20369                 update_add_htlcs_arg_conv_15_conv.inner = (void*)(update_add_htlcs_arg_conv_15 & (~1));
20370                 update_add_htlcs_arg_conv_15_conv.is_owned = (update_add_htlcs_arg_conv_15 & 1) || (update_add_htlcs_arg_conv_15 == 0);
20371                 update_add_htlcs_arg_conv_15_conv = UpdateAddHTLC_clone(&update_add_htlcs_arg_conv_15_conv);
20372                 update_add_htlcs_arg_constr.data[p] = update_add_htlcs_arg_conv_15_conv;
20373         }
20374         (*env)->ReleaseLongArrayElements(env, update_add_htlcs_arg, update_add_htlcs_arg_vals, 0);
20375         LDKCVec_UpdateFulfillHTLCZ update_fulfill_htlcs_arg_constr;
20376         update_fulfill_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fulfill_htlcs_arg);
20377         if (update_fulfill_htlcs_arg_constr.datalen > 0)
20378                 update_fulfill_htlcs_arg_constr.data = MALLOC(update_fulfill_htlcs_arg_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
20379         else
20380                 update_fulfill_htlcs_arg_constr.data = NULL;
20381         int64_t* update_fulfill_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fulfill_htlcs_arg, NULL);
20382         for (size_t t = 0; t < update_fulfill_htlcs_arg_constr.datalen; t++) {
20383                 int64_t update_fulfill_htlcs_arg_conv_19 = update_fulfill_htlcs_arg_vals[t];
20384                 LDKUpdateFulfillHTLC update_fulfill_htlcs_arg_conv_19_conv;
20385                 update_fulfill_htlcs_arg_conv_19_conv.inner = (void*)(update_fulfill_htlcs_arg_conv_19 & (~1));
20386                 update_fulfill_htlcs_arg_conv_19_conv.is_owned = (update_fulfill_htlcs_arg_conv_19 & 1) || (update_fulfill_htlcs_arg_conv_19 == 0);
20387                 update_fulfill_htlcs_arg_conv_19_conv = UpdateFulfillHTLC_clone(&update_fulfill_htlcs_arg_conv_19_conv);
20388                 update_fulfill_htlcs_arg_constr.data[t] = update_fulfill_htlcs_arg_conv_19_conv;
20389         }
20390         (*env)->ReleaseLongArrayElements(env, update_fulfill_htlcs_arg, update_fulfill_htlcs_arg_vals, 0);
20391         LDKCVec_UpdateFailHTLCZ update_fail_htlcs_arg_constr;
20392         update_fail_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fail_htlcs_arg);
20393         if (update_fail_htlcs_arg_constr.datalen > 0)
20394                 update_fail_htlcs_arg_constr.data = MALLOC(update_fail_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
20395         else
20396                 update_fail_htlcs_arg_constr.data = NULL;
20397         int64_t* update_fail_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fail_htlcs_arg, NULL);
20398         for (size_t q = 0; q < update_fail_htlcs_arg_constr.datalen; q++) {
20399                 int64_t update_fail_htlcs_arg_conv_16 = update_fail_htlcs_arg_vals[q];
20400                 LDKUpdateFailHTLC update_fail_htlcs_arg_conv_16_conv;
20401                 update_fail_htlcs_arg_conv_16_conv.inner = (void*)(update_fail_htlcs_arg_conv_16 & (~1));
20402                 update_fail_htlcs_arg_conv_16_conv.is_owned = (update_fail_htlcs_arg_conv_16 & 1) || (update_fail_htlcs_arg_conv_16 == 0);
20403                 update_fail_htlcs_arg_conv_16_conv = UpdateFailHTLC_clone(&update_fail_htlcs_arg_conv_16_conv);
20404                 update_fail_htlcs_arg_constr.data[q] = update_fail_htlcs_arg_conv_16_conv;
20405         }
20406         (*env)->ReleaseLongArrayElements(env, update_fail_htlcs_arg, update_fail_htlcs_arg_vals, 0);
20407         LDKCVec_UpdateFailMalformedHTLCZ update_fail_malformed_htlcs_arg_constr;
20408         update_fail_malformed_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fail_malformed_htlcs_arg);
20409         if (update_fail_malformed_htlcs_arg_constr.datalen > 0)
20410                 update_fail_malformed_htlcs_arg_constr.data = MALLOC(update_fail_malformed_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
20411         else
20412                 update_fail_malformed_htlcs_arg_constr.data = NULL;
20413         int64_t* update_fail_malformed_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fail_malformed_htlcs_arg, NULL);
20414         for (size_t z = 0; z < update_fail_malformed_htlcs_arg_constr.datalen; z++) {
20415                 int64_t update_fail_malformed_htlcs_arg_conv_25 = update_fail_malformed_htlcs_arg_vals[z];
20416                 LDKUpdateFailMalformedHTLC update_fail_malformed_htlcs_arg_conv_25_conv;
20417                 update_fail_malformed_htlcs_arg_conv_25_conv.inner = (void*)(update_fail_malformed_htlcs_arg_conv_25 & (~1));
20418                 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);
20419                 update_fail_malformed_htlcs_arg_conv_25_conv = UpdateFailMalformedHTLC_clone(&update_fail_malformed_htlcs_arg_conv_25_conv);
20420                 update_fail_malformed_htlcs_arg_constr.data[z] = update_fail_malformed_htlcs_arg_conv_25_conv;
20421         }
20422         (*env)->ReleaseLongArrayElements(env, update_fail_malformed_htlcs_arg, update_fail_malformed_htlcs_arg_vals, 0);
20423         LDKUpdateFee update_fee_arg_conv;
20424         update_fee_arg_conv.inner = (void*)(update_fee_arg & (~1));
20425         update_fee_arg_conv.is_owned = (update_fee_arg & 1) || (update_fee_arg == 0);
20426         update_fee_arg_conv = UpdateFee_clone(&update_fee_arg_conv);
20427         LDKCommitmentSigned commitment_signed_arg_conv;
20428         commitment_signed_arg_conv.inner = (void*)(commitment_signed_arg & (~1));
20429         commitment_signed_arg_conv.is_owned = (commitment_signed_arg & 1) || (commitment_signed_arg == 0);
20430         commitment_signed_arg_conv = CommitmentSigned_clone(&commitment_signed_arg_conv);
20431         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);
20432         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20433         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20434         uint64_t ret_ref = (uint64_t)ret_var.inner;
20435         if (ret_var.is_owned) {
20436                 ret_ref |= 1;
20437         }
20438         return ret_ref;
20439 }
20440
20441 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20442         LDKCommitmentUpdate orig_conv;
20443         orig_conv.inner = (void*)(orig & (~1));
20444         orig_conv.is_owned = false;
20445         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(&orig_conv);
20446         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20447         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20448         uint64_t ret_ref = (uint64_t)ret_var.inner;
20449         if (ret_var.is_owned) {
20450                 ret_ref |= 1;
20451         }
20452         return ret_ref;
20453 }
20454
20455 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCFailChannelUpdate_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
20456         if ((this_ptr & 1) != 0) return;
20457         LDKHTLCFailChannelUpdate this_ptr_conv = *(LDKHTLCFailChannelUpdate*)(((uint64_t)this_ptr) & ~1);
20458         FREE((void*)this_ptr);
20459         HTLCFailChannelUpdate_free(this_ptr_conv);
20460 }
20461
20462 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCFailChannelUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20463         LDKHTLCFailChannelUpdate* orig_conv = (LDKHTLCFailChannelUpdate*)orig;
20464         LDKHTLCFailChannelUpdate *ret_copy = MALLOC(sizeof(LDKHTLCFailChannelUpdate), "LDKHTLCFailChannelUpdate");
20465         *ret_copy = HTLCFailChannelUpdate_clone(orig_conv);
20466         uint64_t ret_ref = (uint64_t)ret_copy;
20467         return ret_ref;
20468 }
20469
20470 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
20471         if ((this_ptr & 1) != 0) return;
20472         LDKChannelMessageHandler this_ptr_conv = *(LDKChannelMessageHandler*)(((uint64_t)this_ptr) & ~1);
20473         FREE((void*)this_ptr);
20474         ChannelMessageHandler_free(this_ptr_conv);
20475 }
20476
20477 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
20478         if ((this_ptr & 1) != 0) return;
20479         LDKRoutingMessageHandler this_ptr_conv = *(LDKRoutingMessageHandler*)(((uint64_t)this_ptr) & ~1);
20480         FREE((void*)this_ptr);
20481         RoutingMessageHandler_free(this_ptr_conv);
20482 }
20483
20484 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1write(JNIEnv *env, jclass clz, int64_t obj) {
20485         LDKAcceptChannel obj_conv;
20486         obj_conv.inner = (void*)(obj & (~1));
20487         obj_conv.is_owned = false;
20488         LDKCVec_u8Z ret_var = AcceptChannel_write(&obj_conv);
20489         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20490         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20491         CVec_u8Z_free(ret_var);
20492         return ret_arr;
20493 }
20494
20495 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20496         LDKu8slice ser_ref;
20497         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20498         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20499         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
20500         *ret_conv = AcceptChannel_read(ser_ref);
20501         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20502         return (uint64_t)ret_conv;
20503 }
20504
20505 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
20506         LDKAnnouncementSignatures obj_conv;
20507         obj_conv.inner = (void*)(obj & (~1));
20508         obj_conv.is_owned = false;
20509         LDKCVec_u8Z ret_var = AnnouncementSignatures_write(&obj_conv);
20510         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20511         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20512         CVec_u8Z_free(ret_var);
20513         return ret_arr;
20514 }
20515
20516 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20517         LDKu8slice ser_ref;
20518         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20519         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20520         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
20521         *ret_conv = AnnouncementSignatures_read(ser_ref);
20522         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20523         return (uint64_t)ret_conv;
20524 }
20525
20526 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1write(JNIEnv *env, jclass clz, int64_t obj) {
20527         LDKChannelReestablish obj_conv;
20528         obj_conv.inner = (void*)(obj & (~1));
20529         obj_conv.is_owned = false;
20530         LDKCVec_u8Z ret_var = ChannelReestablish_write(&obj_conv);
20531         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20532         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20533         CVec_u8Z_free(ret_var);
20534         return ret_arr;
20535 }
20536
20537 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20538         LDKu8slice ser_ref;
20539         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20540         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20541         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
20542         *ret_conv = ChannelReestablish_read(ser_ref);
20543         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20544         return (uint64_t)ret_conv;
20545 }
20546
20547 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
20548         LDKClosingSigned obj_conv;
20549         obj_conv.inner = (void*)(obj & (~1));
20550         obj_conv.is_owned = false;
20551         LDKCVec_u8Z ret_var = ClosingSigned_write(&obj_conv);
20552         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20553         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20554         CVec_u8Z_free(ret_var);
20555         return ret_arr;
20556 }
20557
20558 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20559         LDKu8slice ser_ref;
20560         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20561         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20562         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
20563         *ret_conv = ClosingSigned_read(ser_ref);
20564         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20565         return (uint64_t)ret_conv;
20566 }
20567
20568 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
20569         LDKCommitmentSigned obj_conv;
20570         obj_conv.inner = (void*)(obj & (~1));
20571         obj_conv.is_owned = false;
20572         LDKCVec_u8Z ret_var = CommitmentSigned_write(&obj_conv);
20573         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20574         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20575         CVec_u8Z_free(ret_var);
20576         return ret_arr;
20577 }
20578
20579 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20580         LDKu8slice ser_ref;
20581         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20582         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20583         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
20584         *ret_conv = CommitmentSigned_read(ser_ref);
20585         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20586         return (uint64_t)ret_conv;
20587 }
20588
20589 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1write(JNIEnv *env, jclass clz, int64_t obj) {
20590         LDKFundingCreated obj_conv;
20591         obj_conv.inner = (void*)(obj & (~1));
20592         obj_conv.is_owned = false;
20593         LDKCVec_u8Z ret_var = FundingCreated_write(&obj_conv);
20594         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20595         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20596         CVec_u8Z_free(ret_var);
20597         return ret_arr;
20598 }
20599
20600 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20601         LDKu8slice ser_ref;
20602         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20603         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20604         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
20605         *ret_conv = FundingCreated_read(ser_ref);
20606         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20607         return (uint64_t)ret_conv;
20608 }
20609
20610 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
20611         LDKFundingSigned obj_conv;
20612         obj_conv.inner = (void*)(obj & (~1));
20613         obj_conv.is_owned = false;
20614         LDKCVec_u8Z ret_var = FundingSigned_write(&obj_conv);
20615         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20616         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20617         CVec_u8Z_free(ret_var);
20618         return ret_arr;
20619 }
20620
20621 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20622         LDKu8slice ser_ref;
20623         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20624         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20625         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
20626         *ret_conv = FundingSigned_read(ser_ref);
20627         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20628         return (uint64_t)ret_conv;
20629 }
20630
20631 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingLocked_1write(JNIEnv *env, jclass clz, int64_t obj) {
20632         LDKFundingLocked obj_conv;
20633         obj_conv.inner = (void*)(obj & (~1));
20634         obj_conv.is_owned = false;
20635         LDKCVec_u8Z ret_var = FundingLocked_write(&obj_conv);
20636         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20637         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20638         CVec_u8Z_free(ret_var);
20639         return ret_arr;
20640 }
20641
20642 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingLocked_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20643         LDKu8slice ser_ref;
20644         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20645         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20646         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
20647         *ret_conv = FundingLocked_read(ser_ref);
20648         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20649         return (uint64_t)ret_conv;
20650 }
20651
20652 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Init_1write(JNIEnv *env, jclass clz, int64_t obj) {
20653         LDKInit obj_conv;
20654         obj_conv.inner = (void*)(obj & (~1));
20655         obj_conv.is_owned = false;
20656         LDKCVec_u8Z ret_var = Init_write(&obj_conv);
20657         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20658         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20659         CVec_u8Z_free(ret_var);
20660         return ret_arr;
20661 }
20662
20663 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20664         LDKu8slice ser_ref;
20665         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20666         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20667         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
20668         *ret_conv = Init_read(ser_ref);
20669         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20670         return (uint64_t)ret_conv;
20671 }
20672
20673 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1write(JNIEnv *env, jclass clz, int64_t obj) {
20674         LDKOpenChannel obj_conv;
20675         obj_conv.inner = (void*)(obj & (~1));
20676         obj_conv.is_owned = false;
20677         LDKCVec_u8Z ret_var = OpenChannel_write(&obj_conv);
20678         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20679         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20680         CVec_u8Z_free(ret_var);
20681         return ret_arr;
20682 }
20683
20684 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20685         LDKu8slice ser_ref;
20686         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20687         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20688         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
20689         *ret_conv = OpenChannel_read(ser_ref);
20690         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20691         return (uint64_t)ret_conv;
20692 }
20693
20694 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1write(JNIEnv *env, jclass clz, int64_t obj) {
20695         LDKRevokeAndACK obj_conv;
20696         obj_conv.inner = (void*)(obj & (~1));
20697         obj_conv.is_owned = false;
20698         LDKCVec_u8Z ret_var = RevokeAndACK_write(&obj_conv);
20699         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20700         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20701         CVec_u8Z_free(ret_var);
20702         return ret_arr;
20703 }
20704
20705 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20706         LDKu8slice ser_ref;
20707         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20708         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20709         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
20710         *ret_conv = RevokeAndACK_read(ser_ref);
20711         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20712         return (uint64_t)ret_conv;
20713 }
20714
20715 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1write(JNIEnv *env, jclass clz, int64_t obj) {
20716         LDKShutdown obj_conv;
20717         obj_conv.inner = (void*)(obj & (~1));
20718         obj_conv.is_owned = false;
20719         LDKCVec_u8Z ret_var = Shutdown_write(&obj_conv);
20720         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20721         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20722         CVec_u8Z_free(ret_var);
20723         return ret_arr;
20724 }
20725
20726 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20727         LDKu8slice ser_ref;
20728         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20729         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20730         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
20731         *ret_conv = Shutdown_read(ser_ref);
20732         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20733         return (uint64_t)ret_conv;
20734 }
20735
20736 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
20737         LDKUpdateFailHTLC obj_conv;
20738         obj_conv.inner = (void*)(obj & (~1));
20739         obj_conv.is_owned = false;
20740         LDKCVec_u8Z ret_var = UpdateFailHTLC_write(&obj_conv);
20741         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20742         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20743         CVec_u8Z_free(ret_var);
20744         return ret_arr;
20745 }
20746
20747 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20748         LDKu8slice ser_ref;
20749         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20750         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20751         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
20752         *ret_conv = UpdateFailHTLC_read(ser_ref);
20753         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20754         return (uint64_t)ret_conv;
20755 }
20756
20757 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
20758         LDKUpdateFailMalformedHTLC obj_conv;
20759         obj_conv.inner = (void*)(obj & (~1));
20760         obj_conv.is_owned = false;
20761         LDKCVec_u8Z ret_var = UpdateFailMalformedHTLC_write(&obj_conv);
20762         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20763         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20764         CVec_u8Z_free(ret_var);
20765         return ret_arr;
20766 }
20767
20768 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20769         LDKu8slice ser_ref;
20770         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20771         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20772         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
20773         *ret_conv = UpdateFailMalformedHTLC_read(ser_ref);
20774         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20775         return (uint64_t)ret_conv;
20776 }
20777
20778 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFee_1write(JNIEnv *env, jclass clz, int64_t obj) {
20779         LDKUpdateFee obj_conv;
20780         obj_conv.inner = (void*)(obj & (~1));
20781         obj_conv.is_owned = false;
20782         LDKCVec_u8Z ret_var = UpdateFee_write(&obj_conv);
20783         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20784         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20785         CVec_u8Z_free(ret_var);
20786         return ret_arr;
20787 }
20788
20789 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20790         LDKu8slice ser_ref;
20791         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20792         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20793         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
20794         *ret_conv = UpdateFee_read(ser_ref);
20795         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20796         return (uint64_t)ret_conv;
20797 }
20798
20799 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
20800         LDKUpdateFulfillHTLC obj_conv;
20801         obj_conv.inner = (void*)(obj & (~1));
20802         obj_conv.is_owned = false;
20803         LDKCVec_u8Z ret_var = UpdateFulfillHTLC_write(&obj_conv);
20804         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20805         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20806         CVec_u8Z_free(ret_var);
20807         return ret_arr;
20808 }
20809
20810 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20811         LDKu8slice ser_ref;
20812         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20813         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20814         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
20815         *ret_conv = UpdateFulfillHTLC_read(ser_ref);
20816         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20817         return (uint64_t)ret_conv;
20818 }
20819
20820 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
20821         LDKUpdateAddHTLC obj_conv;
20822         obj_conv.inner = (void*)(obj & (~1));
20823         obj_conv.is_owned = false;
20824         LDKCVec_u8Z ret_var = UpdateAddHTLC_write(&obj_conv);
20825         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20826         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20827         CVec_u8Z_free(ret_var);
20828         return ret_arr;
20829 }
20830
20831 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20832         LDKu8slice ser_ref;
20833         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20834         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20835         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
20836         *ret_conv = UpdateAddHTLC_read(ser_ref);
20837         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20838         return (uint64_t)ret_conv;
20839 }
20840
20841 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Ping_1write(JNIEnv *env, jclass clz, int64_t obj) {
20842         LDKPing obj_conv;
20843         obj_conv.inner = (void*)(obj & (~1));
20844         obj_conv.is_owned = false;
20845         LDKCVec_u8Z ret_var = Ping_write(&obj_conv);
20846         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20847         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20848         CVec_u8Z_free(ret_var);
20849         return ret_arr;
20850 }
20851
20852 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20853         LDKu8slice ser_ref;
20854         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20855         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20856         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
20857         *ret_conv = Ping_read(ser_ref);
20858         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20859         return (uint64_t)ret_conv;
20860 }
20861
20862 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Pong_1write(JNIEnv *env, jclass clz, int64_t obj) {
20863         LDKPong obj_conv;
20864         obj_conv.inner = (void*)(obj & (~1));
20865         obj_conv.is_owned = false;
20866         LDKCVec_u8Z ret_var = Pong_write(&obj_conv);
20867         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20868         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20869         CVec_u8Z_free(ret_var);
20870         return ret_arr;
20871 }
20872
20873 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20874         LDKu8slice ser_ref;
20875         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20876         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20877         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
20878         *ret_conv = Pong_read(ser_ref);
20879         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20880         return (uint64_t)ret_conv;
20881 }
20882
20883 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
20884         LDKUnsignedChannelAnnouncement obj_conv;
20885         obj_conv.inner = (void*)(obj & (~1));
20886         obj_conv.is_owned = false;
20887         LDKCVec_u8Z ret_var = UnsignedChannelAnnouncement_write(&obj_conv);
20888         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20889         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20890         CVec_u8Z_free(ret_var);
20891         return ret_arr;
20892 }
20893
20894 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20895         LDKu8slice ser_ref;
20896         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20897         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20898         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
20899         *ret_conv = UnsignedChannelAnnouncement_read(ser_ref);
20900         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20901         return (uint64_t)ret_conv;
20902 }
20903
20904 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
20905         LDKChannelAnnouncement obj_conv;
20906         obj_conv.inner = (void*)(obj & (~1));
20907         obj_conv.is_owned = false;
20908         LDKCVec_u8Z ret_var = ChannelAnnouncement_write(&obj_conv);
20909         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20910         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20911         CVec_u8Z_free(ret_var);
20912         return ret_arr;
20913 }
20914
20915 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20916         LDKu8slice ser_ref;
20917         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20918         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20919         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
20920         *ret_conv = ChannelAnnouncement_read(ser_ref);
20921         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20922         return (uint64_t)ret_conv;
20923 }
20924
20925 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
20926         LDKUnsignedChannelUpdate obj_conv;
20927         obj_conv.inner = (void*)(obj & (~1));
20928         obj_conv.is_owned = false;
20929         LDKCVec_u8Z ret_var = UnsignedChannelUpdate_write(&obj_conv);
20930         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20931         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20932         CVec_u8Z_free(ret_var);
20933         return ret_arr;
20934 }
20935
20936 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20937         LDKu8slice ser_ref;
20938         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20939         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20940         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
20941         *ret_conv = UnsignedChannelUpdate_read(ser_ref);
20942         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20943         return (uint64_t)ret_conv;
20944 }
20945
20946 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
20947         LDKChannelUpdate obj_conv;
20948         obj_conv.inner = (void*)(obj & (~1));
20949         obj_conv.is_owned = false;
20950         LDKCVec_u8Z ret_var = ChannelUpdate_write(&obj_conv);
20951         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20952         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20953         CVec_u8Z_free(ret_var);
20954         return ret_arr;
20955 }
20956
20957 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20958         LDKu8slice ser_ref;
20959         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20960         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20961         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
20962         *ret_conv = ChannelUpdate_read(ser_ref);
20963         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20964         return (uint64_t)ret_conv;
20965 }
20966
20967 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1write(JNIEnv *env, jclass clz, int64_t obj) {
20968         LDKErrorMessage obj_conv;
20969         obj_conv.inner = (void*)(obj & (~1));
20970         obj_conv.is_owned = false;
20971         LDKCVec_u8Z ret_var = ErrorMessage_write(&obj_conv);
20972         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20973         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20974         CVec_u8Z_free(ret_var);
20975         return ret_arr;
20976 }
20977
20978 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20979         LDKu8slice ser_ref;
20980         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20981         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20982         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
20983         *ret_conv = ErrorMessage_read(ser_ref);
20984         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20985         return (uint64_t)ret_conv;
20986 }
20987
20988 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
20989         LDKUnsignedNodeAnnouncement obj_conv;
20990         obj_conv.inner = (void*)(obj & (~1));
20991         obj_conv.is_owned = false;
20992         LDKCVec_u8Z ret_var = UnsignedNodeAnnouncement_write(&obj_conv);
20993         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20994         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20995         CVec_u8Z_free(ret_var);
20996         return ret_arr;
20997 }
20998
20999 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21000         LDKu8slice ser_ref;
21001         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21002         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21003         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
21004         *ret_conv = UnsignedNodeAnnouncement_read(ser_ref);
21005         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21006         return (uint64_t)ret_conv;
21007 }
21008
21009 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
21010         LDKNodeAnnouncement obj_conv;
21011         obj_conv.inner = (void*)(obj & (~1));
21012         obj_conv.is_owned = false;
21013         LDKCVec_u8Z ret_var = NodeAnnouncement_write(&obj_conv);
21014         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21015         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21016         CVec_u8Z_free(ret_var);
21017         return ret_arr;
21018 }
21019
21020 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21021         LDKu8slice ser_ref;
21022         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21023         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21024         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
21025         *ret_conv = NodeAnnouncement_read(ser_ref);
21026         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21027         return (uint64_t)ret_conv;
21028 }
21029
21030 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21031         LDKu8slice ser_ref;
21032         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21033         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21034         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
21035         *ret_conv = QueryShortChannelIds_read(ser_ref);
21036         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21037         return (uint64_t)ret_conv;
21038 }
21039
21040 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1write(JNIEnv *env, jclass clz, int64_t obj) {
21041         LDKQueryShortChannelIds obj_conv;
21042         obj_conv.inner = (void*)(obj & (~1));
21043         obj_conv.is_owned = false;
21044         LDKCVec_u8Z ret_var = QueryShortChannelIds_write(&obj_conv);
21045         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21046         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21047         CVec_u8Z_free(ret_var);
21048         return ret_arr;
21049 }
21050
21051 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21052         LDKu8slice ser_ref;
21053         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21054         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21055         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
21056         *ret_conv = ReplyShortChannelIdsEnd_read(ser_ref);
21057         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21058         return (uint64_t)ret_conv;
21059 }
21060
21061 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1write(JNIEnv *env, jclass clz, int64_t obj) {
21062         LDKReplyShortChannelIdsEnd obj_conv;
21063         obj_conv.inner = (void*)(obj & (~1));
21064         obj_conv.is_owned = false;
21065         LDKCVec_u8Z ret_var = ReplyShortChannelIdsEnd_write(&obj_conv);
21066         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21067         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21068         CVec_u8Z_free(ret_var);
21069         return ret_arr;
21070 }
21071
21072 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1end_1blocknum(JNIEnv *env, jclass clz, int64_t this_arg) {
21073         LDKQueryChannelRange this_arg_conv;
21074         this_arg_conv.inner = (void*)(this_arg & (~1));
21075         this_arg_conv.is_owned = false;
21076         int32_t ret_val = QueryChannelRange_end_blocknum(&this_arg_conv);
21077         return ret_val;
21078 }
21079
21080 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21081         LDKu8slice ser_ref;
21082         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21083         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21084         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
21085         *ret_conv = QueryChannelRange_read(ser_ref);
21086         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21087         return (uint64_t)ret_conv;
21088 }
21089
21090 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
21091         LDKQueryChannelRange obj_conv;
21092         obj_conv.inner = (void*)(obj & (~1));
21093         obj_conv.is_owned = false;
21094         LDKCVec_u8Z ret_var = QueryChannelRange_write(&obj_conv);
21095         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21096         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21097         CVec_u8Z_free(ret_var);
21098         return ret_arr;
21099 }
21100
21101 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21102         LDKu8slice ser_ref;
21103         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21104         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21105         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
21106         *ret_conv = ReplyChannelRange_read(ser_ref);
21107         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21108         return (uint64_t)ret_conv;
21109 }
21110
21111 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
21112         LDKReplyChannelRange obj_conv;
21113         obj_conv.inner = (void*)(obj & (~1));
21114         obj_conv.is_owned = false;
21115         LDKCVec_u8Z ret_var = ReplyChannelRange_write(&obj_conv);
21116         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21117         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21118         CVec_u8Z_free(ret_var);
21119         return ret_arr;
21120 }
21121
21122 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21123         LDKu8slice ser_ref;
21124         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21125         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21126         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
21127         *ret_conv = GossipTimestampFilter_read(ser_ref);
21128         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21129         return (uint64_t)ret_conv;
21130 }
21131
21132 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1write(JNIEnv *env, jclass clz, int64_t obj) {
21133         LDKGossipTimestampFilter obj_conv;
21134         obj_conv.inner = (void*)(obj & (~1));
21135         obj_conv.is_owned = false;
21136         LDKCVec_u8Z ret_var = GossipTimestampFilter_write(&obj_conv);
21137         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21138         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21139         CVec_u8Z_free(ret_var);
21140         return ret_arr;
21141 }
21142
21143 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
21144         LDKIgnoringMessageHandler this_obj_conv;
21145         this_obj_conv.inner = (void*)(this_obj & (~1));
21146         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21147         IgnoringMessageHandler_free(this_obj_conv);
21148 }
21149
21150 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1new(JNIEnv *env, jclass clz) {
21151         LDKIgnoringMessageHandler ret_var = IgnoringMessageHandler_new();
21152         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21153         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21154         uint64_t ret_ref = (uint64_t)ret_var.inner;
21155         if (ret_var.is_owned) {
21156                 ret_ref |= 1;
21157         }
21158         return ret_ref;
21159 }
21160
21161 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
21162         LDKIgnoringMessageHandler this_arg_conv;
21163         this_arg_conv.inner = (void*)(this_arg & (~1));
21164         this_arg_conv.is_owned = false;
21165         LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
21166         *ret = IgnoringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
21167         return (uint64_t)ret;
21168 }
21169
21170 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1RoutingMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
21171         LDKIgnoringMessageHandler this_arg_conv;
21172         this_arg_conv.inner = (void*)(this_arg & (~1));
21173         this_arg_conv.is_owned = false;
21174         LDKRoutingMessageHandler* ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
21175         *ret = IgnoringMessageHandler_as_RoutingMessageHandler(&this_arg_conv);
21176         return (uint64_t)ret;
21177 }
21178
21179 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
21180         LDKErroringMessageHandler this_obj_conv;
21181         this_obj_conv.inner = (void*)(this_obj & (~1));
21182         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21183         ErroringMessageHandler_free(this_obj_conv);
21184 }
21185
21186 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1new(JNIEnv *env, jclass clz) {
21187         LDKErroringMessageHandler ret_var = ErroringMessageHandler_new();
21188         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21189         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21190         uint64_t ret_ref = (uint64_t)ret_var.inner;
21191         if (ret_var.is_owned) {
21192                 ret_ref |= 1;
21193         }
21194         return ret_ref;
21195 }
21196
21197 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
21198         LDKErroringMessageHandler this_arg_conv;
21199         this_arg_conv.inner = (void*)(this_arg & (~1));
21200         this_arg_conv.is_owned = false;
21201         LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
21202         *ret = ErroringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
21203         return (uint64_t)ret;
21204 }
21205
21206 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1as_1ChannelMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
21207         LDKErroringMessageHandler this_arg_conv;
21208         this_arg_conv.inner = (void*)(this_arg & (~1));
21209         this_arg_conv.is_owned = false;
21210         LDKChannelMessageHandler* ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
21211         *ret = ErroringMessageHandler_as_ChannelMessageHandler(&this_arg_conv);
21212         return (uint64_t)ret;
21213 }
21214
21215 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
21216         LDKMessageHandler this_obj_conv;
21217         this_obj_conv.inner = (void*)(this_obj & (~1));
21218         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21219         MessageHandler_free(this_obj_conv);
21220 }
21221
21222 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1chan_1handler(JNIEnv *env, jclass clz, int64_t this_ptr) {
21223         LDKMessageHandler this_ptr_conv;
21224         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21225         this_ptr_conv.is_owned = false;
21226         uint64_t ret_ret = (uint64_t)MessageHandler_get_chan_handler(&this_ptr_conv);
21227         return ret_ret;
21228 }
21229
21230 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1chan_1handler(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
21231         LDKMessageHandler this_ptr_conv;
21232         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21233         this_ptr_conv.is_owned = false;
21234         LDKChannelMessageHandler val_conv = *(LDKChannelMessageHandler*)(((uint64_t)val) & ~1);
21235         if (val_conv.free == LDKChannelMessageHandler_JCalls_free) {
21236                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
21237                 LDKChannelMessageHandler_JCalls_clone(val_conv.this_arg);
21238         }
21239         MessageHandler_set_chan_handler(&this_ptr_conv, val_conv);
21240 }
21241
21242 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1route_1handler(JNIEnv *env, jclass clz, int64_t this_ptr) {
21243         LDKMessageHandler this_ptr_conv;
21244         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21245         this_ptr_conv.is_owned = false;
21246         uint64_t ret_ret = (uint64_t)MessageHandler_get_route_handler(&this_ptr_conv);
21247         return ret_ret;
21248 }
21249
21250 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1route_1handler(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
21251         LDKMessageHandler this_ptr_conv;
21252         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21253         this_ptr_conv.is_owned = false;
21254         LDKRoutingMessageHandler val_conv = *(LDKRoutingMessageHandler*)(((uint64_t)val) & ~1);
21255         if (val_conv.free == LDKRoutingMessageHandler_JCalls_free) {
21256                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
21257                 LDKRoutingMessageHandler_JCalls_clone(val_conv.this_arg);
21258         }
21259         MessageHandler_set_route_handler(&this_ptr_conv, val_conv);
21260 }
21261
21262 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) {
21263         LDKChannelMessageHandler chan_handler_arg_conv = *(LDKChannelMessageHandler*)(((uint64_t)chan_handler_arg) & ~1);
21264         if (chan_handler_arg_conv.free == LDKChannelMessageHandler_JCalls_free) {
21265                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
21266                 LDKChannelMessageHandler_JCalls_clone(chan_handler_arg_conv.this_arg);
21267         }
21268         LDKRoutingMessageHandler route_handler_arg_conv = *(LDKRoutingMessageHandler*)(((uint64_t)route_handler_arg) & ~1);
21269         if (route_handler_arg_conv.free == LDKRoutingMessageHandler_JCalls_free) {
21270                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
21271                 LDKRoutingMessageHandler_JCalls_clone(route_handler_arg_conv.this_arg);
21272         }
21273         LDKMessageHandler ret_var = MessageHandler_new(chan_handler_arg_conv, route_handler_arg_conv);
21274         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21275         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21276         uint64_t ret_ref = (uint64_t)ret_var.inner;
21277         if (ret_var.is_owned) {
21278                 ret_ref |= 1;
21279         }
21280         return ret_ref;
21281 }
21282
21283 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21284         LDKSocketDescriptor* orig_conv = (LDKSocketDescriptor*)(((uint64_t)orig) & ~1);
21285         LDKSocketDescriptor* ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
21286         *ret = SocketDescriptor_clone(orig_conv);
21287         return (uint64_t)ret;
21288 }
21289
21290 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
21291         if ((this_ptr & 1) != 0) return;
21292         LDKSocketDescriptor this_ptr_conv = *(LDKSocketDescriptor*)(((uint64_t)this_ptr) & ~1);
21293         FREE((void*)this_ptr);
21294         SocketDescriptor_free(this_ptr_conv);
21295 }
21296
21297 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
21298         LDKPeerHandleError this_obj_conv;
21299         this_obj_conv.inner = (void*)(this_obj & (~1));
21300         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21301         PeerHandleError_free(this_obj_conv);
21302 }
21303
21304 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1get_1no_1connection_1possible(JNIEnv *env, jclass clz, int64_t this_ptr) {
21305         LDKPeerHandleError this_ptr_conv;
21306         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21307         this_ptr_conv.is_owned = false;
21308         jboolean ret_val = PeerHandleError_get_no_connection_possible(&this_ptr_conv);
21309         return ret_val;
21310 }
21311
21312 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1set_1no_1connection_1possible(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
21313         LDKPeerHandleError this_ptr_conv;
21314         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21315         this_ptr_conv.is_owned = false;
21316         PeerHandleError_set_no_connection_possible(&this_ptr_conv, val);
21317 }
21318
21319 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1new(JNIEnv *env, jclass clz, jboolean no_connection_possible_arg) {
21320         LDKPeerHandleError ret_var = PeerHandleError_new(no_connection_possible_arg);
21321         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21322         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21323         uint64_t ret_ref = (uint64_t)ret_var.inner;
21324         if (ret_var.is_owned) {
21325                 ret_ref |= 1;
21326         }
21327         return ret_ref;
21328 }
21329
21330 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21331         LDKPeerHandleError orig_conv;
21332         orig_conv.inner = (void*)(orig & (~1));
21333         orig_conv.is_owned = false;
21334         LDKPeerHandleError ret_var = PeerHandleError_clone(&orig_conv);
21335         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21336         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21337         uint64_t ret_ref = (uint64_t)ret_var.inner;
21338         if (ret_var.is_owned) {
21339                 ret_ref |= 1;
21340         }
21341         return ret_ref;
21342 }
21343
21344 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
21345         LDKPeerManager this_obj_conv;
21346         this_obj_conv.inner = (void*)(this_obj & (~1));
21347         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21348         PeerManager_free(this_obj_conv);
21349 }
21350
21351 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) {
21352         LDKMessageHandler message_handler_conv;
21353         message_handler_conv.inner = (void*)(message_handler & (~1));
21354         message_handler_conv.is_owned = (message_handler & 1) || (message_handler == 0);
21355         // Warning: we need a move here but no clone is available for LDKMessageHandler
21356         LDKSecretKey our_node_secret_ref;
21357         CHECK((*env)->GetArrayLength(env, our_node_secret) == 32);
21358         (*env)->GetByteArrayRegion(env, our_node_secret, 0, 32, our_node_secret_ref.bytes);
21359         unsigned char ephemeral_random_data_arr[32];
21360         CHECK((*env)->GetArrayLength(env, ephemeral_random_data) == 32);
21361         (*env)->GetByteArrayRegion(env, ephemeral_random_data, 0, 32, ephemeral_random_data_arr);
21362         unsigned char (*ephemeral_random_data_ref)[32] = &ephemeral_random_data_arr;
21363         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
21364         if (logger_conv.free == LDKLogger_JCalls_free) {
21365                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
21366                 LDKLogger_JCalls_clone(logger_conv.this_arg);
21367         }
21368         LDKPeerManager ret_var = PeerManager_new(message_handler_conv, our_node_secret_ref, ephemeral_random_data_ref, logger_conv);
21369         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21370         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21371         uint64_t ret_ref = (uint64_t)ret_var.inner;
21372         if (ret_var.is_owned) {
21373                 ret_ref |= 1;
21374         }
21375         return ret_ref;
21376 }
21377
21378 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_PeerManager_1get_1peer_1node_1ids(JNIEnv *env, jclass clz, int64_t this_arg) {
21379         LDKPeerManager this_arg_conv;
21380         this_arg_conv.inner = (void*)(this_arg & (~1));
21381         this_arg_conv.is_owned = false;
21382         LDKCVec_PublicKeyZ ret_var = PeerManager_get_peer_node_ids(&this_arg_conv);
21383         jobjectArray ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
21384         ;
21385         for (size_t i = 0; i < ret_var.datalen; i++) {
21386                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 33);
21387                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 33, ret_var.data[i].compressed_form);
21388                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
21389         }
21390         FREE(ret_var.data);
21391         return ret_arr;
21392 }
21393
21394 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) {
21395         LDKPeerManager this_arg_conv;
21396         this_arg_conv.inner = (void*)(this_arg & (~1));
21397         this_arg_conv.is_owned = false;
21398         LDKPublicKey their_node_id_ref;
21399         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
21400         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
21401         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
21402         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
21403                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
21404                 LDKSocketDescriptor_JCalls_clone(descriptor_conv.this_arg);
21405         }
21406         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
21407         *ret_conv = PeerManager_new_outbound_connection(&this_arg_conv, their_node_id_ref, descriptor_conv);
21408         return (uint64_t)ret_conv;
21409 }
21410
21411 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerManager_1new_1inbound_1connection(JNIEnv *env, jclass clz, int64_t this_arg, int64_t descriptor) {
21412         LDKPeerManager this_arg_conv;
21413         this_arg_conv.inner = (void*)(this_arg & (~1));
21414         this_arg_conv.is_owned = false;
21415         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
21416         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
21417                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
21418                 LDKSocketDescriptor_JCalls_clone(descriptor_conv.this_arg);
21419         }
21420         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
21421         *ret_conv = PeerManager_new_inbound_connection(&this_arg_conv, descriptor_conv);
21422         return (uint64_t)ret_conv;
21423 }
21424
21425 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) {
21426         LDKPeerManager this_arg_conv;
21427         this_arg_conv.inner = (void*)(this_arg & (~1));
21428         this_arg_conv.is_owned = false;
21429         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
21430         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
21431         *ret_conv = PeerManager_write_buffer_space_avail(&this_arg_conv, descriptor_conv);
21432         return (uint64_t)ret_conv;
21433 }
21434
21435 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) {
21436         LDKPeerManager this_arg_conv;
21437         this_arg_conv.inner = (void*)(this_arg & (~1));
21438         this_arg_conv.is_owned = false;
21439         LDKSocketDescriptor* peer_descriptor_conv = (LDKSocketDescriptor*)(((uint64_t)peer_descriptor) & ~1);
21440         LDKu8slice data_ref;
21441         data_ref.datalen = (*env)->GetArrayLength(env, data);
21442         data_ref.data = (*env)->GetByteArrayElements (env, data, NULL);
21443         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
21444         *ret_conv = PeerManager_read_event(&this_arg_conv, peer_descriptor_conv, data_ref);
21445         (*env)->ReleaseByteArrayElements(env, data, (int8_t*)data_ref.data, 0);
21446         return (uint64_t)ret_conv;
21447 }
21448
21449 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1process_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
21450         LDKPeerManager this_arg_conv;
21451         this_arg_conv.inner = (void*)(this_arg & (~1));
21452         this_arg_conv.is_owned = false;
21453         PeerManager_process_events(&this_arg_conv);
21454 }
21455
21456 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1socket_1disconnected(JNIEnv *env, jclass clz, int64_t this_arg, int64_t descriptor) {
21457         LDKPeerManager this_arg_conv;
21458         this_arg_conv.inner = (void*)(this_arg & (~1));
21459         this_arg_conv.is_owned = false;
21460         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
21461         PeerManager_socket_disconnected(&this_arg_conv, descriptor_conv);
21462 }
21463
21464 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) {
21465         LDKPeerManager this_arg_conv;
21466         this_arg_conv.inner = (void*)(this_arg & (~1));
21467         this_arg_conv.is_owned = false;
21468         LDKPublicKey node_id_ref;
21469         CHECK((*env)->GetArrayLength(env, node_id) == 33);
21470         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
21471         PeerManager_disconnect_by_node_id(&this_arg_conv, node_id_ref, no_connection_possible);
21472 }
21473
21474 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1timer_1tick_1occurred(JNIEnv *env, jclass clz, int64_t this_arg) {
21475         LDKPeerManager this_arg_conv;
21476         this_arg_conv.inner = (void*)(this_arg & (~1));
21477         this_arg_conv.is_owned = false;
21478         PeerManager_timer_tick_occurred(&this_arg_conv);
21479 }
21480
21481 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_build_1commitment_1secret(JNIEnv *env, jclass clz, int8_tArray commitment_seed, int64_t idx) {
21482         unsigned char commitment_seed_arr[32];
21483         CHECK((*env)->GetArrayLength(env, commitment_seed) == 32);
21484         (*env)->GetByteArrayRegion(env, commitment_seed, 0, 32, commitment_seed_arr);
21485         unsigned char (*commitment_seed_ref)[32] = &commitment_seed_arr;
21486         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
21487         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, build_commitment_secret(commitment_seed_ref, idx).data);
21488         return ret_arr;
21489 }
21490
21491 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) {
21492         LDKPublicKey per_commitment_point_ref;
21493         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
21494         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
21495         unsigned char base_secret_arr[32];
21496         CHECK((*env)->GetArrayLength(env, base_secret) == 32);
21497         (*env)->GetByteArrayRegion(env, base_secret, 0, 32, base_secret_arr);
21498         unsigned char (*base_secret_ref)[32] = &base_secret_arr;
21499         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
21500         *ret_conv = derive_private_key(per_commitment_point_ref, base_secret_ref);
21501         return (uint64_t)ret_conv;
21502 }
21503
21504 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) {
21505         LDKPublicKey per_commitment_point_ref;
21506         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
21507         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
21508         LDKPublicKey base_point_ref;
21509         CHECK((*env)->GetArrayLength(env, base_point) == 33);
21510         (*env)->GetByteArrayRegion(env, base_point, 0, 33, base_point_ref.compressed_form);
21511         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
21512         *ret_conv = derive_public_key(per_commitment_point_ref, base_point_ref);
21513         return (uint64_t)ret_conv;
21514 }
21515
21516 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) {
21517         unsigned char per_commitment_secret_arr[32];
21518         CHECK((*env)->GetArrayLength(env, per_commitment_secret) == 32);
21519         (*env)->GetByteArrayRegion(env, per_commitment_secret, 0, 32, per_commitment_secret_arr);
21520         unsigned char (*per_commitment_secret_ref)[32] = &per_commitment_secret_arr;
21521         unsigned char countersignatory_revocation_base_secret_arr[32];
21522         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base_secret) == 32);
21523         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base_secret, 0, 32, countersignatory_revocation_base_secret_arr);
21524         unsigned char (*countersignatory_revocation_base_secret_ref)[32] = &countersignatory_revocation_base_secret_arr;
21525         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
21526         *ret_conv = derive_private_revocation_key(per_commitment_secret_ref, countersignatory_revocation_base_secret_ref);
21527         return (uint64_t)ret_conv;
21528 }
21529
21530 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) {
21531         LDKPublicKey per_commitment_point_ref;
21532         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
21533         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
21534         LDKPublicKey countersignatory_revocation_base_point_ref;
21535         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base_point) == 33);
21536         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base_point, 0, 33, countersignatory_revocation_base_point_ref.compressed_form);
21537         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
21538         *ret_conv = derive_public_revocation_key(per_commitment_point_ref, countersignatory_revocation_base_point_ref);
21539         return (uint64_t)ret_conv;
21540 }
21541
21542 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
21543         LDKTxCreationKeys this_obj_conv;
21544         this_obj_conv.inner = (void*)(this_obj & (~1));
21545         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21546         TxCreationKeys_free(this_obj_conv);
21547 }
21548
21549 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
21550         LDKTxCreationKeys this_ptr_conv;
21551         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21552         this_ptr_conv.is_owned = false;
21553         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
21554         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_per_commitment_point(&this_ptr_conv).compressed_form);
21555         return ret_arr;
21556 }
21557
21558 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21559         LDKTxCreationKeys this_ptr_conv;
21560         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21561         this_ptr_conv.is_owned = false;
21562         LDKPublicKey val_ref;
21563         CHECK((*env)->GetArrayLength(env, val) == 33);
21564         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
21565         TxCreationKeys_set_per_commitment_point(&this_ptr_conv, val_ref);
21566 }
21567
21568 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1revocation_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
21569         LDKTxCreationKeys this_ptr_conv;
21570         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21571         this_ptr_conv.is_owned = false;
21572         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
21573         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_revocation_key(&this_ptr_conv).compressed_form);
21574         return ret_arr;
21575 }
21576
21577 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1revocation_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21578         LDKTxCreationKeys this_ptr_conv;
21579         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21580         this_ptr_conv.is_owned = false;
21581         LDKPublicKey val_ref;
21582         CHECK((*env)->GetArrayLength(env, val) == 33);
21583         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
21584         TxCreationKeys_set_revocation_key(&this_ptr_conv, val_ref);
21585 }
21586
21587 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1broadcaster_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
21588         LDKTxCreationKeys this_ptr_conv;
21589         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21590         this_ptr_conv.is_owned = false;
21591         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
21592         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_broadcaster_htlc_key(&this_ptr_conv).compressed_form);
21593         return ret_arr;
21594 }
21595
21596 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1broadcaster_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21597         LDKTxCreationKeys this_ptr_conv;
21598         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21599         this_ptr_conv.is_owned = false;
21600         LDKPublicKey val_ref;
21601         CHECK((*env)->GetArrayLength(env, val) == 33);
21602         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
21603         TxCreationKeys_set_broadcaster_htlc_key(&this_ptr_conv, val_ref);
21604 }
21605
21606 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1countersignatory_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
21607         LDKTxCreationKeys this_ptr_conv;
21608         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21609         this_ptr_conv.is_owned = false;
21610         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
21611         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_countersignatory_htlc_key(&this_ptr_conv).compressed_form);
21612         return ret_arr;
21613 }
21614
21615 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1countersignatory_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21616         LDKTxCreationKeys this_ptr_conv;
21617         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21618         this_ptr_conv.is_owned = false;
21619         LDKPublicKey val_ref;
21620         CHECK((*env)->GetArrayLength(env, val) == 33);
21621         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
21622         TxCreationKeys_set_countersignatory_htlc_key(&this_ptr_conv, val_ref);
21623 }
21624
21625 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1broadcaster_1delayed_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
21626         LDKTxCreationKeys this_ptr_conv;
21627         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21628         this_ptr_conv.is_owned = false;
21629         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
21630         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_broadcaster_delayed_payment_key(&this_ptr_conv).compressed_form);
21631         return ret_arr;
21632 }
21633
21634 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) {
21635         LDKTxCreationKeys this_ptr_conv;
21636         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21637         this_ptr_conv.is_owned = false;
21638         LDKPublicKey val_ref;
21639         CHECK((*env)->GetArrayLength(env, val) == 33);
21640         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
21641         TxCreationKeys_set_broadcaster_delayed_payment_key(&this_ptr_conv, val_ref);
21642 }
21643
21644 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) {
21645         LDKPublicKey per_commitment_point_arg_ref;
21646         CHECK((*env)->GetArrayLength(env, per_commitment_point_arg) == 33);
21647         (*env)->GetByteArrayRegion(env, per_commitment_point_arg, 0, 33, per_commitment_point_arg_ref.compressed_form);
21648         LDKPublicKey revocation_key_arg_ref;
21649         CHECK((*env)->GetArrayLength(env, revocation_key_arg) == 33);
21650         (*env)->GetByteArrayRegion(env, revocation_key_arg, 0, 33, revocation_key_arg_ref.compressed_form);
21651         LDKPublicKey broadcaster_htlc_key_arg_ref;
21652         CHECK((*env)->GetArrayLength(env, broadcaster_htlc_key_arg) == 33);
21653         (*env)->GetByteArrayRegion(env, broadcaster_htlc_key_arg, 0, 33, broadcaster_htlc_key_arg_ref.compressed_form);
21654         LDKPublicKey countersignatory_htlc_key_arg_ref;
21655         CHECK((*env)->GetArrayLength(env, countersignatory_htlc_key_arg) == 33);
21656         (*env)->GetByteArrayRegion(env, countersignatory_htlc_key_arg, 0, 33, countersignatory_htlc_key_arg_ref.compressed_form);
21657         LDKPublicKey broadcaster_delayed_payment_key_arg_ref;
21658         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key_arg) == 33);
21659         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key_arg, 0, 33, broadcaster_delayed_payment_key_arg_ref.compressed_form);
21660         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);
21661         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21662         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21663         uint64_t ret_ref = (uint64_t)ret_var.inner;
21664         if (ret_var.is_owned) {
21665                 ret_ref |= 1;
21666         }
21667         return ret_ref;
21668 }
21669
21670 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21671         LDKTxCreationKeys orig_conv;
21672         orig_conv.inner = (void*)(orig & (~1));
21673         orig_conv.is_owned = false;
21674         LDKTxCreationKeys ret_var = TxCreationKeys_clone(&orig_conv);
21675         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21676         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21677         uint64_t ret_ref = (uint64_t)ret_var.inner;
21678         if (ret_var.is_owned) {
21679                 ret_ref |= 1;
21680         }
21681         return ret_ref;
21682 }
21683
21684 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1write(JNIEnv *env, jclass clz, int64_t obj) {
21685         LDKTxCreationKeys obj_conv;
21686         obj_conv.inner = (void*)(obj & (~1));
21687         obj_conv.is_owned = false;
21688         LDKCVec_u8Z ret_var = TxCreationKeys_write(&obj_conv);
21689         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21690         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21691         CVec_u8Z_free(ret_var);
21692         return ret_arr;
21693 }
21694
21695 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21696         LDKu8slice ser_ref;
21697         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21698         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21699         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
21700         *ret_conv = TxCreationKeys_read(ser_ref);
21701         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21702         return (uint64_t)ret_conv;
21703 }
21704
21705 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
21706         LDKChannelPublicKeys this_obj_conv;
21707         this_obj_conv.inner = (void*)(this_obj & (~1));
21708         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21709         ChannelPublicKeys_free(this_obj_conv);
21710 }
21711
21712 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
21713         LDKChannelPublicKeys this_ptr_conv;
21714         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21715         this_ptr_conv.is_owned = false;
21716         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
21717         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_funding_pubkey(&this_ptr_conv).compressed_form);
21718         return ret_arr;
21719 }
21720
21721 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21722         LDKChannelPublicKeys this_ptr_conv;
21723         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21724         this_ptr_conv.is_owned = false;
21725         LDKPublicKey val_ref;
21726         CHECK((*env)->GetArrayLength(env, val) == 33);
21727         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
21728         ChannelPublicKeys_set_funding_pubkey(&this_ptr_conv, val_ref);
21729 }
21730
21731 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
21732         LDKChannelPublicKeys this_ptr_conv;
21733         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21734         this_ptr_conv.is_owned = false;
21735         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
21736         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_revocation_basepoint(&this_ptr_conv).compressed_form);
21737         return ret_arr;
21738 }
21739
21740 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21741         LDKChannelPublicKeys this_ptr_conv;
21742         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21743         this_ptr_conv.is_owned = false;
21744         LDKPublicKey val_ref;
21745         CHECK((*env)->GetArrayLength(env, val) == 33);
21746         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
21747         ChannelPublicKeys_set_revocation_basepoint(&this_ptr_conv, val_ref);
21748 }
21749
21750 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
21751         LDKChannelPublicKeys this_ptr_conv;
21752         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21753         this_ptr_conv.is_owned = false;
21754         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
21755         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_payment_point(&this_ptr_conv).compressed_form);
21756         return ret_arr;
21757 }
21758
21759 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21760         LDKChannelPublicKeys this_ptr_conv;
21761         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21762         this_ptr_conv.is_owned = false;
21763         LDKPublicKey val_ref;
21764         CHECK((*env)->GetArrayLength(env, val) == 33);
21765         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
21766         ChannelPublicKeys_set_payment_point(&this_ptr_conv, val_ref);
21767 }
21768
21769 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
21770         LDKChannelPublicKeys this_ptr_conv;
21771         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21772         this_ptr_conv.is_owned = false;
21773         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
21774         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
21775         return ret_arr;
21776 }
21777
21778 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21779         LDKChannelPublicKeys this_ptr_conv;
21780         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21781         this_ptr_conv.is_owned = false;
21782         LDKPublicKey val_ref;
21783         CHECK((*env)->GetArrayLength(env, val) == 33);
21784         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
21785         ChannelPublicKeys_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
21786 }
21787
21788 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
21789         LDKChannelPublicKeys this_ptr_conv;
21790         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21791         this_ptr_conv.is_owned = false;
21792         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
21793         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_htlc_basepoint(&this_ptr_conv).compressed_form);
21794         return ret_arr;
21795 }
21796
21797 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21798         LDKChannelPublicKeys this_ptr_conv;
21799         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21800         this_ptr_conv.is_owned = false;
21801         LDKPublicKey val_ref;
21802         CHECK((*env)->GetArrayLength(env, val) == 33);
21803         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
21804         ChannelPublicKeys_set_htlc_basepoint(&this_ptr_conv, val_ref);
21805 }
21806
21807 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) {
21808         LDKPublicKey funding_pubkey_arg_ref;
21809         CHECK((*env)->GetArrayLength(env, funding_pubkey_arg) == 33);
21810         (*env)->GetByteArrayRegion(env, funding_pubkey_arg, 0, 33, funding_pubkey_arg_ref.compressed_form);
21811         LDKPublicKey revocation_basepoint_arg_ref;
21812         CHECK((*env)->GetArrayLength(env, revocation_basepoint_arg) == 33);
21813         (*env)->GetByteArrayRegion(env, revocation_basepoint_arg, 0, 33, revocation_basepoint_arg_ref.compressed_form);
21814         LDKPublicKey payment_point_arg_ref;
21815         CHECK((*env)->GetArrayLength(env, payment_point_arg) == 33);
21816         (*env)->GetByteArrayRegion(env, payment_point_arg, 0, 33, payment_point_arg_ref.compressed_form);
21817         LDKPublicKey delayed_payment_basepoint_arg_ref;
21818         CHECK((*env)->GetArrayLength(env, delayed_payment_basepoint_arg) == 33);
21819         (*env)->GetByteArrayRegion(env, delayed_payment_basepoint_arg, 0, 33, delayed_payment_basepoint_arg_ref.compressed_form);
21820         LDKPublicKey htlc_basepoint_arg_ref;
21821         CHECK((*env)->GetArrayLength(env, htlc_basepoint_arg) == 33);
21822         (*env)->GetByteArrayRegion(env, htlc_basepoint_arg, 0, 33, htlc_basepoint_arg_ref.compressed_form);
21823         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);
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_ChannelPublicKeys_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21834         LDKChannelPublicKeys orig_conv;
21835         orig_conv.inner = (void*)(orig & (~1));
21836         orig_conv.is_owned = false;
21837         LDKChannelPublicKeys ret_var = ChannelPublicKeys_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 int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1write(JNIEnv *env, jclass clz, int64_t obj) {
21848         LDKChannelPublicKeys obj_conv;
21849         obj_conv.inner = (void*)(obj & (~1));
21850         obj_conv.is_owned = false;
21851         LDKCVec_u8Z ret_var = ChannelPublicKeys_write(&obj_conv);
21852         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21853         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21854         CVec_u8Z_free(ret_var);
21855         return ret_arr;
21856 }
21857
21858 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21859         LDKu8slice ser_ref;
21860         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21861         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21862         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
21863         *ret_conv = ChannelPublicKeys_read(ser_ref);
21864         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21865         return (uint64_t)ret_conv;
21866 }
21867
21868 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) {
21869         LDKPublicKey per_commitment_point_ref;
21870         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
21871         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
21872         LDKPublicKey broadcaster_delayed_payment_base_ref;
21873         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_base) == 33);
21874         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_base, 0, 33, broadcaster_delayed_payment_base_ref.compressed_form);
21875         LDKPublicKey broadcaster_htlc_base_ref;
21876         CHECK((*env)->GetArrayLength(env, broadcaster_htlc_base) == 33);
21877         (*env)->GetByteArrayRegion(env, broadcaster_htlc_base, 0, 33, broadcaster_htlc_base_ref.compressed_form);
21878         LDKPublicKey countersignatory_revocation_base_ref;
21879         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base) == 33);
21880         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base, 0, 33, countersignatory_revocation_base_ref.compressed_form);
21881         LDKPublicKey countersignatory_htlc_base_ref;
21882         CHECK((*env)->GetArrayLength(env, countersignatory_htlc_base) == 33);
21883         (*env)->GetByteArrayRegion(env, countersignatory_htlc_base, 0, 33, countersignatory_htlc_base_ref.compressed_form);
21884         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
21885         *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);
21886         return (uint64_t)ret_conv;
21887 }
21888
21889 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) {
21890         LDKPublicKey per_commitment_point_ref;
21891         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
21892         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
21893         LDKChannelPublicKeys broadcaster_keys_conv;
21894         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
21895         broadcaster_keys_conv.is_owned = false;
21896         LDKChannelPublicKeys countersignatory_keys_conv;
21897         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
21898         countersignatory_keys_conv.is_owned = false;
21899         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
21900         *ret_conv = TxCreationKeys_from_channel_static_keys(per_commitment_point_ref, &broadcaster_keys_conv, &countersignatory_keys_conv);
21901         return (uint64_t)ret_conv;
21902 }
21903
21904 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) {
21905         LDKPublicKey revocation_key_ref;
21906         CHECK((*env)->GetArrayLength(env, revocation_key) == 33);
21907         (*env)->GetByteArrayRegion(env, revocation_key, 0, 33, revocation_key_ref.compressed_form);
21908         LDKPublicKey broadcaster_delayed_payment_key_ref;
21909         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key) == 33);
21910         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key, 0, 33, broadcaster_delayed_payment_key_ref.compressed_form);
21911         LDKCVec_u8Z ret_var = get_revokeable_redeemscript(revocation_key_ref, contest_delay, broadcaster_delayed_payment_key_ref);
21912         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21913         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21914         CVec_u8Z_free(ret_var);
21915         return ret_arr;
21916 }
21917
21918 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
21919         LDKHTLCOutputInCommitment this_obj_conv;
21920         this_obj_conv.inner = (void*)(this_obj & (~1));
21921         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21922         HTLCOutputInCommitment_free(this_obj_conv);
21923 }
21924
21925 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1offered(JNIEnv *env, jclass clz, int64_t this_ptr) {
21926         LDKHTLCOutputInCommitment this_ptr_conv;
21927         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21928         this_ptr_conv.is_owned = false;
21929         jboolean ret_val = HTLCOutputInCommitment_get_offered(&this_ptr_conv);
21930         return ret_val;
21931 }
21932
21933 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1offered(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
21934         LDKHTLCOutputInCommitment this_ptr_conv;
21935         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21936         this_ptr_conv.is_owned = false;
21937         HTLCOutputInCommitment_set_offered(&this_ptr_conv, val);
21938 }
21939
21940 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
21941         LDKHTLCOutputInCommitment this_ptr_conv;
21942         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21943         this_ptr_conv.is_owned = false;
21944         int64_t ret_val = HTLCOutputInCommitment_get_amount_msat(&this_ptr_conv);
21945         return ret_val;
21946 }
21947
21948 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
21949         LDKHTLCOutputInCommitment this_ptr_conv;
21950         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21951         this_ptr_conv.is_owned = false;
21952         HTLCOutputInCommitment_set_amount_msat(&this_ptr_conv, val);
21953 }
21954
21955 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr) {
21956         LDKHTLCOutputInCommitment this_ptr_conv;
21957         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21958         this_ptr_conv.is_owned = false;
21959         int32_t ret_val = HTLCOutputInCommitment_get_cltv_expiry(&this_ptr_conv);
21960         return ret_val;
21961 }
21962
21963 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
21964         LDKHTLCOutputInCommitment this_ptr_conv;
21965         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21966         this_ptr_conv.is_owned = false;
21967         HTLCOutputInCommitment_set_cltv_expiry(&this_ptr_conv, val);
21968 }
21969
21970 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
21971         LDKHTLCOutputInCommitment this_ptr_conv;
21972         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21973         this_ptr_conv.is_owned = false;
21974         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
21975         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *HTLCOutputInCommitment_get_payment_hash(&this_ptr_conv));
21976         return ret_arr;
21977 }
21978
21979 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21980         LDKHTLCOutputInCommitment this_ptr_conv;
21981         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21982         this_ptr_conv.is_owned = false;
21983         LDKThirtyTwoBytes val_ref;
21984         CHECK((*env)->GetArrayLength(env, val) == 32);
21985         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
21986         HTLCOutputInCommitment_set_payment_hash(&this_ptr_conv, val_ref);
21987 }
21988
21989 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1transaction_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
21990         LDKHTLCOutputInCommitment this_ptr_conv;
21991         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21992         this_ptr_conv.is_owned = false;
21993         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
21994         *ret_copy = HTLCOutputInCommitment_get_transaction_output_index(&this_ptr_conv);
21995         uint64_t ret_ref = (uint64_t)ret_copy;
21996         return ret_ref;
21997 }
21998
21999 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1transaction_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
22000         LDKHTLCOutputInCommitment this_ptr_conv;
22001         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22002         this_ptr_conv.is_owned = false;
22003         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(((uint64_t)val) & ~1);
22004         HTLCOutputInCommitment_set_transaction_output_index(&this_ptr_conv, val_conv);
22005 }
22006
22007 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) {
22008         LDKThirtyTwoBytes payment_hash_arg_ref;
22009         CHECK((*env)->GetArrayLength(env, payment_hash_arg) == 32);
22010         (*env)->GetByteArrayRegion(env, payment_hash_arg, 0, 32, payment_hash_arg_ref.data);
22011         LDKCOption_u32Z transaction_output_index_arg_conv = *(LDKCOption_u32Z*)(((uint64_t)transaction_output_index_arg) & ~1);
22012         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_new(offered_arg, amount_msat_arg, cltv_expiry_arg, payment_hash_arg_ref, transaction_output_index_arg_conv);
22013         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22014         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22015         uint64_t ret_ref = (uint64_t)ret_var.inner;
22016         if (ret_var.is_owned) {
22017                 ret_ref |= 1;
22018         }
22019         return ret_ref;
22020 }
22021
22022 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22023         LDKHTLCOutputInCommitment orig_conv;
22024         orig_conv.inner = (void*)(orig & (~1));
22025         orig_conv.is_owned = false;
22026         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(&orig_conv);
22027         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22028         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22029         uint64_t ret_ref = (uint64_t)ret_var.inner;
22030         if (ret_var.is_owned) {
22031                 ret_ref |= 1;
22032         }
22033         return ret_ref;
22034 }
22035
22036 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1write(JNIEnv *env, jclass clz, int64_t obj) {
22037         LDKHTLCOutputInCommitment obj_conv;
22038         obj_conv.inner = (void*)(obj & (~1));
22039         obj_conv.is_owned = false;
22040         LDKCVec_u8Z ret_var = HTLCOutputInCommitment_write(&obj_conv);
22041         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22042         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22043         CVec_u8Z_free(ret_var);
22044         return ret_arr;
22045 }
22046
22047 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
22048         LDKu8slice ser_ref;
22049         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
22050         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
22051         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
22052         *ret_conv = HTLCOutputInCommitment_read(ser_ref);
22053         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
22054         return (uint64_t)ret_conv;
22055 }
22056
22057 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_get_1htlc_1redeemscript(JNIEnv *env, jclass clz, int64_t htlc, int64_t keys) {
22058         LDKHTLCOutputInCommitment htlc_conv;
22059         htlc_conv.inner = (void*)(htlc & (~1));
22060         htlc_conv.is_owned = false;
22061         LDKTxCreationKeys keys_conv;
22062         keys_conv.inner = (void*)(keys & (~1));
22063         keys_conv.is_owned = false;
22064         LDKCVec_u8Z ret_var = get_htlc_redeemscript(&htlc_conv, &keys_conv);
22065         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22066         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22067         CVec_u8Z_free(ret_var);
22068         return ret_arr;
22069 }
22070
22071 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_make_1funding_1redeemscript(JNIEnv *env, jclass clz, int8_tArray broadcaster, int8_tArray countersignatory) {
22072         LDKPublicKey broadcaster_ref;
22073         CHECK((*env)->GetArrayLength(env, broadcaster) == 33);
22074         (*env)->GetByteArrayRegion(env, broadcaster, 0, 33, broadcaster_ref.compressed_form);
22075         LDKPublicKey countersignatory_ref;
22076         CHECK((*env)->GetArrayLength(env, countersignatory) == 33);
22077         (*env)->GetByteArrayRegion(env, countersignatory, 0, 33, countersignatory_ref.compressed_form);
22078         LDKCVec_u8Z ret_var = make_funding_redeemscript(broadcaster_ref, countersignatory_ref);
22079         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22080         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22081         CVec_u8Z_free(ret_var);
22082         return ret_arr;
22083 }
22084
22085 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) {
22086         unsigned char commitment_txid_arr[32];
22087         CHECK((*env)->GetArrayLength(env, commitment_txid) == 32);
22088         (*env)->GetByteArrayRegion(env, commitment_txid, 0, 32, commitment_txid_arr);
22089         unsigned char (*commitment_txid_ref)[32] = &commitment_txid_arr;
22090         LDKHTLCOutputInCommitment htlc_conv;
22091         htlc_conv.inner = (void*)(htlc & (~1));
22092         htlc_conv.is_owned = false;
22093         LDKPublicKey broadcaster_delayed_payment_key_ref;
22094         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key) == 33);
22095         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key, 0, 33, broadcaster_delayed_payment_key_ref.compressed_form);
22096         LDKPublicKey revocation_key_ref;
22097         CHECK((*env)->GetArrayLength(env, revocation_key) == 33);
22098         (*env)->GetByteArrayRegion(env, revocation_key, 0, 33, revocation_key_ref.compressed_form);
22099         LDKTransaction ret_var = build_htlc_transaction(commitment_txid_ref, feerate_per_kw, contest_delay, &htlc_conv, broadcaster_delayed_payment_key_ref, revocation_key_ref);
22100         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22101         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22102         Transaction_free(ret_var);
22103         return ret_arr;
22104 }
22105
22106 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22107         LDKChannelTransactionParameters this_obj_conv;
22108         this_obj_conv.inner = (void*)(this_obj & (~1));
22109         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22110         ChannelTransactionParameters_free(this_obj_conv);
22111 }
22112
22113 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1holder_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr) {
22114         LDKChannelTransactionParameters this_ptr_conv;
22115         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22116         this_ptr_conv.is_owned = false;
22117         LDKChannelPublicKeys ret_var = ChannelTransactionParameters_get_holder_pubkeys(&this_ptr_conv);
22118         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22119         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22120         uint64_t ret_ref = (uint64_t)ret_var.inner;
22121         if (ret_var.is_owned) {
22122                 ret_ref |= 1;
22123         }
22124         return ret_ref;
22125 }
22126
22127 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1holder_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
22128         LDKChannelTransactionParameters this_ptr_conv;
22129         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22130         this_ptr_conv.is_owned = false;
22131         LDKChannelPublicKeys val_conv;
22132         val_conv.inner = (void*)(val & (~1));
22133         val_conv.is_owned = (val & 1) || (val == 0);
22134         val_conv = ChannelPublicKeys_clone(&val_conv);
22135         ChannelTransactionParameters_set_holder_pubkeys(&this_ptr_conv, val_conv);
22136 }
22137
22138 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1holder_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
22139         LDKChannelTransactionParameters this_ptr_conv;
22140         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22141         this_ptr_conv.is_owned = false;
22142         int16_t ret_val = ChannelTransactionParameters_get_holder_selected_contest_delay(&this_ptr_conv);
22143         return ret_val;
22144 }
22145
22146 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) {
22147         LDKChannelTransactionParameters this_ptr_conv;
22148         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22149         this_ptr_conv.is_owned = false;
22150         ChannelTransactionParameters_set_holder_selected_contest_delay(&this_ptr_conv, val);
22151 }
22152
22153 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1is_1outbound_1from_1holder(JNIEnv *env, jclass clz, int64_t this_ptr) {
22154         LDKChannelTransactionParameters this_ptr_conv;
22155         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22156         this_ptr_conv.is_owned = false;
22157         jboolean ret_val = ChannelTransactionParameters_get_is_outbound_from_holder(&this_ptr_conv);
22158         return ret_val;
22159 }
22160
22161 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1is_1outbound_1from_1holder(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
22162         LDKChannelTransactionParameters this_ptr_conv;
22163         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22164         this_ptr_conv.is_owned = false;
22165         ChannelTransactionParameters_set_is_outbound_from_holder(&this_ptr_conv, val);
22166 }
22167
22168 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1counterparty_1parameters(JNIEnv *env, jclass clz, int64_t this_ptr) {
22169         LDKChannelTransactionParameters this_ptr_conv;
22170         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22171         this_ptr_conv.is_owned = false;
22172         LDKCounterpartyChannelTransactionParameters ret_var = ChannelTransactionParameters_get_counterparty_parameters(&this_ptr_conv);
22173         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22174         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22175         uint64_t ret_ref = (uint64_t)ret_var.inner;
22176         if (ret_var.is_owned) {
22177                 ret_ref |= 1;
22178         }
22179         return ret_ref;
22180 }
22181
22182 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1counterparty_1parameters(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
22183         LDKChannelTransactionParameters this_ptr_conv;
22184         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22185         this_ptr_conv.is_owned = false;
22186         LDKCounterpartyChannelTransactionParameters val_conv;
22187         val_conv.inner = (void*)(val & (~1));
22188         val_conv.is_owned = (val & 1) || (val == 0);
22189         val_conv = CounterpartyChannelTransactionParameters_clone(&val_conv);
22190         ChannelTransactionParameters_set_counterparty_parameters(&this_ptr_conv, val_conv);
22191 }
22192
22193 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
22194         LDKChannelTransactionParameters this_ptr_conv;
22195         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22196         this_ptr_conv.is_owned = false;
22197         LDKOutPoint ret_var = ChannelTransactionParameters_get_funding_outpoint(&this_ptr_conv);
22198         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22199         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22200         uint64_t ret_ref = (uint64_t)ret_var.inner;
22201         if (ret_var.is_owned) {
22202                 ret_ref |= 1;
22203         }
22204         return ret_ref;
22205 }
22206
22207 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
22208         LDKChannelTransactionParameters this_ptr_conv;
22209         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22210         this_ptr_conv.is_owned = false;
22211         LDKOutPoint val_conv;
22212         val_conv.inner = (void*)(val & (~1));
22213         val_conv.is_owned = (val & 1) || (val == 0);
22214         val_conv = OutPoint_clone(&val_conv);
22215         ChannelTransactionParameters_set_funding_outpoint(&this_ptr_conv, val_conv);
22216 }
22217
22218 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) {
22219         LDKChannelPublicKeys holder_pubkeys_arg_conv;
22220         holder_pubkeys_arg_conv.inner = (void*)(holder_pubkeys_arg & (~1));
22221         holder_pubkeys_arg_conv.is_owned = (holder_pubkeys_arg & 1) || (holder_pubkeys_arg == 0);
22222         holder_pubkeys_arg_conv = ChannelPublicKeys_clone(&holder_pubkeys_arg_conv);
22223         LDKCounterpartyChannelTransactionParameters counterparty_parameters_arg_conv;
22224         counterparty_parameters_arg_conv.inner = (void*)(counterparty_parameters_arg & (~1));
22225         counterparty_parameters_arg_conv.is_owned = (counterparty_parameters_arg & 1) || (counterparty_parameters_arg == 0);
22226         counterparty_parameters_arg_conv = CounterpartyChannelTransactionParameters_clone(&counterparty_parameters_arg_conv);
22227         LDKOutPoint funding_outpoint_arg_conv;
22228         funding_outpoint_arg_conv.inner = (void*)(funding_outpoint_arg & (~1));
22229         funding_outpoint_arg_conv.is_owned = (funding_outpoint_arg & 1) || (funding_outpoint_arg == 0);
22230         funding_outpoint_arg_conv = OutPoint_clone(&funding_outpoint_arg_conv);
22231         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);
22232         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22233         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22234         uint64_t ret_ref = (uint64_t)ret_var.inner;
22235         if (ret_var.is_owned) {
22236                 ret_ref |= 1;
22237         }
22238         return ret_ref;
22239 }
22240
22241 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22242         LDKChannelTransactionParameters orig_conv;
22243         orig_conv.inner = (void*)(orig & (~1));
22244         orig_conv.is_owned = false;
22245         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(&orig_conv);
22246         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22247         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22248         uint64_t ret_ref = (uint64_t)ret_var.inner;
22249         if (ret_var.is_owned) {
22250                 ret_ref |= 1;
22251         }
22252         return ret_ref;
22253 }
22254
22255 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22256         LDKCounterpartyChannelTransactionParameters this_obj_conv;
22257         this_obj_conv.inner = (void*)(this_obj & (~1));
22258         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22259         CounterpartyChannelTransactionParameters_free(this_obj_conv);
22260 }
22261
22262 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1get_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr) {
22263         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
22264         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22265         this_ptr_conv.is_owned = false;
22266         LDKChannelPublicKeys ret_var = CounterpartyChannelTransactionParameters_get_pubkeys(&this_ptr_conv);
22267         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22268         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22269         uint64_t ret_ref = (uint64_t)ret_var.inner;
22270         if (ret_var.is_owned) {
22271                 ret_ref |= 1;
22272         }
22273         return ret_ref;
22274 }
22275
22276 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1set_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
22277         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
22278         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22279         this_ptr_conv.is_owned = false;
22280         LDKChannelPublicKeys val_conv;
22281         val_conv.inner = (void*)(val & (~1));
22282         val_conv.is_owned = (val & 1) || (val == 0);
22283         val_conv = ChannelPublicKeys_clone(&val_conv);
22284         CounterpartyChannelTransactionParameters_set_pubkeys(&this_ptr_conv, val_conv);
22285 }
22286
22287 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1get_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
22288         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
22289         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22290         this_ptr_conv.is_owned = false;
22291         int16_t ret_val = CounterpartyChannelTransactionParameters_get_selected_contest_delay(&this_ptr_conv);
22292         return ret_val;
22293 }
22294
22295 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1set_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
22296         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
22297         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22298         this_ptr_conv.is_owned = false;
22299         CounterpartyChannelTransactionParameters_set_selected_contest_delay(&this_ptr_conv, val);
22300 }
22301
22302 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) {
22303         LDKChannelPublicKeys pubkeys_arg_conv;
22304         pubkeys_arg_conv.inner = (void*)(pubkeys_arg & (~1));
22305         pubkeys_arg_conv.is_owned = (pubkeys_arg & 1) || (pubkeys_arg == 0);
22306         pubkeys_arg_conv = ChannelPublicKeys_clone(&pubkeys_arg_conv);
22307         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_new(pubkeys_arg_conv, selected_contest_delay_arg);
22308         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22309         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22310         uint64_t ret_ref = (uint64_t)ret_var.inner;
22311         if (ret_var.is_owned) {
22312                 ret_ref |= 1;
22313         }
22314         return ret_ref;
22315 }
22316
22317 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22318         LDKCounterpartyChannelTransactionParameters orig_conv;
22319         orig_conv.inner = (void*)(orig & (~1));
22320         orig_conv.is_owned = false;
22321         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(&orig_conv);
22322         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22323         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22324         uint64_t ret_ref = (uint64_t)ret_var.inner;
22325         if (ret_var.is_owned) {
22326                 ret_ref |= 1;
22327         }
22328         return ret_ref;
22329 }
22330
22331 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1is_1populated(JNIEnv *env, jclass clz, int64_t this_arg) {
22332         LDKChannelTransactionParameters this_arg_conv;
22333         this_arg_conv.inner = (void*)(this_arg & (~1));
22334         this_arg_conv.is_owned = false;
22335         jboolean ret_val = ChannelTransactionParameters_is_populated(&this_arg_conv);
22336         return ret_val;
22337 }
22338
22339 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1as_1holder_1broadcastable(JNIEnv *env, jclass clz, int64_t this_arg) {
22340         LDKChannelTransactionParameters this_arg_conv;
22341         this_arg_conv.inner = (void*)(this_arg & (~1));
22342         this_arg_conv.is_owned = false;
22343         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_holder_broadcastable(&this_arg_conv);
22344         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22345         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22346         uint64_t ret_ref = (uint64_t)ret_var.inner;
22347         if (ret_var.is_owned) {
22348                 ret_ref |= 1;
22349         }
22350         return ret_ref;
22351 }
22352
22353 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1as_1counterparty_1broadcastable(JNIEnv *env, jclass clz, int64_t this_arg) {
22354         LDKChannelTransactionParameters this_arg_conv;
22355         this_arg_conv.inner = (void*)(this_arg & (~1));
22356         this_arg_conv.is_owned = false;
22357         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_counterparty_broadcastable(&this_arg_conv);
22358         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22359         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22360         uint64_t ret_ref = (uint64_t)ret_var.inner;
22361         if (ret_var.is_owned) {
22362                 ret_ref |= 1;
22363         }
22364         return ret_ref;
22365 }
22366
22367 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
22368         LDKCounterpartyChannelTransactionParameters obj_conv;
22369         obj_conv.inner = (void*)(obj & (~1));
22370         obj_conv.is_owned = false;
22371         LDKCVec_u8Z ret_var = CounterpartyChannelTransactionParameters_write(&obj_conv);
22372         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22373         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22374         CVec_u8Z_free(ret_var);
22375         return ret_arr;
22376 }
22377
22378 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
22379         LDKu8slice ser_ref;
22380         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
22381         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
22382         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
22383         *ret_conv = CounterpartyChannelTransactionParameters_read(ser_ref);
22384         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
22385         return (uint64_t)ret_conv;
22386 }
22387
22388 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
22389         LDKChannelTransactionParameters obj_conv;
22390         obj_conv.inner = (void*)(obj & (~1));
22391         obj_conv.is_owned = false;
22392         LDKCVec_u8Z ret_var = ChannelTransactionParameters_write(&obj_conv);
22393         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22394         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22395         CVec_u8Z_free(ret_var);
22396         return ret_arr;
22397 }
22398
22399 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
22400         LDKu8slice ser_ref;
22401         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
22402         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
22403         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
22404         *ret_conv = ChannelTransactionParameters_read(ser_ref);
22405         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
22406         return (uint64_t)ret_conv;
22407 }
22408
22409 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22410         LDKDirectedChannelTransactionParameters this_obj_conv;
22411         this_obj_conv.inner = (void*)(this_obj & (~1));
22412         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22413         DirectedChannelTransactionParameters_free(this_obj_conv);
22414 }
22415
22416 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1broadcaster_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
22417         LDKDirectedChannelTransactionParameters this_arg_conv;
22418         this_arg_conv.inner = (void*)(this_arg & (~1));
22419         this_arg_conv.is_owned = false;
22420         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_broadcaster_pubkeys(&this_arg_conv);
22421         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22422         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22423         uint64_t ret_ref = (uint64_t)ret_var.inner;
22424         if (ret_var.is_owned) {
22425                 ret_ref |= 1;
22426         }
22427         return ret_ref;
22428 }
22429
22430 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1countersignatory_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
22431         LDKDirectedChannelTransactionParameters this_arg_conv;
22432         this_arg_conv.inner = (void*)(this_arg & (~1));
22433         this_arg_conv.is_owned = false;
22434         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_countersignatory_pubkeys(&this_arg_conv);
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 int16_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
22445         LDKDirectedChannelTransactionParameters this_arg_conv;
22446         this_arg_conv.inner = (void*)(this_arg & (~1));
22447         this_arg_conv.is_owned = false;
22448         int16_t ret_val = DirectedChannelTransactionParameters_contest_delay(&this_arg_conv);
22449         return ret_val;
22450 }
22451
22452 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_arg) {
22453         LDKDirectedChannelTransactionParameters this_arg_conv;
22454         this_arg_conv.inner = (void*)(this_arg & (~1));
22455         this_arg_conv.is_owned = false;
22456         jboolean ret_val = DirectedChannelTransactionParameters_is_outbound(&this_arg_conv);
22457         return ret_val;
22458 }
22459
22460 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_arg) {
22461         LDKDirectedChannelTransactionParameters this_arg_conv;
22462         this_arg_conv.inner = (void*)(this_arg & (~1));
22463         this_arg_conv.is_owned = false;
22464         LDKOutPoint ret_var = DirectedChannelTransactionParameters_funding_outpoint(&this_arg_conv);
22465         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22466         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22467         uint64_t ret_ref = (uint64_t)ret_var.inner;
22468         if (ret_var.is_owned) {
22469                 ret_ref |= 1;
22470         }
22471         return ret_ref;
22472 }
22473
22474 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22475         LDKHolderCommitmentTransaction this_obj_conv;
22476         this_obj_conv.inner = (void*)(this_obj & (~1));
22477         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22478         HolderCommitmentTransaction_free(this_obj_conv);
22479 }
22480
22481 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1get_1counterparty_1sig(JNIEnv *env, jclass clz, int64_t this_ptr) {
22482         LDKHolderCommitmentTransaction this_ptr_conv;
22483         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22484         this_ptr_conv.is_owned = false;
22485         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
22486         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, HolderCommitmentTransaction_get_counterparty_sig(&this_ptr_conv).compact_form);
22487         return ret_arr;
22488 }
22489
22490 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1counterparty_1sig(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22491         LDKHolderCommitmentTransaction this_ptr_conv;
22492         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22493         this_ptr_conv.is_owned = false;
22494         LDKSignature val_ref;
22495         CHECK((*env)->GetArrayLength(env, val) == 64);
22496         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
22497         HolderCommitmentTransaction_set_counterparty_sig(&this_ptr_conv, val_ref);
22498 }
22499
22500 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1counterparty_1htlc_1sigs(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
22501         LDKHolderCommitmentTransaction this_ptr_conv;
22502         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22503         this_ptr_conv.is_owned = false;
22504         LDKCVec_SignatureZ val_constr;
22505         val_constr.datalen = (*env)->GetArrayLength(env, val);
22506         if (val_constr.datalen > 0)
22507                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
22508         else
22509                 val_constr.data = NULL;
22510         for (size_t i = 0; i < val_constr.datalen; i++) {
22511                 int8_tArray val_conv_8 = (*env)->GetObjectArrayElement(env, val, i);
22512                 LDKSignature val_conv_8_ref;
22513                 CHECK((*env)->GetArrayLength(env, val_conv_8) == 64);
22514                 (*env)->GetByteArrayRegion(env, val_conv_8, 0, 64, val_conv_8_ref.compact_form);
22515                 val_constr.data[i] = val_conv_8_ref;
22516         }
22517         HolderCommitmentTransaction_set_counterparty_htlc_sigs(&this_ptr_conv, val_constr);
22518 }
22519
22520 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22521         LDKHolderCommitmentTransaction orig_conv;
22522         orig_conv.inner = (void*)(orig & (~1));
22523         orig_conv.is_owned = false;
22524         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(&orig_conv);
22525         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22526         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22527         uint64_t ret_ref = (uint64_t)ret_var.inner;
22528         if (ret_var.is_owned) {
22529                 ret_ref |= 1;
22530         }
22531         return ret_ref;
22532 }
22533
22534 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
22535         LDKHolderCommitmentTransaction obj_conv;
22536         obj_conv.inner = (void*)(obj & (~1));
22537         obj_conv.is_owned = false;
22538         LDKCVec_u8Z ret_var = HolderCommitmentTransaction_write(&obj_conv);
22539         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22540         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22541         CVec_u8Z_free(ret_var);
22542         return ret_arr;
22543 }
22544
22545 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
22546         LDKu8slice ser_ref;
22547         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
22548         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
22549         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
22550         *ret_conv = HolderCommitmentTransaction_read(ser_ref);
22551         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
22552         return (uint64_t)ret_conv;
22553 }
22554
22555 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) {
22556         LDKCommitmentTransaction commitment_tx_conv;
22557         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
22558         commitment_tx_conv.is_owned = (commitment_tx & 1) || (commitment_tx == 0);
22559         commitment_tx_conv = CommitmentTransaction_clone(&commitment_tx_conv);
22560         LDKSignature counterparty_sig_ref;
22561         CHECK((*env)->GetArrayLength(env, counterparty_sig) == 64);
22562         (*env)->GetByteArrayRegion(env, counterparty_sig, 0, 64, counterparty_sig_ref.compact_form);
22563         LDKCVec_SignatureZ counterparty_htlc_sigs_constr;
22564         counterparty_htlc_sigs_constr.datalen = (*env)->GetArrayLength(env, counterparty_htlc_sigs);
22565         if (counterparty_htlc_sigs_constr.datalen > 0)
22566                 counterparty_htlc_sigs_constr.data = MALLOC(counterparty_htlc_sigs_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
22567         else
22568                 counterparty_htlc_sigs_constr.data = NULL;
22569         for (size_t i = 0; i < counterparty_htlc_sigs_constr.datalen; i++) {
22570                 int8_tArray counterparty_htlc_sigs_conv_8 = (*env)->GetObjectArrayElement(env, counterparty_htlc_sigs, i);
22571                 LDKSignature counterparty_htlc_sigs_conv_8_ref;
22572                 CHECK((*env)->GetArrayLength(env, counterparty_htlc_sigs_conv_8) == 64);
22573                 (*env)->GetByteArrayRegion(env, counterparty_htlc_sigs_conv_8, 0, 64, counterparty_htlc_sigs_conv_8_ref.compact_form);
22574                 counterparty_htlc_sigs_constr.data[i] = counterparty_htlc_sigs_conv_8_ref;
22575         }
22576         LDKPublicKey holder_funding_key_ref;
22577         CHECK((*env)->GetArrayLength(env, holder_funding_key) == 33);
22578         (*env)->GetByteArrayRegion(env, holder_funding_key, 0, 33, holder_funding_key_ref.compressed_form);
22579         LDKPublicKey counterparty_funding_key_ref;
22580         CHECK((*env)->GetArrayLength(env, counterparty_funding_key) == 33);
22581         (*env)->GetByteArrayRegion(env, counterparty_funding_key, 0, 33, counterparty_funding_key_ref.compressed_form);
22582         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_new(commitment_tx_conv, counterparty_sig_ref, counterparty_htlc_sigs_constr, holder_funding_key_ref, counterparty_funding_key_ref);
22583         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22584         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22585         uint64_t ret_ref = (uint64_t)ret_var.inner;
22586         if (ret_var.is_owned) {
22587                 ret_ref |= 1;
22588         }
22589         return ret_ref;
22590 }
22591
22592 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22593         LDKBuiltCommitmentTransaction this_obj_conv;
22594         this_obj_conv.inner = (void*)(this_obj & (~1));
22595         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22596         BuiltCommitmentTransaction_free(this_obj_conv);
22597 }
22598
22599 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1get_1transaction(JNIEnv *env, jclass clz, int64_t this_ptr) {
22600         LDKBuiltCommitmentTransaction this_ptr_conv;
22601         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22602         this_ptr_conv.is_owned = false;
22603         LDKTransaction ret_var = BuiltCommitmentTransaction_get_transaction(&this_ptr_conv);
22604         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22605         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22606         Transaction_free(ret_var);
22607         return ret_arr;
22608 }
22609
22610 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1set_1transaction(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22611         LDKBuiltCommitmentTransaction this_ptr_conv;
22612         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22613         this_ptr_conv.is_owned = false;
22614         LDKTransaction val_ref;
22615         val_ref.datalen = (*env)->GetArrayLength(env, val);
22616         val_ref.data = MALLOC(val_ref.datalen, "LDKTransaction Bytes");
22617         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
22618         val_ref.data_is_owned = true;
22619         BuiltCommitmentTransaction_set_transaction(&this_ptr_conv, val_ref);
22620 }
22621
22622 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1get_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
22623         LDKBuiltCommitmentTransaction this_ptr_conv;
22624         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22625         this_ptr_conv.is_owned = false;
22626         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
22627         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *BuiltCommitmentTransaction_get_txid(&this_ptr_conv));
22628         return ret_arr;
22629 }
22630
22631 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1set_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22632         LDKBuiltCommitmentTransaction this_ptr_conv;
22633         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22634         this_ptr_conv.is_owned = false;
22635         LDKThirtyTwoBytes val_ref;
22636         CHECK((*env)->GetArrayLength(env, val) == 32);
22637         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
22638         BuiltCommitmentTransaction_set_txid(&this_ptr_conv, val_ref);
22639 }
22640
22641 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1new(JNIEnv *env, jclass clz, int8_tArray transaction_arg, int8_tArray txid_arg) {
22642         LDKTransaction transaction_arg_ref;
22643         transaction_arg_ref.datalen = (*env)->GetArrayLength(env, transaction_arg);
22644         transaction_arg_ref.data = MALLOC(transaction_arg_ref.datalen, "LDKTransaction Bytes");
22645         (*env)->GetByteArrayRegion(env, transaction_arg, 0, transaction_arg_ref.datalen, transaction_arg_ref.data);
22646         transaction_arg_ref.data_is_owned = true;
22647         LDKThirtyTwoBytes txid_arg_ref;
22648         CHECK((*env)->GetArrayLength(env, txid_arg) == 32);
22649         (*env)->GetByteArrayRegion(env, txid_arg, 0, 32, txid_arg_ref.data);
22650         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_new(transaction_arg_ref, txid_arg_ref);
22651         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22652         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22653         uint64_t ret_ref = (uint64_t)ret_var.inner;
22654         if (ret_var.is_owned) {
22655                 ret_ref |= 1;
22656         }
22657         return ret_ref;
22658 }
22659
22660 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22661         LDKBuiltCommitmentTransaction orig_conv;
22662         orig_conv.inner = (void*)(orig & (~1));
22663         orig_conv.is_owned = false;
22664         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(&orig_conv);
22665         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22666         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22667         uint64_t ret_ref = (uint64_t)ret_var.inner;
22668         if (ret_var.is_owned) {
22669                 ret_ref |= 1;
22670         }
22671         return ret_ref;
22672 }
22673
22674 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
22675         LDKBuiltCommitmentTransaction obj_conv;
22676         obj_conv.inner = (void*)(obj & (~1));
22677         obj_conv.is_owned = false;
22678         LDKCVec_u8Z ret_var = BuiltCommitmentTransaction_write(&obj_conv);
22679         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22680         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22681         CVec_u8Z_free(ret_var);
22682         return ret_arr;
22683 }
22684
22685 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
22686         LDKu8slice ser_ref;
22687         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
22688         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
22689         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
22690         *ret_conv = BuiltCommitmentTransaction_read(ser_ref);
22691         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
22692         return (uint64_t)ret_conv;
22693 }
22694
22695 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) {
22696         LDKBuiltCommitmentTransaction this_arg_conv;
22697         this_arg_conv.inner = (void*)(this_arg & (~1));
22698         this_arg_conv.is_owned = false;
22699         LDKu8slice funding_redeemscript_ref;
22700         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
22701         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
22702         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
22703         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, BuiltCommitmentTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data);
22704         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
22705         return ret_arr;
22706 }
22707
22708 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) {
22709         LDKBuiltCommitmentTransaction this_arg_conv;
22710         this_arg_conv.inner = (void*)(this_arg & (~1));
22711         this_arg_conv.is_owned = false;
22712         unsigned char funding_key_arr[32];
22713         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
22714         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_arr);
22715         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
22716         LDKu8slice funding_redeemscript_ref;
22717         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
22718         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
22719         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
22720         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, BuiltCommitmentTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form);
22721         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
22722         return ret_arr;
22723 }
22724
22725 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22726         LDKCommitmentTransaction this_obj_conv;
22727         this_obj_conv.inner = (void*)(this_obj & (~1));
22728         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22729         CommitmentTransaction_free(this_obj_conv);
22730 }
22731
22732 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22733         LDKCommitmentTransaction orig_conv;
22734         orig_conv.inner = (void*)(orig & (~1));
22735         orig_conv.is_owned = false;
22736         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(&orig_conv);
22737         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22738         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22739         uint64_t ret_ref = (uint64_t)ret_var.inner;
22740         if (ret_var.is_owned) {
22741                 ret_ref |= 1;
22742         }
22743         return ret_ref;
22744 }
22745
22746 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
22747         LDKCommitmentTransaction obj_conv;
22748         obj_conv.inner = (void*)(obj & (~1));
22749         obj_conv.is_owned = false;
22750         LDKCVec_u8Z ret_var = CommitmentTransaction_write(&obj_conv);
22751         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22752         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22753         CVec_u8Z_free(ret_var);
22754         return ret_arr;
22755 }
22756
22757 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
22758         LDKu8slice ser_ref;
22759         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
22760         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
22761         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
22762         *ret_conv = CommitmentTransaction_read(ser_ref);
22763         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
22764         return (uint64_t)ret_conv;
22765 }
22766
22767 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_arg) {
22768         LDKCommitmentTransaction this_arg_conv;
22769         this_arg_conv.inner = (void*)(this_arg & (~1));
22770         this_arg_conv.is_owned = false;
22771         int64_t ret_val = CommitmentTransaction_commitment_number(&this_arg_conv);
22772         return ret_val;
22773 }
22774
22775 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1to_1broadcaster_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
22776         LDKCommitmentTransaction this_arg_conv;
22777         this_arg_conv.inner = (void*)(this_arg & (~1));
22778         this_arg_conv.is_owned = false;
22779         int64_t ret_val = CommitmentTransaction_to_broadcaster_value_sat(&this_arg_conv);
22780         return ret_val;
22781 }
22782
22783 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1to_1countersignatory_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
22784         LDKCommitmentTransaction this_arg_conv;
22785         this_arg_conv.inner = (void*)(this_arg & (~1));
22786         this_arg_conv.is_owned = false;
22787         int64_t ret_val = CommitmentTransaction_to_countersignatory_value_sat(&this_arg_conv);
22788         return ret_val;
22789 }
22790
22791 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_arg) {
22792         LDKCommitmentTransaction this_arg_conv;
22793         this_arg_conv.inner = (void*)(this_arg & (~1));
22794         this_arg_conv.is_owned = false;
22795         int32_t ret_val = CommitmentTransaction_feerate_per_kw(&this_arg_conv);
22796         return ret_val;
22797 }
22798
22799 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1trust(JNIEnv *env, jclass clz, int64_t this_arg) {
22800         LDKCommitmentTransaction this_arg_conv;
22801         this_arg_conv.inner = (void*)(this_arg & (~1));
22802         this_arg_conv.is_owned = false;
22803         LDKTrustedCommitmentTransaction ret_var = CommitmentTransaction_trust(&this_arg_conv);
22804         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22805         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22806         uint64_t ret_ref = (uint64_t)ret_var.inner;
22807         if (ret_var.is_owned) {
22808                 ret_ref |= 1;
22809         }
22810         return ret_ref;
22811 }
22812
22813 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) {
22814         LDKCommitmentTransaction this_arg_conv;
22815         this_arg_conv.inner = (void*)(this_arg & (~1));
22816         this_arg_conv.is_owned = false;
22817         LDKDirectedChannelTransactionParameters channel_parameters_conv;
22818         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
22819         channel_parameters_conv.is_owned = false;
22820         LDKChannelPublicKeys broadcaster_keys_conv;
22821         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
22822         broadcaster_keys_conv.is_owned = false;
22823         LDKChannelPublicKeys countersignatory_keys_conv;
22824         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
22825         countersignatory_keys_conv.is_owned = false;
22826         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
22827         *ret_conv = CommitmentTransaction_verify(&this_arg_conv, &channel_parameters_conv, &broadcaster_keys_conv, &countersignatory_keys_conv);
22828         return (uint64_t)ret_conv;
22829 }
22830
22831 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22832         LDKTrustedCommitmentTransaction this_obj_conv;
22833         this_obj_conv.inner = (void*)(this_obj & (~1));
22834         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22835         TrustedCommitmentTransaction_free(this_obj_conv);
22836 }
22837
22838 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1txid(JNIEnv *env, jclass clz, int64_t this_arg) {
22839         LDKTrustedCommitmentTransaction this_arg_conv;
22840         this_arg_conv.inner = (void*)(this_arg & (~1));
22841         this_arg_conv.is_owned = false;
22842         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
22843         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, TrustedCommitmentTransaction_txid(&this_arg_conv).data);
22844         return ret_arr;
22845 }
22846
22847 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1built_1transaction(JNIEnv *env, jclass clz, int64_t this_arg) {
22848         LDKTrustedCommitmentTransaction this_arg_conv;
22849         this_arg_conv.inner = (void*)(this_arg & (~1));
22850         this_arg_conv.is_owned = false;
22851         LDKBuiltCommitmentTransaction ret_var = TrustedCommitmentTransaction_built_transaction(&this_arg_conv);
22852         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22853         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22854         uint64_t ret_ref = (uint64_t)ret_var.inner;
22855         if (ret_var.is_owned) {
22856                 ret_ref |= 1;
22857         }
22858         return ret_ref;
22859 }
22860
22861 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1keys(JNIEnv *env, jclass clz, int64_t this_arg) {
22862         LDKTrustedCommitmentTransaction this_arg_conv;
22863         this_arg_conv.inner = (void*)(this_arg & (~1));
22864         this_arg_conv.is_owned = false;
22865         LDKTxCreationKeys ret_var = TrustedCommitmentTransaction_keys(&this_arg_conv);
22866         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22867         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22868         uint64_t ret_ref = (uint64_t)ret_var.inner;
22869         if (ret_var.is_owned) {
22870                 ret_ref |= 1;
22871         }
22872         return ret_ref;
22873 }
22874
22875 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) {
22876         LDKTrustedCommitmentTransaction this_arg_conv;
22877         this_arg_conv.inner = (void*)(this_arg & (~1));
22878         this_arg_conv.is_owned = false;
22879         unsigned char htlc_base_key_arr[32];
22880         CHECK((*env)->GetArrayLength(env, htlc_base_key) == 32);
22881         (*env)->GetByteArrayRegion(env, htlc_base_key, 0, 32, htlc_base_key_arr);
22882         unsigned char (*htlc_base_key_ref)[32] = &htlc_base_key_arr;
22883         LDKDirectedChannelTransactionParameters channel_parameters_conv;
22884         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
22885         channel_parameters_conv.is_owned = false;
22886         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
22887         *ret_conv = TrustedCommitmentTransaction_get_htlc_sigs(&this_arg_conv, htlc_base_key_ref, &channel_parameters_conv);
22888         return (uint64_t)ret_conv;
22889 }
22890
22891 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) {
22892         LDKPublicKey broadcaster_payment_basepoint_ref;
22893         CHECK((*env)->GetArrayLength(env, broadcaster_payment_basepoint) == 33);
22894         (*env)->GetByteArrayRegion(env, broadcaster_payment_basepoint, 0, 33, broadcaster_payment_basepoint_ref.compressed_form);
22895         LDKPublicKey countersignatory_payment_basepoint_ref;
22896         CHECK((*env)->GetArrayLength(env, countersignatory_payment_basepoint) == 33);
22897         (*env)->GetByteArrayRegion(env, countersignatory_payment_basepoint, 0, 33, countersignatory_payment_basepoint_ref.compressed_form);
22898         int64_t ret_val = get_commitment_transaction_number_obscure_factor(broadcaster_payment_basepoint_ref, countersignatory_payment_basepoint_ref, outbound_from_broadcaster);
22899         return ret_val;
22900 }
22901
22902 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
22903         LDKInitFeatures a_conv;
22904         a_conv.inner = (void*)(a & (~1));
22905         a_conv.is_owned = false;
22906         LDKInitFeatures b_conv;
22907         b_conv.inner = (void*)(b & (~1));
22908         b_conv.is_owned = false;
22909         jboolean ret_val = InitFeatures_eq(&a_conv, &b_conv);
22910         return ret_val;
22911 }
22912
22913 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
22914         LDKNodeFeatures a_conv;
22915         a_conv.inner = (void*)(a & (~1));
22916         a_conv.is_owned = false;
22917         LDKNodeFeatures b_conv;
22918         b_conv.inner = (void*)(b & (~1));
22919         b_conv.is_owned = false;
22920         jboolean ret_val = NodeFeatures_eq(&a_conv, &b_conv);
22921         return ret_val;
22922 }
22923
22924 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
22925         LDKChannelFeatures a_conv;
22926         a_conv.inner = (void*)(a & (~1));
22927         a_conv.is_owned = false;
22928         LDKChannelFeatures b_conv;
22929         b_conv.inner = (void*)(b & (~1));
22930         b_conv.is_owned = false;
22931         jboolean ret_val = ChannelFeatures_eq(&a_conv, &b_conv);
22932         return ret_val;
22933 }
22934
22935 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
22936         LDKInvoiceFeatures a_conv;
22937         a_conv.inner = (void*)(a & (~1));
22938         a_conv.is_owned = false;
22939         LDKInvoiceFeatures b_conv;
22940         b_conv.inner = (void*)(b & (~1));
22941         b_conv.is_owned = false;
22942         jboolean ret_val = InvoiceFeatures_eq(&a_conv, &b_conv);
22943         return ret_val;
22944 }
22945
22946 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22947         LDKInitFeatures orig_conv;
22948         orig_conv.inner = (void*)(orig & (~1));
22949         orig_conv.is_owned = false;
22950         LDKInitFeatures ret_var = InitFeatures_clone(&orig_conv);
22951         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22952         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22953         uint64_t ret_ref = (uint64_t)ret_var.inner;
22954         if (ret_var.is_owned) {
22955                 ret_ref |= 1;
22956         }
22957         return ret_ref;
22958 }
22959
22960 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22961         LDKNodeFeatures orig_conv;
22962         orig_conv.inner = (void*)(orig & (~1));
22963         orig_conv.is_owned = false;
22964         LDKNodeFeatures ret_var = NodeFeatures_clone(&orig_conv);
22965         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22966         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22967         uint64_t ret_ref = (uint64_t)ret_var.inner;
22968         if (ret_var.is_owned) {
22969                 ret_ref |= 1;
22970         }
22971         return ret_ref;
22972 }
22973
22974 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22975         LDKChannelFeatures orig_conv;
22976         orig_conv.inner = (void*)(orig & (~1));
22977         orig_conv.is_owned = false;
22978         LDKChannelFeatures ret_var = ChannelFeatures_clone(&orig_conv);
22979         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22980         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22981         uint64_t ret_ref = (uint64_t)ret_var.inner;
22982         if (ret_var.is_owned) {
22983                 ret_ref |= 1;
22984         }
22985         return ret_ref;
22986 }
22987
22988 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22989         LDKInvoiceFeatures orig_conv;
22990         orig_conv.inner = (void*)(orig & (~1));
22991         orig_conv.is_owned = false;
22992         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(&orig_conv);
22993         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22994         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22995         uint64_t ret_ref = (uint64_t)ret_var.inner;
22996         if (ret_var.is_owned) {
22997                 ret_ref |= 1;
22998         }
22999         return ret_ref;
23000 }
23001
23002 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23003         LDKInitFeatures this_obj_conv;
23004         this_obj_conv.inner = (void*)(this_obj & (~1));
23005         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23006         InitFeatures_free(this_obj_conv);
23007 }
23008
23009 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23010         LDKNodeFeatures this_obj_conv;
23011         this_obj_conv.inner = (void*)(this_obj & (~1));
23012         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23013         NodeFeatures_free(this_obj_conv);
23014 }
23015
23016 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23017         LDKChannelFeatures this_obj_conv;
23018         this_obj_conv.inner = (void*)(this_obj & (~1));
23019         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23020         ChannelFeatures_free(this_obj_conv);
23021 }
23022
23023 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23024         LDKInvoiceFeatures this_obj_conv;
23025         this_obj_conv.inner = (void*)(this_obj & (~1));
23026         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23027         InvoiceFeatures_free(this_obj_conv);
23028 }
23029
23030 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1empty(JNIEnv *env, jclass clz) {
23031         LDKInitFeatures ret_var = InitFeatures_empty();
23032         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23033         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23034         uint64_t ret_ref = (uint64_t)ret_var.inner;
23035         if (ret_var.is_owned) {
23036                 ret_ref |= 1;
23037         }
23038         return ret_ref;
23039 }
23040
23041 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1known(JNIEnv *env, jclass clz) {
23042         LDKInitFeatures ret_var = InitFeatures_known();
23043         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23044         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23045         uint64_t ret_ref = (uint64_t)ret_var.inner;
23046         if (ret_var.is_owned) {
23047                 ret_ref |= 1;
23048         }
23049         return ret_ref;
23050 }
23051
23052 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1empty(JNIEnv *env, jclass clz) {
23053         LDKNodeFeatures ret_var = NodeFeatures_empty();
23054         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23055         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23056         uint64_t ret_ref = (uint64_t)ret_var.inner;
23057         if (ret_var.is_owned) {
23058                 ret_ref |= 1;
23059         }
23060         return ret_ref;
23061 }
23062
23063 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1known(JNIEnv *env, jclass clz) {
23064         LDKNodeFeatures ret_var = NodeFeatures_known();
23065         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23066         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23067         uint64_t ret_ref = (uint64_t)ret_var.inner;
23068         if (ret_var.is_owned) {
23069                 ret_ref |= 1;
23070         }
23071         return ret_ref;
23072 }
23073
23074 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1empty(JNIEnv *env, jclass clz) {
23075         LDKChannelFeatures ret_var = ChannelFeatures_empty();
23076         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23077         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23078         uint64_t ret_ref = (uint64_t)ret_var.inner;
23079         if (ret_var.is_owned) {
23080                 ret_ref |= 1;
23081         }
23082         return ret_ref;
23083 }
23084
23085 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1known(JNIEnv *env, jclass clz) {
23086         LDKChannelFeatures ret_var = ChannelFeatures_known();
23087         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23088         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23089         uint64_t ret_ref = (uint64_t)ret_var.inner;
23090         if (ret_var.is_owned) {
23091                 ret_ref |= 1;
23092         }
23093         return ret_ref;
23094 }
23095
23096 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1empty(JNIEnv *env, jclass clz) {
23097         LDKInvoiceFeatures ret_var = InvoiceFeatures_empty();
23098         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23099         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23100         uint64_t ret_ref = (uint64_t)ret_var.inner;
23101         if (ret_var.is_owned) {
23102                 ret_ref |= 1;
23103         }
23104         return ret_ref;
23105 }
23106
23107 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1known(JNIEnv *env, jclass clz) {
23108         LDKInvoiceFeatures ret_var = InvoiceFeatures_known();
23109         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23110         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23111         uint64_t ret_ref = (uint64_t)ret_var.inner;
23112         if (ret_var.is_owned) {
23113                 ret_ref |= 1;
23114         }
23115         return ret_ref;
23116 }
23117
23118 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
23119         LDKInitFeatures this_arg_conv;
23120         this_arg_conv.inner = (void*)(this_arg & (~1));
23121         this_arg_conv.is_owned = false;
23122         jboolean ret_val = InitFeatures_supports_payment_secret(&this_arg_conv);
23123         return ret_val;
23124 }
23125
23126 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
23127         LDKNodeFeatures this_arg_conv;
23128         this_arg_conv.inner = (void*)(this_arg & (~1));
23129         this_arg_conv.is_owned = false;
23130         jboolean ret_val = NodeFeatures_supports_payment_secret(&this_arg_conv);
23131         return ret_val;
23132 }
23133
23134 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1supports_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
23135         LDKInvoiceFeatures this_arg_conv;
23136         this_arg_conv.inner = (void*)(this_arg & (~1));
23137         this_arg_conv.is_owned = false;
23138         jboolean ret_val = InvoiceFeatures_supports_payment_secret(&this_arg_conv);
23139         return ret_val;
23140 }
23141
23142 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InitFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
23143         LDKInitFeatures obj_conv;
23144         obj_conv.inner = (void*)(obj & (~1));
23145         obj_conv.is_owned = false;
23146         LDKCVec_u8Z ret_var = InitFeatures_write(&obj_conv);
23147         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23148         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23149         CVec_u8Z_free(ret_var);
23150         return ret_arr;
23151 }
23152
23153 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
23154         LDKNodeFeatures obj_conv;
23155         obj_conv.inner = (void*)(obj & (~1));
23156         obj_conv.is_owned = false;
23157         LDKCVec_u8Z ret_var = NodeFeatures_write(&obj_conv);
23158         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23159         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23160         CVec_u8Z_free(ret_var);
23161         return ret_arr;
23162 }
23163
23164 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
23165         LDKChannelFeatures obj_conv;
23166         obj_conv.inner = (void*)(obj & (~1));
23167         obj_conv.is_owned = false;
23168         LDKCVec_u8Z ret_var = ChannelFeatures_write(&obj_conv);
23169         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23170         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23171         CVec_u8Z_free(ret_var);
23172         return ret_arr;
23173 }
23174
23175 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
23176         LDKInvoiceFeatures obj_conv;
23177         obj_conv.inner = (void*)(obj & (~1));
23178         obj_conv.is_owned = false;
23179         LDKCVec_u8Z ret_var = InvoiceFeatures_write(&obj_conv);
23180         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23181         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23182         CVec_u8Z_free(ret_var);
23183         return ret_arr;
23184 }
23185
23186 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23187         LDKu8slice ser_ref;
23188         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23189         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23190         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
23191         *ret_conv = InitFeatures_read(ser_ref);
23192         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23193         return (uint64_t)ret_conv;
23194 }
23195
23196 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23197         LDKu8slice ser_ref;
23198         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23199         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23200         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
23201         *ret_conv = NodeFeatures_read(ser_ref);
23202         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23203         return (uint64_t)ret_conv;
23204 }
23205
23206 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23207         LDKu8slice ser_ref;
23208         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23209         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23210         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
23211         *ret_conv = ChannelFeatures_read(ser_ref);
23212         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23213         return (uint64_t)ret_conv;
23214 }
23215
23216 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23217         LDKu8slice ser_ref;
23218         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23219         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23220         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
23221         *ret_conv = InvoiceFeatures_read(ser_ref);
23222         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23223         return (uint64_t)ret_conv;
23224 }
23225
23226 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23227         LDKRouteHop this_obj_conv;
23228         this_obj_conv.inner = (void*)(this_obj & (~1));
23229         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23230         RouteHop_free(this_obj_conv);
23231 }
23232
23233 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
23234         LDKRouteHop this_ptr_conv;
23235         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23236         this_ptr_conv.is_owned = false;
23237         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
23238         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RouteHop_get_pubkey(&this_ptr_conv).compressed_form);
23239         return ret_arr;
23240 }
23241
23242 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
23243         LDKRouteHop this_ptr_conv;
23244         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23245         this_ptr_conv.is_owned = false;
23246         LDKPublicKey val_ref;
23247         CHECK((*env)->GetArrayLength(env, val) == 33);
23248         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
23249         RouteHop_set_pubkey(&this_ptr_conv, val_ref);
23250 }
23251
23252 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1node_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
23253         LDKRouteHop this_ptr_conv;
23254         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23255         this_ptr_conv.is_owned = false;
23256         LDKNodeFeatures ret_var = RouteHop_get_node_features(&this_ptr_conv);
23257         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23258         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23259         uint64_t ret_ref = (uint64_t)ret_var.inner;
23260         if (ret_var.is_owned) {
23261                 ret_ref |= 1;
23262         }
23263         return ret_ref;
23264 }
23265
23266 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1node_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23267         LDKRouteHop this_ptr_conv;
23268         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23269         this_ptr_conv.is_owned = false;
23270         LDKNodeFeatures val_conv;
23271         val_conv.inner = (void*)(val & (~1));
23272         val_conv.is_owned = (val & 1) || (val == 0);
23273         val_conv = NodeFeatures_clone(&val_conv);
23274         RouteHop_set_node_features(&this_ptr_conv, val_conv);
23275 }
23276
23277 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
23278         LDKRouteHop this_ptr_conv;
23279         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23280         this_ptr_conv.is_owned = false;
23281         int64_t ret_val = RouteHop_get_short_channel_id(&this_ptr_conv);
23282         return ret_val;
23283 }
23284
23285 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23286         LDKRouteHop this_ptr_conv;
23287         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23288         this_ptr_conv.is_owned = false;
23289         RouteHop_set_short_channel_id(&this_ptr_conv, val);
23290 }
23291
23292 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1channel_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
23293         LDKRouteHop this_ptr_conv;
23294         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23295         this_ptr_conv.is_owned = false;
23296         LDKChannelFeatures ret_var = RouteHop_get_channel_features(&this_ptr_conv);
23297         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23298         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23299         uint64_t ret_ref = (uint64_t)ret_var.inner;
23300         if (ret_var.is_owned) {
23301                 ret_ref |= 1;
23302         }
23303         return ret_ref;
23304 }
23305
23306 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1channel_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23307         LDKRouteHop this_ptr_conv;
23308         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23309         this_ptr_conv.is_owned = false;
23310         LDKChannelFeatures val_conv;
23311         val_conv.inner = (void*)(val & (~1));
23312         val_conv.is_owned = (val & 1) || (val == 0);
23313         val_conv = ChannelFeatures_clone(&val_conv);
23314         RouteHop_set_channel_features(&this_ptr_conv, val_conv);
23315 }
23316
23317 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1fee_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
23318         LDKRouteHop this_ptr_conv;
23319         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23320         this_ptr_conv.is_owned = false;
23321         int64_t ret_val = RouteHop_get_fee_msat(&this_ptr_conv);
23322         return ret_val;
23323 }
23324
23325 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1fee_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23326         LDKRouteHop this_ptr_conv;
23327         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23328         this_ptr_conv.is_owned = false;
23329         RouteHop_set_fee_msat(&this_ptr_conv, val);
23330 }
23331
23332 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
23333         LDKRouteHop this_ptr_conv;
23334         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23335         this_ptr_conv.is_owned = false;
23336         int32_t ret_val = RouteHop_get_cltv_expiry_delta(&this_ptr_conv);
23337         return ret_val;
23338 }
23339
23340 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
23341         LDKRouteHop this_ptr_conv;
23342         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23343         this_ptr_conv.is_owned = false;
23344         RouteHop_set_cltv_expiry_delta(&this_ptr_conv, val);
23345 }
23346
23347 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) {
23348         LDKPublicKey pubkey_arg_ref;
23349         CHECK((*env)->GetArrayLength(env, pubkey_arg) == 33);
23350         (*env)->GetByteArrayRegion(env, pubkey_arg, 0, 33, pubkey_arg_ref.compressed_form);
23351         LDKNodeFeatures node_features_arg_conv;
23352         node_features_arg_conv.inner = (void*)(node_features_arg & (~1));
23353         node_features_arg_conv.is_owned = (node_features_arg & 1) || (node_features_arg == 0);
23354         node_features_arg_conv = NodeFeatures_clone(&node_features_arg_conv);
23355         LDKChannelFeatures channel_features_arg_conv;
23356         channel_features_arg_conv.inner = (void*)(channel_features_arg & (~1));
23357         channel_features_arg_conv.is_owned = (channel_features_arg & 1) || (channel_features_arg == 0);
23358         channel_features_arg_conv = ChannelFeatures_clone(&channel_features_arg_conv);
23359         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);
23360         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23361         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23362         uint64_t ret_ref = (uint64_t)ret_var.inner;
23363         if (ret_var.is_owned) {
23364                 ret_ref |= 1;
23365         }
23366         return ret_ref;
23367 }
23368
23369 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23370         LDKRouteHop orig_conv;
23371         orig_conv.inner = (void*)(orig & (~1));
23372         orig_conv.is_owned = false;
23373         LDKRouteHop ret_var = RouteHop_clone(&orig_conv);
23374         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23375         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23376         uint64_t ret_ref = (uint64_t)ret_var.inner;
23377         if (ret_var.is_owned) {
23378                 ret_ref |= 1;
23379         }
23380         return ret_ref;
23381 }
23382
23383 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHop_1write(JNIEnv *env, jclass clz, int64_t obj) {
23384         LDKRouteHop obj_conv;
23385         obj_conv.inner = (void*)(obj & (~1));
23386         obj_conv.is_owned = false;
23387         LDKCVec_u8Z ret_var = RouteHop_write(&obj_conv);
23388         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23389         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23390         CVec_u8Z_free(ret_var);
23391         return ret_arr;
23392 }
23393
23394 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23395         LDKu8slice ser_ref;
23396         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23397         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23398         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
23399         *ret_conv = RouteHop_read(ser_ref);
23400         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23401         return (uint64_t)ret_conv;
23402 }
23403
23404 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23405         LDKRoute this_obj_conv;
23406         this_obj_conv.inner = (void*)(this_obj & (~1));
23407         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23408         Route_free(this_obj_conv);
23409 }
23410
23411 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1set_1paths(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
23412         LDKRoute this_ptr_conv;
23413         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23414         this_ptr_conv.is_owned = false;
23415         LDKCVec_CVec_RouteHopZZ val_constr;
23416         val_constr.datalen = (*env)->GetArrayLength(env, val);
23417         if (val_constr.datalen > 0)
23418                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
23419         else
23420                 val_constr.data = NULL;
23421         for (size_t m = 0; m < val_constr.datalen; m++) {
23422                 int64_tArray val_conv_12 = (*env)->GetObjectArrayElement(env, val, m);
23423                 LDKCVec_RouteHopZ val_conv_12_constr;
23424                 val_conv_12_constr.datalen = (*env)->GetArrayLength(env, val_conv_12);
23425                 if (val_conv_12_constr.datalen > 0)
23426                         val_conv_12_constr.data = MALLOC(val_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
23427                 else
23428                         val_conv_12_constr.data = NULL;
23429                 int64_t* val_conv_12_vals = (*env)->GetLongArrayElements (env, val_conv_12, NULL);
23430                 for (size_t k = 0; k < val_conv_12_constr.datalen; k++) {
23431                         int64_t val_conv_12_conv_10 = val_conv_12_vals[k];
23432                         LDKRouteHop val_conv_12_conv_10_conv;
23433                         val_conv_12_conv_10_conv.inner = (void*)(val_conv_12_conv_10 & (~1));
23434                         val_conv_12_conv_10_conv.is_owned = (val_conv_12_conv_10 & 1) || (val_conv_12_conv_10 == 0);
23435                         val_conv_12_conv_10_conv = RouteHop_clone(&val_conv_12_conv_10_conv);
23436                         val_conv_12_constr.data[k] = val_conv_12_conv_10_conv;
23437                 }
23438                 (*env)->ReleaseLongArrayElements(env, val_conv_12, val_conv_12_vals, 0);
23439                 val_constr.data[m] = val_conv_12_constr;
23440         }
23441         Route_set_paths(&this_ptr_conv, val_constr);
23442 }
23443
23444 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1new(JNIEnv *env, jclass clz, jobjectArray paths_arg) {
23445         LDKCVec_CVec_RouteHopZZ paths_arg_constr;
23446         paths_arg_constr.datalen = (*env)->GetArrayLength(env, paths_arg);
23447         if (paths_arg_constr.datalen > 0)
23448                 paths_arg_constr.data = MALLOC(paths_arg_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
23449         else
23450                 paths_arg_constr.data = NULL;
23451         for (size_t m = 0; m < paths_arg_constr.datalen; m++) {
23452                 int64_tArray paths_arg_conv_12 = (*env)->GetObjectArrayElement(env, paths_arg, m);
23453                 LDKCVec_RouteHopZ paths_arg_conv_12_constr;
23454                 paths_arg_conv_12_constr.datalen = (*env)->GetArrayLength(env, paths_arg_conv_12);
23455                 if (paths_arg_conv_12_constr.datalen > 0)
23456                         paths_arg_conv_12_constr.data = MALLOC(paths_arg_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
23457                 else
23458                         paths_arg_conv_12_constr.data = NULL;
23459                 int64_t* paths_arg_conv_12_vals = (*env)->GetLongArrayElements (env, paths_arg_conv_12, NULL);
23460                 for (size_t k = 0; k < paths_arg_conv_12_constr.datalen; k++) {
23461                         int64_t paths_arg_conv_12_conv_10 = paths_arg_conv_12_vals[k];
23462                         LDKRouteHop paths_arg_conv_12_conv_10_conv;
23463                         paths_arg_conv_12_conv_10_conv.inner = (void*)(paths_arg_conv_12_conv_10 & (~1));
23464                         paths_arg_conv_12_conv_10_conv.is_owned = (paths_arg_conv_12_conv_10 & 1) || (paths_arg_conv_12_conv_10 == 0);
23465                         paths_arg_conv_12_conv_10_conv = RouteHop_clone(&paths_arg_conv_12_conv_10_conv);
23466                         paths_arg_conv_12_constr.data[k] = paths_arg_conv_12_conv_10_conv;
23467                 }
23468                 (*env)->ReleaseLongArrayElements(env, paths_arg_conv_12, paths_arg_conv_12_vals, 0);
23469                 paths_arg_constr.data[m] = paths_arg_conv_12_constr;
23470         }
23471         LDKRoute ret_var = Route_new(paths_arg_constr);
23472         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23473         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23474         uint64_t ret_ref = (uint64_t)ret_var.inner;
23475         if (ret_var.is_owned) {
23476                 ret_ref |= 1;
23477         }
23478         return ret_ref;
23479 }
23480
23481 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23482         LDKRoute orig_conv;
23483         orig_conv.inner = (void*)(orig & (~1));
23484         orig_conv.is_owned = false;
23485         LDKRoute ret_var = Route_clone(&orig_conv);
23486         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23487         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23488         uint64_t ret_ref = (uint64_t)ret_var.inner;
23489         if (ret_var.is_owned) {
23490                 ret_ref |= 1;
23491         }
23492         return ret_ref;
23493 }
23494
23495 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Route_1write(JNIEnv *env, jclass clz, int64_t obj) {
23496         LDKRoute obj_conv;
23497         obj_conv.inner = (void*)(obj & (~1));
23498         obj_conv.is_owned = false;
23499         LDKCVec_u8Z ret_var = Route_write(&obj_conv);
23500         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23501         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23502         CVec_u8Z_free(ret_var);
23503         return ret_arr;
23504 }
23505
23506 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23507         LDKu8slice ser_ref;
23508         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23509         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23510         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
23511         *ret_conv = Route_read(ser_ref);
23512         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23513         return (uint64_t)ret_conv;
23514 }
23515
23516 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23517         LDKRouteHint this_obj_conv;
23518         this_obj_conv.inner = (void*)(this_obj & (~1));
23519         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23520         RouteHint_free(this_obj_conv);
23521 }
23522
23523 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHint_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
23524         LDKRouteHint a_conv;
23525         a_conv.inner = (void*)(a & (~1));
23526         a_conv.is_owned = false;
23527         LDKRouteHint b_conv;
23528         b_conv.inner = (void*)(b & (~1));
23529         b_conv.is_owned = false;
23530         jboolean ret_val = RouteHint_eq(&a_conv, &b_conv);
23531         return ret_val;
23532 }
23533
23534 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23535         LDKRouteHint orig_conv;
23536         orig_conv.inner = (void*)(orig & (~1));
23537         orig_conv.is_owned = false;
23538         LDKRouteHint ret_var = RouteHint_clone(&orig_conv);
23539         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23540         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23541         uint64_t ret_ref = (uint64_t)ret_var.inner;
23542         if (ret_var.is_owned) {
23543                 ret_ref |= 1;
23544         }
23545         return ret_ref;
23546 }
23547
23548 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23549         LDKRouteHintHop this_obj_conv;
23550         this_obj_conv.inner = (void*)(this_obj & (~1));
23551         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23552         RouteHintHop_free(this_obj_conv);
23553 }
23554
23555 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1src_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
23556         LDKRouteHintHop this_ptr_conv;
23557         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23558         this_ptr_conv.is_owned = false;
23559         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
23560         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RouteHintHop_get_src_node_id(&this_ptr_conv).compressed_form);
23561         return ret_arr;
23562 }
23563
23564 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1src_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
23565         LDKRouteHintHop this_ptr_conv;
23566         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23567         this_ptr_conv.is_owned = false;
23568         LDKPublicKey val_ref;
23569         CHECK((*env)->GetArrayLength(env, val) == 33);
23570         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
23571         RouteHintHop_set_src_node_id(&this_ptr_conv, val_ref);
23572 }
23573
23574 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
23575         LDKRouteHintHop this_ptr_conv;
23576         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23577         this_ptr_conv.is_owned = false;
23578         int64_t ret_val = RouteHintHop_get_short_channel_id(&this_ptr_conv);
23579         return ret_val;
23580 }
23581
23582 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23583         LDKRouteHintHop this_ptr_conv;
23584         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23585         this_ptr_conv.is_owned = false;
23586         RouteHintHop_set_short_channel_id(&this_ptr_conv, val);
23587 }
23588
23589 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
23590         LDKRouteHintHop this_ptr_conv;
23591         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23592         this_ptr_conv.is_owned = false;
23593         LDKRoutingFees ret_var = RouteHintHop_get_fees(&this_ptr_conv);
23594         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23595         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23596         uint64_t ret_ref = (uint64_t)ret_var.inner;
23597         if (ret_var.is_owned) {
23598                 ret_ref |= 1;
23599         }
23600         return ret_ref;
23601 }
23602
23603 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1fees(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23604         LDKRouteHintHop this_ptr_conv;
23605         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23606         this_ptr_conv.is_owned = false;
23607         LDKRoutingFees val_conv;
23608         val_conv.inner = (void*)(val & (~1));
23609         val_conv.is_owned = (val & 1) || (val == 0);
23610         val_conv = RoutingFees_clone(&val_conv);
23611         RouteHintHop_set_fees(&this_ptr_conv, val_conv);
23612 }
23613
23614 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
23615         LDKRouteHintHop this_ptr_conv;
23616         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23617         this_ptr_conv.is_owned = false;
23618         int16_t ret_val = RouteHintHop_get_cltv_expiry_delta(&this_ptr_conv);
23619         return ret_val;
23620 }
23621
23622 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
23623         LDKRouteHintHop this_ptr_conv;
23624         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23625         this_ptr_conv.is_owned = false;
23626         RouteHintHop_set_cltv_expiry_delta(&this_ptr_conv, val);
23627 }
23628
23629 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
23630         LDKRouteHintHop this_ptr_conv;
23631         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23632         this_ptr_conv.is_owned = false;
23633         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
23634         *ret_copy = RouteHintHop_get_htlc_minimum_msat(&this_ptr_conv);
23635         uint64_t ret_ref = (uint64_t)ret_copy;
23636         return ret_ref;
23637 }
23638
23639 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23640         LDKRouteHintHop this_ptr_conv;
23641         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23642         this_ptr_conv.is_owned = false;
23643         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
23644         RouteHintHop_set_htlc_minimum_msat(&this_ptr_conv, val_conv);
23645 }
23646
23647 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
23648         LDKRouteHintHop this_ptr_conv;
23649         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23650         this_ptr_conv.is_owned = false;
23651         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
23652         *ret_copy = RouteHintHop_get_htlc_maximum_msat(&this_ptr_conv);
23653         uint64_t ret_ref = (uint64_t)ret_copy;
23654         return ret_ref;
23655 }
23656
23657 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23658         LDKRouteHintHop this_ptr_conv;
23659         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23660         this_ptr_conv.is_owned = false;
23661         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
23662         RouteHintHop_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
23663 }
23664
23665 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) {
23666         LDKPublicKey src_node_id_arg_ref;
23667         CHECK((*env)->GetArrayLength(env, src_node_id_arg) == 33);
23668         (*env)->GetByteArrayRegion(env, src_node_id_arg, 0, 33, src_node_id_arg_ref.compressed_form);
23669         LDKRoutingFees fees_arg_conv;
23670         fees_arg_conv.inner = (void*)(fees_arg & (~1));
23671         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
23672         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
23673         LDKCOption_u64Z htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)htlc_minimum_msat_arg) & ~1);
23674         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)htlc_maximum_msat_arg) & ~1);
23675         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);
23676         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23677         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23678         uint64_t ret_ref = (uint64_t)ret_var.inner;
23679         if (ret_var.is_owned) {
23680                 ret_ref |= 1;
23681         }
23682         return ret_ref;
23683 }
23684
23685 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
23686         LDKRouteHintHop a_conv;
23687         a_conv.inner = (void*)(a & (~1));
23688         a_conv.is_owned = false;
23689         LDKRouteHintHop b_conv;
23690         b_conv.inner = (void*)(b & (~1));
23691         b_conv.is_owned = false;
23692         jboolean ret_val = RouteHintHop_eq(&a_conv, &b_conv);
23693         return ret_val;
23694 }
23695
23696 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23697         LDKRouteHintHop orig_conv;
23698         orig_conv.inner = (void*)(orig & (~1));
23699         orig_conv.is_owned = false;
23700         LDKRouteHintHop ret_var = RouteHintHop_clone(&orig_conv);
23701         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23702         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23703         uint64_t ret_ref = (uint64_t)ret_var.inner;
23704         if (ret_var.is_owned) {
23705                 ret_ref |= 1;
23706         }
23707         return ret_ref;
23708 }
23709
23710 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_get_1route(JNIEnv *env, jclass clz, int8_tArray our_node_id, int64_t network, int8_tArray payee, int64_t payee_features, int64_tArray first_hops, int64_tArray last_hops, int64_t final_value_msat, int32_t final_cltv, int64_t logger) {
23711         LDKPublicKey our_node_id_ref;
23712         CHECK((*env)->GetArrayLength(env, our_node_id) == 33);
23713         (*env)->GetByteArrayRegion(env, our_node_id, 0, 33, our_node_id_ref.compressed_form);
23714         LDKNetworkGraph network_conv;
23715         network_conv.inner = (void*)(network & (~1));
23716         network_conv.is_owned = false;
23717         LDKPublicKey payee_ref;
23718         CHECK((*env)->GetArrayLength(env, payee) == 33);
23719         (*env)->GetByteArrayRegion(env, payee, 0, 33, payee_ref.compressed_form);
23720         LDKInvoiceFeatures payee_features_conv;
23721         payee_features_conv.inner = (void*)(payee_features & (~1));
23722         payee_features_conv.is_owned = (payee_features & 1) || (payee_features == 0);
23723         payee_features_conv = InvoiceFeatures_clone(&payee_features_conv);
23724         LDKCVec_ChannelDetailsZ first_hops_constr;
23725         first_hops_constr.datalen = (*env)->GetArrayLength(env, first_hops);
23726         if (first_hops_constr.datalen > 0)
23727                 first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
23728         else
23729                 first_hops_constr.data = NULL;
23730         int64_t* first_hops_vals = (*env)->GetLongArrayElements (env, first_hops, NULL);
23731         for (size_t q = 0; q < first_hops_constr.datalen; q++) {
23732                 int64_t first_hops_conv_16 = first_hops_vals[q];
23733                 LDKChannelDetails first_hops_conv_16_conv;
23734                 first_hops_conv_16_conv.inner = (void*)(first_hops_conv_16 & (~1));
23735                 first_hops_conv_16_conv.is_owned = (first_hops_conv_16 & 1) || (first_hops_conv_16 == 0);
23736                 first_hops_constr.data[q] = first_hops_conv_16_conv;
23737         }
23738         (*env)->ReleaseLongArrayElements(env, first_hops, first_hops_vals, 0);
23739         LDKCVec_RouteHintZ last_hops_constr;
23740         last_hops_constr.datalen = (*env)->GetArrayLength(env, last_hops);
23741         if (last_hops_constr.datalen > 0)
23742                 last_hops_constr.data = MALLOC(last_hops_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
23743         else
23744                 last_hops_constr.data = NULL;
23745         int64_t* last_hops_vals = (*env)->GetLongArrayElements (env, last_hops, NULL);
23746         for (size_t l = 0; l < last_hops_constr.datalen; l++) {
23747                 int64_t last_hops_conv_11 = last_hops_vals[l];
23748                 LDKRouteHint last_hops_conv_11_conv;
23749                 last_hops_conv_11_conv.inner = (void*)(last_hops_conv_11 & (~1));
23750                 last_hops_conv_11_conv.is_owned = (last_hops_conv_11 & 1) || (last_hops_conv_11 == 0);
23751                 last_hops_conv_11_conv = RouteHint_clone(&last_hops_conv_11_conv);
23752                 last_hops_constr.data[l] = last_hops_conv_11_conv;
23753         }
23754         (*env)->ReleaseLongArrayElements(env, last_hops, last_hops_vals, 0);
23755         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
23756         if (logger_conv.free == LDKLogger_JCalls_free) {
23757                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23758                 LDKLogger_JCalls_clone(logger_conv.this_arg);
23759         }
23760         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
23761         *ret_conv = get_route(our_node_id_ref, &network_conv, payee_ref, payee_features_conv, &first_hops_constr, last_hops_constr, final_value_msat, final_cltv, logger_conv);
23762         FREE(first_hops_constr.data);
23763         return (uint64_t)ret_conv;
23764 }
23765
23766 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23767         LDKNetworkGraph this_obj_conv;
23768         this_obj_conv.inner = (void*)(this_obj & (~1));
23769         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23770         NetworkGraph_free(this_obj_conv);
23771 }
23772
23773 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23774         LDKNetworkGraph orig_conv;
23775         orig_conv.inner = (void*)(orig & (~1));
23776         orig_conv.is_owned = false;
23777         LDKNetworkGraph ret_var = NetworkGraph_clone(&orig_conv);
23778         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23779         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23780         uint64_t ret_ref = (uint64_t)ret_var.inner;
23781         if (ret_var.is_owned) {
23782                 ret_ref |= 1;
23783         }
23784         return ret_ref;
23785 }
23786
23787 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LockedNetworkGraph_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23788         LDKLockedNetworkGraph this_obj_conv;
23789         this_obj_conv.inner = (void*)(this_obj & (~1));
23790         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23791         LockedNetworkGraph_free(this_obj_conv);
23792 }
23793
23794 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23795         LDKNetGraphMsgHandler this_obj_conv;
23796         this_obj_conv.inner = (void*)(this_obj & (~1));
23797         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23798         NetGraphMsgHandler_free(this_obj_conv);
23799 }
23800
23801 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1new(JNIEnv *env, jclass clz, int8_tArray genesis_hash, int64_t chain_access, int64_t logger) {
23802         LDKThirtyTwoBytes genesis_hash_ref;
23803         CHECK((*env)->GetArrayLength(env, genesis_hash) == 32);
23804         (*env)->GetByteArrayRegion(env, genesis_hash, 0, 32, genesis_hash_ref.data);
23805         LDKAccess *chain_access_conv_ptr = NULL;
23806         if (chain_access != 0) {
23807                 LDKAccess chain_access_conv;
23808                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
23809                 if (chain_access_conv.free == LDKAccess_JCalls_free) {
23810                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23811                         LDKAccess_JCalls_clone(chain_access_conv.this_arg);
23812                 }
23813                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
23814                 *chain_access_conv_ptr = chain_access_conv;
23815         }
23816         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
23817         if (logger_conv.free == LDKLogger_JCalls_free) {
23818                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23819                 LDKLogger_JCalls_clone(logger_conv.this_arg);
23820         }
23821         LDKNetGraphMsgHandler ret_var = NetGraphMsgHandler_new(genesis_hash_ref, chain_access_conv_ptr, logger_conv);
23822         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23823         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23824         uint64_t ret_ref = (uint64_t)ret_var.inner;
23825         if (ret_var.is_owned) {
23826                 ret_ref |= 1;
23827         }
23828         return ret_ref;
23829 }
23830
23831 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1from_1net_1graph(JNIEnv *env, jclass clz, int64_t chain_access, int64_t logger, int64_t network_graph) {
23832         LDKAccess *chain_access_conv_ptr = NULL;
23833         if (chain_access != 0) {
23834                 LDKAccess chain_access_conv;
23835                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
23836                 if (chain_access_conv.free == LDKAccess_JCalls_free) {
23837                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23838                         LDKAccess_JCalls_clone(chain_access_conv.this_arg);
23839                 }
23840                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
23841                 *chain_access_conv_ptr = chain_access_conv;
23842         }
23843         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
23844         if (logger_conv.free == LDKLogger_JCalls_free) {
23845                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23846                 LDKLogger_JCalls_clone(logger_conv.this_arg);
23847         }
23848         LDKNetworkGraph network_graph_conv;
23849         network_graph_conv.inner = (void*)(network_graph & (~1));
23850         network_graph_conv.is_owned = (network_graph & 1) || (network_graph == 0);
23851         network_graph_conv = NetworkGraph_clone(&network_graph_conv);
23852         LDKNetGraphMsgHandler ret_var = NetGraphMsgHandler_from_net_graph(chain_access_conv_ptr, logger_conv, network_graph_conv);
23853         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23854         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23855         uint64_t ret_ref = (uint64_t)ret_var.inner;
23856         if (ret_var.is_owned) {
23857                 ret_ref |= 1;
23858         }
23859         return ret_ref;
23860 }
23861
23862 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1add_1chain_1access(JNIEnv *env, jclass clz, int64_t this_arg, int64_t chain_access) {
23863         LDKNetGraphMsgHandler this_arg_conv;
23864         this_arg_conv.inner = (void*)(this_arg & (~1));
23865         this_arg_conv.is_owned = false;
23866         LDKAccess *chain_access_conv_ptr = NULL;
23867         if (chain_access != 0) {
23868                 LDKAccess chain_access_conv;
23869                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
23870                 if (chain_access_conv.free == LDKAccess_JCalls_free) {
23871                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23872                         LDKAccess_JCalls_clone(chain_access_conv.this_arg);
23873                 }
23874                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
23875                 *chain_access_conv_ptr = chain_access_conv;
23876         }
23877         NetGraphMsgHandler_add_chain_access(&this_arg_conv, chain_access_conv_ptr);
23878 }
23879
23880 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1read_1locked_1graph(JNIEnv *env, jclass clz, int64_t this_arg) {
23881         LDKNetGraphMsgHandler this_arg_conv;
23882         this_arg_conv.inner = (void*)(this_arg & (~1));
23883         this_arg_conv.is_owned = false;
23884         LDKLockedNetworkGraph ret_var = NetGraphMsgHandler_read_locked_graph(&this_arg_conv);
23885         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23886         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23887         uint64_t ret_ref = (uint64_t)ret_var.inner;
23888         if (ret_var.is_owned) {
23889                 ret_ref |= 1;
23890         }
23891         return ret_ref;
23892 }
23893
23894 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LockedNetworkGraph_1graph(JNIEnv *env, jclass clz, int64_t this_arg) {
23895         LDKLockedNetworkGraph this_arg_conv;
23896         this_arg_conv.inner = (void*)(this_arg & (~1));
23897         this_arg_conv.is_owned = false;
23898         LDKNetworkGraph ret_var = LockedNetworkGraph_graph(&this_arg_conv);
23899         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23900         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23901         uint64_t ret_ref = (uint64_t)ret_var.inner;
23902         if (ret_var.is_owned) {
23903                 ret_ref |= 1;
23904         }
23905         return ret_ref;
23906 }
23907
23908 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1as_1RoutingMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
23909         LDKNetGraphMsgHandler this_arg_conv;
23910         this_arg_conv.inner = (void*)(this_arg & (~1));
23911         this_arg_conv.is_owned = false;
23912         LDKRoutingMessageHandler* ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
23913         *ret = NetGraphMsgHandler_as_RoutingMessageHandler(&this_arg_conv);
23914         return (uint64_t)ret;
23915 }
23916
23917 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
23918         LDKNetGraphMsgHandler this_arg_conv;
23919         this_arg_conv.inner = (void*)(this_arg & (~1));
23920         this_arg_conv.is_owned = false;
23921         LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
23922         *ret = NetGraphMsgHandler_as_MessageSendEventsProvider(&this_arg_conv);
23923         return (uint64_t)ret;
23924 }
23925
23926 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23927         LDKDirectionalChannelInfo this_obj_conv;
23928         this_obj_conv.inner = (void*)(this_obj & (~1));
23929         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23930         DirectionalChannelInfo_free(this_obj_conv);
23931 }
23932
23933 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr) {
23934         LDKDirectionalChannelInfo this_ptr_conv;
23935         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23936         this_ptr_conv.is_owned = false;
23937         int32_t ret_val = DirectionalChannelInfo_get_last_update(&this_ptr_conv);
23938         return ret_val;
23939 }
23940
23941 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
23942         LDKDirectionalChannelInfo this_ptr_conv;
23943         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23944         this_ptr_conv.is_owned = false;
23945         DirectionalChannelInfo_set_last_update(&this_ptr_conv, val);
23946 }
23947
23948 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1enabled(JNIEnv *env, jclass clz, int64_t this_ptr) {
23949         LDKDirectionalChannelInfo this_ptr_conv;
23950         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23951         this_ptr_conv.is_owned = false;
23952         jboolean ret_val = DirectionalChannelInfo_get_enabled(&this_ptr_conv);
23953         return ret_val;
23954 }
23955
23956 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1enabled(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
23957         LDKDirectionalChannelInfo this_ptr_conv;
23958         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23959         this_ptr_conv.is_owned = false;
23960         DirectionalChannelInfo_set_enabled(&this_ptr_conv, val);
23961 }
23962
23963 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
23964         LDKDirectionalChannelInfo this_ptr_conv;
23965         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23966         this_ptr_conv.is_owned = false;
23967         int16_t ret_val = DirectionalChannelInfo_get_cltv_expiry_delta(&this_ptr_conv);
23968         return ret_val;
23969 }
23970
23971 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
23972         LDKDirectionalChannelInfo this_ptr_conv;
23973         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23974         this_ptr_conv.is_owned = false;
23975         DirectionalChannelInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
23976 }
23977
23978 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
23979         LDKDirectionalChannelInfo this_ptr_conv;
23980         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23981         this_ptr_conv.is_owned = false;
23982         int64_t ret_val = DirectionalChannelInfo_get_htlc_minimum_msat(&this_ptr_conv);
23983         return ret_val;
23984 }
23985
23986 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23987         LDKDirectionalChannelInfo this_ptr_conv;
23988         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23989         this_ptr_conv.is_owned = false;
23990         DirectionalChannelInfo_set_htlc_minimum_msat(&this_ptr_conv, val);
23991 }
23992
23993 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
23994         LDKDirectionalChannelInfo this_ptr_conv;
23995         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23996         this_ptr_conv.is_owned = false;
23997         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
23998         *ret_copy = DirectionalChannelInfo_get_htlc_maximum_msat(&this_ptr_conv);
23999         uint64_t ret_ref = (uint64_t)ret_copy;
24000         return ret_ref;
24001 }
24002
24003 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24004         LDKDirectionalChannelInfo this_ptr_conv;
24005         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24006         this_ptr_conv.is_owned = false;
24007         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
24008         DirectionalChannelInfo_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
24009 }
24010
24011 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
24012         LDKDirectionalChannelInfo this_ptr_conv;
24013         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24014         this_ptr_conv.is_owned = false;
24015         LDKRoutingFees ret_var = DirectionalChannelInfo_get_fees(&this_ptr_conv);
24016         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24017         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24018         uint64_t ret_ref = (uint64_t)ret_var.inner;
24019         if (ret_var.is_owned) {
24020                 ret_ref |= 1;
24021         }
24022         return ret_ref;
24023 }
24024
24025 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1fees(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24026         LDKDirectionalChannelInfo this_ptr_conv;
24027         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24028         this_ptr_conv.is_owned = false;
24029         LDKRoutingFees val_conv;
24030         val_conv.inner = (void*)(val & (~1));
24031         val_conv.is_owned = (val & 1) || (val == 0);
24032         val_conv = RoutingFees_clone(&val_conv);
24033         DirectionalChannelInfo_set_fees(&this_ptr_conv, val_conv);
24034 }
24035
24036 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1last_1update_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
24037         LDKDirectionalChannelInfo this_ptr_conv;
24038         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24039         this_ptr_conv.is_owned = false;
24040         LDKChannelUpdate ret_var = DirectionalChannelInfo_get_last_update_message(&this_ptr_conv);
24041         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24042         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24043         uint64_t ret_ref = (uint64_t)ret_var.inner;
24044         if (ret_var.is_owned) {
24045                 ret_ref |= 1;
24046         }
24047         return ret_ref;
24048 }
24049
24050 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1last_1update_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24051         LDKDirectionalChannelInfo this_ptr_conv;
24052         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24053         this_ptr_conv.is_owned = false;
24054         LDKChannelUpdate val_conv;
24055         val_conv.inner = (void*)(val & (~1));
24056         val_conv.is_owned = (val & 1) || (val == 0);
24057         val_conv = ChannelUpdate_clone(&val_conv);
24058         DirectionalChannelInfo_set_last_update_message(&this_ptr_conv, val_conv);
24059 }
24060
24061 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) {
24062         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)htlc_maximum_msat_arg) & ~1);
24063         LDKRoutingFees fees_arg_conv;
24064         fees_arg_conv.inner = (void*)(fees_arg & (~1));
24065         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
24066         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
24067         LDKChannelUpdate last_update_message_arg_conv;
24068         last_update_message_arg_conv.inner = (void*)(last_update_message_arg & (~1));
24069         last_update_message_arg_conv.is_owned = (last_update_message_arg & 1) || (last_update_message_arg == 0);
24070         last_update_message_arg_conv = ChannelUpdate_clone(&last_update_message_arg_conv);
24071         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);
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_DirectionalChannelInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24082         LDKDirectionalChannelInfo orig_conv;
24083         orig_conv.inner = (void*)(orig & (~1));
24084         orig_conv.is_owned = false;
24085         LDKDirectionalChannelInfo ret_var = DirectionalChannelInfo_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 int8_tArray JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
24096         LDKDirectionalChannelInfo obj_conv;
24097         obj_conv.inner = (void*)(obj & (~1));
24098         obj_conv.is_owned = false;
24099         LDKCVec_u8Z ret_var = DirectionalChannelInfo_write(&obj_conv);
24100         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24101         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24102         CVec_u8Z_free(ret_var);
24103         return ret_arr;
24104 }
24105
24106 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24107         LDKu8slice ser_ref;
24108         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24109         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24110         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
24111         *ret_conv = DirectionalChannelInfo_read(ser_ref);
24112         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24113         return (uint64_t)ret_conv;
24114 }
24115
24116 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24117         LDKChannelInfo this_obj_conv;
24118         this_obj_conv.inner = (void*)(this_obj & (~1));
24119         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24120         ChannelInfo_free(this_obj_conv);
24121 }
24122
24123 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
24124         LDKChannelInfo this_ptr_conv;
24125         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24126         this_ptr_conv.is_owned = false;
24127         LDKChannelFeatures ret_var = ChannelInfo_get_features(&this_ptr_conv);
24128         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24129         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24130         uint64_t ret_ref = (uint64_t)ret_var.inner;
24131         if (ret_var.is_owned) {
24132                 ret_ref |= 1;
24133         }
24134         return ret_ref;
24135 }
24136
24137 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24138         LDKChannelInfo this_ptr_conv;
24139         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24140         this_ptr_conv.is_owned = false;
24141         LDKChannelFeatures val_conv;
24142         val_conv.inner = (void*)(val & (~1));
24143         val_conv.is_owned = (val & 1) || (val == 0);
24144         val_conv = ChannelFeatures_clone(&val_conv);
24145         ChannelInfo_set_features(&this_ptr_conv, val_conv);
24146 }
24147
24148 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1node_1one(JNIEnv *env, jclass clz, int64_t this_ptr) {
24149         LDKChannelInfo this_ptr_conv;
24150         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24151         this_ptr_conv.is_owned = false;
24152         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
24153         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelInfo_get_node_one(&this_ptr_conv).compressed_form);
24154         return ret_arr;
24155 }
24156
24157 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1node_1one(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
24158         LDKChannelInfo this_ptr_conv;
24159         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24160         this_ptr_conv.is_owned = false;
24161         LDKPublicKey val_ref;
24162         CHECK((*env)->GetArrayLength(env, val) == 33);
24163         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
24164         ChannelInfo_set_node_one(&this_ptr_conv, val_ref);
24165 }
24166
24167 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1one_1to_1two(JNIEnv *env, jclass clz, int64_t this_ptr) {
24168         LDKChannelInfo this_ptr_conv;
24169         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24170         this_ptr_conv.is_owned = false;
24171         LDKDirectionalChannelInfo ret_var = ChannelInfo_get_one_to_two(&this_ptr_conv);
24172         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24173         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24174         uint64_t ret_ref = (uint64_t)ret_var.inner;
24175         if (ret_var.is_owned) {
24176                 ret_ref |= 1;
24177         }
24178         return ret_ref;
24179 }
24180
24181 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1one_1to_1two(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24182         LDKChannelInfo this_ptr_conv;
24183         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24184         this_ptr_conv.is_owned = false;
24185         LDKDirectionalChannelInfo val_conv;
24186         val_conv.inner = (void*)(val & (~1));
24187         val_conv.is_owned = (val & 1) || (val == 0);
24188         val_conv = DirectionalChannelInfo_clone(&val_conv);
24189         ChannelInfo_set_one_to_two(&this_ptr_conv, val_conv);
24190 }
24191
24192 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1node_1two(JNIEnv *env, jclass clz, int64_t this_ptr) {
24193         LDKChannelInfo this_ptr_conv;
24194         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24195         this_ptr_conv.is_owned = false;
24196         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
24197         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelInfo_get_node_two(&this_ptr_conv).compressed_form);
24198         return ret_arr;
24199 }
24200
24201 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1node_1two(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
24202         LDKChannelInfo this_ptr_conv;
24203         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24204         this_ptr_conv.is_owned = false;
24205         LDKPublicKey val_ref;
24206         CHECK((*env)->GetArrayLength(env, val) == 33);
24207         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
24208         ChannelInfo_set_node_two(&this_ptr_conv, val_ref);
24209 }
24210
24211 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1two_1to_1one(JNIEnv *env, jclass clz, int64_t this_ptr) {
24212         LDKChannelInfo this_ptr_conv;
24213         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24214         this_ptr_conv.is_owned = false;
24215         LDKDirectionalChannelInfo ret_var = ChannelInfo_get_two_to_one(&this_ptr_conv);
24216         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24217         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24218         uint64_t ret_ref = (uint64_t)ret_var.inner;
24219         if (ret_var.is_owned) {
24220                 ret_ref |= 1;
24221         }
24222         return ret_ref;
24223 }
24224
24225 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1two_1to_1one(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24226         LDKChannelInfo this_ptr_conv;
24227         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24228         this_ptr_conv.is_owned = false;
24229         LDKDirectionalChannelInfo val_conv;
24230         val_conv.inner = (void*)(val & (~1));
24231         val_conv.is_owned = (val & 1) || (val == 0);
24232         val_conv = DirectionalChannelInfo_clone(&val_conv);
24233         ChannelInfo_set_two_to_one(&this_ptr_conv, val_conv);
24234 }
24235
24236 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1capacity_1sats(JNIEnv *env, jclass clz, int64_t this_ptr) {
24237         LDKChannelInfo this_ptr_conv;
24238         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24239         this_ptr_conv.is_owned = false;
24240         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
24241         *ret_copy = ChannelInfo_get_capacity_sats(&this_ptr_conv);
24242         uint64_t ret_ref = (uint64_t)ret_copy;
24243         return ret_ref;
24244 }
24245
24246 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1capacity_1sats(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24247         LDKChannelInfo this_ptr_conv;
24248         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24249         this_ptr_conv.is_owned = false;
24250         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
24251         ChannelInfo_set_capacity_sats(&this_ptr_conv, val_conv);
24252 }
24253
24254 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
24255         LDKChannelInfo this_ptr_conv;
24256         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24257         this_ptr_conv.is_owned = false;
24258         LDKChannelAnnouncement ret_var = ChannelInfo_get_announcement_message(&this_ptr_conv);
24259         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24260         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24261         uint64_t ret_ref = (uint64_t)ret_var.inner;
24262         if (ret_var.is_owned) {
24263                 ret_ref |= 1;
24264         }
24265         return ret_ref;
24266 }
24267
24268 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24269         LDKChannelInfo this_ptr_conv;
24270         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24271         this_ptr_conv.is_owned = false;
24272         LDKChannelAnnouncement val_conv;
24273         val_conv.inner = (void*)(val & (~1));
24274         val_conv.is_owned = (val & 1) || (val == 0);
24275         val_conv = ChannelAnnouncement_clone(&val_conv);
24276         ChannelInfo_set_announcement_message(&this_ptr_conv, val_conv);
24277 }
24278
24279 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1new(JNIEnv *env, jclass clz, int64_t features_arg, int8_tArray node_one_arg, int64_t one_to_two_arg, int8_tArray node_two_arg, int64_t two_to_one_arg, int64_t capacity_sats_arg, int64_t announcement_message_arg) {
24280         LDKChannelFeatures features_arg_conv;
24281         features_arg_conv.inner = (void*)(features_arg & (~1));
24282         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
24283         features_arg_conv = ChannelFeatures_clone(&features_arg_conv);
24284         LDKPublicKey node_one_arg_ref;
24285         CHECK((*env)->GetArrayLength(env, node_one_arg) == 33);
24286         (*env)->GetByteArrayRegion(env, node_one_arg, 0, 33, node_one_arg_ref.compressed_form);
24287         LDKDirectionalChannelInfo one_to_two_arg_conv;
24288         one_to_two_arg_conv.inner = (void*)(one_to_two_arg & (~1));
24289         one_to_two_arg_conv.is_owned = (one_to_two_arg & 1) || (one_to_two_arg == 0);
24290         one_to_two_arg_conv = DirectionalChannelInfo_clone(&one_to_two_arg_conv);
24291         LDKPublicKey node_two_arg_ref;
24292         CHECK((*env)->GetArrayLength(env, node_two_arg) == 33);
24293         (*env)->GetByteArrayRegion(env, node_two_arg, 0, 33, node_two_arg_ref.compressed_form);
24294         LDKDirectionalChannelInfo two_to_one_arg_conv;
24295         two_to_one_arg_conv.inner = (void*)(two_to_one_arg & (~1));
24296         two_to_one_arg_conv.is_owned = (two_to_one_arg & 1) || (two_to_one_arg == 0);
24297         two_to_one_arg_conv = DirectionalChannelInfo_clone(&two_to_one_arg_conv);
24298         LDKCOption_u64Z capacity_sats_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)capacity_sats_arg) & ~1);
24299         LDKChannelAnnouncement announcement_message_arg_conv;
24300         announcement_message_arg_conv.inner = (void*)(announcement_message_arg & (~1));
24301         announcement_message_arg_conv.is_owned = (announcement_message_arg & 1) || (announcement_message_arg == 0);
24302         announcement_message_arg_conv = ChannelAnnouncement_clone(&announcement_message_arg_conv);
24303         LDKChannelInfo ret_var = ChannelInfo_new(features_arg_conv, node_one_arg_ref, one_to_two_arg_conv, node_two_arg_ref, two_to_one_arg_conv, capacity_sats_arg_conv, announcement_message_arg_conv);
24304         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24305         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24306         uint64_t ret_ref = (uint64_t)ret_var.inner;
24307         if (ret_var.is_owned) {
24308                 ret_ref |= 1;
24309         }
24310         return ret_ref;
24311 }
24312
24313 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24314         LDKChannelInfo orig_conv;
24315         orig_conv.inner = (void*)(orig & (~1));
24316         orig_conv.is_owned = false;
24317         LDKChannelInfo ret_var = ChannelInfo_clone(&orig_conv);
24318         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24319         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24320         uint64_t ret_ref = (uint64_t)ret_var.inner;
24321         if (ret_var.is_owned) {
24322                 ret_ref |= 1;
24323         }
24324         return ret_ref;
24325 }
24326
24327 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
24328         LDKChannelInfo obj_conv;
24329         obj_conv.inner = (void*)(obj & (~1));
24330         obj_conv.is_owned = false;
24331         LDKCVec_u8Z ret_var = ChannelInfo_write(&obj_conv);
24332         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24333         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24334         CVec_u8Z_free(ret_var);
24335         return ret_arr;
24336 }
24337
24338 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24339         LDKu8slice ser_ref;
24340         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24341         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24342         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
24343         *ret_conv = ChannelInfo_read(ser_ref);
24344         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24345         return (uint64_t)ret_conv;
24346 }
24347
24348 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24349         LDKRoutingFees this_obj_conv;
24350         this_obj_conv.inner = (void*)(this_obj & (~1));
24351         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24352         RoutingFees_free(this_obj_conv);
24353 }
24354
24355 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1get_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
24356         LDKRoutingFees this_ptr_conv;
24357         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24358         this_ptr_conv.is_owned = false;
24359         int32_t ret_val = RoutingFees_get_base_msat(&this_ptr_conv);
24360         return ret_val;
24361 }
24362
24363 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1set_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
24364         LDKRoutingFees this_ptr_conv;
24365         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24366         this_ptr_conv.is_owned = false;
24367         RoutingFees_set_base_msat(&this_ptr_conv, val);
24368 }
24369
24370 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1get_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
24371         LDKRoutingFees this_ptr_conv;
24372         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24373         this_ptr_conv.is_owned = false;
24374         int32_t ret_val = RoutingFees_get_proportional_millionths(&this_ptr_conv);
24375         return ret_val;
24376 }
24377
24378 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1set_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
24379         LDKRoutingFees this_ptr_conv;
24380         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24381         this_ptr_conv.is_owned = false;
24382         RoutingFees_set_proportional_millionths(&this_ptr_conv, val);
24383 }
24384
24385 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) {
24386         LDKRoutingFees ret_var = RoutingFees_new(base_msat_arg, proportional_millionths_arg);
24387         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24388         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24389         uint64_t ret_ref = (uint64_t)ret_var.inner;
24390         if (ret_var.is_owned) {
24391                 ret_ref |= 1;
24392         }
24393         return ret_ref;
24394 }
24395
24396 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RoutingFees_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
24397         LDKRoutingFees a_conv;
24398         a_conv.inner = (void*)(a & (~1));
24399         a_conv.is_owned = false;
24400         LDKRoutingFees b_conv;
24401         b_conv.inner = (void*)(b & (~1));
24402         b_conv.is_owned = false;
24403         jboolean ret_val = RoutingFees_eq(&a_conv, &b_conv);
24404         return ret_val;
24405 }
24406
24407 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24408         LDKRoutingFees orig_conv;
24409         orig_conv.inner = (void*)(orig & (~1));
24410         orig_conv.is_owned = false;
24411         LDKRoutingFees ret_var = RoutingFees_clone(&orig_conv);
24412         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24413         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24414         uint64_t ret_ref = (uint64_t)ret_var.inner;
24415         if (ret_var.is_owned) {
24416                 ret_ref |= 1;
24417         }
24418         return ret_ref;
24419 }
24420
24421 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RoutingFees_1write(JNIEnv *env, jclass clz, int64_t obj) {
24422         LDKRoutingFees obj_conv;
24423         obj_conv.inner = (void*)(obj & (~1));
24424         obj_conv.is_owned = false;
24425         LDKCVec_u8Z ret_var = RoutingFees_write(&obj_conv);
24426         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24427         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24428         CVec_u8Z_free(ret_var);
24429         return ret_arr;
24430 }
24431
24432 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24433         LDKu8slice ser_ref;
24434         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24435         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24436         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
24437         *ret_conv = RoutingFees_read(ser_ref);
24438         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24439         return (uint64_t)ret_conv;
24440 }
24441
24442 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24443         LDKNodeAnnouncementInfo this_obj_conv;
24444         this_obj_conv.inner = (void*)(this_obj & (~1));
24445         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24446         NodeAnnouncementInfo_free(this_obj_conv);
24447 }
24448
24449 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
24450         LDKNodeAnnouncementInfo this_ptr_conv;
24451         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24452         this_ptr_conv.is_owned = false;
24453         LDKNodeFeatures ret_var = NodeAnnouncementInfo_get_features(&this_ptr_conv);
24454         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24455         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24456         uint64_t ret_ref = (uint64_t)ret_var.inner;
24457         if (ret_var.is_owned) {
24458                 ret_ref |= 1;
24459         }
24460         return ret_ref;
24461 }
24462
24463 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24464         LDKNodeAnnouncementInfo this_ptr_conv;
24465         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24466         this_ptr_conv.is_owned = false;
24467         LDKNodeFeatures val_conv;
24468         val_conv.inner = (void*)(val & (~1));
24469         val_conv.is_owned = (val & 1) || (val == 0);
24470         val_conv = NodeFeatures_clone(&val_conv);
24471         NodeAnnouncementInfo_set_features(&this_ptr_conv, val_conv);
24472 }
24473
24474 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr) {
24475         LDKNodeAnnouncementInfo this_ptr_conv;
24476         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24477         this_ptr_conv.is_owned = false;
24478         int32_t ret_val = NodeAnnouncementInfo_get_last_update(&this_ptr_conv);
24479         return ret_val;
24480 }
24481
24482 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
24483         LDKNodeAnnouncementInfo this_ptr_conv;
24484         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24485         this_ptr_conv.is_owned = false;
24486         NodeAnnouncementInfo_set_last_update(&this_ptr_conv, val);
24487 }
24488
24489 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr) {
24490         LDKNodeAnnouncementInfo this_ptr_conv;
24491         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24492         this_ptr_conv.is_owned = false;
24493         int8_tArray ret_arr = (*env)->NewByteArray(env, 3);
24494         (*env)->SetByteArrayRegion(env, ret_arr, 0, 3, *NodeAnnouncementInfo_get_rgb(&this_ptr_conv));
24495         return ret_arr;
24496 }
24497
24498 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
24499         LDKNodeAnnouncementInfo this_ptr_conv;
24500         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24501         this_ptr_conv.is_owned = false;
24502         LDKThreeBytes val_ref;
24503         CHECK((*env)->GetArrayLength(env, val) == 3);
24504         (*env)->GetByteArrayRegion(env, val, 0, 3, val_ref.data);
24505         NodeAnnouncementInfo_set_rgb(&this_ptr_conv, val_ref);
24506 }
24507
24508 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
24509         LDKNodeAnnouncementInfo this_ptr_conv;
24510         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24511         this_ptr_conv.is_owned = false;
24512         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
24513         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *NodeAnnouncementInfo_get_alias(&this_ptr_conv));
24514         return ret_arr;
24515 }
24516
24517 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
24518         LDKNodeAnnouncementInfo this_ptr_conv;
24519         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24520         this_ptr_conv.is_owned = false;
24521         LDKThirtyTwoBytes val_ref;
24522         CHECK((*env)->GetArrayLength(env, val) == 32);
24523         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
24524         NodeAnnouncementInfo_set_alias(&this_ptr_conv, val_ref);
24525 }
24526
24527 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1addresses(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
24528         LDKNodeAnnouncementInfo this_ptr_conv;
24529         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24530         this_ptr_conv.is_owned = false;
24531         LDKCVec_NetAddressZ val_constr;
24532         val_constr.datalen = (*env)->GetArrayLength(env, val);
24533         if (val_constr.datalen > 0)
24534                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
24535         else
24536                 val_constr.data = NULL;
24537         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
24538         for (size_t m = 0; m < val_constr.datalen; m++) {
24539                 int64_t val_conv_12 = val_vals[m];
24540                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(((uint64_t)val_conv_12) & ~1);
24541                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)val_conv_12) & ~1));
24542                 val_constr.data[m] = val_conv_12_conv;
24543         }
24544         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
24545         NodeAnnouncementInfo_set_addresses(&this_ptr_conv, val_constr);
24546 }
24547
24548 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
24549         LDKNodeAnnouncementInfo this_ptr_conv;
24550         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24551         this_ptr_conv.is_owned = false;
24552         LDKNodeAnnouncement ret_var = NodeAnnouncementInfo_get_announcement_message(&this_ptr_conv);
24553         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24554         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24555         uint64_t ret_ref = (uint64_t)ret_var.inner;
24556         if (ret_var.is_owned) {
24557                 ret_ref |= 1;
24558         }
24559         return ret_ref;
24560 }
24561
24562 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24563         LDKNodeAnnouncementInfo this_ptr_conv;
24564         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24565         this_ptr_conv.is_owned = false;
24566         LDKNodeAnnouncement val_conv;
24567         val_conv.inner = (void*)(val & (~1));
24568         val_conv.is_owned = (val & 1) || (val == 0);
24569         val_conv = NodeAnnouncement_clone(&val_conv);
24570         NodeAnnouncementInfo_set_announcement_message(&this_ptr_conv, val_conv);
24571 }
24572
24573 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) {
24574         LDKNodeFeatures features_arg_conv;
24575         features_arg_conv.inner = (void*)(features_arg & (~1));
24576         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
24577         features_arg_conv = NodeFeatures_clone(&features_arg_conv);
24578         LDKThreeBytes rgb_arg_ref;
24579         CHECK((*env)->GetArrayLength(env, rgb_arg) == 3);
24580         (*env)->GetByteArrayRegion(env, rgb_arg, 0, 3, rgb_arg_ref.data);
24581         LDKThirtyTwoBytes alias_arg_ref;
24582         CHECK((*env)->GetArrayLength(env, alias_arg) == 32);
24583         (*env)->GetByteArrayRegion(env, alias_arg, 0, 32, alias_arg_ref.data);
24584         LDKCVec_NetAddressZ addresses_arg_constr;
24585         addresses_arg_constr.datalen = (*env)->GetArrayLength(env, addresses_arg);
24586         if (addresses_arg_constr.datalen > 0)
24587                 addresses_arg_constr.data = MALLOC(addresses_arg_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
24588         else
24589                 addresses_arg_constr.data = NULL;
24590         int64_t* addresses_arg_vals = (*env)->GetLongArrayElements (env, addresses_arg, NULL);
24591         for (size_t m = 0; m < addresses_arg_constr.datalen; m++) {
24592                 int64_t addresses_arg_conv_12 = addresses_arg_vals[m];
24593                 LDKNetAddress addresses_arg_conv_12_conv = *(LDKNetAddress*)(((uint64_t)addresses_arg_conv_12) & ~1);
24594                 addresses_arg_constr.data[m] = addresses_arg_conv_12_conv;
24595         }
24596         (*env)->ReleaseLongArrayElements(env, addresses_arg, addresses_arg_vals, 0);
24597         LDKNodeAnnouncement announcement_message_arg_conv;
24598         announcement_message_arg_conv.inner = (void*)(announcement_message_arg & (~1));
24599         announcement_message_arg_conv.is_owned = (announcement_message_arg & 1) || (announcement_message_arg == 0);
24600         announcement_message_arg_conv = NodeAnnouncement_clone(&announcement_message_arg_conv);
24601         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_new(features_arg_conv, last_update_arg, rgb_arg_ref, alias_arg_ref, addresses_arg_constr, announcement_message_arg_conv);
24602         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24603         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24604         uint64_t ret_ref = (uint64_t)ret_var.inner;
24605         if (ret_var.is_owned) {
24606                 ret_ref |= 1;
24607         }
24608         return ret_ref;
24609 }
24610
24611 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24612         LDKNodeAnnouncementInfo orig_conv;
24613         orig_conv.inner = (void*)(orig & (~1));
24614         orig_conv.is_owned = false;
24615         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(&orig_conv);
24616         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24617         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24618         uint64_t ret_ref = (uint64_t)ret_var.inner;
24619         if (ret_var.is_owned) {
24620                 ret_ref |= 1;
24621         }
24622         return ret_ref;
24623 }
24624
24625 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
24626         LDKNodeAnnouncementInfo obj_conv;
24627         obj_conv.inner = (void*)(obj & (~1));
24628         obj_conv.is_owned = false;
24629         LDKCVec_u8Z ret_var = NodeAnnouncementInfo_write(&obj_conv);
24630         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24631         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24632         CVec_u8Z_free(ret_var);
24633         return ret_arr;
24634 }
24635
24636 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24637         LDKu8slice ser_ref;
24638         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24639         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24640         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
24641         *ret_conv = NodeAnnouncementInfo_read(ser_ref);
24642         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24643         return (uint64_t)ret_conv;
24644 }
24645
24646 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24647         LDKNodeInfo this_obj_conv;
24648         this_obj_conv.inner = (void*)(this_obj & (~1));
24649         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24650         NodeInfo_free(this_obj_conv);
24651 }
24652
24653 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
24654         LDKNodeInfo this_ptr_conv;
24655         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24656         this_ptr_conv.is_owned = false;
24657         LDKCVec_u64Z val_constr;
24658         val_constr.datalen = (*env)->GetArrayLength(env, val);
24659         if (val_constr.datalen > 0)
24660                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
24661         else
24662                 val_constr.data = NULL;
24663         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
24664         for (size_t g = 0; g < val_constr.datalen; g++) {
24665                 int64_t val_conv_6 = val_vals[g];
24666                 val_constr.data[g] = val_conv_6;
24667         }
24668         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
24669         NodeInfo_set_channels(&this_ptr_conv, val_constr);
24670 }
24671
24672 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1lowest_1inbound_1channel_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
24673         LDKNodeInfo this_ptr_conv;
24674         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24675         this_ptr_conv.is_owned = false;
24676         LDKRoutingFees ret_var = NodeInfo_get_lowest_inbound_channel_fees(&this_ptr_conv);
24677         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24678         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24679         uint64_t ret_ref = (uint64_t)ret_var.inner;
24680         if (ret_var.is_owned) {
24681                 ret_ref |= 1;
24682         }
24683         return ret_ref;
24684 }
24685
24686 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) {
24687         LDKNodeInfo this_ptr_conv;
24688         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24689         this_ptr_conv.is_owned = false;
24690         LDKRoutingFees val_conv;
24691         val_conv.inner = (void*)(val & (~1));
24692         val_conv.is_owned = (val & 1) || (val == 0);
24693         val_conv = RoutingFees_clone(&val_conv);
24694         NodeInfo_set_lowest_inbound_channel_fees(&this_ptr_conv, val_conv);
24695 }
24696
24697 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1announcement_1info(JNIEnv *env, jclass clz, int64_t this_ptr) {
24698         LDKNodeInfo this_ptr_conv;
24699         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24700         this_ptr_conv.is_owned = false;
24701         LDKNodeAnnouncementInfo ret_var = NodeInfo_get_announcement_info(&this_ptr_conv);
24702         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24703         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24704         uint64_t ret_ref = (uint64_t)ret_var.inner;
24705         if (ret_var.is_owned) {
24706                 ret_ref |= 1;
24707         }
24708         return ret_ref;
24709 }
24710
24711 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1announcement_1info(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24712         LDKNodeInfo this_ptr_conv;
24713         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24714         this_ptr_conv.is_owned = false;
24715         LDKNodeAnnouncementInfo val_conv;
24716         val_conv.inner = (void*)(val & (~1));
24717         val_conv.is_owned = (val & 1) || (val == 0);
24718         val_conv = NodeAnnouncementInfo_clone(&val_conv);
24719         NodeInfo_set_announcement_info(&this_ptr_conv, val_conv);
24720 }
24721
24722 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) {
24723         LDKCVec_u64Z channels_arg_constr;
24724         channels_arg_constr.datalen = (*env)->GetArrayLength(env, channels_arg);
24725         if (channels_arg_constr.datalen > 0)
24726                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
24727         else
24728                 channels_arg_constr.data = NULL;
24729         int64_t* channels_arg_vals = (*env)->GetLongArrayElements (env, channels_arg, NULL);
24730         for (size_t g = 0; g < channels_arg_constr.datalen; g++) {
24731                 int64_t channels_arg_conv_6 = channels_arg_vals[g];
24732                 channels_arg_constr.data[g] = channels_arg_conv_6;
24733         }
24734         (*env)->ReleaseLongArrayElements(env, channels_arg, channels_arg_vals, 0);
24735         LDKRoutingFees lowest_inbound_channel_fees_arg_conv;
24736         lowest_inbound_channel_fees_arg_conv.inner = (void*)(lowest_inbound_channel_fees_arg & (~1));
24737         lowest_inbound_channel_fees_arg_conv.is_owned = (lowest_inbound_channel_fees_arg & 1) || (lowest_inbound_channel_fees_arg == 0);
24738         lowest_inbound_channel_fees_arg_conv = RoutingFees_clone(&lowest_inbound_channel_fees_arg_conv);
24739         LDKNodeAnnouncementInfo announcement_info_arg_conv;
24740         announcement_info_arg_conv.inner = (void*)(announcement_info_arg & (~1));
24741         announcement_info_arg_conv.is_owned = (announcement_info_arg & 1) || (announcement_info_arg == 0);
24742         announcement_info_arg_conv = NodeAnnouncementInfo_clone(&announcement_info_arg_conv);
24743         LDKNodeInfo ret_var = NodeInfo_new(channels_arg_constr, lowest_inbound_channel_fees_arg_conv, announcement_info_arg_conv);
24744         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24745         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24746         uint64_t ret_ref = (uint64_t)ret_var.inner;
24747         if (ret_var.is_owned) {
24748                 ret_ref |= 1;
24749         }
24750         return ret_ref;
24751 }
24752
24753 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24754         LDKNodeInfo orig_conv;
24755         orig_conv.inner = (void*)(orig & (~1));
24756         orig_conv.is_owned = false;
24757         LDKNodeInfo ret_var = NodeInfo_clone(&orig_conv);
24758         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24759         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24760         uint64_t ret_ref = (uint64_t)ret_var.inner;
24761         if (ret_var.is_owned) {
24762                 ret_ref |= 1;
24763         }
24764         return ret_ref;
24765 }
24766
24767 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
24768         LDKNodeInfo obj_conv;
24769         obj_conv.inner = (void*)(obj & (~1));
24770         obj_conv.is_owned = false;
24771         LDKCVec_u8Z ret_var = NodeInfo_write(&obj_conv);
24772         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24773         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24774         CVec_u8Z_free(ret_var);
24775         return ret_arr;
24776 }
24777
24778 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24779         LDKu8slice ser_ref;
24780         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24781         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24782         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
24783         *ret_conv = NodeInfo_read(ser_ref);
24784         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24785         return (uint64_t)ret_conv;
24786 }
24787
24788 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1write(JNIEnv *env, jclass clz, int64_t obj) {
24789         LDKNetworkGraph obj_conv;
24790         obj_conv.inner = (void*)(obj & (~1));
24791         obj_conv.is_owned = false;
24792         LDKCVec_u8Z ret_var = NetworkGraph_write(&obj_conv);
24793         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24794         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24795         CVec_u8Z_free(ret_var);
24796         return ret_arr;
24797 }
24798
24799 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24800         LDKu8slice ser_ref;
24801         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24802         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24803         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
24804         *ret_conv = NetworkGraph_read(ser_ref);
24805         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24806         return (uint64_t)ret_conv;
24807 }
24808
24809 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1new(JNIEnv *env, jclass clz, int8_tArray genesis_hash) {
24810         LDKThirtyTwoBytes genesis_hash_ref;
24811         CHECK((*env)->GetArrayLength(env, genesis_hash) == 32);
24812         (*env)->GetByteArrayRegion(env, genesis_hash, 0, 32, genesis_hash_ref.data);
24813         LDKNetworkGraph ret_var = NetworkGraph_new(genesis_hash_ref);
24814         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24815         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24816         uint64_t ret_ref = (uint64_t)ret_var.inner;
24817         if (ret_var.is_owned) {
24818                 ret_ref |= 1;
24819         }
24820         return ret_ref;
24821 }
24822
24823 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) {
24824         LDKNetworkGraph this_arg_conv;
24825         this_arg_conv.inner = (void*)(this_arg & (~1));
24826         this_arg_conv.is_owned = false;
24827         LDKNodeAnnouncement msg_conv;
24828         msg_conv.inner = (void*)(msg & (~1));
24829         msg_conv.is_owned = false;
24830         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
24831         *ret_conv = NetworkGraph_update_node_from_announcement(&this_arg_conv, &msg_conv);
24832         return (uint64_t)ret_conv;
24833 }
24834
24835 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) {
24836         LDKNetworkGraph this_arg_conv;
24837         this_arg_conv.inner = (void*)(this_arg & (~1));
24838         this_arg_conv.is_owned = false;
24839         LDKUnsignedNodeAnnouncement msg_conv;
24840         msg_conv.inner = (void*)(msg & (~1));
24841         msg_conv.is_owned = false;
24842         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
24843         *ret_conv = NetworkGraph_update_node_from_unsigned_announcement(&this_arg_conv, &msg_conv);
24844         return (uint64_t)ret_conv;
24845 }
24846
24847 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) {
24848         LDKNetworkGraph this_arg_conv;
24849         this_arg_conv.inner = (void*)(this_arg & (~1));
24850         this_arg_conv.is_owned = false;
24851         LDKChannelAnnouncement msg_conv;
24852         msg_conv.inner = (void*)(msg & (~1));
24853         msg_conv.is_owned = false;
24854         LDKAccess *chain_access_conv_ptr = NULL;
24855         if (chain_access != 0) {
24856                 LDKAccess chain_access_conv;
24857                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
24858                 if (chain_access_conv.free == LDKAccess_JCalls_free) {
24859                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24860                         LDKAccess_JCalls_clone(chain_access_conv.this_arg);
24861                 }
24862                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
24863                 *chain_access_conv_ptr = chain_access_conv;
24864         }
24865         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
24866         *ret_conv = NetworkGraph_update_channel_from_announcement(&this_arg_conv, &msg_conv, chain_access_conv_ptr);
24867         return (uint64_t)ret_conv;
24868 }
24869
24870 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) {
24871         LDKNetworkGraph this_arg_conv;
24872         this_arg_conv.inner = (void*)(this_arg & (~1));
24873         this_arg_conv.is_owned = false;
24874         LDKUnsignedChannelAnnouncement msg_conv;
24875         msg_conv.inner = (void*)(msg & (~1));
24876         msg_conv.is_owned = false;
24877         LDKAccess *chain_access_conv_ptr = NULL;
24878         if (chain_access != 0) {
24879                 LDKAccess chain_access_conv;
24880                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
24881                 if (chain_access_conv.free == LDKAccess_JCalls_free) {
24882                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24883                         LDKAccess_JCalls_clone(chain_access_conv.this_arg);
24884                 }
24885                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
24886                 *chain_access_conv_ptr = chain_access_conv;
24887         }
24888         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
24889         *ret_conv = NetworkGraph_update_channel_from_unsigned_announcement(&this_arg_conv, &msg_conv, chain_access_conv_ptr);
24890         return (uint64_t)ret_conv;
24891 }
24892
24893 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) {
24894         LDKNetworkGraph this_arg_conv;
24895         this_arg_conv.inner = (void*)(this_arg & (~1));
24896         this_arg_conv.is_owned = false;
24897         NetworkGraph_close_channel_from_update(&this_arg_conv, short_channel_id, is_permanent);
24898 }
24899
24900 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1update_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
24901         LDKNetworkGraph this_arg_conv;
24902         this_arg_conv.inner = (void*)(this_arg & (~1));
24903         this_arg_conv.is_owned = false;
24904         LDKChannelUpdate msg_conv;
24905         msg_conv.inner = (void*)(msg & (~1));
24906         msg_conv.is_owned = false;
24907         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
24908         *ret_conv = NetworkGraph_update_channel(&this_arg_conv, &msg_conv);
24909         return (uint64_t)ret_conv;
24910 }
24911
24912 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1update_1channel_1unsigned(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
24913         LDKNetworkGraph this_arg_conv;
24914         this_arg_conv.inner = (void*)(this_arg & (~1));
24915         this_arg_conv.is_owned = false;
24916         LDKUnsignedChannelUpdate msg_conv;
24917         msg_conv.inner = (void*)(msg & (~1));
24918         msg_conv.is_owned = false;
24919         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
24920         *ret_conv = NetworkGraph_update_channel_unsigned(&this_arg_conv, &msg_conv);
24921         return (uint64_t)ret_conv;
24922 }
24923
24924 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24925         LDKFilesystemPersister this_obj_conv;
24926         this_obj_conv.inner = (void*)(this_obj & (~1));
24927         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24928         FilesystemPersister_free(this_obj_conv);
24929 }
24930
24931 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1new(JNIEnv *env, jclass clz, jstring path_to_channel_data) {
24932         LDKStr path_to_channel_data_conv = java_to_owned_str(env, path_to_channel_data);
24933         LDKFilesystemPersister ret_var = FilesystemPersister_new(path_to_channel_data_conv);
24934         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24935         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24936         uint64_t ret_ref = (uint64_t)ret_var.inner;
24937         if (ret_var.is_owned) {
24938                 ret_ref |= 1;
24939         }
24940         return ret_ref;
24941 }
24942
24943 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1get_1data_1dir(JNIEnv *env, jclass clz, int64_t this_arg) {
24944         LDKFilesystemPersister this_arg_conv;
24945         this_arg_conv.inner = (void*)(this_arg & (~1));
24946         this_arg_conv.is_owned = false;
24947         LDKStr ret_str = FilesystemPersister_get_data_dir(&this_arg_conv);
24948         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
24949         return ret_conv;
24950 }
24951
24952 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1persist_1manager(JNIEnv *env, jclass clz, jstring data_dir, int64_t manager) {
24953         LDKStr data_dir_conv = java_to_owned_str(env, data_dir);
24954         LDKChannelManager manager_conv;
24955         manager_conv.inner = (void*)(manager & (~1));
24956         manager_conv.is_owned = false;
24957         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
24958         *ret_conv = FilesystemPersister_persist_manager(data_dir_conv, &manager_conv);
24959         return (uint64_t)ret_conv;
24960 }
24961
24962 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1read_1channelmonitors(JNIEnv *env, jclass clz, int64_t this_arg, int64_t keys_manager) {
24963         LDKFilesystemPersister this_arg_conv;
24964         this_arg_conv.inner = (void*)(this_arg & (~1));
24965         this_arg_conv.is_owned = false;
24966         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
24967         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
24968                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24969                 LDKKeysInterface_JCalls_clone(keys_manager_conv.this_arg);
24970         }
24971         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
24972         *ret_conv = FilesystemPersister_read_channelmonitors(&this_arg_conv, keys_manager_conv);
24973         return (uint64_t)ret_conv;
24974 }
24975
24976 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1as_1Persist(JNIEnv *env, jclass clz, int64_t this_arg) {
24977         LDKFilesystemPersister this_arg_conv;
24978         this_arg_conv.inner = (void*)(this_arg & (~1));
24979         this_arg_conv.is_owned = false;
24980         LDKPersist* ret = MALLOC(sizeof(LDKPersist), "LDKPersist");
24981         *ret = FilesystemPersister_as_Persist(&this_arg_conv);
24982         return (uint64_t)ret;
24983 }
24984
24985 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24986         LDKBackgroundProcessor this_obj_conv;
24987         this_obj_conv.inner = (void*)(this_obj & (~1));
24988         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24989         BackgroundProcessor_free(this_obj_conv);
24990 }
24991
24992 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerPersister_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
24993         if ((this_ptr & 1) != 0) return;
24994         LDKChannelManagerPersister this_ptr_conv = *(LDKChannelManagerPersister*)(((uint64_t)this_ptr) & ~1);
24995         FREE((void*)this_ptr);
24996         ChannelManagerPersister_free(this_ptr_conv);
24997 }
24998
24999 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1start(JNIEnv *env, jclass clz, int64_t persister, int64_t event_handler, int64_t chain_monitor, int64_t channel_manager, int64_t peer_manager, int64_t logger) {
25000         LDKChannelManagerPersister persister_conv = *(LDKChannelManagerPersister*)(((uint64_t)persister) & ~1);
25001         if (persister_conv.free == LDKChannelManagerPersister_JCalls_free) {
25002                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25003                 LDKChannelManagerPersister_JCalls_clone(persister_conv.this_arg);
25004         }
25005         LDKEventHandler event_handler_conv = *(LDKEventHandler*)(((uint64_t)event_handler) & ~1);
25006         if (event_handler_conv.free == LDKEventHandler_JCalls_free) {
25007                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25008                 LDKEventHandler_JCalls_clone(event_handler_conv.this_arg);
25009         }
25010         LDKChainMonitor chain_monitor_conv;
25011         chain_monitor_conv.inner = (void*)(chain_monitor & (~1));
25012         chain_monitor_conv.is_owned = false;
25013         LDKChannelManager channel_manager_conv;
25014         channel_manager_conv.inner = (void*)(channel_manager & (~1));
25015         channel_manager_conv.is_owned = false;
25016         LDKPeerManager peer_manager_conv;
25017         peer_manager_conv.inner = (void*)(peer_manager & (~1));
25018         peer_manager_conv.is_owned = false;
25019         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
25020         if (logger_conv.free == LDKLogger_JCalls_free) {
25021                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25022                 LDKLogger_JCalls_clone(logger_conv.this_arg);
25023         }
25024         LDKBackgroundProcessor ret_var = BackgroundProcessor_start(persister_conv, event_handler_conv, &chain_monitor_conv, &channel_manager_conv, &peer_manager_conv, logger_conv);
25025         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25026         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25027         uint64_t ret_ref = (uint64_t)ret_var.inner;
25028         if (ret_var.is_owned) {
25029                 ret_ref |= 1;
25030         }
25031         return ret_ref;
25032 }
25033
25034 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1stop(JNIEnv *env, jclass clz, int64_t this_arg) {
25035         LDKBackgroundProcessor this_arg_conv;
25036         this_arg_conv.inner = (void*)(this_arg & (~1));
25037         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
25038         // Warning: we need a move here but no clone is available for LDKBackgroundProcessor
25039         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
25040         *ret_conv = BackgroundProcessor_stop(this_arg_conv);
25041         return (uint64_t)ret_conv;
25042 }
25043
25044 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_check_1platform(JNIEnv *env, jclass clz) {
25045         check_platform();
25046 }
25047
25048 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Invoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25049         LDKInvoice this_obj_conv;
25050         this_obj_conv.inner = (void*)(this_obj & (~1));
25051         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25052         Invoice_free(this_obj_conv);
25053 }
25054
25055 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Invoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
25056         LDKInvoice a_conv;
25057         a_conv.inner = (void*)(a & (~1));
25058         a_conv.is_owned = false;
25059         LDKInvoice b_conv;
25060         b_conv.inner = (void*)(b & (~1));
25061         b_conv.is_owned = false;
25062         jboolean ret_val = Invoice_eq(&a_conv, &b_conv);
25063         return ret_val;
25064 }
25065
25066 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25067         LDKInvoice orig_conv;
25068         orig_conv.inner = (void*)(orig & (~1));
25069         orig_conv.is_owned = false;
25070         LDKInvoice ret_var = Invoice_clone(&orig_conv);
25071         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25072         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25073         uint64_t ret_ref = (uint64_t)ret_var.inner;
25074         if (ret_var.is_owned) {
25075                 ret_ref |= 1;
25076         }
25077         return ret_ref;
25078 }
25079
25080 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25081         LDKSignedRawInvoice this_obj_conv;
25082         this_obj_conv.inner = (void*)(this_obj & (~1));
25083         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25084         SignedRawInvoice_free(this_obj_conv);
25085 }
25086
25087 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
25088         LDKSignedRawInvoice a_conv;
25089         a_conv.inner = (void*)(a & (~1));
25090         a_conv.is_owned = false;
25091         LDKSignedRawInvoice b_conv;
25092         b_conv.inner = (void*)(b & (~1));
25093         b_conv.is_owned = false;
25094         jboolean ret_val = SignedRawInvoice_eq(&a_conv, &b_conv);
25095         return ret_val;
25096 }
25097
25098 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25099         LDKSignedRawInvoice orig_conv;
25100         orig_conv.inner = (void*)(orig & (~1));
25101         orig_conv.is_owned = false;
25102         LDKSignedRawInvoice ret_var = SignedRawInvoice_clone(&orig_conv);
25103         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25104         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25105         uint64_t ret_ref = (uint64_t)ret_var.inner;
25106         if (ret_var.is_owned) {
25107                 ret_ref |= 1;
25108         }
25109         return ret_ref;
25110 }
25111
25112 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawInvoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25113         LDKRawInvoice this_obj_conv;
25114         this_obj_conv.inner = (void*)(this_obj & (~1));
25115         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25116         RawInvoice_free(this_obj_conv);
25117 }
25118
25119 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1get_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
25120         LDKRawInvoice this_ptr_conv;
25121         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25122         this_ptr_conv.is_owned = false;
25123         LDKRawDataPart ret_var = RawInvoice_get_data(&this_ptr_conv);
25124         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25125         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25126         uint64_t ret_ref = (uint64_t)ret_var.inner;
25127         if (ret_var.is_owned) {
25128                 ret_ref |= 1;
25129         }
25130         return ret_ref;
25131 }
25132
25133 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawInvoice_1set_1data(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25134         LDKRawInvoice this_ptr_conv;
25135         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25136         this_ptr_conv.is_owned = false;
25137         LDKRawDataPart val_conv;
25138         val_conv.inner = (void*)(val & (~1));
25139         val_conv.is_owned = (val & 1) || (val == 0);
25140         val_conv = RawDataPart_clone(&val_conv);
25141         RawInvoice_set_data(&this_ptr_conv, val_conv);
25142 }
25143
25144 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RawInvoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
25145         LDKRawInvoice a_conv;
25146         a_conv.inner = (void*)(a & (~1));
25147         a_conv.is_owned = false;
25148         LDKRawInvoice b_conv;
25149         b_conv.inner = (void*)(b & (~1));
25150         b_conv.is_owned = false;
25151         jboolean ret_val = RawInvoice_eq(&a_conv, &b_conv);
25152         return ret_val;
25153 }
25154
25155 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25156         LDKRawInvoice orig_conv;
25157         orig_conv.inner = (void*)(orig & (~1));
25158         orig_conv.is_owned = false;
25159         LDKRawInvoice ret_var = RawInvoice_clone(&orig_conv);
25160         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25161         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25162         uint64_t ret_ref = (uint64_t)ret_var.inner;
25163         if (ret_var.is_owned) {
25164                 ret_ref |= 1;
25165         }
25166         return ret_ref;
25167 }
25168
25169 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawDataPart_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25170         LDKRawDataPart this_obj_conv;
25171         this_obj_conv.inner = (void*)(this_obj & (~1));
25172         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25173         RawDataPart_free(this_obj_conv);
25174 }
25175
25176 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
25177         LDKRawDataPart this_ptr_conv;
25178         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25179         this_ptr_conv.is_owned = false;
25180         LDKPositiveTimestamp ret_var = RawDataPart_get_timestamp(&this_ptr_conv);
25181         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25182         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25183         uint64_t ret_ref = (uint64_t)ret_var.inner;
25184         if (ret_var.is_owned) {
25185                 ret_ref |= 1;
25186         }
25187         return ret_ref;
25188 }
25189
25190 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawDataPart_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25191         LDKRawDataPart this_ptr_conv;
25192         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25193         this_ptr_conv.is_owned = false;
25194         LDKPositiveTimestamp val_conv;
25195         val_conv.inner = (void*)(val & (~1));
25196         val_conv.is_owned = (val & 1) || (val == 0);
25197         val_conv = PositiveTimestamp_clone(&val_conv);
25198         RawDataPart_set_timestamp(&this_ptr_conv, val_conv);
25199 }
25200
25201 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RawDataPart_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
25202         LDKRawDataPart a_conv;
25203         a_conv.inner = (void*)(a & (~1));
25204         a_conv.is_owned = false;
25205         LDKRawDataPart b_conv;
25206         b_conv.inner = (void*)(b & (~1));
25207         b_conv.is_owned = false;
25208         jboolean ret_val = RawDataPart_eq(&a_conv, &b_conv);
25209         return ret_val;
25210 }
25211
25212 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25213         LDKRawDataPart orig_conv;
25214         orig_conv.inner = (void*)(orig & (~1));
25215         orig_conv.is_owned = false;
25216         LDKRawDataPart ret_var = RawDataPart_clone(&orig_conv);
25217         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25218         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25219         uint64_t ret_ref = (uint64_t)ret_var.inner;
25220         if (ret_var.is_owned) {
25221                 ret_ref |= 1;
25222         }
25223         return ret_ref;
25224 }
25225
25226 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25227         LDKPositiveTimestamp this_obj_conv;
25228         this_obj_conv.inner = (void*)(this_obj & (~1));
25229         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25230         PositiveTimestamp_free(this_obj_conv);
25231 }
25232
25233 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
25234         LDKPositiveTimestamp a_conv;
25235         a_conv.inner = (void*)(a & (~1));
25236         a_conv.is_owned = false;
25237         LDKPositiveTimestamp b_conv;
25238         b_conv.inner = (void*)(b & (~1));
25239         b_conv.is_owned = false;
25240         jboolean ret_val = PositiveTimestamp_eq(&a_conv, &b_conv);
25241         return ret_val;
25242 }
25243
25244 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25245         LDKPositiveTimestamp orig_conv;
25246         orig_conv.inner = (void*)(orig & (~1));
25247         orig_conv.is_owned = false;
25248         LDKPositiveTimestamp ret_var = PositiveTimestamp_clone(&orig_conv);
25249         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25250         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25251         uint64_t ret_ref = (uint64_t)ret_var.inner;
25252         if (ret_var.is_owned) {
25253                 ret_ref |= 1;
25254         }
25255         return ret_ref;
25256 }
25257
25258 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25259         LDKSiPrefix* orig_conv = (LDKSiPrefix*)(orig & ~1);
25260         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_clone(orig_conv));
25261         return ret_conv;
25262 }
25263
25264 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SiPrefix_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
25265         LDKSiPrefix* a_conv = (LDKSiPrefix*)(a & ~1);
25266         LDKSiPrefix* b_conv = (LDKSiPrefix*)(b & ~1);
25267         jboolean ret_val = SiPrefix_eq(a_conv, b_conv);
25268         return ret_val;
25269 }
25270
25271 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SiPrefix_1multiplier(JNIEnv *env, jclass clz, int64_t this_arg) {
25272         LDKSiPrefix* this_arg_conv = (LDKSiPrefix*)(this_arg & ~1);
25273         int64_t ret_val = SiPrefix_multiplier(this_arg_conv);
25274         return ret_val;
25275 }
25276
25277 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25278         LDKCurrency* orig_conv = (LDKCurrency*)(orig & ~1);
25279         jclass ret_conv = LDKCurrency_to_java(env, Currency_clone(orig_conv));
25280         return ret_conv;
25281 }
25282
25283 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Currency_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
25284         LDKCurrency* a_conv = (LDKCurrency*)(a & ~1);
25285         LDKCurrency* b_conv = (LDKCurrency*)(b & ~1);
25286         jboolean ret_val = Currency_eq(a_conv, b_conv);
25287         return ret_val;
25288 }
25289
25290 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Sha256_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25291         LDKSha256 this_obj_conv;
25292         this_obj_conv.inner = (void*)(this_obj & (~1));
25293         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25294         Sha256_free(this_obj_conv);
25295 }
25296
25297 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Sha256_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
25298         LDKSha256 a_conv;
25299         a_conv.inner = (void*)(a & (~1));
25300         a_conv.is_owned = false;
25301         LDKSha256 b_conv;
25302         b_conv.inner = (void*)(b & (~1));
25303         b_conv.is_owned = false;
25304         jboolean ret_val = Sha256_eq(&a_conv, &b_conv);
25305         return ret_val;
25306 }
25307
25308 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sha256_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25309         LDKSha256 orig_conv;
25310         orig_conv.inner = (void*)(orig & (~1));
25311         orig_conv.is_owned = false;
25312         LDKSha256 ret_var = Sha256_clone(&orig_conv);
25313         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25314         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25315         uint64_t ret_ref = (uint64_t)ret_var.inner;
25316         if (ret_var.is_owned) {
25317                 ret_ref |= 1;
25318         }
25319         return ret_ref;
25320 }
25321
25322 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Description_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25323         LDKDescription this_obj_conv;
25324         this_obj_conv.inner = (void*)(this_obj & (~1));
25325         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25326         Description_free(this_obj_conv);
25327 }
25328
25329 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Description_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
25330         LDKDescription a_conv;
25331         a_conv.inner = (void*)(a & (~1));
25332         a_conv.is_owned = false;
25333         LDKDescription b_conv;
25334         b_conv.inner = (void*)(b & (~1));
25335         b_conv.is_owned = false;
25336         jboolean ret_val = Description_eq(&a_conv, &b_conv);
25337         return ret_val;
25338 }
25339
25340 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25341         LDKDescription orig_conv;
25342         orig_conv.inner = (void*)(orig & (~1));
25343         orig_conv.is_owned = false;
25344         LDKDescription ret_var = Description_clone(&orig_conv);
25345         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25346         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25347         uint64_t ret_ref = (uint64_t)ret_var.inner;
25348         if (ret_var.is_owned) {
25349                 ret_ref |= 1;
25350         }
25351         return ret_ref;
25352 }
25353
25354 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25355         LDKPayeePubKey this_obj_conv;
25356         this_obj_conv.inner = (void*)(this_obj & (~1));
25357         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25358         PayeePubKey_free(this_obj_conv);
25359 }
25360
25361 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
25362         LDKPayeePubKey a_conv;
25363         a_conv.inner = (void*)(a & (~1));
25364         a_conv.is_owned = false;
25365         LDKPayeePubKey b_conv;
25366         b_conv.inner = (void*)(b & (~1));
25367         b_conv.is_owned = false;
25368         jboolean ret_val = PayeePubKey_eq(&a_conv, &b_conv);
25369         return ret_val;
25370 }
25371
25372 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25373         LDKPayeePubKey orig_conv;
25374         orig_conv.inner = (void*)(orig & (~1));
25375         orig_conv.is_owned = false;
25376         LDKPayeePubKey ret_var = PayeePubKey_clone(&orig_conv);
25377         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25378         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25379         uint64_t ret_ref = (uint64_t)ret_var.inner;
25380         if (ret_var.is_owned) {
25381                 ret_ref |= 1;
25382         }
25383         return ret_ref;
25384 }
25385
25386 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25387         LDKExpiryTime this_obj_conv;
25388         this_obj_conv.inner = (void*)(this_obj & (~1));
25389         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25390         ExpiryTime_free(this_obj_conv);
25391 }
25392
25393 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
25394         LDKExpiryTime a_conv;
25395         a_conv.inner = (void*)(a & (~1));
25396         a_conv.is_owned = false;
25397         LDKExpiryTime b_conv;
25398         b_conv.inner = (void*)(b & (~1));
25399         b_conv.is_owned = false;
25400         jboolean ret_val = ExpiryTime_eq(&a_conv, &b_conv);
25401         return ret_val;
25402 }
25403
25404 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25405         LDKExpiryTime orig_conv;
25406         orig_conv.inner = (void*)(orig & (~1));
25407         orig_conv.is_owned = false;
25408         LDKExpiryTime ret_var = ExpiryTime_clone(&orig_conv);
25409         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25410         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25411         uint64_t ret_ref = (uint64_t)ret_var.inner;
25412         if (ret_var.is_owned) {
25413                 ret_ref |= 1;
25414         }
25415         return ret_ref;
25416 }
25417
25418 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25419         LDKMinFinalCltvExpiry this_obj_conv;
25420         this_obj_conv.inner = (void*)(this_obj & (~1));
25421         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25422         MinFinalCltvExpiry_free(this_obj_conv);
25423 }
25424
25425 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
25426         LDKMinFinalCltvExpiry a_conv;
25427         a_conv.inner = (void*)(a & (~1));
25428         a_conv.is_owned = false;
25429         LDKMinFinalCltvExpiry b_conv;
25430         b_conv.inner = (void*)(b & (~1));
25431         b_conv.is_owned = false;
25432         jboolean ret_val = MinFinalCltvExpiry_eq(&a_conv, &b_conv);
25433         return ret_val;
25434 }
25435
25436 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25437         LDKMinFinalCltvExpiry orig_conv;
25438         orig_conv.inner = (void*)(orig & (~1));
25439         orig_conv.is_owned = false;
25440         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_clone(&orig_conv);
25441         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25442         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25443         uint64_t ret_ref = (uint64_t)ret_var.inner;
25444         if (ret_var.is_owned) {
25445                 ret_ref |= 1;
25446         }
25447         return ret_ref;
25448 }
25449
25450 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Fallback_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
25451         if ((this_ptr & 1) != 0) return;
25452         LDKFallback this_ptr_conv = *(LDKFallback*)(((uint64_t)this_ptr) & ~1);
25453         FREE((void*)this_ptr);
25454         Fallback_free(this_ptr_conv);
25455 }
25456
25457 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25458         LDKFallback* orig_conv = (LDKFallback*)orig;
25459         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
25460         *ret_copy = Fallback_clone(orig_conv);
25461         uint64_t ret_ref = (uint64_t)ret_copy;
25462         return ret_ref;
25463 }
25464
25465 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Fallback_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
25466         LDKFallback* a_conv = (LDKFallback*)a;
25467         LDKFallback* b_conv = (LDKFallback*)b;
25468         jboolean ret_val = Fallback_eq(a_conv, b_conv);
25469         return ret_val;
25470 }
25471
25472 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25473         LDKInvoiceSignature this_obj_conv;
25474         this_obj_conv.inner = (void*)(this_obj & (~1));
25475         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25476         InvoiceSignature_free(this_obj_conv);
25477 }
25478
25479 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
25480         LDKInvoiceSignature a_conv;
25481         a_conv.inner = (void*)(a & (~1));
25482         a_conv.is_owned = false;
25483         LDKInvoiceSignature b_conv;
25484         b_conv.inner = (void*)(b & (~1));
25485         b_conv.is_owned = false;
25486         jboolean ret_val = InvoiceSignature_eq(&a_conv, &b_conv);
25487         return ret_val;
25488 }
25489
25490 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25491         LDKInvoiceSignature orig_conv;
25492         orig_conv.inner = (void*)(orig & (~1));
25493         orig_conv.is_owned = false;
25494         LDKInvoiceSignature ret_var = InvoiceSignature_clone(&orig_conv);
25495         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25496         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25497         uint64_t ret_ref = (uint64_t)ret_var.inner;
25498         if (ret_var.is_owned) {
25499                 ret_ref |= 1;
25500         }
25501         return ret_ref;
25502 }
25503
25504 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25505         LDKPrivateRoute this_obj_conv;
25506         this_obj_conv.inner = (void*)(this_obj & (~1));
25507         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25508         PrivateRoute_free(this_obj_conv);
25509 }
25510
25511 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
25512         LDKPrivateRoute a_conv;
25513         a_conv.inner = (void*)(a & (~1));
25514         a_conv.is_owned = false;
25515         LDKPrivateRoute b_conv;
25516         b_conv.inner = (void*)(b & (~1));
25517         b_conv.is_owned = false;
25518         jboolean ret_val = PrivateRoute_eq(&a_conv, &b_conv);
25519         return ret_val;
25520 }
25521
25522 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25523         LDKPrivateRoute orig_conv;
25524         orig_conv.inner = (void*)(orig & (~1));
25525         orig_conv.is_owned = false;
25526         LDKPrivateRoute ret_var = PrivateRoute_clone(&orig_conv);
25527         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25528         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25529         uint64_t ret_ref = (uint64_t)ret_var.inner;
25530         if (ret_var.is_owned) {
25531                 ret_ref |= 1;
25532         }
25533         return ret_ref;
25534 }
25535
25536 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1into_1parts(JNIEnv *env, jclass clz, int64_t this_arg) {
25537         LDKSignedRawInvoice this_arg_conv;
25538         this_arg_conv.inner = (void*)(this_arg & (~1));
25539         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
25540         this_arg_conv = SignedRawInvoice_clone(&this_arg_conv);
25541         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_ref = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
25542         *ret_ref = SignedRawInvoice_into_parts(this_arg_conv);
25543         return (uint64_t)ret_ref;
25544 }
25545
25546 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1raw_1invoice(JNIEnv *env, jclass clz, int64_t this_arg) {
25547         LDKSignedRawInvoice this_arg_conv;
25548         this_arg_conv.inner = (void*)(this_arg & (~1));
25549         this_arg_conv.is_owned = false;
25550         LDKRawInvoice ret_var = SignedRawInvoice_raw_invoice(&this_arg_conv);
25551         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25552         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25553         uint64_t ret_ref = (uint64_t)ret_var.inner;
25554         if (ret_var.is_owned) {
25555                 ret_ref |= 1;
25556         }
25557         return ret_ref;
25558 }
25559
25560 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
25561         LDKSignedRawInvoice this_arg_conv;
25562         this_arg_conv.inner = (void*)(this_arg & (~1));
25563         this_arg_conv.is_owned = false;
25564         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
25565         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *SignedRawInvoice_hash(&this_arg_conv));
25566         return ret_arr;
25567 }
25568
25569 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
25570         LDKSignedRawInvoice this_arg_conv;
25571         this_arg_conv.inner = (void*)(this_arg & (~1));
25572         this_arg_conv.is_owned = false;
25573         LDKInvoiceSignature ret_var = SignedRawInvoice_signature(&this_arg_conv);
25574         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25575         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25576         uint64_t ret_ref = (uint64_t)ret_var.inner;
25577         if (ret_var.is_owned) {
25578                 ret_ref |= 1;
25579         }
25580         return ret_ref;
25581 }
25582
25583 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1recover_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
25584         LDKSignedRawInvoice this_arg_conv;
25585         this_arg_conv.inner = (void*)(this_arg & (~1));
25586         this_arg_conv.is_owned = false;
25587         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
25588         *ret_conv = SignedRawInvoice_recover_payee_pub_key(&this_arg_conv);
25589         return (uint64_t)ret_conv;
25590 }
25591
25592 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1check_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
25593         LDKSignedRawInvoice this_arg_conv;
25594         this_arg_conv.inner = (void*)(this_arg & (~1));
25595         this_arg_conv.is_owned = false;
25596         jboolean ret_val = SignedRawInvoice_check_signature(&this_arg_conv);
25597         return ret_val;
25598 }
25599
25600 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
25601         LDKRawInvoice this_arg_conv;
25602         this_arg_conv.inner = (void*)(this_arg & (~1));
25603         this_arg_conv.is_owned = false;
25604         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
25605         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, RawInvoice_hash(&this_arg_conv).data);
25606         return ret_arr;
25607 }
25608
25609 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
25610         LDKRawInvoice this_arg_conv;
25611         this_arg_conv.inner = (void*)(this_arg & (~1));
25612         this_arg_conv.is_owned = false;
25613         LDKSha256 ret_var = RawInvoice_payment_hash(&this_arg_conv);
25614         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25615         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25616         uint64_t ret_ref = (uint64_t)ret_var.inner;
25617         if (ret_var.is_owned) {
25618                 ret_ref |= 1;
25619         }
25620         return ret_ref;
25621 }
25622
25623 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1description(JNIEnv *env, jclass clz, int64_t this_arg) {
25624         LDKRawInvoice this_arg_conv;
25625         this_arg_conv.inner = (void*)(this_arg & (~1));
25626         this_arg_conv.is_owned = false;
25627         LDKDescription ret_var = RawInvoice_description(&this_arg_conv);
25628         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25629         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25630         uint64_t ret_ref = (uint64_t)ret_var.inner;
25631         if (ret_var.is_owned) {
25632                 ret_ref |= 1;
25633         }
25634         return ret_ref;
25635 }
25636
25637 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
25638         LDKRawInvoice this_arg_conv;
25639         this_arg_conv.inner = (void*)(this_arg & (~1));
25640         this_arg_conv.is_owned = false;
25641         LDKPayeePubKey ret_var = RawInvoice_payee_pub_key(&this_arg_conv);
25642         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25643         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25644         uint64_t ret_ref = (uint64_t)ret_var.inner;
25645         if (ret_var.is_owned) {
25646                 ret_ref |= 1;
25647         }
25648         return ret_ref;
25649 }
25650
25651 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1description_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
25652         LDKRawInvoice this_arg_conv;
25653         this_arg_conv.inner = (void*)(this_arg & (~1));
25654         this_arg_conv.is_owned = false;
25655         LDKSha256 ret_var = RawInvoice_description_hash(&this_arg_conv);
25656         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25657         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25658         uint64_t ret_ref = (uint64_t)ret_var.inner;
25659         if (ret_var.is_owned) {
25660                 ret_ref |= 1;
25661         }
25662         return ret_ref;
25663 }
25664
25665 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
25666         LDKRawInvoice this_arg_conv;
25667         this_arg_conv.inner = (void*)(this_arg & (~1));
25668         this_arg_conv.is_owned = false;
25669         LDKExpiryTime ret_var = RawInvoice_expiry_time(&this_arg_conv);
25670         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25671         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25672         uint64_t ret_ref = (uint64_t)ret_var.inner;
25673         if (ret_var.is_owned) {
25674                 ret_ref |= 1;
25675         }
25676         return ret_ref;
25677 }
25678
25679 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1min_1final_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_arg) {
25680         LDKRawInvoice this_arg_conv;
25681         this_arg_conv.inner = (void*)(this_arg & (~1));
25682         this_arg_conv.is_owned = false;
25683         LDKMinFinalCltvExpiry ret_var = RawInvoice_min_final_cltv_expiry(&this_arg_conv);
25684         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25685         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25686         uint64_t ret_ref = (uint64_t)ret_var.inner;
25687         if (ret_var.is_owned) {
25688                 ret_ref |= 1;
25689         }
25690         return ret_ref;
25691 }
25692
25693 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
25694         LDKRawInvoice this_arg_conv;
25695         this_arg_conv.inner = (void*)(this_arg & (~1));
25696         this_arg_conv.is_owned = false;
25697         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
25698         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, RawInvoice_payment_secret(&this_arg_conv).data);
25699         return ret_arr;
25700 }
25701
25702 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
25703         LDKRawInvoice this_arg_conv;
25704         this_arg_conv.inner = (void*)(this_arg & (~1));
25705         this_arg_conv.is_owned = false;
25706         LDKInvoiceFeatures ret_var = RawInvoice_features(&this_arg_conv);
25707         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25708         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25709         uint64_t ret_ref = (uint64_t)ret_var.inner;
25710         if (ret_var.is_owned) {
25711                 ret_ref |= 1;
25712         }
25713         return ret_ref;
25714 }
25715
25716 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1private_1routes(JNIEnv *env, jclass clz, int64_t this_arg) {
25717         LDKRawInvoice this_arg_conv;
25718         this_arg_conv.inner = (void*)(this_arg & (~1));
25719         this_arg_conv.is_owned = false;
25720         LDKCVec_PrivateRouteZ ret_var = RawInvoice_private_routes(&this_arg_conv);
25721         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
25722         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
25723         for (size_t o = 0; o < ret_var.datalen; o++) {
25724                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
25725                 CHECK((((uint64_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25726                 CHECK((((uint64_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25727                 uint64_t ret_conv_14_ref = (uint64_t)ret_conv_14_var.inner;
25728                 if (ret_conv_14_var.is_owned) {
25729                         ret_conv_14_ref |= 1;
25730                 }
25731                 ret_arr_ptr[o] = ret_conv_14_ref;
25732         }
25733         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
25734         FREE(ret_var.data);
25735         return ret_arr;
25736 }
25737
25738 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1amount_1pico_1btc(JNIEnv *env, jclass clz, int64_t this_arg) {
25739         LDKRawInvoice this_arg_conv;
25740         this_arg_conv.inner = (void*)(this_arg & (~1));
25741         this_arg_conv.is_owned = false;
25742         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
25743         *ret_copy = RawInvoice_amount_pico_btc(&this_arg_conv);
25744         uint64_t ret_ref = (uint64_t)ret_copy;
25745         return ret_ref;
25746 }
25747
25748 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_RawInvoice_1currency(JNIEnv *env, jclass clz, int64_t this_arg) {
25749         LDKRawInvoice this_arg_conv;
25750         this_arg_conv.inner = (void*)(this_arg & (~1));
25751         this_arg_conv.is_owned = false;
25752         jclass ret_conv = LDKCurrency_to_java(env, RawInvoice_currency(&this_arg_conv));
25753         return ret_conv;
25754 }
25755
25756 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1from_1unix_1timestamp(JNIEnv *env, jclass clz, int64_t unix_seconds) {
25757         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
25758         *ret_conv = PositiveTimestamp_from_unix_timestamp(unix_seconds);
25759         return (uint64_t)ret_conv;
25760 }
25761
25762 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1from_1system_1time(JNIEnv *env, jclass clz, int64_t time) {
25763         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
25764         *ret_conv = PositiveTimestamp_from_system_time(time);
25765         return (uint64_t)ret_conv;
25766 }
25767
25768 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1as_1unix_1timestamp(JNIEnv *env, jclass clz, int64_t this_arg) {
25769         LDKPositiveTimestamp this_arg_conv;
25770         this_arg_conv.inner = (void*)(this_arg & (~1));
25771         this_arg_conv.is_owned = false;
25772         int64_t ret_val = PositiveTimestamp_as_unix_timestamp(&this_arg_conv);
25773         return ret_val;
25774 }
25775
25776 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1as_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
25777         LDKPositiveTimestamp this_arg_conv;
25778         this_arg_conv.inner = (void*)(this_arg & (~1));
25779         this_arg_conv.is_owned = false;
25780         int64_t ret_val = PositiveTimestamp_as_time(&this_arg_conv);
25781         return ret_val;
25782 }
25783
25784 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1into_1signed_1raw(JNIEnv *env, jclass clz, int64_t this_arg) {
25785         LDKInvoice this_arg_conv;
25786         this_arg_conv.inner = (void*)(this_arg & (~1));
25787         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
25788         this_arg_conv = Invoice_clone(&this_arg_conv);
25789         LDKSignedRawInvoice ret_var = Invoice_into_signed_raw(this_arg_conv);
25790         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25791         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25792         uint64_t ret_ref = (uint64_t)ret_var.inner;
25793         if (ret_var.is_owned) {
25794                 ret_ref |= 1;
25795         }
25796         return ret_ref;
25797 }
25798
25799 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1check_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
25800         LDKInvoice this_arg_conv;
25801         this_arg_conv.inner = (void*)(this_arg & (~1));
25802         this_arg_conv.is_owned = false;
25803         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
25804         *ret_conv = Invoice_check_signature(&this_arg_conv);
25805         return (uint64_t)ret_conv;
25806 }
25807
25808 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1from_1signed(JNIEnv *env, jclass clz, int64_t signed_invoice) {
25809         LDKSignedRawInvoice signed_invoice_conv;
25810         signed_invoice_conv.inner = (void*)(signed_invoice & (~1));
25811         signed_invoice_conv.is_owned = (signed_invoice & 1) || (signed_invoice == 0);
25812         signed_invoice_conv = SignedRawInvoice_clone(&signed_invoice_conv);
25813         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
25814         *ret_conv = Invoice_from_signed(signed_invoice_conv);
25815         return (uint64_t)ret_conv;
25816 }
25817
25818 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1timestamp(JNIEnv *env, jclass clz, int64_t this_arg) {
25819         LDKInvoice this_arg_conv;
25820         this_arg_conv.inner = (void*)(this_arg & (~1));
25821         this_arg_conv.is_owned = false;
25822         int64_t ret_val = Invoice_timestamp(&this_arg_conv);
25823         return ret_val;
25824 }
25825
25826 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
25827         LDKInvoice this_arg_conv;
25828         this_arg_conv.inner = (void*)(this_arg & (~1));
25829         this_arg_conv.is_owned = false;
25830         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
25831         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *Invoice_payment_hash(&this_arg_conv));
25832         return ret_arr;
25833 }
25834
25835 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
25836         LDKInvoice this_arg_conv;
25837         this_arg_conv.inner = (void*)(this_arg & (~1));
25838         this_arg_conv.is_owned = false;
25839         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
25840         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, Invoice_payee_pub_key(&this_arg_conv).compressed_form);
25841         return ret_arr;
25842 }
25843
25844 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
25845         LDKInvoice this_arg_conv;
25846         this_arg_conv.inner = (void*)(this_arg & (~1));
25847         this_arg_conv.is_owned = false;
25848         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
25849         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, Invoice_payment_secret(&this_arg_conv).data);
25850         return ret_arr;
25851 }
25852
25853 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
25854         LDKInvoice this_arg_conv;
25855         this_arg_conv.inner = (void*)(this_arg & (~1));
25856         this_arg_conv.is_owned = false;
25857         LDKInvoiceFeatures ret_var = Invoice_features(&this_arg_conv);
25858         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25859         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25860         uint64_t ret_ref = (uint64_t)ret_var.inner;
25861         if (ret_var.is_owned) {
25862                 ret_ref |= 1;
25863         }
25864         return ret_ref;
25865 }
25866
25867 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1recover_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
25868         LDKInvoice this_arg_conv;
25869         this_arg_conv.inner = (void*)(this_arg & (~1));
25870         this_arg_conv.is_owned = false;
25871         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
25872         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, Invoice_recover_payee_pub_key(&this_arg_conv).compressed_form);
25873         return ret_arr;
25874 }
25875
25876 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
25877         LDKInvoice this_arg_conv;
25878         this_arg_conv.inner = (void*)(this_arg & (~1));
25879         this_arg_conv.is_owned = false;
25880         int64_t ret_val = Invoice_expiry_time(&this_arg_conv);
25881         return ret_val;
25882 }
25883
25884 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1min_1final_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_arg) {
25885         LDKInvoice this_arg_conv;
25886         this_arg_conv.inner = (void*)(this_arg & (~1));
25887         this_arg_conv.is_owned = false;
25888         int64_t ret_val = Invoice_min_final_cltv_expiry(&this_arg_conv);
25889         return ret_val;
25890 }
25891
25892 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1private_1routes(JNIEnv *env, jclass clz, int64_t this_arg) {
25893         LDKInvoice this_arg_conv;
25894         this_arg_conv.inner = (void*)(this_arg & (~1));
25895         this_arg_conv.is_owned = false;
25896         LDKCVec_PrivateRouteZ ret_var = Invoice_private_routes(&this_arg_conv);
25897         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
25898         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
25899         for (size_t o = 0; o < ret_var.datalen; o++) {
25900                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
25901                 CHECK((((uint64_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25902                 CHECK((((uint64_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25903                 uint64_t ret_conv_14_ref = (uint64_t)ret_conv_14_var.inner;
25904                 if (ret_conv_14_var.is_owned) {
25905                         ret_conv_14_ref |= 1;
25906                 }
25907                 ret_arr_ptr[o] = ret_conv_14_ref;
25908         }
25909         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
25910         FREE(ret_var.data);
25911         return ret_arr;
25912 }
25913
25914 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1route_1hints(JNIEnv *env, jclass clz, int64_t this_arg) {
25915         LDKInvoice this_arg_conv;
25916         this_arg_conv.inner = (void*)(this_arg & (~1));
25917         this_arg_conv.is_owned = false;
25918         LDKCVec_RouteHintZ ret_var = Invoice_route_hints(&this_arg_conv);
25919         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
25920         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
25921         for (size_t l = 0; l < ret_var.datalen; l++) {
25922                 LDKRouteHint ret_conv_11_var = ret_var.data[l];
25923                 CHECK((((uint64_t)ret_conv_11_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25924                 CHECK((((uint64_t)&ret_conv_11_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25925                 uint64_t ret_conv_11_ref = (uint64_t)ret_conv_11_var.inner;
25926                 if (ret_conv_11_var.is_owned) {
25927                         ret_conv_11_ref |= 1;
25928                 }
25929                 ret_arr_ptr[l] = ret_conv_11_ref;
25930         }
25931         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
25932         FREE(ret_var.data);
25933         return ret_arr;
25934 }
25935
25936 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Invoice_1currency(JNIEnv *env, jclass clz, int64_t this_arg) {
25937         LDKInvoice this_arg_conv;
25938         this_arg_conv.inner = (void*)(this_arg & (~1));
25939         this_arg_conv.is_owned = false;
25940         jclass ret_conv = LDKCurrency_to_java(env, Invoice_currency(&this_arg_conv));
25941         return ret_conv;
25942 }
25943
25944 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1amount_1pico_1btc(JNIEnv *env, jclass clz, int64_t this_arg) {
25945         LDKInvoice this_arg_conv;
25946         this_arg_conv.inner = (void*)(this_arg & (~1));
25947         this_arg_conv.is_owned = false;
25948         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
25949         *ret_copy = Invoice_amount_pico_btc(&this_arg_conv);
25950         uint64_t ret_ref = (uint64_t)ret_copy;
25951         return ret_ref;
25952 }
25953
25954 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1new(JNIEnv *env, jclass clz, jstring description) {
25955         LDKStr description_conv = java_to_owned_str(env, description);
25956         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
25957         *ret_conv = Description_new(description_conv);
25958         return (uint64_t)ret_conv;
25959 }
25960
25961 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Description_1into_1inner(JNIEnv *env, jclass clz, int64_t this_arg) {
25962         LDKDescription this_arg_conv;
25963         this_arg_conv.inner = (void*)(this_arg & (~1));
25964         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
25965         this_arg_conv = Description_clone(&this_arg_conv);
25966         LDKStr ret_str = Description_into_inner(this_arg_conv);
25967         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
25968         return ret_conv;
25969 }
25970
25971 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1from_1seconds(JNIEnv *env, jclass clz, int64_t seconds) {
25972         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
25973         *ret_conv = ExpiryTime_from_seconds(seconds);
25974         return (uint64_t)ret_conv;
25975 }
25976
25977 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1from_1duration(JNIEnv *env, jclass clz, int64_t duration) {
25978         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
25979         *ret_conv = ExpiryTime_from_duration(duration);
25980         return (uint64_t)ret_conv;
25981 }
25982
25983 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1as_1seconds(JNIEnv *env, jclass clz, int64_t this_arg) {
25984         LDKExpiryTime this_arg_conv;
25985         this_arg_conv.inner = (void*)(this_arg & (~1));
25986         this_arg_conv.is_owned = false;
25987         int64_t ret_val = ExpiryTime_as_seconds(&this_arg_conv);
25988         return ret_val;
25989 }
25990
25991 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1as_1duration(JNIEnv *env, jclass clz, int64_t this_arg) {
25992         LDKExpiryTime this_arg_conv;
25993         this_arg_conv.inner = (void*)(this_arg & (~1));
25994         this_arg_conv.is_owned = false;
25995         int64_t ret_val = ExpiryTime_as_duration(&this_arg_conv);
25996         return ret_val;
25997 }
25998
25999 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1new(JNIEnv *env, jclass clz, int64_t hops) {
26000         LDKRouteHint hops_conv;
26001         hops_conv.inner = (void*)(hops & (~1));
26002         hops_conv.is_owned = (hops & 1) || (hops == 0);
26003         hops_conv = RouteHint_clone(&hops_conv);
26004         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
26005         *ret_conv = PrivateRoute_new(hops_conv);
26006         return (uint64_t)ret_conv;
26007 }
26008
26009 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1into_1inner(JNIEnv *env, jclass clz, int64_t this_arg) {
26010         LDKPrivateRoute this_arg_conv;
26011         this_arg_conv.inner = (void*)(this_arg & (~1));
26012         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
26013         this_arg_conv = PrivateRoute_clone(&this_arg_conv);
26014         LDKRouteHint ret_var = PrivateRoute_into_inner(this_arg_conv);
26015         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26016         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26017         uint64_t ret_ref = (uint64_t)ret_var.inner;
26018         if (ret_var.is_owned) {
26019                 ret_ref |= 1;
26020         }
26021         return ret_ref;
26022 }
26023
26024 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26025         LDKCreationError* orig_conv = (LDKCreationError*)(orig & ~1);
26026         jclass ret_conv = LDKCreationError_to_java(env, CreationError_clone(orig_conv));
26027         return ret_conv;
26028 }
26029
26030 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CreationError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
26031         LDKCreationError* a_conv = (LDKCreationError*)(a & ~1);
26032         LDKCreationError* b_conv = (LDKCreationError*)(b & ~1);
26033         jboolean ret_val = CreationError_eq(a_conv, b_conv);
26034         return ret_val;
26035 }
26036
26037 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_CreationError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
26038         LDKCreationError* o_conv = (LDKCreationError*)(o & ~1);
26039         LDKStr ret_str = CreationError_to_str(o_conv);
26040         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
26041         return ret_conv;
26042 }
26043
26044 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26045         LDKSemanticError* orig_conv = (LDKSemanticError*)(orig & ~1);
26046         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_clone(orig_conv));
26047         return ret_conv;
26048 }
26049
26050 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SemanticError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
26051         LDKSemanticError* a_conv = (LDKSemanticError*)(a & ~1);
26052         LDKSemanticError* b_conv = (LDKSemanticError*)(b & ~1);
26053         jboolean ret_val = SemanticError_eq(a_conv, b_conv);
26054         return ret_val;
26055 }
26056
26057 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SemanticError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
26058         LDKSemanticError* o_conv = (LDKSemanticError*)(o & ~1);
26059         LDKStr ret_str = SemanticError_to_str(o_conv);
26060         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
26061         return ret_conv;
26062 }
26063
26064 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
26065         if ((this_ptr & 1) != 0) return;
26066         LDKSignOrCreationError this_ptr_conv = *(LDKSignOrCreationError*)(((uint64_t)this_ptr) & ~1);
26067         FREE((void*)this_ptr);
26068         SignOrCreationError_free(this_ptr_conv);
26069 }
26070
26071 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26072         LDKSignOrCreationError* orig_conv = (LDKSignOrCreationError*)orig;
26073         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
26074         *ret_copy = SignOrCreationError_clone(orig_conv);
26075         uint64_t ret_ref = (uint64_t)ret_copy;
26076         return ret_ref;
26077 }
26078
26079 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
26080         LDKSignOrCreationError* a_conv = (LDKSignOrCreationError*)a;
26081         LDKSignOrCreationError* b_conv = (LDKSignOrCreationError*)b;
26082         jboolean ret_val = SignOrCreationError_eq(a_conv, b_conv);
26083         return ret_val;
26084 }
26085
26086 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
26087         LDKSignOrCreationError* o_conv = (LDKSignOrCreationError*)o;
26088         LDKStr ret_str = SignOrCreationError_to_str(o_conv);
26089         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
26090         return ret_conv;
26091 }
26092
26093 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) {
26094         LDKChannelManager channelmanager_conv;
26095         channelmanager_conv.inner = (void*)(channelmanager & (~1));
26096         channelmanager_conv.is_owned = false;
26097         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
26098         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
26099                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26100                 LDKKeysInterface_JCalls_clone(keys_manager_conv.this_arg);
26101         }
26102         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
26103         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(((uint64_t)amt_msat) & ~1);
26104         LDKStr description_conv = java_to_owned_str(env, description);
26105         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
26106         *ret_conv = create_invoice_from_channelmanager(&channelmanager_conv, keys_manager_conv, network_conv, amt_msat_conv, description_conv);
26107         return (uint64_t)ret_conv;
26108 }
26109
26110 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SiPrefix_1from_1str(JNIEnv *env, jclass clz, jstring s) {
26111         LDKStr s_conv = java_to_owned_str(env, s);
26112         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
26113         *ret_conv = SiPrefix_from_str(s_conv);
26114         return (uint64_t)ret_conv;
26115 }
26116
26117 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1from_1str(JNIEnv *env, jclass clz, jstring s) {
26118         LDKStr s_conv = java_to_owned_str(env, s);
26119         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
26120         *ret_conv = Invoice_from_str(s_conv);
26121         return (uint64_t)ret_conv;
26122 }
26123
26124 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1from_1str(JNIEnv *env, jclass clz, jstring s) {
26125         LDKStr s_conv = java_to_owned_str(env, s);
26126         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
26127         *ret_conv = SignedRawInvoice_from_str(s_conv);
26128         return (uint64_t)ret_conv;
26129 }
26130
26131 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Invoice_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
26132         LDKInvoice o_conv;
26133         o_conv.inner = (void*)(o & (~1));
26134         o_conv.is_owned = false;
26135         LDKStr ret_str = Invoice_to_str(&o_conv);
26136         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
26137         return ret_conv;
26138 }
26139
26140 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
26141         LDKSignedRawInvoice o_conv;
26142         o_conv.inner = (void*)(o & (~1));
26143         o_conv.is_owned = false;
26144         LDKStr ret_str = SignedRawInvoice_to_str(&o_conv);
26145         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
26146         return ret_conv;
26147 }
26148
26149 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Currency_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
26150         LDKCurrency* o_conv = (LDKCurrency*)(o & ~1);
26151         LDKStr ret_str = Currency_to_str(o_conv);
26152         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
26153         return ret_conv;
26154 }
26155
26156 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SiPrefix_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
26157         LDKSiPrefix* o_conv = (LDKSiPrefix*)(o & ~1);
26158         LDKStr ret_str = SiPrefix_to_str(o_conv);
26159         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
26160         return ret_conv;
26161 }
26162